Files
zkxw/web-admin/src/utils/qc-inbound-lab-storage-sort.ts
T
2026-08-18 14:40:15 +08:00

41 lines
1.0 KiB
TypeScript

/** 编码 DESC → 时间 DESC;负值表示 a 排在 b 前(与后端一致) */
export function compareLabStorageThenCreateTimeDesc(
codeA: string | null | undefined,
timeA: string | null | undefined,
codeB: string | null | undefined,
timeB: string | null | undefined
): number {
const ca = String(codeA || '').trim()
const cb = String(codeB || '').trim()
if (ca !== cb) {
return ca > cb ? -1 : 1
}
const ta = String(timeA || '').trim()
const tb = String(timeB || '').trim()
if (ta !== tb) {
return ta > tb ? -1 : 1
}
return 0
}
export function resolveGroupLabStorageCode(
rows: { labStorageCode?: string | null }[]
): string {
for (const row of rows) {
const code = String(row.labStorageCode || '').trim()
if (code) return code
}
return ''
}
export function resolveGroupMaxCreateTime(
rows: { createTime?: string | null }[]
): string {
let max = ''
for (const row of rows) {
const t = String(row.createTime || '')
if (t > max) max = t
}
return max
}