فهرست منبع

feat: 仪表校验历史数据展示

ZhaoJun 1 سال پیش
والد
کامیت
1867c2abde
2فایلهای تغییر یافته به همراه81 افزوده شده و 26 حذف شده
  1. 74 22
      src/pages/SmartOps/components/DeviceAnalysis.js
  2. 7 4
      src/pages/SmartOps/index.js

+ 74 - 22
src/pages/SmartOps/components/DeviceAnalysis.js

@@ -114,14 +114,20 @@ const DeviceAnalysis = (props) => {
         type: '1',
         data: autoReport?.extendWarningData,
         FluidLevelList: autoReport?.FluidLevelList?.filter(
-          (item) => item.status,
+          (item) => item.status && !item.history,
+        ),
+        DrugFlowList: autoReport?.DrugFlowList?.filter(
+          (item) => item.status && !item.history,
         ),
-        DrugFlowList: autoReport?.DrugFlowList?.filter((item) => item.status),
         WaterInCheckList: autoReport?.WaterInCheckList?.filter(
           (item) => item.status,
         ),
-        PressureCompareList: autoReport?.PressureCompareList,
-        WaterQualityCompareList: autoReport?.WaterQualityCompareList,
+        PressureCompareList: autoReport?.PressureCompareList.filter(
+          (item) => !item.history,
+        ),
+        WaterQualityCompareList: autoReport?.WaterQualityCompareList.filter(
+          (item) => !item.history,
+        ),
       },
       {
         name: '全部',
@@ -166,6 +172,16 @@ const DeviceAnalysis = (props) => {
     }
   };
 
+  const calculateLength = (params) => {
+    let length = 0;
+    Object.keys(params).forEach((key) => {
+      if (key !== 'name' && key !== 'type') {
+        length += params[key]?.length;
+      }
+    });
+    return length;
+  };
+
   return (
     <Spin spinning={loading}>
       <div style={{ height: 'calc(100vh - 5.6rem)', overflow: 'auto' }}>
@@ -175,7 +191,7 @@ const DeviceAnalysis = (props) => {
           defaultActiveKey="1"
           items={data?.map((item) => {
             return {
-              label: `${item.name}(${item.data?.length || 0})`,
+              label: `${item.name}(${calculateLength(item) || 0})`,
               key: item.type,
               children: (
                 <>
@@ -197,22 +213,40 @@ const DeviceAnalysis = (props) => {
                   )}
                   {(item.type === '1'
                     ? item?.FluidLevelList.length > 0
-                    : true) && <LiquidLevel allData={item?.FluidLevelList} />}
+                    : true) && (
+                    <LiquidLevel
+                      allData={item?.FluidLevelList}
+                      type={item.type}
+                    />
+                  )}
                   {(item.type === '1'
                     ? item?.DrugFlowList.length > 0
-                    : true) && <DosingFlow allData={item?.DrugFlowList} />}
+                    : true) && (
+                    <DosingFlow allData={item?.DrugFlowList} type={item.type} />
+                  )}
                   {(item.type === '1'
                     ? item?.WaterInCheckList.length > 0
-                    : true) && <WaterFlow allData={item?.WaterInCheckList} />}
+                    : true) && (
+                    <WaterFlow
+                      allData={item?.WaterInCheckList}
+                      type={item.type}
+                    />
+                  )}
                   {(item.type === '1'
                     ? item?.PressureCompareList.length > 0
                     : true) && (
-                    <PressureGauge allData={item?.PressureCompareList} />
+                    <PressureGauge
+                      allData={item?.PressureCompareList}
+                      type={item.type}
+                    />
                   )}
                   {(item.type === '1'
                     ? item?.WaterQualityCompareList.length > 0
                     : true) && (
-                    <WaterQuality allData={item?.WaterQualityCompareList} />
+                    <WaterQuality
+                      allData={item?.WaterQualityCompareList}
+                      type={item.type}
+                    />
                   )}
                 </>
               ),
