fix(label): contextMenu

This commit is contained in:
zhangheng
2026-04-15 19:03:27 +08:00
parent 915c9ddd86
commit 1e62e96953
3 changed files with 76 additions and 79 deletions

View File

@@ -86,6 +86,45 @@ export const getSubAttrStatus = (
return bool
}
export const buildSubAttributeFormValues = (
operationSchema: Project.LabelSchemaList | null,
detail: Record<string, any> = {}
) => {
const nextValues: Record<string, string | string[]> = {}
if (!operationSchema?.sub_attributes_describe?.length) return nextValues
operationSchema.sub_attributes_describe.forEach((item) => {
nextValues[item.chinese_name] = item.select_mode === 2 ? [] : ""
const currentValue = detail?.[item.chinese_name]
if (
currentValue === undefined ||
currentValue === null ||
currentValue === "" ||
(Array.isArray(currentValue) && currentValue.length === 0)
) {
return
}
if (item.select_mode === 2) {
nextValues[item.chinese_name] = Array.isArray(currentValue)
? currentValue
: currentValue
.toString()
.split(",")
.map((value: string) => value.trim())
.filter(Boolean)
return
}
nextValues[item.chinese_name] = Array.isArray(currentValue)
? currentValue[0] || ""
: currentValue.toString()
})
return nextValues
}
//
export const checkCommentsIsSame: (
a: any[] | null,