form7.vue
34 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
<template>
<div class="NCC-common-layout">
<div class="NCC-common-layout-center">
<!-- 筛选条件 -->
<el-row class="NCC-common-search-box" :gutter="16">
<el-form @submit.native.prevent>
<el-col :span="6">
<el-form-item label="开始时间">
<el-date-picker
v-model="query.startTime"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
format="yyyy-MM-dd HH:mm:ss"
placeholder="开始时间"
/>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="结束时间">
<el-date-picker
v-model="query.endTime"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
format="yyyy-MM-dd HH:mm:ss"
placeholder="结束时间"
/>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="组织类型">
<el-select
v-model="query.organizationType"
placeholder="请选择组织类型"
filterable
clearable
@change="handleOrganizationTypeChange"
:style='{"width":"100%"}'>
<el-option label="事业部" value="事业部"></el-option>
<el-option label="科技部" value="科技部"></el-option>
<el-option label="教育部" value="教育部"></el-option>
<el-option label="大项目部" value="大项目部"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="部门">
<el-select
v-model="query.departmentId"
placeholder="请选择部门"
filterable
clearable
@change="handleDepartmentChange"
:style='{"width":"100%"}'>
<el-option
v-for="dept in departmentOptions"
:key="dept.Id || dept.id"
:label="dept.FullName || dept.fullName"
:value="dept.Id || dept.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="门店">
<el-select
v-model="query.storeIds"
placeholder="请选择门店"
multiple
filterable
clearable
:style='{"width":"100%"}'>
<el-option
v-for="store in storeOptions"
:key="store.id"
:label="store.dm"
:value="store.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="search()">查询</el-button>
<el-button icon="el-icon-refresh-right" @click="reset()">重置</el-button>
</el-form-item>
</el-col>
</el-form>
</el-row>
<!-- 统计卡片 -->
<div class="statistics-cards" v-if="summaryData">
<el-row :gutter="12">
<el-col :span="4">
<div class="statistics-card invite-card">
<div class="card-icon">
<i class="el-icon-user-solid"></i>
</div>
<div class="card-content">
<div class="card-title">总邀请数</div>
<div class="card-value">{{ summaryData.totalInviteCount || 0 }}</div>
</div>
</div>
</el-col>
<el-col :span="4">
<div class="statistics-card appointment-card">
<div class="card-icon">
<i class="el-icon-date"></i>
</div>
<div class="card-content">
<div class="card-title">总预约数</div>
<div class="card-value">{{ summaryData.totalAppointmentCount || 0 }}</div>
</div>
</div>
</el-col>
<el-col :span="4">
<div class="statistics-card visit-card">
<div class="card-icon">
<i class="el-icon-location"></i>
</div>
<div class="card-content">
<div class="card-title">总到店人数</div>
<div class="card-value">{{ summaryData.totalVisitCount || 0 }}</div>
</div>
</div>
</el-col>
<el-col :span="4">
<div class="statistics-card billing-card">
<div class="card-icon">
<i class="el-icon-document"></i>
</div>
<div class="card-content">
<div class="card-title">总开单数</div>
<div class="card-value">{{ summaryData.totalBillingCount || 0 }}</div>
</div>
</div>
</el-col>
<el-col :span="4">
<div class="statistics-card billing-amount-card">
<div class="card-icon">
<i class="el-icon-money"></i>
</div>
<div class="card-content">
<div class="card-title">总开单金额</div>
<div class="card-value">¥{{ formatMoney(summaryData.totalBillingAmount) }}</div>
</div>
</div>
</el-col>
<el-col :span="4">
<div class="statistics-card consume-card">
<div class="card-icon">
<i class="el-icon-success"></i>
</div>
<div class="card-content">
<div class="card-title">总消耗金额</div>
<div class="card-value">¥{{ formatMoney(summaryData.totalConsumeAmount) }}</div>
</div>
</div>
</el-col>
</el-row>
<el-row :gutter="12" style="margin-top: 12px;">
<el-col :span="4">
<div class="statistics-card refund-card">
<div class="card-icon">
<i class="el-icon-warning"></i>
</div>
<div class="card-content">
<div class="card-title">总退款金额</div>
<div class="card-value">¥{{ formatMoney(summaryData.totalRefundAmount) }}</div>
</div>
</div>
</el-col>
<el-col :span="4">
<div class="statistics-card performance-card">
<div class="card-icon">
<i class="el-icon-star-on"></i>
</div>
<div class="card-content">
<div class="card-title">总个人业绩</div>
<div class="card-value">¥{{ formatMoney(summaryData.totalPersonalPerformance) }}</div>
</div>
</div>
</el-col>
<el-col :span="4">
<div class="statistics-card headcount-card">
<div class="card-icon">
<i class="el-icon-user"></i>
</div>
<div class="card-content">
<div class="card-title">总人头数</div>
<div class="card-value">{{ formatNumber(summaryData.totalHeadCount) }}</div>
</div>
</div>
</el-col>
<el-col :span="4">
<div class="statistics-card personcount-card">
<div class="card-icon">
<i class="el-icon-s-custom"></i>
</div>
<div class="card-content">
<div class="card-title">总人次</div>
<div class="card-value">{{ formatNumber(summaryData.totalPersonCount) }}</div>
</div>
</div>
</el-col>
<el-col :span="4">
<div class="statistics-card project-card">
<div class="card-icon">
<i class="el-icon-goods"></i>
</div>
<div class="card-content">
<div class="card-title">总项目数</div>
<div class="card-value">{{ summaryData.totalProjectCount || 0 }}</div>
</div>
</div>
</el-col>
<el-col :span="4">
<div class="statistics-card labor-card">
<div class="card-icon">
<i class="el-icon-coin"></i>
</div>
<div class="card-content">
<div class="card-title">总手工费</div>
<div class="card-value">{{ summaryData.totalLaborCost || 0 }}</div>
</div>
</div>
</el-col>
</el-row>
</div>
<!-- 数据表格 -->
<div class="NCC-common-layout-main NCC-flex-main">
<NCC-table
v-loading="listLoading"
:data="list"
has-c
>
<el-table-column prop="employeeName" label="员工姓名" />
<el-table-column prop="storeName" label="门店名称" />
<el-table-column prop="departmentName" label="部门名称" />
<el-table-column prop="goldTriangleName" label="金三角名称" >
<template slot-scope="scope">
{{ scope.row.goldTriangleName || '无' }}
</template>
</el-table-column>
<el-table-column prop="teamPerformanceRatio" label="业绩占比">
<template slot-scope="scope">
{{ formatPercentage(scope.row.teamPerformanceRatio) }}
</template>
</el-table-column>
<el-table-column prop="inviteCount" label="邀请数" >
<template slot-scope="scope">
<span class="clickable-cell" @click="handleInviteClick(scope.row)">
{{ scope.row.inviteCount || 0 }}
</span>
</template>
</el-table-column>
<el-table-column prop="appointmentCount" label="预约数" >
<template slot-scope="scope">
<span class="clickable-cell" @click="handleAppointmentClick(scope.row)">
{{ scope.row.appointmentCount || 0 }}
</span>
</template>
</el-table-column>
<el-table-column prop="到店人数" label="到店人数" >
<template slot-scope="scope">
<span class="clickable-cell" @click="handleVisitClick(scope.row)">
{{ scope.row.visitCount || 0 }}
</span>
</template>
</el-table-column>
<el-table-column prop="billingCount" label="开单数" >
<template slot-scope="scope">
<span class="clickable-cell" @click="handleBillingClick(scope.row)">
{{ scope.row.billingCount || 0 }}
</span>
</template>
</el-table-column>
<el-table-column prop="billingAmount" label="开单金额" >
<template slot-scope="scope">
<span class="clickable-cell amount-value" @click="handleBillingAmountClick(scope.row)">
¥{{ formatMoney(scope.row.billingAmount) }}
</span>
</template>
</el-table-column>
<el-table-column prop="consumeAmount" label="消耗金额" >
<template slot-scope="scope">
<span class="clickable-cell amount-paid" @click="handleConsumeAmountClick(scope.row)">
¥{{ formatMoney(scope.row.consumeAmount) }}
</span>
</template>
</el-table-column>
<el-table-column prop="refundAmount" label="退款金额" >
<template slot-scope="scope">
<span class="clickable-cell amount-paid" @click="handleRefundAmountClick(scope.row)">
¥{{ formatMoney(scope.row.refundAmount) }}
</span>
</template>
</el-table-column>
<el-table-column label="个人业绩" >
<template slot-scope="scope">
<span class="amount-paid">¥{{ formatMoney(scope.row.billingAmount - scope.row.refundAmount) }}</span>
</template>
</el-table-column>
<el-table-column prop="headCount" label="人头数" >
<template slot-scope="scope">
{{ scope.row.headCount || 0 }}
</template>
</el-table-column>
<el-table-column prop="personCount" label="人次" >
<template slot-scope="scope">
{{ scope.row.personCount || 0 }}
</template>
</el-table-column>
<el-table-column prop="projectCount" label="项目数" >
<template slot-scope="scope">
{{ scope.row.projectCount || 0 }}
</template>
</el-table-column>
<el-table-column prop="laborCost" label="手工费" >
<template slot-scope="scope">
{{ scope.row.laborCost || 0 }}
</template>
</el-table-column>
</NCC-table>
<!-- 分页组件 -->
<pagination
v-show="total > 0"
:total="total"
:page.sync="query.currentPage"
:limit.sync="query.pageSize"
@pagination="search"
/>
</div>
</div>
</div>
</template>
<script>
import request from '@/utils/request'
import Pagination from '@/components/Pagination'
export default {
name: 'StoreOverallStatistics',
components: {
Pagination
},
data() {
return {
query: {
organizationType: undefined,
departmentId: undefined,
storeIds: [],
startTime: undefined,
endTime: undefined,
currentPage: 1,
pageSize: 20
},
storeOptions: [],
departmentOptions: [],
list: [],
total: 0,
listLoading: false,
summaryData: null
}
},
created() {
if (sessionStorage.getItem('isshaixuan') === 'false') {
this.setDefaultTimeRange()
} else{
this.restoreQueryParams()
}
this.loadAllStores()
this.search()
},
watch: {
// 监听开始时间变化,重新加载门店列表
'query.startTime'() {
this.$nextTick(() => {
this.initStoreOptions()
})
}
},
methods: {
// 保存筛选条件到 sessionStorage
saveQueryParams() {
try {
const paramsToSave = {
organizationType: this.query.organizationType,
departmentId: this.query.departmentId,
storeIds: this.query.storeIds,
startTime: this.query.startTime,
endTime: this.query.endTime,
currentPage: this.query.currentPage,
pageSize: this.query.pageSize
}
sessionStorage.setItem('form7_query_params', JSON.stringify(paramsToSave))
sessionStorage.setItem('isshaixuan', true)
} catch (err) {
console.error('保存筛选条件失败:', err)
}
},
// 从 sessionStorage 恢复筛选条件
restoreQueryParams() {
try {
const savedParams = sessionStorage.getItem('form7_query_params')
if (savedParams) {
const params = JSON.parse(savedParams)
// 恢复筛选条件
this.query.organizationType = params.organizationType || undefined
this.query.departmentId = params.departmentId || undefined
this.query.storeIds = params.storeIds || []
this.query.startTime = params.startTime || undefined
this.query.endTime = params.endTime || undefined
this.query.currentPage = params.currentPage || 1
this.query.pageSize = params.pageSize || 20
// 如果没有时间范围,设置默认值
if (!this.query.startTime || !this.query.endTime) {
this.setDefaultTimeRange()
}
// 恢复部门选项和门店列表
if (this.query.organizationType) {
this.loadDepartmentOptions()
}
if (this.query.departmentId && this.query.organizationType && this.query.startTime) {
this.$nextTick(() => {
this.initStoreOptions()
})
} else {
this.loadAllStores()
}
sessionStorage.setItem('isshaixuan', false)
} else {
// 没有保存的条件,设置默认时间范围
this.setDefaultTimeRange()
}
} catch (err) {
console.error('恢复筛选条件失败:', err)
// 出错时设置默认时间范围
this.setDefaultTimeRange()
}
},
// 设置默认时间范围(本月1号到现在)
setDefaultTimeRange() {
const now = new Date()
const firstDayOfMonth = new Date(now.getFullYear(), now.getMonth(), 1)
this.query.startTime = this.formatDateTime(firstDayOfMonth.getTime())
this.query.endTime = this.formatDateTime(now.getTime())
// 时间设置后,如果有组织类型和部门,重新加载门店列表
if (this.query.organizationType && this.query.departmentId) {
this.$nextTick(() => {
this.initStoreOptions()
})
}
},
// 加载全部门店(当没有选择部门时)
loadAllStores() {
request({
url: '/api/Extend/LqMdxx',
method: 'GET',
data: {
currentPage: 1,
pageSize: 1000
}
}).then(res => {
this.storeOptions = res.data.list || []
}).catch(err => {
console.error('获取门店列表失败:', err)
this.storeOptions = []
})
},
// 获取部门选项(根据组织类型)
loadDepartmentOptions() {
if (!this.query.organizationType) {
this.departmentOptions = []
return
}
request({
url: '/api/Extend/Organize/GetByName',
method: 'GET',
data: {
organizeName: this.query.organizationType
}
}).then(res => {
this.departmentOptions = res.data || []
// 如果部门ID不在新列表中,清空部门ID
if (this.query.departmentId) {
const exists = this.departmentOptions.some(
dept => (dept.Id || dept.id) === this.query.departmentId
)
if (!exists) {
this.query.departmentId = undefined
this.query.storeIds = []
this.storeOptions = []
}
}
}).catch(() => {
this.departmentOptions = []
})
},
// 初始化门店选项(根据组织类型、部门、年月)
initStoreOptions() {
// 如果没有选择部门,加载全部门店
if (!this.query.departmentId) {
this.loadAllStores()
return
}
// 如果缺少必要参数,不加载门店列表
if (!this.query.organizationType || !this.query.startTime) {
this.storeOptions = []
return
}
// 从开始时间提取年月(格式:YYYYMM)
// startTime 格式为 yyyy-MM-dd HH:mm:ss
const dateStr = this.query.startTime
if (!dateStr) {
this.storeOptions = []
return
}
// 提取年月,格式:YYYYMM
const monthStr = dateStr.substring(0, 4) + dateStr.substring(5, 7)
request({
url: '/api/Extend/lqmdtarget/GetManagedStores',
method: 'POST',
data: {
month: monthStr,
organizationType: this.query.organizationType,
departmentId: this.query.departmentId
}
}).then(res => {
if (res.data && Array.isArray(res.data)) {
// 将返回的数据格式转换为 storeOptions 需要的格式
// 返回格式: [{ StoreId: "...", StoreName: "..." }]
// 需要格式: [{ id: "...", dm: "..." }]
this.storeOptions = res.data.map(store => ({
id: store.StoreId,
dm: store.StoreName
}))
// 默认选中所有获取到的门店
this.query.storeIds = this.storeOptions.map(store => store.id)
} else {
this.storeOptions = []
this.query.storeIds = []
}
}).catch(err => {
console.error('获取门店列表失败:', err)
this.$message({
type: 'error',
message: '获取门店列表失败',
duration: 1500
})
this.storeOptions = []
this.query.storeIds = []
})
},
// 处理组织类型变化
handleOrganizationTypeChange() {
// 清空部门和门店
this.query.departmentId = undefined
this.query.storeIds = []
// 重新加载部门选项
this.loadDepartmentOptions()
// 加载全部门店(因为部门已清空)
this.loadAllStores()
},
// 处理部门变化
handleDepartmentChange() {
// 清空门店选择
this.query.storeIds = []
// 重新加载门店列表(如果有部门则加载部门管理的门店,否则加载全部门店)
this.initStoreOptions()
},
// 查询数据
search() {
this.listLoading = true
// 保存当前筛选条件
// this.saveQueryParams()
const params = {
currentPage: this.query.currentPage,
pageSize: this.query.pageSize
}
if (this.query.storeIds && this.query.storeIds.length > 0) {
params.StoreIds = this.query.storeIds.join(',')
}
if (this.query.departmentId) {
params.DepartmentId = this.query.departmentId
}
if (this.query.startTime) {
params.StartTime = this.query.startTime
}
if (this.query.endTime) {
params.EndTime = this.query.endTime
}
request({
url: '/api/Extend/lqkdkdjlb/get-health-coach-statistics',
method: 'GET',
data: params
}).then(res => {
if (res.data && res.data.list) {
this.list = res.data.list
this.total = (res.data.pagination && res.data.pagination.totalCount) || 0
// 计算汇总数据
this.calculateSummary(res.data.list)
} else {
this.list = []
this.total = 0
this.summaryData = null
}
this.listLoading = false
}).catch(err => {
console.error('查询失败:', err)
this.$message({
type: 'error',
message: '查询失败,请重试',
duration: 1500
})
this.listLoading = false
this.summaryData = null
})
},
// 计算汇总数据
calculateSummary(dataList) {
if (!dataList || dataList.length === 0) {
this.summaryData = null
return
}
const summary = {
totalInviteCount: 0,
totalAppointmentCount: 0,
totalVisitCount: 0,
totalBillingCount: 0,
totalBillingAmount: 0,
totalConsumeAmount: 0,
totalRefundAmount: 0,
totalPersonalPerformance: 0,
totalHeadCount: 0,
totalPersonCount: 0,
totalProjectCount: 0,
totalLaborCost: 0
}
dataList.forEach(item => {
summary.totalInviteCount += Number(item.inviteCount) || 0
summary.totalAppointmentCount += Number(item.appointmentCount) || 0
summary.totalVisitCount += Number(item.visitCount) || 0
summary.totalBillingCount += Number(item.billingCount) || 0
summary.totalBillingAmount += Number(item.billingAmount) || 0
summary.totalConsumeAmount += Number(item.consumeAmount) || 0
summary.totalRefundAmount += Number(item.refundAmount) || 0
summary.totalHeadCount += Number(item.headCount) || 0
summary.totalPersonCount += Number(item.personCount) || 0
summary.totalProjectCount += Number(item.projectCount) || 0
summary.totalLaborCost += Number(item.laborCost) || 0
})
// 计算总个人业绩(开单金额 - 退款金额)
summary.totalPersonalPerformance = summary.totalBillingAmount - summary.totalRefundAmount
this.summaryData = summary
},
// 重置查询条件
reset() {
this.query = {
organizationType: undefined,
departmentId: undefined,
storeIds: [],
startTime: undefined,
endTime: undefined,
currentPage: 1,
pageSize: 20
}
this.setDefaultTimeRange()
this.departmentOptions = []
// 重置后加载全部门店
this.loadAllStores()
// 清除保存的筛选条件
try {
sessionStorage.removeItem('form7_query_params')
} catch (err) {
console.error('清除保存的筛选条件失败:', err)
}
this.list = []
this.total = 0
this.summaryData = null
this.search()
},
// 格式化金额
formatMoney(amount) {
if (!amount && amount !== 0) return '0.00'
return Number(amount).toFixed(2)
},
// 格式化数字,保留两位小数
formatNumber(num) {
if (num === null || num === undefined || num === '') return '0.00'
const value = Number(num)
if (isNaN(value)) return '0.00'
return value.toFixed(2)
},
// 格式化百分比
formatPercentage(ratio) {
if (ratio === null || ratio === undefined) return '0.00%'
return `${Number(ratio).toFixed(2)}%`
},
// 格式化日期时间(用于API传参)
formatDateTime(timestamp) {
if (!timestamp) return ''
const date = new Date(timestamp)
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
const hours = String(date.getHours()).padStart(2, '0')
const minutes = String(date.getMinutes()).padStart(2, '0')
const seconds = String(date.getSeconds()).padStart(2, '0')
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
},
// 将时间字符串转换为时间戳(毫秒)
getTimestamp(timeStr) {
if (!timeStr) return ''
// 手动解析 yyyy-MM-dd HH:mm:ss 格式,避免时区问题
const parts = timeStr.match(/(\d{4})-(\d{2})-(\d{2})\s+(\d{2}):(\d{2}):(\d{2})/)
if (!parts) {
// 如果格式不匹配,尝试使用 Date 解析
return new Date(timeStr).getTime()
}
// 创建本地时间的 Date 对象
const year = parseInt(parts[1], 10)
const month = parseInt(parts[2], 10) - 1 // 月份从0开始
const day = parseInt(parts[3], 10)
const hours = parseInt(parts[4], 10)
const minutes = parseInt(parts[5], 10)
const seconds = parseInt(parts[6], 10)
return new Date(year, month, day, hours, minutes, seconds).getTime()
},
// 处理邀请数点击事件
handleInviteClick(row) {
if (row && row.employeeId) {
this.saveQueryParams()
this.$router.push({
path: '/lqYaoyjl',
query: {
employeeId: row.employeeId,
storeId: row.storeId || '',
startTime: this.getTimestamp(this.query.startTime),
endTime: this.getTimestamp(this.query.endTime),
}
})
} else {
this.$message({
type: 'warning',
message: '无法获取健康师ID',
duration: 1500
})
}
},
// 处理预约数点击事件
handleAppointmentClick(row) {
if (row && row.employeeId) {
this.saveQueryParams()
this.$router.push({
path: '/lqYyjl',
query: {
employeeId: row.employeeId,
storeId: row.storeId || '',
startTime: this.getTimestamp(this.query.startTime),
endTime: this.getTimestamp(this.query.endTime),
}
})
} else {
this.$message({
type: 'warning',
message: '无法获取健康师ID',
duration: 1500
})
}
},
// 处理到店人数点击事件
handleVisitClick(row) {
if (row && row.employeeId) {
this.saveQueryParams()
this.$router.push({
path: '/lqYyjl',
query: {
employeeId: row.employeeId,
storeId: row.storeId || '',
startTime: this.getTimestamp(this.query.startTime),
endTime: this.getTimestamp(this.query.endTime),
type:'已确认'
}
})
} else {
this.$message({
type: 'warning',
message: '无法获取健康师ID',
duration: 1500
})
}
},
// 处理开单数点击事件
handleBillingClick(row) {
if (row && row.employeeId) {
this.saveQueryParams()
this.$router.push({
path: '/lqKdKdjlb',
query: {
jksId: row.employeeId,
storeId: row.storeId || '',
startTime: this.getTimestamp(this.query.startTime),
endTime: this.getTimestamp(this.query.endTime),
}
})
} else {
this.$message({
type: 'warning',
message: '无法获取健康师ID',
duration: 1500
})
}
},
// 处理开单金额点击事件
handleBillingAmountClick(row) {
if (row && row.employeeId) {
this.saveQueryParams()
this.$router.push({
path: '/lqKdKdjlb',
query: {
jksId: row.employeeId,
storeId: row.storeId || '',
startTime: this.getTimestamp(this.query.startTime),
endTime: this.getTimestamp(this.query.endTime),
}
})
} else {
this.$message({
type: 'warning',
message: '无法获取健康师ID',
duration: 1500
})
}
},
// 处理消耗金额点击事件
handleConsumeAmountClick(row) {
if (row && row.employeeId) {
this.saveQueryParams()
this.$router.push({
path: '/lqXhHyhk',
query: {
jksId: row.employeeId,
storeId: row.storeId || '',
startTime: this.getTimestamp(this.query.startTime),
endTime: this.getTimestamp(this.query.endTime),
}
})
} else {
this.$message({
type: 'warning',
message: '无法获取健康师ID',
duration: 1500
})
}
},
// 处理退款金额点击事件
handleRefundAmountClick(row) {
if (row && row.employeeId) {
this.saveQueryParams()
this.$router.push({
path: '/lqHytkHytk',
query: {
jksId: row.employeeId,
storeId: row.storeId || '',
startTime: this.getTimestamp(this.query.startTime),
endTime: this.getTimestamp(this.query.endTime),
}
})
} else {
this.$message({
type: 'warning',
message: '无法获取健康师ID',
duration: 1500
})
}
}
}
}
</script>
<style lang="scss" scoped>
.statistics-cards {
margin-bottom: 16px;
}
.statistics-card {
height: 72px;
padding: 10px;
border-radius: 8px;
background: #fff;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
display: flex;
align-items: center;
transition: all 0.2s ease;
cursor: default;
&:hover {
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
.card-icon {
width: 44px;
height: 44px;
border-radius: 6px;
display: flex;
align-items: center;
justify-content: center;
margin-right: 10px;
flex-shrink: 0;
i {
font-size: 20px;
color: #fff;
}
}
// 不同卡片的图标颜色
&.invite-card .card-icon {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
&.appointment-card .card-icon {
background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}
&.visit-card .card-icon {
background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}
&.billing-card .card-icon {
background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}
&.billing-amount-card .card-icon {
background: linear-gradient(135deg, #409EFF 0%, #66B1FF 100%);
}
&.consume-card .card-icon {
background: linear-gradient(135deg, #67C23A 0%, #85ce61 100%);
}
&.refund-card .card-icon {
background: linear-gradient(135deg, #F56C6C 0%, #f78989 100%);
}
&.performance-card .card-icon {
background: linear-gradient(135deg, #E6A23C 0%, #ebb563 100%);
}
&.headcount-card .card-icon {
background: linear-gradient(135deg, #909399 0%, #a6a9ad 100%);
}
&.personcount-card .card-icon {
background: linear-gradient(135deg, #606266 0%, #787c82 100%);
}
&.project-card .card-icon {
background: linear-gradient(135deg, #409EFF 0%, #66B1FF 100%);
}
&.labor-card .card-icon {
background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}
.card-content {
flex: 1;
min-width: 0;
.card-title {
font-size: 12px;
color: #909399;
margin-bottom: 4px;
line-height: 1.2;
}
.card-value {
font-size: 18px;
font-weight: bold;
color: #303133;
line-height: 1.2;
word-break: break-all;
}
}
}
// 表格区域样式
.NCC-common-layout-main {
::v-deep .el-table {
.el-table__header {
th {
background-color: #f5f7fa;
color: #606266;
font-weight: 600;
}
}
.el-table__body {
tr:hover > td {
background-color: #f5f7fa;
}
}
}
}
.amount-value {
color: #409EFF;
font-weight: 500;
}
.amount-paid {
color: #67C23A;
font-weight: 500;
}
.clickable-cell {
color: #409EFF;
cursor: pointer;
text-decoration: none;
transition: color 0.2s ease;
&:hover {
color: #66b1ff;
text-decoration: underline;
}
&:active {
color: #3a8ee6;
}
}
// 搜索框区域样式
.NCC-common-search-box {
.el-form-item {
margin-bottom: 18px;
.el-form-item__label {
font-weight: 500;
color: #606266;
}
}
.el-button {
transition: all 0.2s ease;
&:hover {
transform: translateY(-1px);
}
}
}
// 响应式设计
@media (max-width: 768px) {
.statistics-cards {
.el-col {
margin-bottom: 16px;
}
}
.statistics-card {
height: 80px;
padding: 8px;
.card-icon {
width: 50px;
height: 50px;
margin-right: 12px;
i {
font-size: 20px;
}
}
.card-content {
.card-title {
font-size: 12px;
}
.card-value {
font-size: 18px;
}
}
}
}
</style>