fix order/fulfillment unit
This commit is contained in:
@@ -310,13 +310,31 @@ function getRemainingAmountClass(amount?: number | null): "green" | "red" | "gra
|
||||
return amount === 0 ? "green" : "red";
|
||||
}
|
||||
|
||||
function getItemUnitName(item: GaoSalesOrderItem): string {
|
||||
return item.unitSnapshot || "单位";
|
||||
}
|
||||
|
||||
function getBaseUnitName(item: GaoSalesOrderItem): string {
|
||||
return item.baseUnitName || "基础单位";
|
||||
}
|
||||
|
||||
function shouldDisplayBaseQuantity(item: GaoSalesOrderItem, baseQuantity?: number | string): boolean {
|
||||
const isBaseUnit = Number(item.baseQuantityPerUnitSnapshot ?? 1) === 1;
|
||||
return item.allowDecimalQuantity === false
|
||||
&& !isBaseUnit
|
||||
&& baseQuantity !== undefined
|
||||
&& Number(baseQuantity) < Number(item.baseQuantityPerUnitSnapshot ?? 1);
|
||||
}
|
||||
|
||||
function getItemQuantityText(item: GaoSalesOrderItem, baseQuantity?: number | string): string {
|
||||
const quantity = convertPackageQuantity(
|
||||
String(baseQuantity ?? "0"),
|
||||
"1",
|
||||
item.baseQuantityPerUnitSnapshot ?? "1"
|
||||
);
|
||||
return getPackageQuantityText(quantity ?? baseQuantity);
|
||||
const useBaseUnit = shouldDisplayBaseQuantity(item, baseQuantity);
|
||||
const displayQuantity = useBaseUnit ? getPackageQuantityText(baseQuantity) : getPackageQuantityText(quantity ?? baseQuantity);
|
||||
return `${displayQuantity} ${useBaseUnit ? getBaseUnitName(item) : getItemUnitName(item)}`;
|
||||
}
|
||||
|
||||
function getAvailableQuantityClass(item: GaoSalesOrderItem): "green" | "orange" {
|
||||
|
||||
@@ -144,8 +144,9 @@ function sumProductQuantity(field: "quantity" | "fulfilledBaseQuantity"): string
|
||||
}
|
||||
|
||||
function getProductText(item: NonNullable<SalesOrder["itemList"]>[number]): string {
|
||||
const quantity = getPackageQuantityText(item.quantity);
|
||||
const skuText = getProductSkuSnapshotText(item.productNameSnapshot, item.skuNameSnapshot, item.specSummarySnapshot);
|
||||
return `${item.productNameSnapshot || "未命名产品"}${skuText ? ` · ${skuText}` : ""}${item.unitSnapshot ? ` / ${item.unitSnapshot}` : ""}`;
|
||||
return `${item.productNameSnapshot || "未命名产品"}${skuText ? ` · ${skuText}` : ""} × ${quantity}${item.unitSnapshot ? ` ${item.unitSnapshot}` : ""}`;
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user