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 { limit, page } = ctx.query;
let options = {
order: [['id', 'desc']],
include: [{
required: true,
model: models.User,

6
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: '修改巡检模板' },
});
}

47
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)
}}
>
<Form.Item
@ -91,30 +92,19 @@ const PlanModal = ({ visible, onCancel, dispatch, type, curRecord, tableRef }) =
// width: 200,
}}
mode="multiple"
options={[
{
label: 'Manager',
options: [
{
label: 'Jack',
value: 1,
},
{
label: 'Lucy',
value: 2,
},
],
},
{
label: 'Engineer',
options: [
{
label: 'yiminghe',
value: 3,
},
],
},
]}
options={
checkItemsGroup.map(g => {
return {
label: g.name,
options: g.check_items.map(c => {
return {
label: c.name,
value: c.id,
}
})
}
})
}
/>
</Form.Item>
</Form>
@ -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);

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 { 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

Loading…
Cancel
Save