123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- import React, { useState, useEffect } from 'react';
- import { Popover, Radio, Avatar, Tooltip, Empty, Table } from 'antd';
- import style from '../index.less';
- import moment from 'moment';
- import { ChartBoxTitle } from './ChartBox';
- import { useModel, useRequest } from '@umijs/max';
- import { queryProjectFileList } from '@/Project/services/FileAdmin';
- import { getDailyList } from '@/Project/services/DataMeter';
- function Other(props: DataMeter.IModelsProps) {
- const { child, setActive, layout, projectId, subModule } = props;
- const [active, setSelfActive] = useState(
- layout.active || child.find((item) => item.show)?.key,
- );
- const [showTabs, setShowTabs] = useState(false);
- const [title, setTitle] = useState('');
- const { getProject } = useModel('project');
- const id = projectId || -1;
- const fileListRequest = useRequest(queryProjectFileList, {
- defaultParams: [
- {
- fileType: 29,
- projectId: id,
- deviceCode: -1,
- },
- ],
- });
- const dailyListRequest = useRequest(getDailyList, {
- defaultParams: [
- {
- projectId: id,
- },
- ],
- });
- const fileList = fileListRequest.data || [];
- const dailyList = dailyListRequest.data?.list || [];
- useEffect(() => {
- const current = child.find(
- (item: DataMeter.ILayoutChild) => item.key == active,
- );
- if (current) setTitle(current.title);
- }, [active]);
- const getTitle = (title: string) => {
- return (
- <Popover
- placement="topLeft"
- content={<div style={{ maxWidth: '2rem' }}>{title}</div>}
- >
- {title}
- </Popover>
- );
- };
- var content;
- switch (active) {
- case 1:
- if (fileList.length > 0) {
- content = (
- <>
- <table
- className={style.other}
- style={{ width: 'calc(100% - 16px)' }}
- >
- <thead>
- <tr>
- <th
- style={
- subModule == 0
- ? { width: '40%', paddingRight: '10px' }
- : { width: '50%', paddingRight: '10px' }
- }
- >
- 文件名称
- </th>
- <th
- style={
- subModule == 0
- ? { width: '20%', paddingRight: '10px' }
- : { width: '50%', paddingRight: '10px' }
- }
- >
- 日期
- </th>
- {subModule == 0 && (
- <th
- style={
- subModule == 0
- ? { width: '40%', paddingRight: '10px' }
- : { width: '50%', paddingRight: '10px' }
- }
- >
- 项目名称
- </th>
- )}
- </tr>
- </thead>
- </table>
- <div
- style={{
- overflowY: 'scroll',
- height: 'calc(100% - 24px)',
- }}
- >
- <table className={style.other}>
- <tbody>
- {fileList.map((item: any) => (
- <>
- <tr className={style.messageContent} key={item.Id}>
- <td
- style={
- subModule == 0
- ? { width: '40%', paddingRight: '10px' }
- : { width: '50%', paddingRight: '10px' }
- }
- className={style.alarmTitle}
- >
- {getTitle(item.Name)}
- </td>
- <td
- style={
- subModule == 0
- ? { width: '20%', paddingRight: '10px' }
- : { width: '50%', paddingRight: '10px' }
- }
- >
- {moment(item.CreatedTime).format('YYYY-MM-DD')}
- </td>
- {subModule == 0 && (
- <td
- style={{ width: '40%', paddingRight: '10px' }}
- className={style.alarmTitle}
- >
- {getTitle(getProject(item.ProjectId)?.Name || '无')}
- </td>
- )}
- </tr>
- </>
- ))}
- </tbody>
- </table>
- </div>
- </>
- );
- } else {
- content = <Empty />;
- }
- break;
- case 2:
- if (dailyList.length > 0) {
- content = (
- <>
- <table
- className={style.other}
- style={{ width: 'calc(100% - 16px)' }}
- >
- <thead>
- <tr>
- <th
- style={
- subModule == 0
- ? { width: '25%', paddingRight: '10px' }
- : { width: '50%', paddingRight: '10px' }
- }
- >
- 创建人
- </th>
- <th
- style={
- subModule == 0
- ? { width: '20%', paddingRight: '10px' }
- : { width: '50%', paddingRight: '10px' }
- }
- >
- 日期
- </th>
- {subModule == 0 && (
- <th style={{ width: '55%', paddingRight: '10px' }}>
- 项目名称
- </th>
- )}
- </tr>
- </thead>
- </table>
- <div
- style={{
- overflowY: 'scroll',
- height: 'calc(100% - 24px)',
- }}
- >
- <table className={style.other}>
- <tbody>
- {dailyList.map((item: any) => (
- <>
- <tr className={style.messageContent} key={item.id}>
- <td
- style={
- subModule == 0
- ? { width: '25%', paddingRight: '10px' }
- : { width: '50%', paddingRight: '10px' }
- }
- className={style.alarmTitle}
- >
- {getTitle(item.CreatorUser.CName)}
- </td>
- <td
- style={
- subModule == 0
- ? { width: '20%', paddingRight: '10px' }
- : { width: '50%', paddingRight: '10px' }
- }
- >
- {moment(item.ReportDate).format('YYYY-MM-DD')}
- </td>
- {subModule == 0 && (
- <td
- style={{ width: '55%', paddingRight: '10px' }}
- className={style.alarmTitle}
- >
- {getTitle(getProject(item.ProjectId)?.Name || '无')}
- </td>
- )}
- </tr>
- </>
- ))}
- </tbody>
- </table>
- </div>
- </>
- );
- } else {
- content = <Empty />;
- }
- break;
- }
- return (
- <div className={style.modelBox}>
- <ChartBoxTitle
- title={title}
- showTabs={showTabs}
- setShowTabs={setShowTabs}
- width={layout.w}
- ></ChartBoxTitle>
- {showTabs && (
- <ul className={style.tabsList}>
- {(child || [])
- .filter((item: DataMeter.ILayoutChild) => item.show)
- .map((item: DataMeter.ILayoutChild, index: number) => (
- <li
- key={index}
- className={`${active == item.key ? style.active : ''}`}
- onClick={() => {
- setActive(item.key);
- setSelfActive(item.key);
- }}
- >
- {item.title}
- </li>
- ))}
- </ul>
- )}
- <div
- style={{
- paddingTop: '10px',
- paddingLeft: '14px',
- flex: 1,
- height: 0,
- }}
- >
- {content}
- </div>
- </div>
- );
- }
- export default Other;
|