Blame view

antis-ncc-admin/src/views/statisticsList/form7.vue 31.9 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
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
        <!-- 统计卡片 -->
        <div class="statistics-cards" v-if="summaryData">
          <el-row :gutter="16">
            <el-col :span="6">
              <div class="statistics-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="6">
              <div class="statistics-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="6">
              <div class="statistics-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="6">
              <div class="statistics-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-row>
          <el-row :gutter="16" style="margin-top: 16px;">
            <el-col :span="6">
              <div class="statistics-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="6">
              <div class="statistics-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-col :span="6">
              <div class="statistics-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="6">
              <div class="statistics-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-row>
          <el-row :gutter="16" style="margin-top: 16px;">
            <el-col :span="6">
              <div class="statistics-card">
                <div class="card-icon">
                  <i class="el-icon-user"></i>
                </div>
                <div class="card-content">
                  <div class="card-title">总人头数</div>
ffd6aaca   李宇   最新
192
                  <div class="card-value">{{ formatNumber(summaryData.totalHeadCount) }}</div>
18ca819c   李宇   最新
193
194
195
196
197
198
199
200
201
202
                </div>
              </div>
            </el-col>
            <el-col :span="6">
              <div class="statistics-card">
                <div class="card-icon">
                  <i class="el-icon-s-custom"></i>
                </div>
                <div class="card-content">
                  <div class="card-title">总人次</div>
ffd6aaca   李宇   最新
203
                  <div class="card-value">{{ formatNumber(summaryData.totalPersonCount) }}</div>
18ca819c   李宇   最新
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
                </div>
              </div>
            </el-col>
            <el-col :span="6">
              <div class="statistics-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="6">
              <div class="statistics-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>
  
9661fd47   李宇   ```
232
233
        <!-- 数据表格 -->
        <div class="NCC-common-layout-main NCC-flex-main">
1b4e76c0   李宇   ```
234
235
236
237
          <NCC-table 
            v-loading="listLoading" 
            :data="list" 
            has-c
1b4e76c0   李宇   ```
238
          >
9661fd47   李宇   ```
239
240
241
            <el-table-column prop="employeeName" label="员工姓名"  />
            <el-table-column prop="storeName" label="门店名称"  />
            <el-table-column prop="departmentName" label="部门名称"  />
18ca819c   李宇   最新
242
243
244
245
246
247
248
249
250
251
            <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   李宇   ```
252
253
            <el-table-column prop="inviteCount" label="邀请数"  >
              <template slot-scope="scope">
0d5e5446   李宇   ```
254
255
256
                <span class="clickable-cell" @click="handleInviteClick(scope.row)">
                  {{ scope.row.inviteCount || 0 }}
                </span>
9661fd47   李宇   ```
257
258
259
260
              </template>
            </el-table-column>
            <el-table-column prop="appointmentCount" label="预约数"  >
              <template slot-scope="scope">
0d5e5446   李宇   ```
261
262
263
                <span class="clickable-cell" @click="handleAppointmentClick(scope.row)">
                  {{ scope.row.appointmentCount || 0 }}
                </span>
9661fd47   李宇   ```
264
265
              </template>
            </el-table-column>
0d5e5446   李宇   ```
266
            <el-table-column prop="到店人数" label="到店人数"  >
9661fd47   李宇   ```
267
              <template slot-scope="scope">
0d5e5446   李宇   ```
268
269
270
                <span class="clickable-cell" @click="handleVisitClick(scope.row)">
                  {{ scope.row.visitCount || 0 }}
                </span>
9661fd47   李宇   ```
271
272
273
274
              </template>
            </el-table-column>
            <el-table-column prop="billingCount" label="开单数"  >
              <template slot-scope="scope">
0d5e5446   李宇   ```
275
276
277
                <span class="clickable-cell" @click="handleBillingClick(scope.row)">
                  {{ scope.row.billingCount || 0 }}
                </span>
9661fd47   李宇   ```
278
279
280
281
              </template>
            </el-table-column>
            <el-table-column prop="billingAmount" label="开单金额"  >
              <template slot-scope="scope">
b1146e00   李宇   最新
282
283
284
                <span class="clickable-cell amount-value" @click="handleBillingAmountClick(scope.row)">
                  ¥{{ formatMoney(scope.row.billingAmount) }}
                </span>
9661fd47   李宇   ```
285
286
287
288
              </template>
            </el-table-column>
            <el-table-column prop="consumeAmount" label="消耗金额"  >
              <template slot-scope="scope">
