|
|
@ -1,12 +1,13 @@ |
|
|
|
import { Button, Form, Input, Modal, Select, DatePicker } from 'antd'; |
|
|
|
import React, { useState, useEffect } from 'react'; |
|
|
|
import { connect } from 'react-redux'; |
|
|
|
import { createPatrolTemplate, delPatrolTemplate, updatePatrolTemplate, getPatrolTemplate } from '../actions/template'; |
|
|
|
import moment from 'moment'; |
|
|
|
|
|
|
|
const { RangePicker } = DatePicker; |
|
|
|
const { TextArea } = Input; |
|
|
|
|
|
|
|
const PlanModal = ({ visible, onCreate, onCancel, dispatch, type, curRecord }) => { |
|
|
|
const PlanModal = ({ visible, onCancel, dispatch, type, curRecord, tableRef }) => { |
|
|
|
const [form] = Form.useForm(); |
|
|
|
|
|
|
|
return ( |
|
|
@ -20,19 +21,34 @@ const PlanModal = ({ visible, onCreate, onCancel, dispatch, type, curRecord }) = |
|
|
|
onCancel(); |
|
|
|
}} |
|
|
|
onOk={() => { |
|
|
|
if (type === 'view') { |
|
|
|
form.resetFields(); |
|
|
|
onCancel(); |
|
|
|
return; |
|
|
|
} |
|
|
|
form |
|
|
|
.validateFields() |
|
|
|
.then((values) => { |
|
|
|
form.resetFields(); |
|
|
|
|
|
|
|
const params = { |
|
|
|
...values, |
|
|
|
} |
|
|
|
// onCreate(params);
|
|
|
|
|
|
|
|
if (type === 'create') { |
|
|
|
dispatch(createPatrolTemplate(params)).then(res => { |
|
|
|
if (res.success) { |
|
|
|
tableRef.current.reload(); |
|
|
|
form.resetFields(); |
|
|
|
onCancel(); |
|
|
|
} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
dispatch(updatePatrolTemplate({ |
|
|
|
...params, |
|
|
|
id: curRecord.id |
|
|
|
})).then(res => { |
|
|
|
if (res.success) { |
|
|
|
tableRef.current.reload(); |
|
|
|
form.resetFields(); |
|
|
|
onCancel(); |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
.catch((info) => { |
|
|
|
console.log('Validate Failed:', info); |
|
|
@ -46,7 +62,6 @@ const PlanModal = ({ visible, onCreate, onCancel, dispatch, type, curRecord }) = |
|
|
|
initialValues={{ |
|
|
|
...curRecord, |
|
|
|
}} |
|
|
|
disabled={type === 'view'} |
|
|
|
> |
|
|
|
<Form.Item |
|
|
|
name="name" |
|
|
@ -55,14 +70,14 @@ const PlanModal = ({ visible, onCreate, onCancel, dispatch, type, curRecord }) = |
|
|
|
{ required: true, message: '请输入巡检模板名称' }, |
|
|
|
]} |
|
|
|
> |
|
|
|
<Input disabled={type === 'view'} /> |
|
|
|
<Input /> |
|
|
|
</Form.Item> |
|
|
|
<Form.Item |
|
|
|
name="describe" |
|
|
|
label="描述" |
|
|
|
rules={[]} |
|
|
|
> |
|
|
|
<TextArea rows={4} disabled={type === 'view'} /> |
|
|
|
<TextArea rows={4} /> |
|
|
|
</Form.Item> |
|
|
|
<Form.Item |
|
|
|
name="checkItems" |
|
|
@ -82,11 +97,11 @@ const PlanModal = ({ visible, onCreate, onCancel, dispatch, type, curRecord }) = |
|
|
|
options: [ |
|
|
|
{ |
|
|
|
label: 'Jack', |
|
|
|
value: 'jack', |
|
|
|
value: 1, |
|
|
|
}, |
|
|
|
{ |
|
|
|
label: 'Lucy', |
|
|
|
value: 'lucy', |
|
|
|
value: 2, |
|
|
|
}, |
|
|
|
], |
|
|
|
}, |
|
|
@ -95,7 +110,7 @@ const PlanModal = ({ visible, onCreate, onCancel, dispatch, type, curRecord }) = |
|
|
|
options: [ |
|
|
|
{ |
|
|
|
label: 'yiminghe', |
|
|
|
value: 'Yiminghe', |
|
|
|
value: 3, |
|
|
|
}, |
|
|
|
], |
|
|
|
}, |
|
|
|