64 lines
1.5 KiB
TypeScript
64 lines
1.5 KiB
TypeScript
import { Project } from "./api/project/typing"
|
|
|
|
// 是否存在不符合要求的子属性
|
|
export const getSubAttrStatus = (
|
|
operationSchema: Project.LabelSchemaList | null,
|
|
detail: {
|
|
[key: string]: string
|
|
}
|
|
) => {
|
|
if (!operationSchema?.sub_attributes_describe?.length) return false
|
|
let bool = operationSchema?.sub_attributes_describe?.some((item) => {
|
|
if (item.isrequired === 1) {
|
|
if (!detail || !detail?.[item.chinese_name]) {
|
|
return true
|
|
} else {
|
|
return false
|
|
}
|
|
}
|
|
})
|
|
return bool
|
|
}
|
|
|
|
//
|
|
export const checkCommentsIsSame: (
|
|
a: any[] | null,
|
|
b: any[] | null,
|
|
c: any[] | null,
|
|
d: any[] | null
|
|
) => boolean = (
|
|
detailCheckboxComments,
|
|
detailTextComments,
|
|
checkboxComments,
|
|
textComments
|
|
) => {
|
|
if (detailCheckboxComments?.length !== checkboxComments?.length) {
|
|
return false
|
|
}
|
|
if (detailTextComments?.length !== textComments?.length) {
|
|
return false
|
|
}
|
|
const areCheckboxCommentsSame =
|
|
detailCheckboxComments?.every((comment, index) => {
|
|
return comment === checkboxComments?.[index]
|
|
}) ?? true
|
|
const areTextCommentsSame =
|
|
detailTextComments?.every((comment, index) => {
|
|
return comment === textComments?.[index]
|
|
}) ?? true
|
|
return areCheckboxCommentsSame && areTextCommentsSame
|
|
}
|
|
|
|
// find group key
|
|
export const findGroupKey: (
|
|
group: { [x: number]: number[] },
|
|
id: number
|
|
) => number = (group, id) => {
|
|
for (const key in group) {
|
|
if (group[key].includes(id)) {
|
|
return Number(key)
|
|
}
|
|
}
|
|
return -1
|
|
}
|