- 删除 TransferOrderSubmitReview 组件,整合到 PurchaseOrderSubmitReview - 重命名 PurchaseOption 为 MadeOption,TransferOption 为 MarketOption - 重命名 PurchasePreview 为 MadePreview,TransferPreview 为 MarketPreview - 更新档口信息组件 StallInfo 和 StallWeigh 的逻辑和字段 - 修改采购单类型判断逻辑,使用 purchase 常量配置替代硬编码 - 调整采购单创建和预览页面路径,支持不同类型采购单跳转 - 移除重复的 TransferOrderItem 组件,统一使用 PurchaseOrderItem - 优化档口类型切换逻辑,清空相关供应商信息字段 - 调整称重信息校验规则,确保所有字段均通过验证 - 更新采购单列表页面,支持不同类型采购单统一展示和创建
168 lines
5.2 KiB
TypeScript
168 lines
5.2 KiB
TypeScript
import { Button, ButtonSize, Dialog, Toast } from "@nutui/nutui-react-taro";
|
|
import { business } from "@/services";
|
|
import Taro from "@tarojs/taro";
|
|
import { buildUrl } from "@/utils";
|
|
import { purchase } from "@/constant";
|
|
|
|
interface IPurchaseOrderSubmitReviewProps {
|
|
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
|
size?: ButtonSize;
|
|
onFinish?: () => void;
|
|
}
|
|
|
|
export default function PurchaseOrderSubmitReview(
|
|
props: IPurchaseOrderSubmitReviewProps,
|
|
) {
|
|
const { purchaseOrderVO, size = "normal", onFinish } = props;
|
|
|
|
const onSubmit = async () => {
|
|
if (!purchaseOrderVO || !purchaseOrderVO.orderId) {
|
|
Toast.show("toast", {
|
|
icon: "warn",
|
|
title: "提示",
|
|
content: "提交失败",
|
|
});
|
|
return;
|
|
}
|
|
|
|
let success = false;
|
|
let errMessage = "";
|
|
try {
|
|
// 更新成功后再提交审核
|
|
const { data } = await business.purchaseOrder.submitReviewPurchaseOrder({
|
|
orderId: purchaseOrderVO.orderId,
|
|
});
|
|
|
|
if (data.success) {
|
|
success = data.success;
|
|
} else {
|
|
errMessage = data?.errMessage || "";
|
|
}
|
|
|
|
if (success) {
|
|
Toast.show("toast", {
|
|
icon: "success",
|
|
title: "提示",
|
|
content: "提交成功",
|
|
});
|
|
// 可以在这里添加跳转逻辑,例如返回列表页
|
|
onFinish?.();
|
|
} else {
|
|
Toast.show("toast", {
|
|
icon: "warn",
|
|
title: "提示",
|
|
content: "提交失败",
|
|
});
|
|
console.error("提交采购订单失败:", errMessage);
|
|
}
|
|
} catch (error) {
|
|
Toast.show("toast", {
|
|
icon: "fail",
|
|
title: "提示",
|
|
content: "提交失败",
|
|
});
|
|
console.error("提交采购订单失败:", error);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<Button
|
|
block
|
|
type={"primary"}
|
|
size={size}
|
|
className="btn-large bg-primary ml-2 flex-1 text-white"
|
|
onClick={async (e) => {
|
|
// 检查是否已标记最后一个供应商
|
|
const hasLastSupplier = purchaseOrderVO.orderSupplierList?.some(
|
|
(supplier) => supplier.isLast,
|
|
);
|
|
|
|
if (!hasLastSupplier) {
|
|
const lastSupplier =
|
|
purchaseOrderVO.orderSupplierList[
|
|
purchaseOrderVO.orderSupplierList.length - 1
|
|
];
|
|
Dialog.open("dialog", {
|
|
title: "提交审核提醒",
|
|
content: `这车货目前还在拼车状态。一旦确认车辆已满载,就需要在${purchase.supplierSlug[purchaseOrderVO.type]}信息那里,把“${lastSupplier.name}”的这车货标记为“不需要拼车”。`,
|
|
confirmText: "不需要拼车",
|
|
cancelText: "去继续拼车",
|
|
onConfirm: async () => {
|
|
Taro.redirectTo({
|
|
url: buildUrl(purchase.path[purchaseOrderVO.type].create, {
|
|
orderId: purchaseOrderVO.orderId,
|
|
orderSupplierId: lastSupplier.orderSupplierId,
|
|
step: "2",
|
|
}),
|
|
});
|
|
Dialog.close("dialog");
|
|
},
|
|
onCancel: () => {
|
|
Taro.redirectTo({
|
|
url: buildUrl(purchase.path[purchaseOrderVO.type].create, {
|
|
orderId: purchaseOrderVO.orderId,
|
|
step: "6",
|
|
}),
|
|
});
|
|
Dialog.close("dialog");
|
|
},
|
|
});
|
|
e.stopPropagation();
|
|
return;
|
|
}
|
|
|
|
// 产地采购单需要判断瓜农是否上传合同
|
|
if (purchaseOrderVO.type === "PRODUCTION_PURCHASE") {
|
|
// 检查是否存在合同未上传的瓜农
|
|
const hasNoUpdateContractSupplier =
|
|
purchaseOrderVO.orderSupplierList?.find(
|
|
(supplier) => !supplier.contractUpload,
|
|
);
|
|
|
|
if (hasNoUpdateContractSupplier) {
|
|
Dialog.open("dialog", {
|
|
title: "提交审核提醒",
|
|
content: `检测到瓜农“${hasNoUpdateContractSupplier.name}”未上传合同。请返回票证上传步骤上传合同?`,
|
|
confirmText: "去票证上传",
|
|
cancelText: "取消",
|
|
onConfirm: async () => {
|
|
Taro.redirectTo({
|
|
url: buildUrl(purchase.path[purchaseOrderVO.type].create, {
|
|
orderId: purchaseOrderVO.orderId,
|
|
supplierId: hasNoUpdateContractSupplier.supplierId,
|
|
step: "5",
|
|
}),
|
|
});
|
|
Dialog.close("dialog");
|
|
},
|
|
onCancel: () => {
|
|
Dialog.close("dialog");
|
|
},
|
|
});
|
|
e.stopPropagation();
|
|
return;
|
|
}
|
|
}
|
|
|
|
Dialog.open("dialog", {
|
|
title: "提交审核提醒",
|
|
content:
|
|
"提交后报价审核员将看到此审核采购单,请确保所有瓜农信息都录入进来了,确认提交采购订单?",
|
|
confirmText: "确认",
|
|
cancelText: "取消",
|
|
onConfirm: async () => {
|
|
await onSubmit();
|
|
Dialog.close("dialog");
|
|
},
|
|
onCancel: () => {
|
|
Dialog.close("dialog");
|
|
},
|
|
});
|
|
e.stopPropagation();
|
|
}}
|
|
>
|
|
提交审核
|
|
</Button>
|
|
);
|
|
}
|