Yannay 2 mesi fa
parent
commit
6e52b45aec

+ 187 - 152
pages/orderDetailNew/components/pageFour.vue

@@ -114,61 +114,66 @@
114
                 <!-- 分成信息表格 -->
114
                 <!-- 分成信息表格 -->
115
                 <view class="split-table">
115
                 <view class="split-table">
116
                     <u-row class="split-table-header">
116
                     <u-row class="split-table-header">
117
-                        <u-col span="2">
117
+                        <u-col span="4">
118
                             <text class="header-text">关联</text>
118
                             <text class="header-text">关联</text>
119
                         </u-col>
119
                         </u-col>
120
                         <u-col span="2">
120
                         <u-col span="2">
121
-                            <text class="header-text">账户类型</text>
122
-                        </u-col>
123
-                        <u-col span="2">
124
                             <text class="header-text">分成人</text>
121
                             <text class="header-text">分成人</text>
125
                         </u-col>
122
                         </u-col>
123
+
126
                         <u-col span="2">
124
                         <u-col span="2">
127
-                            <text class="header-text">比例(%)</text>
125
+                            <text class="header-text">比例</text>
128
                         </u-col>
126
                         </u-col>
129
-                        <u-col span="2">
130
-                            <text class="header-text">归属公司</text>
127
+                        <u-col span="1">
128
+                            <text class="header-text">类型</text>
129
+                        </u-col>
130
+                        <u-col span="1">
131
+                            <text class="header-text">公司</text>
131
                         </u-col>
132
                         </u-col>
132
                         <u-col span="2" class="action-column">
133
                         <u-col span="2" class="action-column">
133
                             <text class="header-text">操作</text>
134
                             <text class="header-text">操作</text>
134
                         </u-col>
135
                         </u-col>
135
                     </u-row>
136
                     </u-row>
136
                     <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.id" class="split-table-row">
137
-                        <u-col span="2">
138
+                        <u-col span="4">
138
                             <view class="table-cell">
139
                             <view class="table-cell">
139
-                                <select v-model="item.deptId" class="custom-select" @change="onAssociationChange(item)">
140
-                                    <option value="">无</option>
140
+                                <!-- <select v-model="item.deptId" class="custom-select">
141
                                     <option v-for="option in associationOptions" :key="option.id" :value="option.id">
141
                                     <option v-for="option in associationOptions" :key="option.id" :value="option.id">
142
                                         {{ option.label }}
142
                                         {{ option.label }}
143
                                     </option>
143
                                     </option>
144
-                                </select>
145
-                            </view>
146
-                        </u-col>
147
-                        <u-col span="2">
148
-                            <view class="table-cell">
149
-                                <view :class="['account-type', item.accountType == '1' ? 'frontend' : 'backend']"
150
-                                    @click="toggleAccountType(item)" style="cursor: pointer;">
151
-                                    {{ item.accountType == '1' ? '前' : '后' }}
152
-                                </view>
144
+                                </select> -->
145
+                                <u-button @click='handleSelectOrg(item)' :text="item.orgName" plain></u-button>
153
                             </view>
146
                             </view>
154
                         </u-col>
147
                         </u-col>
148
+
155
                         <u-col span="2">
149
                         <u-col span="2">
156
                             <view class="table-cell">
150
                             <view class="table-cell">
157
-                                <select v-model="item.userId" class="custom-select">
151
+                                <!-- <select v-model="item.userId" class="custom-select">
158
                                     <option value="">无</option>
152
                                     <option value="">无</option>
159
                                     <option v-for="person in item.personOptions" :key="person.id" :value="person.id">
153
                                     <option v-for="person in item.personOptions" :key="person.id" :value="person.id">
160
                                         {{ person.label }}
154
                                         {{ person.label }}
161
                                     </option>
155
                                     </option>
162
-                                </select>
156
+                                </select> -->
157
+                                <u-button @click="handleSelectPerson(item)" :text="item.userName" plain></u-button>
163
                             </view>
