@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,172 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ref,
|
|
3
|
+
computed,
|
|
4
|
+
defineComponent,
|
|
5
|
+
} from "vue";
|
|
6
|
+
|
|
7
|
+
import { CForm, CDrawer } from "@elementplus-kit/uikit";
|
|
8
|
+
import { ArrowUpBold } from "@element-plus/icons-vue";
|
|
9
|
+
import '../style/index.scss';
|
|
10
|
+
|
|
11
|
+
export default defineComponent({
|
|
12
|
+
props: {
|
|
13
|
+
modelValue: {
|
|
14
|
+
type: Object,
|
|
15
|
+
default: {}
|
|
16
|
+
},
|
|
17
|
+
formOptions: {
|
|
18
|
+
type: Array,
|
|
19
|
+
default: () => []
|
|
20
|
+
},
|
|
21
|
+
isDrawer: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: false
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
emits: ['update:modelValue', 'search', 'reset', 'close'],
|
|
27
|
+
|
|
28
|
+
setup(props, { emit, slots, attrs, expose }) {
|
|
29
|
+
// 自己的 slot
|
|
30
|
+
const slotsList = ["active", "btn-left", "btn-right"];
|
|
31
|
+
// console.log('slots', slots);
|
|
32
|
+
// console.log('attrs', attrs);
|
|
33
|
+
// 解析 attrs 中的事件
|
|
34
|
+
const getEvent = () => {
|
|
35
|
+
let formObj: any = {};
|
|
36
|
+
Object.keys(attrs)?.forEach((name) => {
|
|
37
|
+
if (name.indexOf("on") === 0) {
|
|
38
|
+
formObj[name] = attrs[name];
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
return formObj
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// 解析插槽
|
|
45
|
+
const getSlot = () => {
|
|
46
|
+
let formObj = {};
|
|
47
|
+
Object.keys(slots).forEach((key) => {
|
|
48
|
+
if (!slotsList.includes(key)) {
|
|
49
|
+
formObj[key] = slots[key];
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return formObj
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// 搜索
|
|
56
|
+
const handleSearch = () => {
|
|
57
|
+
emit("search");
|
|
58
|
+
showSearchForm.value = false;
|
|
59
|
+
};
|
|
60
|
+
// 重置
|
|
61
|
+
const handleReset = () => {
|
|
62
|
+
emit("reset");
|
|
63
|
+
};
|
|
64
|
+
// 关闭
|
|
65
|
+
const handleClose = () => {
|
|
66
|
+
showSearchForm.value = false;
|
|
67
|
+
emit("close");
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const showCountC = computed(() => {
|
|
71
|
+
return props.showCount;
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const showCount = ref(3); // 显示个数
|
|
75
|
+
const showSearchForm = ref(false); // 显示搜索表单
|
|
76
|
+
const handleShow = () => {
|
|
77
|
+
showSearchForm.value = !showSearchForm.value;
|
|
78
|
+
};
|
|
79
|
+
return () => (
|
|
80
|
+
<div className="c-search">
|
|
81
|
+
<div className="c-search-simple">
|
|
82
|
+
<div className="c-search-simple-form">
|
|
83
|
+
<CForm
|
|
84
|
+
{...getEvent()}
|
|
85
|
+
inline
|
|
86
|
+
model={props.modelValue}
|
|
87
|
+
formOptions={props.formOptions?.filter(
|
|
88
|
+
(item, index) => index < showCount.value
|
|
89
|
+
)}
|
|
90
|
+
ref="formRef"
|
|
91
|
+
>
|
|
92
|
+
{getSlot()}
|
|
93
|
+
</CForm>
|
|
94
|
+
</div>
|
|
95
|
+
<div className="c-search-simple-btn">
|
|
96
|
+
{slots["btn-left"]?.()}
|
|
97
|
+
{showCount.value < props.formOptions?.length && (
|
|
98
|
+
<div
|
|
99
|
+
className={
|
|
100
|
+
`c-search-simple-icon ${showSearchForm.value ? "icon-rotate" : ""}`
|
|
101
|
+
}
|
|
102
|
+
onClick={handleShow}
|
|
103
|
+
>
|
|
104
|
+
<el-icon className="el-icon c-search-icon">
|
|
105
|
+
<ArrowUpBold />
|
|
106
|
+
</el-icon>
|
|
107
|
+
</div>
|
|
108
|
+
)}
|
|
109
|
+
<el-button type="primary" onClick={handleSearch}>
|
|
110
|
+
搜索
|
|
111
|
+
</el-button>
|
|
112
|
+
<el-button type="primary" onClick={handleReset}>
|
|
113
|
+
重置
|
|
114
|
+
</el-button>
|
|
115
|
+
{slots["btn-right"]?.()}
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
{/* 下拉悬浮 */}
|
|
120
|
+
{!props.isDrawer && showSearchForm.value && (
|
|
121
|
+
<transition name="search-form-transition">
|
|
122
|
+
<el-card className="c-search-form el-card is-always-shadow">
|
|
123
|
+
<CForm
|
|
124
|
+
{...getEvent()}
|
|
125
|
+
inline
|
|
126
|
+
model={props.modelValue}
|
|
127
|
+
formOptions={props.formOptions.filter(
|
|
128
|
+
(item, index) => index >= showCount.value
|
|
129
|
+
)}
|
|
130
|
+
ref="formRef"
|
|
131
|
+
>
|
|
132
|
+
{getSlot()}
|
|
133
|
+
</CForm>
|
|
134
|
+
<div style="text-align: right;">
|
|
135
|
+
<el-button type="primary" onClick={handleSearch}>
|
|
136
|
+
搜索
|
|
137
|
+
</el-button>
|
|
138
|
+
<el-button type="primary" onClick={handleClose}>
|
|
139
|
+
关闭
|
|
140
|
+
</el-button>
|
|
141
|
+
</div>
|
|
142
|
+
</el-card>
|
|
143
|
+
</transition>
|
|
144
|
+
)}
|
|
145
|
+
|
|
146
|
+
{props.isDrawer && (
|
|
147
|
+
<CDrawer title="搜索" v-model={showSearchForm.value} size="660px">
|
|
148
|
+
<CForm
|
|
149
|
+
{...getEvent()}
|
|
150
|
+
col={12}
|
|
151
|
+
model={props.modelValue}
|
|
152
|
+
formOptions={props.formOptions.filter(
|
|
153
|
+
(item, index) => index >= showCount.value
|
|
154
|
+
)}
|
|
155
|
+
ref="formRef"
|
|
156
|
+
>
|
|
157
|
+
{getSlot()}
|
|
158
|
+
</CForm>
|
|
159
|
+
<div style="text-align: right;">
|
|
160
|
+
<el-button type="primary" onClick={handleSearch}>
|
|
161
|
+
搜索
|
|
162
|
+
</el-button>
|
|
163
|
+
<el-button type="primary" onClick={handleClose}>
|
|
164
|
+
关闭
|
|
165
|
+
</el-button>
|
|
166
|
+
</div>
|
|
167
|
+
</CDrawer>
|
|
168
|
+
)}
|
|
169
|
+
</div>
|
|
170
|
+
)
|
|
171
|
+
},
|
|
172
|
+
})
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
.search-btn {
|
|
2
|
+
margin-right: 20px;
|
|
3
|
+
margin-left: auto;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.c-search {
|
|
7
|
+
position: relative;
|
|
8
|
+
height: 50px;
|
|
9
|
+
|
|
10
|
+
.c-search-simple {
|
|
11
|
+
display: flex;
|
|
12
|
+
justify-content: space-between;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.c-search-simple-btn {
|
|
16
|
+
display: flex;
|
|
17
|
+
margin-left: auto;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.c-search-simple-icon {
|
|
21
|
+
display: flex;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
align-items: center;
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
height: 32px;
|
|
26
|
+
width: 32px;
|
|
27
|
+
margin-right: 10px;
|
|
28
|
+
border-radius: 4px;
|
|
29
|
+
background-color: #409eff;
|
|
30
|
+
transition: all 0.2s;
|
|
31
|
+
|
|
32
|
+
&:hover {
|
|
33
|
+
background-color: rgb(121, 187, 255);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&:active {
|
|
37
|
+
background-color: rgb(51, 126, 204);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.c-search-icon {
|
|
42
|
+
// 添加鼠标悬停效果
|
|
43
|
+
color: #fff;
|
|
44
|
+
transition: all 0.2s;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.icon-rotate {
|
|
48
|
+
background-color: rgb(51, 126, 204);
|
|
49
|
+
.c-search-icon {
|
|
50
|
+
transform: rotate(180deg);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.c-search-form {
|
|
55
|
+
width: 100%;
|
|
56
|
+
position: absolute;
|
|
57
|
+
top: 50px;
|
|
58
|
+
left: 0;
|
|
59
|
+
overflow: hidden;
|
|
60
|
+
z-index: 10;
|
|
61
|
+
background-color: #fff;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* 下拉动画效果 */
|
|
66
|
+
.search-form-transition {
|
|
67
|
+
&-enter-active,
|
|
68
|
+
&-leave-active {
|
|
69
|
+
transition: all 0.3s ease;
|
|
70
|
+
/* 动画过渡时间和缓动函数 */
|
|
71
|
+
overflow: hidden;
|
|
72
|
+
max-height: 500px;
|
|
73
|
+
/* 确保足够大的最大高度以容纳内容 */
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
&-enter-from {
|
|
77
|
+
max-height: 0;
|
|
78
|
+
/* 入场开始时高度为0 */
|
|
79
|
+
opacity: 0;
|
|
80
|
+
/* 可以添加透明度效果增强视觉体验 */
|
|
81
|
+
padding-top: 0;
|
|
82
|
+
padding-bottom: 0;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
&-leave-to {
|
|
86
|
+
max-height: 0;
|
|
87
|
+
/* 出场结束时高度为0 */
|
|
88
|
+
opacity: 0;
|
|
89
|
+
/* 可以添加透明度效果增强视觉体验 */
|
|
90
|
+
padding-top: 0;
|
|
91
|
+
padding-bottom: 0;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import Table from "./src/index";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export const CTable = Table;
|
|
6
|
-
export default { com: Table, name: "CTable" };
|
|
7
|
-
// export type { PropsAttrs, FormItemListItem }
|
|
1
|
+
import Table from "./src/index";
|
|
2
|
+
export * from "./src/index";
|
|
3
|
+
export { Table };
|
|
4
|
+
export default Table;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineComponent,
|
|
3
|
+
h,
|
|
4
|
+
getCurrentInstance,
|
|
5
|
+
type ExtractPropTypes,
|
|
6
|
+
} from "vue";
|
|
7
|
+
import { 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
|
+
const propsAttrs = {
|
|
17
|
+
module: {
|
|
18
|
+
// 公共参数用于业务判断
|
|
19
|
+
type: Object,
|
|
20
|
+
default: () => {},
|
|
21
|
+
},
|
|
22
|
+
// isRadio: { // 是否为单选框
|
|
23
|
+
// type: Boolean,
|
|
24
|
+
// default: false,
|
|
25
|
+
// },
|
|
26
|
+
// isCheckbox: { // 是否为复选框
|
|
27
|
+
// type: Boolean,
|
|
28
|
+
// default: false,
|
|
29
|
+
// },
|
|
30
|
+
columnsItem: {
|
|
31
|
+
// 列数据
|
|
32
|
+
type: Array,
|
|
33
|
+
default: () => [],
|
|
34
|
+
},
|
|
35
|
+
showSelection: {
|
|
36
|
+
// 是否显示选择列
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: false,
|
|
39
|
+
},
|
|
40
|
+
showIndex: {
|
|
41
|
+
// 是否显示索引列
|
|
42
|
+
type: Boolean,
|
|
43
|
+
default: false,
|
|
44
|
+
},
|
|
45
|
+
prop: {
|
|
46
|
+
// 列数据prop
|
|
47
|
+
type: String,
|
|
48
|
+
default: undefined,
|
|
49
|
+
},
|
|
50
|
+
// 字典
|
|
51
|
+
dictType: { type: String, default: undefined },
|
|
52
|
+
// 字典选项
|
|
53
|
+
options: { type: Array, default: () => [] },
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export type PropsAttrs = ExtractPropTypes<typeof propsAttrs>;
|
|
57
|
+
|
|
58
|
+
export default defineComponent({
|
|
59
|
+
props: propsAttrs,
|
|
60
|
+
// emits: eventList,
|
|
61
|
+
|
|
62
|
+
// attrs, emit会继承, slots需要设置
|
|
63
|
+
setup(props: PropsAttrs, { attrs, emit, slots, expose }) {
|
|
64
|
+
const { tableSlots, events } = inject("tableContext");
|
|
65
|
+
|
|
66
|
+
// 属性处理
|
|
67
|
+
const getAttrs = () => {
|
|
68
|
+
const obj = {
|
|
69
|
+
...defaultAttrs, // 设置默认值
|
|
70
|
+
};
|
|
71
|
+
return obj;
|
|
72
|
+
};
|
|
73
|
+
// 事件处理
|
|
74
|
+
const getEvents = () => {
|
|
75
|
+
const obj = {
|
|
76
|
+
...defaultAttrs, // 设置默认值
|
|
77
|
+
};
|
|
78
|
+
return obj;
|
|
79
|
+
};
|
|
80
|
+
// 插槽处理
|
|
81
|
+
const getSlots = () => {
|
|
82
|
+
// 处理插槽
|
|
83
|
+
const obj = {};
|
|
84
|
+
// column 自带插槽
|
|
85
|
+
tablecolumnSlots.map((name) => {
|
|
86
|
+
const slotName = `${prop}.${name}`;
|
|
87
|
+
if (tableSlots[slotName]) {
|
|
88
|
+
obj[name] = tableSlots[slotName];
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
// column 列业务插槽
|
|
92
|
+
if (tableSlots[prop]) {
|
|
93
|
+
obj["default"] = tableSlots[prop];
|
|
94
|
+
}
|
|
95
|
+
return obj;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// 渲染表格列
|
|
99
|
+
const renderTableColumn = () => {
|
|
100
|
+
return h(
|
|
101
|
+
ElTableColumn,
|
|
102
|
+
{
|
|
103
|
+
...attrs,
|
|
104
|
+
class: "c-table-column",
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
// default: () => renderTableColumn(),
|
|
108
|
+
// ...getSlots(),
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// 返回渲染函数
|
|
114
|
+
return () => renderTableColumn();
|
|
115
|
+
},
|
|
116
|
+
});
|
|
@@ -1,11 +1,210 @@
|
|
|
1
|
-
import
|
|
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
|
+
const propsAttrs = {
|
|
17
|
+
module: {
|
|
18
|
+
// 公共参数用于业务判断
|
|
19
|
+
type: Object,
|
|
20
|
+
default: () => {},
|
|
21
|
+
},
|
|
22
|
+
// isRadio: { // 是否为单选框
|
|
23
|
+
// type: Boolean,
|
|
24
|
+
// default: false,
|
|
25
|
+
// },
|
|
26
|
+
// isCheckbox: { // 是否为复选框
|
|
27
|
+
// type: Boolean,
|
|
28
|
+
// default: false,
|
|
29
|
+
// },
|
|
30
|
+
columns: {
|
|
31
|
+
// 列数据
|
|
32
|
+
type: Array,
|
|
33
|
+
default: () => [],
|
|
34
|
+
},
|
|
35
|
+
showSelection: {
|
|
36
|
+
// 是否显示选择列
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: false,
|
|
39
|
+
},
|
|
40
|
+
showIndex: {
|
|
41
|
+
// 是否显示索引列
|
|
42
|
+
type: Boolean,
|
|
43
|
+
default: false,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type PropsAttrs = ExtractPropTypes<typeof propsAttrs>;
|
|
48
|
+
|
|
49
|
+
export default defineComponent({
|
|
50
|
+
props: propsAttrs,
|
|
51
|
+
// emits: eventList,
|
|
52
|
+
|
|
53
|
+
// attrs, emit会继承, slots需要设置
|
|
54
|
+
setup(props: PropsAttrs, { attrs, emit, slots, expose }) {
|
|
55
|
+
// 暴露elTable组件上的方法
|
|
56
|
+
const vm = getCurrentInstance(); // 获取虚拟DOM实例
|
|
57
|
+
const cTableFnRef = (el) => {
|
|
58
|
+
if (!el) return;
|
|
59
|
+
vm.exposed = el; // 设置暴露对象
|
|
60
|
+
vm.exposeProxy = el; // 设置代理暴露对象
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// 暴露方法
|
|
64
|
+
expose({
|
|
65
|
+
// tableRef,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// 属性处理
|
|
69
|
+
const getAttrs = () => {
|
|
70
|
+
const obj = {
|
|
71
|
+
...defaultAttrs, // 设置默认值
|
|
72
|
+
};
|
|
73
|
+
return obj;
|
|
74
|
+
};
|
|
75
|
+
// 事件处理
|
|
76
|
+
const getEvents = () => {
|
|
77
|
+
const obj = {
|
|
78
|
+
...defaultAttrs, // 设置默认值
|
|
79
|
+
};
|
|
80
|
+
return obj;
|
|
81
|
+
};
|
|
2
82
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
83
|
+
// 处理列数据-数组
|
|
84
|
+
const getArrayColumn = () => {
|
|
85
|
+
console.log("adsadsd");
|
|
86
|
+
// 递归处理数据
|
|
87
|
+
const list = [];
|
|
88
|
+
|
|
89
|
+
const c = (columns, list) => {
|
|
90
|
+
columns?.map((item) => {
|
|
91
|
+
const { children, ...p } = item;
|
|
92
|
+
// 递归处理子列
|
|
93
|
+
if (isArray(item.children)) {
|
|
94
|
+
item.children = c(item.children, list);
|
|
95
|
+
}
|
|
96
|
+
list.push(p);
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
c(props.columns, list);
|
|
100
|
+
console.log("🚀 ~ gggggggg:", list);
|
|
101
|
+
return list;
|
|
9
102
|
};
|
|
103
|
+
|
|
104
|
+
// 渲染表格列
|
|
105
|
+
const renderTableColumn = () => {
|
|
106
|
+
const list = [];
|
|
107
|
+
// 处理多选与序号列
|
|
108
|
+
if (props.showSelection) {
|
|
109
|
+
list.push(
|
|
110
|
+
h(ElTableColumn, {
|
|
111
|
+
type: "selection",
|
|
112
|
+
width: 55,
|
|
113
|
+
})
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
if (props.showIndex) {
|
|
117
|
+
list.push(
|
|
118
|
+
h(ElTableColumn, {
|
|
119
|
+
label: "序号",
|
|
120
|
+
type: "index",
|
|
121
|
+
width: 55,
|
|
122
|
+
})
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// 列递归渲染
|
|
127
|
+
const rColumn = (columns, list) => {
|
|
128
|
+
columns.map((item) => {
|
|
129
|
+
const { children, ...p } = item;
|
|
130
|
+
|
|
131
|
+
// 处理多级表头
|
|
132
|
+
const listSub = [];
|
|
133
|
+
if (children?.length) {
|
|
134
|
+
rColumn(children, listSub);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// 处理插槽
|
|
138
|
+
const itemSlot = {};
|
|
139
|
+
// column 自带插槽
|
|
140
|
+
tablecolumnSlots.map((name) => {
|
|
141
|
+
const slotName = `${item.prop}.${name}`;
|
|
142
|
+
if (slots[slotName]) {
|
|
143
|
+
itemSlot[name] = slots[slotName];
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
// column 列插槽
|
|
148
|
+
if (slots[item.prop]) {
|
|
149
|
+
itemSlot["default"] = slots[item.prop];
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// 赋值
|
|
153
|
+
if (Object.keys(itemSlot).length) {
|
|
154
|
+
list.push(
|
|
155
|
+
h(
|
|
156
|
+
ElTableColumn,
|
|
157
|
+
{ ...p, class: "c-table-column" },
|
|
158
|
+
listSub.length
|
|
159
|
+
? { ...itemSlot, default: () => listSub }
|
|
160
|
+
: { ...itemSlot }
|
|
161
|
+
)
|
|
162
|
+
);
|
|
163
|
+
} else {
|
|
164
|
+
list.push(
|
|
165
|
+
h(
|
|
166
|
+
ElTableColumn,
|
|
167
|
+
{ ...p, class: "c-table-column" },
|
|
168
|
+
listSub.length ? { default: () => listSub } : undefined
|
|
169
|
+
)
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
rColumn(props.columns, list);
|
|
175
|
+
return list;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
// 插槽处理
|
|
179
|
+
const getSlots = () => {
|
|
180
|
+
const obj = {};
|
|
181
|
+
tableSlots.map((name) => {
|
|
182
|
+
if (slots[name]) {
|
|
183
|
+
obj[name] = slots[name];
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
return obj;
|
|
187
|
+
};
|
|
188
|
+
// 渲染表格组件
|
|
189
|
+
const renderTable = () => {
|
|
190
|
+
// getColumnList();
|
|
191
|
+
console.log("props", props);
|
|
192
|
+
console.log("attrs", attrs);
|
|
193
|
+
return h(
|
|
194
|
+
ElTable,
|
|
195
|
+
{
|
|
196
|
+
ref: cTableFnRef,
|
|
197
|
+
...attrs,
|
|
198
|
+
class: "c-table",
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
default: () => renderTableColumn(),
|
|
202
|
+
...getSlots(),
|
|
203
|
+
}
|
|
204
|
+
);
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
// 返回渲染函数
|
|
208
|
+
return () => renderTable();
|
|
10
209
|
},
|
|
11
|
-
};
|
|
210
|
+
});
|