From 3c4af47e2d8969a4c49fe2a2f81180b5bf10ce45 Mon Sep 17 00:00:00 2001 From: g7hoo Date: Wed, 17 Aug 2022 16:41:32 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E5=9F=BA=E6=9C=AC=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E5=BD=93=E5=89=8D=E6=A3=80=E6=B5=8B=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../monitoring/qualityInspectionCurrent.vue | 66 +++++++++++++++++-- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/src/views/modules/monitoring/qualityInspectionCurrent.vue b/src/views/modules/monitoring/qualityInspectionCurrent.vue index c71229a..c82d156 100644 --- a/src/views/modules/monitoring/qualityInspectionCurrent.vue +++ b/src/views/modules/monitoring/qualityInspectionCurrent.vue @@ -17,7 +17,7 @@ 查询 - 新增 + @@ -51,7 +51,7 @@ @operate-event="handleOperations" @refreshDataList="getDataList" /> - + @@ -90,6 +90,10 @@ const FakeChart = { typeList: { type: Array, default: () => [] + }, + seriesData: { + type: Array, + default: () => [] } }, data() { @@ -97,9 +101,17 @@ const FakeChart = { chart: null, defaultOpts: { title: { - text: '统计数据' + text: '检测类型统计数据' }, tooltip: {}, + legend: { + orient: 'vertical', + top: 10, + right: 20, + data: [ + /** dynamic */ + ] + }, xAxis: { data: [ /** dynamic */ @@ -126,6 +138,22 @@ const FakeChart = { }, immediate: true }, + typeList: { + handler: function(val, oldVal) { + if (val && val !== oldVal) { + this.defaultOpts.legend.data.push(...val) + } + }, + immediate: true + }, + seriesData: { + handler: function(val, oldVal) { + if (val && val !== oldVal) { + this.defaultOpts.series.push(...val) + } + }, + immediate: true + }, defaultOpts: { handler: function(val) { console.log('defaullt opts change: ', val) @@ -200,6 +228,8 @@ export default { this.showGraph = value === dict[0] ? false : true }, getDataList() { + this.showGraph = false + this.dataType = '表格' this.echartCategories = null this.echartCheckTypes.splice(0) /** 设置默认日期 */ @@ -227,7 +257,7 @@ export default { this.dataListDynamic = this.parseDynamicData(res.data.data) || [] - console.log('dyname', this.dataListDynamic) + this.buildGraphData() }) }, @@ -272,6 +302,34 @@ export default { }) }, + buildGraphData() { + /** 构造 echart 需要的数据 */ + const result = [] + + this.echartCheckTypes.forEach(ect => { + result.push({ name: ect, type: 'bar', data: [] }) + }) + + this.dataListDynamic.forEach((inspection, index) => { + console.log('inspection: ', inspection) + this.echartCategories.forEach(cate => { + if (cate in inspection) { + result[index].data.push(inspection[cate]) + } else { + result[index].data.push('0') + } + }) + }) + + this.echartsData = result + // [ + // { name: '11', type: 'bar', data: [/**产线1*/ 2, /**产线2*/ 3] }, + // { name: '222', type: 'bar', data: [1, 2, 3] } + // ] + + console.log('echarts data: ', this.echartsData) + }, + fetchList(type, startTime, endTime) { switch (type) { case 'sx':