factory-ui/src/components/TableFormCol/index.vue

64 lines
1.4 KiB
Vue
Raw Normal View History

2024-12-17 18:17:53 +08:00
<template>
2024-12-20 18:00:49 +08:00
<el-table-column class="table-form-col" align="center" :width="width" :show-overflow-tooltip="showOverflowTooltip">
2024-12-17 18:17:53 +08:00
<template #header>
<span :class="required ? 'required-label' : ''">{{label}}</span>
</template>
<template scope="d">
2024-12-18 18:06:45 +08:00
<form-col table label-width="0" :prop="colProp(d.$index)" :rules="rules">
2024-12-17 18:17:53 +08:00
<slot :row="d.row"/>
</form-col>
</template>
</el-table-column>
</template>
<script>
import FormCol from '@/components/FormCol/index.vue'
import HoverShow from '@/components/HoverShow/index.vue'
2024-12-18 18:06:45 +08:00
import { isEmpty } from '@/utils'
2024-12-17 18:17:53 +08:00
export default {
name: "TableFormCol",
components: { HoverShow, FormCol },
props: {
label: {
type: String,
default: null,
},
required: {
type: Boolean,
default: false,
},
2024-12-18 18:06:45 +08:00
propPrefix: {
type: String,
default: null,
},
2024-12-17 18:17:53 +08:00
prop: {
type: String,
default: null,
},
rules: {
type: Array,
default: () => ([])
},
width: {
type: String,
default: null,
},
showOverflowTooltip: {
type: Boolean,
default: false,
}
2024-12-18 18:06:45 +08:00
},
computed: {
colProp() {
return (index) => {
if (isEmpty(this.propPrefix) || isEmpty(this.prop)) {
return null;
}
return `${this.propPrefix}[${index}].${this.prop}`;
}
}
2024-12-17 18:17:53 +08:00
}
}
</script>