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

89 lines
2.0 KiB
Vue
Raw Normal View History

2024-12-17 18:17:53 +08:00
<template>
2025-01-06 17:38:48 +08:00
<el-table-column class="table-form-col" :align="align" :width="width" >
2024-12-17 18:17:53 +08:00
<template #header>
<span :class="required ? 'required-label' : ''">{{label}}</span>
2024-12-26 18:03:22 +08:00
<el-tooltip v-if="!isEmpty(tips)" :content="tips" placement="top">
<i class="el-icon-question" style="cursor: pointer;"/>
</el-tooltip>
2024-12-17 18:17:53 +08:00
</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-26 18:03:22 +08:00
<el-popover
v-if="showOverflowTooltip"
placement="top"
width="250"
trigger="hover">
<slot name="content-tip" :row="d.row" :index="d.$index"/>
<template #reference>
<slot :row="d.row" :index="d.$index"/>
</template>
</el-popover>
<slot v-else :row="d.row" :index="d.$index"/>
2024-12-17 18:17:53 +08:00
</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: {
2024-12-26 18:03:22 +08:00
align: {
type: String,
default: "center"
},
2024-12-17 18:17:53 +08:00
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-26 18:03:22 +08:00
},
tips: {
type: String,
default: null,
2024-12-17 18:17:53 +08:00
}
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-26 18:03:22 +08:00
},
methods: {
isEmpty,
2024-12-17 18:17:53 +08:00
}
}
</script>