158
                             </view>
164
                         </u-col>
159
                         </u-col>
160
+
161
+
165
                         <u-col span="2">
162
                         <u-col span="2">
166
                             <view class="table-cell">
163
                             <view class="table-cell">
167
                                 <u--input v-model="item.commissionRate" type="number" class="percentage-input"
164
                                 <u--input v-model="item.commissionRate" type="number" class="percentage-input"
168
                                     @input="handlePercentageInput(item)" min="0" max="100" precision="0" />
165
                                     @input="handlePercentageInput(item)" min="0" max="100" precision="0" />
169
                             </view>
166
                             </view>
170
                         </u-col>
167
                         </u-col>
171
-                        <u-col span="2">
168
+                        <u-col span="1">
169
+                            <view class="table-cell">
170
+                                <view :class="['account-type', item.accountType == '1' ? 'frontend' : 'backend']"
171
+                                    @click="toggleAccountType(item)" style="cursor: pointer;">
172
+                                    {{ item.accountType == '1' ? '前' : '后' }}
173
+                                </view>
174
+                            </view>
175
+                        </u-col>
176
+                        <u-col span="1">
172
                             <view class="table-cell">
177
                             <view class="table-cell">
173
                                 <view class="radio-wrapper" @click="toggleBelongToCompany(item)">
178
                                 <view class="radio-wrapper" @click="toggleBelongToCompany(item)">
174
                                     <view :class="['radio-circle', item.isCompanyPerformance == '1' ? 'active' : '']">
179
                                     <view :class="['radio-circle', item.isCompanyPerformance == '1' ? 'active' : '']">
@@ -180,7 +185,8 @@
180
                         </u-col>
185
                         </u-col>
181
                         <u-col span="2" class="action-column">
186
                         <u-col span="2" class="action-column">
182
                             <view class="table-cell">
187
                             <view class="table-cell">
183
-                                <u-button type="error" plain shape="circle" size="mini" @click="deleteRow(item.id)">
188
+                                <u-button type="error" plain shape="circle" size="mini" @click="deleteRow(item.id)"
189
+                                    class='delectBtn'>
184
                                     <u-icon name="trash" size="20rpx" color="#ff6b6b"></u-icon>
190
                                     <u-icon name="trash" size="20rpx" color="#ff6b6b"></u-icon>
185
                                 </u-button>
191
                                 </u-button>
186
                             </view>
192
                             </view>
@@ -197,11 +203,24 @@
197
                 <text style="margin-left: 8rpx;">确认入库</text>
203
                 <text style="margin-left: 8rpx;">确认入库</text>
198
             </u-button>
204
             </u-button>
199
         </div>
205
         </div>
206
+
207
+        <!-- 组织选择 -->
208
+        <u-picker :show="showOrgPicker" title="请选择组织" :columns="columnsOrgList" keyName="label"
209
+            @confirm="handleOrgConfirmOrg" @cancel='showOrgPicker = false'></u-picker>
210
+
211
+
212
+        <!-- 人员选择 -->
213
+        <u-picker :show="showPersonPicker" title="请选择分成人" :columns="columnsPersonList" keyName="label"
214
+            @confirm="handleConfirmPerson" @cancel='handleCancelPerson'></u-picker>
215
+
216
+        <u-toast ref="uToast"></u-toast>
217
+
200
     </view>
218
     </view>
201
 </template>
219
 </template>
202
 
220
 
203
 <script>
221
 <script>
