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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
<template>
<el-dialog
:visible.sync="dialogVisible"
width="80%"
:before-close="
() => {
$emit('update:dialogVisible', false);
}
"
>
<div class="fee-application">
<h1>{{ $t("费用申请") }}-{{ orderDetails.orderNo }}</h1>
<el-divider></el-divider>
<el-form label-width="100px" inline>
<el-form-item :label="$t('订单号') + ':'"
>
<div class="content">
{{ orderDetails.orderNo }}
</div>
</el-form-item
>
<el-form-item :label="$t('发货人') + ':'"
>
<div class="content">
{{ orderDetails.consignorVO ? orderDetails.consignorVO.name : "" }}
</div>
</el-form-item
>
<el-form-item :label="$t('唛头')"
>
<div class="content">{{ orderDetails.marks }}</div>
</el-form-item
>
<el-form-item>
<el-button
:disabled="!!processInstanceId "
@click="addCost"
>{{ $t("添加申请") }}
</el-button
>
</el-form-item
>
</el-form>
<el-table :data="list">
<el-table-column :label="$t('序号')" type="index"></el-table-column>
<el-table-column :label="$t('费用类型')">
<template v-slot:default="scope">
<dict-selector
:disabled="!scope.row.editMode && !!scope.row.status"
:type="DICT_TYPE.FEE_TYPE"
v-model="scope.row.feeType"
@change="updatePayer(scope.row)"
/>
</template>
</el-table-column>
<el-table-column :label="$t('金额')">
<template v-slot:default="scope">
<el-input
:disabled="!scope.row.editMode && !!scope.row.status"
v-model.number="scope.row.applicationFee"
></el-input>
</template>
</el-table-column>
<el-table-column :label="$t('货币类型')">
<template v-slot:default="scope">
<el-select
:disabled="!scope.row.editMode && !!scope.row.status"
v-model="scope.row.applicationFeeCurrency"
>
<el-option
v-for="item in JSON.parse(currencys)"
:key="item.id"
:label="isChinese ? item.titleZh : item.titleEn"
:value="item.id"
/>
</el-select>
</template>
</el-table-column>
<el-table-column :label="$t('付款类型')">
<template v-slot="{ row }">
<dict-selector
:disabled="!row.editMode && !!row.status"
:type="DICT_TYPE.PAYMENT_TYPE"
v-model="row.payType"
/>
</template>
</el-table-column>
<el-table-column :label="$t('付款人')">
<template v-slot="{ row }">
<dict-selector
:disabled="!row.editMode && !!row.status"
:type="DICT_TYPE.DRAWEE"
:filter="payerDictFilter"
v-model="row.payer"
/>
</template>
</el-table-column>
<el-table-column :label="$t('备注')">
<template v-slot:default="scope">
<el-input
:disabled="!scope.row.editMode && !!scope.row.status"
v-model="scope.row.remarks"
type="textarea"
></el-input>
</template>
</el-table-column>
<el-table-column :label="$t('确认收款')">
<template v-slot:default="scope">
<dict-tag
:type="DICT_TYPE.ECW_RECEIVABLE_STATE"
:value="scope.row.receiveFlag"
/>
</template>
</el-table-column>
<el-table-column :label="$t('申请人')">
<template v-slot:default="scope">
{{
scope.row.status === 0
? $t("未提交")
: scope.row.applicationAuthor
}}
</template>
</el-table-column>
<el-table-column :label="$t('操作')">
<template v-slot:default="scope">
<el-tag v-if="scope.row.status !== 0 && !scope.row.editMode">{{
STATUS[scope.row.status]
}}
</el-tag>
<!--el-button type="text" v-if="scope.row.status == 1" @click="examineFn">{{$t('审核中')}}</el-button-->
<el-button
type="text"
v-if="scope.row.id && modifable(scope.row)"
@click="modify(scope.row)"
>{{ $t("修改") }}
</el-button
>
<el-button
type="text"
v-if="scope.row.status === 0"
@click="del(scope.$index)"
>删除
</el-button
>
<el-button
type="text"
v-if="scope.row.id && scope.row.applicationFee === 0 && scope.row.status === 2 && !scope.row.editMode"
@click="deleteByFeeIsZero(scope.row.id)"
>删除
</el-button
>
</template>
</el-table-column>
</el-table>
<div style="padding: 20px">
<work-flow xmlkey="free_apply" v-model="selectedUsers"/>
</div>
<div style="text-align: center; margin-top: 20px">
<el-button
type="primary"
v-if="!processInstanceId"
style="margin-right: 30px"
:disabled="!feeList.length && !editMode"
@click="submit"
>{{ $t("提交") }}
</el-button>
<el-button
type="primary"
v-if="processInstanceId"
style="margin-right: 30px"
@click="goProcessDetail"
>{{ $t("审核中") }}
</el-button
>
<el-button
type="primary"
v-if="processInstanceId"
style="margin-right: 30px"
@click="cancel"
>{{ $t("取消审核") }}
</el-button
>
<el-button @click="$emit('update:dialogVisible', false)">{{
$t("返回")
}}
</el-button>
</div>
</div>
</el-dialog>
</template>
<script>
import {
getOrder,
feeApplicationCreateBatch,
ApplicationListByOrderId,
applicationUpdate,
feeApplicationListByOrderId,
feeApplicationCancel,
getFeeApplicationApproveByOrderId,
getBatchFeeByProcessId,
qetBatchFeeByBusinessId,
getBatchFeeByBusinessId, feeApplicationDelete, getFeeDraweeByFeeType,
} from "@/api/ecw/order";
import {getDictDatas, DICT_TYPE} from "@/utils/dict";
import workFlow from "@/components/WorkFlow";
export default {
name: "feeApplication",
components: {workFlow},
props: {
orderId: [Number, String],
dialogVisible: {
type: Boolean,
default: false,
},
currencys: String,
},
data() {
return {
orderDetails: {},
// 费用列表
list: [],
// 审核ID,没有则表示不在审核中
processInstanceId: null,
DICT_TYPE,
getDictDatas,
STATUS: {},
selectedUsers: [],
};
},
computed: {
isChinese() {
return this.$i18n.locale === "zh_CN";
},
feeList() {
// return this.list.filter((item) => item.status === 0);
return this.list;
},
// 正在编辑的费用申请
currentItem() {
return this.list.find((item) => item.editMode);
},
// 是否修改模式
editMode() {
return !!this.currentItem;
},
modifable() {
return (item) => {
// 审核中不允许修改
if (this.processInstanceId) return false;
// 有未提交的不允许修改
// if (this.feeList.length) return false;
// 修改中的不允许修改
if (item.editMode) return false;
return true;
}
}
},
created() {
this.getDictDatas(this.DICT_TYPE.AUDIT_STATUS).forEach((e) => {
this.STATUS[e.value] = e.label;
});
getOrder(this.orderId).then((res) => {
this.orderDetails = res.data;
});
// 查询历史申请
feeApplicationListByOrderId({orderId: this.orderId}).then((res) => {
this.list = res.data;
});
// 查询是否有审核中的费用申请
getFeeApplicationApproveByOrderId(this.orderId).then((res) => {
if (res.data) {
this.processInstanceId = res.data.formId;
/*getBatchFeeByBusinessId(res.data.orderApprovalId).then(res => {
this.list = res.data
})*/
}
});
},
methods: {
del(index) {
this.$confirm(this.$t("确定要删除此条费用申请么?")).then(() => {
this.list.splice(index, 1);
});
},
// 过滤订单状态筛选字典内容
payerDictFilter(item) {
if (item.value && item.value == 3) {
return false
}
return true
},
// 修改
modify(item) {
this.$set(item, "editMode", true);
},
updatePayer(item) {
console.log("变动的费用记录:", item);
this.$nextTick(() => {
// 根据新费用类型和索引更新payer付款人信息
this.orderDetails.drawee ? (this.orderDetails.drawee != 3 ? this.$set(item, "payer", this.orderDetails.drawee) : this.getDraweePayer(item)) : undefined; // 费用申请付款人
console.log("变动的费用记录:", item);
})
},
getDraweePayer(item) {
let feeType = item.feeType
if (feeType) {
getFeeDraweeByFeeType(feeType).then(res => {
console.log(res.data)
let drawee = res.data
console.log("自定义费用枚举值:", drawee)
if (drawee) {
if (this.orderDetails.customDraweeVOList && this.orderDetails.customDraweeVOList.length > 0) {
let customDrawee = this.orderDetails.customDraweeVOList.find(item => item.name == drawee)
console.log("自定义费用类型值:", customDrawee)
if (customDrawee) {
console.log("返回值:", customDrawee.value)
this.$set(item, "payer", customDrawee.value)
}
}
}
});
}
},
addCost() {
this.list.push({
orderId: this.orderId,
feeType: undefined, //费用申请类型
applicationFee: undefined, //金额
applicationFeeCurrency: undefined, // 费用申请货币类型
payer: this.orderDetails.drawee && this.orderDetails.drawee != 3 ? this.orderDetails.drawee : undefined, // 费用申请付款人
remarks: undefined,
receiveFlag: 0,
applicationAuthor: undefined,
status: 0,
});
},
deleteByFeeIsZero(id) {
this.$confirm(this.$t("确定要删除此条费用申请么?")).then(() => {
feeApplicationDelete(id).then((r) => {
this.$message({
type: "success",
message: this.$t("删除成功"),
});
this.$emit("update:dialogVisible", false);
});
});
},
submit() {
// 判断费用申请是否有未填项
// console.log("提交的费用信息列表", this.feeList)
const errList = this.feeList.filter((item) => {
return (
!item["feeType"] ||
item.applicationFee == null || item.applicationFee == undefined ||
!item["applicationFeeCurrency"] ||
!item["payType"]
);
});
if (errList.length) {
return this.$message.error("请填写完整费用申请信息");
}
// if (this.editMode) {
// // 要提交status=1,否则保持原状态
// const data = {
// ...this.currentItem,
// status: 1,
// copyUserId: this.selectedUsers,
// };
// return applicationUpdate(data).then((r) => {
// this.$message.success(this.$t("修改成功"));
// this.$emit("update:dialogVisible", false);
// });
// }
feeApplicationCreateBatch({
orderFeeApplicationCreateReqVOList: this.feeList,
copyUserId: this.selectedUsers,
orderId: this.orderId,
}).then((r) => {
if (r.code === 0) {
this.$emit("update:dialogVisible", false);
this.$message.success(this.$t("添加成功"));
this.selectedUsers = [];
this.$emit("refresh")
}
});
},
goProcessDetail() {
this.$emit("update:dialogVisible", false);
this.$router.push(
"/bpm/process-instance/detail?id=" + this.processInstanceId
);
},
cancel() {
this.$prompt(this.$t("请输入取消原因"), this.$t("提示"), {
confirmButtonText: this.$t("确定"),
cancelButtonText: this.$t("取消"),
})
.then(({value}) => {
let item = this.list.find((e) => e.status === 1);
feeApplicationCancel({
huifu: value,
bpmProcessId: this.processInstanceId,
}).then((r) => {
this.$message({
type: "success",
message: this.$t("取消成功"),
});
this.$emit("update:dialogVisible", false);
});
})
.catch(() => {
});
},
},
watch: {
dialogVisible(val) {
if (val) {
this.getOrderList();
getOrder(this.orderId).then((r) => {
if (r.code === 0) {
this.orderDetails = r.data;
}
});
}
},
},
};
</script>
<style scoped lang="scss">
.fee-application {
padding: 0 20px;
h1 {
font-weight: 600;
font-size: 20px;
}
.content {
width: 200px;
}
}
.my-process-designer {
height: calc(100vh - 200px);
}
.box-card {
width: 100%;
margin-bottom: 20px;
}
</style>