31 lines
850 B
TypeScript
31 lines
850 B
TypeScript
export type ProductionTaskSetItemPreview = {
|
|
taskName: string
|
|
routeId: string
|
|
routeName: string
|
|
description: string
|
|
remark: string
|
|
}
|
|
|
|
export function mapWorkOrderTasksToSetItems(tasks: Record<string, any>[] | undefined): {
|
|
items: ProductionTaskSetItemPreview[]
|
|
skippedEmptyNameCount: number
|
|
} {
|
|
const items: ProductionTaskSetItemPreview[] = []
|
|
let skippedEmptyNameCount = 0
|
|
for (const row of tasks || []) {
|
|
const taskName = String(row.taskName || '').trim()
|
|
if (!taskName) {
|
|
skippedEmptyNameCount += 1
|
|
continue
|
|
}
|
|
items.push({
|
|
taskName,
|
|
routeId: String(row.routeId || '').trim(),
|
|
routeName: String(row.routeName || '').trim(),
|
|
description: String(row.description || '').trim(),
|
|
remark: String(row.remark || '').trim()
|
|
})
|
|
}
|
|
return { items, skippedEmptyNameCount }
|
|
}
|