|
|
@@ -290,9 +290,7 @@ export default {
|
|
290
|
290
|
grossPerformance: data.grossPerformance || '',//毛业绩
|
|
291
|
291
|
remarks: data.receiptRemark?.split(';')[0] || '',//收单备注 截取备注第一部分
|
|
292
|
292
|
}
|
|
293
|
|
- this.$nextTick(() => {
|
|
294
|
|
- this.getShareList()
|
|
295
|
|
- })
|
|
|
293
|
+ this.getShareList()
|
|
296
|
294
|
}
|
|
297
|
295
|
},
|
|
298
|
296
|
}
|
|
|
@@ -326,6 +324,7 @@ export default {
|
|
326
|
324
|
showPersonPicker: false,
|
|
327
|
325
|
|
|
328
|
326
|
columnsOrgList: [],
|
|
|
327
|
+ //传入的分成人名单
|
|
329
|
328
|
columnsPersonList: [],
|
|
330
|
329
|
|
|
331
|
330
|
};
|
|
|
@@ -362,21 +361,41 @@ export default {
|
|
362
|
361
|
deptId: '',
|
|
363
|
362
|
accountType: '1',
|
|
364
|
363
|
userId: '',
|
|
365
|
|
- percentage: 0,
|
|
|
364
|
+ commissionRate: 0,
|
|
366
|
365
|
isCompanyPerformance: '2',
|
|
367
|
366
|
orgName: '',
|
|
368
|
367
|
userName: '',
|
|
369
|
368
|
id: '',
|
|
370
|
369
|
uuid: Math.random()//唯一标识,仅vfor使用
|
|
371
|
370
|
});
|
|
372
|
|
- // 重新计算所有行的比例
|
|
|
371
|
+ //重新计算全部行的分成比例
|
|
|
372
|
+ this.calculateTotalPercentage();
|
|
|
373
|
+ },
|
|
|
374
|
+ // 重新计算全部行的分成比例
|
|
|
375
|
+ calculateTotalPercentage() {
|
|
|
376
|
+ //获取选择前端的行的数量
|
|
|
377
|
+ const frontItems = this.profitSharingList.filter(item => item.accountType == '1');
|
|
|
378
|
+ const backItems = this.profitSharingList.filter(item => item.accountType == '2');
|
|
|
379
|
+ const totalFrontItems = frontItems.length;
|
|
|
380
|
+ const totalBackItems = backItems.length;
|
|
|
381
|
+ console.log('选择前端的行的数量====>', totalFrontItems)
|
|
|
382
|
+ console.log('选择后端的行的数量====>', totalBackItems)
|
|
|
383
|
+ //把profitSharingList中的前端行的分成比例按照 100/数量 重新计算
|
|
|
384
|
+ this.profitSharingList.map(item => {
|
|
|
385
|
+ if (item.accountType == '1') {
|
|
|
386
|
+ item.commissionRate = (100 / totalFrontItems).toFixed()
|
|
|
387
|
+ }
|
|
|
388
|
+ if (item.accountType == '2') {
|
|
|
389
|
+ item.commissionRate = (100 / totalBackItems).toFixed()
|
|
|
390
|
+ }
|
|
|
391
|
+ })
|
|
373
|
392
|
},
|
|
374
|
|
-
|
|
375
|
393
|
|
|
376
|
394
|
// 切换账户类型
|
|
377
|
395
|
toggleAccountType(item) {
|
|
378
|
396
|
item.accountType = item.accountType == '1' ? '2' : '1';
|
|
379
|
397
|
// 重新计算分成比例
|
|
|
398
|
+ this.calculateTotalPercentage();
|
|
380
|
399
|
},
|
|
381
|
400
|
// 处理百分比输入
|
|
382
|
401
|
handlePercentageInput(item) {
|
|
|
@@ -452,15 +471,18 @@ export default {
|
|
452
|
471
|
|
|
453
|
472
|
//初始化分成比例
|
|
454
|
473
|
async getShareList() {
|
|
|
474
|
+
|
|
|
475
|
+ console.log('当前收单信息', this.currentReceipt.id)
|
|
455
|
476
|
const { rows, total } = await uni.$u.api.selectCommissionList({
|
|
456
|
477
|
pageSize: 9999,
|
|
457
|
478
|
pageNum: 1,
|
|
458
|
479
|
}, { sendFormId: this.currentReceipt.sendFormId, });
|
|
459
|
480
|
console.log('分成比例表格数据', rows)
|
|
460
|
|
- rows.map(item => {
|
|
|
481
|
+ const newRows = rows.filter(item => item.receiptFormId == this.currentReceipt.id)
|
|
|
482
|
+ newRows.map(item => {
|
|
461
|
483
|
item.uuid = Math.random()//唯一标识
|
|
462
|
484
|
})
|
|
463
|
|
- this.profitSharingList = rows
|
|
|
485
|
+ this.profitSharingList = newRows
|
|
464
|
486
|
},
|
|
465
|
487
|
|
|
466
|
488
|
|
|
|
@@ -481,6 +503,7 @@ export default {
|
|
481
|
503
|
sendFormId: this.currentReceipt.sendFormId,
|
|
482
|
504
|
userId: item.userId,
|
|
483
|
505
|
userName: item.userName,
|
|
|
506
|
+ receiptFormId: this.currentReceipt.id,//关联的收单id
|
|
484
|
507
|
}
|
|
485
|
508
|
if (item.id) {
|
|
486
|
509
|
//更新
|
|
|
@@ -495,19 +518,34 @@ export default {
|
|
495
|
518
|
//删除分成
|
|
496
|
519
|
async deleteRow(id, uuid) {
|
|
497
|
520
|
console.log(id, 'id', uuid, 'uuid')
|
|
498
|
|
- //如果没有id说明是新增的,直接删除数组中的项
|
|
499
|
|
- if (!id) {
|
|
500
|
|
- this.profitSharingList = this.profitSharingList.filter(item => item.uuid != uuid)
|
|
501
|
|
- uni.$u.toast('删除成功')
|
|
502
|
|
- return
|
|
503
|
|
- }
|
|
504
|
|
- try {
|
|
505
|
|
- await uni.$u.api.deleteClueCommissionForm(id)
|
|
506
|
|
- uni.$u.toast('删除成功')
|
|
507
|
|
- this.getShareList()
|
|
508
|
|
- } catch (error) {
|
|
509
|
|
- uni.$u.toast('删除失败,请稍后重试')
|
|
510
|
|
- }
|
|
|
521
|
+ // 确认删除
|
|
|
522
|
+ uni.showModal({
|
|
|
523
|
+ title: '确认删除',
|
|
|
524
|
+ content: '是否确认删除当前行分成比例?',
|
|
|
525
|
+ success: async (res) => {
|
|
|
526
|
+ if (res.confirm) {
|
|
|
527
|
+ //如果没有id说明是新增的,直接删除数组中的项
|
|
|
528
|
+ if (!id) {
|
|
|
529
|
+ this.profitSharingList = this.profitSharingList.filter(item => item.uuid != uuid)
|
|
|
530
|
+ uni.$u.toast('删除成功')
|
|
|
531
|
+ this.calculateTotalPercentage();
|
|
|
532
|
+
|
|
|
533
|
+ return
|
|
|
534
|
+ }
|
|
|
535
|
+ try {
|
|
|
536
|
+ await uni.$u.api.deleteClueCommissionForm(id)
|
|
|
537
|
+ uni.$u.toast('删除成功')
|
|
|
538
|
+ this.getShareList()
|
|
|
539
|
+ } catch (error) {
|
|
|
540
|
+ uni.$u.toast('删除失败,请稍后重试')
|
|
|
541
|
+ }
|
|
|
542
|
+ //重新计算全部行的分成比例
|
|
|
543
|
+ this.calculateTotalPercentage();
|
|
|
544
|
+ } else {
|
|
|
545
|
+ uni.$u.toast('已取消删除')
|
|
|
546
|
+ }
|
|
|
547
|
+ }
|
|
|
548
|
+ })
|
|
511
|
549
|
},
|
|
512
|
550
|
|
|
513
|
551
|
//打开选择框
|
|
|
@@ -554,16 +592,33 @@ export default {
|
|
554
|
592
|
|
|
555
|
593
|
//确认选择人
|
|
556
|
594
|
handleConfirmPerson({ columnIndex, value, values },) {
|
|
557
|
|
- console.log(value, '选择的人')
|
|
|
595
|
+ console.log(value[0], '选择的人')
|
|
|
596
|
+ console.log(value[0].isUser, '是否是用户')
|
|
558
|
597
|
//把值赋值给当前行
|
|
559
|
|
- this.profitSharingList.forEach(item => {
|
|
560
|
|
- if (item.uuid == this.currentEditItem) {
|
|
561
|
|
- item.userName = value[0].label
|
|
562
|
|
- item.userId = value[0].id
|
|
563
|
|
- }
|
|
564
|
|
- })
|
|
565
|
|
- this.columnsPersonList = []
|
|
566
|
|
- this.showPersonPicker = false
|
|
|
598
|
+ if (value[0].isUser) {
|
|
|
599
|
+ //当前选择是用户
|
|
|
600
|
+ this.profitSharingList.forEach(item => {
|
|
|
601
|
+ if (item.uuid == this.currentEditItem) {
|
|
|
602
|
+ item.userName = value[0].label
|
|
|
603
|
+ item.userId = value[0].id
|
|
|
604
|
+ }
|
|
|
605
|
+ })
|
|
|
606
|
+ this.columnsPersonList = []
|
|
|
607
|
+ this.showPersonPicker = false
|
|
|
608
|
+ } else {
|
|
|
609
|
+ //当前选择是组织
|
|
|
610
|
+ // 把组织的label赋值给当前的行的关联
|
|
|
611
|
+ this.profitSharingList.forEach(item => {
|
|
|
612
|
+ if (item.uuid == this.currentEditItem) {
|
|
|
613
|
+ item.orgName = value[0].label
|
|
|
614
|
+ item.deptId = value[0].id
|
|
|
615
|
+ }
|
|
|
616
|
+ })
|
|
|
617
|
+ const childrens = value[0].children
|
|
|
618
|
+ console.log('当前分公司的内部分成人', childrens)
|
|
|
619
|
+
|
|
|
620
|
+ this.columnsPersonList = [childrens]
|
|
|
621
|
+ }
|
|
567
|
622
|
},
|
|
568
|
623
|
// 取消选择人
|
|
569
|
624
|
handleCancelPerson() {
|