|
|
|
@ -0,0 +1,139 @@
|
|
|
|
|
<!--
|
|
|
|
|
* @Author: BINGWU
|
|
|
|
|
* @Date: 2024-05-23 21:45:05
|
|
|
|
|
* @LastEditors: BINGWU HuJiaCheng2003@163.com
|
|
|
|
|
* @LastEditTime: 2024-05-23 23:13:27
|
|
|
|
|
* @FilePath: \employee-information-management-system\app\src\views\components\echarts\FeedbackEcharts.vue
|
|
|
|
|
* @Describe:
|
|
|
|
|
* @Mark: ૮(˶ᵔ ᵕ ᵔ˶)ა
|
|
|
|
|
-->
|
|
|
|
|
<template>
|
|
|
|
|
<div class="feedback-echarts">
|
|
|
|
|
<div id="feedback-echarts" style="width: 600px; height: 500px"></div>
|
|
|
|
|
<div style="text-align: center">反馈信息数据</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
import { onMounted, ref, computed } from 'vue'
|
|
|
|
|
import * as echarts from 'echarts'
|
|
|
|
|
import { getAllFeedback } from '@/api/feedback'
|
|
|
|
|
import { dayjs } from 'element-plus'
|
|
|
|
|
const data1 = ref({
|
|
|
|
|
'待处理-1': 0,
|
|
|
|
|
'待处理-2': 0,
|
|
|
|
|
'待处理-3': 0,
|
|
|
|
|
'待处理-4': 0,
|
|
|
|
|
'待处理-5': 0,
|
|
|
|
|
'待处理-6': 0,
|
|
|
|
|
'待处理-7': 0,
|
|
|
|
|
'待处理-8': 0,
|
|
|
|
|
'待处理-9': 0,
|
|
|
|
|
'待处理-10': 0,
|
|
|
|
|
'待处理-11': 0,
|
|
|
|
|
'待处理-12': 0
|
|
|
|
|
})
|
|
|
|
|
const data2 = ref({
|
|
|
|
|
'已处理-1': 0,
|
|
|
|
|
'已处理-2': 0,
|
|
|
|
|
'已处理-3': 0,
|
|
|
|
|
'已处理-4': 0,
|
|
|
|
|
'已处理-5': 0,
|
|
|
|
|
'已处理-6': 0,
|
|
|
|
|
'已处理-7': 0,
|
|
|
|
|
'已处理-8': 0,
|
|
|
|
|
'已处理-9': 0,
|
|
|
|
|
'已处理-10': 0,
|
|
|
|
|
'已处理-11': 0,
|
|
|
|
|
'已处理-12': 0
|
|
|
|
|
})
|
|
|
|
|
const myEcharts = (data1, data2) => {
|
|
|
|
|
// 基于准备好的dom,初始化echarts实例
|
|
|
|
|
var myChart = echarts.init(document.getElementById('feedback-echarts'))
|
|
|
|
|
|
|
|
|
|
// 指定图表的配置项和数据
|
|
|
|
|
var option = {
|
|
|
|
|
legend: {},
|
|
|
|
|
tooltip: {},
|
|
|
|
|
dataset: {
|
|
|
|
|
source: [
|
|
|
|
|
[
|
|
|
|
|
'product',
|
|
|
|
|
'1月',
|
|
|
|
|
'2月',
|
|
|
|
|
'3月',
|
|
|
|
|
'4月',
|
|
|
|
|
'5月',
|
|
|
|
|
'6月',
|
|
|
|
|
'7月',
|
|
|
|
|
'8月',
|
|
|
|
|
'9月',
|
|
|
|
|
'10月',
|
|
|
|
|
'12月',
|
|
|
|
|
'12月'
|
|
|
|
|
],
|
|
|
|
|
['待处理', ...data1],
|
|
|
|
|
['已处理', ...data2]
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
xAxis: { type: 'category' },
|
|
|
|
|
yAxis: {},
|
|
|
|
|
// Declare several bar series, each will be mapped
|
|
|
|
|
// to a column of dataset.source by default.
|
|
|
|
|
series: [
|
|
|
|
|
{ type: 'bar' },
|
|
|
|
|
{ type: 'bar' },
|
|
|
|
|
{ type: 'bar' },
|
|
|
|
|
{ type: 'bar' },
|
|
|
|
|
{ type: 'bar' },
|
|
|
|
|
{ type: 'bar' },
|
|
|
|
|
{ type: 'bar' },
|
|
|
|
|
{ type: 'bar' },
|
|
|
|
|
{ type: 'bar' },
|
|
|
|
|
{ type: 'bar' },
|
|
|
|
|
{ type: 'bar' },
|
|
|
|
|
{ type: 'bar' }
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 使用刚指定的配置项和数据显示图表。
|
|
|
|
|
myChart.setOption(option)
|
|
|
|
|
}
|
|
|
|
|
const getData = async () => {
|
|
|
|
|
await getAllFeedback({ pageIndex: 1, pageSize: 99999 }).then((res) => {
|
|
|
|
|
res.data.data.forEach((item) => {
|
|
|
|
|
const key = item.status + '-' + dayjs(item.date).format('M')
|
|
|
|
|
if (item.status === '已处理') {
|
|
|
|
|
data2.value[key]++
|
|
|
|
|
} else {
|
|
|
|
|
data1.value[key]++
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const unHandleData = computed(() => {
|
|
|
|
|
let newData = []
|
|
|
|
|
for (const key in data1.value) {
|
|
|
|
|
newData.push(data1.value[key])
|
|
|
|
|
}
|
|
|
|
|
return newData
|
|
|
|
|
})
|
|
|
|
|
const handleData = computed(() => {
|
|
|
|
|
let newData = []
|
|
|
|
|
for (const key in data2.value) {
|
|
|
|
|
newData.push(data2.value[key])
|
|
|
|
|
}
|
|
|
|
|
return newData
|
|
|
|
|
})
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
await getData()
|
|
|
|
|
myEcharts(unHandleData.value, handleData.value)
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.feedback-echarts {
|
|
|
|
|
height: 100%;
|
|
|
|
|
}
|
|
|
|
|
</style>
|