b1146e00   李宇   最新
289
290
291
                <span class="clickable-cell amount-paid" @click="handleConsumeAmountClick(scope.row)">
                  ¥{{ formatMoney(scope.row.consumeAmount) }}
                </span>
9661fd47   李宇   ```
292
293
              </template>
            </el-table-column>
86ade5ce   李宇   报表
294
295
            <el-table-column prop="refundAmount" label="退款金额"  >
              <template slot-scope="scope">
b1146e00   李宇   最新
296
297
298
                <span class="clickable-cell amount-paid" @click="handleRefundAmountClick(scope.row)">
                  ¥{{ formatMoney(scope.row.refundAmount) }}
                </span>
86ade5ce   李宇   报表
299
300
301
302
303
304
305
              </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   李宇   ```
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
            <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   李宇   ```
321
322
323
324
325
            <el-table-column prop="laborCost" label="手工费"  >
              <template slot-scope="scope">
                {{ scope.row.laborCost || 0 }}
              </template>
            </el-table-column>
9661fd47   李宇   ```
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
          </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   李宇   最新
353
          organizationType: undefined,
9661fd47   李宇   ```
354
          departmentId: undefined,
ffd6aaca   李宇   最新
355
          storeIds: [],
9661fd47   李宇   ```
356
357
358
359
360
361
362
363
364
          startTime: undefined,
          endTime: undefined,
          currentPage: 1,
          pageSize: 20
        },
        storeOptions: [],
        departmentOptions: [],
        list: [],
        total: 0,
18ca819c   李宇   最新
365
366
        listLoading: false,
        summaryData: null
9661fd47   李宇   ```
367
368
369
      }
    },
    created() {
86ade5ce   李宇   报表
370
371
372
373
374
375
  
      if (sessionStorage.getItem('isshaixuan') === 'false') {
        this.setDefaultTimeRange()
      } else{
        this.restoreQueryParams()
      }
ffd6aaca   李宇   最新
376
      this.loadAllStores()
9661fd47   李宇   ```
377
378
      this.search()
    },
ffd6aaca   李宇   最新
379
380
381
382
383
384
385
386
    watch: {
      // 监听开始时间变化,重新加载门店列表
      'query.startTime'() {
        this.$nextTick(() => {
          this.initStoreOptions()
        })
      }
    },
9661fd47   李宇   ```
387
    methods: {
86ade5ce   李宇   报表
388
389
390
391
      // 保存筛选条件到 sessionStorage
      saveQueryParams() {
        try {
          const paramsToSave = {
ffd6aaca   李宇   最新
392
            organizationType: this.query.organizationType,
86ade5ce   李宇   报表
393
            departmentId: this.query.departmentId,
ffd6aaca   李宇   最新
394
            storeIds: this.query.storeIds,
86ade5ce   李宇   报表
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
            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   李宇   最新
414
            this.query.organizationType = params.organizationType || undefined
86ade5ce   李宇   报表
415
            this.query.departmentId = params.departmentId || undefined
ffd6aaca   李宇   最新
416
            this.query.storeIds = params.storeIds || []
86ade5ce   李宇   报表
417
418
419
420
421
422
423
424
425
            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   李宇   最新
426
427
428
429
430
431
432
433
434
435
436
437
438
            
            // 恢复部门选项和门店列表
            if (this.query.organizationType) {
              this.loadDepartmentOptions()
            }
            if (this.query.departmentId && this.query.organizationType && this.query.startTime) {
              this.$nextTick(() => {
                this.initStoreOptions()
              })
            } else {
              this.loadAllStores()
            }
            
86ade5ce   李宇   报表
439
440
441
442
443
444
445
446
447
448
449
450
            sessionStorage.setItem('isshaixuan', false)
          } else {
            // 没有保存的条件,设置默认时间范围
            this.setDefaultTimeRange()
          }
        } catch (err) {
          console.error('恢复筛选条件失败:', err)
          // 出错时设置默认时间范围
          this.setDefaultTimeRange()
        }
      },
  
9661fd47   李宇   ```
451
452
453
454
455
456
457
      // 设置默认时间范围(本月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   李宇   最新
