Преглед изворни кода

解决在编辑分成数据的时候会影响到其他行的问题

Yannay пре 2 месеци
родитељ
комит
f287094334
2 измењених фајлова са 24 додато и 13 уклоњено
  1. 22 11
      pages/orderDetailNew/components/pageFour.vue
  2. 2 2
      store/modules/user.js

+ 22 - 11
pages/orderDetailNew/components/pageFour.vue

@@ -134,7 +134,7 @@
134
                             <text class="header-text">操作</text>
134
                             <text class="header-text">操作</text>
135
                         </u-col>
135
                         </u-col>
136
                     </u-row>
136
                     </u-row>
137
-                    <u-row v-for="(item, index) in profitSharingList" :key="item.id" class="split-table-row">
137
+                    <u-row v-for="(item, index) in profitSharingList" :key="item.uuid" class="split-table-row">
138
                         <u-col span="4">
138
                         <u-col span="4">
139
                             <view class="table-cell">
139
                             <view class="table-cell">
140
                                 <!-- <select v-model="item.deptId" class="custom-select">
140
                                 <!-- <select v-model="item.deptId" class="custom-select">
@@ -185,8 +185,8 @@
185
                         </u-col>
185
                         </u-col>
186
                         <u-col span="2" class="action-column">
186
                         <u-col span="2" class="action-column">
187
                             <view class="table-cell">
187
                             <view class="table-cell">
188
-                                <u-button type="error" plain shape="circle" size="mini" @click="deleteRow(item.id)"
189
-                                    class='delectBtn'>
188
+                                <u-button type="error" plain shape="circle" size="mini"
189
+                                    @click="deleteRow(item.id, item.uuid)" class='delectBtn'>
190
                                     <u-icon name="trash" size="20rpx" color="#ff6b6b"></u-icon>
190
                                     <u-icon name="trash" size="20rpx" color="#ff6b6b"></u-icon>
191
                                 </u-button>
191
                                 </u-button>
192
                             </view>
192
                             </view>
@@ -367,6 +367,7 @@ export default {
367
                 orgName: '',
367
                 orgName: '',
368
                 userName: '',
368
                 userName: '',
369
                 id: '',
369
                 id: '',
370
+                uuid: Math.random()//唯一标识,仅vfor使用
370
             });
371
             });
371
             // 重新计算所有行的比例
372
             // 重新计算所有行的比例
372
         },
373
         },
@@ -456,6 +457,9 @@ export default {
456
                 pageNum: 1,
457
                 pageNum: 1,
457
             }, { sendFormId: this.currentReceipt.sendFormId, });
458
             }, { sendFormId: this.currentReceipt.sendFormId, });
458
             console.log('分成比例表格数据', rows)
459
             console.log('分成比例表格数据', rows)
460
+            rows.map(item => {
461
+                item.uuid = Math.random()//唯一标识
462
+            })
459
             this.profitSharingList = rows
463
             this.profitSharingList = rows
460
         },
464
         },
461
 
465
 
@@ -465,6 +469,7 @@ export default {
465
 
469
 
466
 
470
 
467
 
471
 
472
+        //上传分成
468
         addShare() {
473
         addShare() {
469
             this.profitSharingList.forEach(async item => {
474
             this.profitSharingList.forEach(async item => {
470
                 const data = {
475
                 const data = {
@@ -487,9 +492,15 @@ export default {
487
             });
492
             });
488
         },
493
         },
489
 
494
 
490
-        //删除分成ok
491
-        async deleteRow(id) {
492
-            console.log(id, 'id')
495
+        //删除分成
496
+        async deleteRow(id, uuid) {
497
+            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
+            }
493
             try {
504
             try {
494
                 await uni.$u.api.deleteClueCommissionForm(id)
505
                 await uni.$u.api.deleteClueCommissionForm(id)
495
                 uni.$u.toast('删除成功')
506
                 uni.$u.toast('删除成功')
@@ -501,14 +512,14 @@ export default {
501
 
512
 
502
         //打开选择框
513
         //打开选择框
503
         handleSelectOrg(item) {
514
         handleSelectOrg(item) {
504
-            console.log(item.id, '当前选择的行的id')
505
-            this.currentEditItem = item.id
515
+            console.log(item.uuid, '当前选择的行的uuid')
516
+            this.currentEditItem = item.uuid
506
             this.showOrgPicker = true
517
             this.showOrgPicker = true
507
         },
518
         },
508
         //选择当前的分成人
519
         //选择当前的分成人
509
         handleSelectPerson(item) {
520
         handleSelectPerson(item) {
510
             console.log(item, '当前选择的行')
521
             console.log(item, '当前选择的行')
511
-            this.currentEditItem = item.id
522
+            this.currentEditItem = item.uuid
512
             //获取当前选择组织的分成人名单
523
             //获取当前选择组织的分成人名单
513
             // 获取当前行的关联id
524
             // 获取当前行的关联id
514
             const deptId = item.deptId
525
             const deptId = item.deptId
@@ -527,7 +538,7 @@ export default {
527
             console.log(value, '选择的组织')
538
             console.log(value, '选择的组织')
528
             //把值赋值给当前行
539
             //把值赋值给当前行
529
             this.profitSharingList.forEach(item => {
540
             this.profitSharingList.forEach(item => {
530
-                if (item.id == this.currentEditItem) {
541
+                if (item.uuid == this.currentEditItem) {
531
                     item.orgName = value[0].label
542
                     item.orgName = value[0].label
532
                     item.deptId = value[0].id
543
                     item.deptId = value[0].id
533
                     // item.personOptions = value[0].children
544
                     // item.personOptions = value[0].children
@@ -546,7 +557,7 @@ export default {
546
             console.log(value, '选择的人')
557
             console.log(value, '选择的人')
547
             //把值赋值给当前行
558
             //把值赋值给当前行
548
             this.profitSharingList.forEach(item => {
559
             this.profitSharingList.forEach(item => {
549
-                if (item.id == this.currentEditItem) {
560
+                if (item.uuid == this.currentEditItem) {
550
                     item.userName = value[0].label
561
                     item.userName = value[0].label
551
                     item.userId = value[0].id
562
                     item.userId = value[0].id
552
                 }
563
                 }

+ 2 - 2
store/modules/user.js

@@ -28,8 +28,8 @@ export default {
28
 		netConfig: {
28
 		netConfig: {
29
 			// http://59.42.9.166:9520/proxy
29
 			// http://59.42.9.166:9520/proxy
30
 			// http://10.0.7.100:9500
30
 			// http://10.0.7.100:9500
31
-			ip: "https://crm.nanjingshiyu.com/prod-api", // ip
32
-			// ip: "https://crmtest.nanjingshiyu.com/prod-api", // 测试环境ip
31
+			// ip: "https://crm.nanjingshiyu.com/prod-api", // ip
32
+			ip: "https://crmtest.nanjingshiyu.com/prod-api", // 测试环境ip
33
 			// ip : "/api", // 测试环境ip
33
 			// ip : "/api", // 测试环境ip
34
 			// ip : "http://47.113.184.101", // 测试环境ip
34
 			// ip : "http://47.113.184.101", // 测试环境ip
35
 			// ip: "http://172.16.7.200", // ip
35
 			// ip: "http://172.16.7.200", // ip