204
 export default {
222
 export default {
223
+
205
     props: {
224
     props: {
206
         orderDetail: {
225
         orderDetail: {
207
             type: Object,
226
             type: Object,
@@ -270,7 +289,9 @@ export default {
270
                         grossPerformance: data.grossPerformance || '',//毛业绩
289
                         grossPerformance: data.grossPerformance || '',//毛业绩
271
                         remarks: data.receiptRemark.split(';')[0] || '',//收单备注  截取备注第一部分
290
                         remarks: data.receiptRemark.split(';')[0] || '',//收单备注  截取备注第一部分
272
                     }
291
                     }
273
-                    this.getList()
292
+                    this.$nextTick(() => {
293
+                        this.getList()
294
+                    })
274
                 }
295
                 }
275
             },
296
             },
276
         }
297
         }
@@ -296,16 +317,23 @@ export default {
296
 
317
 
297
             ],
318
             ],
298
             // 关联选项列表
319
             // 关联选项列表
299
-            associationOptions: [],
320
+            // associationOptions: [],
300
             // 分成人选项列表
321
             // 分成人选项列表
301
-            personOptions: [],
322
+            // personOptions: [],
302
             // 表单验证规则
323
             // 表单验证规则
324
+            showOrgPicker: false,
325
+            showPersonPicker: false,
326
+
327
+            columnsOrgList: [],
328
+            columnsPersonList: [],
303
 
329
 
304
         };
330
         };
305
     },
331
     },
306
     mounted() {
332
     mounted() {
307
         // 获取分成人名单
333
         // 获取分成人名单
308
-        this.getCommissionUserList();
334
+        this.$nextTick(() => {
335
+            this.getCommissionUserList();
336
+        })
309
     },
337
     },
310
 
338
 
311
     methods: {
339
     methods: {
@@ -333,41 +361,20 @@ export default {
333
                 deptId: '',
361
                 deptId: '',
334
                 accountType: '1',
362
                 accountType: '1',
335
                 userId: '',
363
                 userId: '',
336
-                personOptions: [],
337
                 percentage: 0,
364
                 percentage: 0,
338
-                isCompanyPerformance: '2'
365
+                isCompanyPerformance: '2',
366
+                orgName: '',
367
+                userName: '',
368
+                id: '',
339
             });
369
             });
340
             // 重新计算所有行的比例
370
             // 重新计算所有行的比例
341
-            this.recalculatePercentage();
342
         },
371
         },
343
 
372
 
344
-        // 重新计算分成比例
345
-        recalculatePercentage() {
346
-            // 分别计算前端和后端的行数
347
-            const frontendRows = this.profitSharingList.filter(item => item.accountType === 'frontend');
348
-            const backendRows = this.profitSharingList.filter(item => item.accountType === 'backend');
349
-
350
-            // 计算前端平均比例
351
-            if (frontendRows.length > 0) {
352
-                const frontendAvg = Math.floor(100 / frontendRows.length);
353
-                frontendRows.forEach(item => {
354
-                    item.percentage = frontendAvg;
355
-                });
356
-            }
357
 
373
 
358
-            // 计算后端平均比例
359
-            if (backendRows.length > 0) {
360
-                const backendAvg = Math.floor(100 / backendRows.length);
361
-                backendRows.forEach(item => {
362
-                    item.percentage = backendAvg;
363
-                });
364
-            }
365
-        },
366
         // 切换账户类型
374
         // 切换账户类型
367
         toggleAccountType(item) {
375
         toggleAccountType(item) {
368
             item.accountType = item.accountType == '1' ? '2' : '1';
376
             item.accountType = item.accountType == '1' ? '2' : '1';
369
             // 重新计算分成比例
377
             // 重新计算分成比例
370
-            this.recalculatePercentage();
371
         },
378
         },
372
         // 处理百分比输入
379
         // 处理百分比输入
