@elementplus-kit/uikit 1.9.0 → 1.11.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.
@@ -1,50 +0,0 @@
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
- };
@@ -1,17 +1,11 @@
1
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";
2
+ import { ElButton, ElDropdown, ElDropdownItem } from "element-plus";
9
3
 
10
4
  import "../style/index.scss";
11
- import { has, isBoolean, isFunction, isArray } from "lodash-es";
12
- import { typeActiveMap } from "./constants.ts";
5
+ import { has, isBoolean, isFunction, isArray, isNumber } from "lodash-es";
13
6
 
14
7
  import { type BtnOptions } from "./type.ts";
8
+ import { isString } from "element-plus/es/utils/types.mjs";
15
9
  const buttonAttrs = {
16
10
  params: {
17
11
  // 用于验证自定义函数的外部数据
@@ -22,15 +16,10 @@ const buttonAttrs = {
22
16
  permit: {
23
17
  type: Function,
24
18
  },
25
- // 折叠
19
+ // 折叠与数量
26
20
  fold: {
27
- type: Boolean,
28
- default: false,
29
- },
30
- // 折叠数量
31
- foldNum: {
32
- type: Number,
33
- default: 0,
21
+ type: [Number, String, Boolean, undefined],
22
+ default: undefined,
34
23
  },
35
24
  btnOptions: {
36
25
  type: Array as PropType<BtnOptions[]>,
@@ -184,11 +173,22 @@ export default defineComponent({
184
173
  const dropdownList = []; // 不折叠的按钮
185
174
  const dropdownMain = []; // 下拉占位
186
175
  const dropdownItemList = []; // 折叠的按钮
187
-
176
+ let foldSun = 1;
177
+ if (!isBoolean(props.fold)) {
178
+ const s = props.fold * 1;
179
+ console.log("🚀 ~ createDropdown ~ s:", s);
180
+ if (s) {
181
+ if (isNumber(s)) {
182
+ foldSun = props.fold;
183
+ } else {
184
+ console.error("fold 类型错误");
185
+ }
186
+ }
187
+ }
188
188
  finalList.map((itm, idx) => {
189
- if (idx < props.foldNum) {
189
+ if (idx < foldSun - 1) {
190
190
  dropdownList.push(itm);
191
- } else if (idx === props.foldNum) {
191
+ } else if (idx === foldSun - 1) {
192
192
  dropdownMain.push(itm);
193
193
  } else {
194
194
  dropdownItemList.push(itm);
@@ -255,7 +255,16 @@ export default defineComponent({
255
255
  const render = () => {
256
256
  const finalList = filterOptions(); // 最终列表
257
257
  // 是否折叠 折叠
258
- if (props.fold) {
258
+ console.log("🚀 ~ render ~ props:", props);
259
+ let isFold = false;
260
+ if (isBoolean(props.fold)) {
261
+ isFold = props.fold;
262
+ } else if (isNumber(props.fold)) {
263
+ isFold = true;
264
+ } else if (isString(props.fold)) {
265
+ isFold = true;
266
+ }
267
+ if (isFold) {
259
268
  return createDropdown(finalList);
260
269
  } else {
261
270
  // 不折叠
@@ -8,6 +8,8 @@ export type BtnOptions = Expand<
8
8
  {
9
9
  label: string;
10
10
  alias: string;
11
+ type: string;
12
+ icon?: any;
11
13
  permit?: string[];
12
14
  vIf?: (params: any) => boolean;
13
15
  disable?: boolean | ((params: any) => boolean);
@@ -1,9 +1,6 @@
1
1
  import {
2
2
  defineComponent,
3
- ref,
4
3
  h,
5
- computed,
6
- toRefs,
7
4
  type ExtractPropTypes,
8
5
  } from "vue";
9
6
  import { ElDialog } from "element-plus";
@@ -15,18 +12,9 @@ export type DialogAttrs = ExtractPropTypes<typeof dialogAttrs>;
15
12
 
16
13
  export default defineComponent({
17
14
  name: `${prefix}Dialog`,
18
- // props: propsAttrs,
19
- // emits: eventList,
20
15
 
21
16
  // attrs, emit会继承, slots需要设置
22
17
  setup(props: DialogAttrs, { attrs, emit, slots, expose }) {
23
- // const dialogRef = ref();
24
-
25
- // 暴露方法
26
- // expose({
27
- // dialogRef,
28
- // });
29
-
30
18
  // 属性处理
31
19
  const getAttrs = () => {
32
20
  const obj = {
@@ -40,11 +28,10 @@ export default defineComponent({
40
28
  return h(
41
29
  ElDialog,
42
30
  {
43
- // ref: dialogRef,
44
31
  ...getAttrs(),
45
32
  class: "c-dialog",
46
33
  },
47
- slots
34
+ slots,
48
35
  );
49
36
  };
50
37
 
@@ -1,4 +1 @@
1
- import DictLabel from "./src/index.vue";
2
- export * from "./src/index.vue";
3
- export { DictLabel };
4
- export default DictLabel;
1
+ export { default as CDictLabel } from "./src/index.vue";
@@ -2,20 +2,30 @@
2
2
  {{ label }}
3
3
  </template>
4
4
  <script setup lang="ts">
5
- import { computed, PropType } from 'vue'
5
+ import { computed, type PropType } from 'vue'
6
6
  const props = defineProps({
7
+ // 字典选项
7
8
  options: {
8
- type: Array,
9
+ type: Array as PropType<{ value: string; label: string }[]>,
9
10
  default: () => []
10
11
  },
12
+ // 字典值
11
13
  value: {
12
- type: String as PropType<any>,
13
14
  default: ''
14
15
  },
16
+ // 是否将value转换为字符串进行匹配
17
+ stringify: {
18
+ type: Boolean,
19
+ default: false
20
+ }
15
21
  })
16
22
  const label = computed(() => {
17
- // 处理value为数字的情况 后端字典都是字符串
18
- const item = props.options?.find((item) => item.value == props.value.toString());
19
- return item?.label || props.value;
20
- });
23
+ const item = props.options?.find((item) => {
24
+ if (!props.stringify) {
25
+ return item.value === props.value
26
+ }
27
+ return item.value === props.value?.toString()
28
+ })
29
+ return item?.label || props.value
30
+ })
21
31
  </script>
@@ -14,18 +14,8 @@ const drawerAttrs = {};
14
14
  export type DrawerAttrs = ExtractPropTypes<typeof drawerAttrs>;
15
15
 
16
16
  export default defineComponent({
17
- // props: propsAttrs,
18
- // emits: eventList,
19
-
20
17
  // attrs, emit会继承, slots需要设置
21
18
  setup(props: DrawerAttrs, { attrs, emit, slots, expose }) {
22
- // const drawerRef = ref();
23
-
24
- // 暴露方法
25
- // expose({
26
- // drawerRef,
27
- // });
28
-
29
19
  // 属性处理
30
20
  const getAttrs = () => {
31
21
  const obj = {
@@ -39,11 +29,10 @@ export default defineComponent({
39
29
  return h(
40
30
  ElDrawer,
41
31
  {
42
- // ref: drawerRef,
43
32
  ...getAttrs(),
44
33
  class: "c-drawer",
45
34
  },
46
- slots
35
+ slots,
47
36
  );
48
37
  };
49
38
 
@@ -192,15 +192,17 @@ export default defineComponent({
192
192
  ...handleAttrs(),
193
193
  ...handleEvents(),
194
194
  },
195
- () => {
196
- return options?.value?.map((item) => {
197
- return h(ElOption, {
198
- ...item,
199
- label: item.label,
200
- value: item.value,
201
- key: item.value,
195
+ {
196
+ default: () => {
197
+ return options?.value?.map((item) => {
198
+ return h(ElOption, {
199
+ ...item,
200
+ label: item.label,
201
+ value: item.value,
202
+ key: item.value,
203
+ });
202
204
  });
203
- });
205
+ },
204
206
  },
205
207
  );
206
208
  },
@@ -63,8 +63,8 @@ export default defineComponent({
63
63
  const { model, formOptions, readonly, gutter, col } = toRefs(props);
64
64
 
65
65
  // 暴露elForm组件上的方法
66
- const vm = getCurrentInstance(); // 获取虚拟DOM实例
67
- const cFormFnRef = (el) => {
66
+ const vm: any = getCurrentInstance(); // 获取虚拟DOM实例
67
+ const cFormFnRef = (el: any) => {
68
68
  if (!el) return;
69
69
  vm.exposed = el; // 设置暴露对象
70
70
  vm.exposeProxy = el; // 设置代理暴露对象
@@ -78,7 +78,7 @@ export default defineComponent({
78
78
  () =>
79
79
  ["", 0].includes(gutter?.value) ||
80
80
  col?.value ||
81
- formOptions?.value.some((item) => has(item, "col"))
81
+ formOptions?.value.some((item) => has(item, "col")),
82
82
  );
83
83
 
84
84
  // 渲染 row
@@ -95,7 +95,7 @@ export default defineComponent({
95
95
  },
96
96
  {
97
97
  default: () => formItemVdom,
98
- }
98
+ },
99
99
  );
100
100
  } else {
101
101
  return formItemVdom;
@@ -161,14 +161,14 @@ export default defineComponent({
161
161
  span: has(item, "col")
162
162
  ? item.col
163
163
  : col?.value
164
- ? col?.value
165
- : isLayout.value
166
- ? 8
167
- : undefined,
164
+ ? col?.value
165
+ : isLayout.value
166
+ ? 8
167
+ : undefined,
168
168
  },
169
169
  {
170
170
  default: () => (colSlot ? colSlot() : rFormItem()),
171
- }
171
+ },
172
172
  );
173
173
  } else {
174
174
  return rFormItem();
@@ -188,7 +188,7 @@ export default defineComponent({
188
188
  },
189
189
  {
190
190
  default: () => renderRow(),
191
- }
191
+ },
192
192
  );
193
193
  };
194
194
 
@@ -1,4 +1,4 @@
1
- // 字符串转大驼峰
2
- export const formatEventName = (name: string) => {
3
- return name.replace(/(?:^|-)(\w)/g, (_, c) => c.toUpperCase())
4
- }
1
+ // 字符串转大驼峰
2
+ export const formatEventName = (name: string) => {
3
+ return name.replace(/(?:^|-)(\w)/g, (_, c) => c.toUpperCase());
4
+ };
@@ -1,7 +1,8 @@
1
- export * from "./table/index.ts";
2
- export * from "./form/index.ts";
3
- export * from "./pagination/index.ts";
4
- export * from "./dialog/index.ts";
5
- export * from "./drawer/index.ts";
6
- export * from "./search/index.ts";
7
- export * from "./button/index.ts";
1
+ export * from "./table/index.ts"; // 表格
2
+ export * from "./form/index.ts"; // 表单
3
+ export * from "./pagination/index.ts"; // 分页
4
+ export * from "./dialog/index.ts"; // 弹窗
5
+ export * from "./drawer/index.ts"; // 抽屉
6
+ export * from "./search/index.ts"; // 搜索
7
+ export * from "./button/index.ts"; // 按钮
8
+ export * from "./dictLabel/index.ts"; // 字典标签
@@ -15,18 +15,8 @@ const paginationAttrs = {};
15
15
  export type PaginationAttrs = ExtractPropTypes<typeof paginationAttrs>;
16
16
 
17
17
  export default defineComponent({
18
- // props: paginationAttrs,
19
- // emits: eventList,
20
-
21
18
  // attrs, emit会继承, slots需要设置
22
19
  setup(props: PaginationAttrs, { attrs, emit, slots, expose }) {
23
- // const pageRef = ref();
24
-
25
- // 暴露方法
26
- // expose({
27
- // pageRef,
28
- // });
29
-
30
20
  // 属性处理
31
21
  const getAttrs = () => {
32
22
  const obj = {
@@ -38,7 +28,6 @@ export default defineComponent({
38
28
  // 渲染表单
39
29
  const render = () => {
40
30
  return h(ElPagination, {
41
- // ref: pageRef,
42
31
  ...getAttrs(),
43
32
  class: "c-pagination",
44
33
  });
@@ -197,6 +197,7 @@ export default defineComponent({
197
197
 
198
198
  return () => {
199
199
  return (
200
+ // c-search 使用中需要设置动态宽度
200
201
  <div className="c-search">
201
202
  <div className="c-search-simple" ref={simpleRef}>
202
203
  <div className="c-search-simple-form" ref={simpleFormRef}>
@@ -1,2 +1 @@
1
1
  export type { SearchAttrs as SearchProps } from "./index.tsx";
2
- export default "./index.tsx";
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  defineComponent,
3
3
  h,
4
- getCurrentInstance,
5
4
  type ExtractPropTypes,
6
5
  } from "vue";
7
6
  import { ElTableColumn } from "element-plus";
@@ -5,7 +5,7 @@ import {
5
5
  type ExtractPropTypes,
6
6
  } from "vue";
7
7
  import { ElTable, ElTableColumn } from "element-plus";
8
- import TableDictLabel from "./tableDictLabel.vue";
8
+ import { CDictLabel } from "@elementplus-kit/uikit";
9
9
  import {
10
10
  defaultAttrs,
11
11
  tableSlots,
@@ -54,13 +54,12 @@ export type TableAttrs = ExtractPropTypes<typeof tableAttrs>;
54
54
 
55
55
  export default defineComponent({
56
56
  props: tableAttrs,
57
- // emits: eventList,
58
57
 
59
58
  // attrs, emit会继承, slots需要设置
60
59
  setup(props: TableAttrs, { attrs, emit, slots, expose }) {
61
60
  // 暴露elTable组件上的方法
62
- const vm = getCurrentInstance(); // 获取虚拟DOM实例
63
- const cTableFnRef = (el) => {
61
+ const vm: any = getCurrentInstance(); // 获取虚拟DOM实例
62
+ const cTableFnRef = (el: any) => {
64
63
  if (!el) return;
65
64
  vm.exposed = el; // 设置暴露对象
66
65
  vm.exposeProxy = el; // 设置代理暴露对象
@@ -71,40 +70,6 @@ export default defineComponent({
71
70
  // // tableRef,
72
71
  // });
73
72
 
74
- // // 属性处理
75
- // const getAttrs = () => {
76
- // const obj = {
77
- // ...defaultAttrs, // 设置默认值
78
- // };
79
- // return obj;
80
- // };
81
- // // 事件处理
82
- // const getEvents = () => {
83
- // const obj = {
84
- // ...defaultAttrs, // 设置默认值
85
- // };
86
- // return obj;
87
- // };
88
-
89
- // // 处理列数据-数组
90
- // const getArrayColumn = () => {
91
- // // 递归处理数据
92
- // const list = [];
93
-
94
- // const columnsRecursion = (columns, list) => {
95
- // columns?.map((item) => {
96
- // const { children, ...p } = item;
97
- // // 递归处理子列
98
- // if (isArray(item.children)) {
99
- // item.children = c(item.children, list);
100
- // }
101
- // list.push(p);
102
- // });
103
- // };
104
- // columnsRecursion(props.columns, list);
105
- // return list;
106
- // };
107
-
108
73
  // 渲染表格列
109
74
  const renderTableColumn = () => {
110
75
  const list = [];
@@ -115,7 +80,7 @@ export default defineComponent({
115
80
  type: "selection",
116
81
  width: 50,
117
82
  align: "center",
118
- })
83
+ }),
119
84
  );
120
85
  }
121
86
  if (props.showIndex) {
@@ -125,7 +90,7 @@ export default defineComponent({
125
90
  type: "index",
126
91
  width: 60,
127
92
  align: "center",
128
- })
93
+ }),
129
94
  );
130
95
  }
131
96
 
@@ -167,9 +132,10 @@ export default defineComponent({
167
132
  } else if (isArray(item.options)) {
168
133
  // column 字典数组
169
134
  itemSlot["default"] = (scope: any) =>
170
- h(TableDictLabel, {
135
+ h(CDictLabel, {
171
136
  options: item.options,
172
137
  value: scope.row[item.prop],
138
+ stringify: true, // value 转换为字符串
173
139
  });
174
140
  }
175
141
 
@@ -188,8 +154,8 @@ export default defineComponent({
188
154
  h(
189
155
  ElTableColumn,
190
156
  { ...p, class: "c-table-column" },
191
- getColumnContent()
192
- )
157
+ getColumnContent(),
158
+ ),
193
159
  );
194
160
  } else {
195
161
  const getColumnContent = () => {
@@ -204,8 +170,8 @@ export default defineComponent({
204
170
  h(
205
171
  ElTableColumn,
206
172
  { ...p, class: "c-table-column" },
207
- getColumnContent()
208
- )
173
+ getColumnContent(),
174
+ ),
209
175
  );
210
176
  }
211
177
  });
@@ -216,7 +182,7 @@ export default defineComponent({
216
182
 
217
183
  // 插槽处理
218
184
  const getSlots = () => {
219
- const obj = {};
185
+ const obj: any = {};
220
186
  tableSlots.map((name) => {
221
187
  if (slots[name]) {
222
188
  obj[name] = slots[name];
@@ -226,9 +192,6 @@ export default defineComponent({
226
192
  };
227
193
  // 渲染表格组件
228
194
  const renderTable = () => {
229
- // getColumnList();
230
- // console.log("props", props);
231
- // console.log("attrs", attrs);
232
195
  // 先拼接好子数据不然会重复执行多次
233
196
  const columnList = renderTableColumn();
234
197
  return h(
@@ -241,7 +204,7 @@ export default defineComponent({
241
204
  {
242
205
  default: () => columnList,
243
206
  ...getSlots(),
244
- }
207
+ },
245
208
  );
246
209
  };
247
210
 
@@ -2,14 +2,13 @@
2
2
  {{ label }}
3
3
  </template>
4
4
  <script setup lang="ts">
5
- import { computed, PropType } from 'vue'
5
+ import { computed, type PropType } from 'vue'
6
6
  const props = defineProps({
7
7
  options: {
8
- type: Array,
8
+ type: Array as PropType<{ value: string; label: string }[]>,
9
9
  default: () => []
10
10
  },
11
11
  value: {
12
- type: String as PropType<any>,
13
12
  default: ''
14
13
  },
15
14
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementplus-kit/uikit",
3
- "version": "1.9.0",
3
+ "version": "1.11.0",
4
4
  "description": "",
5
5
  "main": "./components/index.ts",
6
6
  "peerDependencies": {
@@ -1,2 +0,0 @@
1
- export type textType2 = "1" | "2" | "3";
2
- export type textType3 = "2" | "3" | "4";
@@ -1 +0,0 @@
1
- import { TableProps, TableColumnProps } from "@elementplus-kit/uikit";
@@ -1,3 +0,0 @@
1
- type textType1 = "a" | "b" | "c";
2
- export type textType2 = "1" | "2" | "3";
3
- export type textType3 = "2" | "3" | "4";