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
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
<template>
<div class="app-container">
<el-card>
<div slot="header" class="card-title">
{{ $t("付款单详情") }}{{ id ? `-${form.paymentNo}` : "" }}
</div>
<el-form
ref="form"
:model="form"
label-width="120px"
label-position="left"
>
<el-descriptions :column="3" class="card" border>
<el-descriptions-item :label="$t('供应商')">
<el-form-item
label=""
label-width="0"
style="margin-bottom: 0"
prop="supplierId"
>
<!-- <customer-selector v-model="form.supplierId" @change="consignor = $event" /> -->
<el-select
v-model="form.supplierId"
:placeholder="$t('请选择供应商')"
disabled
>
<el-option
v-for="supplier in allSupplier"
:key="supplier.id"
:label="supplier.companyZh"
:value="supplier.id"
></el-option>
</el-select>
</el-form-item>
</el-descriptions-item>
<el-descriptions-item :label="$t('部门')">
<el-form-item
label=""
label-width="0"
style="margin-bottom: 0"
prop="departmentId"
>
<el-select
v-model="form.departmentId"
style="width: 300px"
disabled
>
<el-option
v-for="item in deptData"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-descriptions-item>
<el-descriptions-item :label="$t('业务员')">
<el-form-item
label=""
label-width="0"
style="margin-bottom: 0"
prop="salesmanName"
>
<el-select v-model="form.salesmanName" disabled>
<el-option
v-for="item in creatorData"
:key="item.id"
:label="item.nickname"
:value="item.nickname"
/>
</el-select>
</el-form-item>
</el-descriptions-item>
<el-descriptions-item :label="$t('申请日期')">
<el-form-item
label=""
label-width="0"
style="margin-bottom: 0"
prop="applicationAt"
>
<el-date-picker
clearable
v-model="form.applicationAt"
value-format="yyyy-MM-dd"
format="yyyy-MM-dd"
type="date"
disabled
/>
</el-form-item>
</el-descriptions-item>
<el-descriptions-item
:label="$t('供应商银行账号')"
style="width: 50%"
>
<el-form-item
label=""
label-width="0"
style="margin-bottom: 0"
prop="supplierBankAccount"
>
<el-select v-model="form.supplierBankAccount" disabled>
<el-option
v-for="item in bankData"
:key="item.id"
:label="item.bankName + '(' + item.bankAccount + ')'"
:value="item.bankAccount"
/>
</el-select>
</el-form-item>
</el-descriptions-item>
</el-descriptions>
<el-descriptions :column="3" class="card" border>
<el-descriptions-item :label="$t('实际付款日期')">
<el-form-item
label=""
label-width="0"
style="margin-bottom: 0"
prop="sjfkdate"
>
<el-date-picker
clearable
v-model="form.sjfkdate"
value-format="yyyy-MM-dd"
format="yyyy-MM-dd"
type="date"
disabled
/>
</el-form-item>
</el-descriptions-item>
<el-descriptions-item :label="$t('最后付款日期')">
<el-form-item
label=""
label-width="0"
style="margin-bottom: 0"
prop="latestPayAt"
>
<el-date-picker
clearable
v-model="form.latestPayAt"
value-format="yyyy-MM-dd"
format="yyyy-MM-dd"
type="date"
disabled
/>
</el-form-item>
</el-descriptions-item>
<el-descriptions-item :label="$t('结算方式')">
<el-form-item
label=""
label-width="0"
style="margin-bottom: 0"
prop="settlementType"
>
<dict-tag
:type="DICT_TYPE.CUSTOMER_BALANCE"
v-model="form.settlementType"
/>
</el-form-item>
</el-descriptions-item>
<el-descriptions-item :label="$t('付款备注')">
<el-form-item
label=""
label-width="0"
style="margin-bottom: 0"
prop="settlementType"
>
<el-input
v-model="form.reason"
type="text"
rows="2"
disabled
></el-input>
</el-form-item>
</el-descriptions-item>
<el-descriptions-item :label="$t('付款人')">
<el-form-item
label=""
label-width="0"
style="margin-bottom: 0"
prop="settlementType"
>
<el-input
v-model="form.fkren"
type="text"
rows="2"
disabled
></el-input>
</el-form-item>
</el-descriptions-item>
<!--lanbm 2024-05-17 添加字段-->
<el-descriptions-item :label="$t('核销时间')">
<el-form-item
label=""
label-width="0"
style="margin-bottom: 0"
prop="settlementType"
>
<el-input
v-model="form.hexiaodate"
type="text"
rows="2"
disabled
></el-input>
</el-form-item>
</el-descriptions-item>
</el-descriptions>
</el-form>
</el-card>
<el-card class="card">
<div slot="header" class="card-title">{{ $t("费用信息") }}</div>
<el-table
v-loading="loadings"
:data="list"
border
:show-summary="!!list.length"
:summary-method="getSummaries"
>
<el-table-column
:label="$t('自编号')"
align="center"
prop="payableNo"
/>
<el-table-column :label="$t('费用类型')" align="center" prop="feeType">
<template slot-scope="scope">
<dict-tag
:type="DICT_TYPE.FEE_TYPE"
:value="scope.row.feeType"
></dict-tag>
</template>
</el-table-column>
<el-table-column
:label="$t('发票号码')"
align="center"
prop="invoiceNumber"
/>
<el-table-column
:label="$t('应付金额')"
align="center"
prop="totalAmount"
/>
<el-table-column :label="$t('币种')" align="center" prop="currencyId">
<template slot-scope="scope">
{{ getCurrencyLabel(scope.row.currencyId) }}
<!-- <dict-tag :type="DICT_TYPE.BOX_SHIPPING_PRICE_UNIT" :value="scope.row.currencyId" /> -->
</template>
</el-table-column>
<el-table-column
:label="$t('汇率')"
align="center"
prop="exchangeRate"
/>
<el-table-column
:label="$t('税率') + '%'"
align="center"
prop="taxRate"
/>
<el-table-column
:label="$t('价税合计') + '(RMB)'"
align="center"
prop="total"
>
<template slot-scope="scope">
<!-- <span>{{ scope.row.total = ((scope.row.totalAmount * scope.row.exchangeRate) + (scope.row.totalAmount * scope.row.exchangeRate) * (scope.row.taxRate/100)).toFixed(6) }}</span> -->
<span>{{ scope.row.total }}</span>
</template>
</el-table-column>
</el-table>
<el-form
ref="forms"
:model="form"
label-width="120px"
label-position="left"
style="width: 50%"
>
<el-descriptions :column="1" class="card" border>
<el-descriptions-item :label="$t('账单号')">
<el-form-item
label=""
label-width="0"
style="margin-bottom: 0"
required
:error="$t('账单号不能为空')"
prop="accountNumber"
>
<el-input v-model="form.accountNumber" disabled></el-input>
</el-form-item>
</el-descriptions-item>
<el-descriptions-item :label="$t('发票')">
<el-form-item
label=""
label-width="0"
style="margin-bottom: 0"
prop="invoiceStatus"
>
<el-select v-model="form.invoiceStatus" disabled>
<el-option :label="$t('未开票')" value="0" />
<el-option :label="$t('已开票')" value="1" />
</el-select>
</el-form-item>
</el-descriptions-item>
<el-descriptions-item :label="$t('备注')">
<!--lanbm 2024-05-30 添加备注信息和附件上传功能-->
<el-form-item abel="" label-width="0" prop="editreason">
<el-input
v-model="form.editreason" disabled
></el-input>
</el-form-item>
</el-descriptions-item>
<el-descriptions-item :label="$t('附件')">
<el-form-item label="" label-width="0" prop="filelist">
<el-upload
v-if="!isView"
class="upload-demo"
:action="uploadFileUrl"
:headers="headers"
:on-success="handleUploadSuccess"
:before-upload="handleBeforeUpload"
:on-error="handleUploadError"
:before-remove="beforeRemove"
:file-list="form.filelist"
multiple
>
<!--filelist 是保存在数据库中的文件路径-->
<el-button size="small" type="primary">{{
$t("上传附件")
}}</el-button>
</el-upload>
<div v-else>
<div v-for="(v, i) in form.filelist" :key="i">
<el-link :href="v.url" type="primary" target="_blank">{{
v.name
}}</el-link>
</div>
</div>
</el-form-item>
</el-descriptions-item>
</el-descriptions>
</el-form>
</el-card>
<div slot="footer" style="margin: 20px 0">
<el-button
type="primary"
@click="$store.dispatch('tagsView/delCurrentView')"
>{{ $t("返回") }}</el-button
>
</div>
</div>
</template>
<script>
import { listSimpleUsers } from "@/api/system/user";
import { DICT_TYPE } from "@/utils/dict";
import { getToken } from "@/utils/auth";
import { getChannelList } from "@/api/ecw/channel";
import CustomerSelector from "@/components/CustomerSelector";
import { listSimpleDepts } from "@/api/system/dept";
import { getTradeCityList } from "@/api/ecw/region";
import { getSupplierPage, getSupplier } from "@/api/ecw/supplier";
import {
getPayableList,
getPayableInfoByIds,
createPayment,
getPaymentInfoByIds,
getPaymentItem,
updatePayment,
} from "@/api/ecw/financial";
import { getCurrencyPage } from "@/api/ecw/currency";
import NP from "number-precision";
export default {
name: "CreatPayment",
components: {
CustomerSelector,
},
data() {
return {
//lanbm 2024-05-31 add
isView: true,
id: 0,
payableId: 0,
orderData: [],
total: 0,
loadings: false,
open: false,
form: {},
creatorData: [],
list: [],
defaultList: [],
channelList: [],
loading: "",
bankData: [],
params: {
page: 1,
rows: 20,
},
deptData: [],
deptArr: [],
queryParams: {
page: 1,
rows: 20,
},
multipleSelection: [],
tradeCityList: [],
allSupplier: [],
currencyList: [],
};
},
async created() {
await getCurrencyPage(this.params).then(
(res) => (this.currencyList = res.data.list)
);
let that = this;
if (that.$route.query.payableId && that.$route.query.payableId !== "0") {
this.payableId = this.$route.query.payableId;
getPayableInfoByIds({ id: this.payableId }).then((res) => {
this.list = [{ ...res.data }];
this.$set(this.form, "supplierId", res.data.supplierId);
});
}
if (that.$route.query.id && that.$route.query.id !== "0") {
this.id = this.$route.query.id;
getPaymentInfoByIds({ id: this.id }).then((res) => {
this.form = {
...res.data,
latestPayAt: this.parseTime(res.data.latestPayAt, "{y}-{m}-{d}"),
applicationAt: this.parseTime(res.data.applicationAt, "{y}-{m}-{d}"),
invoiceStatus: String(res.data.invoiceStatus),
};
this.$set(
this.form,
"supplierBankAccount",
res.data.supplierBankAccount
);
console.log(this.form);
});
getPaymentItem({ id: this.id }).then((res) => {
this.list = [...res.data];
this.defaultList = [...res.data];
});
}
listSimpleUsers().then((res) => (that.creatorData = res.data));
getChannelList().then((res) => (that.channelList = res.data));
getTradeCityList().then((res) => (that.tradeCityList = res.data));
getSupplierPage({ pageNo: "1", pageSize: "10000" }).then((res) => {
const { data } = res;
this.allSupplier = data.list;
this.selectChange(this.form.supplierId);
});
listSimpleDepts().then((res) => {
that.deptData = res.data;
});
},
computed: {
expoerCityList() {
return this.tradeCityList.filter((item) => item.type == 2);
},
importCityList() {
return this.tradeCityList.filter((item) => item.type == 1);
},
},
methods: {
getCurrencyLabel(id) {
var label = this.currencyList.filter((item) => item.id == id);
if (label.length > 0)
return this.$i18n.locale == "zh_CN"
? label[0].titleZh
: label[0].titleEn;
return "";
},
getList() {
this.loading = true;
// 处理查询参数
let params = { ...this.queryParams };
this.addBeginAndEndTime(params, this.dateRangeCreateTime, "createTime");
// 执行查询
getPayableList(params).then((response) => {
this.orderData = response.data.list;
this.total = response.data.total;
this.loading = false;
this.$nextTick(() => {
this.list.forEach((itm) => {
const t = this.orderData.find((v) => v.id == itm.id);
t && this.$refs.multipleTable.toggleRowSelection(t, true);
});
});
});
},
getSummaries(param) {
const { columns, data } = param;
const sums = new Array(columns.length).map((v) => "");
const index = sums.length - 1;
sums[index - 1] = this.$t("价税合计大写");
const t = data
.map((v) => v.total)
.reduce((prev, curr) => {
return parseFloat(prev) + parseFloat(curr);
}, 0);
sums[index] = this.convertCurrency(t);
return sums;
},
/** 新增按钮操作 */
handleAdd() {
this.open = true;
},
submitForm() {
this.$refs.form.validate((valid) => {
if (valid) {
this.$refs.forms.validate((val) => {
if (val) {
const params = { ...this.form };
if (this.list && this.list.length > 0) {
params.payableReqVOList = [...this.list];
} else {
this.$modal.msgError(this.$t("请选择供应商未付款项"));
return;
}
if (!params.supplierBankAccount) {
this.$modal.msgError(this.$t("请选择供应商银行账号"));
return;
}
if (this.id && this.id !== "0") {
updatePayment(params).then((res) => {
this.$modal.msgSuccess(this.$t("修改成功"));
this.$router.back();
});
} else {
createPayment(params).then((res) => {
this.$modal.msgSuccess(this.$t("新增成功"));
this.$router.back();
});
}
}
});
}
});
},
submitDraft() {
this.$refs.form.validate((valid) => {
if (valid) {
const params = { ...this.form };
if (this.list && this.list.length > 0) {
params.payableReqVOList = [...this.list];
} else {
this.$modal.msgError(this.$t("请选择供应商未付款项"));
return;
}
if (!params.supplierBankAccount) {
this.$modal.msgError(this.$t("请选择供应商银行账号"));
return;
}
if (this.id && this.id !== "0") {
updatePayment(params).then((res) => {
this.$modal.msgSuccess(this.$t("修改成功"));
this.$router.back();
});
} else {
createPayment(params).then((res) => {
this.$modal.msgSuccess(this.$t("新增成功"));
this.$router.back();
});
}
// console.log(params, '-----params---------')
}
});
},
selectChangeBank(val) {
this.$forceUpdate();
},
selectChange(val) {
this.bankData = [];
// this.form.supplierBankAccount=''
if (val) {
getSupplier(val).then((res) => {
this.bankData = res.data.bankList;
var bank = this.bankData.find(
(item) => item.bankAccount == this.form.supplierBankAccount
);
if (this.bankData.length == 0 || !bank)
this.form.supplierBankAccount = "";
});
}
const t = this.allSupplier.find((v) => v.id == val);
t && (this.form.supplierName = t.companyZh);
// t && (this.bankData = t.bankList)
},
handleQuery() {
this.queryParams.page = 1;
this.getList();
},
UStoRMB() {
return NP.divide(
this.currencyList.find((v) => v.titleEn === "USD").huilv,
100
).toFixed(6);
},
NANtoRMB() {
return NP.divide(
this.currencyList.find((v) => v.titleEn === "NGN").huilv,
100
).toFixed(6);
},
handleSelectionChange(val) {
this.multipleSelection = val.map((v) => {
if (v.currencyId === 1)
return Object.assign(v, { exchangeRate: this.UStoRMB() });
if (v.currencyId === 2) return Object.assign(v, { exchangeRate: 1 });
if (v.currencyId === 3)
return Object.assign(v, { exchangeRate: this.NANtoRMB() });
});
},
hiddenDialog() {
this.open = false;
},
saveSelectList() {
if (this.id && this.id !== "0") {
this.list = [...this.defaultList, ...this.multipleSelection];
} else {
this.list = this.multipleSelection;
}
this.open = false;
},
convertCurrency(money) {
//汉字的数字
var cnNums = new Array(
"零",
this.$t("壹"),
this.$t("贰"),
this.$t("叁"),
this.$t("肆"),
this.$t("伍"),
this.$t("陆"),
this.$t("柒"),
this.$t("捌"),
"玖"
);
//基本单位
var cnIntRadice = new Array("", this.$t("拾"), this.$t("佰"), "仟");
//对应整数部分扩展单位
var cnIntUnits = new Array("", this.$t("万"), this.$t("亿"), "兆");
//对应小数部分单位
var cnDecUnits = new Array("角", this.$t("分"), this.$t("毫"), "厘");
//整数金额时后面跟的字符
var cnInteger = this.$t("整");
//整型完以后的单位
var cnIntLast = this.$t("元");
//最大处理的数字
var maxNum = 999999999999999.9999;
//金额整数部分
var integerNum;
//金额小数部分
var decimalNum;
//输出的中文金额字符串
var chineseStr = "";
//分离金额后用的数组,预定义
var parts;
// 传入的参数为空情况
if (money === "") {
return "";
}
money = parseFloat(money);
if (money >= maxNum) {
return "";
}
// 传入的参数为0情况
if (money === 0) {
chineseStr = cnNums[0] + cnIntLast + cnInteger;
return chineseStr;
}
// 转为字符串
money = money.toString();
// indexOf 检测某字符在字符串中首次出现的位置 返回索引值(从0 开始) -1 代表无
if (money.indexOf(".") == -1) {
integerNum = money;
decimalNum = "";
} else {
parts = money.split(".");
integerNum = parts[0];
decimalNum = parts[1].substr(0, 4);
}
//转换整数部分
if (parseInt(integerNum, 10) > 0) {
let zeroCount = 0;
let IntLen = integerNum.length;
for (let i = 0; i < IntLen; i++) {
let n = integerNum.substr(i, 1);
let p = IntLen - i - 1;
let q = p / 4;
let m = p % 4;
if (n == "0") {
zeroCount++;
} else {
if (zeroCount > 0) {
chineseStr += cnNums[0];
}
zeroCount = 0;
chineseStr += cnNums[parseInt(n)] + cnIntRadice[m];
}
if (m == 0 && zeroCount < 4) {
chineseStr += cnIntUnits[q];
}
}
// 最后+ 元
chineseStr += cnIntLast;
}
// 转换小数部分
if (decimalNum != "") {
let decLen = decimalNum.length;
for (let i = 0; i < decLen; i++) {
let n = decimalNum.substr(i, 1);
if (n != "0") {
chineseStr += cnNums[Number(n)] + cnDecUnits[i];
}
}
}
if (chineseStr == "") {
chineseStr += cnNums[0] + cnIntLast + cnInteger;
} else if (decimalNum == "") {
chineseStr += cnInteger;
}
return chineseStr;
},
openDialog() {
this.getList();
},
oninput(num) {
let str = num;
let len1 = str.substr(0, 1);
let len2 = str.substr(1, 1);
//如果第一位是0,第二位不是点,就用数字把点替换掉
if (str.length > 1 && len1 == 0 && len2 != ".") {
str = str.substr(1, 1);
}
//第一位不能是.
if (len1 == ".") {
str = "";
}
//限制只能输入一个小数点
if (str.indexOf(".") != -1) {
let str_ = str.substr(str.indexOf(".") + 1);
if (str_.indexOf(".") != -1) {
str = str.substr(0, str.indexOf(".") + str_.indexOf(".") + 1);
} else {
// if (str_.length > 2) {
// str = str.substr(0, str.indexOf('.') + 1) + str_.substr(0, 2)
// }
}
}
//正则替换
str = str.replace(/[^\d^\.]+/g, ""); // 保留数字和小数点
// str = str.replace(/\.\d\d\d$/,'') // 小数点后只能输两位
return str;
},
},
};
</script>
<style scoped>
.card {
margin-top: 20px;
}
.dialog-footer {
padding: 40px;
}
.card-title {
font-size: 18px;
font-weight: bold;
}
</style>