Blame view

antis-ncc-admin/src/views/statisticsList/form7.vue 34 KB
9661fd47   李宇   ```
1
2
3
4
5
6
7
  <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">
9661fd47   李宇   ```
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
              <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">
ffd6aaca   李宇   最新
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
              <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">
9661fd47   李宇   ```
82
83
84
85
86
87
88
89
              <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>
  
18ca819c   李宇   最新
90
91
        <!-- 统计卡片 -->
        <div class="statistics-cards" v-if="summaryData">
8479baab   “wangming”   优化统计卡片样式和布局,调整卡片间...
92
93
94
          <el-row :gutter="12">
            <el-col :span="4">
              <div class="statistics-card invite-card">
18ca819c   李宇   最新
95
96
97
98
99
100
101
102
103
                <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>
8479baab   “wangming”   优化统计卡片样式和布局,调整卡片间...
104
105
            <el-col :span="4">
              <div class="statistics-card appointment-card">
18ca819c   李宇   最新
106
107
108
109
110
111
112
113
114
                <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>
8479baab   “wangming”   优化统计卡片样式和布局,调整卡片间...
115
116
            <el-col :span="4">
              <div class="statistics-card visit-card">
18ca819c   李宇   最新
117
118
119
120
121
122
123
124
125
                <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>
8479baab   “wangming”   优化统计卡片样式和布局,调整卡片间...
126
127
            <el-col :span="4">
              <div class="statistics-card billing-card">
18ca819c   李宇   最新
128
129
130
131
132
133
134
135
136
                <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>
8479baab   “wangming”   优化统计卡片样式和布局,调整卡片间...
137
138
            <el-col :span="4">
              <div class="statistics-card billing-amount-card">
18ca819c   李宇   最新
139
140
141
142
143
144
145
146
147
                <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>
8479baab   “wangming”   优化统计卡片样式和布局,调整卡片间...
148
149
            <el-col :span="4">
              <div class="statistics-card consume-card">
18ca819c   李宇   最新
150
151
152
153
154
155
156
157
158
                <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>
8479baab   “wangming”   优化统计卡片样式和布局,调整卡片间...
159
160
161
162
          </el-row>
          <el-row :gutter="12" style="margin-top: 12px;">
            <el-col :span="4">
              <div class="statistics-card refund-card">
18ca819c   李宇   最新
163
164
165
166
167
168
169
170
171
                <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>
8479baab   “wangming”   优化统计卡片样式和布局,调整卡片间...
172
173
            <el-col :span="4">
              <div class="statistics-card performance-card">
18ca819c   李宇   最新
174
175
176
177
178
179
180
181
182
                <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>
8479baab   “wangming”   优化统计卡片样式和布局,调整卡片间...
183
184
            <el-col :span="4">
              <div class="statistics-card headcount-card">
18ca819c   李宇   最新
185
186
187
188
189
                <div class="card-icon">
                  <i class="el-icon-user"></i>
                </div>
                <div class="card-content">
                  <div class="card-title">总人头数</div>
ffd6aaca   李宇   最新
190
                  <div class="card-value">{{ formatNumber(summaryData.totalHeadCount) }}</div>
18ca819c   李宇   最新
191
192
193
                </div>
              </div>
            </el-col>
8479baab   “wangming”   优化统计卡片样式和布局,调整卡片间...
194
195
            <el-col :span="4">
              <div class="statistics-card personcount-card">
18ca819c   李宇   最新
196
197
198
199
200
                <div class="card-icon">
                  <i class="el-icon-s-custom"></i>
                </div>
                <div class="card-content">
                  <div class="card-title">总人次</div>
ffd6aaca   李宇   最新
201
                  <div class="card-value">{{ formatNumber(summaryData.totalPersonCount) }}</div>
18ca819c   李宇   最新
202
203
204
                </div>
              </div>
            </el-col>
8479baab   “wangming”   优化统计卡片样式和布局,调整卡片间...
205
206
            <el-col :span="4">
              <div class="statistics-card project-card">
18ca819c   李宇   最新
207
208
209
210
211
212
213
214
215
                <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>
8479baab   “wangming”   优化统计卡片样式和布局,调整卡片间...
216
217
            <el-col :span="4">
              <div class="statistics-card labor-card">
18ca819c   李宇   最新
218
219
220
221
222
223
224
225
226
227
228
229
                <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>
  
9661fd47   李宇   ```
230
231
        <!-- 数据表格 -->
        <div class="NCC-common-layout-main NCC-flex-main">
1b4e76c0   李宇   ```
232
233
234
235
          <NCC-table 
            v-loading="listLoading" 
            :data="list" 
            has-c
1b4e76c0   李宇   ```
236
          >
