ol-base-components 2.5.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,80 @@
1
+ <!-- src/package/table/src/TableColumn.vue -->
2
+ <template>
3
+ <el-table-column
4
+ :key="`${column.prop}-${column.show}`"
5
+ v-if="shouldShow"
6
+ :label="column.label"
7
+ :prop="column.prop"
8
+ :min-width="column.minWidth || '150px'"
9
+ :show-overflow-tooltip="column.overHidden || true"
10
+ :type="column.type || 'normal'"
11
+ v-bind="{
12
+ align: 'center',
13
+ width: column.width,
14
+ fixed: column.fixed || false,
15
+ sortable: column.sortable || false,
16
+ ...column.attrs,
17
+ }"
18
+ >
19
+ <!-- 表头插槽 -->
20
+ <template v-slot:header>
21
+ <el-tooltip
22
+ v-if="column.prop"
23
+ :content="`${column.label} ${column.prop} ${column.show}`"
24
+ placement="top"
25
+ >
26
+ <span>{{ column.label }}</span>
27
+ </el-tooltip>
28
+ <!-- 多级表头无prop无需提示 -->
29
+ <span v-else>{{ column.label }}</span>
30
+ </template>
31
+
32
+ <!-- 递归渲染子列 -->
33
+ <template v-if="column.children && column.children.length">
34
+ <TableColumn v-for="(child, idx) in column.children" :key="idx" :column="child">
35
+ <!-- 透传插槽 -->
36
+ <template v-for="(slotFn, name) in $scopedSlots" v-slot:[name]="slotProps">
37
+ <slot :name="name" v-bind="slotProps" />
38
+ </template>
39
+ </TableColumn>
40
+ </template>
41
+ <!-- 内容插槽:自定义渲染 -->
42
+ <template v-else-if="column.render" v-slot="scope">
43
+ <render-dom :render="() => column.render(scope.row)" />
44
+ </template>
45
+ <template v-else-if="column.renderSlot" v-slot="scope">
46
+ <slot :row="scope.row" :name="column.prop" />
47
+ </template>
48
+ </el-table-column>
49
+ </template>
50
+ <script>
51
+ export default {
52
+ name: "TableColumn",
53
+ components: {
54
+ renderDom: {
55
+ functional: true,
56
+ props: { render: Function },
57
+ render(h, ctx) {
58
+ return <div>{ctx.props.render()}</div>;
59
+ },
60
+ },
61
+ TableColumn: null, // 递归自身,见下方
62
+ },
63
+ props: {
64
+ column: { type: Object, required: true },
65
+ },
66
+ data() {
67
+ return {};
68
+ },
69
+ // beforeCreate() {
70
+ // // 递归注册自身
71
+ // this.$options.components.TableColumn = require("./TableColumn.vue").default;
72
+ // },
73
+ computed: {
74
+ shouldShow() {
75
+ if (this.column.hasOwnProperty("show")) return this.column.show;
76
+ return true;
77
+ },
78
+ },
79
+ };
80
+ </script>