31 lines
1.0 KiB
TypeScript
31 lines
1.0 KiB
TypeScript
/** 协议单/运费配置:区分可配置与已配样本 */
|
|
|
|
export function sampleHasFreight(row: Record<string, any> | null | undefined): boolean {
|
|
if (!row) return false
|
|
if (row.freight && typeof row.freight === 'object' && row.freight.id) return true
|
|
if (row.freightDraft && typeof row.freightDraft === 'object') return true
|
|
const fid = String(row.freightId || '').trim()
|
|
return !!fid
|
|
}
|
|
|
|
export function partitionFreightConfigSamples<T extends Record<string, any>>(selected: T[]): {
|
|
configurable: T[]
|
|
skipped: T[]
|
|
} {
|
|
const configurable: T[] = []
|
|
const skipped: T[] = []
|
|
for (const row of selected || []) {
|
|
if (sampleHasFreight(row)) skipped.push(row)
|
|
else configurable.push(row)
|
|
}
|
|
return { configurable, skipped }
|
|
}
|
|
|
|
export function freightConfigSkipMessage(skippedCount: number): string {
|
|
return `已跳过 ${skippedCount} 个已配置运费的样本,将仅为其余样本配置运费`
|
|
}
|
|
|
|
export function freightConfigAllConfiguredMessage(): string {
|
|
return '所选样本均已配置运费,请先取消运费后再配置'
|
|
}
|