9661fd47   李宇   ```
237
238
239
            <el-table-column prop="employeeName" label="员工姓名"  />
            <el-table-column prop="storeName" label="门店名称"  />
            <el-table-column prop="departmentName" label="部门名称"  />
18ca819c   李宇   最新
240
241
242
243
244
245
246
247
248
249
            <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>
9661fd47   李宇   ```
250
251
            <el-table-column prop="inviteCount" label="邀请数"  >
              <template slot-scope="scope">
0d5e5446   李宇   ```
252
253
254
                <span class="clickable-cell" @click="handleInviteClick(scope.row)">
                  {{ scope.row.inviteCount || 0 }}
                </span>
9661fd47   李宇   ```
255
256
257
258
              </template>
            </el-table-column>
            <el-table-column prop="appointmentCount" label="预约数"  >
              <template slot-scope="scope">
0d5e5446   李宇   ```
259
260
261
                <span class="clickable-cell" @click="handleAppointmentClick(scope.row)">
                  {{ scope.row.appointmentCount || 0 }}
                </span>
9661fd47   李宇   ```
262
263
              </template>
            </el-table-column>
0d5e5446   李宇   ```
264
            <el-table-column prop="到店人数" label="到店人数"  >
9661fd47   李宇   ```
265
              <template slot-scope="scope">
0d5e5446   李宇   ```
266
267
268
                <span class="clickable-cell" @click="handleVisitClick(scope.row)">
                  {{ scope.row.visitCount || 0 }}
                </span>
9661fd47   李宇   ```
269
270
271
272
              </template>
            </el-table-column>
            <el-table-column prop="billingCount" label="开单数"  >
              <template slot-scope="scope">
0d5e5446   李宇   ```
273
274
275
                <span class="clickable-cell" @click="handleBillingClick(scope.row)">
                  {{ scope.row.billingCount || 0 }}
                </span>
9661fd47   李宇   ```
276
277
278
279
              </template>
            </el-table-column>
            <el-table-column prop="billingAmount" label="开单金额"  >
              <template slot-scope="scope">
b1146e00   李宇   最新
280
281
282
                <span class="clickable-cell amount-value" @click="handleBillingAmountClick(scope.row)">
                  ¥{{ formatMoney(scope.row.billingAmount) }}
                </span>
9661fd47   李宇   ```
283
284
285
286
              </template>
            </el-table-column>
            <el-table-column prop="consumeAmount" label="消耗金额"  >
              <template slot-scope="scope">
b1146e00   李宇   最新
287
288
289
                <span class="clickable-cell amount-paid" @click="handleConsumeAmountClick(scope.row)">
                  ¥{{ formatMoney(scope.row.consumeAmount) }}
                </span>
9661fd47   李宇   ```
290
291
              </template>
            </el-table-column>
86ade5ce   李宇   报表
292
293
            <el-table-column prop="refundAmount" label="退款金额"  >
              <template slot-scope="scope">
b1146e00   李宇   最新
294
295
296
                <span class="clickable-cell amount-paid" @click="handleRefundAmountClick(scope.row)">
                  ¥{{ formatMoney(scope.row.refundAmount) }}
                </span>
86ade5ce   李宇   报表
297
298
299
300
301
302
303
              </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>
9661fd47   李宇   ```
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
            <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>
ad3658d9   李宇   ```
319
320
321
322
323
            <el-table-column prop="laborCost" label="手工费"  >
              <template slot-scope="scope">
                {{ scope.row.laborCost || 0 }}
              </template>
            </el-table-column>
9661fd47   李宇   ```
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
          </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: {
ffd6aaca   李宇   最新
351
          organizationType: undefined,
9661fd47   李宇   ```
352
          departmentId: undefined,
ffd6aaca   李宇   最新
353
          storeIds: [],
