From 2b4372f4e680b1ce997fd05fbb8762ed2a211ea7 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Wed, 22 Feb 2023 10:47:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B7=A1=E6=A3=80=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../patrolManage/patrolTemplate.js | 1 + .../sections/patrolManage/actions/template.js | 6 +-- .../components/planTemplateModal.js | 47 +++++++------------ .../patrolManage/containers/patrolTemplate.js | 9 +++- 4 files changed, 28 insertions(+), 35 deletions(-) diff --git a/api/app/lib/controllers/patrolManage/patrolTemplate.js b/api/app/lib/controllers/patrolManage/patrolTemplate.js index 8f6d33a..e8f9c96 100644 --- a/api/app/lib/controllers/patrolManage/patrolTemplate.js +++ b/api/app/lib/controllers/patrolManage/patrolTemplate.js @@ -6,6 +6,7 @@ async function getPatrolTemplate (ctx, next) { const { userId } = ctx.fs.api const { limit, page } = ctx.query; let options = { + order: [['id', 'desc']], include: [{ required: true, model: models.User, diff --git a/web/client/src/sections/patrolManage/actions/template.js b/web/client/src/sections/patrolManage/actions/template.js index e5c8afd..0442191 100644 --- a/web/client/src/sections/patrolManage/actions/template.js +++ b/web/client/src/sections/patrolManage/actions/template.js @@ -21,7 +21,7 @@ export function createPatrolTemplate (data) { dispatch: dispatch, actionType: 'CREATE_PATROL_TEMPLATE', url: ApiTable.patrolTemplate, - msg: { error: '新增巡检模板失败' }, + msg: { option: '新增巡检模板' }, }); } @@ -31,7 +31,7 @@ export function delPatrolTemplate (id) { dispatch: dispatch, actionType: 'DEL_PATROL_TEMPLATE', url: ApiTable.delPatrolTemplate.replace('{id}', id), - msg: { error: '删除巡检模板失败' }, + msg: { option: '删除巡检模板' }, }); } @@ -42,6 +42,6 @@ export function updatePatrolTemplate (data) { dispatch: dispatch, actionType: 'UPDATE_PATROL_TEMPLATE', url: ApiTable.patrolTemplate, - msg: { error: '修改巡检模板失败' }, + msg: { option: '修改巡检模板' }, }); } \ No newline at end of file diff --git a/web/client/src/sections/patrolManage/components/planTemplateModal.js b/web/client/src/sections/patrolManage/components/planTemplateModal.js index d41ad71..c995d54 100644 --- a/web/client/src/sections/patrolManage/components/planTemplateModal.js +++ b/web/client/src/sections/patrolManage/components/planTemplateModal.js @@ -7,7 +7,7 @@ import moment from 'moment'; const { RangePicker } = DatePicker; const { TextArea } = Input; -const PlanModal = ({ visible, onCancel, dispatch, type, curRecord, tableRef }) => { +const PlanModal = ({ visible, onCancel, dispatch, type, curRecord, tableRef, checkItemsGroup }) => { const [form] = Form.useForm(); return ( @@ -61,6 +61,7 @@ const PlanModal = ({ visible, onCancel, dispatch, type, curRecord, tableRef }) = name="form_in_modal" initialValues={{ ...curRecord, + checkItems: curRecord?.check_items?.map(c => c.id) }} > { + return { + label: g.name, + options: g.check_items.map(c => { + return { + label: c.name, + value: c.id, + } + }) + } + }) + } /> @@ -123,13 +113,10 @@ const PlanModal = ({ visible, onCancel, dispatch, type, curRecord, tableRef }) = }; function mapStateToProps (state) { - const { auth, userList, structureList } = state + const { auth, checkItemsGroup } = state return { user: auth.user, - userList: userList.data || [], - structureList: structureList.data || [], - userLoading: userList.isRequesting, - struLoading: structureList.isRequesting + checkItemsGroup: checkItemsGroup.data || [] } } export default connect(mapStateToProps)(PlanModal); \ No newline at end of file diff --git a/web/client/src/sections/patrolManage/containers/patrolTemplate.js b/web/client/src/sections/patrolManage/containers/patrolTemplate.js index c0e25b5..48f11a9 100644 --- a/web/client/src/sections/patrolManage/containers/patrolTemplate.js +++ b/web/client/src/sections/patrolManage/containers/patrolTemplate.js @@ -1,10 +1,10 @@ -import React, { useState, useRef } from 'react'; +import React, { useState, useRef, useEffect } from 'react'; import { connect } from 'react-redux'; import { Button, Popconfirm, Tag } from 'antd'; import ProTable from '@ant-design/pro-table'; import PlanTemplateModal from '../components/planTemplateModal'; import { createPatrolTemplate, delPatrolTemplate, updatePatrolTemplate, getPatrolTemplate } from '../actions/template'; -import moment from 'moment'; +import { getCheckItemsGroup } from '../actions/checkItems'; function PatrolTemplate (props) { const { dispatch, user } = props; @@ -14,6 +14,10 @@ function PatrolTemplate (props) { const [type, setType] = useState(); const [curRecord, setCurRecord] = useState(); + useEffect(() => { + dispatch(getCheckItemsGroup()) + }, []) + const columns = [{ title: '模板名称', dataIndex: 'name', @@ -103,6 +107,7 @@ function PatrolTemplate (props) { curRecord={curRecord} onCancel={() => { setVisible(false); + setCurRecord({}) }} tableRef={tableRef} /> : null