@skyfox2000/webui 1.5.14 → 1.5.16

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyfox2000/webui",
3
- "version": "1.5.14",
3
+ "version": "1.5.16",
4
4
  "description": "后台前端通用组件定义, 支持国际化",
5
5
  "type": "module",
6
6
  "keywords": [],
@@ -1,18 +1,11 @@
1
1
  <script setup lang="ts">
2
2
  import { formValidate, useInputFactory } from '@/index';
3
3
  import { Input } from 'ant-design-vue';
4
- import { ref, watch } from 'vue';
4
+ import { ref, watch, computed, useAttrs } from 'vue';
5
5
  import { useI18n } from 'vue-i18n';
6
6
  const { t } = useI18n();
7
7
 
8
8
  const { editorCtrl, labelText, errInfo } = useInputFactory();
9
- const onBlur = () => {
10
- if (errInfo?.value.errClass && editorCtrl) {
11
- /// 重新开始验证
12
- formValidate(editorCtrl);
13
- }
14
- };
15
-
16
9
  const props = withDefaults(defineProps<{
17
10
  value?: any;
18
11
  /**
@@ -29,7 +22,22 @@ const props = withDefaults(defineProps<{
29
22
 
30
23
  // 如果初始value为undefined,自动设置undefValue为true
31
24
  const undefValue = props.value === undefined ? true : props.undefValue;
32
- const emit = defineEmits(['update:value']);
25
+ const emit = defineEmits(['update:value', 'blur', 'change']);
26
+
27
+ // 过滤已配置的事件处理器
28
+ const filteredAttrs = computed(() => {
29
+ const { onBlur, onChange, ...rest } = useAttrs();
30
+ return rest;
31
+ });
32
+
33
+ const onBlur = (e: any) => {
34
+ if (errInfo?.value.errClass && editorCtrl) {
35
+ /// 重新开始验证
36
+ formValidate(editorCtrl);
37
+ }
38
+ emit('blur', e)
39
+ };
40
+
33
41
  // 内部值,拦截外部传入的 value
34
42
  const innerValue = ref(props.value);
35
43
 
@@ -53,10 +61,12 @@ watch(
53
61
  },
54
62
  );
55
63
 
56
- const onClear = () => {
64
+ const onClear = (e: any) => {
57
65
  if (innerValue.value === '') {
58
66
  innerValue.value = undefValue ? undefined : null;
59
67
  }
68
+
69
+ emit('change', e)
60
70
  };
61
71
  </script>
62
72
  <template>
@@ -65,16 +75,8 @@ const onClear = () => {
65
75
  errInfo?.errClass,
66
76
  errInfo?.errClass === 'error' && !$slots.addonBefore && !$slots.addonAfter
67
77
  ? '!border-red-300 shadow-[0_0_3px_0px_#ff4d4f]'
68
- : '',
69
- ]"
70
- v-model:value="innerValue"
71
- autocomplete="new-password"
72
- :allow-clear="true"
73
- :placeholder="t('webui.common.placeholder', [labelText])"
74
- @blur="onBlur"
75
- @change="onClear"
76
- v-bind="$attrs"
77
- >
78
+ : '',]" v-model:value="innerValue" autocomplete="new-password" :allow-clear="true"
79
+ :placeholder="t('webui.common.placeholder', [labelText])" @blur="onBlur" @change="onClear" v-bind="filteredAttrs">
78
80
  <template #addonBefore v-if="$slots.addonBefore">
79
81
  <slot name="addonBefore"></slot>
80
82
  </template>
package/src/utils/page.ts CHANGED
@@ -246,10 +246,10 @@ export const useOptionFactory = (url?: IUrlInfo, props?: OptionProps) => {
246
246
  url: url,
247
247
  reload: ref(false),
248
248
  optionQuery: {},
249
- data: shallowRef([]),
249
+ data: shallowRef(props?.data ?? []),
250
250
  selected: ref([]),
251
251
  selectedOptions: ref([]),
252
- options: ref([]),
252
+ options: ref(props?.data ?? []),
253
253
  isOptionLoading: ref(false),
254
254
  };
255
255