瀏覽代碼

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

ZhaoJun 1 年之前
父節點
當前提交
54b07dbed5

+ 35 - 0
src/models/eqSelfInspection.js

@@ -1,9 +1,12 @@
+import dayjs from 'dayjs';
+
 import {
   analysisResultList,
   getAutoPatrolByRouteId,
   getPatrolDumuList,
   getPatrolRecordMandateInfo,
   getRecentAutoPatrolByRouteId,
+  getRecentGaugeRecord,
   getRouteList,
   patrolRelationList,
   queryAnalysisDict,
@@ -45,6 +48,10 @@ export default {
       const { data } = yield call(queryPatrolRecord, {
         recordId: payload.routeId,
       });
+      const recentGaugeRecord = yield call(getRecentGaugeRecord, {
+        project_id: payload.projectId,
+        e_time: payload.eTime || dayjs().format('YYYY-MM-DD HH:mm:ss'),
+      });
       if (data) {
         const cacheData = yield select(
           (state) => state.eqSelfInspection.autoReport,
@@ -248,6 +255,34 @@ export default {
         data.secureChild = secureChild;
 
         callback?.(data);
+
+        if (recentGaugeRecord.code === 200) {
+          data.DrugFlowList = [
+            ...data.DrugFlowList,
+            ...recentGaugeRecord.data.DrugFlowList.map((item) => {
+              return { ...item, history: true };
+            }),
+          ];
+          data.FluidLevelList = [
+            ...data.FluidLevelList,
+            ...recentGaugeRecord.data.FluidLevelList.map((item) => {
+              return { ...item, history: true };
+            }),
+          ];
+          data.PressureCompareList = [
+            ...data.PressureCompareList,
+            ...recentGaugeRecord.data.PressureCompareList.map((item) => {
+              return { ...item, history: true };
+            }),
+          ];
+          data.WaterQualityCompareList = [
+            ...data.WaterQualityCompareList,
+            ...recentGaugeRecord.data.WaterQualityCompareList.map((item) => {
+              return { ...item, history: true };
+            }),
+          ];
+        }
+
         yield put({
           type: 'save',
           payload: { autoReport: data },

+ 7 - 3
src/pages/EqSelfInspection/List/index.js

@@ -16,7 +16,7 @@ function List(props) {
     history.push(
       `/self-inspection/detail/${projectId}/${
         record.Id
-      }?JWT-TOKEN=${GetTokenFromUrl()}`,
+      }?JWT-TOKEN=${GetTokenFromUrl()}&eTime=${record.CreatedTime}`,
     );
   };
 
@@ -39,8 +39,12 @@ function List(props) {
     <PageContent closeable={false}>
       <PageTitle returnable>自检记录</PageTitle>
       <div className={`content-title ${styles.list}`}>
-        {list.map((item) => (
-          <div className={styles.item} onClick={() => goToDetail(item)}>
+        {list.map((item, index) => (
+          <div
+            className={styles.item}
+            key={item.CreatedTime + index}
+            onClick={() => goToDetail(item)}
+          >
             {item.Status == 0 ? (
               <div className={`${styles.status}`}>正常</div>
             ) : (

+ 5 - 1
src/pages/EqSelfInspection/ReportDetail.js

@@ -1,6 +1,6 @@
 import PageContent from '@/components/PageContent';
 import PageTitle from '@/components/PageTitle';
-import { connect, useParams } from '@umijs/max';
+import { connect, useLocation, useParams } from '@umijs/max';
 import { useEffect } from 'react';
 import Detail from './components/Detail';
 
@@ -8,12 +8,16 @@ const ReportDetail = (props) => {
   const { data, dispatch, loading } = props;
 
   const { projectId, routeId } = useParams();
+  const eTime = new URLSearchParams(useLocation()?.search)?.get('eTime');
+
   useEffect(() => {
     if (routeId) {
       dispatch({
         type: 'eqSelfInspection/getPatrolDataById',
         payload: {
           routeId,
+          projectId,
+          eTime,
         },
       });
     }

+ 70 - 20
src/pages/EqSelfInspection/components/Detail.js

@@ -290,7 +290,7 @@ export function DeviceTable(props) {
   };
   const handleError = async (values) => {
     setLoading(true);
-    var res = await changeRecordStatus({
+    let res = await changeRecordStatus({
       ...values,
       Id: currentItem.Id,
       DeviceCode: currentItem.DeviceCode,
@@ -314,7 +314,9 @@ export function DeviceTable(props) {
       title: '巡检项',
       key: 'TemplateItem.Name',
       dataIndex: 'TemplateItem',
-      render: (TemplateItem) => <div>{TemplateItem.Name}</div>,
+      render: (TemplateItem) => {
+        return TemplateItem?.Name || '-';
+      },
     },
     // {
     //   title: '设备位号',
@@ -629,7 +631,11 @@ export function WarningTable(props) {
     },
     {
       title: '巡检项',
-      dataIndex: 'TemplateItem.Name',
+      key: 'TemplateItem.Name',
+      dataIndex: 'TemplateItem',
+      render: (TemplateItem) => {
+        return TemplateItem?.Name || '-';
+      },
     },
     // {
     //   title: '设备位号',
@@ -821,9 +827,19 @@ export function LiquidTable(props) {
   const columns = [
     {
       title: '设备名称',
-      width: '20%',
+      width: '12%',
       dataIndex: 'device_name',
     },
+    {
+      title: '时间',
+      dataIndex: 'record_time',
+      render: (text) => {
+        if (text) {
+          return dayjs(text).format('YYYY.MM.DD HH:mm');
+        }
+        return '-';
+      },
+    },
     {
       title: '类型',
       key: 'template_item_name',
@@ -839,7 +855,7 @@ export function LiquidTable(props) {
     },
     {
       title: '设定值范围',
-      width: '25%',
+      width: '20%',
       render: (record) => (
         <ThresholdDetail
           current={record.value || 0}
@@ -916,7 +932,7 @@ function LiquidLevelCom(props) {
   const [activeKey, setActiveKey] = useState('1');
 
   const errorData = useMemo(() => {
-    const errorData = allData?.filter((item) => item.status);
+    const errorData = allData?.filter((item) => item.status && !item.history);
     return errorData;
   }, [allData]);
 
@@ -939,14 +955,14 @@ function LiquidLevelCom(props) {
             },
             {
               key: '2',
-              label: `全部(${allData?.length || 0})`,
+              label: `历史记录(${allData?.length || 0})`,
               children: <div></div>,
             },
           ]}
         ></TabsContent>
       </div>
 
-      {activeKey == '1' && (
+      {activeKey === '1' && (
         <LiquidTable
           onClickItem={sendMessageToUnity}
           select={select}
@@ -955,7 +971,7 @@ function LiquidLevelCom(props) {
           type={type}
         />
       )}
-      {activeKey == '2' && (
+      {activeKey === '2' && (
         <LiquidTable
           onClickItem={sendMessageToUnity}
           select={select}
@@ -973,12 +989,22 @@ function DosingFlowTable(props) {
   const columns = [
     {
       title: '设备名称',
-      width: '20%',
+      width: '12%',
       dataIndex: 'device_name',
     },
+    {
+      title: '时间',
+      dataIndex: 'record_time',
+      render: (text) => {
+        if (text) {
+          return dayjs(text).format('YYYY.MM.DD HH:mm');
+        }
+        return '-';
+      },
+    },
     {
       title: '类型',
-      width: '1rem',
+      width: '10%',
       key: 'template_item_name',
       dataIndex: 'template_item_name',
     },
@@ -996,7 +1022,7 @@ function DosingFlowTable(props) {
     },
     {
       title: '设定值范围',
-      width: '20%',
+      width: '18%',
       render: (record) => (
         <ThresholdDetail
           current={record.value || 0}
@@ -1075,7 +1101,7 @@ function DosingFlowCom(props) {
   const [activeKey, setActiveKey] = useState('1');
 
   const errorData = useMemo(() => {
-    const errorData = allData?.filter((item) => item.status);
+    const errorData = allData?.filter((item) => item.status && !item.history);
     return errorData;
   }, [allData]);
 
@@ -1098,7 +1124,7 @@ function DosingFlowCom(props) {
             },
             {
               key: '2',
-              label: `全部(${allData?.length || 0})`,
+              label: `历史记录(${allData?.length || 0})`,
               children: <div></div>,
             },
           ]}
@@ -1414,7 +1440,7 @@ function PressureGaugeCom(props) {
   const [activeKey, setActiveKey] = useState('2');
 
   const errorData = useMemo(() => {
-    const tempData = allData?.filter((item) => item.status);
+    const tempData = allData?.filter((item) => item.status && !item.history);
     return tempData;
   }, [allData]);
 
@@ -1426,18 +1452,30 @@ function PressureGaugeCom(props) {
       <div className={styles.tableTop}>
         {title}
         <TabsContent
-          defaultActiveKey="2"
+          defaultActiveKey="1"
           onChange={handleTabsChange}
           small
           items={[
+            {
+              key: '1',
+              label: `异常/警告(${errorData?.length || 0})`,
+              children: <div></div>,
+            },
             {
               key: '2',
-              label: `异常/警告(${allData?.length || 0})`,
+              label: `历史记录(${allData?.length || 0})`,
               children: <div></div>,
             },
           ]}
         ></TabsContent>
       </div>
+      {activeKey === '1' && (
+        <PressureGaugeTable
+          onClickItem={sendMessageToUnity}
+          select={select}
+          items={errorData}
+        />
+      )}
       {activeKey === '2' && (
         <PressureGaugeTable
           onClickItem={sendMessageToUnity}
@@ -1576,7 +1614,7 @@ function WaterQualityCom(props) {
   const [activeKey, setActiveKey] = useState('2');
 
   const errorData = useMemo(() => {
-    const tempData = allData?.filter((item) => item.status);
+    const tempData = allData?.filter((item) => item.status && !item.history);
     return tempData;
   }, [allData]);
 
@@ -1588,18 +1626,30 @@ function WaterQualityCom(props) {
       <div className={styles.tableTop}>
         {title}
         <TabsContent
-          defaultActiveKey="2"
+          defaultActiveKey="1"
           onChange={handleTabsChange}
           small
           items={[
+            {
+              key: '1',
+              label: `异常/警告(${errorData?.length || 0})`,
+              children: <div></div>,
+            },
             {
               key: '2',
-              label: `异常/警告(${allData?.length || 0})`,
+              label: `历史记录(${allData?.length || 0})`,
               children: <div></div>,
             },
           ]}
         ></TabsContent>
       </div>
+      {activeKey === '1' && (
+        <WaterQualityTable
+          onClickItem={sendMessageToUnity}
+          select={select}
+          items={errorData}
+        />
+      )}
       {activeKey === '2' && (
         <WaterQualityTable
           onClickItem={sendMessageToUnity}

+ 1 - 0
src/pages/EqSelfInspection/index.js

@@ -112,6 +112,7 @@ const EqSelfInspection = (props) => {
         type: 'eqSelfInspection/getPatrolDataById',
         payload: {
           routeId: routeId,
+          projectId,
         },
       });
     } else {

+ 1 - 0
src/pages/SmartOps/index.js

@@ -99,6 +99,7 @@ function SmartOps(props) {
       type: 'eqSelfInspection/getPatrolDataById',
       payload: {
         routeId: patrolId || reportData.PatrolId,
+        projectId,
       },
       callback: (data) => {
         // console.log(data);