From d1b793c51a67e7aebf04d35c0200b21681337024 Mon Sep 17 00:00:00 2001 From: quanyawei <401863037@qq.com> Date: Sun, 08 Oct 2023 15:13:54 +0800 Subject: [PATCH] fix:接口修改和echarts修改 --- src/views/charts/index.vue | 107 +++++++++++++++++++++++------------------------------ 1 files changed, 46 insertions(+), 61 deletions(-) diff --git a/src/views/charts/index.vue b/src/views/charts/index.vue index 6ccbfaa..c89cb1c 100644 --- a/src/views/charts/index.vue +++ b/src/views/charts/index.vue @@ -2,27 +2,11 @@ <div style="width: 100%; height: 100%"> <div class="topSelect"> <!-- <el-cascader v-model="newMac" :options="options" clearable change-on-select :props="{ checkStrictly: true }" placeholder="������������" /> --> - <el-cascader - v-model="newMac" - :options="options" - :props="props" - collapse-tags - clearable - placeholder="������������" - style="width: 354px" - /> + <el-cascader v-model="newMac" :options="options" :props="props" collapse-tags clearable placeholder="������������" + style="width: 354px" /> <!-- <div> --> - <el-select - v-model="value" - placeholder="������������" - style="margin-left: 20px" - > - <el-option - v-for="item in newSensor" - :key="item.value" - :label="item.label" - :value="item.value" - /> + <el-select v-model="value" placeholder="������������" style="margin-left: 20px"> + <el-option v-for="(item, index) in newSensor" :key="index" :label="item.label" :value="item.value" /> </el-select> <!-- </div> --> <!-- <el-radio-group v-model="radio1" style="margin-left:20px"> @@ -31,25 +15,12 @@ <el-radio-button label="������" /> <el-radio-button label="���������" /> </el-radio-group> --> - <el-select - v-model="select1" - placeholder="���������" - style="margin-left: 20px; width: 200px" - > - <el-option - v-for="item in options1" - :key="item.value" - :label="item.label" - :value="item.value" - > + <el-select v-model="select1" placeholder="���������" style="margin-left: 20px; width: 200px"> + <el-option v-for="item in options1" :key="item.value" :label="item.label" :value="item.value"> </el-option> </el-select> - <component - :is="dataType" - style="padding-left: 0; margin-left: 20px; width: 160px" - @sendPickerChild="showPickerChild" - class="select11" - /> + <component :is="dataType" style="padding-left: 0; margin-left: 20px; width: 160px" + @sendPickerChild="showPickerChild" class="select11" /> <!--������������--> <el-button @click="selectData" class="btn1">������</el-button> </div> @@ -141,6 +112,10 @@ isSelect: false, options1: [ { + label: '������������', + value: '������������', + }, + { label: '���������', value: '���������', }, @@ -168,7 +143,6 @@ } // ������������������������������������������ this.getSensor() - console.log(this.newMac1) }, // ������dataType��������������� select1(nv, ov) { @@ -184,6 +158,9 @@ } else if (nv === '���������') { this.dataType = 'HourPicker1' this.unit = 'hour' + } else if (nv === '������������') { + this.dataType = 'HourPicker1' + this.unit = 'FiveMinute' } else { this.dataType = 'CustomPicker' this.unit = 'hour' @@ -195,8 +172,7 @@ one === 'a34002' || one === 'a21004' || one === 'a21026' || - one === 'a05024' || - one === 'a21001' + one === 'a05024' ) { this.selectyz = '(������:ug/m��)' } else if ( @@ -224,7 +200,13 @@ this.selectyz = '(������:pcs/0.1L)' } else if (one === 'a00e13') { this.selectyz = '(������:db)' - } else if (one === 'a21028') { + } else if ( + one === 'a21028' || + one === 'a25002' || + one === 'a21001' || + one === 'a25005' || + one === 'a25003' + ) { this.selectyz = '(������:ppm)' } }, @@ -237,17 +219,18 @@ // mounted() { // // }, - beforeCreate() {}, // ������������ - ������������ - beforeMount() {}, // ������������ - ������������ - beforeUpdate() {}, // ������������ - ������������ - updated() {}, // ������������ - ������������ - beforeDestroy() {}, // ������������ - ������������ - destroyed() {}, // ������������ - ������������ - activated() {}, + beforeCreate() { }, // ������������ - ������������ + beforeMount() { }, // ������������ - ������������ + beforeUpdate() { }, // ������������ - ������������ + updated() { }, // ������������ - ������������ + beforeDestroy() { }, // ������������ - ������������ + destroyed() { }, // ������������ - ������������ + activated() { }, // ������������ methods: { // ������������ selectData() { + console.log(this.newData) var newLineChartData = { series: [], xAxis: [], @@ -267,16 +250,18 @@ }) .then((res) => { // console.log('������������������������������') - console.log(res) const data = res.data let lockLength = 0 for (let i = 0; i < data.length; i++) { for (let j = 0; j < data[i].deviceData.length; j++) { - console.log(data[i].deviceData); - if (res.data[0].deviceData.length == 1) { + if (res.data[0].deviceData.length === 1) { if (lockLength < data[i].deviceData.length) { newLineChartData.series.push({ data: [], + triggerLineEvent: true, + emphasis: { + focus: 'series' + }, name: '', type: 'line', label: { @@ -285,32 +270,26 @@ }, }) } - } else if (lockLength < data[i].deviceData.length) { + } else { newLineChartData.series.push({ data: [], name: '', + triggerLineEvent: true, + emphasis: { focus: 'series' }, type: 'line', - label: { - show: false, - position: 'top', - }, }) } newLineChartData.series[j].name = data[i].deviceData[j].name newLineChartData.title.push(data[i].deviceData[j].name) - lockLength++ newLineChartData.series[j].data.push( data[i].deviceData[j].sensorValue ) - - - } newLineChartData.xAxis.push(data[i].time) } // newLineChartData.title = this.value this.lineChartData = newLineChartData - // console.log(newLineChartData, 'newLineChartData') + console.log(lineChartData, 'newLineChartData') }) .catch((err) => { console.log(err) @@ -352,6 +331,7 @@ }, // ��������������������������������� getSensor() { + this.newSensor = [] // stringMacs.su // var newMac = this.newMac[this.newMac.length - 1][this.newMac[this.newMac.length - 1].length - 1] // this.newMac1 = this.newMac[this.newMac.length - 1][this.newMac[this.newMac.length - 1].length - 1] @@ -388,21 +368,25 @@ display: flex; margin-bottom: 20px; padding: 20px 15px 0 15px; + span:first-child { flex: 1; } + div:last-child { width: 300px; line-height: 40px; padding-left: 6px; } } + .topTitle { display: flex; justify-content: space-between; margin-bottom: 20px; padding: 0 15px; } + .btn1 { margin-left: 1%; height: 40px; @@ -411,6 +395,7 @@ .select11 { width: 20% !important; } + /deep/.el-date-editor .el-range-separator { width: 11%; } -- Gitblit v1.8.0