9661fd47   李宇   ```
354
355
356
357
358
359
360
361
362
          startTime: undefined,
          endTime: undefined,
          currentPage: 1,
          pageSize: 20
        },
        storeOptions: [],
        departmentOptions: [],
        list: [],
        total: 0,
18ca819c   李宇   最新
363
364
        listLoading: false,
        summaryData: null
9661fd47   李宇   ```
365
366
367
      }
    },
    created() {
86ade5ce   李宇   报表
368
369
370
371
372
373
  
      if (sessionStorage.getItem('isshaixuan') === 'false') {
        this.setDefaultTimeRange()
      } else{
        this.restoreQueryParams()
      }
ffd6aaca   李宇   最新
374
      this.loadAllStores()
9661fd47   李宇   ```
375
376
      this.search()
    },
ffd6aaca   李宇   最新
377
378
379
380
381
382
383
384
    watch: {
      // 监听开始时间变化,重新加载门店列表
      'query.startTime'() {
        this.$nextTick(() => {
          this.initStoreOptions()
        })
      }
    },
9661fd47   李宇   ```
385
    methods: {
86ade5ce   李宇   报表
386
387
388
389
      // 保存筛选条件到 sessionStorage
      saveQueryParams() {
        try {
          const paramsToSave = {
ffd6aaca   李宇   最新
390
            organizationType: this.query.organizationType,
86ade5ce   李宇   报表
391
            departmentId: this.query.departmentId,
ffd6aaca   李宇   最新
392
            storeIds: this.query.storeIds,
86ade5ce   李宇   报表
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
            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)
            // 恢复筛选条件
ffd6aaca   李宇   最新
412
            this.query.organizationType = params.organizationType || undefined
86ade5ce   李宇   报表
413
            this.query.departmentId = params.departmentId || undefined
ffd6aaca   李宇   最新
414
            this.query.storeIds = params.storeIds || []
86ade5ce   李宇   报表
415
416
417
418
419
420
421
422
423
            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()
            }
ffd6aaca   李宇   最新
424
425
426
427
428
429
430
431
432
433
434
435
436
            
            // 恢复部门选项和门店列表
            if (this.query.organizationType) {
              this.loadDepartmentOptions()
            }
            if (this.query.departmentId && this.query.organizationType && this.query.startTime) {
              this.$nextTick(() => {
                this.initStoreOptions()
              })
            } else {
              this.loadAllStores()
            }
            
86ade5ce   李宇   报表
437
438
439
440
441
442
443
444
445
446
447
448
            sessionStorage.setItem('isshaixuan', false)
          } else {
            // 没有保存的条件,设置默认时间范围
            this.setDefaultTimeRange()
          }
        } catch (err) {
          console.error('恢复筛选条件失败:', err)
          // 出错时设置默认时间范围
          this.setDefaultTimeRange()
        }
      },
  
9661fd47   李宇   ```
449
450
451
452
453
454
455
      // 设置默认时间范围(本月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())
ffd6aaca   李宇   最新
456
457
458
459
460
461
462
        
        // 时间设置后,如果有组织类型和部门,重新加载门店列表
        if (this.query.organizationType && this.query.departmentId) {
          this.$nextTick(() => {
            this.initStoreOptions()
          })
        }
9661fd47   李宇   ```
463
464
      },
  
ffd6aaca   李宇   最新
465
466
      // 加载全部门店(当没有选择部门时)
      loadAllStores() {
9661fd47   李宇   ```
467
468
469
470
471
472
473
474
475
476
477
        request({
          url: '/api/Extend/LqMdxx',
          method: 'GET',
          data: {
            currentPage: 1,
            pageSize: 1000
          }
        }).then(res => {
          this.storeOptions = res.data.list || []
        }).catch(err => {
          console.error('获取门店列表失败:', err)
ffd6aaca   李宇   最新
478
          this.storeOptions = []
9661fd47   李宇   ```
479
480
481
        })
      },
  
ffd6aaca   李宇   最新
482
483
484
485
486
487
488
      // 获取部门选项(根据组织类型)
      loadDepartmentOptions() {
        if (!this.query.organizationType) {
          this.departmentOptions = []
          return
        }
        
9661fd47   李宇   ```
489
        request({
ffd6aaca   李宇   最新
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
          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
          }
9661fd47   李宇   ```
546
        }).then(res => {
ffd6aaca   李宇   最新
547
548
549
550
551
552
553
554
555
556
557
558
559
560
          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 = []
          }
9661fd47   李宇   ```
561
        }).catch(err => {
ffd6aaca   李宇   最新
562
563
564
565
566
567
568
569
          console.error('获取门店列表失败:', err)
          this.$message({
            type: 'error',
            message: '获取门店列表失败',
            duration: 1500
          })
          this.storeOptions = []
          this.query.storeIds = []
9661fd47   李宇   ```
570
571
572
        })
      },
  
ffd6aaca   李宇   最新
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
      // 处理组织类型变化
      handleOrganizationTypeChange() {
        // 清空部门和门店
        this.query.departmentId = undefined
        this.query.storeIds = []
        // 重新加载部门选项
        this.loadDepartmentOptions()
        // 加载全部门店(因为部门已清空)
        this.loadAllStores()
      },
  
      // 处理部门变化
      handleDepartmentChange() {
        // 清空门店选择
        this.query.storeIds = []
        // 重新加载门店列表(如果有部门则加载部门管理的门店,否则加载全部门店)
        this.initStoreOptions()
      },
  
