diff --git a/src/components/base-table/index.vue b/src/components/base-table/index.vue index 506d39e..43ea43f 100644 --- a/src/components/base-table/index.vue +++ b/src/components/base-table/index.vue @@ -1,33 +1,41 @@ @@ -36,27 +44,27 @@ export default { name: 'BaseTable', props: { - tableHeadConfigs: { - type: Array, - default: () => [] - }, + tableHeadConfigs: { + type: Array, + default: () => [] + }, data: { type: Array, default: () => [] }, - maxHeight: { - type: Number, - default: 500 - } + maxHeight: { + type: Number, + default: 500 + } }, filters: { commonFilter: (source, filterType = a => a) => { return filterType(source) } }, - data () { - return {} - }, + data() { + return {} + }, methods: { handleSubEmitData(payload) { this.$emit('operate-event', payload) diff --git a/src/views/modules/monitoring/equipment.vue b/src/views/modules/monitoring/equipment.vue index 0d050cf..22a4c8b 100644 --- a/src/views/modules/monitoring/equipment.vue +++ b/src/views/modules/monitoring/equipment.vue @@ -12,6 +12,7 @@ + @@ -72,9 +73,54 @@ import BaseTable from '@/components/base-table' import AddOrUpdate from './equipment-add-or-update' +const TableOperateComponent = { + 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) + } +} + const tableConfigs = [ - { type: 'selection' }, - { type: 'index', name: 'No' }, + { + type: 'index', + name: '序号', + more: { + index: function(index) { + return (index + 1) * 2 + } + } + }, { prop: 'id', name: 'id' }, { prop: 'code', name: '编码' }, { prop: 'name', name: '设备名称' }, @@ -95,12 +141,13 @@ const tableConfigs = [ { prop: 'valid', name: '删除标志,是否有效:1 可用 0不可用' }, { prop: 'creatorId', name: '创建人' }, { prop: 'creatorName', name: '创建人姓名' }, - { prop: 'createTime', name: '创建时间' }, + { prop: 'createTime', name: '添加时间' }, { prop: 'updaterId', name: '更新人' }, { prop: 'updaterName', name: '更新人姓名' }, { prop: 'updateTime', name: '更新时间' }, { prop: 'version', name: '版本号' }, - { prop: 'externalCode', name: '外部系统代码' } + { prop: 'externalCode', name: '外部系统代码' }, + { prop: 'operations', name: '操作', fixed: 'right', width: 180, subcomponent: TableOperateComponent, options: ['add', 'detail', 'delete'] } ] export default {