fix(label): contextMenu
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user