ProductionTimeModal.tsx
2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { RESPONSE_CODE } from '@/constants/enum';
import { postServiceOrderEditProductionTime } from '@/services';
import { ModalForm, ProFormDatePicker } from '@ant-design/pro-components';
import { Form, message } from 'antd';
// import { cloneDeep } from 'lodash';
export default ({ setVisible, subOrders, onClose }) => {
const [form] = Form.useForm<{
productionStartTime: string;
productionEndTime: string;
}>();
let ids = subOrders?.map((item: { id: any }) => {
return item.id;
});
let defaultValue = {};
if (subOrders && subOrders.length > 0) {
defaultValue = subOrders[0];
}
return (
<>
<ModalForm<{
productionStartTime: string;
productionEndTime: string;
}>
width={500}
open
title="生产时间"
form={form}
autoFocusFirstInput
initialValues={defaultValue}
modalProps={{
okText: '保存',
cancelText: '取消',
destroyOnClose: true,
onCancel: () => {
setVisible(false);
},
}}
onFinish={async (values) => {
if (values.productionStartTime > values.productionEndTime) {
message.error('开始时间不能大于结束时间');
return;
}
let res = await postServiceOrderEditProductionTime({
data: {
...values,
ids: ids,
},
});
if (res && res.result === RESPONSE_CODE.SUCCESS) {
message.success(res.message);
onClose();
}
}}
onOpenChange={setVisible}
>
<span className="text-[red] leading-8">
如果选中多个子订单,将默认回显第一个子订单的生产时间
</span>
<ProFormDatePicker
width="lg"
key="productionStartTime"
name="productionStartTime"
label="开始时间"
placeholder="请输入开始时间"
rules={[{ required: true, message: '开始时间必填' }]}
/>
<ProFormDatePicker
width="lg"
key="productionEndTime"
name="productionEndTime"
label="结束时间"
placeholder="请输入结束时间"
rules={[{ required: true, message: '结束时间必填' }]}
/>
</ModalForm>
</>
);
};