index.vue
62.9 KB
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
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
<!-- 财务 -->
<template>
<d2-Container class="financialRulesContainer" v-loading="$store.state.d2admin.loading.value">
<div class="d2-container-content">
<div class="headerContainer">
<p>
<span>商户名称 {{ routerInfo.merchantName }}</span>
</p>
<p>
<span>业务场景 {{ sceneList[routerInfo.scene] }}</span>
</p>
<p class="edit-sub-title">
分账类型<span class="title-tips">开启线上自动分账,分账金额会根据分账规则自动转入分账方的对公账户。</span>
</p>
</div>
<div class="publicContainer">
<el-form ref="divisionRuleRef" :model="financialObj" :rules="rules" label-suffix=":" label-width="180px">
<el-form-item label="" prop="autoFlag">
<span class="tips-block" slot="label">
<span class="tips-label">线上自动分账</span>
<el-tooltip popper-class="tooltip-class" effect="dark" content="产生交易后会自动打款给商户,开启及关闭操作第二天生效。"
placement="top">
<span class="tips-icon" /> </el-tooltip>:
</span>
<el-switch v-model="financialObj.autoFlag" active-value="Y" inactive-value="N" />
</el-form-item>
<el-form-item label="结算时间方式" prop="settleTimeType">
<span class="tips-block" slot="label">
<span class="tips-label">分账周期</span>
<el-tooltip popper-class="tooltip-class" effect="dark" content="用户支付的款项可按T+1或指定日自动打款给商户。" placement="top">
<span class="tips-icon" /> </el-tooltip>:
</span>
<el-radio-group v-model="financialObj.settleTimeType" :disabled="financialObj.autoFlag === 'N'">
<div class="block_item" style="margin-bottom: 20px">
<el-radio :label="1">
分账周期 T+
<el-input-number v-model="settleTimeObj.first" controls-position="right" size="small" :min="0"
:max="20" :disabled="financialObj.autoFlag === 'N'" />
日
<span v-show="financialObj.settleTimeType == 1">(分账后第2天到分账方对公账户)</span>
</el-radio>
</div>
<!-- v4.15.8紧急需求隐藏固定日期分账 -->
<!-- <div class="block_item">
<el-radio :label="2">
固定日期分账:每月
<el-input-number v-model="settleTimeObj.second"
controls-position="right"
size="small"
:min="1"
:max="31"
:disabled="financialObj.settleTimeType == 1 || financialObj.autoFlag === 'N'" />
日
<span
v-show="financialObj.settleTimeType == 2">(上个月整月的分账金额于次月{{ +financialObj.settleTime + 1 }}日分账到分账方对公账户)</span>
</el-radio>
</div> -->
</el-radio-group>
</el-form-item>
<el-form-item label="平台方分账方" prop="realityPlatformMerchantId" required>
<el-select v-model="financialObj.realityPlatformMerchantId" filterable placeholder="请选择平台方分账方">
<el-option v-for="item in baseData.PlatformLevelList" :key="item.merchantId"
:label="item.showMerchantName" :value="item.merchantId" />
</el-select>
<el-checkbox class="ml10" true-label="Y" false-label="N"
v-model="financialObj.multiPlatformMerchantFlag">开启多平台分账
</el-checkbox>
<el-tooltip class="item" effect="dark" placement="right">
<i class="el-icon-info"> </i>
<template slot="content"><i class="el-icon-info"></i>
开启多平台分账,可使用嘀加智慧云子商户作为分账方。</template>
</el-tooltip>
</el-form-item>
<el-form-item label="流量方分账方" prop="realityShopMerchantId" required>
<!-- @change="refreshData" -->
<el-select v-model="financialObj.realityShopMerchantId" placeholder="请选择流量方分账方">
<el-option v-for="item in baseData.merchantLevelList" :key="item.merchantId"
:label="item.showMerchantName" :value="item.merchantId" />
</el-select>
</el-form-item>
</el-form>
</div>
<!-- @tab-click="clickTab" -->
<el-tabs v-model="editableTabsValue" type="card" @tab-remove="confirmRemove" :before-leave="beforeLeave"
class="my-tab-pane">
<!-- closable -->
<el-tab-pane v-for="(item, idx) in editableTabs" :key="item.name" :label="item.title" :name="item.name"
:closable="idx != 0">
<span slot="label"><i v-show="item.testFlag != 'Y' || item.calculateModeError"
class="el-icon-warning car-error-txt" />{{ item.title }}
</span>
<div class="classificationCptContainer">
<classificationCpt :ref="`classification${item.name}`" :key="idx" :goods-list="goodsTypeGroupRelations"
:goods-type-group-rules="financialObj['goodsTypeGroupRules'][idx]" :goods-select-list="goodsSelectList"
:financial-ledger-party="financialLedgerParty" :tabindex="idx" :tab-item="item"
:service-merchant-list="serviceMerchantList" :router-info="routerInfo"
:classification-obj-select="classificationObj" @rulesTest="rulesTest"
@assignGoodsTypeList="assignGoodsTypeList" @deleteGoodsTypeItem="deleteGoodsTypeItem"
@checkSuccess="checkSuccess(idx)" :upgrade-goods-list="upgradeGoodsList"
:package-goods-list="packageGoodsList" @assignPackageGoodsList="assignPackageGoodsList"
:select-package-goods-list="selectPackageGoodsList" @deletePackageGoodsItem="deletePackageGoodsItem"
@deleteUpgradeGoodsItem="deleteUpgradeGoodsItem" @assignUpgradeGoodsList="assignUpgradeGoodsList"
:select-upgrade-goods-list="selectUpgradeGoodsList"
@deleteSelectUpgradeGoodsList="deleteSelectUpgradeGoodsList"
@deleteSelectPackageGoodsList="deleteSelectPackageGoodsList"
@deleteSelectGoodsTypeList="deleteSelectGoodsTypeList" />
</div>
</el-tab-pane>
<el-tab-pane key="add" v-if="addVisible" name="add">
<!-- //这是增加的按钮 -->
<span slot="label" style="padding: 8px; font-size: 20px; font-weight: bold">+</span>
</el-tab-pane>
</el-tabs>
<div class="footer">
<el-button @click="submit" type="primary">保存</el-button>
<el-button @click="navBack">取消</el-button>
</div>
</div>
<verificationCodeDialog v-if="verificationCodeVisible" :effect-start-date="effectStartDate"
@handleConfirm="codeHandleConfirm" :visible.sync="verificationCodeVisible" />
<!-- 财务分账测试 -->
<merchantTestDialog v-if="merchantTestVisible" :rules-test-params="rulesTestParams"
:visible.sync="merchantTestVisible" />
</d2-Container>
</template>
<script>
import { mapActions, mapGetters, mapMutations } from "vuex"
import {
sceneList,
userType,
attrToVal as attrToValOptions
} from "@/common/constants"
import { deepClone } from "@/common/util"
import {
scenemerchantrefQueryServiceRefByShop,
merchantSettleDistributeRuleLastRule,
merchantSettleDistributeRule,
getMerchantLevelApi,
getDjzhySubMerchant,
ruleAuditSituation
} from "@api/merchant"
import { getPlatformMerchantList } from "@api/index"
import {
queryFeeCategoryByType,
getGoodsCategoryConfiguration
} from "@/api/sys.base.js"
import verificationCodeDialog from "./components/verificationCodeDialog"
import classificationCpt from "./components/classificationCpt.vue"
import merchantTestDialog from "./components/merchantTestDialog"
import {
getAllGoodsListPage as getAllGoodsList,
merchantPackageGoodsInfoPage
} from "@api/grounding"
export default {
name: "FinancialRules",
// isNeedVuex: true,
components: {
classificationCpt,
verificationCodeDialog, //
merchantTestDialog //
},
data() {
return {
verificationCodeVisible: false,
merchantTestVisible: false,
rulesTestParams: {},
goodsTypeGroupRelations: [],
classificationObj: {},
sceneList: Object.freeze(sceneList),
editableTabsValue: "1",
currentIndex: 1,
addIndex: 1,
// tabIndex: 1,
editableTabs: [
{
title: "全部品类",
name: "1",
testFlag: "Y"
}
],
goodsSelectList: [], // { goodsType: 6, goodsTypeName: '商品6' }
financialObj: {
smsCode: "",
merchantId: "",
merchantName: "",
sceneType: "", // 场景(0:1.0;1:1.1;2:1.2;3:1.3)
autoFlag: "N", // 自动分账标识(Y是,N否)
settleTimeType: 1, // 分账时间方式(1:T+1,2:每月)
settleTime: "", // 分账时间每月几号
realityPlatformMerchantId: "", // 实际分账平台方商户id(嘀加智慧云为-1)
realityPlatformMerchantName: "", // 实际分账平台方商户名称
realityPlatformUserType: "2", // 实际分账平台方商户用户类型(1工厂2省代3市代4门店)
realityShopMerchantId: "", // 实际分账4S店商户号
realityShopMerchantName: "", // 实际分账4S店商户名称
realityShopUserType: "", // 实际分账4S店商户用户类型(1工厂2省代3市代4门店)
djzhySubMerchantId: "",
djzhySubMerchantName: "",
multiPlatformMerchantFlag: "N", // 是否多平台
goodsTypeGroupRules: []
},
// 结算周期
settleTimeObj: {
first: "1",
second: "1"
},
baseData: {
merchantLevelList: [],
PlatformLevelList: [
{
merchantId: "-1",
showMerchantName: "嘀加智慧云",
merchantName: "嘀加智慧云",
// userType: res.userType
userType: 1
}
]
},
// merchantId: '44211227',
// yqMerchantId: '44209389',
rules: {
realityPlatformMerchantId: [
{ required: true, message: "请选择平台方", trigger: "change" }
],
realityShopMerchantId: [
{ required: true, message: "请选择流量方", trigger: "change" }
]
},
submitParams: {},
serviceMerchantList: [],
productType: [],
upgradeGoodsList: [],
packageGoodsList: [],
currentPage: 1,
pageSize: 20,
selectUpgradeGoodsList: [],
selectPackageGoodsList: [],
DjzhySubMerchantObj: {
djzhySubMerchantId: "",
djzhySubMerchantName: ""
},
effectStartDate: false // 规则时间 true 表示可以立即生效 是否立即生效
}
},
computed: {
// ...mapState({
// // .FinancialRules.active
// // test: (state) => state.FinancialRules.active,
// productType: (state) => state.d2admin.base.productType
// //
// }),
...mapGetters("goodsSourceSet", { goodsSourceSet: "goodsSourceSet" }),
routerInfo() {
return this.$route.query.params
? JSON.parse(this.$route.query.params)
: ""
},
addVisible() {
// return false
// 已选中的小于全部商品即可追加
const length1 = this.goodsTypeGroupRelations.length
const length2 = this.editableTabs.length - 1
const length3 = this.goodsSelectList.length
// 现在要考虑商品来源的影响 现在固定为有另外两个先写死
return length1 - length3 - 2 > 0 && length1 > length2
},
financialLedgerParty() {
const {
realityPlatformMerchantId,
realityPlatformMerchantName,
realityShopMerchantId,
realityShopMerchantName,
djzhySubMerchantId,
djzhySubMerchantName
} = this.financialObj
// console.log(realityShopMerchantName, dizhySubMerchantId, this.financialObj, 'this.financialObj')
return {
realityPlatformMerchantId, // 实际分账平台方商户id(嘀加智慧云为-1)
realityPlatformMerchantName, // 实际分账平台方商户名称
realityShopMerchantId,
realityShopMerchantName,
djzhySubMerchantName,
djzhySubMerchantId
}
}
},
watch: {
"financialObj.realityShopMerchantId": {
handler(val) {
// this.financialObj.realityShopMerchantId
const obj = this.baseData.merchantLevelList.find(
(item) => item.merchantId == val
)
if (obj) {
const shop = {
realityShopMerchantId: obj.merchantId,
realityShopMerchantName: obj.merchantName,
realityShopUserType: obj.userType
}
this.financialObj = Object.assign(this.financialObj, shop)
}
}
},
"financialObj.realityPlatformMerchantId": {
handler(val) {
// this.financialObj.realityShopMerchantId
const obj = this.baseData.PlatformLevelList.find(
(item) => item.merchantId == val
)
if (obj) {
const Platform = {
realityPlatformMerchantId: obj.merchantId,
realityPlatformMerchantName: obj.merchantName,
realityPlatformUserType: obj.userType
}
this.financialObj = Object.assign(this.financialObj, Platform)
}
}
},
"financialObj.multiPlatformMerchantFlag": {
handler(val) {
console.log(val, "financialObj.multiPlatformMerchantFlag")
if (val == "Y") {
// const { djzhySubMerchantId, djzhySubMerchantName } = this.DjzhySubMerchantObj
// console.log(djzhySubMerchantId, djzhySubMerchantName, 'djzhySubMerchantId')
this.financialObj = Object.assign(
this.financialObj,
this.DjzhySubMerchantObj
)
// this.$forceUpdate()
// this.financialObj.djzhySubMerchantId = djzhySubMerchantId
// this.financialObj.djzhySubMerchantName = djzhySubMerchantName
console.log(this.financialObj, "this.financialObj")
} else {
this.financialObj.djzhySubMerchantId = ""
this.financialObj.djzhySubMerchantName = ""
}
}
},
productType: {
handler(val) {
this.initBaseData()
},
immediate: true,
deep: true
}
},
mounted() {
this.initFinancialObj() // 先默认初始化平台方和流量方
this.initDjzhySubMerchant() // 初始化嘀加智慧云子商户
// this.getFinancialObj()
// this.init4sServiceList()
this.initFeeCategoryByType()
this.getGoodsCategoryConfiguration()
this.getLedgerHistoryRecordApi()
const { merchantId, scene } = this.routerInfo
// yqMerchant && this.getMerchantLevel(yqMerchant.merchantId, 'PlatformLevelList')
this.initPlatformLevelList()
let eventArr = [this.init4sServiceList(), this.getFinancialObj()]
if (merchantId)
eventArr.push(
this.getMerchantLevel(merchantId, "merchantLevelList", scene)
)
// merchantId && this.getMerchantLevel(merchantId, "merchantLevelList", scene)
Promise.all(eventArr).then(() => {
this.checkSelectEmpty()
})
},
methods: {
...mapActions("FinancialRules", ["reset"]),
...mapMutations("FinancialRules", ["toggle", "set4sService"]),
initDjzhySubMerchant() {
// 初始化嘀加智慧云子商户
getDjzhySubMerchant({}).then((res) => {
// console.log(res, 'getDjzhySubMerchant')
const { merchantId, merchantName } = res
this.DjzhySubMerchantObj = {
djzhySubMerchantId: merchantId,
djzhySubMerchantName: merchantName
}
})
},
initFinancialObj() {
// 先取默认值
const { channelType, merchantName, merchantId } = this.routerInfo
this.financialObj = Object.assign(this.financialObj, {
realityPlatformMerchantId: -1, // 实际分账平台方商户id(嘀加智慧云为-1)
realityPlatformMerchantName: "嘀加智慧云", // 实际分账平台方商户名称
realityPlatformUserType: "2", // 实际分账平台方商户用户类型(1工厂2省代3市代4门店)
realityShopMerchantId: merchantId, // 实际分账4S店商户号
realityShopMerchantName: merchantName, // 实际分账4S店商户名称
realityShopUserType: channelType // 实际分账4S店商户用户类型(1工厂2省代3市代4门店)
})
},
initSettleTimeObj() {
const { settleTimeType, settleTime } = this.financialObj
this.settleTimeObj[settleTimeType == 1 ? "first" : "second"] = settleTime
},
getLedgerHistoryRecordApi() {
// 根据历史记录 处理财务生效记录的选项
const { merchantId, scene: sceneType } = this.routerInfo
ruleAuditSituation({
merchantId,
sceneType,
ruleType: 1
})
.then((res) => {
// 立即生效或者需选择
// console.log(res.every(item => {
// return item.rule.enableFlag == 3
// }), 'getLedgerHistoryRecordApi')
//
// res.inEffectSettleDistributeRule == null
this.effectStartDate = !res.inEffectSettleDistributeRule
// if (res.inEffectSettleDistributeRule == null) {
// }
// this.effectStartDate = res.every(item => {
// return item.rule.enableFlag == 3
// }) || !res.length
})
.catch((err) => {
console.log(err)
})
},
getGoodsCategoryConfiguration() {
// const { scene: sceneType } = this.routerInfo
// sceneType
getGoodsCategoryConfiguration({}).then((result) => {
const { list } = result
if (list.length) {
this.productType = list.map(({ categoryType, categoryName }) => {
return {
goodsType: categoryType,
goodsTypeName: categoryName
}
})
}
})
},
initFeeCategoryByType() {
// debugger
queryFeeCategoryByType({
feeCategoryType: 1,
applicationSceneType: this.routerInfo.scene,
orderBy: 2,
pageSize: 100000
}).then((result) => {
result = result.list
// console.log(result, 'result')
this.classificationObj = result.reduce(
(prev, item) => {
// console.log(item, 'item')
const {
applicationObjectType,
feeCategoryChildren,
formType,
feeCategoryNameId,
targetType,
nodeType
} = item
const feeCategoryNameListNew = feeCategoryChildren.map((ele) => {
ele.applicationObjectName = ele.feeCategoryName
ele.expenseCategoryId = ele.feeCategoryNameId
ele.targetType = applicationObjectType
return ele
})
// console.log(feeCategoryNameListNew, 'feeCategoryNameListNew')
const obj = {
applicationObjectType,
id: item.id,
applicationObjectName: item.feeCategoryName,
formType,
feeCategoryNameList: feeCategoryNameListNew,
expenseCategoryId: feeCategoryNameId,
nodeType,
targetType: applicationObjectType
}
if (applicationObjectType == 1) {
prev.trafficSide.push(obj)
} else if (applicationObjectType == 2) {
prev.serviceProvider.push(obj)
} else if (applicationObjectType == 3) {
// 过滤掉 产品成本 虚拟对账成本 回收成本 嘀加成本 第三方成本
const filterIdList = [3, 4, 300, 301, 700, 701]
if (!filterIdList.includes(obj.id)) {
prev.platformPublic.push(obj)
}
}
return prev
},
{
trafficSide: [],
serviceProvider: [],
platformPublic: []
}
)
})
},
init4sServiceList() {
return new Promise((resolve) => {
const { scene, merchantId } = this.routerInfo
scenemerchantrefQueryServiceRefByShop({ scene, merchantId })
.then((res) => {
// console.log(res)
this.serviceMerchantList = res
resolve()
})
.catch((err) => {
resolve()
})
})
},
getFinancialObj() {
return new Promise((resolve) => {
const { merchantId, scene: sceneType } = this.routerInfo
merchantSettleDistributeRuleLastRule({
merchantId,
sceneType,
expenseCategroyRulsBuildType: 1
})
.then((result) => {
// console.log(result)
// 判空处理
// result.goodsTypeGroupRules = [...result?.goodsTypeGroupRules, ...result?.goodsTypeGroupRules, ...result?.goodsTypeGroupRules]
const goodsTypeGroupRules = result?.goodsTypeGroupRules
result = result || this.financialObj
// result.autoFlag = null
// result.settleTimeType = null
// 解决老财务规则只做了一部分的问题 就不取老的了
// 处理 autoFlag 为空的兼容问题
// console.log(result.autoFlag)
// debugger
result.autoFlag = result.autoFlag ? result.autoFlag : "N"
result.settleTimeType = result.settleTimeType
? result.settleTimeType
: 1
result && result.divisionRuleId && (this.financialObj = result)
result.multiPlatformMerchantFlag =
result.multiPlatformMerchantFlag || "N"
const autoFlag = result?.autoFlag == "Y"
// 隐藏固定周期分账 处理历史数据
if (result?.settleTimeType == 2) result.settleTimeType = 1
result && (this.financialObj = result)
const upgradeArr = []
const packageArr = []
let startNum = 0
if (goodsTypeGroupRules && goodsTypeGroupRules[0].groupType == 2) {
goodsTypeGroupRules.unshift({ groupType: 1 })
}
goodsTypeGroupRules &&
goodsTypeGroupRules.forEach((item, index) => {
if (index == 0 && item.groupType == 2) {
startNum = 1
}
this.editableTabs[index] = {
title:
item.groupType == 1
? "全部品类"
: "特殊品类" + (index + startNum),
name: (index + 1).toString(),
testFlag: item.testFlag == "Y" && autoFlag ? "Y" : "N",
groupDivisionRuleId:
item.testFlag == "Y" ? "" : item.groupDivisionRuleId || ""
}
// 按商品分类
if (
item.goodsTypes?.length &&
item.goodsTypes[0]?.categoryType == 1
) {
item.goodsTypes = deepClone(item.goodsTypes)
item.categoryType = 1
item.upgradeGoods = [] // 与具体商品互不干扰
item.packageGoods = []
}
// 按具体商品
if (
item.goodsTypes?.length &&
item.goodsTypes[0]?.categoryType == 2
) {
item.upgradeGoods = deepClone(item.goodsTypes)
item.categoryType = 2
item.goodsTypes?.forEach((val) => {
upgradeArr.push({
upgradeGoodsId: val.upgradeGoodsId,
upgradeGoodsName: val.upgradeGoodsName,
commodityCode: val.commodityCode
})
})
item.goodsTypes = [] // 与分类互不干扰
item.packageGoods = []
}
// 按套餐商品
console.log(item.goodsTypes, "item.goodsTypes")
if (
item.goodsTypes?.length &&
item.goodsTypes[0]?.categoryType == 3
) {
item.packageGoods = deepClone(item.goodsTypes)
item.categoryType = 3
item.goodsTypes?.forEach((val) => {
packageArr.push({
packageCode: val.packageCode,
packageName: val.packageName
// commodityCode: val.commodityCode
})
})
item.goodsTypes = [] // 与分类互不干扰
item.upgradeGoods = [] // 与具体商品互不干扰
}
})
console.log(packageArr, "packageArr")
// 获取商品
this.getSelectingList(upgradeArr)
this.getSelectingListPackage(packageArr)
this.initSettleTimeObj()
resolve()
})
.catch(() => {
resolve()
})
})
},
initBaseData() {
this.goodsTypeGroupRelations = deepClone(this.productType)
},
assignGoodsTypeList(list) {
// console.log(list)
const newDatas = [...this.goodsSelectList, ...list]
const hash = {}
this.goodsSelectList = newDatas.reduce((item, next) => {
hash[next.goodsType]
? ""
: (hash[next.goodsType] = true && item.push(next))
return item
}, [])
},
// 取消选中具体商品
deleteUpgradeGoodsItem(item) {
this.selectUpgradeGoodsList = this.selectUpgradeGoodsList.filter(
(el) => el?.upgradeGoodsId != item?.upgradeGoodsId
)
},
assignUpgradeGoodsList(list) {
const newDatas = [...this.selectUpgradeGoodsList, ...list]
const hash = {}
this.selectUpgradeGoodsList = newDatas.reduce((item, next) => {
hash[next?.upgradeGoodsId]
? ""
: (hash[next?.upgradeGoodsId] = true && item.push(next))
return item
}, [])
// console.log(list, this.selectUpgradeGoodsList, 'this.selectUpgradeGoodsList')
},
// 取消选中套餐商品
deletePackageGoodsItem(item) {
this.selectPackageGoodsList = this.selectPackageGoodsList.filter(
(el) => el?.packageCode != item?.packageCode
)
},
assignPackageGoodsList(list) {
const newDatas = [...this.selectPackageGoodsList, ...list]
const hash = {}
this.selectPackageGoodsList = newDatas.reduce((item, next) => {
hash[next?.packageCode]
? ""
: (hash[next?.packageCode] = true && item.push(next))
return item
}, [])
},
async rulesTest() {
const res = deepClone(await this.handlerConfirm())
delete res.goodsTypeGroupRules
const testList = deepClone(
this.editableTabs.filter((item) => item.name == this.currentIndex)
)
// console.log('testList', testList)
const goodsTypeGroupRules = await this.getGoodsTypeGroupRules(testList)
// console.log(!this.checkParamsType(res, goodsTypeGroupRules))
if (!this.checkParamsType(res, goodsTypeGroupRules))
return this.$message.warning("请完善分账规则")
// console.log(res)
// console.log(goodsTypeGroupRules, 'goodsTypeGroupRules')
this.rulesTestParams = {
...res,
goodsTypeGroupRule: goodsTypeGroupRules[0]
}
// console.log('this.rulesTestParams', this.rulesTestParams)
this.merchantTestVisible = true
},
codeHandleConfirm({ smsCode, effectStartDate }) {
this.submitParams.smsCode = smsCode
// this.submitParams.effectStartDate = effectStartDate
this.submitParams.effectStartDate = effectStartDate
? effectStartDate + " 00:00:00"
: ""
merchantSettleDistributeRule({ json: JSON.stringify(this.submitParams) })
.then((result) => {
// 判断是否有没有进行过分账测试的账号
// autoFlag: 'N', // 自动分账标识(Y是,N否)
const { goodsTypeGroupRules, autoFlag } = result
const testFlag = goodsTypeGroupRules.some(
(item) => item.testFlag != "Y"
)
// 测试没通过的账号 线下分账无需校验
if (testFlag && autoFlag != "N") {
let frequency = 0 // 没通过的账号
goodsTypeGroupRules.forEach((item, index) => {
if (item.testFlag != "Y") {
frequency++
// this.editableTabs[index].testFlag = "N"
this.$set(this.editableTabs[index], "testFlag", "N")
// this.editableTabs[index].groupDivisionRuleId = item.groupDivisionRuleId
this.$set(
this.editableTabs[index],
"groupDivisionRuleId",
item.groupDivisionRuleId
)
}
})
this.editableTabs = deepClone(this.editableTabs)
this.$message.warning("需要进行分账测试")
// 只有一个账号没通过测试 直接弹框
if (frequency == 1) {
this.$nextTick(() => {
const item = this.editableTabs.find(
(item) => item.testFlag == "N"
)
const node = this.$refs[`classification${item.name}`][0]
node.getProgress()
}, 100)
}
} else {
// this.$ntoe.success('保存成功')
this.$notify({
type: "success",
title: "保存成功"
})
this.navBack()
}
})
.catch((err) => {
console.log(err)
})
},
checkSuccess(index) {
// 分账测试通过
this.editableTabs[index].testFlag = "Y"
this.editableTabs[index].groupDivisionRuleId = ""
this.editableTabs = deepClone(this.editableTabs)
// this.$set(this.editableTabs[index], 'groupDivisionRuleId', '')
// this.$set(this.editableTabs[index], 'testFlag', 'Y')
const flag = this.editableTabs.every((item) => item.testFlag == "Y")
flag && this.$router.push({ name: "merchantManage" })
// this.editableTabs[index].test = 'Y'
// this.editableTabs[index].testFlag = 'Y'
},
// 校验选项是否都通过
checkParamsType(obj, array) {
const flag = array.every((item) => item)
return obj && flag
},
async submit() {
const res = await this.handlerConfirm()
const goodsTypeGroupRules = await this.getGoodsTypeGroupRules(
this.editableTabs
)
if (!this.checkParamsType(res, goodsTypeGroupRules)) {
return this.$message.warning("请完善分账规则")
}
try {
this.submitParams = {
...res,
goodsTypeGroupRules
}
this.checkCalculateType()
this.verificationCodeVisible = true
console.log(this.submitParams, "this.submitParams ")
} catch (error) { }
// if (!res || !goodsTypeGroupRules) return false // 没有通过检验
},
checkCalculateType() {
let errorTips = 0
let [
allTrafficSide,
allTrafficSideArr,
allServiceProvider,
allServiceProviderArr,
allPlatformPublic,
allPlatformPublicArr
] = [[], [], [], [], [], []]
this.submitParams?.goodsTypeGroupRules?.forEach((val, index) => {
this.editableTabs[index].calculateModeError = false
const node =
this.$refs[`classification${this.editableTabs[index].name}`][0]
let [trafficSide, serviceProvider, platformPublic] = [[], [], []]
val?.expenseCategoryRules?.forEach((subV, subIndex) => {
if (subV?.targetType == 1) {
trafficSide.push(subV)
allTrafficSideArr.push(subV)
} else if (subV?.targetType == 2) {
serviceProvider.push(subV)
allServiceProviderArr.push(subV)
} else if (subV?.targetType == 3) {
platformPublic.push(subV)
allPlatformPublicArr.push(subV)
}
// 单独品类tab校验
if (subIndex == val.expenseCategoryRules?.length - 1) {
// 若自定义费用类目存在按整单分润模式,则流量方类目设置和服务商类目设置时,在按(收入-自定义其他费用)比例、按(收入-其他费用)比例按、园区店毛利(不扣除产品成本)、按园区店毛利仅支持整单模式(面向整套规则),存在该情况则无法提交(短信验证提交时)并toast提示:存在费用类目的计算模式冲突,请确认后重新操作
let platformPublicCalculateModeFlag = platformPublic.findIndex(
(i) => i.calculateMode == 2
)
// 若流量方费用类目存在按整单分润模式,则服务商类目设置时,在按园区店总金额、按园区店毛利(不扣除产品成本)、按园区店毛利仅支持整单模式(面向整套规则),存在该情况则无法提交(短信验证提交时)并toast提示:存在费用类目的计算模式冲突,请确认后重新操作
let trafficSideCalculateModeFlag = trafficSide.findIndex(
(i) => i.calculateMode == 2
)
if (platformPublicCalculateModeFlag > -1) {
trafficSide?.map((value, subI) => {
node.setCalculateError(subI, "trafficSide", false)
value?.children?.forEach((v) => {
if (
value?.calculateMode === 1 &&
([8, 9].includes(value.expenseCategoryCalculateType) ||
[8, 9].includes(v.expenseCategoryCalculateType))
) {
this.editableTabs[index].calculateModeError = true
errorTips++
node.setCalculateError(subI, "trafficSide")
}
})
if (
value?.calculateMode === 1 &&
[8, 9].includes(value.expenseCategoryCalculateType)
) {
this.editableTabs[index].calculateModeError = true
errorTips++
node.setCalculateError(subI, "trafficSide")
}
})
serviceProvider?.map((value, subI) => {
node.setCalculateError(subI, "serviceProvider", false)
value?.children?.forEach((v) => {
if (
value?.calculateMode === 1 &&
([5, 6, 8, 9].includes(
value.expenseCategoryCalculateType
) ||
[5, 6, 8, 9].includes(v.expenseCategoryCalculateType))
) {
this.editableTabs[index].calculateModeError = true
errorTips++
node.setCalculateError(subI, "serviceProvider")
}
})
if (
value?.calculateMode === 1 &&
[5, 6, 8, 9].includes(value.expenseCategoryCalculateType)
) {
this.editableTabs[index].calculateModeError = true
errorTips++
node.setCalculateError(subI, "serviceProvider")
}
})
}
if (trafficSideCalculateModeFlag > -1) {
serviceProvider?.map((value, subI) => {
node.setCalculateError(subI, "serviceProvider", false)
value?.children?.forEach((v) => {
if (
value?.calculateMode === 1 &&
([4, 5, 6].includes(value.expenseCategoryCalculateType) ||
[4, 5, 6].includes(v.expenseCategoryCalculateType))
) {
this.editableTabs[index].calculateModeError = true
errorTips++
node.setCalculateError(subI, "serviceProvider")
}
})
if (
value?.calculateMode === 1 &&
[4, 5, 6].includes(value.expenseCategoryCalculateType)
) {
this.editableTabs[index].calculateModeError = true
errorTips++
node.setCalculateError(subI, "serviceProvider")
}
})
}
// 流量方和其它费用同时设置为整单 服务商对账模式要取合集进行判断标记
if (
platformPublicCalculateModeFlag > -1 &&
trafficSideCalculateModeFlag > -1
) {
serviceProvider?.map((value, subI) => {
node.setCalculateError(subI, "serviceProvider", false)
value?.children?.forEach((v) => {
if (
value?.calculateMode === 1 &&
([4, 5, 6, 8, 9].includes(
value.expenseCategoryCalculateType
) ||
[4, 5, 6, 8, 9].includes(v.expenseCategoryCalculateType))
) {
this.editableTabs[index].calculateModeError = true
errorTips++
node.setCalculateError(subI, "serviceProvider")
}
})
if (
value?.calculateMode === 1 &&
[4, 5, 6, 8, 9].includes(value.expenseCategoryCalculateType)
) {
this.editableTabs[index].calculateModeError = true
errorTips++
node.setCalculateError(subI, "serviceProvider")
}
})
}
}
})
allTrafficSide.push(trafficSide)
allServiceProvider.push(serviceProvider)
allPlatformPublic.push(platformPublic)
// 全部tab品类校验
// 若自定义费用类目存在按整单分润模式,则流量方类目设置和服务商类目设置时,在按(收入-自定义其他费用)比例、按(收入-其他费用)比例按、园区店毛利(不扣除产品成本)、按园区店毛利仅支持整单模式(面向整套规则),存在该情况则无法提交(短信验证提交时)并toast提示:存在费用类目的计算模式冲突,请确认后重新操作
let platformPublicCalculateModeFlag = allPlatformPublicArr.findIndex(
(i) => i.calculateMode == 2
)
// 若流量方费用类目存在按整单分润模式,则服务商类目设置时,在按园区店总金额、按园区店毛利(不扣除产品成本)、按园区店毛利仅支持整单模式(面向整套规则),存在该情况则无法提交(短信验证提交时)并toast提示:存在费用类目的计算模式冲突,请确认后重新操作
let trafficSideCalculateModeFlag = allTrafficSideArr.findIndex(
(i) => i.calculateMode == 2
)
if (platformPublicCalculateModeFlag > -1) {
allTrafficSide?.map((value, subI) => {
let subNode =
this.$refs[`classification${this.editableTabs[subI].name}`][0]
value?.forEach((v, i) => {
subNode.setCalculateError(i, "trafficSide", false)
v?.children?.forEach((suV) => {
if (
v?.calculateMode === 1 &&
([8, 9].includes(v.expenseCategoryCalculateType) ||
[8, 9].includes(suV.expenseCategoryCalculateType))
) {
this.editableTabs[subI].calculateModeError = true
errorTips++
subNode.setCalculateError(i, "trafficSide")
}
})
if (
v?.calculateMode === 1 &&
[8, 9].includes(v.expenseCategoryCalculateType)
) {
this.editableTabs[subI].calculateModeError = true
errorTips++
subNode.setCalculateError(i, "trafficSide")
}
})
})
allServiceProvider?.map((value, subI) => {
let subNode =
this.$refs[`classification${this.editableTabs[subI].name}`][0]
value?.forEach((v, i) => {
subNode.setCalculateError(i, "serviceProvider", false)
v?.children?.forEach((suV) => {
if (
v?.calculateMode === 1 &&
([5, 6, 8, 9].includes(v.expenseCategoryCalculateType) ||
[5, 6, 8, 9].includes(suV.expenseCategoryCalculateType))
) {
this.editableTabs[subI].calculateModeError = true
errorTips++
subNode.setCalculateError(i, "serviceProvider")
}
})
if (
v?.calculateMode === 1 &&
[5, 6, 8, 9].includes(v.expenseCategoryCalculateType)
) {
this.editableTabs[subI].calculateModeError = true
errorTips++
subNode.setCalculateError(i, "serviceProvider")
}
})
})
}
if (trafficSideCalculateModeFlag > -1) {
allServiceProvider?.map((value, subI) => {
let subNode =
this.$refs[`classification${this.editableTabs[subI].name}`][0]
value?.forEach((v, i) => {
subNode.setCalculateError(i, "serviceProvider", false)
v?.children?.forEach((suV) => {
if (
v?.calculateMode === 1 &&
([4, 5, 6].includes(v.expenseCategoryCalculateType) ||
[4, 5, 6].includes(suV.expenseCategoryCalculateType))
) {
this.editableTabs[subI].calculateModeError = true
errorTips++
subNode.setCalculateError(i, "serviceProvider")
}
})
if (
v?.calculateMode === 1 &&
[4, 5, 6].includes(v.expenseCategoryCalculateType)
) {
this.editableTabs[subI].calculateModeError = true
errorTips++
subNode.setCalculateError(i, "serviceProvider")
}
})
})
}
// 流量方和其它费用同时设置为整单 服务商对账模式要取合集进行判断标记
if (
platformPublicCalculateModeFlag > -1 &&
trafficSideCalculateModeFlag > -1
) {
allServiceProvider?.map((value, subI) => {
let subNode =
this.$refs[`classification${this.editableTabs[subI].name}`][0]
value?.forEach((v, i) => {
subNode.setCalculateError(i, "serviceProvider", false)
v?.children?.forEach((suV) => {
if (
v?.calculateMode === 1 &&
([4, 5, 6, 8, 9].includes(v.expenseCategoryCalculateType) ||
[4, 5, 6, 8, 9].includes(suV.expenseCategoryCalculateType))
) {
this.editableTabs[subI].calculateModeError = true
errorTips++
subNode.setCalculateError(i, "serviceProvider")
}
})
if (
v?.calculateMode === 1 &&
[4, 5, 6, 8, 9].includes(v.expenseCategoryCalculateType)
) {
this.editableTabs[subI].calculateModeError = true
errorTips++
subNode.setCalculateError(i, "serviceProvider")
}
})
})
}
})
if (errorTips) {
throw this.$message.error(
"存在费用类目的计算模式冲突,请确认后重新操作"
)
}
},
getAllParams() {
// const res = await this.handlerConfirm()
// const goodsTypeGroupRules = this.getGoodsTypeGroupRules(this.editableTabs)
// if (!this.checkParamsType(res, goodsTypeGroupRules)) return this.$message.warning('请完善分账规则')
// if (!res || !goodsTypeGroupRules) return false // 没有通过检验
// this.submitParams = {
// ...res,
// goodsTypeGroupRules
// }
// this.verificationCodeVisible = true
// return new Promise(async (resolve, reject) => {
const list = deepClone(this.editableTabs)
const goodsTypeGroupRules = []
// 需要使用for循环解决异步同步问题
for (var index = 0; index < list.length; index++) {
// const element = array[index];
const node = this.$refs[`classification${list[index].name}`][0]
const res = node.getClassificationParams()
// const tabindex = this.editableTabs.findIndex(item => item.name == list[index].name)
// // 显示错误icon
// res ? this.editableTabs[tabindex].testFlag = "Y" : this.editableTabs[tabindex].testFlag = "N"
goodsTypeGroupRules.push(res)
}
console.log(goodsTypeGroupRules, "this.submitParams ")
return goodsTypeGroupRules
// })
},
async handlerConfirm() {
return new Promise((resolve, reject) => {
this.$refs.divisionRuleRef.validate(async (valid) => {
if (valid) {
resolve(this.getSubmitData())
} else {
resolve(false)
}
})
})
},
getSubmitData() {
// console.log(this.routerInfo.scene, 'getSubmitData')
return {
...this.getParams(),
sceneType: this.routerInfo.scene // 在后面避免被覆盖
}
},
getGoodsTypeGroupRules(list) {
return new Promise(async (resolve, reject) => {
const goodsTypeGroupRules = []
// 需要使用for循环解决异步同步问题
for (var index = 0; index < list.length; index++) {
// const element = array[index];
const node = this.$refs[`classification${list[index].name}`][0]
const res = await node.handleConfirm()
const tabindex = this.editableTabs.findIndex(
(item) => item.name == list[index].name
)
// 显示错误icon
res
? (this.editableTabs[tabindex].testFlag = "Y")
: (this.editableTabs[tabindex].testFlag = "N")
goodsTypeGroupRules.push(res)
}
this.$forceUpdate()
resolve(goodsTypeGroupRules)
})
},
getSelectingList(defaultSelect) {
getAllGoodsList({
// upgradeGoodsNameOrCCode: this.goodsNameKeyword,
goodsNameKeyword: this.goodsNameKeyword,
merchantIdList: [this.routerInfo.merchantId],
statusList: [1],
sceneTypeList: [this.routerInfo.scene],
currentPage: this.currentPage,
pageSize: this.pageSize
})
.then((res) => {
// console.log(res, "getAllGoodsList")
this.allPages = res.pages
const resArr = res.list.reduce((arr, val) => {
val.upgradeGoodsList.forEach(el => {
const item = {}
const { upgradeGoodsName, id, commodityCode } = el
item.upgradeGoodsId = id
item.upgradeGoodsName = upgradeGoodsName
item.commodityCode = commodityCode
arr.push(item)
})
return arr
}, [])
let arr = this.upgradeGoodsList.concat(resArr)
if (defaultSelect?.length) arr = arr.concat(defaultSelect)
this.upgradeGoodsList = this.unique(arr)
})
.catch(() => { })
},
unique(arr) {
const res = new Map()
return arr.filter(
(a) => !res.has(a.upgradeGoodsId) && res.set(a.upgradeGoodsId, 1)
)
},
// 或者商品套餐
getSelectingListPackage(defaultSelect = []) {
merchantPackageGoodsInfoPage({
// goodsNameKeyword: this.goodsNameKeyword,
currentPage: 1,
pageSize: 20,
status: 1,
sceneType: this.routerInfo.scene,
merchantIdList: [this.routerInfo.merchantId]
})
.then((res) => {
console.log(res, "merchantPackageGoodsInfoPage")
// this.allPages = res.pages
const resArr = []
res.list &&
res.list.forEach((val) => {
resArr.push({
packageCode: val.packageCode,
packageName: val.packageName
})
})
// console.log(resArr, 'resArr')
let arr = this.packageGoodsList.concat(resArr)
// console.log(arr, 'arr')
if (defaultSelect?.length) arr = arr.concat(defaultSelect)
this.packageGoodsList = this.uniquePackage(arr)
})
.catch(() => { })
},
uniquePackage(arr) {
const res = new Map()
return arr.filter(
(a) => !res.has(a.packageCode) && res.set(a.packageCode, 1)
)
},
getParams() {
var realityPlatform = this.baseData.PlatformLevelList.find(
(item) => item.merchantId == this.financialObj.realityPlatformMerchantId
)
var realityMerchant = this.baseData.merchantLevelList.find(
(item) => item.merchantId == this.financialObj.realityShopMerchantId
)
// debugger
const { settleTimeType, autoFlag } = this.financialObj
// debugger
return {
...this.financialObj,
merchantId: this.routerInfo.merchantId,
autoFlag,
settleTimeType,
settleTime:
this.settleTimeObj[settleTimeType == 1 ? "first" : "second"],
// 平台方
realityPlatformMerchantId: realityPlatform.merchantId,
realityPlatformMerchantName: realityPlatform.merchantName,
realityPlatformUserType: realityPlatform.userType || 2,
// 导流方
realityShopMerchantId: realityMerchant.merchantId,
realityShopMerchantName: realityMerchant.merchantName,
realityShopUserType: realityMerchant.userType
}
},
initPlatformLevelList() {
getPlatformMerchantList({}).then((res) => {
res.forEach((item) => {
item.showMerchantName = item.merchantName
})
this.baseData.PlatformLevelList = [
...this.baseData.PlatformLevelList,
...res
]
})
},
// 校验下拉框选项值是否存在
checkSelectEmpty() {
// 流量方分账方
if (
!this.baseData.merchantLevelList.find(
(item) => item.merchantId == this.financialObj.realityShopMerchantId
)
) {
this.financialObj.realityShopMerchantId = ""
}
// 服务商分润对象
this.editableTabs.forEach((val, index) => {
this.$refs[
`classification${this.editableTabs[index].name}`
][0].checkSelectEmpty()
})
},
getMerchantLevel(id, name, scene) {
// console.log(this.merchantInfo)
// getPlatformMerchantList().then(res => {
return new Promise((resolve, reject) => {
getMerchantLevelApi({
merchantId: id,
channelType: 1,
scene
})
.then((res) => {
// console.log('res', res)
// 取消渠道判断
const attrToVal = deepClone(attrToValOptions)
// var userTypeList = userType
if (name == "PlatformLevelList") {
delete attrToVal[2]
} else {
res.merchantId &&
this.baseData[name].push({
merchantId: res.merchantId,
showMerchantName: res.merchantName,
merchantName: res.merchantName,
// userType: res.userType
userType: res.merchantAccountLevel
})
}
attrToVal
.filter((item) => item.confId < +res.merchantAccountLevel)
.forEach((item) => {
res[item.confLabel + "MerchantId"] &&
this.baseData[name].push({
merchantId: res[item.confLabel + "MerchantId"],
showMerchantName:
userType[item.confId] +
":" +
res[item.confLabel + "MerchantName"],
merchantName: res[item.confLabel + "MerchantName"],
userType: item.confId
})
})
// 追加一级流量方和流量通道方
if (res.firstFlowMerchantId) {
this.baseData[name].push({
merchantId: res.firstFlowMerchantId,
showMerchantName: res.firstFlowMerchantName,
merchantName: res.firstFlowMerchantName
})
}
if (res.flowChannelMerchantId) {
this.baseData[name].push({
merchantId: res.flowChannelMerchantId,
showMerchantName: res.flowChannelMerchantName,
merchantName: res.flowChannelMerchantName
})
}
// 没有追加默认导流方
if (
this.baseData[name].length == 0 &&
name == "merchantLevelList"
) {
const { merchantId, merchantName, userType = 4 } = this.routerInfo
this.baseData[name].unshift({
merchantId,
showMerchantName: merchantName,
merchantName,
userType
})
}
// 将数据去重 (商户上架时一级流量方和流量通道方设置同一家门店)
this.baseData[name] = this.uniqueMerchant(this.baseData[name])
resolve()
})
.catch(() => {
resolve()
})
})
},
uniqueMerchant(arr) {
const res = new Map()
return arr.filter(
(a) => !res.has(a.merchantId) && res.set(a.merchantId, 1)
)
},
/* 函数定义 */
/* 活动标签切换时触发 */
beforeLeave(currentName, oldName) {
// 通过tab标签的切换事件触发增加的函数
// 如果name是add,则调用增加tab的函数
if (currentName == "add") {
this.addTab()
return false
} else {
this.currentIndex = currentName
}
},
addTab() {
// 根据已有的tab,再增减
const length = this.editableTabs.length
// this.tabIndex = length
this.addIndex = length
this.editableTabs = this.editableTabs.map((item, index) => {
item.name = (index + 1).toString()
return item
})
const newTabIndex = (this.editableTabs.length + 1).toString()
this.editableTabs.push({
title: "特殊品类" + this.addIndex++,
name: newTabIndex
})
this.editableTabsValue = newTabIndex
this.currentIndex = newTabIndex
},
confirmRemove(targetName) {
// 删除tab
this.$confirm("确认删除标签页吗?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
closeOnClickModal: false // 是否可以点击空白处关闭弹窗
})
.then(() => {
// 确认切换标签页
// this.activeName = tab.name
this.removeTab(targetName)
})
.catch((e) => {
console.log(e, "e")
// 取消切换标签页
this.$message({
type: "info",
message: "已取消删除"
})
})
},
removeTab(targetName) {
console.log(targetName)
// 获取当前tab 对应的对象
const goodsTypeGroupRules = this.getAllParams()
console.log(goodsTypeGroupRules, "goodsTypeGroupRules")
if (this.editableTabs.length <= 1) return false
var self = this
const tabs = self.editableTabs
let activeName = self.editableTabsValue
if (activeName === targetName) {
tabs.forEach((tab, index) => {
if (tab.name === targetName) {
const nextTab = tabs[index + 1]
if (!nextTab) {
activeName = tabs[index - 1].name
}
}
})
}
const currentTabIndex = this.editableTabs.findIndex(
(item) => item.name == targetName
)
console.log(
currentTabIndex,
this.editableTabs.length,
self.editableTabsValue,
activeName,
targetName,
currentTabIndex == this.editableTabs.length &&
activeName === targetName,
"currentTabIndex"
)
if (currentTabIndex < parseInt(self.editableTabsValue)) {
// activeName = this.editableTabs[ ].name
console.log(
parseInt(self.editableTabsValue) - 1,
"parseInt(self.editableTabsValue) - 1"
)
activeName = (parseInt(self.editableTabsValue) - 1).toString()
// self.editableTabsValue = activeName
}
self.editableTabsValue = activeName
const tabIndex = this.editableTabs.findIndex(
(item) => item.name == targetName
)
const upgradeArr = []
const packageArr = []
this.editableTabs = []
// console.log(goodsTypeGroupRules, "goodsTypeGroupRules")
const childParams = goodsTypeGroupRules.splice(tabIndex, 1)
// console.log(goodsTypeGroupRules, this.financialObj, "goodsTypeGroupRules")
// console.log(childParams, "packageArr")
// return
this.$nextTick(() => {
const { autoFlag } = this.financialObj
this.$set(this.financialObj, "goodsTypeGroupRules", goodsTypeGroupRules)
this.deleteSelectGoodsTypeList(childParams[0].goodsTypes)
this.deleteSelectUpgradeGoodsList(
childParams[0].goodsTypeGroupRelations
)
this.deleteSelectPackageGoodsList(childParams[0].packageGoods)
console.log(childParams, "packageArr")
goodsTypeGroupRules &&
goodsTypeGroupRules.forEach((item, index) => {
this.editableTabs[index] = {
title: index ? "特殊品类" + index : "全部品类",
name: (index + 1).toString(),
testFlag: item.testFlag == "Y" && autoFlag ? "Y" : "N",
groupDivisionRuleId:
item.testFlag == "Y" ? "" : item.groupDivisionRuleId || ""
}
// 按商品分类
if (
item.goodsTypes?.length &&
item.goodsTypes[0]?.categoryType == 1
) {
item.goodsTypes = deepClone(item.goodsTypes)
item.categoryType = 1
item.upgradeGoods = [] // 与具体商品互不干扰
item.packageGoods = []
}
// 按具体商品
if (
item.goodsTypes?.length &&
item.goodsTypes[0]?.categoryType == 2
) {
item.upgradeGoods = deepClone(item.goodsTypes)
item.categoryType = 2
item.goodsTypes?.forEach((val) => {
upgradeArr.push({
upgradeGoodsId: val.upgradeGoodsId,
upgradeGoodsName: val.upgradeGoodsName,
commodityCode: val.commodityCode
})
})
item.goodsTypes = [] // 与分类互不干扰
item.packageGoods = []
}
// 按套餐商品
// console.log(item.goodsTypes, 'item.goodsTypes')
if (
item.goodsTypes?.length &&
item.goodsTypes[0]?.categoryType == 3
) {
item.packageGoods = deepClone(item.goodsTypes)
item.categoryType = 3
item.goodsTypes?.forEach((val) => {
packageArr.push({
packageCode: val.packageCode,
packageName: val.packageName
// commodityCode: val.commodityCode
})
})
item.goodsTypes = [] // 与分类互不干扰
item.upgradeGoods = [] // 与具体商品互不干扰
}
})
// 获取商品
this.getSelectingList(upgradeArr)
this.getSelectingListPackage(packageArr)
// this.$forceUpdate()
this.$message({
type: "success",
message: "删除成功!"
})
})
},
deleteGoodsTypeItem(item) {
this.goodsSelectList = this.goodsSelectList.filter(
(el) => el.goodsType != item.goodsType
)
},
deleteSelectGoodsTypeList(list) {
this.goodsSelectList = this.goodsSelectList.reduce((arr, item) => {
if (
list &&
list.findIndex((el) => item.goodsType == el.goodsType) == -1
) {
arr.push(item)
}
return arr
}, [])
},
deleteSelectUpgradeGoodsList(list) {
console.log(
list,
this.selectUpgradeGoodsList,
"this.selectUpgradeGoodsList"
)
if (list && list.length) {
this.selectUpgradeGoodsList = this.selectUpgradeGoodsList.reduce(
(arr, item) => {
if (
list.findIndex(
(el) => item?.upgradeGoodsId == el?.upgradeGoodsId
) == -1
) {
arr.push(item)
}
return arr
},
[]
)
}
console.log(
list,
this.selectUpgradeGoodsList,
"this.selectUpgradeGoodsList"
)
// debugger
},
deleteSelectPackageGoodsList(list) {
this.selectPackageGoodsList = this.selectPackageGoodsList.reduce(
(arr, item) => {
if (
list &&
list.findIndex((el) => item?.packageCode == el?.packageCode) == -1
) {
arr.push(item)
}
return arr
},
[]
)
},
navBack() {
this.$router.push({ path: "/merchantManage" })
}
}
}
</script>
<style lang="scss" scoped>
.financialRulesContainer {
// background-color: #fff;
}
.ml10 {
margin-left: 10px;
}
.footer {
text-align: center;
}
</style>