Skip to content

Commit a77dca8

Browse files
authored
fix: 修复枚举类型字段默认值选择异常的问题 (#8500)
--bug=146937624 # Reviewed, transaction id: 54755
1 parent 39f54c8 commit a77dca8

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/ui/src/components/model-manage/field-group/field-detail/enum.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,14 @@
201201
}
202202
},
203203
defaultValue(val, old) {
204-
// 检测选中值变化,需要修正is_default
204+
// 检测选中值变化,需要修正is_default,这里值的类型都是string
205205
if (val && !isEqual(val, old)) {
206206
this.enumList.forEach((item) => {
207-
item.is_default = val.includes(item.id)
207+
if (this.isDefaultCompMultiple && Array.isArray(val)) {
208+
item.is_default = val.includes(item.id)
209+
} else {
210+
item.is_default = val === item.id
211+
}
208212
})
209213
this.$emit('input', this.enumList)
210214
}

src/ui/src/components/model-manage/field-group/field-view.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,9 @@
151151
:value="defaultValue"
152152
:property="field">
153153
</cmdb-property-value>
154+
<!-- bool类型字段未设置与默认值false都将显示为false -->
154155
<span v-else
155-
class="property-value">{{defaultValue || '--'}}</span>
156+
class="property-value">{{defaultValue ?? '--'}}</span>
156157
</div>
157158
</div>
158159
<template slot="footer" slot-scope="{ sticky }" v-if="canEdit">

0 commit comments

Comments
 (0)