mirror of
https://gitee.com/wonderful-code/buildadmin
synced 2024-11-21 22:55:36 +00:00
refactor(BaTable):表格列渲染不再使用单独的组件封装
This commit is contained in:
parent
07a91cb906
commit
a61d313f5a
@ -1,21 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { defineComponent, createVNode, reactive } from 'vue'
|
|
||||||
import { ElTableColumn } from 'element-plus'
|
|
||||||
import { uuid } from '/@/utils/random'
|
|
||||||
export default defineComponent({
|
|
||||||
name: 'Column',
|
|
||||||
props: {
|
|
||||||
attr: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
setup(props, { slots }) {
|
|
||||||
const attr = reactive(props.attr)
|
|
||||||
attr['column-key'] = attr['column-key'] ? attr['column-key'] : attr.prop || uuid()
|
|
||||||
return () => {
|
|
||||||
return createVNode(ElTableColumn, attr, slots.default)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
})
|
|
||||||
</script>
|
|
@ -24,8 +24,12 @@
|
|||||||
<!-- 渲染为 slot -->
|
<!-- 渲染为 slot -->
|
||||||
<slot v-if="item.render == 'slot'" :name="item.slotName"></slot>
|
<slot v-if="item.render == 'slot'" :name="item.slotName"></slot>
|
||||||
|
|
||||||
<!-- Column 组件内部是 el-table-column -->
|
<el-table-column
|
||||||
<Column v-else :attr="item" :key="key + '-column'">
|
v-else
|
||||||
|
:key="key + '-column'"
|
||||||
|
v-bind="item"
|
||||||
|
:column-key="(item['columnKey'] ? item['columnKey'] : `table-column-${item.prop}`) || shortUuid()"
|
||||||
|
>
|
||||||
<!-- baTable 预设的列 render 方案 -->
|
<!-- baTable 预设的列 render 方案 -->
|
||||||
<template v-if="item.render" #default="scope">
|
<template v-if="item.render" #default="scope">
|
||||||
<FieldRender
|
<FieldRender
|
||||||
@ -44,7 +48,7 @@
|
|||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</el-table-column>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
<slot name="columnAppend"></slot>
|
<slot name="columnAppend"></slot>
|
||||||
@ -66,12 +70,12 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, nextTick, inject, computed } from 'vue'
|
|
||||||
import type { ElTable, TableInstance } from 'element-plus'
|
import type { ElTable, TableInstance } from 'element-plus'
|
||||||
import Column from '/@/components/table/column/index.vue'
|
import { computed, inject, nextTick, ref } from 'vue'
|
||||||
import FieldRender from '/@/components/table/fieldRender/index.vue'
|
import FieldRender from '/@/components/table/fieldRender/index.vue'
|
||||||
import { useConfig } from '/@/stores/config'
|
import { useConfig } from '/@/stores/config'
|
||||||
import type baTableClass from '/@/utils/baTable'
|
import type baTableClass from '/@/utils/baTable'
|
||||||
|
import { shortUuid } from '/@/utils/random'
|
||||||
|
|
||||||
const config = useConfig()
|
const config = useConfig()
|
||||||
const tableRef = ref<TableInstance>()
|
const tableRef = ref<TableInstance>()
|
||||||
|
Loading…
Reference in New Issue
Block a user