@elementplus-kit/uikit 1.0.0 → 1.0.2
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/aaaindex.ts +55 -0
- package/components/config.ts +4 -0
- package/components/dialog/index.ts +5 -4
- package/components/dialog/src/index.ts +12 -4
- package/components/drawer/index.ts +3 -4
- package/components/drawer/src/index.ts +10 -3
- package/components/form/index.ts +4 -8
- package/components/form/src/FormItem.ts +3 -3
- package/components/form/src/index.ts +3 -2
- package/components/index.ts +41 -0
- package/components/pagination/index.ts +4 -5
- package/components/pagination/src/index.ts +10 -3
- package/components/search/index.ts +4 -56
- package/components/search/src/index-/346/272/220.vue +256 -0
- package/components/search/src/index.tsx +172 -0
- package/components/search/style/index.scss +93 -0
- package/components/table/index.ts +4 -7
- package/components/table/src/TableColumn.ts +116 -0
- package/components/table/src/index.ts +207 -8
- package/components/table/src/index2.ts +219 -0
- package/components/table/src/index3.ts +233 -0
- package/components/table2/index.ts +3 -4
- package/components/table2/src/index.ts +9 -202
- package/components/{table → table2}/src/types.ts +39 -39
- package/components//346/250/241/346/235/277/ttt.ts +3 -2
- package/components//346/250/241/346/235/277/ttt.vue +18 -0
- package/index.ts +2 -0
- package/package.json +17 -18
- package/aaaindex.js +0 -18
- package/components/index.js +0 -50
- /package/components/{table2 → table}/src/constants.ts +0 -0
- /package/components/{table2 → table}/src/tableaa.ts +0 -0
- /package/components/{table2 → table}/src/type.ts +0 -0
- /package/components/table/{style → type}/index.scss +0 -0
- /package/components/{table → table2}/src/config.ts +0 -0
- /package/components/{table → table2}/src/render.ts +0 -0
- /package/components/table2/{type → style}/index.scss +0 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineComponent,
|
|
3
|
+
h,
|
|
4
|
+
getCurrentInstance,
|
|
5
|
+
computed,
|
|
6
|
+
type ExtractPropTypes,
|
|
7
|
+
} from "vue";
|
|
8
|
+
import { ElTable, ElTableColumn } from "element-plus";
|
|
9
|
+
import {
|
|
10
|
+
defaultAttrs,
|
|
11
|
+
tableSlots,
|
|
12
|
+
tablecolumnSlots,
|
|
13
|
+
selectionColumn,
|
|
14
|
+
indexColumn,
|
|
15
|
+
} from "./constants.ts";
|
|
16
|
+
import { isArray, isObject } from "lodash-es";
|
|
17
|
+
const propsAttrs = {
|
|
18
|
+
module: {
|
|
19
|
+
// 公共参数用于业务判断
|
|
20
|
+
type: Object,
|
|
21
|
+
default: () => {},
|
|
22
|
+
},
|
|
23
|
+
// isRadio: { // 是否为单选框
|
|
24
|
+
// type: Boolean,
|
|
25
|
+
// default: false,
|
|
26
|
+
// },
|
|
27
|
+
// isCheckbox: { // 是否为复选框
|
|
28
|
+
// type: Boolean,
|
|
29
|
+
// default: false,
|
|
30
|
+
// },
|
|
31
|
+
columns: {
|
|
32
|
+
// 列数据
|
|
33
|
+
type: Array,
|
|
34
|
+
default: () => [],
|
|
35
|
+
},
|
|
36
|
+
showSelection: {
|
|
37
|
+
// 是否显示选择列
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: false,
|
|
40
|
+
},
|
|
41
|
+
showIndex: {
|
|
42
|
+
// 是否显示索引列
|
|
43
|
+
type: Boolean,
|
|
44
|
+
default: false,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type PropsAttrs = ExtractPropTypes<typeof propsAttrs>;
|
|
49
|
+
|
|
50
|
+
export default defineComponent({
|
|
51
|
+
props: propsAttrs,
|
|
52
|
+
// emits: eventList,
|
|
53
|
+
|
|
54
|
+
// attrs, emit会继承, slots需要设置
|
|
55
|
+
setup(props: PropsAttrs, { attrs, emit, slots, expose }) {
|
|
56
|
+
// 暴露elTable组件上的方法
|
|
57
|
+
const vm = getCurrentInstance(); // 获取虚拟DOM实例
|
|
58
|
+
const cTableFnRef = (el) => {
|
|
59
|
+
if (!el) return;
|
|
60
|
+
vm.exposed = el; // 设置暴露对象
|
|
61
|
+
vm.exposeProxy = el; // 设置代理暴露对象
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// 暴露方法
|
|
65
|
+
expose({
|
|
66
|
+
// tableRef,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// 属性处理
|
|
70
|
+
const getAttrs = () => {
|
|
71
|
+
const obj = {
|
|
72
|
+
...defaultAttrs, // 设置默认值
|
|
73
|
+
};
|
|
74
|
+
return obj;
|
|
75
|
+
};
|
|
76
|
+
// 事件处理
|
|
77
|
+
const getEvents = () => {
|
|
78
|
+
const obj = {
|
|
79
|
+
...defaultAttrs, // 设置默认值
|
|
80
|
+
};
|
|
81
|
+
return obj;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const columnsList = computed(() => {
|
|
85
|
+
let list = [];
|
|
86
|
+
list = getArrayColumn();
|
|
87
|
+
// 处理多选与序号列
|
|
88
|
+
if (props.showSelection) {
|
|
89
|
+
list.push(
|
|
90
|
+
h(ElTableColumn, {
|
|
91
|
+
type: "selection",
|
|
92
|
+
width: 55,
|
|
93
|
+
})
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
if (props.showIndex) {
|
|
97
|
+
list.push(
|
|
98
|
+
h(ElTableColumn, {
|
|
99
|
+
label: "序号",
|
|
100
|
+
type: "index",
|
|
101
|
+
width: 55,
|
|
102
|
+
})
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
return list;
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// 处理列数据-数组
|
|
109
|
+
const getArrayColumn = () => {
|
|
110
|
+
console.log("adsadsd");
|
|
111
|
+
// 递归处理数据
|
|
112
|
+
const list = [];
|
|
113
|
+
|
|
114
|
+
const c = (columns, list) => {
|
|
115
|
+
columns?.map((item) => {
|
|
116
|
+
const { children, ...p } = item;
|
|
117
|
+
// 递归处理子列
|
|
118
|
+
if (isArray(item.children)) {
|
|
119
|
+
item.children = c(item.children, list);
|
|
120
|
+
}
|
|
121
|
+
list.push(p);
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
c(props.columns, list);
|
|
125
|
+
console.log("🚀 ~ getArrayColumn ~ props.columns:", props.columns)
|
|
126
|
+
console.log("🚀 ~ gggggggg:", list);
|
|
127
|
+
return list;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// 渲染表格列
|
|
131
|
+
const renderTableColumn = () => {
|
|
132
|
+
const list = [];
|
|
133
|
+
|
|
134
|
+
// 列递归渲染
|
|
135
|
+
const rColumn = (columns, list) => {
|
|
136
|
+
console.log("🚀 ~ rColumn ~ columns:", columns);
|
|
137
|
+
columns?.map((item) => {
|
|
138
|
+
const { children, ...p } = item;
|
|
139
|
+
|
|
140
|
+
// 处理多级表头
|
|
141
|
+
const listSub = [];
|
|
142
|
+
if (children?.length) {
|
|
143
|
+
rColumn(children, listSub);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// 处理插槽
|
|
147
|
+
const itemSlot = {};
|
|
148
|
+
// column 自带插槽
|
|
149
|
+
tablecolumnSlots.map((name) => {
|
|
150
|
+
const slotName = `${item.prop}.${name}`;
|
|
151
|
+
if (slots[slotName]) {
|
|
152
|
+
itemSlot[name] = slots[slotName];
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// column 列插槽
|
|
157
|
+
if (slots[item.prop]) {
|
|
158
|
+
itemSlot["default"] = slots[item.prop];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// 赋值
|
|
162
|
+
if (Object.keys(itemSlot).length) {
|
|
163
|
+
list.push(
|
|
164
|
+
h(
|
|
165
|
+
ElTableColumn,
|
|
166
|
+
{ ...p, class: "c-table-column" },
|
|
167
|
+
listSub.length
|
|
168
|
+
? { ...itemSlot, default: () => listSub }
|
|
169
|
+
: { ...itemSlot }
|
|
170
|
+
)
|
|
171
|
+
);
|
|
172
|
+
} else {
|
|
173
|
+
list.push(
|
|
174
|
+
h(
|
|
175
|
+
ElTableColumn,
|
|
176
|
+
{ ...p, class: "c-table-column" },
|
|
177
|
+
listSub.length ? { default: () => listSub } : undefined
|
|
178
|
+
)
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
rColumn(columnsList.value, list);
|
|
184
|
+
return list;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
// 插槽处理
|
|
188
|
+
const getSlots = () => {
|
|
189
|
+
const obj = {};
|
|
190
|
+
tableSlots.map((name) => {
|
|
191
|
+
if (slots[name]) {
|
|
192
|
+
obj[name] = slots[name];
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
return obj;
|
|
196
|
+
};
|
|
197
|
+
// 渲染表格组件
|
|
198
|
+
const renderTable = () => {
|
|
199
|
+
// getColumnList();
|
|
200
|
+
console.log("props", props);
|
|
201
|
+
console.log("attrs", attrs);
|
|
202
|
+
return h(
|
|
203
|
+
ElTable,
|
|
204
|
+
{
|
|
205
|
+
ref: cTableFnRef,
|
|
206
|
+
...attrs,
|
|
207
|
+
class: "c-table",
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
default: () => renderTableColumn(),
|
|
211
|
+
...getSlots(),
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
// 返回渲染函数
|
|
217
|
+
return () => renderTable();
|
|
218
|
+
},
|
|
219
|
+
});
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineComponent,
|
|
3
|
+
h,
|
|
4
|
+
getCurrentInstance,
|
|
5
|
+
type ExtractPropTypes,
|
|
6
|
+
} from "vue";
|
|
7
|
+
import { ElTable, ElTableColumn } from "element-plus";
|
|
8
|
+
import {
|
|
9
|
+
defaultAttrs,
|
|
10
|
+
tableSlots,
|
|
11
|
+
tablecolumnSlots,
|
|
12
|
+
selectionColumn,
|
|
13
|
+
indexColumn,
|
|
14
|
+
} from "./constants.ts";
|
|
15
|
+
import { isArray, isObject } from "lodash-es";
|
|
16
|
+
import TableColumn from "./TableColumn.vue"
|
|
17
|
+
const propsAttrs = {
|
|
18
|
+
module: {
|
|
19
|
+
// 公共参数用于业务判断
|
|
20
|
+
type: Object,
|
|
21
|
+
default: () => {},
|
|
22
|
+
},
|
|
23
|
+
// isRadio: { // 是否为单选框
|
|
24
|
+
// type: Boolean,
|
|
25
|
+
// default: false,
|
|
26
|
+
// },
|
|
27
|
+
// isCheckbox: { // 是否为复选框
|
|
28
|
+
// type: Boolean,
|
|
29
|
+
// default: false,
|
|
30
|
+
// },
|
|
31
|
+
columns: {
|
|
32
|
+
// 列数据
|
|
33
|
+
type: Array,
|
|
34
|
+
default: () => [],
|
|
35
|
+
},
|
|
36
|
+
showSelection: {
|
|
37
|
+
// 是否显示选择列
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: false,
|
|
40
|
+
},
|
|
41
|
+
showIndex: {
|
|
42
|
+
// 是否显示索引列
|
|
43
|
+
type: Boolean,
|
|
44
|
+
default: false,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type PropsAttrs = ExtractPropTypes<typeof propsAttrs>;
|
|
49
|
+
|
|
50
|
+
export default defineComponent({
|
|
51
|
+
props: propsAttrs,
|
|
52
|
+
// emits: eventList,
|
|
53
|
+
|
|
54
|
+
// attrs, emit会继承, slots需要设置
|
|
55
|
+
setup(props: PropsAttrs, { attrs, emit, slots, expose }) {
|
|
56
|
+
provide("tableContext", {
|
|
57
|
+
tableSlots: slots,
|
|
58
|
+
events: (eProp, ...args: any) => {
|
|
59
|
+
emit(eProp, ...args);
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
// 暴露elTable组件上的方法
|
|
63
|
+
const vm = getCurrentInstance(); // 获取虚拟DOM实例
|
|
64
|
+
const cTableFnRef = (el) => {
|
|
65
|
+
if (!el) return;
|
|
66
|
+
vm.exposed = el; // 设置暴露对象
|
|
67
|
+
vm.exposeProxy = el; // 设置代理暴露对象
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// 暴露方法
|
|
71
|
+
expose({
|
|
72
|
+
// tableRef,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// 属性处理
|
|
76
|
+
const getAttrs = () => {
|
|
77
|
+
const obj = {
|
|
78
|
+
...defaultAttrs, // 设置默认值
|
|
79
|
+
};
|
|
80
|
+
return obj;
|
|
81
|
+
};
|
|
82
|
+
// 事件处理
|
|
83
|
+
const getEvents = () => {
|
|
84
|
+
const obj = {
|
|
85
|
+
...defaultAttrs, // 设置默认值
|
|
86
|
+
};
|
|
87
|
+
return obj;
|
|
88
|
+
};
|
|
89
|
+
// 插槽处理
|
|
90
|
+
const getSlots = () => {
|
|
91
|
+
const obj = {};
|
|
92
|
+
tableSlots.map((name) => {
|
|
93
|
+
if (slots[name]) {
|
|
94
|
+
obj[name] = slots[name];
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
return obj;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// // 处理列数据-数组
|
|
101
|
+
// const getArrayColumn = () => {
|
|
102
|
+
// console.log("adsadsd");
|
|
103
|
+
// // 递归处理数据
|
|
104
|
+
// const list = [];
|
|
105
|
+
|
|
106
|
+
// const c = (columns, list) => {
|
|
107
|
+
// columns?.map((item) => {
|
|
108
|
+
// const { children, ...p } = item;
|
|
109
|
+
// // 递归处理子列
|
|
110
|
+
// if (isArray(item.children)) {
|
|
111
|
+
// item.children = c(item.children, list);
|
|
112
|
+
// }
|
|
113
|
+
// list.push(p);
|
|
114
|
+
// });
|
|
115
|
+
// };
|
|
116
|
+
// c(props.columns, list);
|
|
117
|
+
// console.log("🚀 ~ gggggggg:", list);
|
|
118
|
+
// return list;
|
|
119
|
+
// };
|
|
120
|
+
|
|
121
|
+
// // 渲染表格列
|
|
122
|
+
// const renderTableColumn = () => {
|
|
123
|
+
// const list = [];
|
|
124
|
+
// // 处理多选与序号列
|
|
125
|
+
// if (props.showSelection) {
|
|
126
|
+
// list.push(
|
|
127
|
+
// h(ElTableColumn, {
|
|
128
|
+
// type: "selection",
|
|
129
|
+
// width: 55,
|
|
130
|
+
// })
|
|
131
|
+
// );
|
|
132
|
+
// }
|
|
133
|
+
// if (props.showIndex) {
|
|
134
|
+
// list.push(
|
|
135
|
+
// h(ElTableColumn, {
|
|
136
|
+
// label: "序号",
|
|
137
|
+
// type: "index",
|
|
138
|
+
// width: 55,
|
|
139
|
+
// })
|
|
140
|
+
// );
|
|
141
|
+
// }
|
|
142
|
+
|
|
143
|
+
// // 列递归渲染
|
|
144
|
+
// const rColumn = (columns, list) => {
|
|
145
|
+
// columns.map((item) => {
|
|
146
|
+
// const { children, ...p } = item;
|
|
147
|
+
|
|
148
|
+
// // 处理多级表头
|
|
149
|
+
// const listSub = [];
|
|
150
|
+
// if (children?.length) {
|
|
151
|
+
// rColumn(children, listSub);
|
|
152
|
+
// }
|
|
153
|
+
|
|
154
|
+
// // 处理插槽
|
|
155
|
+
// const itemSlot = {};
|
|
156
|
+
// // column 自带插槽
|
|
157
|
+
// tablecolumnSlots.map((name) => {
|
|
158
|
+
// const slotName = `${item.prop}.${name}`;
|
|
159
|
+
// if (slots[slotName]) {
|
|
160
|
+
// itemSlot[name] = slots[slotName];
|
|
161
|
+
// }
|
|
162
|
+
// });
|
|
163
|
+
|
|
164
|
+
// // column 列插槽
|
|
165
|
+
// if (slots[item.prop]) {
|
|
166
|
+
// itemSlot["default"] = slots[item.prop];
|
|
167
|
+
// }
|
|
168
|
+
|
|
169
|
+
// // 赋值
|
|
170
|
+
// if (Object.keys(itemSlot).length) {
|
|
171
|
+
// list.push(
|
|
172
|
+
// h(
|
|
173
|
+
// ElTableColumn,
|
|
174
|
+
// { ...p, class: "c-table-column" },
|
|
175
|
+
// listSub.length
|
|
176
|
+
// ? { ...itemSlot, default: () => listSub }
|
|
177
|
+
// : { ...itemSlot }
|
|
178
|
+
// )
|
|
179
|
+
// );
|
|
180
|
+
// } else {
|
|
181
|
+
// list.push(
|
|
182
|
+
// h(
|
|
183
|
+
// ElTableColumn,
|
|
184
|
+
// { ...p, class: "c-table-column" },
|
|
185
|
+
// listSub.length ? { default: () => listSub } : undefined
|
|
186
|
+
// )
|
|
187
|
+
// );
|
|
188
|
+
// }
|
|
189
|
+
// });
|
|
190
|
+
// };
|
|
191
|
+
// rColumn(props.columns, list);
|
|
192
|
+
// return list;
|
|
193
|
+
// };
|
|
194
|
+
|
|
195
|
+
const renderTableColumn = () => {
|
|
196
|
+
const list = []
|
|
197
|
+
const rTableColumn = (columnsList, list) => {
|
|
198
|
+
|
|
199
|
+
}
|
|
200
|
+
columns.map((item) => {
|
|
201
|
+
|
|
202
|
+
const { children, ...p } = item;
|
|
203
|
+
// 递归处理子列
|
|
204
|
+
if (isArray(item.children)) {
|
|
205
|
+
item.children = renderTableColumn(item.children);
|
|
206
|
+
}
|
|
207
|
+
})
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
TableColumn
|
|
211
|
+
// 渲染表格组件
|
|
212
|
+
const renderTable = () => {
|
|
213
|
+
// getColumnList();
|
|
214
|
+
console.log("props", props);
|
|
215
|
+
console.log("attrs", attrs);
|
|
216
|
+
return h(
|
|
217
|
+
ElTable,
|
|
218
|
+
{
|
|
219
|
+
ref: cTableFnRef,
|
|
220
|
+
...attrs,
|
|
221
|
+
class: "c-table",
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
default: () => renderTableColumn(),
|
|
225
|
+
...getSlots(),
|
|
226
|
+
}
|
|
227
|
+
);
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
// 返回渲染函数
|
|
231
|
+
return () => renderTable();
|
|
232
|
+
},
|
|
233
|
+
});
|
|
@@ -1,205 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
defaultAttrs,
|
|
5
|
-
tableSlots,
|
|
6
|
-
tablecolumnSlots,
|
|
7
|
-
selectionColumn,
|
|
8
|
-
indexColumn,
|
|
9
|
-
} from "./constants.ts";
|
|
10
|
-
import { isArray, isObject } from "lodash-es";
|
|
11
|
-
const propsAttrs = {
|
|
12
|
-
module: {
|
|
13
|
-
// 公共参数用于业务判断
|
|
14
|
-
type: Object,
|
|
15
|
-
default: () => {},
|
|
16
|
-
},
|
|
17
|
-
// isRadio: { // 是否为单选框
|
|
18
|
-
// type: Boolean,
|
|
19
|
-
// default: false,
|
|
20
|
-
// },
|
|
21
|
-
// isCheckbox: { // 是否为复选框
|
|
22
|
-
// type: Boolean,
|
|
23
|
-
// default: false,
|
|
24
|
-
// },
|
|
25
|
-
columns: {
|
|
26
|
-
// 列数据
|
|
27
|
-
type: Array,
|
|
28
|
-
default: () => [],
|
|
29
|
-
},
|
|
30
|
-
showSelection: {
|
|
31
|
-
// 是否显示选择列
|
|
32
|
-
type: Boolean,
|
|
33
|
-
default: false,
|
|
34
|
-
},
|
|
35
|
-
showIndex: {
|
|
36
|
-
// 是否显示索引列
|
|
37
|
-
type: Boolean,
|
|
38
|
-
default: false,
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export type PropsAttrs = ExtractPropTypes<typeof propsAttrs>;
|
|
43
|
-
|
|
44
|
-
export default {
|
|
45
|
-
props: propsAttrs,
|
|
46
|
-
// emits: eventList,
|
|
47
|
-
|
|
48
|
-
// attrs, emit会继承, slots需要设置
|
|
49
|
-
setup(props: PropsAttrs, { attrs, emit, slots, expose }) {
|
|
50
|
-
// 暴露elTable组件上的方法
|
|
51
|
-
const vm = getCurrentInstance(); // 获取虚拟DOM实例
|
|
52
|
-
const cTableFnRef = (el) => {
|
|
53
|
-
if (!el) return;
|
|
54
|
-
vm.exposed = el; // 设置暴露对象
|
|
55
|
-
vm.exposeProxy = el; // 设置代理暴露对象
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
// 暴露方法
|
|
59
|
-
expose({
|
|
60
|
-
// tableRef,
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
// 属性处理
|
|
64
|
-
const getAttrs = () => {
|
|
65
|
-
const obj = {
|
|
66
|
-
...defaultAttrs, // 设置默认值
|
|
67
|
-
};
|
|
68
|
-
return obj;
|
|
69
|
-
};
|
|
70
|
-
// 事件处理
|
|
71
|
-
const getEvents = () => {
|
|
72
|
-
const obj = {
|
|
73
|
-
...defaultAttrs, // 设置默认值
|
|
74
|
-
};
|
|
75
|
-
return obj;
|
|
76
|
-
};
|
|
1
|
+
import { defineComponent } from "vue";
|
|
2
|
+
import render from "./render.ts";
|
|
77
3
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const c = (columns, list) => {
|
|
85
|
-
columns?.map((item) => {
|
|
86
|
-
const { children, ...p } = item;
|
|
87
|
-
// 递归处理子列
|
|
88
|
-
if (isArray(item.children)) {
|
|
89
|
-
item.children = c(item.children, list);
|
|
90
|
-
}
|
|
91
|
-
list.push(p);
|
|
92
|
-
});
|
|
93
|
-
};
|
|
94
|
-
c(props.columns, list);
|
|
95
|
-
console.log("🚀 ~ gggggggg:", list);
|
|
96
|
-
return list;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
// 渲染表格列
|
|
100
|
-
const renderTableColumn = () => {
|
|
101
|
-
const list = [];
|
|
102
|
-
// 处理多选与序号列
|
|
103
|
-
if (props.showSelection) {
|
|
104
|
-
list.push(
|
|
105
|
-
h(ElTableColumn, {
|
|
106
|
-
type: "selection",
|
|
107
|
-
width: 55,
|
|
108
|
-
})
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
if (props.showIndex) {
|
|
112
|
-
list.push(
|
|
113
|
-
h(ElTableColumn, {
|
|
114
|
-
label: "序号",
|
|
115
|
-
type: "index",
|
|
116
|
-
width: 55,
|
|
117
|
-
})
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// 列递归渲染
|
|
122
|
-
const rColumn = (columns, list) => {
|
|
123
|
-
columns.map((item) => {
|
|
124
|
-
const { children, ...p } = item;
|
|
125
|
-
|
|
126
|
-
// 处理多级表头
|
|
127
|
-
const listSub = [];
|
|
128
|
-
if (children?.length) {
|
|
129
|
-
rColumn(children, listSub);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// 处理插槽
|
|
133
|
-
const itemSlot = {};
|
|
134
|
-
// column 自带插槽
|
|
135
|
-
tablecolumnSlots.map((name) => {
|
|
136
|
-
const slotName = `${item.prop}.${name}`;
|
|
137
|
-
if (slots[slotName]) {
|
|
138
|
-
itemSlot[name] = slots[slotName];
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
// column 列插槽
|
|
143
|
-
if (slots[item.prop]) {
|
|
144
|
-
itemSlot["default"] = slots[item.prop];
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// 赋值
|
|
148
|
-
if (Object.keys(itemSlot).length) {
|
|
149
|
-
list.push(
|
|
150
|
-
h(
|
|
151
|
-
ElTableColumn,
|
|
152
|
-
{ ...p, class: "c-table-column" },
|
|
153
|
-
listSub.length
|
|
154
|
-
? { ...itemSlot, default: () => listSub }
|
|
155
|
-
: { ...itemSlot }
|
|
156
|
-
)
|
|
157
|
-
);
|
|
158
|
-
} else {
|
|
159
|
-
list.push(
|
|
160
|
-
h(
|
|
161
|
-
ElTableColumn,
|
|
162
|
-
{ ...p, class: "c-table-column" },
|
|
163
|
-
listSub.length ? { default: () => listSub } : undefined
|
|
164
|
-
)
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
};
|
|
169
|
-
rColumn(props.columns, list);
|
|
170
|
-
return list;
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
// 插槽处理
|
|
174
|
-
const getSlots = () => {
|
|
175
|
-
const obj = {};
|
|
176
|
-
tableSlots.map((name) => {
|
|
177
|
-
if (slots[name]) {
|
|
178
|
-
obj[name] = slots[name];
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
return obj;
|
|
182
|
-
};
|
|
183
|
-
// 渲染表格组件
|
|
184
|
-
const renderTable = () => {
|
|
185
|
-
// getColumnList();
|
|
186
|
-
console.log("props", props);
|
|
187
|
-
console.log("attrs", attrs);
|
|
188
|
-
return h(
|
|
189
|
-
ElTable,
|
|
190
|
-
{
|
|
191
|
-
ref: cTableFnRef,
|
|
192
|
-
...attrs,
|
|
193
|
-
class: "c-table",
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
default: () => renderTableColumn(),
|
|
197
|
-
...getSlots(),
|
|
198
|
-
}
|
|
199
|
-
);
|
|
4
|
+
export default defineComponent({
|
|
5
|
+
props: ["schema", "data"],
|
|
6
|
+
emits: [],
|
|
7
|
+
setup(props: any, { attrs, emit, slots, expose }) {
|
|
8
|
+
return () => {
|
|
9
|
+
return render(props.schema, props.data, emit, slots);
|
|
200
10
|
};
|
|
201
|
-
|
|
202
|
-
// 返回渲染函数
|
|
203
|
-
return () => renderTable();
|
|
204
11
|
},
|
|
205
|
-
};
|
|
12
|
+
});
|