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',