wui-components-v2 1.1.83 → 1.1.84

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.
@@ -193,31 +193,26 @@ const subRelMonitor = computed(() =>
193
193
  // 仅当字段类型(extControlType)不在排除列表中才参与联动监听
194
194
  .filter((item: any) => !EXCLUDE_CONTROL_TYPES.includes(item.extControlType))
195
195
  .flatMap((item: any) =>
196
- REL_FIELD_CONFIG
197
- .map(({ key, assignment }) => {
198
- const rel = (item as any)[key]
199
- // subRelValueField:兼容嵌套在 rel 字段下,或 item 同级(仅 relValueField 兼容同级)
200
- const subRel =
201
- rel?.subRelValueField ||
202
- (key === 'relValueField' ? (item as any).subRelValueField : undefined)
203
- if (!rel || !subRel) return null
204
- // 找到原始字段对象(props.fieldGroup.fields 中):filteredFields 每次重算会浅拷贝生成新对象,
205
- // 只改拷贝对象会在重算时丢失 max/min,因此同时持有原始对象引用,双写以保证不丢值
206
- const rawItem =
207
- (props.fieldGroup?.fields || []).find((f: any) => f.sourceId === item.sourceId) || item
208
- return {
209
- monitorKey: `${item.sourceId}__${key}`, // 唯一键,避免多 rel 字段共用 paramSourceId 相互干扰
210
- item, // filteredFields 中的拷贝对象,直接改可立即触发模板更新
211
- rawItem, // 原始字段对象,改它可在 filteredFields 重算后保留 max/min
212
- itemSourceId: item.sourceId,
213
- assignment, // 'value' | 'max' | 'min'
214
- valueSourceKey: subRel.sourceId, // 从接口返回 fieldMap 取值所用的 key
215
- paramSourceId: rel.sourceId || rel.id, // 请求参数来源字段
216
- useA: !!rel.extRefPageId,
217
- extRefPageId: rel.extRefPageId,
218
- }
219
- })
220
- .filter((m: any) => m && m.paramSourceId && m.valueSourceKey)
196
+ REL_FIELD_CONFIG.map(({ key, assignment }) => {
197
+ const rel = (item as any)[key]
198
+ // subRelValueField:兼容嵌套在 rel 字段下,或 item 同级(仅 relValueField 兼容同级)
199
+ const subRel = rel?.subRelValueField || (key === 'relValueField' ? (item as any).subRelValueField : undefined)
200
+ if (!rel || !subRel) return null
201
+ // 找到原始字段对象(props.fieldGroup.fields 中):filteredFields 每次重算会浅拷贝生成新对象,
202
+ // 只改拷贝对象会在重算时丢失 max/min,因此同时持有原始对象引用,双写以保证不丢值
203
+ const rawItem = (props.fieldGroup?.fields || []).find((f: any) => f.sourceId === item.sourceId) || item
204
+ return {
205
+ monitorKey: `${item.sourceId}__${key}`, // 唯一键,避免多 rel 字段共用 paramSourceId 相互干扰
206
+ item, // filteredFields 中的拷贝对象,直接改可立即触发模板更新
207
+ rawItem, // 原始字段对象,改它可在 filteredFields 重算后保留 max/min
208
+ itemSourceId: item.sourceId,
209
+ assignment, // 'value' | 'max' | 'min'
210
+ valueSourceKey: subRel.sourceId, // 从接口返回 fieldMap 取值所用的 key
211
+ paramSourceId: rel.sourceId || rel.id, // 请求参数来源字段
212
+ useA: !!rel.extRefPageId,
213
+ extRefPageId: rel.extRefPageId,
214
+ }
215
+ }).filter((m: any) => m && m.paramSourceId && m.valueSourceKey)
221
216
  )
222
217
  )
223
218
  const { setFieldValue, getFieldValue } = useFormFieldValues()
