Skip to content

Commit 6baeea5

Browse files
committed
fix:字段组合模板因用模型的内置字段(bk_)提交报错 --bug=159428564
1 parent 112f64d commit 6baeea5

7 files changed

Lines changed: 12 additions & 2 deletions

File tree

resources/errors/common/default/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
"1199090": "非法的正则表达式",
9191
"1199091": "至少设置[%s]和[%s]中的一个值",
9292
"1199092": "当前字段类型状态为单选,请设置合理数据",
93+
"1199093": "'%s' 不能以bk_开头,该前缀为系统字段保留",
9394

9495
"1109001": "保存操作审计日志失败",
9596
"1109002": "创建操作审计快照失败",

resources/errors/english/en/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
"1199090": "Regular expression's type assertion failed",
9090
"1199091": "at least one of %s and %s must be set",
9191
"1199092": "current field type status is single choice, please set reasonable data",
92+
"1199093": "'%s' cannot start with bk_, this prefix is reserved for system fields",
9293

9394
"1109001": "save audit log failed",
9495
"1109002": "take audit log snapshot failed",

src/common/errInfo.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ const (
243243
// 该状态码只提供给支持可多选字段校验报错时使用,目前用户类型,枚举多选,枚举引用,组织类型校验可多选报错时可以使用
244244
CCErrCommParamsNeedSingleChoice = 1199092
245245

246+
// CCErrCommParamsReservedFieldPrefix the field id starts with reserved prefix bk_ or _bk
247+
CCErrCommParamsReservedFieldPrefix = 1199093
248+
246249
// too many requests
247250
CCErrTooManyRequestErr = 1199997
248251

src/common/metadata/field_template.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func (f *FieldTemplateAttr) validatePropertyID() ccErr.RawErrorInfo {
163163
}
164164

165165
if strings.HasPrefix(f.PropertyID, "bk_") || strings.HasPrefix(f.PropertyID, "_bk") {
166-
return ccErr.RawErrorInfo{ErrCode: common.CCErrCommParamsIsInvalid,
166+
return ccErr.RawErrorInfo{ErrCode: common.CCErrCommParamsReservedFieldPrefix,
167167
Args: []interface{}{common.BKPropertyIDField}}
168168
}
169169

src/ui/src/i18n/lang/cn.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,6 +1800,7 @@
18001800
"在实例中可编辑": "在实例中可编辑",
18011801
"设置为必填项": "设置为必填项",
18021802
"字段已在模板中存在,无法添加": "字段已在模板中存在,无法添加",
1803+
"内置字段,无法添加": "前缀bk_为内置字段,无法添加",
18031804
"与已有字段的唯一标识或名称重复,请修改": "与已有字段的唯一标识或名称重复,请修改",
18041805
"立即绑定": "立即绑定",
18051806
"模型信息确认": "模型信息确认",

src/ui/src/i18n/lang/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,6 +1793,7 @@
17931793
"在实例中可编辑": "Editable in instance",
17941794
"设置为必填项": "Required",
17951795
"字段已在模板中存在,无法添加": "Field already exists in the template and cannot be added",
1796+
"内置字段,无法添加": "The bk_ prefix indicates a built-in field and cannot be added",
17961797
"与已有字段的唯一标识或名称重复,请修改": "Duplicate with ID or Name of the existing field, please modify",
17971798
"立即绑定": "Bind now",
17981799
"模型信息确认": "Model information confirmation",

src/ui/src/views/field-template/children/model-field-selector.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
status.selected[prop.id] = selected.value.some(item => item.id === prop.id)
6060
status.disabled[prop.id] = props.templateFieldList.some(item => item.bk_property_id === prop.bk_property_id
6161
|| item.bk_property_name === prop.bk_property_name)
62+
|| prop.bk_property_id.startsWith('bk_') || prop.bk_property_id.startsWith('_bk')
6263
})
6364
return status
6465
})
@@ -132,7 +133,9 @@
132133
:deletable="false"
133134
v-bk-tooltips="{
134135
disabled: !selectedStatus.disabled[field.id],
135-
content: $t('字段已在模板中存在,无法添加')
136+
content: field.bk_property_id.startsWith('bk_') || field.bk_property_id.startsWith('_bk')
137+
? $t('内置字段,无法添加')
138+
: $t('字段已在模板中存在,无法添加')
136139
}"
137140
@click-field="handleSelect">
138141
<template #action-append>

0 commit comments

Comments
 (0)