wui-components-v2 1.2.9 → 1.2.11
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.
|
@@ -303,11 +303,7 @@ console.log(props, '3333333333333')
|
|
|
303
303
|
</wd-button>
|
|
304
304
|
</template>
|
|
305
305
|
</template>
|
|
306
|
-
<wd-button
|
|
307
|
-
v-if="isShowAction !== false && props.item.buttons.includes('copy') && isActionVisible(props.buttonEditAction)"
|
|
308
|
-
size="small"
|
|
309
|
-
@click="handleCopy"
|
|
310
|
-
>
|
|
306
|
+
<wd-button v-if="isShowAction !== false && props.item.buttons.includes('copy')" size="small" @click="handleCopy">
|
|
311
307
|
复制
|
|
312
308
|
</wd-button>
|
|
313
309
|
<wd-button
|
|
@@ -102,7 +102,10 @@ function toggleCollapse(contentId: string) {
|
|
|
102
102
|
<!-- 订单卡片容器 -->
|
|
103
103
|
<view class="mx-auto max-w-md space-y-4">
|
|
104
104
|
<!-- 订单卡片2 -->
|
|
105
|
-
<view
|
|
105
|
+
<view
|
|
106
|
+
class="ma-2 overflow-hidden rounded-xl bg-white shadow-sm dark:bg-[var(--wot-dark-background2)]"
|
|
107
|
+
@click="emit('click')"
|
|
108
|
+
>
|
|
106
109
|
<!-- 订单头部 -->
|
|
107
110
|
<view v-if="props.primaryColumn" class="flex items-center justify-between border-b border-gray-100 p-4">
|
|
108
111
|
<view class="flex min-w-0 flex-1 items-center gap-4 text-base text-gray-800 font-medium dark:text-white">
|
|
@@ -134,22 +137,6 @@ function toggleCollapse(contentId: string) {
|
|
|
134
137
|
<!-- <slot name="detailAddress" /> -->
|
|
135
138
|
</view>
|
|
136
139
|
</view>
|
|
137
|
-
<view
|
|
138
|
-
v-if="props.labelColumn"
|
|
139
|
-
class="whitespace-nowrap rounded px-1 py-1 text-sm text-white font-700"
|
|
140
|
-
:style="{
|
|
141
|
-
color: labelColumns?.find(
|
|
142
|
-
item => props.labelColumn && item.value === data.fieldMap[props.labelColumn.sourceId]
|
|
143
|
-
)?.css?.color,
|
|
144
|
-
}"
|
|
145
|
-
>
|
|
146
|
-
{{
|
|
147
|
-
formatItemData(
|
|
148
|
-
data.fieldMap[props.labelColumn.sourceId],
|
|
149
|
-
props.labelColumn.extControlType || props.labelColumn.controlType
|
|
150
|
-
)
|
|
151
|
-
}}
|
|
152
|
-
</view>
|
|
153
140
|
</view>
|
|
154
141
|
|
|
155
142
|
<!-- 订单内容 -->
|
|
@@ -185,7 +172,9 @@ function toggleCollapse(contentId: string) {
|
|
|
185
172
|
display: grid;
|
|
186
173
|
grid-template-rows: 0fr;
|
|
187
174
|
opacity: 0;
|
|
188
|
-
transition:
|
|
175
|
+
transition:
|
|
176
|
+
grid-template-rows 0.3s ease,
|
|
177
|
+
opacity 0.25s ease;
|
|
189
178
|
}
|
|
190
179
|
.fold-collapse > view {
|
|
191
180
|
overflow: hidden;
|
|
@@ -152,6 +152,7 @@ function initFormData() {
|
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
+
console.log('processedModels:', processedModels)
|
|
155
156
|
model.value = {
|
|
156
157
|
...processedModels,
|
|
157
158
|
}
|
|
@@ -415,10 +416,8 @@ watch(
|
|
|
415
416
|
shouldMonitor.value?.forEach((item: any) => {
|
|
416
417
|
const oldSnap = oldVal[item.id] || {}
|
|
417
418
|
const newSnap = newVal[item.id] || {}
|
|
418
|
-
const relChanged =
|
|
419
|
-
|
|
420
|
-
const rel3Changed =
|
|
421
|
-
item.relValueField3 && oldSnap.relValueField3 !== newSnap.relValueField3
|
|
419
|
+
const relChanged = item.relValueField && oldSnap.relValueField !== newSnap.relValueField
|
|
420
|
+
const rel3Changed = item.relValueField3 && oldSnap.relValueField3 !== newSnap.relValueField3
|
|
422
421
|
if (relChanged || rel3Changed) {
|
|
423
422
|
model.value[item.id] = ''
|
|
424
423
|
}
|
|
@@ -552,6 +551,17 @@ function submit() {
|
|
|
552
551
|
if (Object.prototype.hasOwnProperty.call(model.value, key)) {
|
|
553
552
|
fields.value?.forEach((item: Fields) => {
|
|
554
553
|
if (item.sourceId === key) {
|
|
554
|
+
// 表单不显示的字段(hidden 或由 title 含 'y' 隐藏)一律传空,
|
|
555
|
+
// 避免把隐藏字段里残留的旧值一并提交
|
|
556
|
+
const visible = !item.title?.includes('y') && !item.hidden
|
|
557
|
+
if (!visible) {
|
|
558
|
+
const ct = ControlTypeSupportor.getControlType(item)
|
|
559
|
+
const isArrayType = ['multiselect', 'tree-entity-select', 'relselect', 'file', 'relfile'].includes(
|
|
560
|
+
ct
|
|
561
|
+
)
|
|
562
|
+
data[key] = isArrayType ? [] : ''
|
|
563
|
+
return
|
|
564
|
+
}
|
|
555
565
|
if (ControlTypeSupportor.getControlType(item) === 'file') {
|
|
556
566
|
data[key] = toRaw(model.value[key][0])
|
|
557
567
|
} else if (
|
|
@@ -570,8 +580,8 @@ function submit() {
|
|
|
570
580
|
})
|
|
571
581
|
}
|
|
572
582
|
}
|
|
573
|
-
console.log('data',
|
|
574
|
-
resolve(
|
|
583
|
+
console.log('data', clearValueMap, data)
|
|
584
|
+
resolve(data)
|
|
575
585
|
} else {
|
|
576
586
|
reject(valid)
|
|
577
587
|
}
|
|
@@ -854,6 +864,7 @@ console.log('clearValueMap', clearValueMap)
|
|
|
854
864
|
:readonly="item.disabled || item.rowEditType === 'readonly'"
|
|
855
865
|
:clearable="!item.disabled"
|
|
856
866
|
:default-select-first="!!item.defaultSelectFirst"
|
|
867
|
+
:default-value="item.transDefaultValue || item.defaultValue"
|
|
857
868
|
/>
|
|
858
869
|
</wd-form-item>
|
|
859
870
|
<wd-form-item
|
|
@@ -873,6 +884,7 @@ console.log('clearValueMap', clearValueMap)
|
|
|
873
884
|
:readonly="item.disabled || item.rowEditType === 'readonly'"
|
|
874
885
|
:clearable="!item.disabled"
|
|
875
886
|
:default-select-first="!!item.defaultSelectFirst"
|
|
887
|
+
:default-value="item.transDefaultValue || item.defaultValue"
|
|
876
888
|
/>
|
|
877
889
|
</wd-form-item>
|
|
878
890
|
<wd-form-item
|
|
@@ -894,6 +906,7 @@ console.log('clearValueMap', clearValueMap)
|
|
|
894
906
|
:readonly="item.disabled || item.rowEditType === 'readonly'"
|
|
895
907
|
:clearable="!item.disabled"
|
|
896
908
|
:default-select-first="!!item.defaultSelectFirst"
|
|
909
|
+
:default-value="item.transDefaultValue || item.defaultValue"
|
|
897
910
|
fold-card-model="complex"
|
|
898
911
|
/>
|
|
899
912
|
</wd-form-item>
|
|
@@ -23,6 +23,7 @@ const props = withDefaults(
|
|
|
23
23
|
readonly?: boolean // 只读模式,禁止打开弹窗
|
|
24
24
|
clearable?: boolean // 是否显示清空按钮
|
|
25
25
|
defaultSelectFirst?: boolean // 是否默认选择第一项
|
|
26
|
+
defaultValue?: string | string[] // 字段配置的默认值(格式同 modelValue,可单值或数组)
|
|
26
27
|
}>(),
|
|
27
28
|
{
|
|
28
29
|
title: '',
|
|
@@ -33,6 +34,7 @@ const props = withDefaults(
|
|
|
33
34
|
readonly: false,
|
|
34
35
|
clearable: true,
|
|
35
36
|
defaultSelectFirst: false,
|
|
37
|
+
defaultValue: '',
|
|
36
38
|
}
|
|
37
39
|
)
|
|
38
40
|
console.log(props, '3333333333333333333')
|
|
@@ -167,18 +169,61 @@ const hasInitialized = ref(false)
|
|
|
167
169
|
// ★ 是否已完成默认首项选中
|
|
168
170
|
const hasDefaultSelected = ref(false)
|
|
169
171
|
|
|
170
|
-
//
|
|
172
|
+
// 解析 $$user. 占位符:取 `$$user.` 之后的字段名,从本地 userInfo.extInfo.fieldMap 取对应值
|
|
173
|
+
const resolveUserValue = (raw: string): string => {
|
|
174
|
+
if (typeof raw !== 'string' || !raw.includes('$$user.')) return raw
|
|
175
|
+
const key = raw.split('$$user.')[1]
|
|
176
|
+
const { extInfo = {} } = uni.getStorageSync('userInfo') || {}
|
|
177
|
+
const fieldMap = extInfo.fieldMap || {}
|
|
178
|
+
const val = fieldMap[key]
|
|
179
|
+
return val !== undefined && val !== null ? String(val) : ''
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// ★ 预选默认值来源:props.defaultValue(父组件传入) > 后端配置 primaryCriterion.transDefaultValue/defaultValue
|
|
183
|
+
const getDefaultValue = (): string | string[] => {
|
|
184
|
+
if (props.defaultValue) return props.defaultValue
|
|
185
|
+
const criterion = config.value.primaryCriterion
|
|
186
|
+
if (criterion?.transDefaultValue) return criterion.transDefaultValue
|
|
187
|
+
if (criterion?.defaultValue) return criterion.defaultValue
|
|
188
|
+
return ''
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// ★ 默认选择:数据加载完成后按「默认值」或「第一项」预选并回显
|
|
171
192
|
watch(datas, val => {
|
|
172
|
-
if (!
|
|
173
|
-
|
|
174
|
-
const
|
|
175
|
-
selectData.value[first.code] = `${first.code}@R@${first.fieldMap[config.value.primaryColumn.sourceId]}`
|
|
176
|
-
const result =
|
|
193
|
+
if (!val?.length || hasDefaultSelected.value || Object.keys(selectData.value).length > 0) return
|
|
194
|
+
|
|
195
|
+
const buildResult = () =>
|
|
177
196
|
props.extControlType === 'relselect' || props.extControlType === 'relselect-extdis'
|
|
178
|
-
? selectData.value[
|
|
197
|
+
? Object.values(selectData.value)[0]
|
|
179
198
|
: Object.values(selectData.value)
|
|
180
|
-
|
|
181
|
-
|
|
199
|
+
|
|
200
|
+
// 1) 字段/后端配置的默认值:按 code 在已加载数据中匹配预选
|
|
201
|
+
const def = getDefaultValue()
|
|
202
|
+
if (def) {
|
|
203
|
+
const codes = (Array.isArray(def) ? def : [def]).map(c => resolveUserValue(String(c)))
|
|
204
|
+
const matched = codes
|
|
205
|
+
.map(c => {
|
|
206
|
+
const code = typeof c === 'string' ? c.split('@R@')[0] : ''
|
|
207
|
+
return val.find(item => item.code === code)
|
|
208
|
+
})
|
|
209
|
+
.filter(Boolean) as Entities[]
|
|
210
|
+
if (matched.length) {
|
|
211
|
+
matched.forEach(item => {
|
|
212
|
+
selectData.value[item.code] = `${item.code}@R@${item.fieldMap[config.value.primaryColumn.sourceId]}`
|
|
213
|
+
})
|
|
214
|
+
emit('update:modelValue', buildResult())
|
|
215
|
+
hasDefaultSelected.value = true
|
|
216
|
+
return
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// 2) 兜底:自动选第一项
|
|
221
|
+
if (props.defaultSelectFirst) {
|
|
222
|
+
const first = val[0]
|
|
223
|
+
selectData.value[first.code] = `${first.code}@R@${first.fieldMap[config.value.primaryColumn.sourceId]}`
|
|
224
|
+
emit('update:modelValue', buildResult())
|
|
225
|
+
hasDefaultSelected.value = true
|
|
226
|
+
}
|
|
182
227
|
})
|
|
183
228
|
|
|
184
229
|
// 获取页面配置
|