wlzboy
2025-09-29 c622702a7b9357a45df08361dfab4dcc690fc95c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="车牌号" prop="vehicleNo">
        <el-input
          v-model="queryParams.vehicleNo"
          placeholder="请输入车牌号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="评价时间" prop="evaluationTime">
        <el-date-picker
          v-model="dateRange"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
 
    <el-row :gutter="32">
      <el-col :xs="24" :sm="12" :lg="6" class="card-panel-col">
        <div class="card-panel">
          <div class="card-panel-icon-wrapper icon-people">
            <svg-icon icon-class="peoples" class-name="card-panel-icon" />
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">总评价数</div>
            <div class="card-panel-num">{{ statisticsData.totalEvaluations }}</div>
          </div>
        </div>
      </el-col>
      <el-col :xs="24" :sm="12" :lg="6" class="card-panel-col">
        <div class="card-panel">
          <div class="card-panel-icon-wrapper icon-message">
            <svg-icon icon-class="message" class-name="card-panel-icon" />
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">平均评分</div>
            <div class="card-panel-num">{{ statisticsData.averageScore }}</div>
          </div>
        </div>
      </el-col>
      <el-col :xs="24" :sm="12" :lg="6" class="card-panel-col">
        <div class="card-panel">
          <div class="card-panel-icon-wrapper icon-star">
            <svg-icon icon-class="star" class-name="card-panel-icon" />
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">好评率</div>
            <div class="card-panel-num">{{ statisticsData.goodRate }}%</div>
          </div>
        </div>
      </el-col>
      <el-col :xs="24" :sm="12" :lg="6" class="card-panel-col">
        <div class="card-panel">
          <div class="card-panel-icon-wrapper icon-vehicle">
            <svg-icon icon-class="car" class-name="card-panel-icon" />
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">参与车辆</div>
            <div class="card-panel-num">{{ statisticsData.vehicleCount }}</div>
          </div>
        </div>
      </el-col>
    </el-row>
 
    <el-row :gutter="32" style="margin-top: 20px;">
      <el-col :xs="24" :sm="24" :lg="12">
        <div class="chart-container">
          <div class="chart-title">评分分布</div>
          <div ref="scoreChart" class="chart"></div>
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="12">
        <div class="chart-container">
          <div class="chart-title">月度评价趋势</div>
          <div ref="trendChart" class="chart"></div>
        </div>
      </el-col>
    </el-row>
 
    <el-row style="margin-top: 20px;">
      <el-col :span="24">
        <div class="chart-container">
          <div class="chart-title">各维度评分统计</div>
          <div ref="dimensionChart" class="chart"></div>
        </div>
      </el-col>
    </el-row>
 
    <el-table v-loading="loading" :data="evaluationList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="评价ID" align="center" prop="evaluationId" />
      <el-table-column label="车牌号" align="center" prop="vehicleNo" />
      <el-table-column label="客户姓名" align="center" prop="customerName" />
      <el-table-column label="客户手机" align="center" prop="customerPhone" />
      <el-table-column label="综合评分" align="center" prop="overallScore">
        <template slot-scope="scope">
          <el-rate
            v-model="scope.row.overallScore"
            disabled
            show-score
            text-color="#ff9900"
            score-template="{value}"
          />
        </template>
      </el-table-column>
      <el-table-column label="评价时间" align="center" prop="evaluationTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.evaluationTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleView(scope.row)"
          >查看详情</el-button>
        </template>
      </el-table-column>
    </el-table>
 
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
 
    <!-- 评价详情对话框 -->
    <el-dialog title="评价详情" :visible.sync="detailOpen" width="600px" append-to-body>
      <el-descriptions :column="2" border>
        <el-descriptions-item label="评价ID">{{ detailForm.evaluationId }}</el-descriptions-item>
        <el-descriptions-item label="车牌号">{{ detailForm.vehicleNo }}</el-descriptions-item>
        <el-descriptions-item label="客户姓名">{{ detailForm.customerName }}</el-descriptions-item>
        <el-descriptions-item label="客户手机">{{ detailForm.customerPhone }}</el-descriptions-item>
        <el-descriptions-item label="微信昵称">{{ detailForm.wechatNickname }}</el-descriptions-item>
        <el-descriptions-item label="综合评分">
          <el-rate
            v-model="detailForm.overallScore"
            disabled
            show-score
            text-color="#ff9900"
            score-template="{value}"
          />
        </el-descriptions-item>
        <el-descriptions-item label="评价时间" :span="2">
          {{ parseTime(detailForm.evaluationTime, '{y}-{m}-{d} {h}:{i}:{s}') }}
        </el-descriptions-item>
      </el-descriptions>
      
      <div style="margin-top: 20px;">
        <h4>详细评价</h4>
        <el-table :data="detailForm.evaluationDetails" border>
          <el-table-column label="评价维度" prop="dimensionName" />
          <el-table-column label="评分" align="center">
            <template slot-scope="scope">
              <el-rate
                v-if="scope.row.dimensionType === 'star'"
                v-model="scope.row.score"
                disabled
                show-score
                text-color="#ff9900"
                score-template="{value}"
              />
              <span v-else>{{ scope.row.optionValue || scope.row.textContent }}</span>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </el-dialog>
  </div>
