Pārlūkot izejas kodu

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

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

+ 2 - 2
store/modules/user.js

@@ -28,8 +28,8 @@ export default {
28 28
 		netConfig: {
29 29
 			// http://59.42.9.166:9520/proxy
30 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 33
 			// ip : "/api", // 测试环境ip
34 34
 			// ip : "http://47.113.184.101", // 测试环境ip
35 35
 			// ip: "http://172.16.7.200", // ip