@elementplus-kit/uikit 1.9.0 → 1.10.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,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>
@@ -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
  },
@@ -5,3 +5,4 @@ export * from "./dialog/index.ts";
5
5
  export * from "./drawer/index.ts";
6
6
  export * from "./search/index.ts";
7
7
  export * from "./button/index.ts";
8
+ export * from "./dictLabel/index.ts";
@@ -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,
@@ -115,7 +115,7 @@ export default defineComponent({
115
115
  type: "selection",
116
116
  width: 50,
117
117
  align: "center",
118
- })
118
+ }),
119
119
  );
120
120
  }
121
121
  if (props.showIndex) {
@@ -125,7 +125,7 @@ export default defineComponent({
125
125
  type: "index",
126
126
  width: 60,
127
127
  align: "center",
128
- })
128
+ }),
129
129
  );
130
130
  }
131
131
 
@@ -167,9 +167,10 @@ export default defineComponent({
167
167
  } else if (isArray(item.options)) {
168
168
  // column 字典数组
169
169
  itemSlot["default"] = (scope: any) =>
170
- h(TableDictLabel, {
170
+ h(CDictLabel, {
171
171
  options: item.options,
172
172
  value: scope.row[item.prop],
173
+ stringify: true, // value 转换为字符串
173
174
  });
174
175
  }
175
176
 
@@ -188,8 +189,8 @@ export default defineComponent({
188
189
  h(
189
190
  ElTableColumn,
190
191
  { ...p, class: "c-table-column" },
191
- getColumnContent()
192
- )
192
+ getColumnContent(),
193
+ ),
193
194
  );
194
195
  } else {
195
196
  const getColumnContent = () => {
@@ -204,8 +205,8 @@ export default defineComponent({
204
205
  h(
205
206
  ElTableColumn,
206
207
  { ...p, class: "c-table-column" },
207
- getColumnContent()
208
- )
208
+ getColumnContent(),
209
+ ),
209
210
  );
210
211
  }
211
212
  });
@@ -241,7 +242,7 @@ export default defineComponent({
241
242
  {
242
243
  default: () => columnList,
243
244
  ...getSlots(),
244
- }
245
+ },
245
246
  );
246
247
  };
247
248
 
@@ -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.10.0",
4
4
  "description": "",
5
5
  "main": "./components/index.ts",
6
6
  "peerDependencies": {