373
         handlePercentageInput(item) {
380
         handlePercentageInput(item) {
@@ -390,68 +397,41 @@ export default {
390
         toggleBelongToCompany(item) {
397
         toggleBelongToCompany(item) {
391
             item.isCompanyPerformance = item.isCompanyPerformance == '1' ? '2' : '1';
398
             item.isCompanyPerformance = item.isCompanyPerformance == '1' ? '2' : '1';
392
         },
399
         },
393
-        // 关联选择变化时,更新分成人选项
394
-        onAssociationChange(item) {
395
-            if (item.deptId) {
396
-                const selectedOption = this.associationOptions.find(opt => opt.id === item.deptId);
397
-                item.personOptions = selectedOption ? selectedOption.children || [] : [];
398
-                item.userId = '';
399
-            } else {
400
-                item.personOptions = [];
401
-                item.userId = '';
402
-            }
403
-        },
404
-        // 确认入库方法
405
-        confirmWarehouseEntry() {
406
-            // 表单校验
407
-
408
-            if (this.validateProfitSharing()) {
409
 
400
 
410
-                //上传表单数据
411
-                this.$emit('confirmInterStore', {
412
-                    warehouseInfo: this.warehouseInfo,
413
-                })
401
+        // 确认入库方法
402
+        async confirmWarehouseEntry() {
403
+
404
+
405
+            //上传物流表单数据
406
+            this.$emit('confirmInterStore', {
407
+                warehouseInfo: this.warehouseInfo,
408
+            })
409
+
410
+            //上传分成数据
411
+            await this.addShare()
412
+
413
+            this.$refs.uToast.show({
414
+                type: "success",
415
+                message: "入库成功",
416
+                iconUrl: "https://uviewui.com/demo/toast/success.png",
417
+                complete() {
418
+                    uni.navigateTo({
419
+                        url: '/pages/pagereceivecenter/pagereceivecenter',
420
+                    })
421
+                },
422
+            });
414
 
423
 
415
-                //上传分成数据
416
-                this.addShare()
424
+            //跳转接单
417
 
425
 
418
-            }
419
 
426
 
420
         },
427
         },
421
-        // 分成信息校验方法
422
-        validateProfitSharing() {
423
-            for (let i = 0; i < this.profitSharingList.length; i++) {
424
-                const item = this.profitSharingList[i];
425
-                if (!item.userId || !item.userId.trim()) {
426
-                    uni.showToast({
427
-                        title: `第${i + 1}行请选择分成人`,
428
-                        icon: 'none'
429
-                    });
430
-                    return false;
431
-                }
432
-
433
-                if (item.commissionRate <= 0 || item.commissionRate > 100) {
434
-                    uni.showToast({
435
-                        title: `第${i + 1}行分成比例必须在1-100之间`,
436
-                        icon: 'none'
437
-                    });
438
-                    return false;
439
-                }
440
-            }
441
 
428
 
442
-            return true;
443
-        },
444
         // 获取分成人名单
429
         // 获取分成人名单
445
         async getCommissionUserList() {
430
         async getCommissionUserList() {
446
             const commissionUserList = await uni.$u.api.getCustomerManagerAllList()
431
             const commissionUserList = await uni.$u.api.getCustomerManagerAllList()
447
-            console.log(commissionUserList.data[0].children, '分成人名单')
448
-            this.associationOptions = commissionUserList.data[0].children
449
-            if (this.profitSharingList.length > 0) {
450
-                this.profitSharingList = this.profitSharingList.map(item => ({
451
-                    ...item,
452
-                    personOptions: item.deptId ? this.getPersonOptionsByDeptId(item.deptId) : []
453
-                }));
454
-            }
432
+            console.log('分成人名单', commissionUserList.data[0].children)
433
+            // this.associationOptions = commissionUserList.data[0].children
434
+            this.columnsOrgList = [commissionUserList.data[0].children]
455
         },
435
         },
456
 
436
 
457
         //初始化分成比例
437
         //初始化分成比例
@@ -460,59 +440,39 @@ export default {
460
                 pageSize: 9999,
440
                 pageSize: 9999,
461
                 pageNum: 1,
441
                 pageNum: 1,
462
             }, { sendFormId: this.receiptList[0].sendFormId, });
442
             }, { sendFormId: this.receiptList[0].sendFormId, });