9661fd47   李宇   ```
592
593
594
595
596
  
  
      // 查询数据
      search() {
        this.listLoading = true
86ade5ce   李宇   报表
597
598
        // 保存当前筛选条件
        // this.saveQueryParams()
9661fd47   李宇   ```
599
600
601
602
603
604
  
        const params = {
          currentPage: this.query.currentPage,
          pageSize: this.query.pageSize
        }
  
ffd6aaca   李宇   最新
605
        if (this.query.storeIds && this.query.storeIds.length > 0) {
f7aed489   李宇   最新
606
          params.StoreIds = this.query.storeIds.join(',')
9661fd47   李宇   ```
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
        }
  
        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
86ade5ce   李宇   报表
628
            this.total = (res.data.pagination && res.data.pagination.totalCount) || 0
18ca819c   李宇   最新
629
630
            // 计算汇总数据
            this.calculateSummary(res.data.list)
9661fd47   李宇   ```
631
632
633
          } else {
            this.list = []
            this.total = 0
18ca819c   李宇   最新
634
            this.summaryData = null
9661fd47   李宇   ```
635
636
637
638
639
640
641
642
643
644
          }
          this.listLoading = false
        }).catch(err => {
          console.error('查询失败:', err)
          this.$message({
            type: 'error',
            message: '查询失败,请重试',
            duration: 1500
          })
          this.listLoading = false
18ca819c   李宇   最新
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
          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
9661fd47   李宇   ```
683
        })
18ca819c   李宇   最新
684
685
686
687
688
  
        // 计算总个人业绩(开单金额 - 退款金额)
        summary.totalPersonalPerformance = summary.totalBillingAmount - summary.totalRefundAmount
  
        this.summaryData = summary
9661fd47   李宇   ```
689
690
691
692
693
      },
  
      // 重置查询条件
      reset() {
        this.query = {
ffd6aaca   李宇   最新
694
          organizationType: undefined,
9661fd47   李宇   ```
695
          departmentId: undefined,
ffd6aaca   李宇   最新
696
          storeIds: [],
9661fd47   李宇   ```
697
698
699
700
701
702
          startTime: undefined,
          endTime: undefined,
          currentPage: 1,
          pageSize: 20
        }
        this.setDefaultTimeRange()
ffd6aaca   李宇   最新
703
704
705
        this.departmentOptions = []
        // 重置后加载全部门店
        this.loadAllStores()
86ade5ce   李宇   报表
706
707
708
709
710
711
        // 清除保存的筛选条件
        try {
          sessionStorage.removeItem('form7_query_params')
        } catch (err) {
          console.error('清除保存的筛选条件失败:', err)
        }
9661fd47   李宇   ```
712
713
        this.list = []
        this.total = 0
18ca819c   李宇   最新
714
        this.summaryData = null
9661fd47   李宇   ```
715
716
717
718
719
720
721
722
723
        this.search()
      },
  
      // 格式化金额
      formatMoney(amount) {
        if (!amount && amount !== 0) return '0.00'
        return Number(amount).toFixed(2)
      },
  
ffd6aaca   李宇   最新
724
725
726
727
728
729
730
731
      // 格式化数字,保留两位小数
      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)
      },
  
18ca819c   李宇   最新
732
733
734
735
736
737
      // 格式化百分比
      formatPercentage(ratio) {
        if (ratio === null || ratio === undefined) return '0.00%'
        return `${Number(ratio).toFixed(2)}%`
      },
  
9661fd47   李宇   ```
738
739
740
741
742
743
744
745
746
747
748
      // 格式化日期时间(用于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}`
0d5e5446   李宇   ```
749
750
751
752
753
      },
  
      // 将时间字符串转换为时间戳(毫秒)
      getTimestamp(timeStr) {
        if (!timeStr) return ''
1b4e76c0   李宇   ```
754
755
756
757
758
759
760
761
762
763
764
765
766
767
        // 手动解析 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()
0d5e5446   李宇   ```
768
769
770
771
772
      },
  
      // 处理邀请数点击事件
      handleInviteClick(row) {
        if (row && row.employeeId) {
86ade5ce   李宇   报表
773
          this.saveQueryParams()
0d5e5446   李宇   ```
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
          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) {
86ade5ce   李宇   报表
795
          this.saveQueryParams()
0d5e5446   李宇   ```
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
          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) {
86ade5ce   李宇   报表
817
          this.saveQueryParams()
0d5e5446   李宇   ```
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
          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) {
86ade5ce   李宇   报表
840
          this.saveQueryParams()
0d5e5446   李宇   ```
841
842
843
          this.$router.push({
            path: '/lqKdKdjlb',
            query: {
b1146e00   李宇   最新
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
              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,
0d5e5446   李宇   ```
911
912
913
914
915
916
917
918
919
920
921
922
              storeId: row.storeId || '',
              startTime: this.getTimestamp(this.query.startTime),
              endTime: this.getTimestamp(this.query.endTime),
            }
          })
        } else {
          this.$message({
            type: 'warning',
            message: '无法获取健康师ID',
            duration: 1500
          })
        }
