@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.
Files changed (68) hide show
  1. package/components/button/index.ts +2 -0
  2. package/components/button/src/constants.ts +50 -0
  3. package/components/button/src/index.ts +269 -0
  4. package/components/button/src/type.ts +15 -0
  5. package/components/button/style/index.scss +3 -0
  6. package/components/config.ts +4 -0
  7. package/components/dialog/index.ts +2 -0
  8. package/components/dialog/src/constants.ts +3 -0
  9. package/components/dialog/src/index.ts +54 -0
  10. package/components/dialog/src/type.ts +1 -0
  11. package/components/dialog/style/index.scss +18 -0
  12. package/components/dictLabel/index.ts +4 -0
  13. package/components/dictLabel/src/index.vue +21 -0
  14. package/components/dictLabel/src/type.ts +1 -0
  15. package/components/drawer/index.ts +2 -0
  16. package/components/drawer/src/constants.ts +3 -0
  17. package/components/drawer/src/index.ts +53 -0
  18. package/components/drawer/src/type.ts +1 -0
  19. package/components/drawer/style/index.scss +18 -0
  20. package/components/form/index.ts +2 -0
  21. package/components/form/src/FormItem.ts +406 -0
  22. package/components/form/src/constants.ts +161 -0
  23. package/components/form/src/index.ts +198 -0
  24. package/components/form/src/type.ts +68 -0
  25. package/components/form/src/utils.ts +4 -0
  26. package/components/form/style/index.scss +5 -0
  27. package/components/importText/index.ts +2 -0
  28. package/components/importText/src/index.ts +1 -0
  29. package/components/importText/src/type.ts +3 -0
  30. package/components/index.ts +10 -31
  31. package/components/pagination/index.ts +2 -0
  32. package/components/pagination/src/constants.ts +5 -0
  33. package/components/pagination/src/index.ts +50 -0
  34. package/components/pagination/src/type.ts +1 -0
  35. package/components/search/index.ts +2 -0
  36. package/components/search/src/index.tsx +306 -0
  37. package/components/search/src/type.ts +2 -0
  38. package/components/search/style/index.scss +104 -0
  39. package/components/table/index.ts +2 -0
  40. package/components/table/src/TableColumn.ts +116 -0
  41. package/components/table/src/constants.ts +42 -0
  42. package/components/table/src/index.ts +251 -0
  43. package/components/table/src/tableDictLabel.vue +21 -0
  44. package/components/table/src/type.ts +19 -0
  45. package/components/table/type/index.scss +0 -0
  46. package/components/table2/index.ts +4 -0
  47. package/components/table2/src/config.ts +5 -0
  48. package/components/table2/src/index.ts +12 -0
  49. package/components/table2/src/render.ts +136 -0
  50. package/components/table2/src/types.ts +39 -0
  51. package/components/table2/style/index.scss +0 -0
  52. package/components//346/250/241/346/235/277/index.tsx +57 -0
  53. package/components//346/250/241/346/235/277/ttt.ts +66 -0
  54. package/components//346/250/241/346/235/277/ttt.vue +18 -0
  55. package/index.ts +2 -0
  56. package/package.json +1 -4
  57. package/vite.config.ts +30 -0
  58. package//345/205/266/344/273/226/core/dialog/elementPlus/dialogWarp.vue +151 -0
  59. package//345/205/266/344/273/226/core/dialog/index.ts +10 -0
  60. package//345/205/266/344/273/226/core/form/elementPlus/elementWarp.ts +15 -0
  61. package//345/205/266/344/273/226/core/form/elementPlus/elementWarp.vue +16 -0
  62. package//345/205/266/344/273/226/core/form/elementPlus/formRender.ts +55 -0
  63. package//345/205/266/344/273/226/core/form/index.ts +10 -0
  64. package//345/205/266/344/273/226/core/table/config.ts +5 -0
  65. package//345/205/266/344/273/226/core/table/render.ts +91 -0
  66. package//345/205/266/344/273/226/core/table/warp.ts +11 -0
  67. package//345/205/266/344/273/226/core/utils/fetch.ts +58 -0
  68. package//345/205/266/344/273/226/useMessage.ts +95 -0
