From 0b4433dd80f82a57acd31ad29392f85f5fbe348d Mon Sep 17 00:00:00 2001 From: g7hoo Date: Mon, 22 Aug 2022 11:26:57 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E5=9F=BA=E6=9C=AC=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/operationComponent.js | 23 ++++++++++++++--- src/views/modules/monitoring/reportDetail.vue | 25 ++++++++++++++++++- .../modules/monitoring/reportPreview.vue | 6 +++-- 3 files changed, 47 insertions(+), 7 deletions(-) diff --git a/src/components/base-table/components/operationComponent.js b/src/components/base-table/components/operationComponent.js index 33e400b..d91436d 100644 --- a/src/components/base-table/components/operationComponent.js +++ b/src/components/base-table/components/operationComponent.js @@ -24,6 +24,8 @@ export default { }, colors: { delete: '#FF5454', + preview: '#f09843', + design: '#99089f' // add more... }, text: { @@ -31,22 +33,35 @@ export default { edit: '编辑', detail: '详情', delete: '删除', - viewAttr: '查看属性' + viewAttr: '查看属性', + preview: '预览', + design: '设计' // add more... } } }, methods: { // 发射事件 - emit(eventType) { - this.$emit('emit-data', { type: eventType, data: this.injectData.head?.emitFullData ? this.injectData : this.injectData.id }) + emit(opt) { + let emitFull = false + let eventType = 'default' + let customField + if (typeof opt === 'object') { + eventType = opt.name + customField = opt.emitField || 'id' + emitFull = opt.emitFull || false + } else { + eventType = opt + } + this.$emit('emit-data', { type: eventType, data: emitFull ? this.injectData : customField ? this.injectData[customField] : this.injectData.id }) } }, render: function (h) { let btns = [] for (const optionStr of this.injectData.head?.options) { + const optObj = typeof optionStr === 'object' // btns.push(h('el-button', { props: { type: this.btnTypes[optionStr] } }, optionStr)) - btns.push(h('el-button', { props: { type: 'text' }, style: { color: this.colors[optionStr] || '#409EFF' }, on: { click: this.emit.bind(null, optionStr) } }, this.text[optionStr])) + btns.push(h('el-button', { props: { type: 'text' }, style: { color: optObj ? this.colors[optionStr.name] : this.colors[optionStr] || '#409EFF' }, on: { click: this.emit.bind(null, optionStr) } }, typeof optionStr === 'object' ? this.text[optionStr.name] : this.text[optionStr])) } return h('span', null, btns) } diff --git a/src/views/modules/monitoring/reportDetail.vue b/src/views/modules/monitoring/reportDetail.vue index fbc7a5e..7642fd1 100644 --- a/src/views/modules/monitoring/reportDetail.vue +++ b/src/views/modules/monitoring/reportDetail.vue @@ -120,12 +120,20 @@ export default { { prop: 'createTime', name: '创建时间', width: 200 }, { prop: 'fileName', name: '报表名称' }, { prop: 'category', name: '报表分类', subcomponent: CategoryList, options: categories }, - { prop: 'operations', name: '操作', fixed: 'right', width: 180, subcomponent: TableOperateComponent, options: ['preview', 'design', 'edit', 'delete'] } + { + prop: 'operations', + name: '操作', + fixed: 'right', + width: 180, + subcomponent: TableOperateComponent, + options: [{ name: 'preview', emitField: 'fileName' }, { name: 'design', emitField: 'name' }, 'edit', 'delete'] + } ] } }) }, handleOperations({ type, data }) { + console.log('operation data: ', data) let id = data switch (type) { case 'change-category': @@ -134,6 +142,21 @@ export default { return this.addOrUpdateHandle(id) case 'delete': return this.deleteHandle(id) + case 'design': + return this.$router.push({ + name: 'monitoring-reportDesign', + query: { + // data 的数据是 emitField 的值 + name: data + } + }) + case 'preview': + return this.$router.push({ + name: 'monitoring-reportPreview', + query: { + name: data + } + }) } }, updateCategory({ id, fileName, categoryId }) { diff --git a/src/views/modules/monitoring/reportPreview.vue b/src/views/modules/monitoring/reportPreview.vue index f3017c9..5eef7fe 100644 --- a/src/views/modules/monitoring/reportPreview.vue +++ b/src/views/modules/monitoring/reportPreview.vue @@ -7,14 +7,16 @@ -->