|
1
|
import { RESPONSE_CODE } from '@/constants/enum';
|
|
2
3
4
5
|
import {
postServiceOrderCheckOrder,
postServiceOrderFinanceCheckOrder,
} from '@/services';
|
sanmu
authored
|
6
|
import { ModalForm, ProFormTextArea } from '@ant-design/pro-components';
|
|
7
|
import { Button, Form, message } from 'antd';
|
|
8
9
10
11
12
13
14
15
|
import { CHECK_TYPE } from '../constant';
export default ({
setCheckVisible,
data,
subOrders,
orderCheckType,
onClose,
}) => {
|
sanmu
authored
|
16
|
const [form] = Form.useForm<{ name: string; company: string }>();
|
|
17
18
|
let subOrderIds: any[] = [];
//是单条子订单审核
|
|
19
|
if (subOrders === undefined) {
|
|
20
21
|
subOrderIds = [data.id];
} else {
|
|
22
|
subOrderIds = subOrders.map((subOrder) => subOrder.id);
|
|
23
|
}
|
|
24
|
|
|
25
|
async function doCheck(body: object) {
|
|
26
|
const data = await postServiceOrderCheckOrder({
|
|
27
28
|
data: body,
});
|
|
29
30
|
if (data.result === RESPONSE_CODE.SUCCESS) {
message.success(data.message);
|
|
31
|
onClose();
|
|
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
|
/**
*
* @param body 财务审核
*/
async function doFinancailCheck(body: object) {
const data = await postServiceOrderFinanceCheckOrder({
data: body,
});
if (data.result === RESPONSE_CODE.SUCCESS) {
message.success(data.message);
onClose();
}
}
/**
* 审核类型
*/
function checkType(check: string) {
if (orderCheckType === check) {
return true;
}
return false;
}
|
sanmu
authored
|
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
return (
<ModalForm<{
name: string;
company: string;
}>
width={500}
open
title="审核"
form={form}
autoFocusFirstInput
modalProps={{
okText: '通过',
cancelText: '驳回',
destroyOnClose: true,
onCancel: () => {
setCheckVisible(false);
},
}}
|
|
77
78
|
submitter={{
render: (props, defaultDoms) => {
|
|
79
80
|
let myDoms = [];
myDoms.push(
|
|
81
82
83
|
<Button
key="驳回"
onClick={() => {
|
|
84
85
86
87
88
89
90
91
92
93
94
95
|
if (checkType(CHECK_TYPE.NORMAL)) {
doCheck({
flag: false,
ids: subOrderIds,
externalProcurement: 0,
checkNotes: form.getFieldValue('name'),
});
return;
}
//财务审核
doFinancailCheck({
|
|
96
|
checkNotes: form.getFieldValue('name'),
|
|
97
98
|
ids: subOrderIds,
checkPassOrReject: false,
|
|
99
100
101
102
103
|
});
}}
>
驳回
</Button>,
|
|
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
);
//如果不是财务审核,那么显示这个外部采购
if (checkType(CHECK_TYPE.NORMAL)) {
myDoms.push(
<Button
key="外部采购"
onClick={() => {
doCheck({
flag: false,
ids: subOrderIds,
externalProcurement: 1,
checkNotes: form.getFieldValue('name'),
});
}}
>
外部采购
</Button>,
);
}
//确认
myDoms.push(defaultDoms[1]);
return myDoms;
|
|
128
129
|
},
}}
|
sanmu
authored
|
130
131
|
submitTimeout={2000}
onFinish={async (values) => {
|
|
132
133
134
135
136
137
138
139
140
141
142
143
|
if (checkType(CHECK_TYPE.NORMAL)) {
//审核通过
return doCheck({
flag: true,
ids: subOrderIds,
externalProcurement: 0,
checkNotes: values.name,
});
}
//财务审核
return doFinancailCheck({
|
|
144
|
checkNotes: values.name,
|
|
145
146
|
ids: subOrderIds,
checkPassOrReject: true,
|
|
147
|
});
|
sanmu
authored
|
148
|
}}
|
|
149
|
onOpenChange={setCheckVisible}
|
sanmu
authored
|
150
151
152
153
154
155
156
157
158
159
|
>
<div>请特别注意订单总金额与订单金额。</div>
<ProFormTextArea
width="lg"
name="name"
placeholder="若驳回,请填写驳回理由"
/>
</ModalForm>
);
};
|