@@ -0,0 +1,2 @@
1
+ export * from "./src/type.ts";
2
+ export default "./src/index.ts";
@@ -0,0 +1,50 @@
1
+ export const typeActiveMap = {
2
+ reset: {
3
+ name: "重置",
4
+ type: "info",
5
+ },
6
+ search: {
7
+ name: "查询",
8
+ type: "primary",
9
+ },
10
+ submit: {
11
+ name: "提交",
12
+ type: "primary",
13
+ },
14
+ save: {
15
+ name: "保存",
16
+ type: "primary",
17
+ },
18
+ create: {
19
+ name: "新增",
20
+ type: "primary",
21
+ },
22
+ delete: {
23
+ name: "删除",
24
+ type: "danger",
25
+ },
26
+ edit: {
27
+ name: "编辑",
28
+ type: "primary",
29
+ },
30
+ view: {
31
+ name: "查看",
32
+ type: "primary",
33
+ },
34
+ publish: {
35
+ name: "发布",
36
+ type: "primary",
37
+ },
38
+ import: {
39
+ name: "导入",
40
+ type: "primary",
41
+ },
42
+ export: {
43
+ name: "导出",
44
+ type: "primary",
45
+ },
46
+ exportAll: {
47
+ name: "导出全部",
48
+ type: "primary",
49
+ },
50
+ };
@@ -0,0 +1,269 @@
1
+ import { defineComponent, h, type PropType, type ExtractPropTypes } from "vue";
2
+ import {
3
+ ElButton,
4
+ ElDropdown,
5
+ ElDropdownMenu,
6
+ ElDropdownItem,
7
+ buttonProps,
8
+ } from "element-plus";
9
+
10
+ import "../style/index.scss";
11
+ import { has, isBoolean, isFunction, isArray } from "lodash-es";
12
+ import { typeActiveMap } from "./constants.ts";
13
+
14
+ import { type BtnOptions } from "./type.ts";
15
+ const buttonAttrs = {
16
+ params: {
17
+ // 用于验证自定义函数的外部数据
18
+ type: Object,
19
+ default: () => ({}),
20
+ },
21
+ // 权限验证函数
22
+ permit: {
23
+ type: Function,
24
+ },
25
+ // 折叠
26
+ fold: {
27
+ type: Boolean,
28
+ default: false,
29
+ },
30
+ // 折叠数量
31
+ foldNum: {
32
+ type: Number,
33
+ default: 0,
34
+ },
35
+ btnOptions: {
36
+ type: Array as PropType<BtnOptions[]>,
37
+ default: () => [],
38
+ },
39
+ // 按钮常用全局属性
40
+ size: {
41
+ type: String as PropType<"large" | "default" | "small">,
42
+ default: undefined,
43
+ },
44
+ plain: {
45
+ type: Boolean,
46
+ default: undefined,
47
+ },
48
+ text: {
49
+ type: Boolean,
50
+ default: undefined,
51
+ },
52
+ link: {
53
+ type: Boolean,
54
+ default: undefined,
55
+ },
56
+
57
+ // // 权限函数
58
+ // hasRole: {
59
+ // type: Function,
60
+ // default: () => true
61
+ // },
62
+ };
63
+ export type ButtonAttrs = ExtractPropTypes<typeof buttonAttrs>;
64
+ export default defineComponent({
65
+ props: buttonAttrs,
66
+ emits: ["btnAction"],
67
+ setup(props: ButtonAttrs, { emit, slots, attrs, expose }) {
68
+ // console.log('slots', slots);
69
+ // console.log('attrs', attrs);
70
+
71
+ // 解析按钮属性
72
+ const getAttrs = (item) => {
73
+ let defaultAttrs = {
74
+ size: props.size,
75
+ plain: props.plain,
76
+ text: props.text,
77
+ link: props.link,
78
+ class: `c-btn-alias-${item.alias || ""}`,
79
+ };
80
+
81
+ // 默认按钮类型 用样式控制?
82
+ // if (item?.alias && typeActiveMap[item.alias]) {
83
+ // defaultAttrs = {
84
+ // ...typeActiveMap[item.alias],
85
+ // ...defaultAttrs,
86
+ // };
87
+ // }
88
+
89
+ // 过滤掉非elbutton属性
90
+ const filterAttrsList = ["label", "alias", "permit", "vIf", "disable"];
91
+
92
+ Object.keys(item).map((key) => {
93
+ if (!filterAttrsList.includes(key)) {
94
+ defaultAttrs[key] = item[key];
95
+ }
96
+ });
97
+
98
+ // 处理禁用
99
+ if (isBoolean(item.disable)) {
100
+ defaultAttrs.disabled = item.disable;
101
+ }
102
+ if (
103
+ isFunction(item.disable) &&
104
+ item.disable(props.params) !== undefined
105
+ ) {
106
+ defaultAttrs.disabled = item.disable(props.params);
107
+ }
108
+ return defaultAttrs;
109
+ };
110
+ // 解析下拉菜单属性
111
+ const getDropdownAttrs = (item) => {
112
+ const obj = getAttrs(item);
113
+ const defaultAttrs = {
114
+ splitButton: true,
115
+ };
116
+ // 过滤下拉菜单属性
117
+ const l = [
118
+ "type",
119
+ "size",
120
+ "splitButton",
121
+ "disabled",
122
+ "placement",
123
+ "effect",
124
+ "trigger",
125
+ ];
126
+ l.forEach((key) => {
127
+ if (obj[key] !== undefined) {
128
+ defaultAttrs[key] = obj[key];
129
+ }
130
+ });
131
+ return defaultAttrs;
132
+ };
133
+ // 过滤权限与 vIf
134
+ const filterOptions = () => {
135
+ const list = [];
136
+ // 过滤权限
137
+ props.btnOptions.map((item) => {
138
+ if (
139
+ isArray(item.permit) &&
140
+ item.permit.length > 0 &&
141
+ isFunction(props.permit)
142
+ ) {
143
+ if (props.permit(item.permit)) {
144
+ list.push(item);
145
+ }
146
+ } else {
147
+ list.push(item);
148
+ }
149
+ });
150
+ const list2 = [];
151
+ // 过滤 vIf
152
+ list.map((item) => {
153
+ if (
154
+ has(item, "vIf") &&
155
+ isFunction(item.vIf) &&
156
+ item.vIf(props.params) !== undefined
157
+ ) {
158
+ if (item.vIf(props.params)) {
159
+ list2.push(item);
160
+ }
161
+ } else {
162
+ list2.push(item);
163
+ }
164
+ });
165
+ return list2;
166
+ };
167
+ // 按钮单个生成函数
168
+ const createBtn = (item) => {
169
+ return h(
170
+ ElButton,
171
+ {
172
+ ...getAttrs(item),
173
+ onClick: () => {
174
+ emit("btnAction", item.alias, props.params);
175
+ },
176
+ },
177
+ {
178
+ default: () => item?.label,
179
+ },
180
+ );
181
+ };
182
+ // 下拉菜单生成函数
183
+ const createDropdown = (finalList) => {
184
+ const dropdownList = []; // 不折叠的按钮
185
+ const dropdownMain = []; // 下拉占位
186
+ const dropdownItemList = []; // 折叠的按钮
187
+
188
+ finalList.map((itm, idx) => {
189
+ if (idx < props.foldNum) {
190
+ dropdownList.push(itm);
191
+ } else if (idx === props.foldNum) {
192
+ dropdownMain.push(itm);
193
+ } else {
194
+ dropdownItemList.push(itm);
195
+ }
196
+ });
197
+ // 处理只有一个下拉按钮的情况
198
+ if (dropdownMain.length > 0 && dropdownItemList.length === 0) {
199
+ dropdownList.push(dropdownMain[0]);
200
+ }
201
+
202
+ // 最终渲染的vdom
203
+ let renderVdom = [];
204
+ // 展示按钮vdom
205
+ const butsVdom = dropdownList.map((item) => {
206
+ return createBtn(item);
207
+ });
208
+
209
+ // 合并参数
210
+ if (butsVdom.length > 0) {
211
+ renderVdom = renderVdom.concat(butsVdom);
212
+ }
213
+
214
+ if (dropdownMain.length > 0 && dropdownItemList.length > 0) {
215
+ // 下拉菜单vdom
216
+ const dropdownVdom = h(
217
+ ElDropdown,
218
+ {
219
+ ...getDropdownAttrs(dropdownMain[0]),
220
+ class: "c-btn-dropdown",
221
+ buttonProps: getAttrs(dropdownMain[0]),
222
+ splitButton: true,
223
+ // splitButton: dropdownItemList.length > 0,
224
+ onClick: () => {
225
+ emit("btnAction", dropdownMain[0].alias, props.params);
226
+ },
227
+ onCommand: (command: string) => {
228
+ emit("btnAction", command, props.params);
229
+ },
230
+ },
231
+ {
232
+ default: () => {
233
+ return dropdownMain[0].label;
234
+ },
235
+ dropdown: () => {
236
+ return dropdownItemList.map((item) => {
237
+ return h(
238
+ ElDropdownItem,
239
+ {
240
+ command: item.alias,
241
+ },
242
+ {
243
+ default: () => item?.label,
244
+ },
245
+ );
246
+ });
247
+ },
248
+ },
249
+ );
250
+ renderVdom = renderVdom.concat(dropdownVdom);
251
+ }
252
+ return renderVdom;
253
+ };
254
+
255
+ const render = () => {
256
+ const finalList = filterOptions(); // 最终列表
257
+ // 是否折叠 折叠
258
+ if (props.fold) {
259
+ return createDropdown(finalList);
260
+ } else {
261
+ // 不折叠
262
+ return finalList.map((item) => {
263
+ return createBtn(item);
264
+ });
265
+ }
266
+ };
267
+ return () => render();
268
+ },
269
+ });
@@ -0,0 +1,15 @@
1
+ import type { ButtonProps as ElButtonProps } from "element-plus";
2
+ import { type ButtonAttrs } from "./index.ts";
3
+ type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never; // 展开类型工具
4
+
5
+ export type ButtonProps = Expand<Partial<ButtonAttrs>>;
6
+
7
+ export type BtnOptions = Expand<
8
+ {
9
+ label: string;
10
+ alias: string;
11
+ permit?: string[];
12
+ vIf?: (params: any) => boolean;
13
+ disable?: boolean | ((params: any) => boolean);
14
+ } & Partial<ElButtonProps>
15
+ >;
@@ -0,0 +1,3 @@
1
+ .el-button + .el-dropdown {
2
+ margin-left: 10px;
3
+ }
@@ -0,0 +1,4 @@
1
+ // 组件配置
2
+ // 组件名称前缀 组件标识 class 前缀
3
+ import { capitalize } from "lodash-es";
4
+ export const prefix = capitalize("C"); // 首字母大写 其他字母小写
@@ -0,0 +1,2 @@
1
+ export * from "./src/type.ts";
2
+ export default "./src/index.ts";
@@ -0,0 +1,3 @@
1
+ export const defaultAttrs = {
2
+ destroyOnClose: true,
3
+ };
@@ -0,0 +1,54 @@
1
+ import {
2
+ defineComponent,
3
+ ref,
4
+ h,
5
+ computed,
6
+ toRefs,
7
+ type ExtractPropTypes,
8
+ } from "vue";
9
+ import { ElDialog } from "element-plus";
10
+ import { defaultAttrs } from "./constants.ts";
11
+ import { prefix } from "../../config.ts";
12
+ const dialogAttrs = {};
13
+
14
+ export type DialogAttrs = ExtractPropTypes<typeof dialogAttrs>;
15
+
16
+ export default defineComponent({
17
+ name: `${prefix}Dialog`,
18
+ // props: propsAttrs,
19
+ // emits: eventList,
20
+
21
+ // attrs, emit会继承, slots需要设置
22
+ setup(props: DialogAttrs, { attrs, emit, slots, expose }) {
23
+ // const dialogRef = ref();
24
+
25
+ // 暴露方法
26
+ // expose({
27
+ // dialogRef,
28
+ // });
29
+
30
+ // 属性处理
31
+ const getAttrs = () => {
32
+ const obj = {
33
+ ...defaultAttrs, // 设置默认值
34
+ };
35
+ return obj;
36
+ };
37
+
38
+ // 渲染组件
39
+ const render = () => {
40
+ return h(
41
+ ElDialog,
42
+ {
43
+ // ref: dialogRef,
44
+ ...getAttrs(),
45
+ class: "c-dialog",
46
+ },
47
+ slots
48
+ );
49
+ };
50
+
51
+ // 返回渲染函数
52
+ return () => render();
53
+ },
54
+ });
@@ -0,0 +1 @@
1
+ export type {}
@@ -0,0 +1,18 @@
1
+ /* Bounce Animation */
2
+ .dialog-bounce-enter-active,
3
+ .dialog-bounce-leave-active,
4
+ .dialog-bounce-enter-active .el-dialog,
5
+ .dialog-bounce-leave-active .el-dialog {
6
+ transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
7
+ }
8
+
9
+ .dialog-bounce-enter-from,
10
+ .dialog-bounce-leave-to {
11
+ opacity: 0;
12
+ }
13
+
14
+ .dialog-bounce-enter-from .el-dialog,
15
+ .dialog-bounce-leave-to .el-dialog {
16
+ transform: scale(0.3) translateY(-50px);
17
+ opacity: 0;
18
+ }
@@ -0,0 +1,4 @@
1
+ import DictLabel from "./src/index.vue";
2
+ export * from "./src/index.vue";
3
+ export { DictLabel };
4
+ export default DictLabel;
@@ -0,0 +1,21 @@
1
+ <template>
2
+ {{ label }}
3
+ </template>
4
+ <script setup lang="ts">
5
+ import { computed, PropType } from 'vue'
6
+ const props = defineProps({
7
+ options: {
8
+ type: Array,
9
+ default: () => []
10
+ },
11
+ value: {
12
+ type: String as PropType<any>,
13
+ default: ''
14
+ },
15
+ })
16
+ const label = computed(() => {
17
+ // 处理value为数字的情况 后端字典都是字符串
18
+ const item = props.options?.find((item) => item.value == props.value.toString());
19
+ return item?.label || props.value;
20
+ });
21
+ </script>
@@ -0,0 +1 @@
1
+ export type {}
@@ -0,0 +1,2 @@
1
+ export * from "./src/type.ts";
2
+ export default "./src/index.ts";
@@ -0,0 +1,3 @@
1
+ export const defaultAttrs = {
2
+ destroyOnClose: true,
3
+ };
@@ -0,0 +1,53 @@
1
+ import {
2
+ defineComponent,
3
+ ref,
4
+ h,
5
+ computed,
6
+ toRefs,
7
+ type ExtractPropTypes,
8
+ } from "vue";
9
+ import { ElDrawer } from "element-plus";
10
+ import { defaultAttrs } from "./constants.ts";
11
+
12
+ const drawerAttrs = {};
13
+
14
+ export type DrawerAttrs = ExtractPropTypes<typeof drawerAttrs>;
15
+
16
+ export default defineComponent({
17
+ // props: propsAttrs,
18
+ // emits: eventList,
19
+
20
+ // attrs, emit会继承, slots需要设置
21
+ setup(props: DrawerAttrs, { attrs, emit, slots, expose }) {
22
+ // const drawerRef = ref();
23
+
24
+ // 暴露方法
25
+ // expose({
26
+ // drawerRef,
27
+ // });
28
+
29
+ // 属性处理
30
+ const getAttrs = () => {
31
+ const obj = {
32
+ ...defaultAttrs, // 设置默认值
33
+ };
34
+ return obj;
35
+ };
36
+
37
+ // 渲染组件
38
+ const render = () => {
39
+ return h(
40
+ ElDrawer,
41
+ {
42
+ // ref: drawerRef,
43
+ ...getAttrs(),
44
+ class: "c-drawer",
45
+ },
46
+ slots
47
+ );
48
+ };
49
+
50
+ // 返回渲染函数
51
+ return () => render();
52
+ },
53
+ });
@@ -0,0 +1 @@
1
+ export type {}
@@ -0,0 +1,18 @@
1
+ // /* Bounce Animation */
2
+ // .dialog-bounce-enter-active,
3
+ // .dialog-bounce-leave-active,
4
+ // .dialog-bounce-enter-active .el-dialog,
5
+ // .dialog-bounce-leave-active .el-dialog {
6
+ // transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
7
+ // }
8
+
9
+ // .dialog-bounce-enter-from,
10
+ // .dialog-bounce-leave-to {
11
+ // opacity: 0;
12
+ // }
13
+
14
+ // .dialog-bounce-enter-from .el-dialog,
15
+ // .dialog-bounce-leave-to .el-dialog {
16
+ // transform: scale(0.3) translateY(-50px);
17
+ // opacity: 0;
18
+ // }
@@ -0,0 +1,2 @@
1
+ export * from "./src/type.ts";
2
+ export default "./src/index.ts";