@elementplus-kit/uikit 1.6.0 → 1.8.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.
- package/components/button/index.ts +2 -0
- package/components/button/src/constants.ts +50 -0
- package/components/button/src/index.ts +269 -0
- package/components/button/src/type.ts +15 -0
- package/components/button/style/index.scss +3 -0
- package/components/config.ts +4 -0
- package/components/dialog/index.ts +2 -0
- package/components/dialog/src/constants.ts +3 -0
- package/components/dialog/src/index.ts +54 -0
- package/components/dialog/src/type.ts +1 -0
- package/components/dialog/style/index.scss +18 -0
- package/components/dictLabel/index.ts +4 -0
- package/components/dictLabel/src/index.vue +21 -0
- package/components/dictLabel/src/type.ts +1 -0
- package/components/drawer/index.ts +2 -0
- package/components/drawer/src/constants.ts +3 -0
- package/components/drawer/src/index.ts +53 -0
- package/components/drawer/src/type.ts +1 -0
- package/components/drawer/style/index.scss +18 -0
- package/components/form/index.ts +2 -0
- package/components/form/src/FormItem.ts +406 -0
- package/components/form/src/constants.ts +161 -0
- package/components/form/src/index.ts +198 -0
- package/components/form/src/type.ts +68 -0
- package/components/form/src/utils.ts +4 -0
- package/components/form/style/index.scss +5 -0
- package/components/importText/index.ts +2 -0
- package/components/importText/src/index.ts +1 -0
- package/components/importText/src/type.ts +3 -0
- package/components/index.ts +10 -31
- package/components/pagination/index.ts +2 -0
- package/components/pagination/src/constants.ts +5 -0
- package/components/pagination/src/index.ts +50 -0
- package/components/pagination/src/type.ts +1 -0
- package/components/search/index.ts +2 -0
- package/components/search/src/index.tsx +306 -0
- package/components/search/src/type.ts +2 -0
- package/components/search/style/index.scss +104 -0
- package/components/table/index.ts +2 -0
- package/components/table/src/TableColumn.ts +116 -0
- package/components/table/src/constants.ts +42 -0
- package/components/table/src/index.ts +251 -0
- package/components/table/src/tableDictLabel.vue +21 -0
- package/components/table/src/type.ts +19 -0
- package/components/table/type/index.scss +0 -0
- package/components/table2/index.ts +4 -0
- package/components/table2/src/config.ts +5 -0
- package/components/table2/src/index.ts +12 -0
- package/components/table2/src/render.ts +136 -0
- package/components/table2/src/types.ts +39 -0
- package/components/table2/style/index.scss +0 -0
- package/components//346/250/241/346/235/277/index.tsx +57 -0
- package/components//346/250/241/346/235/277/ttt.ts +66 -0
- package/components//346/250/241/346/235/277/ttt.vue +18 -0
- package/index.ts +2 -0
- package/package.json +1 -4
- package/vite.config.ts +30 -0
- package//345/205/266/344/273/226/core/dialog/elementPlus/dialogWarp.vue +151 -0
- package//345/205/266/344/273/226/core/dialog/index.ts +10 -0
- package//345/205/266/344/273/226/core/form/elementPlus/elementWarp.ts +15 -0
- package//345/205/266/344/273/226/core/form/elementPlus/elementWarp.vue +16 -0
- package//345/205/266/344/273/226/core/form/elementPlus/formRender.ts +55 -0
- package//345/205/266/344/273/226/core/form/index.ts +10 -0
- package//345/205/266/344/273/226/core/table/config.ts +5 -0
- package//345/205/266/344/273/226/core/table/render.ts +91 -0
- package//345/205/266/344/273/226/core/table/warp.ts +11 -0
- package//345/205/266/344/273/226/core/utils/fetch.ts +58 -0
- package//345/205/266/344/273/226/useMessage.ts +95 -0
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ref,
|
|
3
|
+
defineComponent,
|
|
4
|
+
onMounted,
|
|
5
|
+
onUnmounted,
|
|
6
|
+
type PropType,
|
|
7
|
+
type ExtractPropTypes,
|
|
8
|
+
} from "vue";
|
|
9
|
+
|
|
10
|
+
import { CForm, CDrawer } from "@elementplus-kit/uikit";
|
|
11
|
+
import { ArrowUpBold } from "@element-plus/icons-vue";
|
|
12
|
+
import "../style/index.scss";
|
|
13
|
+
|
|
14
|
+
import { FormOptions } from "../../form/src/type.ts";
|
|
15
|
+
|
|
16
|
+
export type SearchAttrs = ExtractPropTypes<typeof searchAttrs>;
|
|
17
|
+
|
|
18
|
+
const searchAttrs = {
|
|
19
|
+
modelValue: {
|
|
20
|
+
type: Object,
|
|
21
|
+
default: {},
|
|
22
|
+
},
|
|
23
|
+
formOptions: {
|
|
24
|
+
type: Array as PropType<FormOptions>,
|
|
25
|
+
default: () => [],
|
|
26
|
+
},
|
|
27
|
+
isDrawer: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
default: false,
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
export default defineComponent({
|
|
33
|
+
props: searchAttrs,
|
|
34
|
+
emits: ["update:modelValue", "search", "reset", "close"],
|
|
35
|
+
|
|
36
|
+
setup(props: SearchAttrs, { emit, slots, attrs, expose }) {
|
|
37
|
+
// 自己的 slot
|
|
38
|
+
const slotsList = ["btn-left", "btn-right"];
|
|
39
|
+
// 解析 attrs 中的事件
|
|
40
|
+
const getEvent = () => {
|
|
41
|
+
let formObj: any = {};
|
|
42
|
+
Object.keys(attrs)?.forEach((name) => {
|
|
43
|
+
if (name.indexOf("on") === 0) {
|
|
44
|
+
formObj[name] = attrs[name];
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
return formObj;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// 解析插槽
|
|
51
|
+
const getSlot = () => {
|
|
52
|
+
let formObj = {};
|
|
53
|
+
Object.keys(slots).forEach((key) => {
|
|
54
|
+
if (!slotsList.includes(key)) {
|
|
55
|
+
formObj[key] = slots[key];
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return formObj;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// 搜索
|
|
62
|
+
const handleSearch = () => {
|
|
63
|
+
emit("search");
|
|
64
|
+
showSearchForm.value = false;
|
|
65
|
+
document.removeEventListener("click", handleClickOutside); // 销毁点击事件
|
|
66
|
+
};
|
|
67
|
+
// 重置
|
|
68
|
+
const handleReset = () => {
|
|
69
|
+
emit("reset");
|
|
70
|
+
};
|
|
71
|
+
// 关闭
|
|
72
|
+
const handleClose = () => {
|
|
73
|
+
showSearchForm.value = false;
|
|
74
|
+
document.removeEventListener("click", handleClickOutside); // 销毁点击事件
|
|
75
|
+
emit("close");
|
|
76
|
+
};
|
|
77
|
+
// 点击元素外关闭
|
|
78
|
+
const dropdownRef = ref<HTMLElement | null>(null); // 下拉表单的 ref
|
|
79
|
+
|
|
80
|
+
// 点击外部关闭函数
|
|
81
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
82
|
+
// 如果下拉表单可见,且点击事件不在下拉表单内部
|
|
83
|
+
if (
|
|
84
|
+
showSearchForm.value &&
|
|
85
|
+
dropdownRef.value &&
|
|
86
|
+
!dropdownRef.value?.$el?.contains(event.target)
|
|
87
|
+
) {
|
|
88
|
+
showSearchForm.value = false; // 关闭下拉表单
|
|
89
|
+
document.removeEventListener("click", handleClickOutside); // 销毁点击事件
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
// 显示隐藏折叠搜索表单
|
|
93
|
+
const showSearchForm = ref(false);
|
|
94
|
+
const handleShow = () => {
|
|
95
|
+
if (showSearchForm.value) {
|
|
96
|
+
showSearchForm.value = false;
|
|
97
|
+
document.removeEventListener("click", handleClickOutside); // 销毁点击事件
|
|
98
|
+
} else {
|
|
99
|
+
showSearchForm.value = true;
|
|
100
|
+
setTimeout(() => {
|
|
101
|
+
document.addEventListener("click", handleClickOutside); // 注册点击事件
|
|
102
|
+
}, 0);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const showCount = ref(6); // 显示个数
|
|
107
|
+
const simpleRef = ref<HTMLDivElement>(null);
|
|
108
|
+
const simpleFormRef = ref<HTMLDivElement>(null);
|
|
109
|
+
const simpleFormContainerRef = ref<HTMLDivElement>(null);
|
|
110
|
+
const simpleBtnRef = ref<HTMLDivElement>(null);
|
|
111
|
+
const cFormRef = ref<HTMLDivElement>(null);
|
|
112
|
+
|
|
113
|
+
// 设置节流
|
|
114
|
+
let timer: any = null;
|
|
115
|
+
const searchResize = () => {
|
|
116
|
+
if (timer) {
|
|
117
|
+
clearTimeout(timer);
|
|
118
|
+
}
|
|
119
|
+
timer = setTimeout(() => {
|
|
120
|
+
calcSunResize();
|
|
121
|
+
}, 200);
|
|
122
|
+
};
|
|
123
|
+
// 计算显示个数
|
|
124
|
+
const calcSunResize = () => {
|
|
125
|
+
if (simpleFormContainerRef.value) {
|
|
126
|
+
// 寻找cForm 先写死 后期做成动态寻找
|
|
127
|
+
const cFormDom = simpleFormContainerRef.value.children[0];
|
|
128
|
+
const cFormW = simpleFormRef.value.offsetWidth;
|
|
129
|
+
// 收集子元素宽度并保存到数组中
|
|
130
|
+
|
|
131
|
+
let maxW = 0;
|
|
132
|
+
showCount.value = cFormDom?.children?.length;
|
|
133
|
+
Array.from(cFormDom.children).map((child, index) => {
|
|
134
|
+
child.style.display = "inline-flex"; // 行内布局时的默认值 如果表单换了默认值要动态变化 暂时不考虑
|
|
135
|
+
if (maxW > cFormW) {
|
|
136
|
+
child.style.display = "none";
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const computedStyles = window.getComputedStyle(child); // 获取元素 css 样式
|
|
141
|
+
const mg = computedStyles.marginRight; // 获取元素 margin-right 样式值 有单位
|
|
142
|
+
const mgValue = parseFloat(mg); // 转换为数值
|
|
143
|
+
const w = child.offsetWidth + mgValue;
|
|
144
|
+
maxW = maxW + w;
|
|
145
|
+
if (maxW > cFormW) {
|
|
146
|
+
child.style.display = "none";
|
|
147
|
+
showCount.value = index;
|
|
148
|
+
maxW = 100000;
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
// 监听表单宽度变化
|
|
154
|
+
const formWidth = ref(0);
|
|
155
|
+
const jt = () => {
|
|
156
|
+
// 获取需要监听的元素
|
|
157
|
+
const targetElement = simpleFormRef.value.children[0];
|
|
158
|
+
// 创建 ResizeObserver 实例
|
|
159
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
160
|
+
const clearW = 25; // input clear 按钮 22 按 25 算
|
|
161
|
+
for (const entry of entries) {
|
|
162
|
+
// 获取元素最新的宽度(contentBox 是内容区尺寸,也可改用 borderBox/devicePixelContentBox)
|
|
163
|
+
const newWidth = entry.contentRect.width;
|
|
164
|
+
// 变化了才执行
|
|
165
|
+
if (newWidth !== formWidth.value) {
|
|
166
|
+
if (formWidth.value === 0) {
|
|
167
|
+
// 初始化赋值
|
|
168
|
+
formWidth.value = newWidth;
|
|
169
|
+
searchResize();
|
|
170
|
+
} else if (newWidth < formWidth.value - clearW) {
|
|
171
|
+
// 过滤抖动
|
|
172
|
+
formWidth.value = newWidth;
|
|
173
|
+
searchResize();
|
|
174
|
+
} else if (newWidth > formWidth.value + clearW) {
|
|
175
|
+
// 过滤抖动
|
|
176
|
+
searchResize();
|
|
177
|
+
formWidth.value = newWidth;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
// 开始监听目标元素
|
|
184
|
+
resizeObserver.observe(targetElement);
|
|
185
|
+
};
|
|
186
|
+
onMounted(() => {
|
|
187
|
+
// jt函数会触发一次初始化
|
|
188
|
+
jt();
|
|
189
|
+
// 注册页面大小函数
|
|
190
|
+
window.addEventListener("resize", searchResize);
|
|
191
|
+
});
|
|
192
|
+
// 销毁
|
|
193
|
+
onUnmounted(() => {
|
|
194
|
+
window.removeEventListener("resize", searchResize);
|
|
195
|
+
document.removeEventListener("click", handleClickOutside); // 销毁点击事件
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
return () => {
|
|
199
|
+
return (
|
|
200
|
+
<div className="c-search">
|
|
201
|
+
<div className="c-search-simple" ref={simpleRef}>
|
|
202
|
+
<div className="c-search-simple-form" ref={simpleFormRef}>
|
|
203
|
+
<div
|
|
204
|
+
className="c-simple-form-container"
|
|
205
|
+
ref={simpleFormContainerRef}
|
|
206
|
+
>
|
|
207
|
+
<CForm
|
|
208
|
+
ref={(el) => (cFormRef.value = el)}
|
|
209
|
+
{...getEvent()}
|
|
210
|
+
inline
|
|
211
|
+
model={props.modelValue}
|
|
212
|
+
formOptions={props.formOptions}
|
|
213
|
+
>
|
|
214
|
+
{getSlot()}
|
|
215
|
+
</CForm>
|
|
216
|
+
</div>
|
|
217
|
+
</div>
|
|
218
|
+
<div className="c-search-simple-btn" ref={simpleBtnRef}>
|
|
219
|
+
{slots["arrow-left"]?.()}
|
|
220
|
+
{showCount.value < props.formOptions?.length && (
|
|
221
|
+
<div
|
|
222
|
+
className={`c-search-simple-icon ${
|
|
223
|
+
showSearchForm.value ? "icon-rotate" : ""
|
|
224
|
+
}`}
|
|
225
|
+
onClick={handleShow}
|
|
226
|
+
>
|
|
227
|
+
<el-icon className="el-icon c-search-icon">
|
|
228
|
+
<ArrowUpBold />
|
|
229
|
+
</el-icon>
|
|
230
|
+
</div>
|
|
231
|
+
)}
|
|
232
|
+
{slots["search-btn"] ? (
|
|
233
|
+
slots["search-btn"]()
|
|
234
|
+
) : (
|
|
235
|
+
<>
|
|
236
|
+
{slots["btn-left"]?.()}
|
|
237
|
+
<el-button type="primary" onClick={handleSearch}>
|
|
238
|
+
搜索
|
|
239
|
+
</el-button>
|
|
240
|
+
<el-button type="primary" onClick={handleReset}>
|
|
241
|
+
重置
|
|
242
|
+
</el-button>
|
|
243
|
+
{slots["btn-right"]?.()}
|
|
244
|
+
</>
|
|
245
|
+
)}
|
|
246
|
+
</div>
|
|
247
|
+
</div>
|
|
248
|
+
|
|
249
|
+
{/* 下拉悬浮 */}
|
|
250
|
+
{!props.isDrawer && showSearchForm.value && (
|
|
251
|
+
<transition name="search-form-transition">
|
|
252
|
+
<el-card
|
|
253
|
+
ref={dropdownRef}
|
|
254
|
+
className="c-search-form el-card is-always-shadow"
|
|
255
|
+
>
|
|
256
|
+
<CForm
|
|
257
|
+
{...getEvent()}
|
|
258
|
+
inline
|
|
259
|
+
model={props.modelValue}
|
|
260
|
+
formOptions={props.formOptions.filter(
|
|
261
|
+
(item, index) => index >= showCount.value,
|
|
262
|
+
)}
|
|
263
|
+
ref="formRef"
|
|
264
|
+
>
|
|
265
|
+
{getSlot()}
|
|
266
|
+
</CForm>
|
|
267
|
+
<div style="text-align: right;">
|
|
268
|
+
<el-button type="primary" onClick={handleSearch}>
|
|
269
|
+
搜索
|
|
270
|
+
</el-button>
|
|
271
|
+
<el-button type="primary" onClick={handleClose}>
|
|
272
|
+
关闭
|
|
273
|
+
</el-button>
|
|
274
|
+
</div>
|
|
275
|
+
</el-card>
|
|
276
|
+
</transition>
|
|
277
|
+
)}
|
|
278
|
+
|
|
279
|
+
{props.isDrawer && (
|
|
280
|
+
<CDrawer title="搜索" v-model={showSearchForm.value} size="660px">
|
|
281
|
+
<CForm
|
|
282
|
+
{...getEvent()}
|
|
283
|
+
col={12}
|
|
284
|
+
model={props.modelValue}
|
|
285
|
+
formOptions={props.formOptions.filter(
|
|
286
|
+
(item, index) => index >= showCount.value,
|
|
287
|
+
)}
|
|
288
|
+
ref="formRef"
|
|
289
|
+
>
|
|
290
|
+
{getSlot()}
|
|
291
|
+
</CForm>
|
|
292
|
+
<div style="text-align: right;">
|
|
293
|
+
<el-button type="primary" onClick={handleSearch}>
|
|
294
|
+
搜索
|
|
295
|
+
</el-button>
|
|
296
|
+
<el-button type="primary" onClick={handleClose}>
|
|
297
|
+
关闭
|
|
298
|
+
</el-button>
|
|
299
|
+
</div>
|
|
300
|
+
</CDrawer>
|
|
301
|
+
)}
|
|
302
|
+
</div>
|
|
303
|
+
);
|
|
304
|
+
};
|
|
305
|
+
},
|
|
306
|
+
});
|
|
@@ -0,0 +1,104 @@
|
|
|
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
|
+
.c-search-simple-form {
|
|
15
|
+
flex: 1; // 占满剩余空间
|
|
16
|
+
overflow: auto; // 开启滚动条
|
|
17
|
+
// 滚动条宽度
|
|
18
|
+
scrollbar-width: none; // 隐藏滚动条
|
|
19
|
+
}
|
|
20
|
+
.c-simple-form-container {
|
|
21
|
+
display: inline-block;
|
|
22
|
+
> .c-form {
|
|
23
|
+
white-space: nowrap; // 防止表单内容换行
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
.c-search-simple-btn {
|
|
27
|
+
display: flex;
|
|
28
|
+
margin-left: auto;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.c-search-simple-icon {
|
|
32
|
+
display: flex;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
align-items: center;
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
height: 32px;
|
|
37
|
+
width: 32px;
|
|
38
|
+
margin-right: 10px;
|
|
39
|
+
border-radius: 4px;
|
|
40
|
+
background-color: #409eff;
|
|
41
|
+
transition: all 0.2s;
|
|
42
|
+
|
|
43
|
+
&:hover {
|
|
44
|
+
background-color: rgb(121, 187, 255);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&:active {
|
|
48
|
+
background-color: rgb(51, 126, 204);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.c-search-icon {
|
|
53
|
+
// 添加鼠标悬停效果
|
|
54
|
+
color: #fff;
|
|
55
|
+
transition: all 0.2s;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.icon-rotate {
|
|
59
|
+
background-color: rgb(51, 126, 204);
|
|
60
|
+
.c-search-icon {
|
|
61
|
+
transform: rotate(180deg);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.c-search-form {
|
|
66
|
+
width: 100%;
|
|
67
|
+
position: absolute;
|
|
68
|
+
top: 50px;
|
|
69
|
+
left: 0;
|
|
70
|
+
overflow: hidden;
|
|
71
|
+
z-index: 10;
|
|
72
|
+
background-color: #fff;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/* 下拉动画效果 */
|
|
77
|
+
.search-form-transition {
|
|
78
|
+
&-enter-active,
|
|
79
|
+
&-leave-active {
|
|
80
|
+
transition: all 0.3s ease;
|
|
81
|
+
/* 动画过渡时间和缓动函数 */
|
|
82
|
+
overflow: hidden;
|
|
83
|
+
max-height: 500px;
|
|
84
|
+
/* 确保足够大的最大高度以容纳内容 */
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&-enter-from {
|
|
88
|
+
max-height: 0;
|
|
89
|
+
/* 入场开始时高度为0 */
|
|
90
|
+
opacity: 0;
|
|
91
|
+
/* 可以添加透明度效果增强视觉体验 */
|
|
92
|
+
padding-top: 0;
|
|
93
|
+
padding-bottom: 0;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
&-leave-to {
|
|
97
|
+
max-height: 0;
|
|
98
|
+
/* 出场结束时高度为0 */
|
|
99
|
+
opacity: 0;
|
|
100
|
+
/* 可以添加透明度效果增强视觉体验 */
|
|
101
|
+
padding-top: 0;
|
|
102
|
+
padding-bottom: 0;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -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
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export const defaultAttrs = {
|
|
2
|
+
// destroyOnClose: true,
|
|
3
|
+
};
|
|
4
|
+
export const tableEvents = [
|
|
5
|
+
"select",
|
|
6
|
+
"select-all",
|
|
7
|
+
"selection-change",
|
|
8
|
+
"cell-mouse-enter",
|
|
9
|
+
"cell-mouse-leave",
|
|
10
|
+
"cell-click",
|
|
11
|
+
"cell-dblclick",
|
|
12
|
+
"cell-contextmenu",
|
|
13
|
+
"row-click",
|
|
14
|
+
"row-contextmenu",
|
|
15
|
+
"row-dblclick",
|
|
16
|
+
"header-click",
|
|
17
|
+
"header-contextmenu",
|
|
18
|
+
"sort-change",
|
|
19
|
+
"filter-change",
|
|
20
|
+
"current-change",
|
|
21
|
+
"header-dragend",
|
|
22
|
+
"expand-change",
|
|
23
|
+
"scroll",
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
export const tableSlots = ["default", "append", "empty"];
|
|
27
|
+
export const tablecolumnSlots = ["default", "header", "filter-icon", "expand"];
|
|
28
|
+
|
|
29
|
+
export const selectionColumn = {
|
|
30
|
+
type: "selection",
|
|
31
|
+
width: 50,
|
|
32
|
+
align: "center",
|
|
33
|
+
};
|
|
34
|
+
export const indexColumn = {
|
|
35
|
+
type: "index",
|
|
36
|
+
width: 50,
|
|
37
|
+
align: "center",
|
|
38
|
+
};
|
|
39
|
+
export const actionColumn = {
|
|
40
|
+
prop: "action",
|
|
41
|
+
align: "center",
|
|
42
|
+
};
|