diff --git a/api/app/lib/controllers/patrolPlan/patrolPlan.js b/api/app/lib/controllers/patrolPlan/patrolPlan.js
index 6de5a45..cb72752 100644
--- a/api/app/lib/controllers/patrolPlan/patrolPlan.js
+++ b/api/app/lib/controllers/patrolPlan/patrolPlan.js
@@ -63,9 +63,9 @@ async function updatePatrolPlan(ctx, next) {
let errMsg = '修改巡检计划失败';
const models = ctx.fs.dc.models;
const data = ctx.request.body;
- const { name, startTime, endTime, frequency, patrolPerson } = data;
+ const { name, way, structureId, startTime, endTime, frequency, points, userId } = data;
- let plan = { name, startTime, endTime, frequency, patrolPerson };
+ let plan = { name, way, structureId, startTime, endTime, frequency, points, userId };
if (data && data.id) {
await models.PatrolPlan.update(plan, {
diff --git a/web/client/src/sections/patrolManage/components/planModal.js b/web/client/src/sections/patrolManage/components/planModal.js
index 6cf9e39..583c56c 100644
--- a/web/client/src/sections/patrolManage/components/planModal.js
+++ b/web/client/src/sections/patrolManage/components/planModal.js
@@ -2,19 +2,33 @@ import { Button, Form, Input, Modal, Select, DatePicker } from 'antd';
import React, { useState, useEffect } from 'react';
import { connect } from 'react-redux';
import { getUserList, getProjectList, positionList } from '../actions/plan';
+import moment from 'moment';
const { RangePicker } = DatePicker;
-const PlanModal = ({ visible, onCreate, onCancel, dispatch, userLoading, userList, structureList, struLoading }) => {
+const PlanModal = ({ visible, onCreate, onCancel, dispatch, userLoading, userList, structureList, struLoading, type, curRecord }) => {
const [userOpt, setUserOpt] = useState();
const [struOpt, setStruOpt] = useState();
const [pointOpt, setPointOpt] = useState();
+ const [points, setPoints] = useState();
const [unit, setUnit] = useState('次/天');
const [form] = Form.useForm();
useEffect(() => {
- dispatch(getUserList())
- dispatch(getProjectList())
+ if (type === 'view') {
+
+ } else {
+ dispatch(getUserList())
+ dispatch(getProjectList())
+ }
+ if (type === 'edit') {
+ dispatch(positionList({ projectId: curRecord?.project?.id })).then(res => {
+ if (res.success) {
+ setPoints(res.payload.data?.rows)
+ setPointOpt(res.payload.data?.rows[0]?.points?.map(p => ({ label: p.name, value: p.id })))
+ }
+ })
+ }
}, [])
useEffect(() => {
@@ -47,16 +61,21 @@ const PlanModal = ({ visible, onCreate, onCancel, dispatch, userLoading, userLis
onCancel();
}}
onOk={() => {
+ if (type === 'view') {
+ form.resetFields();
+ onCancel();
+ return;
+ }
form
.validateFields()
.then((values) => {
form.resetFields();
const params = {
+ ...values,
frequency: values.frequency + unit,
startTime: values.time[0],
endTime: values.time[1],
- points: pointOpt.filter(p => p.id == values.points),
- ...values
+ points: points[0]?.points?.filter(p => values?.points?.includes(p.id))
}
onCreate(params);
})
@@ -70,8 +89,12 @@ const PlanModal = ({ visible, onCreate, onCancel, dispatch, userLoading, userLis
layout="vertical"
name="form_in_modal"
initialValues={{
- modifier: 'public',
+ ...curRecord,
+ time: [moment(curRecord?.startTime), moment(curRecord?.startTime)],
+ points: curRecord?.points?.map(p => p.id),
+ userDept: curRecord?.user?.department?.name
}}
+ disabled={type === 'view'}
>
-
-
+
-
+
-
+
- {
+ {
const curUser = userList.filter(u => u.id == value)
if (curUser.length) {
form.setFieldsValue({
@@ -160,7 +184,7 @@ const PlanModal = ({ visible, onCreate, onCancel, dispatch, userLoading, userLis
-
+
);
};
diff --git a/web/client/src/sections/patrolManage/containers/patrolPlan.js b/web/client/src/sections/patrolManage/containers/patrolPlan.js
index 45e5805..fc8ef24 100644
--- a/web/client/src/sections/patrolManage/containers/patrolPlan.js
+++ b/web/client/src/sections/patrolManage/containers/patrolPlan.js
@@ -4,20 +4,30 @@ import { Button, Popconfirm } from 'antd';
import ProTable from '@ant-design/pro-table';
import PlanModal from '../components/planModal';
import { createPatrolPlan, delPatrolPlan, updatePatrolPlan, getPatrolPlan } from '../actions/plan';
+import moment from 'moment';
function PatrolPlan(props) {
const { dispatch, user } = props;
const tableRef = useRef();
const [dataSource, setDataSource] = useState([{}]);
const [visible, setVisible] = useState(false);
+ const [type, setType] = useState();
+ const [curRecord, setCurRecord] = useState();
const onCreate = (values) => {
- console.log(values, 'values')
- dispatch(createPatrolPlan(values)).then(res => {
- if (res.success) {
- tableRef.current.reload();
- }
- })
+ if (type === 'create') {
+ dispatch(createPatrolPlan(values)).then(res => {
+ if (res.success) {
+ tableRef.current.reload();
+ }
+ })
+ } else {
+ dispatch(updatePatrolPlan({ ...values, id: curRecord.id })).then(res => {
+ if (res.success) {
+ tableRef.current.reload();
+ }
+ })
+ }
setVisible(false);
};
@@ -25,7 +35,10 @@ function PatrolPlan(props) {
title: '结构物名称',
dataIndex: 'struName',
key: 'struName',
- ellipsis: true
+ ellipsis: true,
+ render: (_, record) => {
+ return {record?.project?.name}
+ }
}, {
title: '巡检任务名称',
dataIndex: 'name',
@@ -36,11 +49,14 @@ function PatrolPlan(props) {
dataIndex: 'startTime',
key: 'startTime',
ellipsis: true,
+ render: (_, record) => moment(record.startTime).format('YYYY-MM-DD')
}, {
title: '结束时间',
dataIndex: 'endTime',
key: 'endTime',
ellipsis: true,
+ render: (_, record) => moment(record.endTime).format('YYYY-MM-DD')
+
}, {
title: '巡检频次',
dataIndex: 'frequency',
@@ -51,12 +67,13 @@ function PatrolPlan(props) {
dataIndex: 'patrolPoints',
key: 'patrolPoints',
ellipsis: true,
+ render: (_, record) => {record?.points?.length ? record?.points?.map(p => p.name).join() : '-'}
}, {
title: '巡检人',
dataIndex: 'patrolPerson',
key: 'patrolPerson',
ellipsis: true,
- render: (_, record) =>
+ render: (_, record) => {record?.user?.name}
}, {
title: '巡检次数统计',
dataIndex: 'patrolCount',
@@ -69,8 +86,16 @@ function PatrolPlan(props) {
search: false,
render: (_, record) => {
return <>
-
-
+
+
{
@@ -106,7 +131,10 @@ function PatrolPlan(props) {
]}
/>
@@ -115,6 +143,8 @@ function PatrolPlan(props) {
{
setVisible(false);
}}