Blame view

antis-ncc-admin/src/views/statisticsList/form8.vue 14 KB
9661fd47   李宇   ```
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
  <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="8">
              <el-form-item label="活动">
                <el-select
                  v-model="query.activityId"
                  placeholder="请选择活动"
                  clearable
                  filterable
                  :style='{"width":"100%"}'>
                  <el-option
                    v-for="item in activityOptions"
                    :key="item.id"
                    :label="item.activityName"
                    :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <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.storeIds"
                  multiple
                  collapse-tags
                  placeholder="请选择门店"
                  filterable
                  :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="4">
              <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-loading="listLoading">
          <el-row :gutter="16" v-if="statisticsData">
            <el-col :span="6">
              <div class="statistics-card">
72ae1b1c   李宇   ```
78
79
                <div class="card-icon icon-blue">
                  <i class="el-icon-trophy"></i>
9661fd47   李宇   ```
80
81
82
83
84
85
86
87
88
                </div>
                <div class="card-content">
                  <div class="card-title">活动名称</div>
                  <div class="card-value">{{ statisticsData.ActivityName || '无' }}</div>
                </div>
              </div>
            </el-col>
            <el-col :span="6">
              <div class="statistics-card">
72ae1b1c   李宇   ```
89
                <div class="card-icon icon-green">
9661fd47   李宇   ```
90
91
92
93
94
95
96
97
98
99
                  <i class="el-icon-shopping-bag-1"></i>
                </div>
                <div class="card-content">
                  <div class="card-title">开单数量</div>
                  <div class="card-value">{{ statisticsData.BillingCount || 0 }}</div>
                </div>
              </div>
            </el-col>
            <el-col :span="6">
              <div class="statistics-card">
72ae1b1c   李宇   ```
100
                <div class="card-icon icon-orange">
9661fd47   李宇   ```
101
102
103
104
105
106
107
108
109
110
                  <i class="el-icon-money"></i>
                </div>
                <div class="card-content">
                  <div class="card-title">开单金额</div>
                  <div class="card-value">¥{{ formatMoney(statisticsData.BillingAmount) }}</div>
                </div>
              </div>
            </el-col>
            <el-col :span="6">
              <div class="statistics-card">
72ae1b1c   李宇   ```
111
112
                <div class="card-icon icon-red">
                  <i class="el-icon-wallet"></i>
9661fd47   李宇   ```
113
114
                </div>
                <div class="card-content">
72ae1b1c   李宇   ```
115
116
                  <div class="card-title">欠款金额</div>
                  <div class="card-value">¥{{ formatMoney(statisticsData.DebtAmount) }}</div>
9661fd47   李宇   ```
117
118
119
120
121
                </div>
              </div>
            </el-col>
          </el-row>
        </div>
72ae1b1c   李宇   ```
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
  
        <!-- 开单列表 -->
        <div class="billing-table-section" v-loading="listLoading">
          <el-table
            :data="billingList"
            border
            style="width: 100%;max-height: 40vh;overflow-y: scroll;"
            stripe>
            <!-- <el-table-column
              prop="BillingId"
              label="账单ID"
              >
              <template slot-scope="scope">
                <i class="el-icon-document"></i> {{ scope.row.BillingId || '无' }}
              </template>
            </el-table-column> -->
            <el-table-column
              prop="BillingDate"
              label="开单日期"
              >
              <template slot-scope="scope">
                {{ formatDate(scope.row.BillingDate) }}
              </template>
            </el-table-column>
            <el-table-column
              prop="CustomerName"
              label="客户姓名"
             >
              <template slot-scope="scope">
                <i class="el-icon-user"></i> {{ scope.row.CustomerName || '无' }}
              </template>
            </el-table-column>
            <el-table-column
              prop="CustomerPhone"
              label="客户电话"
              >
              <template slot-scope="scope">
                <i class="el-icon-phone"></i> {{ scope.row.CustomerPhone || '无' }}
              </template>
            </el-table-column>
            <el-table-column
              prop="StoreName"
              label="门店"
              >
              <template slot-scope="scope">
                <i class="el-icon-s-home"></i> {{ scope.row.StoreName || '无' }}
              </template>
            </el-table-column>
            <el-table-column
              prop="Amount"
              label="开单金额"
             >
              <template slot-scope="scope">
                <i class="el-icon-money"></i> ¥{{ formatMoney(scope.row.Amount) }}
              </template>
            </el-table-column>
            <el-table-column
              prop="DebtAmount"
              label="欠款金额"
             >
              <template slot-scope="scope">
                <i class="el-icon-wallet"></i> ¥{{ formatMoney(scope.row.DebtAmount) }}
              </template>
            </el-table-column>
          </el-table>
  
          <!-- 分页组件 -->
          <el-pagination
            v-if="billingList.length > 0"
            @size-change="handleSizeChange"
            @current-change="handlePageChange"
            :current-page="pager.pageIndex"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="pager.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="pager.total"
            style="margin-top: 16px; text-align: right;">
          </el-pagination>
        </div>
