Skip to content

Commit 4d776e1

Browse files
committed
fix: 动态type属性错误 & 增加是否需要重载值
1 parent faa8ea9 commit 4d776e1

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

lib/EleForm.vue

+16-14
Original file line numberDiff line numberDiff line change
@@ -417,16 +417,16 @@ export default {
417417
}
418418
419419
// 隐藏属性
420-
Object.keys(desc[field]).forEach(key => {
421-
if (key.startsWith('_')) {
422-
Object.defineProperty(desc[field], key, {
423-
enumerable: false,
424-
writable: true,
425-
configurable: true,
426-
value: desc[field][key]
427-
})
428-
}
429-
})
420+
// Object.keys(desc[field]).forEach(key => {
421+
// if (key.startsWith('_')) {
422+
// Object.defineProperty(desc[field], key, {
423+
// enumerable: false,
424+
// writable: true,
425+
// configurable: true,
426+
// value: desc[field][key]
427+
// })
428+
// }
429+
// })
430430
})
431431
return desc
432432
}
@@ -553,13 +553,15 @@ export default {
553553
let type = formItem.type
554554
if (typeof formItem.type === 'function') {
555555
type = this.getComponentName(formItem.type(formData))
556-
if (formItem._type && formItem._type !== type) {
556+
557+
// 是否需要载入旧数据
558+
if (formItem.isTypeChangeReloadValue !== false && formItem._type && formItem._type !== type) {
557559
// 保存老数据
558-
this.computedFormDesc[field]['_oldValue']['type-' + type] =
560+
this.computedFormDesc[field]['_oldValue']['type-' + formItem._type] =
559561
formData[field]
560562
// 并获取新类型的数据
561563
const newVal =
562-
formItem['_oldValue']['type-' + formItem._type] || null
564+
formItem['_oldValue']['type-' + type] || null
563565
this.setValue(field, newVal)
564566
}
565567
} else {
@@ -698,7 +700,7 @@ export default {
698700
this.$set(this.computedFormDesc[field], '_options', newOptions)
699701
700702
// 判断是否需要重置值
701-
if (reloadOptions && oldOptions !== undefined) {
703+
if (this.computedFormDesc[field].isOptionsChangeReloadValue !== false && reloadOptions && oldOptions !== undefined) {
702704
const newOptionValues = new Set(
703705
Array.isArray(newOptions) ? newOptions.map(item => item.value) : []
704706
)

0 commit comments

Comments
 (0)