</template>
 
<script>
import { listCustomerEvaluation, getCustomerEvaluation, getEvaluationStatistics } from "@/api/evaluation";
import * as echarts from 'echarts';
 
export default {
  name: "EvaluationStatistics",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 客户评价表格数据
      evaluationList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      detailOpen: false,
      // 日期范围
      dateRange: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        vehicleNo: null,
        evaluationTime: null
      },
      // 表单参数
      detailForm: {},
      // 统计数据
      statisticsData: {
        totalEvaluations: 0,
        averageScore: 0,
        goodRate: 0,
        vehicleCount: 0
      },
      // 图表实例
      scoreChart: null,
      trendChart: null,
      dimensionChart: null
    };
  },
  created() {
    this.getList();
    this.getStatistics();
  },
  mounted() {
    this.$nextTick(() => {
      this.initCharts();
    });
  },
  methods: {
    /** 查询客户评价列表 */
    getList() {
      this.loading = true;
      listCustomerEvaluation(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
        this.evaluationList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 获取统计数据 */
    getStatistics() {
      getEvaluationStatistics(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
        const data = response.data;
        this.statisticsData = {
          totalEvaluations: data.totalEvaluations || 0,
          averageScore: data.averageScore || 0,
          goodRate: data.goodRate || 0,
          vehicleCount: data.vehicleCount || 0
        };
        
        // 更新图表数据
        this.updateCharts(data);
      }).catch(() => {
        // 如果接口调用失败,使用默认数据
        this.statisticsData = {
          totalEvaluations: 0,
          averageScore: 0,
          goodRate: 0,
          vehicleCount: 0
        };
      });
    },
    /** 初始化图表 */
    initCharts() {
      this.initScoreChart();
      this.initTrendChart();
      this.initDimensionChart();
    },
    /** 更新图表数据 */
    updateCharts(data) {
      this.updateScoreChart(data.scoreDistribution);
      this.updateTrendChart(data.monthlyTrend);
      this.updateDimensionChart(data.dimensionScores);
    },
    /** 初始化评分分布图表 */
    initScoreChart() {
      this.scoreChart = echarts.init(this.$refs.scoreChart);
      this.updateScoreChart([0, 0, 0, 0, 0]);
    },
    /** 更新评分分布图表 */
    updateScoreChart(scoreDistribution) {
      if (!this.scoreChart) {
        this.scoreChart = echarts.init(this.$refs.scoreChart);
      }
      const option = {
        title: {
          text: '评分分布',
          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        series: [
          {
            name: '评分分布',
            type: 'pie',
            radius: '50%',
            data: [
              { value: scoreDistribution[4] || 0, name: '5星' },
              { value: scoreDistribution[3] || 0, name: '4星' },
              { value: scoreDistribution[2] || 0, name: '3星' },
              { value: scoreDistribution[1] || 0, name: '2星' },
              { value: scoreDistribution[0] || 0, name: '1星' }
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      };
      this.scoreChart.setOption(option);
    },
    /** 初始化趋势图表 */
    initTrendChart() {
      this.trendChart = echarts.init(this.$refs.trendChart);
      this.updateTrendChart([0, 0, 0, 0, 0, 0]);
    },
    /** 更新趋势图表 */
    updateTrendChart(monthlyTrend) {
      if (!this.trendChart) {
        this.trendChart = echarts.init(this.$refs.trendChart);
      }
      const option = {
        title: {
          text: '月度评价趋势',
          left: 'center'
        },
        tooltip: {
          trigger: 'axis'
        },
        xAxis: {
          type: 'category',
          data: ['1月', '2月', '3月', '4月', '5月', '6月']
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            name: '评价数量',
            type: 'line',
            data: monthlyTrend || [0, 0, 0, 0, 0, 0],
            smooth: true
          }
        ]
      };
      this.trendChart.setOption(option);
    },
    /** 初始化维度统计图表 */
    initDimensionChart() {
      this.dimensionChart = echarts.init(this.$refs.dimensionChart);
      this.updateDimensionChart([0, 0, 0, 0, 0]);
    },
    /** 更新维度统计图表 */
    updateDimensionChart(dimensionScores) {
      if (!this.dimensionChart) {
        this.dimensionChart = echarts.init(this.$refs.dimensionChart);
      }
      const option = {
        title: {
          text: '各维度评分统计',
          left: 'center'
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
          }
        },
        xAxis: {
          type: 'category',
          data: ['服务态度', '收费情况', '车辆卫生', '驾驶技术', '整体服务']
        },
        yAxis: {
          type: 'value',
          max: 5
        },
        series: [
          {
            name: '平均评分',
            type: 'bar',
            data: dimensionScores || [0, 0, 0, 0, 0],
            itemStyle: {
              color: '#409EFF'
            }
          }
        ]
      };
      this.dimensionChart.setOption(option);
    },
    // 取消按钮
    cancel() {
      this.detailOpen = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.detailForm = {
        evaluationId: null,
        vehicleNo: null,
        customerName: null,
        customerPhone: null,
        wechatOpenid: null,
        wechatNickname: null,
        wechatAvatar: null,
        wechatPhone: null,
        overallScore: null,
        evaluationTime: null,
        evaluationDetails: []
      };
      this.resetForm("detailForm");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
      this.getStatistics();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.evaluationId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 查看详情按钮操作 */
    handleView(row) {
      this.reset();
      const evaluationId = row.evaluationId || this.ids
      getCustomerEvaluation(evaluationId).then(response => {
        this.detailForm = response.data;
        this.detailOpen = true;
        this.title = "评价详情";
      });
    }
  }
};
</script>
 
<style scoped>
.app-container {
  padding: 20px;
}
 
.card-panel-col {
  margin-bottom: 20px;
}
 
.card-panel {
  height: 108px;
  cursor: pointer;
  font-size: 12px;
  position: relative;
  overflow: hidden;
  color: #666;
  background: #fff;
  box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
  border-color: rgba(0, 0, 0, .05);
}
 
.card-panel:hover {
  box-shadow: 4px 4px 40px rgba(0, 0, 0, .1);
}
 
.card-panel-icon-wrapper {
  float: left;
  margin: 14px 0 0 14px;
  padding: 16px;
  transition: all 0.38s ease-out;
  border-radius: 6px;
}
 
.card-panel-icon {
  float: left;
  font-size: 48px;
}
 
.card-panel-description {
  float: right;
  font-weight: bold;
  margin: 26px;
  margin-left: 0px;
}
 
.card-panel-text {
  line-height: 18px;
  color: rgba(0, 0, 0, 0.45);
  font-size: 16px;
  margin-bottom: 12px;
}
 
.card-panel-num {
  font-size: 20px;
  color: #666;
}
 
.icon-people {
  color: #40c9c6;
}
 
.icon-message {
  color: #36a3f7;
}
 
.icon-star {
  color: #f4516c;
}
 
.icon-vehicle {
  color: #34bfa3;
}
 
.chart-container {
  background: #fff;
  padding: 20px;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}
 
.chart-title {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 15px;
  text-align: center;
}
 
.chart {
  height: 300px;
  width: 100%;
}
</style>