yudao-dev/src/views/quality/monitoring/qualityStatistics/graphPage.vue

117 lines
2.5 KiB
Vue
Raw Normal View History

2023-08-07 15:23:19 +08:00
<!--
filename: graphPage.vue
author: liubin
date: 2023-08-07 13:46:59
description:
-->
<template>
<div class="graph-page">
2023-09-20 10:49:17 +08:00
<!-- <DetailGraph id="dg1" key="dg1" ref="dg1" title="数据总览">
2023-08-07 16:09:25 +08:00
<TotalGraph :summary-list="summaryList" />
2023-09-20 10:49:17 +08:00
</DetailGraph> -->
<!-- <DetailGraph id="dg2" key="dg2" ref="dg2" title="检测内容数据">
2023-08-08 10:16:53 +08:00
<LineGraph :x-props="lineData.xProps" :legend="legend" :series="series" />
2023-09-20 10:49:17 +08:00
</DetailGraph> -->
2023-08-07 15:23:19 +08:00
<!-- <DetailGraph id="dg3" key="dg3" ref="dg3" />
2023-09-20 10:49:17 +08:00
<DetailGraph id="dg4" key="dg4" ref="dg4" /> -->
2023-10-09 17:01:19 +08:00
<!-- <div v-if="!series || series.length == 0" style="color: #777; font-size: 16px; letter-spacing: 1px; text-align: center; padding-top: 56px; text-decoration: underline;">暂无数据</div> -->
<div v-if="!series || series.length == 0" class="no-data-bg" />
2023-09-20 10:57:16 +08:00
<LineGraph
v-else
:x-props="lineData.xProps"
:legend="legend"
:series="series" />
2023-08-07 15:23:19 +08:00
</div>
</template>
<script>
import DetailGraph from './components/detailGraph.vue';
import TotalGraph from './components/graphs/total.vue';
2023-08-07 17:05:09 +08:00
import LineGraph from './components/graphs/line.vue';
2023-08-07 15:23:19 +08:00
export default {
name: 'GraphPage',
2023-08-07 16:38:52 +08:00
components: { DetailGraph, TotalGraph, LineGraph },
2023-08-07 16:09:25 +08:00
props: {
summaryList: {
type: Array,
default: () => [],
},
2023-08-07 17:05:09 +08:00
lineData: {
type: Object,
default: () => ({}),
},
2023-08-07 16:09:25 +08:00
},
2023-08-07 15:23:19 +08:00
data() {
2023-08-07 17:05:09 +08:00
return {
legend: [],
2023-08-08 10:16:53 +08:00
series: [],
2023-08-07 17:05:09 +08:00
};
2023-08-07 15:23:19 +08:00
},
2023-08-08 10:16:53 +08:00
mounted() {
this.buildLegend();
this.$nextTick(() => {
this.series = this.lineData.list.map(this.buildSeries);
console.log('this.series', this.series);
});
},
2023-08-07 17:05:09 +08:00
methods: {
buildSeries(item) {
2023-08-08 10:16:53 +08:00
console.log('this.list', this.lineData.list, this.lineData.xProps);
const seriesItem = {
2023-08-07 17:05:09 +08:00
name: item.inspectionContent,
2023-09-20 10:57:16 +08:00
type: 'bar',
barCategoryGap: 12,
2023-10-17 17:02:53 +08:00
barWidth: 20,
2023-08-08 10:16:53 +08:00
data: [],
2023-08-07 17:05:09 +08:00
};
2023-08-08 10:16:53 +08:00
this.lineData.xProps.forEach((prop) => {
if (prop in item) {
seriesItem.data.push(item[prop]);
} else {
seriesItem.data.push(null);
}
});
return seriesItem;
2023-08-07 17:05:09 +08:00
},
buildLegend() {
this.legend = this.lineData.list
.map((item) => item.inspectionContent)
.sort();
},
},
2023-08-07 15:23:19 +08:00
};
</script>
<style scoped lang="scss">
.graph-page {
height: 100%;
display: grid;
// grid-template-columns: ;
// grid-template-columns: 1fr 1fr;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
grid-auto-rows: minmax(300px, max-content);
gap: 12px;
}
#dg1 {
grid-column: 1 / 3;
}
#dg2 {
grid-column: 3 / 5;
}
#dg3 {
grid-column: span 2;
}
#dg4 {
grid-column: span 2;
}
</style>