463
-            this.profitSharingList = rows.map(item => {
464
-                let personOptions = [];
465
-                if (item.deptId) {
466
-                    if (this.associationOptions.length > 0) {
467
-                        personOptions = this.getPersonOptionsByDeptId(item.deptId);
468
-                    } else {
469
-                        personOptions = [];
470
-                    }
471
-                }
472
-                return {
473
-                    ...item,
474
-                    personOptions
475
-                };
476
-            });
477
-            if (this.associationOptions.length === 0) {
478
-                await this.getCommissionUserList();
479
-            }
480
-            console.log('这里是分成比例', this.profitSharingList, '总数是', total);
443
+            console.log('分成比例表格数据', rows)
444
+            this.profitSharingList = rows
481
         },
445
         },
482
 
446
 
483
-        getPersonOptionsByDeptId(deptId) {
484
-            const selectedOption = this.associationOptions.find(opt => opt.id === deptId);
485
-            return selectedOption ? selectedOption.children || [] : [];
486
-        },
487
 
447
 
488
 
448
 
489
-        //添加分成比例
490
-        async addProfitSharingList(data) {
491
-            if (data.id) {
492
-                //编辑
493
-                await uni.$u.api.clueCommissionUpdate(data);
494
-            } else {
495
-                //新增
496
-                await uni.$u.api.clueCommissionAdd(data);
497
-            }
498
-        },
449
+
450
+
451
+
452
+
499
         addShare() {
453
         addShare() {
500
-            console.log('开始上传')
501
-            this.profitSharingList.forEach(item => {
502
-                this.addProfitSharingList({
503
-                    id: item.id,
454
+            this.profitSharingList.forEach(async item => {
455
+                const data = {
456
+                    id: item.id || '',
504
                     accountType: item.accountType == '1' ? 1 : 2,
457
                     accountType: item.accountType == '1' ? 1 : 2,
505
                     clueId: this.receiptList[0].clueId,
458
                     clueId: this.receiptList[0].clueId,
506
                     commissionRate: item.commissionRate,
459
                     commissionRate: item.commissionRate,
507
                     isCompanyPerformance: item.isCompanyPerformance == '1' ? 1 : 2,
460
                     isCompanyPerformance: item.isCompanyPerformance == '1' ? 1 : 2,
508
                     sendFormId: this.receiptList[0].sendFormId,
461
                     sendFormId: this.receiptList[0].sendFormId,
509
                     userId: item.userId,
462
                     userId: item.userId,
510
-                    userName: item.personOptions.find(opt => opt.id == item.userId)?.label || '',
511
-                });
463
+                    userName: item.userName,
464
+                }
465
+                if (item.id) {
466
+                    //更新
467
+                    await uni.$u.api.clueCommissionUpdate(data);
468
+                } else {
469
+                    //新增
470
+                    await uni.$u.api.clueCommissionAdd(data);
471
+                }
512
             });
472
             });
513
-            uni.$u.toast('上传成功')
514
         },
473
         },
