@skyfox2000/webui 1.3.8 → 1.3.9

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.3.8",
3
+ "version": "1.3.9",
4
4
  "description": "后台前端通用组件定义",
5
5
  "type": "module",
6
6
  "keywords": [],
@@ -19,18 +19,14 @@ const attrs = useAttrs(); // 手动获取 $attrs
19
19
  <Popover placement="topRight">
20
20
  <template #content>
21
21
  <slot>
22
- <div class="text-[14px]" :style="{ maxWidth }">
22
+ <div class="text-[14px]" :class="[maxWidth]">
23
23
  {{ text }}
24
24
  </div>
25
25
  </slot>
26
26
  </template>
27
27
  <span class="ml-2">
28
- <ToolIcon
29
- icon="icon-question-circle"
30
- class="text-[#888]"
31
- :class="[size ? 'w-' + size + ' h-' + size : 'w-5 h-5']"
32
- v-bind="attrs"
33
- />
28
+ <ToolIcon icon="icon-question-circle" class="text-[#888]"
29
+ :class="[size ? 'w-' + size + ' h-' + size : 'w-5 h-5']" v-bind="attrs" />
34
30
  </span>
35
31
  </Popover>
36
32
  </template>
@@ -60,6 +60,7 @@ const getRule = (rule: Array<string>, ruleObj: Record<string, any> | undefined):
60
60
  if (rule.length === 1) {
61
61
  return ruleObj[key];
62
62
  }
63
+ if (!ruleObj[key]) return undefined;
63
64
  return getRule(rest, ruleObj[key].fields as Record<string, any>);
64
65
  };
65
66
  /**
@@ -92,18 +93,13 @@ const required = computed(() => {
92
93
  </script>
93
94
  <template>
94
95
  <div :class="['relative', bottomMargin ? bottomMargin : 'mb-1']">
95
- <FormItem
96
- v-if="visible"
97
- :required="required"
98
- class="relative"
99
- :class="[nextLine ? 'mb-0' : rule ? '' : 'mb-3']"
100
- v-bind="attrs"
101
- >
96
+ <FormItem v-if="visible" :required="required" class="relative" :class="[nextLine ? 'mb-0' : rule ? '' : 'mb-3']"
97
+ v-bind="attrs">
102
98
  <template #label>
103
99
  <span :class="[errInfo.errClass ? 'text-[#ff4d4f]' : '', 'w-full']"> {{ label }}</span>
104
100
  </template>
105
- <div class="flex items-center" :class="width ? width : 'w-full'" v-if="!nextLine">
106
- <div class="flex-grow">
101
+ <div class="flex items-center" :class="width ? width : 'w-full'">
102
+ <div class="flex-grow" v-if="!nextLine">
107
103
  <slot></slot>
108
104
  </div>
109
105
  <div class="w-8 mt-[-2px]">
@@ -113,18 +109,12 @@ const required = computed(() => {
113
109
  </div>
114
110
  </div>
115
111
  </FormItem>
116
- <div
117
- v-if="nextLine"
118
- class="w-[95%] flex items-center relative"
119
- :class="[nextLine ? (rule ? 'mb-7' : 'mb-3') : '']"
120
- >
112
+ <div v-if="nextLine" class="w-[95%] flex items-center relative"
113
+ :class="[nextLine ? (rule ? 'mb-7' : 'mb-3') : '']">
121
114
  <slot></slot>
122
115
  </div>
123
- <span
124
- :style="{ left: nextLine ? '2px' : labelWidth }"
125
- class="absolute bottom-[3px] text-[12px] text-[#ff4d4fcc]"
126
- v-if="errInfo.errClass"
127
- >
116
+ <span :style="{ left: nextLine ? '2px' : labelWidth }" class="absolute bottom-[3px] text-[12px] text-[#ff4d4fcc]"
117
+ v-if="errInfo.errClass">
128
118
  {{ errInfo.msg }}
129
119
  </span>
130
120
  </div>
@@ -66,8 +66,7 @@ const defaultVal = ref(props.value);
66
66
  const placeholder = ref(attrs.placeholder);
67
67
 
68
68
  /// 避免类型错误
69
- /// 初始化禁止使用optionCtrl.selected值,避免组件值缓存
70
- const innerValue = ref<string | number | string[] | number[] | undefined>(undefined);
69
+ const innerValue = ref<string | number | string[] | number[] | undefined>(optionCtrl?.selected.value || undefined);
71
70
  const emit = defineEmits(['change', 'update:value', 'update:label', 'update:labels']);
72
71
  inputFactory.inputEmit = emit;
73
72
 
@@ -30,7 +30,7 @@ const props = defineProps({
30
30
  });
31
31
 
32
32
  // 如果初始value为undefined,自动设置undefValue为true
33
- const undefValue = props.value === undefined ? true : props.undefValue;
33
+ const undefVal = props.value === undefined ? true : props.undefValue;
34
34
 
35
35
  const treeCtrl = props.treeCtrl;
36
36
 
@@ -54,6 +54,12 @@ watch(
54
54
  },
55
55
  { immediate: true },
56
56
  );
57
+ watch(
58
+ () => currentValue.value,
59
+ (newVal) => {
60
+ emit('update:value', newVal);
61
+ },
62
+ );
57
63
 
58
64
  // 监听树数据变化
59
65
  watch(
@@ -71,10 +77,14 @@ const handleChange = (value: SelectValue) => {
71
77
  if (props.multiple) {
72
78
  currentValue.value = value ?? [];
73
79
  } else {
74
- currentValue.value = value ?? undefValue ? undefined : null;
80
+ // 修复原始代码中的逻辑错误
81
+ if (value === undefined || value === null) {
82
+ currentValue.value = undefVal ? undefined : null;
83
+ } else {
84
+ currentValue.value = value;
85
+ }
75
86
  }
76
87
  emit('change', currentValue.value);
77
- emit('update:value', currentValue.value);
78
88
  };
79
89
 
80
90
  // 组件挂载时加载数据
@@ -94,8 +104,9 @@ onMounted(() => {
94
104
  queryTree(props.treeCtrl);
95
105
  }
96
106
  });
107
+
97
108
  const onClear = () => {
98
- currentValue.value = undefValue ? undefined : null;
109
+ currentValue.value = undefVal ? undefined : null;
99
110
  };
100
111
  </script>
101
112
 
@@ -109,4 +120,4 @@ const onClear = () => {
109
120
  border-color: #ef444480;
110
121
  box-shadow: 0 0 3px 0 #ff4d4f;
111
122
  }
112
- </style>
123
+ </style>