<template>
|
<template v-for="column in columns" :key="column.id">
|
<el-table-column
|
v-if="column.isShow && !otherType.includes(column.type)"
|
:prop="column.prop"
|
:label="column.label"
|
v-bind="column.table"
|
>
|
<template #default="scope">
|
{{ formatData(column.format, getProperty(scope.row, column.prop)) }}
|
</template>
|
</el-table-column>
|
|
<el-table-column
|
v-if="column.isShow && column.type === 'dict'"
|
:prop="column.prop"
|
:label="column.label"
|
v-bind="column.table"
|
>
|
<template #default="scope">
|
{{ formatData(column.format, column.options.dict[getProperty(scope.row, column.prop)]) }}
|
</template>
|
</el-table-column>
|
|
<el-table-column
|
v-if="column.isShow && column.type === 'select'"
|
:prop="column.prop"
|
:label="column.label"
|
v-bind="column.table"
|
>
|
<template #default="scope">
|
{{ formatData(column.format, column.options.select[getProperty(scope.row, column.prop)]) }}
|
</template>
|
</el-table-column>
|
|
<el-table-column
|
v-if="column.isShow && column.type === 'slot'"
|
:prop="column.prop"
|
:label="column.label"
|
v-bind="column.table"
|
>
|
<template #default="scope">
|
<slot :name="`table-${column.prop}`" v-bind="scope"/>
|
</template>
|
</el-table-column>
|
</template>
|
</template>
|
|
<script setup>
|
|
import {getProperty} from "@/utils/tools.js";
|
|
const props = defineProps({
|
columns: {
|
type: Array,
|
default: []
|
},
|
});
|
|
const otherType = ['slot', 'dict', 'select'];
|
|
const formatData = (format, data) => {
|
return format ? format(data) : (data || '')
|
}
|
|
</script>
|
|
<style lang='scss' scoped>
|
</style>
|