515
-        //删除分成
474
+
475
+        //删除分成ok
516
         async deleteRow(id) {
476
         async deleteRow(id) {
517
             console.log(id, 'id')
477
             console.log(id, 'id')
518
             try {
478
             try {
@@ -520,10 +480,71 @@ export default {
520
                 uni.$u.toast('删除成功')
480
                 uni.$u.toast('删除成功')
521
                 this.getList()
481
                 this.getList()
522
             } catch (error) {
482
             } catch (error) {
523
-                uni.$u.toast('删除失败,请稍后重试', error)
483
+                uni.$u.toast('删除失败,请稍后重试')
484
+            }
485
+        },
486
+
487
+        //打开选择框
488
+        handleSelectOrg(item) {
489
+            console.log(item.id, '当前选择的行的id')
490
+            this.currentEditItem = item.id
491
+            this.showOrgPicker = true
492
+        },
493
+        //选择当前的分成人
494
+        handleSelectPerson(item) {
495
+            console.log(item, '当前选择的行')
496
+            this.currentEditItem = item.id
497
+            //获取当前选择组织的分成人名单
498
+            // 获取当前行的关联id
499
+            const deptId = item.deptId
500
+            const org = this.columnsOrgList[0].find(org => org.id == deptId)
501
+            console.log(org, '当前选择的行的组织')
502
+            if (org) {
503
+                this.columnsPersonList = [org.children]
524
             }
504
             }
505
+            // 把当前选择组织的分成人名单赋值给当前行的分成人选项列表
506
+
507
+            this.showPersonPicker = true
525
         },
508
         },
526
 
509
 
510
+        //确认选择组织
511
+        handleOrgConfirmOrg({ columnIndex, value, values },) {
512
+            console.log(value, '选择的组织')
513
+            //把值赋值给当前行
514
+            this.profitSharingList.forEach(item => {
515
+                if (item.id == this.currentEditItem) {
516
+                    item.orgName = value[0].label
517
+                    item.deptId = value[0].id
518
+                    // item.personOptions = value[0].children
519
+                    //将当前的行的分成人清空
520
+                    item.userId = ''
521
+                    item.userName = ''
522
+                }
523
+            })
524
+
525
+
526
+            this.showOrgPicker = false
527
+        },
528
+
529
+        //确认选择人
530
+        handleConfirmPerson({ columnIndex, value, values },) {
531
+            console.log(value, '选择的人')
532
+            //把值赋值给当前行
533
+            this.profitSharingList.forEach(item => {
534
+                if (item.id == this.currentEditItem) {
535
+                    item.userName = value[0].label
536
+                    item.userId = value[0].id
537
+                }
538
+            })
539
+            this.columnsPersonList = []
540
+            this.showPersonPicker = false
541
+        },
542
+        // 取消选择人
543
+        handleCancelPerson() {
544
+            this.columnsPersonList = []
545
+            this.showPersonPicker = false
546
+        }
547
+
527
     }
548
     }
528
 };
549
 };
529
 </script>
550
 </script>
@@ -841,12 +862,7 @@ export default {
841
     padding: 0 5rpx;
862
     padding: 0 5rpx;
842
 }
863
 }
843
 
864
 
844
-/* 调整输入框样式 */
845
-.percentage-input {
846
-    width: 80%;
847
-    height: 50rpx;
848
-    font-size: 28rpx;
849
-}
865
+
850
 
866
 
851
 /* 归属公司单选框样式 */
867
 /* 归属公司单选框样式 */
852
 .radio-wrapper {
868
 .radio-wrapper {
@@ -902,4 +918,23 @@ export default {
902
         padding: 0 10rpx;
918
         padding: 0 10rpx;
903
     }
919
     }
904
 }
920
 }
921
+
922
+.u-button {
923
+    height: 60rpx;
924
+}
925
+
926
+.delectBtn {
927
+    height: 40rpx;
928
+
929
+    .u-button {
930
+        width: 40rpx;
931
+    }
932
+
933
+
934
+
935
+}
936
+
937
+.delectBtn ::v-deep .u-button--mini {
938
+    min-width: 20rpx !important;
939
+}
905
 </style>
940
 </style>

+ 1 - 1
pages/orderDetailNew/components/pageTwo.vue

@@ -150,7 +150,7 @@ export default {
150
         orderDetail: {
150
         orderDetail: {
151
             handler(newVal) {
151
             handler(newVal) {
152
                 if (newVal) {
152
                 if (newVal) {
153
-                    this.approvedPrice = newVal.itemPrice || 0;
153
+                    this.approvedPrice = Number(newVal.itemPrice) || 0;
154
                     this.getList('2', '3');
154
                     this.getList('2', '3');
155
                 }
155
                 }
156
             },
156
             },