Commit d35a137b00df7160e194dc1cd1b9652079f979ec
1 parent
8ccad1f0
feat: update
Showing
1 changed file
with
86 additions
and
0 deletions
src/pages/Order/components/AfterSalesDrawer.tsx
0 → 100644
1 | +import { RESPONSE_CODE } from '@/constants/enum'; | ||
2 | +import { postServiceOrderApplyAfterSales } from '@/services'; | ||
3 | +import { enumToSelect } from '@/utils'; | ||
4 | +import { | ||
5 | + DrawerForm, | ||
6 | + ProFormDigit, | ||
7 | + ProFormSelect, | ||
8 | + ProFormTextArea, | ||
9 | +} from '@ant-design/pro-components'; | ||
10 | +import { Form, message } from 'antd'; | ||
11 | +import { AFTE_SALES_PLAN_OPTIONS } from '../constant'; | ||
12 | +export default ({ setVisible, mainOrder, subOrders, onClose }) => { | ||
13 | + console.log(subOrders); | ||
14 | + console.log(mainOrder); | ||
15 | + let subOrderIds = subOrders?.map((item: { id: any }) => { | ||
16 | + return item.id; | ||
17 | + }); | ||
18 | + let mainOrderId = mainOrder.id; | ||
19 | + const [form] = Form.useForm<{ | ||
20 | + afterSalesNotes: string; | ||
21 | + afterSalesPlan: string; | ||
22 | + ids: []; | ||
23 | + totalPayment: number; | ||
24 | + }>(); | ||
25 | + | ||
26 | + return ( | ||
27 | + <DrawerForm<{ | ||
28 | + afterSalesNotes: string; | ||
29 | + afterSalesPlan: string; | ||
30 | + subOrderIds: []; | ||
31 | + totalPayment: number; | ||
32 | + mainId: number; | ||
33 | + }> | ||
34 | + title="申请售后" | ||
35 | + open | ||
36 | + resize={{ | ||
37 | + onResize() { | ||
38 | + console.log('resize!'); | ||
39 | + }, | ||
40 | + maxWidth: window.innerWidth * 0.8, | ||
41 | + minWidth: 500, | ||
42 | + }} | ||
43 | + form={form} | ||
44 | + autoFocusFirstInput | ||
45 | + drawerProps={{ | ||
46 | + destroyOnClose: true, | ||
47 | + onClose: () => { | ||
48 | + setVisible(false); | ||
49 | + }, | ||
50 | + }} | ||
51 | + onFinish={async (values) => { | ||
52 | + values.subOrderIds = subOrderIds; | ||
53 | + values.mainId = mainOrderId; | ||
54 | + let res = await postServiceOrderApplyAfterSales({ data: values }); | ||
55 | + if (res?.result === RESPONSE_CODE.SUCCESS) { | ||
56 | + message.success(res.message); | ||
57 | + onClose(); | ||
58 | + } | ||
59 | + }} | ||
60 | + > | ||
61 | + <ProFormSelect | ||
62 | + key="key" | ||
63 | + label="售后方案" | ||
64 | + width="lg" | ||
65 | + showSearch | ||
66 | + name="afterSalesPlan" | ||
67 | + options={enumToSelect(AFTE_SALES_PLAN_OPTIONS)} | ||
68 | + placeholder="请搜索" | ||
69 | + rules={[{ required: true, message: '售后方案必填' }]} | ||
70 | + ></ProFormSelect> | ||
71 | + <ProFormDigit | ||
72 | + width="lg" | ||
73 | + name="totalPayment" | ||
74 | + label="总金额调整" | ||
75 | + min={0} | ||
76 | + rules={[{ required: true, message: '总金额必填' }]} | ||
77 | + /> | ||
78 | + <ProFormTextArea | ||
79 | + width="lg" | ||
80 | + label="售后原因" | ||
81 | + name="afterSalesNotes" | ||
82 | + rules={[{ required: true, message: '售后原因必填' }]} | ||
83 | + /> | ||
84 | + </DrawerForm> | ||
85 | + ); | ||
86 | +}; |