wui-components-v2 1.2.6 → 1.2.8
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.
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<view size="small" @click="handleCopy" class="bg-[#1c64fd] text-white px-[12rpx] leading-[32rpx] rounded-[4px]">
|
|
3
|
+
{{ '复制' }}
|
|
4
|
+
</view>
|
|
3
5
|
</template>
|
|
4
6
|
<script setup lang="ts">
|
|
5
7
|
import { editPageConfig, copyDataApi } from '../../api/page'
|
|
@@ -129,8 +129,10 @@ function initFormData() {
|
|
|
129
129
|
// 开关:归一化为 "是"/"否" 字符串,避免 wd-switch 在 onBeforeMount 校验时
|
|
130
130
|
// 因 modelValue 非 active/inactive 值(如 ''、布尔、数字)被强制重置为未选中
|
|
131
131
|
if (ControlTypeSupportor.getControlType(item, props.entity && props.entity[item.sourceId]) === 'yes-no-switch') {
|
|
132
|
-
const
|
|
133
|
-
|
|
132
|
+
const defRaw = (props.entity && props.entity[item.sourceId]) ?? item.transDefaultValue
|
|
133
|
+
// def 运行时可能是 string / boolean / number,统一转字符串再比较,避免与字面量类型比较的 TS 报错
|
|
134
|
+
const defStr = defRaw === null || defRaw === undefined ? '' : String(defRaw)
|
|
135
|
+
const isYes = defStr === '是' || defStr === 'true' || defStr === '1'
|
|
134
136
|
return (models[item.sourceId] = isYes ? '是' : '否')
|
|
135
137
|
}
|
|
136
138
|
|
|
@@ -388,37 +390,67 @@ watch(
|
|
|
388
390
|
)
|
|
389
391
|
//-e subRelValueField 联动
|
|
390
392
|
|
|
391
|
-
//
|
|
393
|
+
// 按「当前项 sourceId」分组存储联动参数:
|
|
394
|
+
// { [当前项sourceId]: { relValueField: 指向字段的表单值, relValueField3: 指向字段的表单值 } }
|
|
392
395
|
const changedData = ref<Record<string, any>>({})
|
|
393
|
-
const initialModel = ref<Record<string, any>>({})
|
|
394
396
|
|
|
395
|
-
// 监听 shouldMonitor 中 relValueField / relValueField3 对应的 model
|
|
397
|
+
// 监听 shouldMonitor 中 relValueField / relValueField3 对象下 id 对应的 model 字段,
|
|
398
|
+
// 把这两个 id 对应的表单值作为参数回传给「当前项」(按当前项 sourceId 分组,避免多字段互相覆盖)
|
|
396
399
|
watch(
|
|
397
400
|
() => {
|
|
401
|
+
// 按当前项 sourceId 分别记录其 relValueField / relValueField3 指向字段的当前值
|
|
398
402
|
const snapshot: Record<string, any> = {}
|
|
399
403
|
shouldMonitor.value?.forEach((item: any) => {
|
|
400
|
-
|
|
401
|
-
|
|
404
|
+
snapshot[item.id] = {
|
|
405
|
+
relValueField: item.relValueField ? model.value[item.relValueField] : undefined,
|
|
406
|
+
relValueField3: item.relValueField3 ? model.value[item.relValueField3] : undefined,
|
|
407
|
+
}
|
|
402
408
|
})
|
|
403
409
|
return snapshot
|
|
404
410
|
},
|
|
405
|
-
newVal => {
|
|
406
|
-
//
|
|
411
|
+
(newVal, oldVal) => {
|
|
412
|
+
// 当 relValueField / relValueField3 指向的字段值发生变化时,清空「当前项」自身的数据
|
|
413
|
+
// (oldVal 为 undefined 表示首次执行,跳过清空,避免初始化时误清)
|
|
414
|
+
if (oldVal) {
|
|
415
|
+
shouldMonitor.value?.forEach((item: any) => {
|
|
416
|
+
const oldSnap = oldVal[item.id] || {}
|
|
417
|
+
const newSnap = newVal[item.id] || {}
|
|
418
|
+
const relChanged =
|
|
419
|
+
item.relValueField && oldSnap.relValueField !== newSnap.relValueField
|
|
420
|
+
const rel3Changed =
|
|
421
|
+
item.relValueField3 && oldSnap.relValueField3 !== newSnap.relValueField3
|
|
422
|
+
if (relChanged || rel3Changed) {
|
|
423
|
+
model.value[item.id] = ''
|
|
424
|
+
}
|
|
425
|
+
})
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// 当前项存在 relValueField / relValueField3 时,把其 id 对应的表单值作为联动参数带上
|
|
407
429
|
const changed: Record<string, any> = {}
|
|
408
430
|
shouldMonitor.value?.forEach((item: any) => {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
if (item.relValueField3
|
|
413
|
-
|
|
414
|
-
}
|
|
431
|
+
const snap = newVal[item.id] || {}
|
|
432
|
+
const entry: Record<string, any> = {}
|
|
433
|
+
if (item.relValueField) entry.relValueField = snap.relValueField
|
|
434
|
+
if (item.relValueField3) entry.relValueField3 = snap.relValueField3
|
|
435
|
+
changed[item.id] = entry
|
|
415
436
|
})
|
|
416
437
|
changedData.value = changed
|
|
417
438
|
|
|
418
|
-
//
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
|
|
439
|
+
// 任一被监听字段有值时即写入缓存,供对应字段的 select 弹窗按 sourceId 读取自己的联动参数
|
|
440
|
+
const hasValue = shouldMonitor.value?.some((item: any) => {
|
|
441
|
+
const snap = newVal[item.id] || {}
|
|
442
|
+
return (
|
|
443
|
+
(item.relValueField &&
|
|
444
|
+
snap.relValueField !== undefined &&
|
|
445
|
+
snap.relValueField !== null &&
|
|
446
|
+
snap.relValueField !== '') ||
|
|
447
|
+
(item.relValueField3 &&
|
|
448
|
+
snap.relValueField3 !== undefined &&
|
|
449
|
+
snap.relValueField3 !== null &&
|
|
450
|
+
snap.relValueField3 !== '')
|
|
451
|
+
)
|
|
452
|
+
})
|
|
453
|
+
if (shouldMonitor.value?.length && hasValue) {
|
|
422
454
|
uni.setStorageSync('paramsData', {
|
|
423
455
|
changedData: changedData.value,
|
|
424
456
|
rawData: shouldMonitor.value,
|
|
@@ -434,7 +466,6 @@ action.value = uni.getStorageSync('BASE_URL')
|
|
|
434
466
|
hydrocarbonProgramToken.value = uni.getStorageSync('HYDROCARBON_PROGRAM_TOKEN')
|
|
435
467
|
token.value = uni.getStorageSync('TOKEN')
|
|
436
468
|
initFormData()
|
|
437
|
-
initialModel.value = JSON.parse(JSON.stringify(model.value))
|
|
438
469
|
|
|
439
470
|
// 小程序端 setData 异步:wd-switch 在 popup 内延迟挂载时,onBeforeMount 可能读到
|
|
440
471
|
// 初始(未同步)的 modelValue,被组件校正逻辑强制重置为 inactiveValue("否")。
|
|
@@ -241,7 +241,8 @@ async function queryList(pageNo: number, pageSize: number) {
|
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
// 步骤2:构建查询参数
|
|
244
|
-
|
|
244
|
+
// 按当前字段 sourceId 读取其专属联动参数(relValueField / relValueField3 指向字段的表单值)
|
|
245
|
+
const search = uni.getStorageSync('paramsData')?.changedData?.[props.sourceId] || {}
|
|
245
246
|
const newParams = {
|
|
246
247
|
thirdCriterion: search.relValueField3 || '',
|
|
247
248
|
secondCriterion: search.relValueField?.toString() || '',
|