index.vue
36.8 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
<template>
<div class="dashboard-page">
<!-- 1. 顶部导航栏 -->
<div class="top-header-wrapper">
<HeaderCustom v-model="currentTab"
:show-bottom-border="false"
:tabs="tabs">
</HeaderCustom>
<!-- 日期选择器 -->
<CalendarCustom v-model="timeRangeType"
:date-format="dateFormat"
:date-range.sync="dateRange"
:time-range-options="timeRangeOptions"
@date-range-change="handleDateRangeChange"
@time-range-change="handleTimeRangeChange" />
<div class="border-bottom-line"></div>
</div>
<div class="content-area">
<!-- 2. KPI 核心指标 -->
<div class="top-content">
<div class="kpi-row">
<el-row style="flex-wrap: nowrap;" :gutter="24">
<el-col v-for="(item, index) in kpiList"
:key="index"
:span="12">
<div class="kpi-bg-wrapper">
<div class="kpi-card-content">
<div class="kpi-label">
{{ item.label }}
</div>
<div class="kpi-value">
{{ item.value }}
<span style="font-size: 16px; color: #2A58AD;">{{ item.unit }}</span>
</div>
<div class="kpi-sub">
{{ item.subLabel }} <span :class="item.trendClass">{{ item.subValue }}</span>
</div>
</div>
</div>
</el-col>
</el-row>
</div>
</div>
<!-- 3. 策略类型分布+线上运营分析 -->
<div class="center-content">
<div class="chart-row">
<el-row :gutter="20">
<!-- 左侧:策略类型分布 -->
<el-col :span="12">
<StrategyTypeChart ref="strategyTypeChart"
:operator-filter.sync="strategyTypeOperatorFilter"
:pie-data="strategyTypeData" />
</el-col>
<!-- 右侧:线上运营分布 -->
<el-col :span="12">
<OnlineOperList ref="onlineOperList"
:rank-data="onlineOperData" />
</el-col>
</el-row>
</div>
</div>
<!-- 4. 效果分析表格展示 -->
<div class="bottom-content">
<div class="d2-container-content">
<d2-table-header title="效果分析">
<div class="tool-left">
<!-- 盯防类型 -->
<SelectCustom label="盯防类型"
trigger-icon-type="image"
:options="watchTypeOptions"
:trigger-icon="require('@/assets/strategy/icon-strategy-type.png')"
:value="currentWatchType"
@change="selectWatchType" />
</div>
</d2-table-header>
<d2-table ref="table"
no-data-text="暂无数据"
:before-search-fn="beforeSearchFn"
:get-list-api="getListApi"
:has-page="false"
:no-data-img="noDataImg"
:search-form="searchFormSearch"
:table-params="tableParams">
<!-- 主营品牌 -->
<template #mainBrandsStr="scope">
<div>
<el-tooltip v-if="scope.columnsObj.formatter(scope.scope) && scope.columnsObj.formatter(scope.scope) !== '-' && scope.columnsObj.formatter(scope.scope) !== '、'"
effect="dark"
placement="top">
<template #content>
<div class="tooltip-content-max">
<div>{{ scope.columnsObj.formatter(scope.scope) }}</div>
</div>
</template>
<span class="two-line-ellipsis">{{ scope.columnsObj.formatter(scope.scope) }}</span>
</el-tooltip>
<span v-else>{{ scope.columnsObj.formatter(scope.scope) }}</span>
</div>
</template>
<template #strategyTotalCount="scope">
<div>
<el-tooltip v-if="scope.columnsObj.formatter(scope.scope) && scope.columnsObj.formatter(scope.scope) !== '-' && scope.columnsObj.formatter(scope.scope) !== '、'"
effect="dark"
placement="top">
<template #content>
<div class="tooltip-content-max">
<div v-if="scope.scope.strategyTypeStatisticsResponse && Array.isArray(scope.scope.strategyTypeStatisticsResponse) && scope.scope.strategyTypeStatisticsResponse.length > 0">
<div v-for="(item, index) in scope.scope.strategyTypeStatisticsResponse" :key="index">
{{ item.strategyTypeName }}:{{ item.strategyCount }}
</div>
</div>
<div v-else>
{{ scope.columnsObj.formatter(scope.scope) || '暂无数据' }}
</div>
</div>
</template>
<span class="two-line-ellipsis"
style="color: #2A58AD;cursor: pointer;"
@click="handleViewDetail(scope.scope)">
{{ scope.columnsObj.formatter(scope.scope) }}
</span>
</el-tooltip>
<span v-else
style="color: #2A58AD;cursor: pointer;"
@click="handleViewDetail(scope.scope)">
{{ scope.columnsObj.formatter(scope.scope) }}
</span>
</div>
</template>
<!-- 线上运营 -->
<template #onlineOperator="scope">
<div>
<el-tooltip v-if="scope.columnsObj.formatter(scope.scope) && scope.columnsObj.formatter(scope.scope) !== '-' && scope.columnsObj.formatter(scope.scope) !== '、'"
effect="dark"
placement="top">
<template #content>
<div class="tooltip-content-max">
<div>{{ scope.columnsObj.formatter(scope.scope) }}</div>
</div>
</template>
<span class="two-line-ellipsis">{{ scope.columnsObj.formatter(scope.scope) }}</span>
</el-tooltip>
<span v-else>{{ scope.columnsObj.formatter(scope.scope) }}</span>
</div>
</template>
<!-- 线上运营 -->
<template #areaOperator="scope">
<div>
<el-tooltip v-if="scope.columnsObj.formatter(scope.scope) && scope.columnsObj.formatter(scope.scope) !== '-' && scope.columnsObj.formatter(scope.scope) !== '、'"
effect="dark"
placement="top">
<template #content>
<div class="tooltip-content-max">
<div>{{ scope.columnsObj.formatter(scope.scope) }}</div>
</div>
</template>
<span class="two-line-ellipsis">{{ scope.columnsObj.formatter(scope.scope) }}</span>
</el-tooltip>
<span v-else>{{ scope.columnsObj.formatter(scope.scope) }}</span>
</div>
</template>
<template #flightSupervision="scope">
<div>
<el-tooltip v-if="scope.columnsObj.formatter(scope.scope) && scope.columnsObj.formatter(scope.scope) !== '-' && scope.columnsObj.formatter(scope.scope) !== '、'"
effect="dark"
placement="top">
<template #content>
<div class="tooltip-content-max">
<div>{{ scope.columnsObj.formatter(scope.scope) }}</div>
</div>
</template>
<span class="two-line-ellipsis">{{ scope.columnsObj.formatter(scope.scope) }}</span>
</el-tooltip>
<span v-else>{{ scope.columnsObj.formatter(scope.scope) }}</span>
</div>
</template>
<!-- 效果分析 -->
<template #metrics="scope">
<span class="effect-cell"
@click="handleEffectDetail(scope.scope)">
{{ countImprovedMetrics(scope.scope.metrics) }} <span style="color: #333333;">项提升</span>
</span>
</template>
</d2-table>
</div>
</div>
<div class="bottom-content">
<div class="d2-container-content">
<d2-table-header title="策略明细">
<el-button size="small"
type="primary"
@click="handleExport">
导出
</el-button>
</d2-table-header>
<d2-table ref="table2"
no-data-text="暂无数据"
:before-search-fn="beforeSearchFn"
:get-list-api="getStrategyDetailPageApi"
:no-data-img="noDataImg"
:search-form="searchFormSearch"
:table-params="detailTableParams">
<template #pushFlagName="scope">
<div class="strategy-item-status" :class="[`strategy-item-status-${scope.scope.pushFlag}`]">
{{ scope.scope.pushFlagName }}
</div>
</template>
<template #tooltip="scope">
<el-tooltip v-if="scope.scope[scope.columnsObj.prop] && scope.scope[scope.columnsObj.prop] !== '-'"
effect="dark"
placement="top">
<template #content>
<div class="tooltip-content-max">
<div>{{ scope.scope[scope.columnsObj.prop] }}</div>
</div>
</template>
<span class="two-line-ellipsis">{{ scope.scope[scope.columnsObj.prop] }}</span>
</el-tooltip>
<span v-else>-</span>
</template>
<template #auth-button="scope">
<el-button type="text"
@click="toDetail(scope.scope)">
查看
</el-button>
</template>
</d2-table>
</div>
</div>
</div>
<EffectDetailDialog :row="effectDetailRow"
:search-params="effectSearchParams"
:visible.sync="effectDetailVisible" />
<StrategyDetail :dialogVisible.sync="strategyDetailVisible"
:item="currentItem"
:prop-biz="currentTab.value"
@openReceptionDialog="openReceptionDialog">
</StrategyDetail>
<TaskDetail :item="currentItem" :visibleSync.sync="taskDetailVisible"></TaskDetail>
<QualityDetail v-if="isQualityVisible"
ref="qualityDetail"
:current-num="currentNum"
:is-quality-visible="isQualityVisible"
:quality-detail-list="qualityDetailList"
@closeDialog="closeReceptionDialog">
</QualityDetail>
<NewQualityDetail v-if="isNewQualityVisible"
ref="newQualityDetail"
:current-num="currentNum"
:is-quality-visible="isNewQualityVisible"
:quality-detail-list="qualityDetailList"
@closeDialog="closeReceptionDialog">
</NewQualityDetail>
</div>
</template>
<script>
import dayjs from "dayjs";
import { mapActions, mapState } from "vuex";
import { exportStrategyDetail, getStrategyAnalysisEffect, getStrategyEffectList, getStrategyOnlineDist, getStrategyTotal, getStrategyTypeDist, getWarningTypeList, queryStrategyDetailPage } from "@/api/earlyWarningManager";
import noDataImg from "@/assets/strategy/emepty-strategy.png";
import { deepClone } from "@/common/util";
import StrategyDetail from "@/views/earlyWarningManager/strategyCentre/storeSignboard/components/StrategyDetail/index.vue";
import TaskDetail from "@/views/earlyWarningManager/strategyCentre/storeSignboard/components/taskDetail/index.vue";
import newQualityDetail from "@/views/residentManage/components/newQualityDetail";
import qualityDetail from "@/views/residentManage/components/qualityDetail";
import calendarCustom from "../strategyCentre/compoments/clendarCustom.vue";
import HeaderCustom from "../strategyCentre/compoments/headerCustom.vue";
import SelectCustom from "../strategyCentre/compoments/selectCustom.vue";
import EffectDetailDialog from "./components/EffectDetailDialog.vue";
import OnlineOperList from "./components/OnlineOperList";
import StrategyTypeChart from "./components/StrategyTypeChart/index.vue";
// 盯防类型图标配置(配置化管理,易于扩展)
const WATCH_TYPE_ICON_CONFIG = {
2: {
icon: "el-icon-warning-outline",
iconUrl: require("@/assets/strategy/icon-strategy-type01.png"),
},
3: {
icon: "el-icon-data-line",
iconUrl: require("@/assets/strategy/icon-strategy-type02.png"),
},
4: {
icon: "el-icon-data-line",
iconUrl: require("@/assets/strategy/icon-strategy-type07.png"),
},
5: {
icon: "el-icon-data-line",
iconUrl: require("@/assets/strategy/icon-strategy-type08.png"),
},
// 默认图标配置
default: {
icon: "el-icon-warning-outline",
iconUrl: require("@/assets/strategy/icon-strategy-type01.png"),
},
};
export default {
name: "StrategyAnalysis",
components: {
HeaderCustom,
SelectCustom,
CalendarCustom: calendarCustom,
StrategyTypeChart,
OnlineOperList,
EffectDetailDialog,
TaskDetail,
StrategyDetail,
QualityDetail: qualityDetail,
NewQualityDetail: newQualityDetail,
},
provide() {
return {
GET_PARAMS_INFO: () => "",
GET_MERCHANT_NAME: () => "",
deepClone,
GET_BIZ: () => this.currentTab.value,
};
},
data() {
return {
noDataImg,
currentTab: { label: "延保", value: 1 },
tabs: [
{ label: "延保", value: 1 },
{ label: "权益", value: 3 },
{ label: "轻改", value: 2 },
],
// 时间范围类型
timeRangeType: { label: "月", value: 2 },
timeRangeOptions: [
{ label: "周", value: 1 },
{ label: "月", value: 2 },
{ label: "自定义", value: 4 },
],
// 日期范围
dateRange: {
startDate: null,
endDate: null,
},
dateFormat: "YYYY-MM-DD", // 日期格式化模式
// KPI 指标数据列表
kpiList: [],
// 日期范围(已包含时间后缀,便于统一使用)
startDate: dayjs().startOf("month").format("YYYY-MM-DD") + " 00:00:00",
endDate: dayjs().format("YYYY-MM-DD") + " 23:59:59",
// 加载状态
loading: {
kpiData: false,
strategyTypeData: false,
onlineOperData: false,
},
// 策略类型分布数据
strategyTypeData: [],
// 线上运营分布数据
onlineOperData: [],
// 策略类型分布筛选的运营人员UUID
strategyTypeOperatorFilter: null,
// 存储原始监控类型数据(接口返回的完整数据)
monitorTypeData: [],
// 当前选中的盯防类型
currentWatchType: { label: "", value: null },
// 表格相关数据
searchFormSearch: {},
getListApi: null, // 在 mounted 中初始化
getStrategyDetailPageApi: null,
effectDetailVisible: false,
effectDetailRow: [],
// 策略类型分布运营人员筛选防抖定时器
// eslint-disable-next-line vue/no-reserved-keys
_strategyTypeOperatorTimer: null,
tableParams: {
listName: "data",
tableColumns: [
{
label: "门店名称",
prop: "storeName",
minWidth: 160,
},
{
label: "主营品牌",
prop: "mainBrandsStr",
type: "slot",
minWidth: 100,
addHtml: "mainBrandsStr",
formatter: (cellValue) => {
if (!cellValue.mainBrandsStr) {
return "-";
}
return cellValue.mainBrandsStr;
},
},
{
label: "线上运营",
prop: "onlineOperator",
type: "slot",
minWidth: 80,
addHtml: "onlineOperator",
formatter: (cellValue) => {
if (!cellValue.onlineOperator || !Array.isArray(cellValue.onlineOperator)) {
return "-";
}
return cellValue.onlineOperator
.map(item => item.username)
.filter(username => username)
.join("/") || "-";
},
},
{
label: "区域运营",
prop: "areaOperator",
minWidth: 80,
type: "slot",
addHtml: "areaOperator",
formatter: (cellValue) => {
if (!cellValue.areaOperator || !Array.isArray(cellValue.areaOperator)) {
return "-";
}
return cellValue.areaOperator
.map(item => item.username)
.filter(username => username)
.join("/") || "-";
},
},
{
label: "区域督导",
prop: "flightSupervision",
minWidth: 80,
type: "slot",
addHtml: "flightSupervision",
formatter: (cellValue) => {
if (!cellValue.flightSupervision) {
return "-";
}
return cellValue.flightSupervision
.map(item => item.username)
.filter(username => username)
.join("/") || "-";
},
},
// {
// label: "当期指标",
// prop: "cycleIndicator",
// minWidth: 140,
// type: "slot",
// formatter: (cellValue) => {
// if (cellValue.cycleIndicator == null && cellValue.cycleIndicator == undefined) {
// return "-";
// }
// return `${cellValue.cycleIndicator}${this.currentWatchType.value == 1 ? "%" : ""}`;
// },
// },
{
label: "执行策略总数",
prop: "strategyTotalCount",
minWidth: 80,
type: "slot",
addHtml: "strategyTotalCount",
formatter: (cellValue) => {
if (cellValue.strategyTotalCount === null || cellValue.strategyTotalCount === undefined) {
return "-";
}
return cellValue.strategyTotalCount;
},
},
{
label: "效果分析",
prop: "metrics",
minWidth: 120,
type: "slot",
addHtml: "metrics",
},
],
},
detailTableParams: {
tableOption: {
width: "150",
},
listName: "data",
tableColumns: [
{
label: "门店名称",
prop: "merchantName",
minWidth: 160,
},
{
label: "策略类型",
prop: "strategyTypeName",
minWidth: 160,
},
{
label: "创建人",
prop: "createdBy",
minWidth: 160,
},
{
label: "创建时间",
prop: "createdDate",
minWidth: 160,
},
{
label: "策略目标",
prop: "strategyTarget",
minWidth: 160,
formatter: (cellValue) => {
let businessType = this.currentTab.value;
const { strategyType, strategyTarget } = cellValue;
if (strategyTarget == "-" || strategyTarget == null || strategyTarget == undefined || strategyTarget == "") {
return "-";
}
let text = "";
if (strategyType == 12) {
text = `触客率${strategyTarget}%`;
} else {
if (businessType == 2) {
text = `平均客单价${strategyTarget}`;
} else {
text = `转化率${strategyTarget}%`;
}
}
return text;
},
},
{
label: "策略说明",
prop: "description",
minWidth: 160,
addHtml: "tooltip",
},
{
label: "执行周期",
prop: "executeCycle",
minWidth: 180,
},
{
label: "策略状态",
minWidth: 120,
addHtml: "pushFlagName",
},
{
label: "执行人",
prop: "executePersons",
minWidth: 160,
},
{
label: "完成时间",
prop: "finishTime",
minWidth: 160,
},
{
label: "执行结果",
prop: "executeResult",
minWidth: 160,
},
{
label: "任务描述",
prop: "taskDescription",
minWidth: 160,
addHtml: "tooltip",
},
],
},
currentItem: {},
strategyDetailVisible: false,
taskDetailVisible: false,
isNewQualityVisible: false,
isQualityVisible: false,
qualityDetailList: [],
currentNum: 0,
};
},
computed: {
...mapState({
dowloadList: state => state.d2admin.user.dowloadList,
}),
// 盯防类型选项(自动根据原始数据生成)
watchTypeOptions() {
if (!this.monitorTypeData || this.monitorTypeData.length === 0) {
return [];
}
return this.monitorTypeData.map((item) => {
const iconConfig = WATCH_TYPE_ICON_CONFIG[item.typeCode] || WATCH_TYPE_ICON_CONFIG.default;
return {
label: item.typeName,
value: item.typeCode,
icon: iconConfig.icon,
iconUrl: iconConfig.iconUrl,
};
});
},
effectSearchParams() {
return {
startDate: this.startDate,
endDate: this.endDate,
businessType: this.currentTab.value,
warningType: this.currentWatchType.value || null,
periodType: this.timeRangeType.value,
};
},
},
watch: {
// 监听业务类型变化,重新获取数据
"currentTab.value": function (newValue, oldValue) {
if (newValue !== oldValue && oldValue !== undefined) {
this.fetchStrategyTotal();
this.fetchStrategyTypeDist();
this.fetchStrategyOnlineDist();
// 重置运营人员筛选
this.strategyTypeOperatorFilter = null;
// 切换业务类型后,更新效果分析表格传参并重新请求
this.$nextTick(() => {
this.refreshEffectTable();
});
}
},
// 监听策略类型分布运营人员筛选变化,防抖请求数据
strategyTypeOperatorFilter(newValue, oldValue) {
if (newValue !== oldValue && oldValue !== undefined) {
// 防抖处理,300ms 后执行
if (this._strategyTypeOperatorTimer) {
clearTimeout(this._strategyTypeOperatorTimer);
}
this._strategyTypeOperatorTimer = setTimeout(() => {
this.fetchStrategyTypeDist();
}, 300);
}
},
},
mounted() {
// 初始化包装后的 API 方法
this.getListApi = this.wrapStrategyEffectList;
this.getStrategyDetailPageApi = this.queryStrategyDetailPage;
// 启用页面滚动
this.enablePageScroll();
// 调用策略总数接口
this.fetchStrategyTotal();
// 调用策略类型分布和线上运营分布接口
this.fetchStrategyTypeDist();
this.fetchStrategyOnlineDist();
},
beforeDestroy() {
// 禁用页面滚动
this.disablePageScroll();
// 清理定时器
if (this._strategyTypeOperatorTimer) {
clearTimeout(this._strategyTypeOperatorTimer);
this._strategyTypeOperatorTimer = null;
}
},
methods: {
...mapActions({
get: "d2admin/base/get",
close: "d2admin/page/close",
}),
...mapActions("d2admin/user", ["actionSetDownloadList"]),
/**
* 包装 API 方法,将数组响应转换为 d2-table 期望的对象格式
*/
async wrapStrategyEffectList(params) {
const periodType = params.periodType ?? this.timeRangeType?.value;
// 周、自定义周期不请求效果分析列表
if (periodType === 1 || periodType === 4) {
return {
data: [],
total: 0,
pageNum: params.pageNum || 1,
pageSize: params.pageSize || 1000,
};
}
try {
// const data = await getStrategyEffectList(params);
params.cycleType = params.periodType == 1 ? 2 : params.periodType == 2 ? 3 : params.periodType;
params.startDate = dayjs(this.startDate).format("YYYY-MM-DD");
params.endDate = dayjs(this.endDate).format("YYYY-MM-DD");
params.pageSize = 1000;
const data = await getStrategyAnalysisEffect(params);
// axios 响应拦截器已返回 data 字段的内容(数组)
// 需要包装成 d2-table 期望的格式:{ data: [...], total: number }
return {
data: data.list || [],
total: data.total,
pageNum: data.pageNum,
pageSize: data.pageSize,
};
} catch (error) {
return {
data: [],
total: 0,
pageNum: 1,
pageSize: 1000,
};
}
},
/** 策略分析 */
async queryStrategyDetailPage(params) {
// 周、自定义周期不请求效果分析列表
try {
// const data = await getStrategyEffectList(params);
params.startDate = dayjs(this.startDate).format("YYYY-MM-DD") + " 00:00:00";
params.endDate = dayjs(this.endDate).format("YYYY-MM-DD") + " 23:59:59";
delete params.periodType;
delete params.warningType;
params.pageNum = params.currentPage;
const data = await queryStrategyDetailPage(params);
// axios 响应拦截器已返回 data 字段的内容(数组)
// 需要包装成 d2-table 期望的格式:{ data: [...], total: number }
return {
data: data.list || [],
total: data.total,
pageNum: data.pageNum,
pageSize: data.pageSize,
};
} catch (error) {
return {
data: [],
total: 0,
pageNum: 1,
pageSize: 1000,
};
}
},
/**
* 刷新效果分析表格(beforeSearchFn 会同步 businessType 等参数,再调用 wrapStrategyEffectList)
*/
refreshEffectTable() {
this.$refs.table && this.$refs.table.refreshTable(true, true);
this.$refs.table2 && this.$refs.table2.refreshTable(true, true);
},
/**
* 搜索前处理
*/
async beforeSearchFn(type = 1) {
try {
// 先获取盯防类型列表(若已存在数据则不需要再次调用)
if (!this.monitorTypeData || this.monitorTypeData.length === 0) {
await this.getWatchTypeList();
}
} catch (error) {
}
// 构建搜索参数,即使字段为空也先构建(避免首次加载时参数缺失)
this.searchFormSearch = deepClone({
startDate: this.startDate,
endDate: this.endDate,
businessType: this.currentTab.value,
warningType: this.currentWatchType.value || null,
periodType: this.timeRangeType.value,
});
},
/**
* 启用页面滚动 - 动态添加样式到父容器
*/
enablePageScroll() {
this.$nextTick(() => {
// 查找父容器
const parentContainer = this.$el?.closest(".d2-theme-container-main-body")
|| this.$el?.closest(".container-component");
if (parentContainer) {
// 添加唯一标识类名,避免影响其他页面
parentContainer.classList.add("strategy-analysis-scroll-container");
// 直接设置样式,允许垂直滚动
parentContainer.style.overflowY = "auto";
parentContainer.style.overflowX = "hidden";
parentContainer.style.height = "100%";
}
});
},
/**
* 禁用页面滚动 - 移除样式
*/
disablePageScroll() {
const parentContainer = document.querySelector(".strategy-analysis-scroll-container");
if (parentContainer) {
parentContainer.classList.remove("strategy-analysis-scroll-container");
parentContainer.style.overflowY = "";
parentContainer.style.overflowX = "";
}
},
/**
* 选择盯防类型
*/
selectWatchType(item) {
this.currentWatchType = {
label: item.label,
value: item.value !== undefined ? item.value : item.label,
};
this.$nextTick(() => {
this.refreshEffectTable();
});
},
/**
* 获取盯防类型列表
*/
async getWatchTypeList() {
try {
const res = await getWarningTypeList();
if (res && res.length) {
this.monitorTypeData = res.map(item => ({
typeName: item.warningTypeName,
typeCode: item.warningType,
}));
const first = this.monitorTypeData[0];
this.currentWatchType = {
label: first.typeName,
value: first.typeCode,
};
}
} catch (error) {
}
},
/**
* 获取策略总数(优化版)
*/
async fetchStrategyTotal() {
this.loading.kpiData = true;
try {
const params = {
startDate: this.startDate,
endDate: this.endDate,
businessType: this.currentTab.value,
};
const res = await getStrategyTotal(params);
if (!res) {
return;
}
// 根据接口返回的数据更新 KPI 列表
this.kpiList = [
{
label: "策略总数",
value: res.strategyTotalCount || 0,
unit: "个",
subLabel: "本月策略总数",
subValue: `${res.strategyTotalCountInMonth || 0}个`,
trendClass: "trend-up",
},
{
label: "门店总数",
value: res.merchantTotalCount || 0,
unit: "家",
subLabel: "本月门店总数",
subValue: `${res.merchantTotalCountInMonth || 0}家`,
trendClass: "trend-up",
},
];
} catch (error) {
this.$message.error("获取策略总数失败,请稍后重试");
} finally {
this.loading.kpiData = false;
}
},
/**
* 更新日期范围并刷新数据(公共方法)
*/
_updateDateRangeAndRefresh(dateRange) {
if (!dateRange) {
return;
}
this.dateRange = { ...dateRange };
// 组件已根据 dateFormat 返回格式化后的字符串,直接使用即可
// 保留类型判断以兼容可能的 Date 对象(当 dateFormat 未传递时)
// 统一添加时间后缀,便于所有使用 this.startDate 和 this.endDate 的地方都符合格式
this.startDate = dateRange.startDate
? (typeof dateRange.startDate === "string"
? dateRange.startDate + " 00:00:00"
: dayjs(dateRange.startDate).format("YYYY-MM-DD") + " 00:00:00")
: this.startDate;
this.endDate = dateRange.endDate
? (typeof dateRange.endDate === "string"
? dateRange.endDate + " 23:59:59"
: dayjs(dateRange.endDate).format("YYYY-MM-DD") + " 23:59:59")
: this.endDate;
// 重新获取数据
this.fetchStrategyTotal();
this.fetchStrategyTypeDist();
this.fetchStrategyOnlineDist();
// 刷新表格数据
this.refreshEffectTable();
},
/**
* 处理时间范围类型变化
*/
handleTimeRangeChange(type, dateRange) {
// 更新时间范围类型
if (typeof type === "string") {
const option = this.timeRangeOptions.find(opt => opt.label === type);
if (option) {
this.timeRangeType = { label: option.label, value: option.value };
} else {
console.warn("未找到匹配的时间范围类型:", type);
}
} else if (typeof type === "object" && type !== null) {
this.timeRangeType = type;
}
// 更新日期范围并刷新数据
this._updateDateRangeAndRefresh(dateRange);
},
/**
* 处理日期范围变化
*/
handleDateRangeChange(dateRange) {
console.log("handleDateRangeChange:", dateRange);
this._updateDateRangeAndRefresh(dateRange);
},
/**
* 获取策略类型分布
*/
async fetchStrategyTypeDist() {
this.loading.strategyTypeData = true;
try {
const params = {
startDate: this.startDate,
endDate: this.endDate,
businessType: this.currentTab.value,
uuid: this.strategyTypeOperatorFilter,
};
const res = await getStrategyTypeDist(params);
this.strategyTypeData = res || [];
} catch (error) {
this.$message.error("获取策略类型分布失败,请稍后重试");
this.strategyTypeData = [];
} finally {
this.loading.strategyTypeData = false;
}
},
/**
* 获取线上运营分布
*/
async fetchStrategyOnlineDist() {
this.loading.onlineOperData = true;
try {
const params = {
startDate: this.startDate,
endDate: this.endDate,
businessType: this.currentTab.value,
};
const res = await getStrategyOnlineDist(params);
this.onlineOperData = res || [];
} catch (error) {
this.$message.error("获取线上运营分布失败,请稍后重试");
this.onlineOperData = [];
} finally {
this.loading.onlineOperData = false;
}
},
countImprovedMetrics(metrics) {
if (!Array.isArray(metrics)) {
return 0;
}
return metrics.filter(m => m.improved === true).length;
},
handleEffectDetail(row) {
const metrics = row.metrics;
this.effectDetailRow = Array.isArray(metrics) ? metrics : [];
this.effectDetailVisible = true;
},
handleViewDetail(e) {
// 构建查询参数
const query = {
merchantNo: e.merchantNo,
storeName: e.storeName,
businessType: this.currentTab.value,
};
// 添加时间范围类型
if (this.timeRangeType && this.timeRangeType.value !== undefined) {
query.timeRangeType = this.timeRangeType.value;
}
// 添加日期范围
if (this.dateRange) {
if (this.dateRange.startDate) {
query.startDate = this.dateRange.startDate;
}
if (this.dateRange.endDate) {
query.endDate = this.dateRange.endDate;
}
}
this.$router.push({
path: "/storeSignboard",
query,
});
},
handleExport() {
const params = {
method: "dj.api.smartcarlife.strategy.detail.export",
startDate: dayjs(this.startDate).format("YYYY-MM-DD") + " 00:00:00",
endDate: dayjs(this.endDate).format("YYYY-MM-DD") + " 23:59:59",
businessType: this.currentTab.value,
};
const list = [
...this.dowloadList,
{
name: "策略明细" + Date.now(),
exportParam: JSON.stringify(params),
status: "waiting",
timeid: new Date().getTime(),
},
];
this.actionSetDownloadList({ list, type: "dowloadList" });
},
toDetail(item) {
this.currentItem = item;
if ([8, 9, 10, 11, 12, 13, 14].includes(+item.strategyType)) {
this.taskDetailVisible = true;
} else {
this.strategyDetailVisible = true;
}
},
openReceptionDialog({ list, row, currentNum }) {
this.currentNum = currentNum;
this.qualityDetailList = list;
if (row.checkHistoryFlag == 0) {
this.isNewQualityVisible = true;
} else {
this.isQualityVisible = true;
}
},
closeReceptionDialog() {
if (this.$refs.qualityDetail) {
this.$refs.qualityDetail.onPageHide();
}
if (this.$refs.newQualityDetail) {
this.$refs.newQualityDetail.onPause();
this.$refs.newQualityDetail.onPageHide();
}
this.isQualityVisible = false;
this.isNewQualityVisible = false;
},
},
};
</script>
<style lang="scss" scoped>
$bg-white: #fff;
.dashboard-page {
min-height: 100vh;
padding: 0 19px 20px;
box-sizing: border-box;
height: auto;
overflow: visible;
}
.top-header-wrapper {
display: flex;
align-items: center;
justify-content: space-between;
background-color: #fff;
position: sticky;
top: 0;
z-index: 9;
padding-right: 24px;
}
.border-bottom-line {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
border-bottom: 1px solid #e5e5e5;
}
.content-area {
min-height: 0;
width: 100%;
.top-content {
background-color: $bg-white;
padding: 16px 20px;
}
/* KPI 指标卡 */
.kpi-row {
padding: 10px 14px;
border-radius: 8px;
background: #f2f7ff;
/* 模拟设计图中浅蓝色的背景装饰效果 */
.kpi-bg-wrapper {
background: linear-gradient(180deg, #f0f7ff 0%, #ffffff 100%);
border-radius: 8px;
padding: 1px; /* border effect */
.kpi-card-content {
background: #fff;
border-radius: 8px;
padding: 24px;
text-align: center;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
height: 108px;
.kpi-label {
font-size: 14px;
text-align: left;
margin-bottom: 4px;
color: #666666;
line-height: 20px;
font-weight: Medium;
font-family: "HarmonyOSSansSC";
}
.kpi-value {
font-size: 30px;
color: #2a58ad;
font-weight: bold;
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
}
.kpi-sub {
margin-top: 8px;
color: #333333;
font-size: 14px;
font-weight: Medium;
.trend-up {
color: #2a58ad;
}
}
}
}
}
.center-content {
background-color: #eff3f6;
margin-top: 20px;
border-radius: 4px;
height: 332px;
overflow: hidden;
position: relative;
.chart-row {
.dashboard-card {
background: $bg-white;
border-radius: 4px;
padding: 20px;
padding-right: 28px;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}
}
}
/* 效果分析表格展示 */
.bottom-content {
background-color: $bg-white;
padding: 16px 20px;
margin-top: 20px;
}
}
.tooltip-content-max {
max-height: 320px;
overflow-y: scroll;
}
.two-line-ellipsis {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
line-clamp: 2;
overflow: hidden;
text-overflow: ellipsis;
word-break: break-all;
line-height: 1.5;
padding: 0 10px;
}
.tool-left {
display: flex;
align-items: center;
font-size: 14px;
color: #333333;
line-height: normal; // 重置 line-height,避免受 .table-header 影响
.v-divider {
margin: 0 20px;
color: #e5e6eb;
line-height: normal; // 重置 line-height,避免受 .table-header 影响
}
}
.effect-cell {
color: #2a58ad;
cursor: pointer;
}
::v-deep .emptyBg {
margin-top: 20px;
color: #999ea8;
font-size: 12px;
line-height: 1;
padding-bottom: 10px;
.noDataImg {
width: 86px;
height: 86px;
}
}
.strategy-item-status {
font-size: 14px;
flex-shrink: 0;
padding: 0 6px;
border-radius: 2px;
line-height: 21px;
width: fit-content;
margin: 0 auto;
}
.strategy-item-status-0 {
background: #fdb7571a;
color: #fdb757;
}
.strategy-item-status-1 {
background: #2a82e41a;
color: #2a82e4;
}
.strategy-item-status-2,
.strategy-item-status-7,
.strategy-item-status-9 {
background: #eb4e4e1a;
color: #eb4e4e;
}
.strategy-item-status-6 {
background: #8c8c8c1a;
color: #8c8c8c;
}
.strategy-item-status-8 {
background: #43cf7c1a;
color: #43cf7c;
}
</style>