9661fd47   李宇   ```
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
      </div>
    </div>
  </template>
  
  <script>
  import request from '@/utils/request'
  
  export default {
    name: 'ActivityStatistics',
    data() {
      return {
        query: {
          activityId: '',
          startTime: undefined,
          endTime: undefined,
          storeIds: []
        },
        activityOptions: [],
        storeOptions: [],
        statisticsData: null,
72ae1b1c   李宇   ```
221
222
223
224
225
226
227
        listLoading: false,
        billingList: [],
        pager: {
          pageIndex: 1,
          pageSize: 20,
          total: 0
        }
9661fd47   李宇   ```
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
      }
    },
    created() {
      this.setDefaultTimeRange()
      this.initActivityOptions()
      this.initStoreOptions()
    },
    methods: {
      // 设置默认时间范围(本月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())
      },
  
      // 初始化活动选项
      initActivityOptions() {
        request({
          url: '/api/Extend/lqpackageinfo/GetPackageInfoListAsync',
          method: 'GET',
          data: {
            currentPage: 1,
            pageSize: 1000
          }
        }).then(res => {
          this.activityOptions = res.data.list || []
          if(this.activityOptions.length > 0) {
            this.query.activityId = this.activityOptions[0].id
            this.search()
          }
        }).catch(err => {
          console.error('获取活动列表失败:', err)
        })
      },
  
      // 初始化门店选项
      initStoreOptions() {
        request({
          url: '/api/Extend/LqMdxx',
          method: 'GET',
          data: {
            currentPage: 1,
            pageSize: 1000
          }
        }).then(res => {
          this.storeOptions = res.data.list || []
        }).catch(err => {
          console.error('获取门店列表失败:', err)
        })
      },
  
      // 查询数据
      search() {
        if (!this.query.activityId) {
          this.$message({
            type: 'warning',
            message: '请选择活动',
            duration: 1500
          })
          return
        }
  
        this.listLoading = true
  
        const params = {
          activityId: this.query.activityId,
          startTime: this.query.startTime,
          endTime: this.query.endTime,
72ae1b1c   李宇   ```
298
299
300
          storeIds: this.query.storeIds || [],
          pageIndex: this.pager.pageIndex,
          pageSize: this.pager.pageSize
9661fd47   李宇   ```
301
302
303
304
305
306
307
308
309
310
        }
  
        request({
          url: '/api/Extend/lqpackageinfo/get-activity-statistics',
          method: 'POST',
          data: params
        }).then(res => {
          console.error(res)
          if (res.data && res.data) {
            this.statisticsData = res.data
72ae1b1c   李宇   ```
311
312
            this.billingList = res.data.BillingList || []
            this.pager.total = res.data.total || this.billingList.length
9661fd47   李宇   ```
313
314
          } else {
            this.statisticsData = null
72ae1b1c   李宇   ```
315
316
            this.billingList = []
            this.pager.total = 0
