index.js
40.6 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
// packageCrowdFunding/pages/homePage/index/index.js
import {
setConfigInfo
} from "~/store/index";
import {
checkDailyReport
} from "~/store/ModalToQueueControl";
import {
getReceptionRecordList,
getRecordDetailList
} from "../../receptionRecordsApi"
let lastPath = null; // 用于存储上一次的路径
function throttle(func, delay) {
let timeoutId;
let lastExecTime = 0;
return function (...args) {
const currentTime = Date.now();
// Calculate the time elapsed since the last execution
const timeSinceLastExec = currentTime - lastExecTime;
// If the elapsed time is greater than the delay, execute the function immediately
if (timeSinceLastExec >= delay) {
func.apply(this, args);
lastExecTime = currentTime;
} else {
// If there is a pending timeout, cancel it
if (timeoutId) {
clearTimeout(timeoutId);
}
// Schedule the function execution after the remaining delay
timeoutId = setTimeout(() => {
func.apply(this, args);
lastExecTime = Date.now();
}, delay - timeSinceLastExec);
}
};
}
const IMG_URL =
"https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/";
// import api from '~/packageCrowdFunding/api'
import NP from "number-precision";
import {
getBusinessSchoolScene
} from "~/store/index";
import {
getQuotationStatistics,
outputValueStatistics,
quotationPage,
updateOrderStatus,
merchantMode,
orderStaffValid,
} from "../../api";
import commonApi from "~/api/api";
const app = getApp();
import carLifeApi from "../../carEquityApi";
import reportPageTrackMixin from '~/mixins/reportPageTrackMixin'
Component({
behaviors: [reportPageTrackMixin],
/**
* 组件的属性列表
*/
properties: {
navBarHeight: {
type: Number,
value: 0,
},
mode: {
type: Number,
observer: function (n, o) {
this.menuListRest();
},
},
waitInputCount: {
type: Number,
},
showScreen: {
type: Boolean
},
show: {
type: Number,
observer: function (n, o) {
if (n) this.onPageShow()
else this.onPageHide()
},
},
},
/**
* 组件的初始数据
*/
data: {
nothing: false,
listData: [],
IMG_URL,
statisticsObj: {},
dataActive: "today",
staticDataList: [{
label: "今日营业额",
value: "todayTurnover",
tipsLabel: "今日成交量",
tipsValue: "todayOrderNumber",
},
{
label: "本月营业额",
value: "monthTurnover",
tipsLabel: "本月成交量",
tipsValue: "monthOrderNumber",
},
{
label: "累计营业额",
value: "totalTurnover",
tipsLabel: "累计成交量",
tipsValue: "totalOrderNumber",
},
],
itemDataList: [
// {
// label: '营业额',
// value: 'totalOutputValue',
// icon: 'icon_15',
// unit: true
// },
{
label: "客户成交",
value: "totalSuccessCount",
icon: "icon_1",
waitlabel: "推荐量",
waitValue: "totalQuotationCount",
index: 1,
},
// {
// label: '客户推荐量',
// value: 'totalQuotationCount',
// icon: 'icon_13'
// },
// {
// label: '报价单量',
// value: 'totalOrderCount',
// icon: 'icon_4'
// },
{
label: "成交",
value: "totalSuccessOrderCount",
icon: "icon_7",
waitlabel: "报价单量",
waitValue: "totalOrderCount",
index: 2,
},
{
label: "融合客单价",
value: "avgPrice",
icon: "icon_12",
unit: true,
},
{
label: "权益客单价",
value: "avgQuotationPrice",
icon: "icon_11",
unit: true,
},
],
menuList: [],
newMenuList: [{
menuText: "培训资料",
icon: "peixun_icon",
path: "packageEquity.trainingMaterials",
},],
loginRoleLabel: {
1: "超管",
2: "商户管理员",
3: "区域运营",
4: "驻店负责人",
5: '广联销售',
},
loginRole: "",
userInfo: {},
staticData: {},
taskInfo: {},
current: 0,
todoList: [],
stodoList: [],
todos: {
1: "日报填写提醒",
2: "今日尚未开单",
3: "工牌处于离线状态",
4: "客户跟进提醒",
5: "培训提醒",
6: "资料查看提醒",
7: "上班打卡",
8: "下班打卡",
},
styleHight: "auto",
ispopUp: true,
isPad: false,
pageNum: 1, // 接待记录时间轴分页
searchForm: {},
showEmployeeName: false, // 是否展示销售顾问字段
isShowDefeatBtn: true, // 是否展示录单按钮入口
loaded: false,
track_event_code: 'staff_reception_list', //埋点动作类型
},
lifetimes: {
attached() {
let userInfo = wx.$util.getUserInfo()
const loginRole = userInfo.subLoginUser?.loginRole
this.setData({
loginRole,
userInfo
})
this.onLoad();
},
},
/**
* 组件的方法列表
*/
methods: {
onScroll(e) {
let _this = this
let {
navBarHeight
} = _this.data
let query = wx.createSelectorQuery().in(_this)
query.select('.screen-box').boundingClientRect()
query.exec(function (res) {
if (res[0]?.top - 6 <= navBarHeight) {
_this.setData({
isScrollTop: true,
isSticky: true
})
} else {
_this.setData({
isScrollTop: false
})
}
})
},
// 查询员工待办事项列表
getStaffRemindList() {
let userInfo = wx.$util.getUserInfo();
let params = {
merchantId: userInfo?.default4SStoreInfo?.merchantId,
staffUuid: userInfo?.uuid,
scene: 0,
};
commonApi.getStaffRemindList(params).then((result) => {
this.setData({
todoList: result.data || [],
});
});
},
closeRemind(e) {
let userInfo = wx.$util.getUserInfo(),
taskId = e.currentTarget.dataset.id;
let params = {
merchantId: userInfo?.default4SStoreInfo?.merchantId,
staffUuid: userInfo?.uuid,
scene: 0,
taskId,
};
commonApi.shutDownTaskApi(params).then((result) => {
if (result.data) {
this.getStaffRemindList();
wx.showToast({
title: "关闭成功",
icon: "success",
});
// if (taskId == 5) {
// //培训提醒
// return wx.$router.go("packageEquity.trainingMaterials");
// }
// if (taskId == 6) {
// // 资料查看提醒
// wx.$eventbus.emit('switch_tab')
// return
// }
}
});
},
goto(e) {
let url,
id = e.currentTarget.dataset.id;
switch (id) {
case 1:
//日报填写提醒
let currentDate = new Date();
// 获取上一天的日期
let previousDate = new Date(currentDate);
previousDate.setDate(currentDate.getDate() - 1);
// toISOString 方法会丢失时区 导致与北京时间差八小时
let hour = previousDate.getHours() + 8;
previousDate.setHours(hour);
// 格式化日期为"yyyy-mm-dd"
let formattedDate = previousDate.toISOString().split("T")[0];
wx.$router.go("tabWorkOrder.staffDaily", {
// reportDate: hasNeedReport.date
reportDate: formattedDate,
});
break;
case 2:
//开单提醒
let {
mode, taskId, merchantBrand
} = this.data;
if (
merchantBrand.findIndex((i) => ["鸿蒙智行"].includes(i.name)) != -1
)
wx.$router.go("beforeCreate", {
mode,
});
else
wx.$router.go(
mode ? "createOrderCarQuotationSimple" : "createOrderCarQuotation"
);
// wx.$router.go('tabDate.apprManage')
break;
case 4:
//预约客户提醒
// url = "/pages/index/index";
break;
}
// wx.$router.go(url);
},
packupList() {
if (this.data.ispopUp) {
this.setData({
stodoList: this.data.todoList.slice(0, 2),
ispopUp: false,
});
} else {
this.setData({
ispopUp: true,
});
}
},
changeSwiper(e) {
let name =
e.detail.current == 0 ?
"today" :
e.detail.current == 1 ?
"month" :
"total";
this.setData({
current: e.detail.current,
dataActive: name,
});
this.getData(name);
},
checkIsPadOrNot() {
wx.getRendererUserAgent({
success(res) {
let isPad = /iPad|Android.*Tablet|Kindle|Silk/i.test(res.userAgent);
_this.setData({
isPad,
});
},
});
},
menuListRest() {
// debugger
const isStaff = app.globalData.isStaff;
// console.log(isStaff, "isStaff");
// let userInfo = wx.$util.getUserInfo()
let userInfo = wx.$util.getUserInfo() || {};
// let issta
let {
menuList,
mode
} = this.data;
// if (
// isStaff &&
// menuList.every((item) => item.menuText != "战败下单" && mode)
// ) {
// menuList.push({
// menuText: "战败下单",
// icon: "deafeat_order",
// // path: "packageEquity.createDeafeatOrder",
// path: "packageEquity.createDeafeatOrderBefore",
// sortVal: 3
// });
// }
// if (menuList.some((item) => item.menuText == "战败下单" && mode == 0)) {
// menuList = menuList.filter((item) => item.menuText != "战败下单");
// }
// console.log('menuList', mode, menuList,);
// 将menuList排序
menuList.sort((a, b) => a.sortVal - b.sortVal)
this.setData({
menuList,
});
},
// 接待记录查询条件
getParams() {
let {
searchForm,
isFilterDefeat,
isFilterUpgrade,
storeRangeList
} = this.data
let userInfo = wx.$util.getUserInfo() || {};
// 获取当前时间的时间戳
let timestamp = new Date().getTime()
let sevenDaysAgoTimestamp = timestamp - 6 * 24 * 60 * 60 * 1000
let sevenDaysAgoDate = new Date().format('yyyy-MM-dd')
if (!searchForm.orderResult?.length) searchForm.orderResult = (isFilterDefeat ? [2] : []).concat(isFilterUpgrade ? [1] : [])
let obj = {
startDateTime: searchForm?.startDateTime || new Date(sevenDaysAgoTimestamp).format('yyyy-MM-dd'),
endDateTime: searchForm?.endDateTime || sevenDaysAgoDate,
customerName: searchForm?.customerName || '',
phoneNumber: searchForm?.customerName || '',
qualityCheckScoreBegin: searchForm?.qualityCheckScoreBegin,
qualityCheckScoreEnd: searchForm?.qualityCheckScoreEnd,
customerTypes: searchForm?.customerTypes,
carModels: searchForm?.carModels,
orderResult: searchForm?.orderResult,
merchantNo: !searchForm?.merchantNo?.length ? (userInfo?.isSuper ? storeRangeList.map(v => {
if (v.merchantNo) return v.merchantNo
}) : userInfo?.loginRole == 3 || userInfo.loginRole == 5 ? '' : [userInfo?.default4SStoreInfo?.merchantId]) : searchForm?.merchantNo,
staffUuids: userInfo.isSuper || userInfo?.loginRole == 3 || userInfo.loginRole == 5 ? searchForm?.staffUuids : [userInfo.uuid]
}
return obj
},
// 详情页面
goReceptionDetail(e) {
let {
item
} = e.currentTarget.dataset
wx.$router.go('receptionDetail', item)
wx.$track.setTrackData(0, 'reception_detail', {
batchId: item.batchId
})
},
onLoad() {
this.onPageShow()
const isStaff = app.globalData.isStaff;
let userInfo = wx.$util.getUserInfo() || {};
if (userInfo?.isSuper || userInfo?.loginRole == 3 || userInfo.loginRole == 5) this.setData({
showEmployeeName: true,
isShowDefeatBtn: false
})
this.setData({
storeInfo: wx.$util.getUserInfo()?.default4SStoreInfo || {},
userInfo,
isStaff,
isWait: !(userInfo?.isSuper || userInfo?.loginRole == 3 || userInfo.loginRole == 5)
});
let {
menuList,
mode
} = this.data;
if (isStaff && menuList.every((item) => item.menuText != "新建工单")) {
menuList.unshift({
menuText: "新建工单",
icon: "create_order",
path: "",
sortVal: 2
});
}
// if (
// isStaff &&
// menuList.every((item) => item.menuText != "战败下单" && mode)
// ) {
// menuList.push({
// menuText: "战败下单",
// icon: "deafeat_order",
// path: "packageEquity.createDeafeatOrder",
// path: "packageEquity.createDeafeatOrderBefore",
// sortVal: 3
// });
// }
// if ((userInfo.isSuper || userInfo?.loginRole == 3 || userInfo.loginRole == 5) && menuList.every((item) => item.menuText != "BI报表")) {
// menuList.unshift({
// menuText: "BI报表",
// path: "tabOperating.index",
// recordId: 11,
// icon: "business_data",
// sortVal: 11
// })
// }
// if ((userInfo?.loginRole == 3 || userInfo.loginRole == 5) && menuList.every((item) => item.menuText != '积分审批')) {
// menuList.unshift({
// menuText: "积分审批",
// path: "pages.pointsReview",
// icon: "points_review",
// sortVal: 12
// })
// }
// if (
// userInfo.isSuper &&
// menuList.every((item) => item.menuText != "质检管理")
// ) {
// menuList.unshift({
// menuText: "质检管理",
// icon: "s_ai_inspection",
// path: "packageEquity.employeeInspection",
// default: true,
// });
// }
if (
(isStaff || userInfo.isSuper || userInfo?.loginRole == 3 || userInfo.loginRole == 5) &&
menuList.every((item) => item.menuText != "驻店日报")
) {
menuList.unshift({
menuText: "驻店日报",
path: "tabWorkOrder.staffDaily",
recordId: 13,
icon: "supplementary_order",
sortVal: 1
});
}
// 驻店负责人
// if (
// app.globalData.isStaff &&
// userInfo?.loginRoleOnSelectMerchant == 4 &&
// menuList.every((item) => item.menuText != "交车目标")
// ) {
// menuList.push({
// menuText: "交车目标",
// path: "packageEquity.deliveryTarget",
// icon: "delivery_target",
// sortVal: 9
// });
// }
// if (!(userInfo?.isSuper || userInfo?.loginRole == 3 || userInfo.loginRole == 5) && menuList.every((item) => item.menuText != "培训资料")) {
// menuList.push({
// menuText: "培训资料",
// icon: "peixun_icon",
// path: "packageEquity.trainingMaterials",
// sortVal: 7
// });
// }
// if (!app.globalData.isStaff || userInfo?.loginRoleOnSelectMerchant != 4) {
// let index = menuList?.findIndex((val) => val.menuText == "交车目标");
// index > -1 && menuList.splice(index, 1);
// }
// 督导和销售
// if ((userInfo?.loginRole == 3 || userInfo?.loginRole == 5) && menuList.every((item) => item.menuText != '工作日报')) {
// menuList.push({
// menuText: "工作日报",
// path: "tabWorkOrder.supervisorDaily",
// icon: "supervisorDaily",
// })
// }
// if (
// (userInfo?.isSuper ||
// userInfo?.loginRole == 3 ||
// userInfo.loginRole == 5) &&
// menuList.every((item) => item.menuText != "驻店管理")
// ) {
// menuList.push({
// menuText: "驻店管理",
// path: "tabWorkOrder.residentManage",
// recordId: 13,
// icon: "residentManage"
// });
// }
this.checkIsPadOrNot();
this.getData();
// 隐藏待办事项模块
// if (isStaff) this.getStaffRemindList();
this.getTotal(this.data.dataActive);
let eventArr = [ this.getInspectionBadgeCode()]
if (isStaff) eventArr.push(this.getStaffTargetTask())
Promise.all(eventArr).then(() => {
this.menuListRest(); // 解决融合和非融合互相切换导致战败按钮问题
})
// 将开单预警弹窗提醒移到equityPage页去校验
// if (isStaff) this.checkStaffOrderStatus();
// 非区域督导和超管角色
if (!userInfo?.isSuper && userInfo?.loginRole != 3) this.getMerchantCarBrandList();
},
getStoreList() {
return new Promise(resolve => {
// if (wx.$receptionLoaded) return
let userInfo = wx.$util.getUserInfo() || {}
let {
menuList
} = this.data
carLifeApi.selectrecmerchantList({}).then(res => {
let {
code,
data,
message
} = res
if (code == 0) {
let index = data?.findIndex(v => v.merchantNo == userInfo?.default4SStoreInfo?.merchantId)
if (userInfo.isSuper || index > -1 || userInfo.loginRole === 3 || userInfo.loginRole == 5) {
if (menuList.every((item) => item.menuText != "接待记录")) {
menuList.push({
menuText: "接待记录",
icon: "reception-record-icon",
path: "packageEquity.receptionRecords",
default: true,
sortVal: 4
})
}
this.setData({
storeRangeList: data,
listData: [],
nothing: false
}, () => {
this.getReceptionList()
})
} else {
let index_x = menuList.findIndex((e) => e.menuText == "接待记录")
if (index_x > -1) menuList.splice(index_x, 1)
}
} else {
wx.$util.showToast(message)
}
resolve()
})
})
},
// 获取接待记录统计数据
getReceptionList() {
let params = this.getParams()
this.setData({
loaded: false
}, () => {
wx.showLoading({
title: '加载中'
})
getReceptionRecordList({
merchantNo: params.merchantNo,
startDateTime: params.startDateTime,
endDateTime: params.endDateTime,
staffUuids: params.staffUuids
}).then(res => {
let {
code,
message,
data
} = res
if (code == 0) {
data?.forEach(val => {
val.receptionStaticInfoDTOList = []
val.staticDateStr = `${new Date(val.staticDate).getMonth() + 1}月${new Date(val.staticDate).getDate()}日`
})
this.setData({
listData: data,
pageNum: 1,
nothing: false
}, () => {
this.getReceptionRecordDetailInfo()
})
} else {
wx.$util.showToast(message)
}
}).catch(err => {
wx.hideLoading()
})
})
},
// 获取接待记录接待时间轴详情数据
getReceptionRecordDetailInfo() {
let {
pageNum,
listData,
nothing
} = this.data
let params = {
pageNum,
...this.getParams()
}
if (nothing) return // 进获取近七天数据
wx.showLoading({
title: '加载中'
})
this.track_businessParam = params //埋点业务参数
getRecordDetailList(params).then(res => {
let {
code,
data,
message
} = res
if (code == 0) {
listData?.forEach(val => {
data?.list?.forEach(subV => {
if (val.staticDate == subV.staticDate && val.receptionStaticInfoDTOList?.findIndex(v => v.fileUrl == subV.fileUrl) < 0) val.receptionStaticInfoDTOList.push(subV)
})
})
this.setData({
loaded: true,
listData,
pageNum: pageNum + 1,
nothing: pageNum == data?.pages || data?.total == listData.reduce((acc, curr) => acc + curr?.receptionStaticInfoDTOList?.length, 0)
})
} else {
wx.$util.showToast(message)
}
wx.$receptionLoaded = true
wx.hideLoading()
}).catch(err => {
wx.hideLoading()
})
},
// 过滤升级/战败接待记录数据
filterItemData(e) {
let {
type
} = e.currentTarget.dataset
let {
isFilterUpgrade,
isFilterDefeat,
searchForm
} = this.data
let orderResult = searchForm?.orderResult || []
let index
if (type == 'upgrade' || type == 'defeat') {
let targetType = type == 'upgrade' ? 1 : 2;
index = orderResult.findIndex(v => v == targetType)
if (type == 'upgrade') {
if (!isFilterUpgrade) {
orderResult.push(1)
} else {
orderResult.splice(index, 1)
}
this.setData({
isFilterUpgrade: !isFilterUpgrade,
'searchForm.orderResult': orderResult
});
} else if (type == 'defeat') {
if (!isFilterDefeat) {
orderResult.push(2)
} else {
orderResult.splice(index, 1)
}
this.setData({
isFilterDefeat: !isFilterDefeat,
'searchForm.orderResult': orderResult
})
}
}
this.setData({
nothing: false,
listData: [],
['searchForm.orderResult']: orderResult
}, () => {
this.getReceptionList()
})
},
onBottomRefresh() {
this.getReceptionRecordDetailInfo()
},
// 工资绩效入口
getBusiness() {
let {
menuList
} = this.data
let userInfo = wx.$util.getUserInfo() || {};
getBusinessSchoolScene({}).then((res) => {
// if (
// (res || userInfo?.isSuper) &&
// menuList.every((item) => item.menuText != "工资绩效")
// ) {
if (res && menuList.every((item) => item.menuText != "工资绩效")) {
menuList.unshift({
menuText: "工资绩效",
icon: "businessschoo",
path: "",
sortVal: 8
});
this.setData({
menuList
});
}
});
},
checkStaffOrderStatus() {
let userInfo = wx.$util.getUserInfo();
let dateStaffPop = wx.$storage.get("dateStaffPop");
let nowDate = new Date().format("yyyy-MM-dd");
let {
sceneType,
default4SStoreInfo: {
merchantId
},
} = userInfo;
let dayBoolean = dateStaffPop?.date && nowDate == dateStaffPop?.date;
let flag = dateStaffPop?.[sceneType]?.[merchantId];
console.log(
flag,
"flag",
dateStaffPop?.[sceneType],
dateStaffPop?.[sceneType]?.[merchantId]
);
// let num = 0
// 当天已查询过
if (dayBoolean && flag) {
// num = dateStaffPop?.num || 0
// num = num + 1
// num = 1
return;
}
orderStaffValid({
sceneType: userInfo.sceneType,
})
.then((result) => {
console.log(result, "orderStaffValid");
if (result.data) {
if (wx.__HAS_NOREPORT_MODAL || wx.__HAS_NOTLOGIN_MODAL)
return false;
wx.__HAS_NOREPORT_MODAL = true;
wx.showModal({
title: "开单预警",
content: "您已超过三天未开单",
showCancel: false,
// cancelText: '取消', // '取消
cancelColor: "#292D33",
confirmText: "确定",
confirmColor: "#347BFF",
success(res) {
// if (res.confirm) {
// wx.$router.go('tabWorkOrder.staffDaily', {
// reportDate: hasNeedReport.date
// })
// }
},
complete: () => {
// 这个延迟的目的是为了避免短时间内重复弹出
// 你要是没有这个需要也可以去掉,直接把标志位改成 false 就行
setTimeout(() => {
wx.__HAS_NOREPORT_MODAL = false;
}, 2000);
},
});
wx.$storage.set("dateStaffPop", {
date: new Date().format("yyyy-MM-dd"),
0: {
[userInfo.default4SStoreInfo.merchantId]: true,
...dateStaffPop[0],
},
});
}
})
.catch((err) => { });
},
getStaffTargetTask() {
return new Promise(resolve => {
let userInfo = wx.$util.getUserInfo();
let {
menuList
} = this.data;
if (userInfo?.isSuper || userInfo?.loginRole == 3 || userInfo.loginRole == 5) return
commonApi
.getStaffTargetTaskApi({
sceneType: 0,
merchantId: userInfo?.default4SStoreInfo?.merchantId,
})
.then((res) => {
let {
code,
data,
message
} = res;
if (code == 0) {
// 切换门店 需删除入口 重新请求判断显示入口
let index = menuList.findIndex((v) => v.menuText == "驻店目标");
if (index > -1) menuList.splice(index, 1);
if (
data?.length &&
menuList.every((item) => item.name != "驻店目标")
) {
menuList.push({
menuText: "驻店目标",
path: "packageEquity.residentTarget",
icon: "resident_target",
noRead: data[0]?.readFlag == "N",
sortVal: 10
});
}
this.setData({
taskId: data[0]?.id,
menuList,
});
// 当前周期未弹起过查看任务明细提示弹窗
if (data[0]?.promptFlag == "N") {
this.setData({
showTaskDialog: true,
taskInfo: data[0],
});
// 将当前周期的员工目标任务弹窗标记为已弹起
commonApi
.setTaskDialog({
id: data[0]?.id,
})
.then(() => { });
}
} else {
wx.$util.showToast(message);
}
});
resolve()
})
},
getTotal() {
let {
storeInfo
} = this.data;
getQuotationStatistics({
merchantId: storeInfo?.merchantId,
}).then((res) => {
// console.log(res, '统计---')
let {
code,
message
} = res;
let data = res.data ? {
...res.data,
todayTurnover: res.data.todayTurnover ?
((res.data.todayTurnover / 100).toFixed(2) + "").split(".")[0] : "0",
todayTurDecimal: res.data.todayTurnover ?
((res.data.todayTurnover / 100).toFixed(2) + "").split(".")[1] : "00",
// totalTurnover: res.data.totalTurnover ? (Math.round()(res.data.totalTurnover / 100).toFixed(2) + '').split('.')[0] : '0',
totalTurnover: res.data.totalTurnover ?
Math.round(res.data.totalTurnover / 100) : "0",
totalTurDecimal: res.data.totalTurnover ?
((res.data.totalTurnover / 100).toFixed(2) + "").split(".")[1] : "00",
monthTurnover: res.data.monthTurnover ?
((res.data.monthTurnover / 100).toFixed(2) + "").split(".")[0] : "0",
// monthTurnover: 12233,
// monthTurDecimal: res.data.monthTurnover ? ((res.data.monthTurnover / 100).toFixed(2) + '').split('.')[1] : '00'
} : {};
if (code == "0") {
this.setData({
statisticsObj: data,
});
// console.log(this.data.statisticsObj)
} else {
wx.$util.showToast(message || "接口异常");
}
});
},
getData() {
const userInfo = wx.$util.getUserInfo();
const {
dataActive,
merchantId
} = this.data;
let today = new Date();
let thisMonth = new Date(new Date().setDate(1)).format("yyyy-MM-dd");
const dataobj = {
today: {
startTime: today.format("yyyy-MM-dd") + " 00:00:00",
endTime: today.format("yyyy-MM-dd") + " 23:59:59",
},
month: {
startTime: thisMonth + " 00:00:00",
endTime: today.format("yyyy-MM-dd") + " 23:59:59",
},
total: {
startTime: "",
endTime: "",
},
};
outputValueStatistics({
...dataobj[dataActive],
shopMerchantId: userInfo?.default4SStoreInfo?.merchantId,
}).then((res) => {
let {
code,
data,
message
} = res;
if (code == 0) {
data.conversionRate = NP.times(data.conversionRate, 100);
data.avgPrice = NP.divide(data.avgPrice, 100);
data.avgPrice = NP.round(data.avgPrice, 0);
data.totalOutputValue = NP.round(data.totalOutputValue, 0);
data.avgQuotationPrice = NP.round(data.avgQuotationPrice, 0);
this.setData({
staticData: data || {},
});
} else {
wx.$util.showToast(message);
}
});
},
changeDataSelect(e) {
let {
name
} = e.currentTarget.dataset;
this.setData({
dataActive: name,
});
this.getData(name);
},
// setData (name) {
// let thisMonth = new Date(new Date().setDate(1)).format('yyyy-MM-dd')
// let today = new Date()
// let todayObj = {
// name: '今日',
// startDate: today.format('yyyy-MM-dd'),
// endDate: today.format('yyyy-MM-dd')
// }
// let thisMonthObj = {
// name: '本月',
// startDate: thisMonth,
// endDate: today.format('yyyy-MM-dd')
// }
// let {
// }
// },
navGo: throttle(async function (e) {
// debugger
// wx.$util.showLoading('跳转中...')
let {
mode,
taskId,
merchantBrand
} = this.data;
let {
item
} = e.currentTarget.dataset;
let userInfo = wx.$util.getUserInfo();
// 如果 item.path 相同,则不执行后续跳转
if (item.path === lastPath) {
console.log('路径一样');
return; // 直接返回,不执行后续逻辑
}
// 解决路径不清空问题
setTimeout(() => {
lastPath = null
}, 2000)
lastPath = item.path; // 更新上一次的路径
if (item.path) {
if (item.menuText == "驻店目标") {
return wx.$router.go(item.path, {
id: taskId,
});
}
else {
// if (item.menuText === "培训资料") {
// let params = {
// merchantId: userInfo?.default4SStoreInfo?.merchantId,
// staffUuid: userInfo?.uuid,
// scene: 0,
// taskId: 5,
// };
// commonApi.shutDownTaskApi(params);
// }
// console.log(merchantBrand.findIndex((i) => ["鸿蒙智行"].includes(i.name)) == -1);
// debugger
// if (item.menuText == '战败下单' && merchantBrand.findIndex((i) => ["鸿蒙智行"].includes(i.name)) == -1) {
// item.path = 'packageEquity.createDeafeatOrder'
// }
// if (item.menuText == '战败下单') {
// // 校验是否填写昨日日报
// let staffCheck = await checkDailyReport(true);
// if (staffCheck) return false;
// }
return wx.$router.go(item.path, {
scene: 0,
params: item.params || {},
});
}
} else {
// 工资绩效特殊处理
if (item.menuText == "工资绩效") {
return wx.$router.go("packageEquity.collegeScene", {
reLaunchPath: "packageEquity.equityPage",
tabIndex: 0,
});
}
// 校验是否填写昨日日报
let staffCheck = await checkDailyReport(true);
console.log(staffCheck, 'staffCheck');
if (staffCheck) return false;
if (
merchantBrand.findIndex((i) => ["鸿蒙智行"].includes(i.name)) != -1
) {
wx.$router.go("beforeCreate", {
mode,
});
} else {
wx.$router.go(
mode ? "createOrderCarQuotationSimple" : "createOrderCarQuotation"
);
}
}
}, 2000),
async checkDaily() {
// 校验是否填写昨日日报
let staffCheck = await checkDailyReport(true);
if (staffCheck) return false;
},
// Set the desired delay (in milliseconds)
// navGo(e) {
// // this.throttle()
// let {
// mode,
// taskId,
// merchantBrand
// } = this.data;
// let {
// item
// } = e.currentTarget.dataset;
// let userInfo = wx.$util.getUserInfo();
// if (item.path) {
// if (item.menuText == "驻店目标") {
// return wx.$router.go(item.path, {
// id: taskId,
// });
// } else {
// if (item.menuText = "培训资料") {
// let params = {
// merchantId: userInfo?.default4SStoreInfo?.merchantId,
// staffUuid: userInfo?.uuid,
// scene: 0,
// taskId: 5,
// };
// commonApi.shutDownTaskApi(params)
// }
// return wx.$router.go(item.path, {
// scene: 0,
// params: item.params || {},
// });
// }
// } else {
// // 工资绩效特殊处理
// if (item.menuText == '工资绩效') {
// return wx.$router.go('packageEquity.collegeScene', {
// reLaunchPath: 'packageEquity.equityPage',
// tabIndex: 0
// })
// }
// if (merchantBrand.findIndex(i => ['鸿蒙智行'].includes(i.name)) != -1) wx.$router.go('beforeCreate', {
// mode
// })
// else wx.$router.go(
// mode ? "createOrderCarQuotationSimple" : "createOrderCarQuotation"
// );
// }
// // console.log(e)
// // const thisPage = wx.$router.getPageInstance()
// // let {item} = e.currentTarget.dataset
// // if (item.isTab) return thisPage.changeTabBar && thisPage.changeTabBar({detail: item?.tabIndex})
// // if (!item.path) wx.$util.showToast('模块暂未开通\r\n敬请期待')
// },
/**获取园区配置 */
async getYqStoreConfig() {
return new Promise(async resolve => {
const {
merchantId: yqMerchantId
} = wx.$util.getUserInfo(), {
data
} = await commonApi.getYqStoreConfig({
yqMerchantId,
});
let {
menuList
} = this.data
//是否配置园区店面档案互通 Y / N
if (data) {
const culeIndex = menuList.findIndex((e) => e.menuText == "客户线索");
if (data.customerExchangeFlag == "Y") {
if (culeIndex == -1)
menuList.push({
menuText: "客户线索",
icon: "customer_clue",
path: "packageEquity.clueList",
default: true,
sortVal: 6
});
// menuList.push({
// menuText: '话术质检',
// icon: 'ai_inspection',
// path: 'packageEquity.aiInspection',
// default: true
// })
this.getCustomerClueRemind();
}
if (data.customerExchangeFlag == "N" && culeIndex != -1)
menuList.splice(culeIndex, 1);
}
this.setData({
// menuList,
});
resolve()
})
},
/**客户线索新增客户提醒 */
async getCustomerClueRemind() {
return new Promise(async resolve => {
const {
sceneType,
shopMerchantId: merchantId
} = wx.$util.getUserInfo(), {
data,
code
} = await commonApi.getCustomerClueRemind({
sceneType,
merchantId: [merchantId],
});
let {
menuList
} = this.data
if (code == 0) {
const index = menuList.findIndex((e) => e.menuText == "客户线索");
this.setData({
[`menuList[${index}].tipsNum`]: data,
});
}
resolve()
})
},
getSelectByMerchantId() {
return new Promise((resolve) => {
const {
default4SStoreInfo: {
merchantId
},
} = wx.$util.getUserInfo();
carLifeApi
.getSelectByMerchantId({
merchantNo: merchantId,
})
.then((res) => {
resolve(res.data);
});
});
},
/**根据手机号查询工牌设备号 */
async getInspectionBadgeCode() {
const {
userInfo
} = this.data;
return new Promise(async resolve => {
// const { phone } = wx.$util.getUserInfo(),
// result = await this.getSelectByMerchantId()
let {
menuList,
newMenuList
} = this.data
// let index = menuList.findIndex((e) => e.menuText == "话术质检");
// if (result) {
// const { data } = await carLifeApi.getInspectionBadgeCode({
// phone,
// });
// if (index == -1) {
// menuList.push({
// menuText: "话术质检",
// icon: "ai_inspection",
// path: "packageEquity.aiInspection",
// default: true,
// params: {
// badgeId: data,
// },
// });
// }
// }
// if (!result && index != -1) menuList.splice(index, 1);
// let index_a = menuList.findIndex((e) => e.menuText == "AI对练");
// if (index_a == -1)
// menuList.push({
// menuText: "AI对练",
// icon: "AIFun-practice-icon",
// path: "packageEquity.ai",
// default: true,
// sortVal: 5
// });
// const { aiPhone } = await setConfigInfo({});
let index_d = menuList.findIndex((e) => e.menuText == "AI趣练");
if (index_d == -1)
menuList.push({
menuText: "AI趣练",
icon: "ai_chat",
path: "packageEquity.start",
default: true,
sortVal: 5
})
this.setData({
menuList,
newMenuList,
});
resolve()
})
},
/**获取门店主营品牌 */
async getMerchantCarBrandList() {
const {
userInfo
} = this.data, {
shopMerchantId
} = userInfo, {
code,
data
} = await carLifeApi.getMerchantCarBrandList([
shopMerchantId,
]);
if (code == 0 && data) {
let merchantBrand = data?.data[0]?.carBrandList || [];
this.setData({
merchantBrand,
});
}
},
// 接待记录筛选
back() {
const thisPage = wx.$router.getPageInstance();
thisPage.setData({
showScreen: false,
show_reception_confirm: false
});
},
showScreenPop() {
let {
isFilterDefeat,
isFilterUpgrade
} = this.data
const thisPage = wx.$router.getPageInstance();
thisPage.setData({
showScreen: true,
showReceptionRendering: true,
show_reception_confirm: true,
isFilterDefeat,
isFilterUpgrade
});
},
// 筛选确认
searchScreen(e) {
let searchForm = e.detail
const orderResult = searchForm?.orderResult || []
this.setData({
isFilterUpgrade: orderResult?.includes(1),
isFilterDefeat: orderResult?.includes(2),
searchForm,
listData: [],
nothing: false
}, () => {
this.getReceptionList()
wx.$track.setTrackData(0, 'staff_reception_search', this.getParams())
})
this.back()
this.getData()
},
// 查看更多接待记录
goPage() {
wx.$router.go('packageEquity.receptionRecords')
wx.$track.setTrackData(0, 'see_more')
},
onHide() {
this.onPageHide()
},
onUnload() {
this.onPageHide()
}
},
});