StatusTransitionModal.tsx
2.34 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
import { RESPONSE_CODE } from '@/constants/enum';
import {
postProcureReturnBillAudit,
postProcureReturnBillSend,
} from '@/services';
import { ModalForm, ProFormTextArea } from '@ant-design/pro-components';
import { Button, Form, message } from 'antd';
export default ({ type, ids, reloadTable }) => {
const transitionTypes = {
audit: {
title: '审核',
notesLabel: '驳回原因',
notesPlaceholder: '请输入驳回原因',
submitText: '通过',
resetText: '驳回',
onfinish: async (values) => {
const res = await postProcureReturnBillAudit({
data: {
ids: ids,
transitionNotes: values.transitionNotes,
},
});
if (res.result === RESPONSE_CODE.SUCCESS) {
message.success('操作成功');
reloadTable();
return true;
} else {
message.error('操作失败');
}
},
},
send: {
title: '发货',
notesLabel: '发货信息',
notesPlaceholder: '请输入发货信息(如:顺丰快递,SF24070802324)',
submitText: '发货',
resetText: '取消',
onfinish: async (values) => {
const res = await postProcureReturnBillSend({
data: {
ids: ids,
transitionNotes: values.transitionNotes,
},
});
if (res.result === RESPONSE_CODE.SUCCESS) {
message.success('操作成功');
reloadTable();
return true;
} else {
message.error('操作失败');
}
},
},
};
const [form] = Form.useForm();
return (
<ModalForm
title={transitionTypes[type].title}
trigger={
<Button size={'small'} type="link">
{transitionTypes[type].title}
</Button>
}
form={form}
autoFocusFirstInput
modalProps={{
destroyOnClose: true,
onCancel: () => console.log('run'),
}}
submitter={{
searchConfig: {
submitText: transitionTypes[type].submitText,
resetText: transitionTypes[type].resetText,
},
}}
onFinish={transitionTypes[type].onfinish}
>
<ProFormTextArea
name="transitionNotes"
label={transitionTypes[type].notesLabel}
placeholder={transitionTypes[type].notesPlaceholder}
/>
</ModalForm>
);
};