wui-components-v2 1.1.58 → 1.1.59

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.
@@ -301,6 +301,9 @@ async function save() {
301
301
  if (editEvent.value)
302
302
  uni.$emit(editEvent.value, res.entityCode)
303
303
 
304
+ // ★ 通知 wui-select-popup 刷新列表数据
305
+ uni.$emit('selectPopup:refresh', sourceId.value)
306
+
304
307
  subLoading.value = false
305
308
  router.back()
306
309
  }).catch((error: any) => {
@@ -1,10 +1,11 @@
1
1
  <script setup lang="ts">
2
- import { computed, nextTick, onUnmounted, ref, watch } from 'vue'
2
+ import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
3
3
  import { enums, listData, pageConfig, pageKey } from '../../api/page'
4
4
  import foldCard from '../fold-card/fold-card.vue'
5
5
  import Search from '../search/search.vue'
6
6
  import type { Config, Entities, Enums, FoldCardModel } from '../../type'
7
7
  import { useGlobalToast } from '../../composables/useGlobalToast'
8
+ import listTopButtons from '../list-top-buttons/list-top-buttons.vue'
8
9
 
9
10
  defineOptions({
10
11
  name: 'WuiSelectPopup',
@@ -158,6 +159,8 @@ const formatAddress = (value: string) => {
158
159
 
159
160
  // 标记是否已获取配置
160
161
  const isConfigLoaded = ref(false)
162
+ // ★ 防止重复加载
163
+ const isLoading = ref(false)
161
164
 
162
165
  // ★ 是否已完成默认首项选中
163
166
  const hasDefaultSelected = ref(false)
@@ -174,7 +177,6 @@ watch(datas, val => {
174
177
  : Object.values(selectData.value)
175
178
  emit('update:modelValue', result)
176
179
  hasDefaultSelected.value = true
177
- console.log('[WuiSelectPopup] ✅ 默认选中首项:', first.code)
178
180
  })
179
181
 
180
182
  // 获取页面配置
@@ -215,6 +217,10 @@ async function getEnums() {
215
217
 
216
218
  // 查询列表数据(完整流程:config -> key -> data)
217
219
  async function queryList(pageNo: number, pageSize: number) {
220
+ // ★ 首次加载时防重复(分页加载不拦截,pageNo > 1 时放行)
221
+ if (pageNo === 1 && isLoading.value) return
222
+ if (pageNo === 1) isLoading.value = true
223
+
218
224
  try {
219
225
  // 步骤1:确保配置已加载
220
226
  if (!isConfigLoaded.value) {
@@ -261,6 +267,8 @@ async function queryList(pageNo: number, pageSize: number) {
261
267
  } catch (error) {
262
268
  console.error('[WuiSelectPopup] ❌ 数据加载失败:', error)
263
269
  Zpaging.value.complete(false)
270
+ } finally {
271
+ if (pageNo === 1) isLoading.value = false
264
272
  }
265
273
  }
266
274
 
@@ -336,6 +344,7 @@ function openPopup(e?: any) {
336
344
  watch(show, async val => {
337
345
  console.log('[WuiSelectPopup] 📢 show 状态变化:', val)
338
346
  if (val) {
347
+ if (isLoading.value) return // ★ 防重复
339
348
  isConfigLoaded.value = false
340
349
  await nextTick()
341
350
  if (Zpaging.value) {
@@ -350,7 +359,22 @@ watch(show, async val => {
350
359
  }
351
360
  })
352
361
 
362
+ // ★ 监听 edit-page 返回后刷新数据(通过 sourceId 过滤,只响应自己的刷新)
363
+ function handleRefresh(refreshSourceId: string) {
364
+ if (refreshSourceId !== props.sourceId) return
365
+ console.log('[WuiSelectPopup] 🔄 收到刷新信号,重新加载数据')
366
+ if (show.value && Zpaging.value && !isLoading.value) {
367
+ isConfigLoaded.value = false
368
+ Zpaging.value.reload()
369
+ }
370
+ }
371
+
372
+ onMounted(() => {
373
+ uni.$on('selectPopup:refresh', handleRefresh)
374
+ })
375
+
353
376
  onUnmounted(() => {
377
+ uni.$off('selectPopup:refresh', handleRefresh)
354
378
  uni.removeStorageSync('paramsData')
355
379
  })
356
380
 
@@ -430,6 +454,9 @@ defineExpose({
430
454
  :primary-criteria="config.primaryCriteria"
431
455
  @submit="submitSearch"
432
456
  />
457
+ <view>
458
+ <listTopButtons :buttons="config.buttons" :source-id="sourceId" :page-title="pageTitle" />
459
+ </view>
433
460
  <slot name="top" />
434
461
  </template>
435
462
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wui-components-v2",
3
- "version": "1.1.58",
3
+ "version": "1.1.59",
4
4
  "description": "wui 组件库",
5
5
  "author": "wgxshh",
6
6
  "license": "MIT",
@@ -1,2 +0,0 @@
1
- allowBuilds:
2
- '@parcel/watcher': set this to true or false