/** 主体危化品能力:产品是否允许选择 */ export function productAllowedByHazard( isToxic: number | undefined, isExplosive: number | undefined, allowToxic: number, allowExplosive: number ): boolean { const toxic = Number(isToxic || 0) === 1 const explosive = Number(isExplosive || 0) === 1 if (!toxic && !explosive) return true if (toxic && explosive) return allowToxic === 1 && allowExplosive === 1 if (toxic) return allowToxic === 1 return allowExplosive === 1 } export function removeProductsNotAllowedByHazard< T extends { productId?: string | number productName?: string isToxic?: number isExplosive?: number } >( products: T[], allowToxic: number, allowExplosive: number ): { kept: T[]; removedNames: string[] } { const kept: T[] = [] const removedNames: string[] = [] for (const p of products) { if (productAllowedByHazard(p.isToxic, p.isExplosive, allowToxic, allowExplosive)) { kept.push(p) } else { removedNames.push(p.productName || String(p.productId || '')) } } return { kept, removedNames } }