458
459
460
461
462
463
464
        
        // 时间设置后,如果有组织类型和部门,重新加载门店列表
        if (this.query.organizationType && this.query.departmentId) {
          this.$nextTick(() => {
            this.initStoreOptions()
          })
        }
9661fd47   李宇   ```
465
466
      },
  
ffd6aaca   李宇   最新
467
468
      // 加载全部门店(当没有选择部门时)
      loadAllStores() {
9661fd47   李宇   ```
469
470
471
472
473
474
475
476
477
478
479
        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   李宇   最新
480
          this.storeOptions = []
9661fd47   李宇   ```
481
482
483
        })
      },
  
ffd6aaca   李宇   最新
484
485
486
487
488
489
490
      // 获取部门选项(根据组织类型)
      loadDepartmentOptions() {
        if (!this.query.organizationType) {
          this.departmentOptions = []
          return
        }
        
9661fd47   李宇   ```
491
        request({
ffd6aaca   李宇   最新
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
          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   李宇   ```
548
        }).then(res => {
ffd6aaca   李宇   最新
549
550
551
552
553
554
555
556
557
558
559
560
561
562
          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   李宇   ```
563
        }).catch(err => {
ffd6aaca   李宇   最新
564
565
566
567
568
569
570
571
          console.error('获取门店列表失败:', err)
          this.$message({
            type: 'error',
            message: '获取门店列表失败',
            duration: 1500
          })
          this.storeOptions = []
          this.query.storeIds = []
9661fd47   李宇   ```
572
573
574
        })
      },
  
ffd6aaca   李宇   最新
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
      // 处理组织类型变化
      handleOrganizationTypeChange() {
        // 清空部门和门店
        this.query.departmentId = undefined
        this.query.storeIds = []
        // 重新加载部门选项
        this.loadDepartmentOptions()
        // 加载全部门店(因为部门已清空)
        this.loadAllStores()
      },
  
      // 处理部门变化
      handleDepartmentChange() {
        // 清空门店选择
        this.query.storeIds = []
        // 重新加载门店列表(如果有部门则加载部门管理的门店,否则加载全部门店)
        this.initStoreOptions()
      },
  
9661fd47   李宇   ```
594
595
596
597
598
  
  
      // 查询数据
      search() {
        this.listLoading = true
86ade5ce   李宇   报表
599
600
        // 保存当前筛选条件
        // this.saveQueryParams()
9661fd47   李宇   ```
601
602
603
604
605
606
  
        const params = {
          currentPage: this.query.currentPage,
          pageSize: this.query.pageSize
        }
  
ffd6aaca   李宇   最新
607
        if (this.query.storeIds && this.query.storeIds.length > 0) {
f7aed489   李宇   最新
608
          params.StoreIds = this.query.storeIds.join(',')
9661fd47   李宇   ```
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
        }
  
        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   李宇   报表
630
            this.total = (res.data.pagination && res.data.pagination.totalCount) || 0
18ca819c   李宇   最新
631
632
            // 计算汇总数据
            this.calculateSummary(res.data.list)
9661fd47   李宇   ```
633
634
635
          } else {
            this.list = []
            this.total = 0
18ca819c   李宇   最新
636
            this.summaryData = null
9661fd47   李宇   ```
637
638
639
640
641
642
643
644
645
646
          }
          this.listLoading = false
        }).catch(err => {
          console.error('查询失败:', err)
          this.$message({
            type: 'error',
            message: '查询失败,请重试',
            duration: 1500
          })
          this.listLoading = false
18ca819c   李宇   最新
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
          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   李宇   ```
685
        })
18ca819c   李宇   最新
686
687
688
689
690
  
        // 计算总个人业绩(开单金额 - 退款金额)
        summary.totalPersonalPerformance = summary.totalBillingAmount - summary.totalRefundAmount
  
        this.summaryData = summary
9661fd47   李宇   ```
691
692
693
694
695
      },
  
      // 重置查询条件
      reset() {
        this.query = {
ffd6aaca   李宇   最新
696
          organizationType: undefined,
9661fd47   李宇   ```
697
          departmentId: undefined,
ffd6aaca   李宇   最新
698
          storeIds: [],
9661fd47   李宇   ```
699
700
701
702
703
704
          startTime: undefined,
          endTime: undefined,
          currentPage: 1,
          pageSize: 20
        }
        this.setDefaultTimeRange()
ffd6aaca   李宇   最新
705
706
707
        this.departmentOptions = []
        // 重置后加载全部门店
        this.loadAllStores()
86ade5ce   李宇   报表
708
709
710
711
712
713
        // 清除保存的筛选条件
        try {
          sessionStorage.removeItem('form7_query_params')
        } catch (err) {
          console.error('清除保存的筛选条件失败:', err)
        }
9661fd47   李宇   ```
714
715
        this.list = []
        this.total = 0
18ca819c   李宇   最新
716
        this.summaryData = null
9661fd47   李宇   ```
717
718
719
720
721
722
723
724
725
        this.search()
      },
  
      // 格式化金额
      formatMoney(amount) {
        if (!amount && amount !== 0) return '0.00'
        return Number(amount).toFixed(2)
      },
  
ffd6aaca   李宇   最新
726
727
728
729
730
731
732
733
      // 格式化数字,保留两位小数
      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   李宇   最新
734
735
736
737
738
739
      // 格式化百分比
      formatPercentage(ratio) {
        if (ratio === null || ratio === undefined) return '0.00%'
        return `${Number(ratio).toFixed(2)}%`
      },
  
9661fd47   李宇   ```
740
741
742
743
744
745
746
747
748
749
750
      // 格式化日期时间(用于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   李宇   ```
751
752
753
754
755
      },
  
      // 将时间字符串转换为时间戳(毫秒)
      getTimestamp(timeStr) {
        if (!timeStr) return ''
1b4e76c0   李宇   ```
756
757
758
759
760
761
762
763
764
765
766
767
768
769
        // 手动解析 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   李宇   ```
770
771
772
773
774
      },
  
      // 处理邀请数点击事件
      handleInviteClick(row) {
        if (row && row.employeeId) {
86ade5ce   李宇   报表
775
          this.saveQueryParams()
0d5e5446   李宇   ```
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
          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   李宇   报表
797
          this.saveQueryParams()
0d5e5446   李宇   ```
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
          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   李宇   报表
819
          this.saveQueryParams()
0d5e5446   李宇   ```
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
          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   李宇   报表
842
          this.saveQueryParams()
0d5e5446   李宇   ```
843
844
845
          this.$router.push({
            path: '/lqKdKdjlb',
            query: {
b1146e00   李宇   最新
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
              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   李宇   ```
913
914
915
916
917
918
919
920
921
922
923
924
              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   李宇   ```
925
926
927
928
929
930
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
18ca819c   李宇   最新
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
  .statistics-cards {
    margin-bottom: 20px;
  }
  
  .statistics-card {
    height: 100px;
    padding: 12px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    
    .card-icon {
      width: 60px;
      height: 60px;
      border-radius: 8px;
      background: linear-gradient(135deg, #409EFF, #67C23A);
      display: flex;
      align-items: center;
      justify-content: center;
      margin-right: 16px;
      
      i {
        font-size: 24px;
        color: #fff;
      }
    }
    
    .card-content {
      flex: 1;
      
      .card-title {
        font-size: 14px;
        color: #909399;
        margin-bottom: 8px;
      }
      
      .card-value {
        font-size: 24px;
        font-weight: bold;
        color: #303133;
      }
    }
  }
  
9661fd47   李宇   ```
977
978
979
980
981
982
983
984
985
  .amount-value {
    color: #409EFF;
    font-weight: 500;
  }
  
  .amount-paid {
    color: #67C23A;
    font-weight: 500;
  }
0d5e5446   李宇   ```
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
  
  .clickable-cell {
    color: #409EFF;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s;
  
    &:hover {
      color: #66b1ff;
      text-decoration: underline;
    }
  
    &:active {
      color: #3a8ee6;
    }
  }
18ca819c   李宇   最新
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
  
  // 响应式设计
  @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   李宇   ```
1036
  </style>