@@ -281,11 +276,23 @@ watch(
281
276
  const fromStore = getFieldValue(m.paramSourceId)
282
277
  const fromEntity = (props.entity as any)?.[m.paramSourceId]
283
278
  const finalVal =
284
- local !== undefined && local !== '' ? local
285
- : fromStore !== undefined && fromStore !== '' ? fromStore
286
- : fromEntity !== undefined && fromEntity !== '' ? fromEntity
279
+ local !== undefined && local !== ''
280
+ ? local
281
+ : fromStore !== undefined && fromStore !== ''
282
+ ? fromStore
283
+ : fromEntity !== undefined && fromEntity !== ''
284
+ ? fromEntity
287
285
  : undefined
288
- console.log(`[subRel] 来源取值 ${m.monitorKey} sourceId=${m.paramSourceId} | local=`, local, '| store=', fromStore, '| props.entity=', fromEntity, '=> 采用', finalVal)
286
+ console.log(
287
+ `[subRel] 来源取值 ${m.monitorKey} sourceId=${m.paramSourceId} | local=`,
288
+ local,
289
+ '| store=',
290
+ fromStore,
291
+ '| props.entity=',
292
+ fromEntity,
293
+ '=> 采用',
294
+ finalVal
295
+ )
289
296
  snapshot[m.monitorKey] = finalVal
290
297
  })
291
298
  return snapshot
@@ -295,10 +302,18 @@ watch(
295
302
  const val = newVal[m.monitorKey]
296
303
  const prev = lastSubRelSnapshot.value[m.monitorKey]
297
304
  lastSubRelSnapshot.value[m.monitorKey] = val
298
- console.log('[subRel] 处理', m.monitorKey,
299
- '| assignment=', m.assignment,
300
- '| 参数来源sourceId=', m.paramSourceId,
301
- '| 取到的值val=', val, '| 上次值prev=', prev)
305
+ console.log(
306
+ '[subRel] 处理',
307
+ m.monitorKey,
308
+ '| assignment=',
309
+ m.assignment,
310
+ '| 参数来源sourceId=',
311
+ m.paramSourceId,
312
+ '| 取到的值val=',
313
+ val,
314
+ '| 上次值prev=',
315
+ prev
316
+ )
302
317
  // 仅在选中值存在且发生变化时请求,避免无意义重复调用
303
318
  if (val !== undefined && val !== null && val !== '' && val !== prev) {
304
319
  try {
@@ -308,11 +323,11 @@ watch(
308
323
  if (m.useA) {
309
324
  api = topData
310
325
  apiName = '/v3/ltmpl/top-data'
311
- param = { top: 1, code: val, sourceId: m.extRefPageId }
326
+ param = { top: 1, secondCriterion: val, sourceId: m.extRefPageId }
312
327
  } else {
313
328
  api = dtmplData
314
329
  apiName = '/v3/dtmpl/data'
315
- param = { top: 1, code: val, sourceId: m.paramSourceId }
330
+ param = { top: 1, secondCriterion: val, sourceId: m.paramSourceId }
316
331
  }
317
332
  console.log('[subRel] >>> 发起请求', apiName, '参数=', param)
318
333
  const res = await api(param)
@@ -352,10 +367,12 @@ watch(
352
367
  }
353
368
  } else {
354
369
  // 没进请求分支:常见原因是 val 为空(跨页面没取到值)或值未变化
355
- console.warn('[subRel] ✗ 未发起请求 ——',
370
+ console.warn(
371
+ '[subRel] ✗ 未发起请求 ——',
356
372
  val === undefined || val === null || val === ''
357
373
  ? `参数来源值 val 为空(跨页面存储未取到 sourceId=${m.paramSourceId} 的值)`
358
- : `值未发生变化(prev=${prev})`)
374
+ : `值未发生变化(prev=${prev})`
375
+ )
359
376
  }
360
377
  }
361
378
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wui-components-v2",
3
- "version": "1.1.83",
3
+ "version": "1.1.84",
4
4
  "description": "wui 组件库",
5
5
  "author": "wgxshh",
6
6
  "license": "MIT",