凌世锦
authored
|
1
2
3
4
|
import {
getOrderErpOrderZoNingSelectUserAll,
postOrderErpOrderZoNingSaveOrUpdate,
} from '@/services';
|
凌世锦
authored
|
5
6
7
8
9
10
11
12
|
import { PlusOutlined } from '@ant-design/icons';
import {
ModalForm,
ProForm,
ProFormSelect,
ProFormText,
} from '@ant-design/pro-components';
import { Button, Form, message } from 'antd';
|
凌世锦
authored
|
13
|
import { provinceEnum, zoningItem } from './constant';
|
凌世锦
authored
|
14
15
16
17
18
19
20
21
|
const waitTime = (time: number = 100) => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(true);
}, time);
});
};
|
凌世锦
authored
|
22
|
export default ({ toReload, option, needEditBody }) => {
|
凌世锦
authored
|
23
|
const [form] = Form.useForm<zoningItem>();
|
凌世锦
authored
|
24
|
|
凌世锦
authored
|
25
26
|
return (
<ModalForm<{
|
凌世锦
authored
|
27
28
29
|
zoning: string;
province: string[];
user: number[];
|
凌世锦
authored
|
30
|
}>
|
凌世锦
authored
|
31
|
title={option}
|
凌世锦
authored
|
32
|
trigger={
|
凌世锦
authored
|
33
34
35
|
<Button type="primary" key={option.id}>
{option !== '编辑' && <PlusOutlined />}
{option}
|
凌世锦
authored
|
36
37
38
39
|
</Button>
}
form={form}
autoFocusFirstInput
|
凌世锦
authored
|
40
41
42
43
44
45
46
47
48
|
initialValues={{
zoning: needEditBody.zoning ? needEditBody.zoning : '',
province: needEditBody.orderProvinceShowList
? needEditBody.orderProvinceShowList.split('、')
: [],
user: needEditBody.orderUserNumberShowList
? needEditBody.orderUserNumberShowList
: [],
}}
|
凌世锦
authored
|
49
50
51
|
modalProps={{
destroyOnClose: true,
}}
|
凌世锦
authored
|
52
|
submitTimeout={500}
|
凌世锦
authored
|
53
|
onFinish={async (values) => {
|
凌世锦
authored
|
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
console.log(values);
const orderProvinceList = values.province.map((item) => {
return { province: item };
});
const orderUserList = values.user.map((item) => {
return { uId: item };
});
const fetchData: zoningItem = {
zoning: values.zoning,
orderProvinceVoList: orderProvinceList,
orderUserVoList: orderUserList,
};
let res = await postOrderErpOrderZoNingSaveOrUpdate({
data: fetchData,
});
if (res) {
console.log(res);
await waitTime(500);
console.log(values);
message.success('提交成功');
toReload();
return true;
}
return false;
|
凌世锦
authored
|
78
79
80
81
|
}}
>
<ProForm.Group>
<ProFormText
|
凌世锦
authored
|
82
|
width="lg"
|
凌世锦
authored
|
83
84
85
|
name="zoning"
label="区域名称"
placeholder="请输入"
|
凌世锦
authored
|
86
|
rules={[{ required: true, message: '此项为必填项' }]}
|
凌世锦
authored
|
87
88
89
90
|
/>
</ProForm.Group>
<ProForm.Group>
<ProFormSelect
|
凌世锦
authored
|
91
92
93
|
name="user"
width="lg"
label="负责销售"
|
凌世锦
authored
|
94
|
request={async () => {
|
凌世锦
authored
|
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
const userList = await getOrderErpOrderZoNingSelectUserAll();
if (userList) {
let userSelList = [];
userList.data.forEach((item: { uId: any; userName: any }) =>
userSelList.push({
value: item.uId,
label: item.userName,
}),
);
userSelList.unshift({
value: 0,
label: '全选',
});
return userSelList;
|
凌世锦
authored
|
109
110
111
|
}
return [];
}}
|
凌世锦
authored
|
112
113
114
115
116
117
118
119
120
121
122
|
fieldProps={{
mode: 'multiple',
}}
placeholder="请选择"
rules={[
{
required: true,
message: '请选择!',
type: 'array',
},
]}
|
凌世锦
authored
|
123
124
125
126
|
/>
</ProForm.Group>
<ProForm.Group>
<ProFormSelect
|
凌世锦
authored
|
127
128
129
130
131
132
133
134
135
|
name="province"
width="lg"
label="管辖地区"
valueEnum={provinceEnum}
fieldProps={{
mode: 'multiple',
}}
placeholder="请选择"
rules={[
|
凌世锦
authored
|
136
|
{
|
凌世锦
authored
|
137
138
139
|
required: true,
message: '请选择!',
type: 'array',
|
凌世锦
authored
|
140
141
142
143
144
145
146
|
},
]}
/>
</ProForm.Group>
</ModalForm>
);
};
|