BehalfMoney.tsx
5.98 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
import React, { useEffect, useState } from "react";
import {
Button,
Modal,
Form,
Select,
InputNumber,
Radio,
message,
Spin,
Input,
} from "antd";
import {
getOrderDetail,
saveDiffApi,
saveSubsidyDiffApi,
} from "../Manufacturer/api";
import { useStore } from "../index";
import _ from "lodash";
import useInitail from "@/hooks/useInitail";
import moment from "moment";
const { TextArea } = Input;
const Option = Select.Option;
interface Props {
visible: boolean;
onCancel: Function;
// eslint-disable-next-line react/require-default-props
orderId?: number;
fetchList: () => any;
}
export default function CreateModal(props: Props) {
const [form] = Form.useForm();
const { visible, onCancel, fetchList, orderId } = props;
// differenceItem,
const {
reasonList,
commonOrderDetail,
currentItem,
commonSaveDiffApi,
differenceItem,
setDifferencetItem,
rebateId,
} = useStore();
const [saveLoading, setSaveLoading] = useState(false);
// function handSubmit(fieldsValue: any) {
// const param: any = {
// orderId,
// actualRebateAmount: fieldsValue.actualRebateAmount,
// reason:
// fieldsValue.type && fieldsValue.type === 1
// ? fieldsValue.writeReason
// : fieldsValue.reason && fieldsValue.reason.label,
// };
// setSaveLoading(true);
// const api = commonSaveDiffApi[currentItem.rebateFundsType];
// api(param)
// .then(() => {
// message.success("操作成功");
// setSaveLoading(false);
// fetchList && fetchList();
// onCancel && onCancel();
// setData({});
// })
// .catch((e) => {
// message.error(e.message);
// setSaveLoading(false);
// });
// }
function handSubmit(fieldsValue: any) {
const param: any = {
rebateId,
orderId: differenceItem.id,
actualRebateAmount: fieldsValue.actualRebateAmount,
reason:
fieldsValue.type && fieldsValue.type === 1
? fieldsValue.writeReason
: fieldsValue.reason && fieldsValue.reason.label,
subsidyType: currentItem.subsidyType,
};
setSaveLoading(true);
saveSubsidyDiffApi(param)
.then(() => {
message.success("操作成功");
setSaveLoading(false);
fetchList && fetchList();
onCancel && onCancel();
setDifferencetItem({});
})
.catch((e) => {
message.error(e.message);
setSaveLoading(false);
});
}
useEffect(() => {
if (visible) {
form.setFieldsValue({
...differenceItem,
});
}
}, [visible]);
return (
<Modal
title="确认折让差异"
visible={visible}
maskClosable={false}
confirmLoading={saveLoading}
afterClose={form.resetFields}
onCancel={() => onCancel()}
footer={[
<Button key="2" type="primary" onClick={form.submit}>
确认差异
</Button>,
]}
>
<Form
form={form}
labelCol={{ span: 7 }}
wrapperCol={{ span: 18 }}
onFinish={handSubmit}
>
{differenceItem.realName && (
<Form.Item label="客户" style={{ marginBottom: 0 }}>
{differenceItem.realName}
</Form.Item>
)}
<Form.Item label="车辆" style={{ marginBottom: 0 }}>
{differenceItem.materialName}
</Form.Item>
<Form.Item label="下零售时间" style={{ marginBottom: 0 }}>
{differenceItem.retailTime
? moment(differenceItem.retailTime).format("YYYY-MM-DD HH:mm:ss")
: "-"}
</Form.Item>
<Form.Item label="下零售门店" style={{ marginBottom: 0 }}>
{differenceItem.retailShopName || "-"}
</Form.Item>
<Form.Item label="下零售商家" style={{ marginBottom: 0 }}>
{differenceItem.dealerName || "-"}
</Form.Item>
<div style={{ height: 30 }} />
<Form.Item label="零售终端补贴金额" required>
{differenceItem.saleSubsidyAmount}元
</Form.Item>
<Form.Item label="应折让金额" required>
{differenceItem.rebateAmount}元
</Form.Item>
<Form.Item label="实际折让金额" required>
<Form.Item
noStyle
name="actualRebateAmount"
rules={[{ required: true, message: "请输入" }]}
>
<InputNumber placeholder="请输入" style={{ width: "60%" }} />
</Form.Item>
<span style={{ paddingLeft: 10 }}>元</span>
</Form.Item>
<Form.Item name="type" label="原因">
<Radio.Group>
<Radio value={1}>输入原因</Radio>
<Radio value={2}>选择原因</Radio>
</Radio.Group>
</Form.Item>
<Form.Item
noStyle
shouldUpdate={(prevValues, currentValues) =>
prevValues.type != currentValues.type
}
>
{({ getFieldValue }): any => {
return getFieldValue("type") == 1 ? (
<Form.Item
name="writeReason"
style={{ marginLeft: 130 }}
rules={[{ required: true, message: "请填写原因" }]}
>
<TextArea
allowClear
placeholder="请输入"
rows={2}
style={{ width: "100%" }}
/>
</Form.Item>
) : getFieldValue("type") == 2 ? (
<Form.Item
name="reason"
style={{ marginLeft: 130 }}
rules={[{ required: true, message: "请选择原因" }]}
>
<Select placeholder="选择原因" labelInValue>
{reasonList.map((item) => (
<Option value={item.id} key={item.id}>
{item.name}
</Option>
))}
</Select>
</Form.Item>
) : null;
}}
</Form.Item>
</Form>
</Modal>
);
}