From 93b401071a120f70fbda3039e0155a7749dfa980 Mon Sep 17 00:00:00 2001 From: g7hoo Date: Thu, 18 Aug 2022 09:01:06 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E5=9F=BA=E6=9C=AC=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=E7=AE=A1=E7=90=86=E5=92=8C=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E8=B5=84=E6=96=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/base-dialog/AttrForm/index.vue | 6 +- .../base-dialog/addOrUpdate/index.vue | 38 +++++++++---- src/components/base-upload/index.vue | 6 +- src/views/modules/monitoring/equipment.vue | 55 +++++++++++++------ 4 files changed, 76 insertions(+), 29 deletions(-) diff --git a/src/components/base-dialog/AttrForm/index.vue b/src/components/base-dialog/AttrForm/index.vue index 9d0bdce..bc29764 100644 --- a/src/components/base-dialog/AttrForm/index.vue +++ b/src/components/base-dialog/AttrForm/index.vue @@ -1,6 +1,6 @@ + 返回 @@ -347,7 +362,8 @@ export default { } }, - init(id) { + init(id, isdetail = false) { + this.isDetail = isdetail this.visible = true this.$nextTick(() => { this.$refs['dataForm'].resetFields() diff --git a/src/components/base-upload/index.vue b/src/components/base-upload/index.vue index 94562c1..7873bdd 100644 --- a/src/components/base-upload/index.vue +++ b/src/components/base-upload/index.vue @@ -13,7 +13,7 @@ - {{ buttonContent }} + {{ buttonContent }}
{{ tip }}
@@ -39,6 +39,10 @@ export default { // 从外部传进来 fileList,用于展示文件列表用 type: Array, default: () => [] + }, + readOnly: { + type: Boolean, + default: false } }, // inject: { diff --git a/src/views/modules/monitoring/equipment.vue b/src/views/modules/monitoring/equipment.vue index 8e3b289..30fb4f8 100644 --- a/src/views/modules/monitoring/equipment.vue +++ b/src/views/modules/monitoring/equipment.vue @@ -6,8 +6,8 @@ 查询 - test 新增 + 导出 @@ -163,7 +163,7 @@ const addOrUpdateConfigs = { { prop: 'createTime', name: '创建时间' }, { prop: 'attrName', name: '属性名称', formField: true }, { prop: 'attrValue', name: '属性值', formField: true }, - { prop: 'operate', name: '操作', options: ['edit', 'delete'] } + { prop: 'operations', name: '操作', fixed: 'right', width: 180, subcomponent: TableOperateComponent, options: ['edit', 'delete'] } ] }, operations: [ @@ -272,31 +272,54 @@ export default { switch (type) { case 'view-detail': // const { name, code } = this.dataList.find(item => item.id === id) - this.$router.push({ - name: 'monitoring-equipmentAdd', - params: { - isdetail: true, - equipmentId: id - } - }) - break + // this.$router.push({ + // name: 'monitoring-equipmentAdd', + // params: { + // isdetail: true, + // equipmentId: id + // } + // }) + // break + return this.addOrUpdateHandle(id, true) case 'edit': return this.addOrUpdateHandle(id) case 'delete': return this.deleteHandle(id) } }, - test() { - this.addOrUpdateVisible = true - this.$nextTick(() => { - this.$refs.addOrUpdate.init() + exportHandle() { + // this.$http.get(this.$http.adornUrl('/monitoring/equipment/export')).then(({ data: res }) => { + this.$http({ url: this.$http.adornUrl('/monitoring/equipment/export'), method: 'get', responseType: 'blob' }).then(res => { + let fileName = 'equipment-list.xls' + if (res.headers['content-disposition']) { + const contentDisposition = res.headers['content-disposition'] + fileName = contentDisposition.slice(contentDisposition.indexOf('filename=') + 9) + } + + fileName = decodeURIComponent(fileName) + + const blob = new Blob([res.data]) + + if ('download' in document.createElement('a')) { + const alink = document.createElement('a') + alink.download = fileName + alink.style.display = 'none' + alink.target = '_blank' + alink.href = URL.createObjectURL(blob) + document.body.appendChild(alink) + alink.click() + URL.revokeObjectURL(alink.href) + document.body.removeChild(alink) + } else { + navigator.msSaveBlob(blob, fileName) + } }) }, // 新增 / 修改 - addOrUpdateHandle(id) { + addOrUpdateHandle(id, isdetail = false) { this.addOrUpdateVisible = true this.$nextTick(() => { - this.$refs.addOrUpdate.init(id) + this.$refs.addOrUpdate.init(id, isdetail) }) // this.$router.push({ // name: 'monitoring-equipmentAdd',