|
@@ -1,26 +1,25 @@
|
|
|
import TabsContent from '@/components/TabsContent';
|
|
|
+import ThresholdDetail from '@/components/ThresholdDetail';
|
|
|
import { UnityAction } from '@/utils/utils';
|
|
|
import { connect } from '@umijs/max';
|
|
|
import { Spin, Table, Tabs } from 'antd';
|
|
|
import { useEffect, useMemo, useState } from 'react';
|
|
|
import styles from './DeviceAnalysis.less';
|
|
|
-import ThresholdBar from './ThresholdBar';
|
|
|
const { TabPane } = Tabs;
|
|
|
|
|
|
const DeviceAnalysis = (props) => {
|
|
|
const Status = [
|
|
|
- { name: '异常', type: '1', data: [] },
|
|
|
- { name: '全部', type: '2', data: [] },
|
|
|
+ { name: '异常', type: '0', data: [] },
|
|
|
+ { name: '全部', type: '1 ', data: [] },
|
|
|
];
|
|
|
|
|
|
- const { list = [], processList, loading } = props;
|
|
|
+ const { loading, autoReport } = props;
|
|
|
const [selectedRowKeys, setSelectedRowKeys] = useState([]);
|
|
|
const [tab, setTab] = useState('1');
|
|
|
|
|
|
const columns = [
|
|
|
{
|
|
|
title: '设备名称',
|
|
|
- width: '20%',
|
|
|
render: (record) => (
|
|
|
<div>
|
|
|
{record.DeviceName}({record.DeviceCode})
|
|
@@ -30,32 +29,59 @@ const DeviceAnalysis = (props) => {
|
|
|
{
|
|
|
title: '巡检项',
|
|
|
width: '14%',
|
|
|
- dataIndex: 'ProcessSectionId',
|
|
|
- render: (id) => {
|
|
|
- return processList.find((item) => item.id == id)?.name;
|
|
|
- },
|
|
|
+ dataIndex: 'TemplateItem',
|
|
|
+ render: (TemplateItem) => <div>{TemplateItem.Name}</div>,
|
|
|
},
|
|
|
{
|
|
|
title: '设定值范围',
|
|
|
- width: '14%',
|
|
|
- render: (record) => {
|
|
|
- let thresholds = record.fault_range.split(',');
|
|
|
- return (
|
|
|
- <div>
|
|
|
- {record.fault_range && (
|
|
|
- <ThresholdBar
|
|
|
- current={record.fault_result}
|
|
|
- thresholds={thresholds}
|
|
|
- />
|
|
|
- )}
|
|
|
- </div>
|
|
|
- );
|
|
|
- },
|
|
|
+ width: '40%',
|
|
|
+ render: (record) => (
|
|
|
+ <ThresholdDetail
|
|
|
+ current={record.Value || 0}
|
|
|
+ data={record || {}}
|
|
|
+ // onClick={() => onClickThreshold(record)}
|
|
|
+ />
|
|
|
+ ),
|
|
|
},
|
|
|
{
|
|
|
title: '状态',
|
|
|
- width: '20%',
|
|
|
- dataIndex: 'Reason',
|
|
|
+ width: '14%',
|
|
|
+ dataIndex: 'Status',
|
|
|
+ render: (Status) => {
|
|
|
+ switch (Status) {
|
|
|
+ case -1:
|
|
|
+ case 0:
|
|
|
+ return (
|
|
|
+ <div>
|
|
|
+ <i
|
|
|
+ className={styles.iconStatus}
|
|
|
+ style={{ background: '#12CEB3' }}
|
|
|
+ ></i>
|
|
|
+ 正常
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+ case 1:
|
|
|
+ return (
|
|
|
+ <div>
|
|
|
+ <i
|
|
|
+ className={styles.iconStatus}
|
|
|
+ style={{ background: '#FE5850' }}
|
|
|
+ ></i>
|
|
|
+ 异常
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+ case 2:
|
|
|
+ return (
|
|
|
+ <div>
|
|
|
+ <i
|
|
|
+ className={styles.iconStatus}
|
|
|
+ style={{ background: '#FFE26D' }}
|
|
|
+ ></i>
|
|
|
+ 警告
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
];
|
|
|
|
|
@@ -81,27 +107,15 @@ const DeviceAnalysis = (props) => {
|
|
|
};
|
|
|
|
|
|
const data = useMemo(() => {
|
|
|
- return Status.map((item, idx) => {
|
|
|
- const data = list?.filter((cur) => cur.grade_alarm == item.type);
|
|
|
- return { ...item, data };
|
|
|
- });
|
|
|
- }, [list]);
|
|
|
-
|
|
|
- const handleBtnClick = (plcs, title) => {
|
|
|
- if (!plcs) return;
|
|
|
- const msg = JSON.stringify(plcs); //[{ dataitemid: 'Raw_Water_Tank_Level', deviceid: '1436022785' }]
|
|
|
- UnityAction.sendMsg(
|
|
|
- 'ProcessAnalysisAbout',
|
|
|
- JSON.stringify({
|
|
|
- title,
|
|
|
- data: msg,
|
|
|
- }),
|
|
|
- );
|
|
|
- };
|
|
|
+ return [
|
|
|
+ { name: '异常', type: '1', data: autoReport?.extendWarningData },
|
|
|
+ { name: '全部', type: '2', data: autoReport?.extendWarningAllData },
|
|
|
+ ];
|
|
|
+ }, [autoReport]);
|
|
|
|
|
|
const onTabChange = (tab) => {
|
|
|
setTab(tab);
|
|
|
- UnityAction.sendMsg('ProcessAnalysisType', tab);
|
|
|
+ UnityAction.sendMsg('DevAnalysisType', tab);
|
|
|
};
|
|
|
|
|
|
const rowSelection = {
|
|
@@ -143,8 +157,7 @@ const DeviceAnalysis = (props) => {
|
|
|
<Table
|
|
|
dataSource={item.data}
|
|
|
columns={columns}
|
|
|
- // rowKey={'DeviceCode'}
|
|
|
- // rowSelection={rowSelection}
|
|
|
+ rowKey="Id"
|
|
|
rowClassName={setRowClassName}
|
|
|
onRow={(record, index) => ({
|
|
|
onClick: () => onSelectRow(record, index),
|
|
@@ -161,8 +174,7 @@ const DeviceAnalysis = (props) => {
|
|
|
</Spin>
|
|
|
);
|
|
|
};
|
|
|
-export default connect(({ smartOps, loading }) => ({
|
|
|
- loading: loading.effects['smartOps/queryList'],
|
|
|
- list: smartOps.list.list,
|
|
|
- processList: smartOps.processList,
|
|
|
+export default connect(({ eqSelfInspection, loading }) => ({
|
|
|
+ loading: loading.effects['eqSelfInspection/getPatrolDataById'],
|
|
|
+ autoReport: eqSelfInspection.autoReport,
|
|
|
}))(DeviceAnalysis);
|