<template>
<div class="table-wrap">
<el-table ref="display-table" :data="tableData" border style="width: 100%; font-size: 12px;">
<el-table-column v-for="(column, index) in propsArr" :key="index"
:type="(column.type && ['index', 'selection', 'expand'].includes(column.type)) ? column.type : null"
:prop="column.prop" :label="column.label"
:show-overflow-tooltip="[true, false].includes(column.toolTip) ? column.toolTip : true"
:align="column.align ? column.align : 'center'" :width="column.width ? column.width : 'auto'">
<template v-if="!(column.type && ['index', 'selection', 'expand'].includes(column.type))" v-slot="scope">
<span v-if="column.render" :style="column.style ? column.style : {}">
{{ renderHtml(column, scope) }}
<slot :name="'renderHtml'" />
</span>
<span v-else :style="column.style ? column.style : {}">{{ scope.row[column.prop] }}</span>
</template>
</el-table-column>
</el-table>
</div>
</template>
<script>
export default {
name: 'TableDisplayProp',
props: {
tableData: {
type: Array,
default: () => []
},
propsArr: {
type: Array,
default: () => []
}
},
data() {
return {
}
},
watch: {
propsArr: {
handler() {
this.$refs?.['display-table']?.doLayout()
},
deep: true
},
tableData(nv) {
}
},
created() {
},
methods: {
renderHtml(col, scope) {
if (typeof col.render === 'function') {
this.$slots['renderHtml'] = col.render(this.$createElement, scope)
}
return null
}
}
}
</script>