9661fd47   李宇   ```
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
          }
          this.listLoading = false
        }).catch(err => {
          console.error('查询失败:', err)
          this.$message({
            type: 'error',
            message: '查询失败,请重试',
            duration: 1500
          })
          this.listLoading = false
        })
      },
  
      // 重置查询条件
      reset() {
        this.query = {
          activityId: '',
          startTime: undefined,
          endTime: undefined,
          storeIds: []
        }
        this.setDefaultTimeRange()
        this.statisticsData = null
72ae1b1c   李宇   ```
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
        this.billingList = []
        this.pager = {
          pageIndex: 1,
          pageSize: 20,
          total: 0
        }
      },
  
      // 分页改变
      handlePageChange(page) {
        this.pager.pageIndex = page
        this.search()
      },
  
      // 每页条数改变
      handleSizeChange(size) {
        this.pager.pageSize = size
        this.pager.pageIndex = 1
        this.search()
      },
  
      // 格式化日期
      formatDate(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}`
9661fd47   李宇   ```
372
373
374
375
376
377
378
379
      },
  
      // 格式化金额
      formatMoney(amount) {
        if (!amount && amount !== 0) return '0.00'
        return Number(amount).toFixed(2)
      },
  
9661fd47   李宇   ```
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
      // 格式化日期时间(用于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}`
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .statistics-cards {
    margin-bottom: 20px;
72ae1b1c   李宇   ```
399
    min-height: 100px;
9661fd47   李宇   ```
400
401
402
403
404
405
406
  }
  
  .statistics-card {
    height: 100px;
    padding: 12px;
    border-radius: 12px;
    background: #fff;
72ae1b1c   李宇   ```
407
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
9661fd47   李宇   ```
408
409
    display: flex;
    align-items: center;
72ae1b1c   李宇   ```
410
411
412
413
414
415
    transition: all 0.3s ease;
    
    &:hover {
      transform: translateY(-2px);
      box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    }
9661fd47   李宇   ```
416
417
418
419
420
    
    .card-icon {
      width: 60px;
      height: 60px;
      border-radius: 8px;
9661fd47   李宇   ```
421
422
423
424
      display: flex;
      align-items: center;
      justify-content: center;
      margin-right: 16px;
72ae1b1c   李宇   ```
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
      flex-shrink: 0;
      
      &.icon-blue {
        background: linear-gradient(135deg, #409EFF, #66B1FF);
      }
      
      &.icon-green {
        background: linear-gradient(135deg, #67C23A, #85CE61);
      }
      
      &.icon-orange {
        background: linear-gradient(135deg, #E6A23C, #EEBE77);
      }
      
      &.icon-red {
        background: linear-gradient(135deg, #F56C6C, #F89898);
      }
9661fd47   李宇   ```
442
443
444
445
446
447
448
449
450
      
      i {
        font-size: 24px;
        color: #fff;
      }
    }
    
    .card-content {
      flex: 1;
72ae1b1c   李宇   ```
451
      min-width: 0;
9661fd47   李宇   ```
452
453
454
455
456
      
      .card-title {
        font-size: 14px;
        color: #909399;
        margin-bottom: 8px;
72ae1b1c   李宇   ```
457
        line-height: 1.2;
9661fd47   李宇   ```
458
459
460
461
462
463
464
      }
      
      .card-value {
        font-size: 20px;
        font-weight: bold;
        color: #303133;
        word-break: break-all;
72ae1b1c   李宇   ```
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
        line-height: 1.2;
      }
    }
  }
  
  .billing-table-section {
    margin-top: 20px;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    
    ::v-deep .el-table {
      .el-table__header th {
        background-color: #f5f7fa;
        color: #303133;
        font-weight: 600;
        padding: 12px 0;
9661fd47   李宇   ```
483
      }
72ae1b1c   李宇   ```
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
      
      .el-table__body td {
        padding: 12px 0;
        
        .cell {
          display: flex;
          align-items: center;
          
          i {
            margin-right: 6px;
            color: #409EFF;
            font-size: 16px;
          }
        }
      }
      
      .el-table__row:hover {
        background-color: #f5f7fa;
      }
    }
    
    ::v-deep .el-pagination {
      margin-top: 20px;
9661fd47   李宇   ```
507
508
509
    }
  }
  </style>