0bc2e94e
谢忠泽
add:快递收费标准配置
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import React, { useCallback, useEffect, useState } from "react";
import { Modal, Skeleton, Select, Form, message, InputNumber } from "antd";
import * as API from '../../api';
import _ from "lodash";
interface Props {
visible:boolean;
row?:API.Item;
compList:any[];
cityList:any[];
onCancel:()=>void;
onRefresh:() => void;
}
function AddModel({visible, row, compList, cityList, onCancel, onRefresh}:Props) {
const [form] = Form.useForm();
const [loading, setLoading] = useState<boolean>(false);
const { id } = row || {};
useEffect(() => {
if (id) {
const { tradeCompName, sendAreaName, firstWeight, continuedWeight, arriveAreaName } = row || {};
form.setFieldsValue({
tradeComp: compList.filter(it => tradeCompName === it.name).map(item => ({value: item.id, label: item.name}))[0],
|
a35a7955
谢忠泽
fix:收寄件字段名
|
25
|
sendArea: cityList.filter(it => sendAreaName === it.fullName).map(item => ({value: item.bh, label: item.fullName}))[0],
|
0bc2e94e
谢忠泽
add:快递收费标准配置
|
26
27
|
firstWeight,
continuedWeight,
|
a35a7955
谢忠泽
fix:收寄件字段名
|
28
|
arriveAreas: cityList.filter(it => arriveAreaName === it.fullName).map(item => ({value: item.bh, label: item.fullName}))[0]
|
0bc2e94e
谢忠泽
add:快递收费标准配置
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
});
}
}, [row]);
/**
* @description: 确定
* @param {*}
* @return {*}
*/
const handleSave = (feildValue:any) => {
setLoading(true);
const {tradeComp, sendArea, arriveAreas, firstWeight, continuedWeight} = feildValue;
const _arriveAreas = id ? [{ ...arriveAreas }].map(item => ({arriveAreaNo: item.value, arriveAreaName: item.label}))
: arriveAreas.length && arriveAreas.map((item:any) => ({arriveAreaNo: item.value, arriveAreaName: item.label}));
const params = {
|
350949eb
谢忠泽
fix:编辑快递收费标准时请求参数
|
46
|
expressChargeStandardId: id,
|
0bc2e94e
谢忠泽
add:快递收费标准配置
|
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
82
83
84
85
86
87
88
89
90
|
tradeCompId: tradeComp.value,
tradeCompName: tradeComp.label,
tradeCompShortName: compList && compList.filter(item => item.id == tradeComp.value)[0].shortName,
sendAreaNo: sendArea.value,
sendAreaName: sendArea.label,
firstWeight,
continuedWeight,
arriveAreas: _arriveAreas
};
API.addStandardSave({ ...params })
.then(res => {
message.success("操作成功");
_onCancel();
setLoading(false);
onRefresh();
}).catch(err => {
message.error(err?.message);
setLoading(false);
});
};
/**
* @description: 关闭弹框
* @param {*}
* @return {*}
*/
const _onCancel = () => {
onCancel && onCancel();
form.resetFields();
};
return (
<Modal
title={`${id ? '编辑':'新增'}快递收费标准`}
visible={visible}
confirmLoading={loading}
onCancel={_onCancel}
onOk={form.submit}
cancelButtonProps={{ hidden: true }}
width="50%"
bodyStyle={{minHeight: 300}}
>
<Skeleton loading={false}>
<Form form={form} onFinish={handleSave} wrapperCol={{ span: 18 }} labelCol={{ span: 4 }}>
<Form.Item
|
1c4a8623
谢忠泽
fix:快递收费标准配置文案修改
|
91
|
label="快递公司"
|
0bc2e94e
谢忠泽
add:快递收费标准配置
|
92
|
name="tradeComp"
|
1c4a8623
谢忠泽
fix:快递收费标准配置文案修改
|
93
|
rules={[{required: true, message: '请选择快递公司'}]}
|
0bc2e94e
谢忠泽
add:快递收费标准配置
|
94
95
|
>
<Select
|
1c4a8623
谢忠泽
fix:快递收费标准配置文案修改
|
96
|
placeholder="请选择快递公司"
|
0bc2e94e
谢忠泽
add:快递收费标准配置
|
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
showSearch
allowClear
optionFilterProp="children"
labelInValue
onSelect={(it:any) => {
const item = compList.filter((i:any) => it.value === i.id);
}}
filterOption={(input, option: any) => option?.children.indexOf(input) >= 0}
>
{
compList.map(item => (
<Select.Option value={item.id} key={item.id}>
{item.name}
</Select.Option>
))
}
</Select>
</Form.Item>
<Form.Item
label="寄件地区"
name="sendArea"
rules={[{required: true, message: '请选择寄件地区'}]}
>
<Select
placeholder="请选择寄件地区"
showSearch
allowClear
optionFilterProp="children"
labelInValue
onSelect={(it:any) => {
const item = cityList.filter((i:any) => it.value === i.id);
}}
filterOption={(input, option: any) => option?.children.indexOf(input) >= 0}
>
{
cityList.map(item => (
<Select.Option value={item.bh} key={item.bh}>
|
a35a7955
谢忠泽
fix:收寄件字段名
|
134
|
{item.fullName}
|
0bc2e94e
谢忠泽
add:快递收费标准配置
|
135
136
137
138
139
140
|
</Select.Option>
))
}
</Select>
</Form.Item>
<Form.Item
|
0bc2e94e
谢忠泽
add:快递收费标准配置
|
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
label="到达地区"
name="arriveAreas"
rules={[{required: true, message: '请选择到达地区'}]}
>
<Select
placeholder={`请选择到达地区${id ? '' : '(支持多选)'}`}
mode={id ? undefined : 'multiple'}
showSearch
allowClear
showArrow
optionFilterProp="children"
labelInValue
onSelect={(it:any) => {
const item = cityList.filter((i:any) => it.value === i.id);
}}
filterOption={(input, option: any) => option?.children.indexOf(input) >= 0}
>
{
cityList.map(item => (
<Select.Option value={item.bh} key={item.bh}>
|
a35a7955
谢忠泽
fix:收寄件字段名
|
161
|
{item.fullName}
|
0bc2e94e
谢忠泽
add:快递收费标准配置
|
162
163
164
165
166
|
</Select.Option>
))
}
</Select>
</Form.Item>
|
1c4a8623
谢忠泽
fix:快递收费标准配置文案修改
|
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
<Form.Item
label="首重"
name="firstWeight"
rules={[{required: true, message: '请填写首重'}]}
>
<InputNumber placeholder="请填写" addonAfter="元" max={100000000} min={0} precision={2} />
</Form.Item>
<Form.Item
label="续重"
name="continuedWeight"
rules={[{required: true, message: '请填写续重'}]}
>
<InputNumber placeholder="请填写" addonAfter="元/kg" max={100000000} min={0} precision={2} />
</Form.Item>
|
0bc2e94e
谢忠泽
add:快递收费标准配置
|
181
182
183
184
185
186
187
|
</Form>
</Skeleton>
</Modal>
);
}
export default AddModel;
|