|
@@ -2,8 +2,8 @@ import ModuleTitle from '@/components/ManagementPage/moduleTitle';
|
|
import TabsContent from '@/components/TabsContent';
|
|
import TabsContent from '@/components/TabsContent';
|
|
import ThresholdDetail from '@/components/ThresholdDetail';
|
|
import ThresholdDetail from '@/components/ThresholdDetail';
|
|
import { UnityAction } from '@/utils/utils';
|
|
import { UnityAction } from '@/utils/utils';
|
|
-import { Collapse, Spin, Table, Tabs } from 'antd';
|
|
|
|
-import { useMemo, useState } from 'react';
|
|
|
|
|
|
+import { Collapse, Empty, Spin, Table, Tabs } from 'antd';
|
|
|
|
+import { useEffect, useMemo, useState } from 'react';
|
|
import styles from './VideoAnalysis.less';
|
|
import styles from './VideoAnalysis.less';
|
|
|
|
|
|
const { TabPane } = Tabs;
|
|
const { TabPane } = Tabs;
|
|
@@ -45,27 +45,28 @@ function VideoAnalysis(props) {
|
|
return [...list1, ...list2, ...list3];
|
|
return [...list1, ...list2, ...list3];
|
|
}, [videoData]);
|
|
}, [videoData]);
|
|
|
|
|
|
- // useEffect(() => {
|
|
|
|
- // UnityAction.on('SynCam', selectedItem);
|
|
|
|
- // UnityAction.on('SynDev', selectedItem);
|
|
|
|
- // return () => {
|
|
|
|
- // UnityAction.off('SynDev', selectedItem);
|
|
|
|
- // UnityAction.off('SynCam', selectedItem);
|
|
|
|
- // };
|
|
|
|
- // }, [data?.list]);
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ UnityAction.on('SynCam', selectedItem);
|
|
|
|
+ UnityAction.on('SynDev', selectedItem);
|
|
|
|
+ return () => {
|
|
|
|
+ UnityAction.off('SynDev', selectedItem);
|
|
|
|
+ UnityAction.off('SynCam', selectedItem);
|
|
|
|
+ };
|
|
|
|
+ }, [videoData]);
|
|
|
|
|
|
- // //滚动到相应位置
|
|
|
|
- // const selectedItem = (e) => {
|
|
|
|
- // setSelectedName(e);
|
|
|
|
- // const dom = document.querySelector(`div[data-name="${e}"]`);
|
|
|
|
- // if (dom) {
|
|
|
|
- // let v = document.getElementById('videoContent');
|
|
|
|
- // v.scrollTop = dom.offsetTop;
|
|
|
|
- // }
|
|
|
|
- // };
|
|
|
|
|
|
+ //滚动到相应位置
|
|
|
|
+ const selectedItem = (e) => {
|
|
|
|
+ setSelectedName(e);
|
|
|
|
+ const dom = document.querySelector(`div[data-name="${e}"]`);
|
|
|
|
+ if (dom) {
|
|
|
|
+ let v = document.getElementById('videoContent');
|
|
|
|
+ v.scrollTop = dom.offsetTop;
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
|
|
const onTabChange = (tab) => {
|
|
const onTabChange = (tab) => {
|
|
setTab(tab);
|
|
setTab(tab);
|
|
|
|
+ setSelectedName('');
|
|
UnityAction.sendMsg('SensorAnalysisType', tab);
|
|
UnityAction.sendMsg('SensorAnalysisType', tab);
|
|
};
|
|
};
|
|
|
|
|
|
@@ -83,13 +84,20 @@ function VideoAnalysis(props) {
|
|
<AnalysisContent
|
|
<AnalysisContent
|
|
errorData={errorData}
|
|
errorData={errorData}
|
|
selectedName={selectedName}
|
|
selectedName={selectedName}
|
|
|
|
+ setSelectedName={setSelectedName}
|
|
/>
|
|
/>
|
|
),
|
|
),
|
|
},
|
|
},
|
|
{
|
|
{
|
|
label: `全部(${allCount})`,
|
|
label: `全部(${allCount})`,
|
|
key: '2',
|
|
key: '2',
|
|
- children: <AllContent data={data} videoData={videoData} />,
|
|
|
|
|
|
+ children: (
|
|
|
|
+ <AllContent
|
|
|
|
+ videoData={videoData}
|
|
|
|
+ selectedName={selectedName}
|
|
|
|
+ setSelectedName={setSelectedName}
|
|
|
|
+ />
|
|
|
|
+ ),
|
|
},
|
|
},
|
|
]}
|
|
]}
|
|
onChange={onTabChange}
|
|
onChange={onTabChange}
|
|
@@ -98,17 +106,20 @@ function VideoAnalysis(props) {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
-function AnalysisContent({ errorData, selectedName }) {
|
|
|
|
|
|
+function AnalysisContent({ errorData, selectedName, setSelectedName }) {
|
|
const [prevKey, setPrevKey] = useState();
|
|
const [prevKey, setPrevKey] = useState();
|
|
const handleImgClick = (item) => {
|
|
const handleImgClick = (item) => {
|
|
- localStorage.setItem('preview', JSON.stringify(item.data));
|
|
|
|
|
|
+ localStorage.setItem('preview', item.path);
|
|
UnityAction.sendMsg('SensorPic');
|
|
UnityAction.sendMsg('SensorPic');
|
|
};
|
|
};
|
|
|
|
+
|
|
const handleCollapse = (item) => {
|
|
const handleCollapse = (item) => {
|
|
const key = item.type == TYPE.video ? item.device_name : item.device_code;
|
|
const key = item.type == TYPE.video ? item.device_name : item.device_code;
|
|
const name = item.type == TYPE.video ? 'SynCam' : 'SynDev';
|
|
const name = item.type == TYPE.video ? 'SynCam' : 'SynDev';
|
|
- if (key === prevKey) return;
|
|
|
|
- setPrevKey(key);
|
|
|
|
|
|
+ // 清除unity发送过来的选中设备
|
|
|
|
+ setSelectedName('');
|
|
|
|
+ if (item.key === prevKey) return;
|
|
|
|
+ setPrevKey(item.key);
|
|
UnityAction.sendMsg(name, key);
|
|
UnityAction.sendMsg(name, key);
|
|
};
|
|
};
|
|
|
|
|
|
@@ -197,31 +208,36 @@ function AnalysisContent({ errorData, selectedName }) {
|
|
return content;
|
|
return content;
|
|
};
|
|
};
|
|
const getClassName = (item) => {
|
|
const getClassName = (item) => {
|
|
- const key = item.type == TYPE.video ? item.device_name : item.device_code;
|
|
|
|
- return selectedName == key || prevKey == key
|
|
|
|
- ? styles.tableSelect
|
|
|
|
- : styles.table;
|
|
|
|
|
|
+ const device =
|
|
|
|
+ item.type == TYPE.video ? item.device_name : item.device_code;
|
|
|
|
+ if (selectedName && selectedName == device) {
|
|
|
|
+ return styles.tableSelect;
|
|
|
|
+ } else if (prevKey == item.key) {
|
|
|
|
+ return styles.tableSelect;
|
|
|
|
+ }
|
|
|
|
+ return styles.table;
|
|
};
|
|
};
|
|
|
|
+
|
|
return (
|
|
return (
|
|
<div
|
|
<div
|
|
className={styles.page}
|
|
className={styles.page}
|
|
style={{ height: 'calc(100vh - 630px)', overflow: 'auto' }}
|
|
style={{ height: 'calc(100vh - 630px)', overflow: 'auto' }}
|
|
>
|
|
>
|
|
{errorData?.length > 0 ? (
|
|
{errorData?.length > 0 ? (
|
|
- errorData?.map((item) => (
|
|
|
|
- <div data-name={item.device_name}>
|
|
|
|
|
|
+ errorData.map((item) => (
|
|
|
|
+ <div
|
|
|
|
+ data-name={item.device_name}
|
|
|
|
+ key={item.key}
|
|
|
|
+ onClick={() => handleCollapse(item)}
|
|
|
|
+ >
|
|
<Collapse
|
|
<Collapse
|
|
- defaultActiveKey={[item.device_name]}
|
|
|
|
- key={item.device_name}
|
|
|
|
|
|
+ activeKey={item.key}
|
|
className={getClassName(item)}
|
|
className={getClassName(item)}
|
|
expandIcon={() => (
|
|
expandIcon={() => (
|
|
<div className={styles.typeText}>{item.type_name}</div>
|
|
<div className={styles.typeText}>{item.type_name}</div>
|
|
)}
|
|
)}
|
|
- onChange={(e) => {
|
|
|
|
- handleCollapse(item);
|
|
|
|
- }}
|
|
|
|
>
|
|
>
|
|
- <Panel header={item.device_name} key={item.device_name}>
|
|
|
|
|
|
+ <Panel header={item.device_name} key={item.key}>
|
|
<div className={styles.box}>
|
|
<div className={styles.box}>
|
|
<div className={styles.item}>
|
|
<div className={styles.item}>
|
|
{renderContent(item.type, item)}
|
|
{renderContent(item.type, item)}
|
|
@@ -238,13 +254,14 @@ function AnalysisContent({ errorData, selectedName }) {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
-function AllContent({ data = [], videoData = {} }) {
|
|
|
|
|
|
+function AllContent({ videoData = {}, selectedName, setSelectedName }) {
|
|
const {
|
|
const {
|
|
environment_list = [],
|
|
environment_list = [],
|
|
fluid_level_list = [],
|
|
fluid_level_list = [],
|
|
dumu_list = [],
|
|
dumu_list = [],
|
|
} = videoData;
|
|
} = videoData;
|
|
- const [selectedRowKeys, setSelectedRowKeys] = useState([]);
|
|
|
|
|
|
+ // const [selectedRowKeys, setSelectedRowKeys] = useState([]);
|
|
|
|
+ const [selectKey, setSelectKey] = useState([]);
|
|
const columns1 = [
|
|
const columns1 = [
|
|
{
|
|
{
|
|
title: '设备名称',
|
|
title: '设备名称',
|
|
@@ -268,7 +285,6 @@ function AllContent({ data = [], videoData = {} }) {
|
|
JsonNumThreshold: record?.json_num_threshold,
|
|
JsonNumThreshold: record?.json_num_threshold,
|
|
Type: record.type || 2,
|
|
Type: record.type || 2,
|
|
}}
|
|
}}
|
|
- // onClick={() => onClickThreshold(record)}
|
|
|
|
/>
|
|
/>
|
|
),
|
|
),
|
|
},
|
|
},
|
|
@@ -413,18 +429,26 @@ function AllContent({ data = [], videoData = {} }) {
|
|
const onSelectRow = (item, type) => {
|
|
const onSelectRow = (item, type) => {
|
|
const key = type == TYPE.video ? item.device_name : item.device_code;
|
|
const key = type == TYPE.video ? item.device_name : item.device_code;
|
|
const name = type == TYPE.video ? 'SynCam' : 'SynDev';
|
|
const name = type == TYPE.video ? 'SynCam' : 'SynDev';
|
|
- const selectedList = [...selectedRowKeys];
|
|
|
|
- if (selectedList[0] === key) return;
|
|
|
|
- selectedList[0] = key;
|
|
|
|
- setSelectedRowKeys(selectedList);
|
|
|
|
|
|
+ setSelectedName('');
|
|
|
|
+ if (selectKey === item.key) return;
|
|
|
|
+ setSelectKey(item.key);
|
|
UnityAction.sendMsg(name, key);
|
|
UnityAction.sendMsg(name, key);
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ const handleImgClick = (item) => {
|
|
|
|
+ localStorage.setItem('preview', item.path);
|
|
|
|
+ UnityAction.sendMsg('SensorPic');
|
|
|
|
+ };
|
|
|
|
+
|
|
const setRowClassName = (item) => {
|
|
const setRowClassName = (item) => {
|
|
- const key = item.type == TYPE.video ? item.device_name : item.device_code;
|
|
|
|
- return selectedRowKeys.length > 0 && key == selectedRowKeys[0]
|
|
|
|
- ? styles.tableSelect
|
|
|
|
- : '';
|
|
|
|
|
|
+ const device =
|
|
|
|
+ item.type == TYPE.video ? item.device_name : item.device_code;
|
|
|
|
+ if (selectedName && selectedName == device) {
|
|
|
|
+ return styles.tableSelect;
|
|
|
|
+ } else if (selectKey == item.key) {
|
|
|
|
+ return styles.tableSelect;
|
|
|
|
+ }
|
|
|
|
+ return '';
|
|
};
|
|
};
|
|
|
|
|
|
return (
|
|
return (
|
|
@@ -467,6 +491,7 @@ function AllContent({ data = [], videoData = {} }) {
|
|
onRow={(record, index) => ({
|
|
onRow={(record, index) => ({
|
|
onClick: () => onSelectRow(record, TYPE.video),
|
|
onClick: () => onSelectRow(record, TYPE.video),
|
|
})}
|
|
})}
|
|
|
|
+ rowKey="id"
|
|
pagination={false}
|
|
pagination={false}
|
|
scroll={{ y: 400 }}
|
|
scroll={{ y: 400 }}
|
|
/>
|
|
/>
|