From bfb69728c725d05b580f58e290cbb09b814f6fb0 Mon Sep 17 00:00:00 2001 From: guoshipeng <3194674006@qq.com> Date: Wed, 26 Jul 2023 08:58:47 +0800 Subject: [PATCH] fix --- src/views/Listdata/index.vue | 103 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 95 insertions(+), 8 deletions(-) diff --git a/src/views/Listdata/index.vue b/src/views/Listdata/index.vue index d065d2c..acc59f9 100644 --- a/src/views/Listdata/index.vue +++ b/src/views/Listdata/index.vue @@ -55,10 +55,30 @@ class="select11" /> - <el-button type="primary" @click="toExcel()" style="margin-left: 20px" + <!-- <el-button type="primary" @click="toExcel()" style="margin-left: 20px" >������</el-button + > --> + <!-- <el-dropdown @command="handleCommand"> + <el-button type="primary" @click="toExcel()" style="margin-left: 20px" + >������<i class="el-icon-arrow-down el-icon--right"></i + ></el-button> + <el-dropdown-menu slot="dropdown"> + <el-dropdown-item command="expNew">������(���)</el-dropdown-item> + </el-dropdown-menu> + </el-dropdown> --> + <el-dropdown + split-button + type="primary" + @click="toExcel()" + @command="handleCommand" + style="margin-left: 20px" > - <el-button @click="exportMon">������</el-button> + ������ + <el-dropdown-menu slot="dropdown"> + <el-dropdown-item command="expNew">������(���)</el-dropdown-item> + </el-dropdown-menu> + </el-dropdown> + <el-button @click="exportMon" style="margin-left: 10px">������</el-button> </div> <el-table :data="dateList" @@ -75,6 +95,14 @@ :key="item" > </el-table-column> + <!-- <el-table-column + v-for="item in columnList" + :prop="item.props" + :label="item.label" + width="180px" + :key="item.label" + > + </el-table-column> --> </el-table> </div> </template> @@ -175,9 +203,6 @@ // ������������ - ��������������������������������� this ��������� created() { this.getData() - // for (let key in this.timess[0]) { - // this.columnList.push(key) - // } }, // ������������ - ��������������������������� DOM ��������� // mounted() { @@ -192,6 +217,53 @@ activated() {}, // ������������ methods: { + handleCommand(command) { + if (this.newMac1 == '') { + this.$message.warning('���������������') + return + } + if (this.value == '') { + this.$message.warning('���������������') + return + } + this.dateList = [] + this.columnList = [] + this.$request({ + url: 'monitorPoint/exlOut', + method: 'post', + data: { + macs: this.newMac1, + sensors: this.value.toString(), + // startTime: this.timevalue[0], + // endTime: this.timevalue[1], + type: this.unit, + times: this.newData instanceof Array ? this.newData : [this.newData], + }, + responseType: 'blob', + }).then((res) => { + console.log('������������', res) + this.getOutExcel('������������������.xlsx', res) + }) + }, + getOutExcel(fileName, res) { + let blob = new Blob([res], { type: 'application/x-xls' }) + if (window.navigator.msSaveOrOpenBlob) { + //������ IE & EDGE + navigator.msSaveBlob(blob, fileName) + } else { + var link = document.createElement('a') + // ������������������������URL������ + const url = window.URL || window.webkitURL || window.moxURL + // ������������������ + link.href = url.createObjectURL(blob) + //������������������ + link.download = fileName + //������������������ + link.click() + //������������������������ + url.revokeObjectURL(link.href) + } + }, showPickerChild(data) { this.newData = data }, @@ -251,7 +323,6 @@ }) }, exportMon() { - console.log(this.timevalue) if (this.newMac1 == '') { this.$message.warning('���������������') return @@ -274,15 +345,31 @@ times: this.newData instanceof Array ? this.newData : [this.newData], }, }).then((res) => { - console.log(res, 11) + //console.log(res, 11) this.tableData = res.data - // console.log(this.tableData, 'this.tableData') for (let key in this.tableData[0]) { this.columnList.push(key) } for (let item of this.tableData) { this.dateList.push(item) } + // this.tableData = res.data + // for (let key in this.tableData[0]) { + // let prop = key + // if (String(key).indexOf('.') > -1) { + // prop = key.replace(/\./g, '') + // } + // this.columnList.push({ label: key, props: prop }) + // } + // for (let item of this.tableData) { + // for (let key in this.tableData[0]) { + // if (String(key).indexOf('.') > -1) { + // let newKey = key.replace(/\./g, '') + // item[newKey] = item[key] + // } + // } + // this.dateList.push(item) + // } }) }, toExcel() { -- Gitblit v1.8.0