9661fd47   李宇   ```
923
924
925
926
927
928
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
18ca819c   李宇   最新
929
  .statistics-cards {
8479baab   “wangming”   优化统计卡片样式和布局,调整卡片间...
930
    margin-bottom: 16px;
18ca819c   李宇   最新
931
932
933
  }
  
  .statistics-card {
8479baab   “wangming”   优化统计卡片样式和布局,调整卡片间...
934
935
936
    height: 72px;
    padding: 10px;
    border-radius: 8px;
18ca819c   李宇   最新
937
    background: #fff;
8479baab   “wangming”   优化统计卡片样式和布局,调整卡片间...
938
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
18ca819c   李宇   最新
939
940
    display: flex;
    align-items: center;
8479baab   “wangming”   优化统计卡片样式和布局,调整卡片间...
941
942
943
944
945
946
947
    transition: all 0.2s ease;
    cursor: default;
    
    &:hover {
      transform: translateY(-1px);
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    }
18ca819c   李宇   最新
948
949
    
    .card-icon {
8479baab   “wangming”   优化统计卡片样式和布局,调整卡片间...
950
951
952
      width: 44px;
      height: 44px;
      border-radius: 6px;
18ca819c   李宇   最新
953
954
955
      display: flex;
      align-items: center;
      justify-content: center;
8479baab   “wangming”   优化统计卡片样式和布局,调整卡片间...
956
957
      margin-right: 10px;
      flex-shrink: 0;
18ca819c   李宇   最新
958
959
      
      i {
8479baab   “wangming”   优化统计卡片样式和布局,调整卡片间...
960
        font-size: 20px;
18ca819c   李宇   最新
961
962
963
964
        color: #fff;
      }
    }
    
8479baab   “wangming”   优化统计卡片样式和布局,调整卡片间...
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
    // 不同卡片的图标颜色
    &.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%);
    }
    
18ca819c   李宇   最新
1014
1015
    .card-content {
      flex: 1;
8479baab   “wangming”   优化统计卡片样式和布局,调整卡片间...
1016
      min-width: 0;
18ca819c   李宇   最新
1017
1018
      
      .card-title {
8479baab   “wangming”   优化统计卡片样式和布局,调整卡片间...
1019
        font-size: 12px;
18ca819c   李宇   最新
1020
        color: #909399;
8479baab   “wangming”   优化统计卡片样式和布局,调整卡片间...
1021
1022
        margin-bottom: 4px;
        line-height: 1.2;
18ca819c   李宇   最新
1023
1024
1025
      }
      
      .card-value {
8479baab   “wangming”   优化统计卡片样式和布局,调整卡片间...
1026
        font-size: 18px;
18ca819c   李宇   最新
1027
1028
        font-weight: bold;
        color: #303133;
8479baab   “wangming”   优化统计卡片样式和布局,调整卡片间...
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
        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;
        }
18ca819c   李宇   最新
1050
1051
1052
1053
      }
    }
  }
  
9661fd47   李宇   ```
1054
1055
1056
1057
1058
1059
1060
1061
1062
  .amount-value {
    color: #409EFF;
    font-weight: 500;
  }
  
  .amount-paid {
    color: #67C23A;
    font-weight: 500;
  }
0d5e5446   李宇   ```
1063
1064
1065
1066
1067
  
  .clickable-cell {
    color: #409EFF;
    cursor: pointer;
    text-decoration: none;
8479baab   “wangming”   优化统计卡片样式和布局,调整卡片间...
1068
    transition: color 0.2s ease;
0d5e5446   李宇   ```
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
  
    &:hover {
      color: #66b1ff;
      text-decoration: underline;
    }
  
    &:active {
      color: #3a8ee6;
    }
  }
18ca819c   李宇   最新
1079
  
8479baab   “wangming”   优化统计卡片样式和布局,调整卡片间...
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
  // 搜索框区域样式
  .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);
      }
    }
  }
  
18ca819c   李宇   最新
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
  // 响应式设计
  @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;
        }
      }
    }
  }
9661fd47   李宇   ```
1133
  </style>