fix(purchase): 修复订单步骤保存和界面显示问题

- 移除了 OrderCost 和 TicketUpload 组件中不必要的底部内边距
- 修复了 approved 页面中 setLoading 状态未正确结束的问题
- 优化了 approved 页面中单据生成区域的条件渲染逻辑
- 在 create 页面中增加了对订单步骤索引的有效性校验
- 调整了保存订单步骤时的 active 索引递增逻辑
- 限制了暂存按钮仅在有效步骤范围内显示
- 更新了供应商权重计算方法,加入自有纸箱重量统计
- 添加了调试日志用于追踪供应商重量计算过程
This commit is contained in:
shenyifei 2025-11-11 19:15:29 +08:00
parent 32017a6ce0
commit 99bec0cbac
5 changed files with 44 additions and 25 deletions

View File

@ -384,7 +384,7 @@ export default forwardRef<OrderCostRef, IOrderCostProps>(
};
return (
<View className="flex flex-1 flex-col bg-[#D1D5DB] px-2.5 pt-2.5 pb-16">
<View className="flex flex-1 flex-col bg-[#D1D5DB] px-2.5 pt-2.5">
<View className={"mb-2.5"}>
<View className="mb-2.5 text-sm font-bold"></View>
<View className="mb-2.5 flex items-center rounded-lg border border-blue-200 bg-blue-50 p-2.5">

View File

@ -89,7 +89,7 @@ export default function TicketUpload(props: ITicketUploadProps) {
}
return (
<View className="flex flex-1 flex-col bg-[#D1D5DB] px-2.5 pt-2.5 pb-16">
<View className="flex flex-1 flex-col bg-[#D1D5DB] px-2.5 pt-2.5">
<View className="border-primary mb-2.5 rounded-lg border-4 bg-white p-2.5 shadow-sm">
<View className="text-primary mb-2.5 text-sm font-bold">
{supplierVO.name}

View File

@ -21,7 +21,7 @@ export default hocAuth(function Page(props: CommonComponent) {
const [shipOrder, setShipOrder] = useState<BusinessAPI.ShipOrderVO>();
const init = async (orderId: string) => {
setLoading(true)
setLoading(true);
try {
// 获取采购单信息
const { data: purchaseData } =
@ -71,7 +71,7 @@ export default hocAuth(function Page(props: CommonComponent) {
content: "获取采购单信息失败",
});
} finally {
setLoading(false)
setLoading(false);
}
};
@ -205,9 +205,9 @@ export default hocAuth(function Page(props: CommonComponent) {
</View>
</View>
{(canGenerateDocuments.shipDocument ||
canGenerateDocuments.purchaseDocument ||
canGenerateDocuments.costDocument) && (
{canGenerateDocuments.shipDocument ||
canGenerateDocuments.purchaseDocument ||
canGenerateDocuments.costDocument ? (
<View className="border-t border-gray-200 pt-2.5">
<View className="mb-2">
<Text className="text-lg font-semibold"></Text>
@ -254,6 +254,18 @@ export default hocAuth(function Page(props: CommonComponent) {
</View>
)}
</View>
) : (
<View className="border-t border-gray-200 pt-2.5">
<View className="mb-2">
<Text className="text-lg font-semibold"></Text>
</View>
<View className="flex flex-col gap-3">
<View className="mt-2.5 text-center text-sm text-red-500">
</View>
</View>
</View>
)}
</View>
</View>

View File

@ -129,7 +129,12 @@ export default hocAuth(function Page(props: CommonComponent) {
if (defaultStep) {
setActive(Number(defaultStep));
} else {
setActive(purchaseOrder.active || 1);
const active = purchaseOrder.active || 1;
if (active < 1 || active > 6) {
setActive(1);
} else {
setActive(active);
}
}
const orderCostList1 = purchaseOrder.orderCostList.map(
(item: CostItem) => ({
@ -340,7 +345,7 @@ export default hocAuth(function Page(props: CommonComponent) {
try {
const { data } = await business.purchaseOrder.savePurchaseOrderStep3({
orderId: orderId,
active: active,
active: active + 1,
orderCostList: purchaseOrder.orderCostList.filter(
(item: CostItem) => item.selected,
),
@ -412,7 +417,7 @@ export default hocAuth(function Page(props: CommonComponent) {
let success = true;
// 保存第一步车辆和经销商信息
if (active >= 1) {
if (active == 1) {
success = await saveVehicleAndDealerInfo();
}
@ -702,19 +707,21 @@ export default hocAuth(function Page(props: CommonComponent) {
</View>
)}
<View className={"flex-1"}>
<Button
block
type={"default"}
size={"xlarge"}
className="flex-1 bg-gray-200 text-gray-700"
onClick={async () => {
await saveDraft();
}}
>
</Button>
</View>
{active >= 1 && active <= 6 && (
<View className={"flex-1"}>
<Button
block
type={"default"}
size={"xlarge"}
className="flex-1 bg-gray-200 text-gray-700"
onClick={async () => {
await saveDraft();
}}
>
</Button>
</View>
)}
{active < 6 && (
<View className={"flex-1"}>

View File

@ -25,8 +25,8 @@ export function calculateSupplierWeights(suppliers) {
}
// 计算本次使用纸箱的总重量(斤)
const usedBoxesWeight = calculateBoxesTotalWeight(supplier.orderPackageList, 'USED');
const usedBoxesWeight = calculateBoxesTotalWeight(supplier.orderPackageList, 'USED') + calculateBoxesTotalWeight(supplier.orderPackageList, 'OWN');
console.log("usedBoxesWeight", usedBoxesWeight, supplier)
if (!supplier.isPaper) {
// 如果不是纸箱包装直接使用原始重量kg转斤
supplier.grossWeight = (supplier.totalWeight - supplier.emptyWeight) * 2;