wui-components-v2 1.1.53 → 1.1.54

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.
@@ -82,11 +82,25 @@ const fetchDataById = async (id: string) => {
82
82
  showValue.phone = textArr?.[1] || ''
83
83
  showValue.address = textArr?.[2] || ''
84
84
  }
85
+ // 数据获取完成后,触发 emit
86
+ emitIfNeeded(id)
85
87
  } catch (error) {
86
88
  console.error('获取数据失败:', error)
87
89
  }
88
90
  }
89
91
 
92
+ const emitIfNeeded = (val: string) => {
93
+ if (!val) return
94
+ let emitVal = val
95
+ if (typeof val === 'string' && !val.includes('@R@')) {
96
+ emitVal = val + '@R@' + showValue.name
97
+ }
98
+ if (emitVal !== props.modelValue) {
99
+ console.log('emit update:modelValue', emitVal)
100
+ emit('update:modelValue', emitVal)
101
+ }
102
+ }
103
+
90
104
  onMounted(() => {
91
105
  if (currentValue.value) {
92
106
  fetchDataById(currentValue.value)
@@ -112,10 +126,16 @@ watch(() => props.modelValue, (val) => {
112
126
  })
113
127
 
114
128
  watch(currentValue, (val) => {
115
- emit('update:modelValue', val)
116
- })
129
+ if (!val) return
130
+ // 如果值已经包含@R@(无需异步获取数据),直接 emit
131
+ if (typeof val === 'string' && val.includes('@R@')) {
132
+ if (val !== props.modelValue) {
133
+ emit('update:modelValue', val)
134
+ }
135
+ }
136
+ // 否则由 fetchDataById 成功后调用 emitIfNeeded 来 emit
137
+ }, { immediate: true })
117
138
  </script>
118
-
119
139
  <style scoped lang="scss">
120
140
  .custom-select-picker {
121
141
  width: 100%;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wui-components-v2",
3
- "version": "1.1.53",
3
+ "version": "1.1.54",
4
4
  "description": "wui 组件库",
5
5
  "author": "wgxshh",
6
6
  "license": "MIT",