Browse Source

修改巡检模板

master
巴林闲侠 2 years ago
parent
commit
2b4372f4e6
  1. 1
      api/app/lib/controllers/patrolManage/patrolTemplate.js
  2. 6
      web/client/src/sections/patrolManage/actions/template.js
  3. 47
      web/client/src/sections/patrolManage/components/planTemplateModal.js
  4. 9
      web/client/src/sections/patrolManage/containers/patrolTemplate.js

1
api/app/lib/controllers/patrolManage/patrolTemplate.js

@ -6,6 +6,7 @@ async function getPatrolTemplate (ctx, next) {
const { userId } = ctx.fs.api const { userId } = ctx.fs.api
const { limit, page } = ctx.query; const { limit, page } = ctx.query;
let options = { let options = {
order: [['id', 'desc']],
include: [{ include: [{
required: true, required: true,
model: models.User, model: models.User,

6
web/client/src/sections/patrolManage/actions/template.js

@ -21,7 +21,7 @@ export function createPatrolTemplate (data) {
dispatch: dispatch, dispatch: dispatch,
actionType: 'CREATE_PATROL_TEMPLATE', actionType: 'CREATE_PATROL_TEMPLATE',
url: ApiTable.patrolTemplate, url: ApiTable.patrolTemplate,
msg: { error: '新增巡检模板失败' }, msg: { option: '新增巡检模板' },
}); });
} }
@ -31,7 +31,7 @@ export function delPatrolTemplate (id) {
dispatch: dispatch, dispatch: dispatch,
actionType: 'DEL_PATROL_TEMPLATE', actionType: 'DEL_PATROL_TEMPLATE',
url: ApiTable.delPatrolTemplate.replace('{id}', id), url: ApiTable.delPatrolTemplate.replace('{id}', id),
msg: { error: '删除巡检模板失败' }, msg: { option: '删除巡检模板' },
}); });
} }
@ -42,6 +42,6 @@ export function updatePatrolTemplate (data) {
dispatch: dispatch, dispatch: dispatch,
actionType: 'UPDATE_PATROL_TEMPLATE', actionType: 'UPDATE_PATROL_TEMPLATE',
url: ApiTable.patrolTemplate, url: ApiTable.patrolTemplate,
msg: { error: '修改巡检模板失败' }, msg: { option: '修改巡检模板' },
}); });
} }

47
web/client/src/sections/patrolManage/components/planTemplateModal.js

@ -7,7 +7,7 @@ import moment from 'moment';
const { RangePicker } = DatePicker; const { RangePicker } = DatePicker;
const { TextArea } = Input; const { TextArea } = Input;
const PlanModal = ({ visible, onCancel, dispatch, type, curRecord, tableRef }) => { const PlanModal = ({ visible, onCancel, dispatch, type, curRecord, tableRef, checkItemsGroup }) => {
const [form] = Form.useForm(); const [form] = Form.useForm();
return ( return (
@ -61,6 +61,7 @@ const PlanModal = ({ visible, onCancel, dispatch, type, curRecord, tableRef }) =
name="form_in_modal" name="form_in_modal"
initialValues={{ initialValues={{
...curRecord, ...curRecord,
checkItems: curRecord?.check_items?.map(c => c.id)
}} }}
> >
<Form.Item <Form.Item
@ -91,30 +92,19 @@ const PlanModal = ({ visible, onCancel, dispatch, type, curRecord, tableRef }) =
// width: 200, // width: 200,
}} }}
mode="multiple" mode="multiple"
options={[ options={
{ checkItemsGroup.map(g => {
label: 'Manager', return {
options: [ label: g.name,
{ options: g.check_items.map(c => {
label: 'Jack', return {
value: 1, label: c.name,
}, value: c.id,
{ }
label: 'Lucy', })
value: 2, }
}, })
], }
},
{
label: 'Engineer',
options: [
{
label: 'yiminghe',
value: 3,
},
],
},
]}
/> />
</Form.Item> </Form.Item>
</Form> </Form>
@ -123,13 +113,10 @@ const PlanModal = ({ visible, onCancel, dispatch, type, curRecord, tableRef }) =
}; };
function mapStateToProps (state) { function mapStateToProps (state) {
const { auth, userList, structureList } = state const { auth, checkItemsGroup } = state
return { return {
user: auth.user, user: auth.user,
userList: userList.data || [], checkItemsGroup: checkItemsGroup.data || []
structureList: structureList.data || [],
userLoading: userList.isRequesting,
struLoading: structureList.isRequesting
} }
} }
export default connect(mapStateToProps)(PlanModal); export default connect(mapStateToProps)(PlanModal);

9
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 { connect } from 'react-redux';
import { Button, Popconfirm, Tag } from 'antd'; import { Button, Popconfirm, Tag } from 'antd';
import ProTable from '@ant-design/pro-table'; import ProTable from '@ant-design/pro-table';
import PlanTemplateModal from '../components/planTemplateModal'; import PlanTemplateModal from '../components/planTemplateModal';
import { createPatrolTemplate, delPatrolTemplate, updatePatrolTemplate, getPatrolTemplate } from '../actions/template'; import { createPatrolTemplate, delPatrolTemplate, updatePatrolTemplate, getPatrolTemplate } from '../actions/template';
import moment from 'moment'; import { getCheckItemsGroup } from '../actions/checkItems';
function PatrolTemplate (props) { function PatrolTemplate (props) {
const { dispatch, user } = props; const { dispatch, user } = props;
@ -14,6 +14,10 @@ function PatrolTemplate (props) {
const [type, setType] = useState(); const [type, setType] = useState();
const [curRecord, setCurRecord] = useState(); const [curRecord, setCurRecord] = useState();
useEffect(() => {
dispatch(getCheckItemsGroup())
}, [])
const columns = [{ const columns = [{
title: '模板名称', title: '模板名称',
dataIndex: 'name', dataIndex: 'name',
@ -103,6 +107,7 @@ function PatrolTemplate (props) {
curRecord={curRecord} curRecord={curRecord}
onCancel={() => { onCancel={() => {
setVisible(false); setVisible(false);
setCurRecord({})
}} }}
tableRef={tableRef} tableRef={tableRef}
/> : null /> : null

Loading…
Cancel
Save