feat(web-admin): add freight config sample partition helper

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
zlwuandCursor committed 2026-10-12 13:46:54 +08:00
1 parent 55e321f266
commit ce9d836194
2 files changed
+81

No files matched your search

@@ -0,0 +1,30 @@
/** 协议单/运费配置:区分可配置与已配样本 */
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 '所选样本均已配置运费,请先取消运费后再配置'
}