|
@@ -1,11 +1,10 @@
|
|
|
import PageContent from '@/components/PageContent';
|
|
|
import PageTitle from '@/components/PageTitle';
|
|
|
-import { getMandateIDs } from '@/services/eqSelfInspection';
|
|
|
import { GetTokenFromUrl, UnityAction } from '@/utils/utils';
|
|
|
-import { connect, history, useLocation, useParams } from '@umijs/max';
|
|
|
+import { connect, history, useLocation, useModel, useParams } from '@umijs/max';
|
|
|
import { Button, Form, Modal, Select, Spin, message } from 'antd';
|
|
|
import dayjs from 'dayjs';
|
|
|
-import { useEffect, useState } from 'react';
|
|
|
+import { useEffect, useMemo, useState } from 'react';
|
|
|
import styles from './index.less';
|
|
|
|
|
|
const EqSelfInspection = (props) => {
|
|
@@ -13,12 +12,17 @@ const EqSelfInspection = (props) => {
|
|
|
const { projectId } = useParams();
|
|
|
const { routeId } = useLocation();
|
|
|
const [form] = Form.useForm();
|
|
|
+ const { mandate, queryMandate } = useModel('useMandate');
|
|
|
const [visible, setVisible] = useState(false);
|
|
|
// 0 正常 1 异常 2 loading
|
|
|
const [patrolStatus, setPatrolStatus] = useState(0);
|
|
|
const [faultAnalysisStatus, setFaultAnalysisStatus] = useState(0);
|
|
|
const [secureStatus, setSecureStatus] = useState(0);
|
|
|
const [secureChildren, setSecureChildren] = useState([]);
|
|
|
+
|
|
|
+ const hasTask = useMemo(() => {
|
|
|
+ return mandate.find((item) => item.mandate_id);
|
|
|
+ }, [mandate]);
|
|
|
const getDate = () => {
|
|
|
dispatch({
|
|
|
type: 'eqSelfInspection/getAutoPatrol',
|
|
@@ -78,14 +82,11 @@ const EqSelfInspection = (props) => {
|
|
|
if (!autoReport.Id) {
|
|
|
return;
|
|
|
}
|
|
|
- let res = await getMandateIDs({
|
|
|
- project_id: projectId,
|
|
|
- id: autoReport.Id,
|
|
|
- }).catch((err) => {
|
|
|
- console.log(err);
|
|
|
- });
|
|
|
- let mandateIDs = res.map((item) => item.id);
|
|
|
- if (mandateIDs?.length) {
|
|
|
+
|
|
|
+ let mandateIDs = mandate
|
|
|
+ .filter((item) => item.mandate_id)
|
|
|
+ .map((item) => item.mandate_id);
|
|
|
+ if (mandateIDs.length) {
|
|
|
mandateIDs = [...new Set(mandateIDs)];
|
|
|
UnityAction.sendMsg('OpenTaskModal', `mandate_id=${mandateIDs.join()}`);
|
|
|
} else {
|
|
@@ -111,6 +112,7 @@ const EqSelfInspection = (props) => {
|
|
|
});
|
|
|
//自检页面加载完毕
|
|
|
UnityAction.sendMsg('pageInited');
|
|
|
+
|
|
|
return () => UnityAction.off('notiZiJian');
|
|
|
}, []);
|
|
|
|
|
@@ -135,11 +137,19 @@ const EqSelfInspection = (props) => {
|
|
|
});
|
|
|
}, []);
|
|
|
|
|
|
+ useEffect(() => {}, [autoReport?.routeId]);
|
|
|
+
|
|
|
useEffect(() => {
|
|
|
setPatrolStatus(autoReport?.patrolStatus);
|
|
|
setFaultAnalysisStatus(autoReport?.faultAnalysisStatus);
|
|
|
setSecureStatus(autoReport?.secureStatus);
|
|
|
setSecureChildren(autoReport?.secureChild);
|
|
|
+ if (autoReport?.Id) {
|
|
|
+ queryMandate({
|
|
|
+ project_id: projectId,
|
|
|
+ id: autoReport.Id,
|
|
|
+ });
|
|
|
+ }
|
|
|
}, [autoReport]);
|
|
|
|
|
|
return (
|
|
@@ -222,11 +232,10 @@ const EqSelfInspection = (props) => {
|
|
|
<div
|
|
|
className={styles.btnContainer}
|
|
|
style={{
|
|
|
- justifyContent:
|
|
|
- autoReport?.Status == 0 ? 'center' : 'space-between',
|
|
|
+ justifyContent: !hasTask ? 'center' : 'space-between',
|
|
|
}}
|
|
|
>
|
|
|
- {autoReport?.Status != 0 && (
|
|
|
+ {hasTask && (
|
|
|
<Button
|
|
|
className={styles.reportBtn}
|
|
|
type="primary"
|