wkjp-list-page 1.0.32 → 1.0.33

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wkjp-list-page",
3
- "version": "1.0.32",
3
+ "version": "1.0.33",
4
4
  "description": "Vue2 + ElementUI CommonListPage component",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.js",
@@ -8,10 +8,12 @@ export default {
8
8
  column: { type: Object, required: true },
9
9
  resolveCellText: { type: Function, default: null },
10
10
  columnBind: { type: Function, default: null },
11
+ parentScopedSlots: { type: Object, default: null }, // 新增:接收父组件传递的插槽
11
12
  },
12
13
  render(h) {
13
14
  const col = this.column;
14
- const slots = this.$scopedSlots;
15
+ // 优先使用 parentScopedSlots,否则使用 $scopedSlots
16
+ const slots = this.parentScopedSlots || this.$scopedSlots;
15
17
  const resolveCellText = this.resolveCellText;
16
18
  const columnBind = this.columnBind;
17
19
 
@@ -26,6 +28,7 @@ export default {
26
28
  minWidth: parentBind.minWidth != null ? parentBind.minWidth : col.minWidth,
27
29
  headerAlign: parentBind.headerAlign,
28
30
  };
31
+
29
32
  return h(
30
33
  "el-table-column",
31
34
  { props: parentProps },
@@ -36,26 +39,64 @@ export default {
36
39
  column: child,
37
40
  resolveCellText,
38
41
  columnBind,
42
+ parentScopedSlots: slots, // 关键:继续向下传递插槽
39
43
  },
40
- scopedSlots: slots,
44
+ scopedSlots: slots, // 也传递 scopedSlots 作为备选
41
45
  }),
42
46
  ),
43
47
  );
44
48
  }
45
49
 
46
50
  const bind = typeof columnBind === "function" ? columnBind(col) || {} : {};
47
- const columnProps = Object.assign({}, bind);
51
+
52
+ // 构建 columnProps
53
+ const columnProps = Object.assign(
54
+ {
55
+ prop: col.prop,
56
+ label: col.label,
57
+ slot: col.slot,
58
+ type: col.type,
59
+ align: col.align,
60
+ fixed: col.fixed,
61
+ width: col.width,
62
+ minWidth: col.minWidth,
63
+ sortable: col.sortable,
64
+ sortMethod: col.sortMethod,
65
+ sortBy: col.sortBy,
66
+ sortOrders: col.sortOrders,
67
+ resizable: col.resizable,
68
+ formatter: col.formatter,
69
+ showOverflowTooltip: col.showOverflowTooltip,
70
+ inlineTemplate: col.inlineTemplate,
71
+ headerAlign: col.headerAlign,
72
+ className: col.className,
73
+ labelClassName: col.labelClassName,
74
+ selectable: col.selectable,
75
+ reserveSelection: col.reserveSelection,
76
+ filters: col.filters,
77
+ filterMultiple: col.filterMultiple,
78
+ filterMethod: col.filterMethod,
79
+ filteredValue: col.filteredValue,
80
+ },
81
+ bind,
82
+ );
83
+
48
84
  delete columnProps.children;
49
85
 
86
+ // 处理自定义 slot
50
87
  if (col.slot && slots[col.slot]) {
51
88
  return h("el-table-column", {
52
89
  props: columnProps,
53
90
  scopedSlots: {
54
- default: (scope) => slots[col.slot](scope),
91
+ default: (scope) => {
92
+ const slotFn = slots[col.slot];
93
+ return slotFn(scope);
94
+ },
55
95
  },
56
96
  });
57
97
  }
58
98
 
99
+ // 处理普通文本渲染
59
100
  return h("el-table-column", {
60
101
  props: columnProps,
61
102
  scopedSlots: {
@@ -70,4 +111,4 @@ export default {
70
111
  });
71
112
  },
72
113
  };
73
- </script>
114
+ </script>