From 333da8433e763d7cdb362cb3a18dc0fc012a5bfc Mon Sep 17 00:00:00 2001 From: lb Date: Mon, 8 Aug 2022 10:54:23 +0800 Subject: [PATCH] update base-table --- .../base-table/components/detailComponent.js | 34 ++++++++++ .../components/operationComponent.js | 45 ++++++++++++ src/views/modules/monitoring/equipment.vue | 68 ++----------------- 3 files changed, 86 insertions(+), 61 deletions(-) create mode 100644 src/components/base-table/components/detailComponent.js create mode 100644 src/components/base-table/components/operationComponent.js diff --git a/src/components/base-table/components/detailComponent.js b/src/components/base-table/components/detailComponent.js new file mode 100644 index 0000000..18b98bd --- /dev/null +++ b/src/components/base-table/components/detailComponent.js @@ -0,0 +1,34 @@ +/** + * @Author: lb + * @CreateDate: 2022.8.8 + * @Modifier: + * @ModifiedDate: + * 表格里的文本组件 + * 一般用途:展示查看详情入口 + */ +export default { + name: 'TableTextComponent', + props: { + injectData: { + type: Object, + default: () => ({}) + } + }, + data() { + return { + // for i18n inject: + defaultText: '查看详情' + } + }, + methods: { + emitClick() { + this.$emit('emitData', { + action: this.injectData.actionName || 'view-detail-action', + data: this.injectData.emitFullData ? this.injectData : { id: this.injectData.id } + }) + } + }, + render: function (h) { + return h('span', null, [h('el-button', { props: { type: 'text' }, style: { paddingLeft: 0 } }, this.injectData.buttonContent || this.defaultText)]) + } +} \ No newline at end of file diff --git a/src/components/base-table/components/operationComponent.js b/src/components/base-table/components/operationComponent.js new file mode 100644 index 0000000..96e2756 --- /dev/null +++ b/src/components/base-table/components/operationComponent.js @@ -0,0 +1,45 @@ +/** + * @Author: lb + * @CreateDate: 2022.8.8 + * @Modifier: + * @ModifiedDate: + * 表格里的操作组件 + * 一般用途:展示添加删除按钮 + */ +export default { + name: 'TableOperations', + props: { + injectData: { + type: Object, + default: () => ({}) + } + }, + data() { + return { + btnTypes: { + add: 'primary', + delete: 'danger', + detail: 'info' + // add more... + }, + colors: { + // add more... + }, + text: { + // for i18n inject: + add: '添加' + // add more... + } + } + }, + methods: { + // 发射事件 + }, + render: function (h) { + let btns = [] + for (const optionStr of this.injectData.head?.options) { + btns.push(h('el-button', { props: { type: this.btnTypes[optionStr] } }, optionStr)) + } + return h('span', null, btns) + } +} \ No newline at end of file diff --git a/src/views/modules/monitoring/equipment.vue b/src/views/modules/monitoring/equipment.vue index 22a4c8b..f9d9d49 100644 --- a/src/views/modules/monitoring/equipment.vue +++ b/src/views/modules/monitoring/equipment.vue @@ -71,46 +71,10 @@