|
@@ -1,17 +1,37 @@
|
|
|
-import React, { useState } from 'react'
|
|
|
|
|
|
|
+import React, { useState, useEffect } from 'react'
|
|
|
import { Form, Radio, DatePicker, Switch, Modal } from 'antd'
|
|
import { Form, Radio, DatePicker, Switch, Modal } from 'antd'
|
|
|
import { dayjsFormat } from '@/utils/utils'
|
|
import { dayjsFormat } from '@/utils/utils'
|
|
|
import dayjs from 'dayjs'
|
|
import dayjs from 'dayjs'
|
|
|
import { ProFormTextArea } from '@ant-design/pro-form'
|
|
import { ProFormTextArea } from '@ant-design/pro-form'
|
|
|
|
|
+import type { ModalProps } from 'antd'
|
|
|
|
|
|
|
|
-const AddRecord = props => {
|
|
|
|
|
|
|
+type AddRecordProps = {
|
|
|
|
|
+ defaultValues?: API.ServiceLogItem
|
|
|
|
|
+ onConfirm: () => Promise<void>
|
|
|
|
|
+} & ModalProps
|
|
|
|
|
+
|
|
|
|
|
+const options = [
|
|
|
|
|
+ { label: '上门服务', value: 1 },
|
|
|
|
|
+ { label: '电话拜访', value: 2 },
|
|
|
|
|
+ { label: '其他事项', value: 3 },
|
|
|
|
|
+ { label: '在线服务', value: 4 }
|
|
|
|
|
+]
|
|
|
|
|
+const AddRecord: React.FC<AddRecordProps> = ({ defaultValues, onConfirm, ...resetModalProps }) => {
|
|
|
const [formRef] = Form.useForm()
|
|
const [formRef] = Form.useForm()
|
|
|
- const { onConfirm, ...resetModalProps } = props
|
|
|
|
|
const [state, setState] = useState({
|
|
const [state, setState] = useState({
|
|
|
showExtraItem: false,
|
|
showExtraItem: false,
|
|
|
loading: false
|
|
loading: false
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ if (defaultValues) {
|
|
|
|
|
+ if (Reflect.has(defaultValues, 'remindTime') || Reflect.has(defaultValues, 'remarks')) {
|
|
|
|
|
+ setState({ ...state, showExtraItem: true })
|
|
|
|
|
+ }
|
|
|
|
|
+ formRef?.setFieldsValue({ ...defaultValues })
|
|
|
|
|
+ }
|
|
|
|
|
+ }, [defaultValues])
|
|
|
|
|
+
|
|
|
const onChange = value => {
|
|
const onChange = value => {
|
|
|
setState({ ...state, showExtraItem: value })
|
|
setState({ ...state, showExtraItem: value })
|
|
|
}
|
|
}
|
|
@@ -45,23 +65,17 @@ const AddRecord = props => {
|
|
|
setState({ ...state, loading: false })
|
|
setState({ ...state, loading: false })
|
|
|
})
|
|
})
|
|
|
}}
|
|
}}
|
|
|
- confirmLoading={state.loading}
|
|
|
|
|
- >
|
|
|
|
|
|
|
+ confirmLoading={state.loading}>
|
|
|
<Form layout="vertical" form={formRef}>
|
|
<Form layout="vertical" form={formRef}>
|
|
|
|
|
+ <Form.Item name="id" hidden />
|
|
|
<Form.Item name="status" label="服务类型" rules={[{ required: true, message: '请选择类型' }]}>
|
|
<Form.Item name="status" label="服务类型" rules={[{ required: true, message: '请选择类型' }]}>
|
|
|
- <Radio.Group>
|
|
|
|
|
- <Radio value={1}>上门服务</Radio>
|
|
|
|
|
- <Radio value={2}>电话拜访</Radio>
|
|
|
|
|
- <Radio value={3}>其他事项</Radio>
|
|
|
|
|
- <Radio value={4}>在线服务</Radio>
|
|
|
|
|
- </Radio.Group>
|
|
|
|
|
|
|
+ <Radio.Group options={options} />
|
|
|
</Form.Item>
|
|
</Form.Item>
|
|
|
<Form.Item
|
|
<Form.Item
|
|
|
name="date"
|
|
name="date"
|
|
|
label="服务日期"
|
|
label="服务日期"
|
|
|
initialValue={dayjs(new Date())}
|
|
initialValue={dayjs(new Date())}
|
|
|
- rules={[{ required: true, message: '请选择服务日期' }]}
|
|
|
|
|
- >
|
|
|
|
|
|
|
+ rules={[{ required: true, message: '请选择服务日期' }]}>
|
|
|
<DatePicker style={{ width: '100%' }} />
|
|
<DatePicker style={{ width: '100%' }} />
|
|
|
</Form.Item>
|
|
</Form.Item>
|
|
|
<ProFormTextArea name="mark" label="内容" rules={[{ required: true, message: '请输入服务内容' }]} />
|
|
<ProFormTextArea name="mark" label="内容" rules={[{ required: true, message: '请输入服务内容' }]} />
|
|
@@ -75,8 +89,7 @@ const AddRecord = props => {
|
|
|
<Form.Item
|
|
<Form.Item
|
|
|
name="remindTime"
|
|
name="remindTime"
|
|
|
label="备忘日期"
|
|
label="备忘日期"
|
|
|
- rules={[{ required: true, message: '请选择备忘日期' }]}
|
|
|
|
|
- >
|
|
|
|
|
|
|
+ rules={[{ required: true, message: '请选择备忘日期' }]}>
|
|
|
<DatePicker style={{ width: '100%' }} disabledDate={disabledDate} />
|
|
<DatePicker style={{ width: '100%' }} disabledDate={disabledDate} />
|
|
|
</Form.Item>
|
|
</Form.Item>
|
|
|
<ProFormTextArea name="remarks" label="备忘内容" />
|
|
<ProFormTextArea name="remarks" label="备忘内容" />
|