AfterSalesDrawer.tsx
2.69 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
import { RESPONSE_CODE } from '@/constants/enum';
import { postServiceOrderApplyAfterSales } from '@/services';
import { enumToSelect } from '@/utils';
import {
DrawerForm,
ProFormDigit,
ProFormSelect,
ProFormTextArea,
ProFormUploadDragger,
} from '@ant-design/pro-components';
import { Form, message } from 'antd';
import { AFTE_SALES_PLAN_OPTIONS } from '../constant';
export default ({ setVisible, mainOrder, subOrders, onClose }) => {
let subOrderIds = subOrders?.map((item: { id: any }) => {
return item.id;
});
let mainOrderId = mainOrder.id;
const [form] = Form.useForm<{
afterSalesNotes: string;
afterSalesPlan: string;
ids: [];
totalPayment: number;
filePaths: any[];
}>();
return (
<DrawerForm<{
afterSalesNotes: string;
afterSalesPlan: string;
subOrderIds: [];
totalPayment: number;
mainId: number;
filePaths: any[];
}>
title="申请售后"
open
resize={{
onResize() {
console.log('resize!');
},
maxWidth: window.innerWidth * 0.8,
minWidth: 500,
}}
form={form}
autoFocusFirstInput
drawerProps={{
destroyOnClose: true,
onClose: () => {
setVisible(false);
},
}}
onFinish={async (values) => {
values.subOrderIds = subOrderIds;
values.mainId = mainOrderId;
values.filePaths = values.filePaths?.map((file) => {
return { url: file.response.data[0] };
});
let res = await postServiceOrderApplyAfterSales({ data: values });
if (res?.result === RESPONSE_CODE.SUCCESS) {
message.success(res.message);
onClose();
}
}}
>
<ProFormSelect
key="key"
label="售后方案"
width="lg"
showSearch
name="afterSalesPlan"
options={enumToSelect(AFTE_SALES_PLAN_OPTIONS)}
placeholder="请搜索"
rules={[{ required: true, message: '售后方案必填' }]}
></ProFormSelect>
<ProFormDigit
width="lg"
name="totalPayment"
label="总金额调整"
min={0}
initialValue={mainOrder.totalPayment}
rules={[{ required: true, message: '总金额必填' }]}
/>
<ProFormTextArea
width="lg"
label="售后原因"
name="afterSalesNotes"
rules={[{ required: true, message: '售后原因必填' }]}
/>
<ProFormUploadDragger
key="filePaths"
label="附件"
name="filePaths"
action="/api/service/order/fileProcess"
fieldProps={{
headers: { Authorization: localStorage.getItem('token') },
}}
/>
</DrawerForm>
);
};