@@ -230,14 +264,23 @@ export default connect(({ eqSelfInspection, loading }) => ({
 }))(DeviceAnalysis);
 
 const LiquidLevel = (props) => {
-  const { allData } = props;
+  const { allData, type } = props;
 
   const columns = [
     {
       title: '设备名称',
-      width: '20%',
+      width: '14%',
       dataIndex: 'device_name',
     },
+    {
+      title: '时间',
+      dataIndex: 'record_time',
+      render: (text) => {
+        if (text) {
+          return dayjs(text).format('YYYY.MM.DD HH:mm');
+        }
+      },
+    },
     {
       title: '类型',
       key: 'template_item_name',
@@ -253,7 +296,7 @@ const LiquidLevel = (props) => {
     },
     {
       title: '设定值范围',
-      width: '25%',
+      width: '20%',
       render: (record) => (
         <ThresholdDetail
           current={record.value || 0}
@@ -318,21 +361,30 @@ const LiquidLevel = (props) => {
 
   return (
     <div>
-      <ModuleTitle title="液位检测" />
+      <ModuleTitle title={`液位检测${type === '1' ? '' : '(历史记录)'}`} />
       <Table dataSource={allData} columns={columns} />
     </div>
   );
 };
 
 const DosingFlow = (props) => {
-  const { allData } = props;
+  const { allData, type } = props;
 
   const columns = [
     {
       title: '设备名称',
-      width: '15%',
+      width: '14%',
       dataIndex: 'device_name',
     },
+    {
+      title: '时间',
+      dataIndex: 'record_time',
+      render: (text) => {
+        if (text) {
+          return dayjs(text).format('YYYY.MM.DD HH:mm');
+        }
+      },
+    },
     {
       title: '类型',
       key: 'template_item_name',
@@ -416,14 +468,14 @@ const DosingFlow = (props) => {
   ];
   return (
     <div>
-      <ModuleTitle title="加药流量校验" />
+      <ModuleTitle title={`加药流量校验${type === '1' ? '' : '(历史记录)'}`} />
       <Table dataSource={allData} columns={columns} />
     </div>
   );
 };
 
 const WaterFlow = (props) => {
-  const { allData } = props;
+  const { allData, type } = props;
   const columns = [
     {
       title: '设备名称',
@@ -534,7 +586,7 @@ const WaterFlow = (props) => {
 };
 
 const PressureGauge = (props) => {
-  const { allData } = props;
+  const { allData, type } = props;
 
   const columns = [
     {
@@ -644,14 +696,14 @@ const PressureGauge = (props) => {
 
   return (
     <div>
-      <ModuleTitle title="压力仪表校验" />
+      <ModuleTitle title={`压力仪表校验${type === '1' ? '' : '(历史记录)'}`} />
       <Table dataSource={allData} columns={columns} />
     </div>
   );
 };
 
 const WaterQuality = (props) => {
-  const { allData } = props;
+  const { allData, type } = props;
 
   const columns = [
     {
@@ -761,7 +813,7 @@ const WaterQuality = (props) => {
 
   return (
     <div>
-      <ModuleTitle title="水质仪表校验" />
+      <ModuleTitle title={`水质仪表校验${type === '1' ? '' : '(历史记录)'}`} />
       <Table dataSource={allData} columns={columns} />
     </div>
   );

+ 7 - 4
src/pages/SmartOps/index.js

@@ -266,11 +266,14 @@ function SmartOps(props) {
   const lengthCalculate = () => {
     return (
       autoReport?.extendWarningData?.length +
-      autoReport?.FluidLevelList?.filter((item) => item.status).length +
-      autoReport?.DrugFlowList?.filter((item) => item.status)?.length +
+      autoReport?.FluidLevelList?.filter((item) => item.status && !item.history)
+        .length +
+      autoReport?.DrugFlowList?.filter((item) => item.status && !item.history)
+        ?.length +
       autoReport?.WaterInCheckList?.filter((item) => item.status)?.length +
-      autoReport?.WaterQualityCompareList?.length +
-      autoReport?.PressureCompareList?.length
+      autoReport?.WaterQualityCompareList?.filter((item) => !item.history)
+        ?.length +
+      autoReport?.PressureCompareList?.filter((item) => !item.history)?.length
     );
   };