<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>
|