diff --git a/packages/app-client/src/components/biz/PriceEditor.tsx b/packages/app-client/src/components/biz/PriceEditor.tsx
index c208f2d..5c74d50 100644
--- a/packages/app-client/src/components/biz/PriceEditor.tsx
+++ b/packages/app-client/src/components/biz/PriceEditor.tsx
@@ -11,6 +11,8 @@ interface PriceEditorProps {
unit?: string;
icon?: IconNames;
hint?: string;
+ // 是否负数
+ negative?: boolean;
}
export default function PriceEditor(props: PriceEditorProps) {
@@ -22,6 +24,7 @@ export default function PriceEditor(props: PriceEditorProps) {
unit = "元/斤",
icon = "money-bill",
hint = "点击销售单价可直接编辑",
+ negative = false,
} = props;
// 控制区域是否处于编辑状态
@@ -34,7 +37,11 @@ export default function PriceEditor(props: PriceEditorProps) {
// 当开始编辑时,设置初始值并聚焦输入框
useEffect(() => {
if (isEditing) {
- setInputValue(value.toFixed(2));
+ if (value == 0) {
+ setInputValue("");
+ } else {
+ setInputValue(value.toString());
+ }
// 聚焦到输入框
setTimeout(() => {
if (inputRef.current) {
@@ -83,6 +90,7 @@ export default function PriceEditor(props: PriceEditorProps) {
{isEditing ? (
+ {negative && -}
setIsEditing(true)}
>
+ {negative && "-"}
{formatCurrency(value || 0)}
- {formatCurrency(value || 0)}
+ {Number.isNaN(value) ? "" : formatCurrency(value)}
diff --git a/packages/app-client/src/components/delivery/Step1Form.tsx b/packages/app-client/src/components/delivery/Step1Form.tsx
index e1a0c1e..1945397 100644
--- a/packages/app-client/src/components/delivery/Step1Form.tsx
+++ b/packages/app-client/src/components/delivery/Step1Form.tsx
@@ -548,24 +548,20 @@ const Step1Form = forwardRef((props, ref) => {
return !hasErrors;
};
- return (
-
- {moduleList.map((module) => {
- const contentFields = renderContentFields(module);
- // 如果没有内容配置字段,则不渲染该模块
- if (!contentFields) return null;
+ return moduleList.map((module) => {
+ const contentFields = renderContentFields(module);
+ // 如果没有内容配置字段,则不渲染该模块
+ if (!contentFields) return null;
- return (
-
-
- {module.title}
-
- {contentFields}
-
- );
- })}
-
- );
+ return (
+
+
+ {module.title}
+
+ {contentFields}
+
+ );
+ });
});
export default Step1Form;
diff --git a/packages/app-client/src/components/purchase/cost/CostCard.tsx b/packages/app-client/src/components/purchase/cost/CostCard.tsx
index c9bdb2c..8d3eef2 100644
--- a/packages/app-client/src/components/purchase/cost/CostCard.tsx
+++ b/packages/app-client/src/components/purchase/cost/CostCard.tsx
@@ -116,7 +116,8 @@ export default function CostCard(props: CostCardComponentProps) {
{orderCostItem.name}
- {orderCostItem.count} {orderCostItem.unit}
+ {orderCostItem.price} {orderCostItem.count}{" "}
+ {orderCostItem.unit}
);
diff --git a/packages/app-client/src/components/purchase/cost/CostCreate.tsx b/packages/app-client/src/components/purchase/cost/CostCreate.tsx
index faeeae2..b6bde22 100644
--- a/packages/app-client/src/components/purchase/cost/CostCreate.tsx
+++ b/packages/app-client/src/components/purchase/cost/CostCreate.tsx
@@ -224,40 +224,44 @@ export default function CostCreate(props: AddCostComponentProps) {
选择费用类型
- {costList?.map((cost) => (
- handleCostSelect(cost)}
- >
+ {costList
+ .filter((cost) => {
+ return !(cost.name === "空箱费" || cost.name === "纸箱费");
+ })
+ ?.map((cost) => (
handleCostSelect(cost)}
>
- {/*@ts-ignore*/}
- {cost.image ? (
-
- ) : (
-
- {cost.name.substring(0, 2)}
-
- )}
+
+ {/*@ts-ignore*/}
+ {cost.image ? (
+
+ ) : (
+
+ {cost.name.substring(0, 2)}
+
+ )}
+
+ {cost.name}
- {cost.name}
-
- ))}
+ ))}
{/* 显示金额输入框 */}
@@ -362,6 +366,23 @@ export default function CostCreate(props: AddCostComponentProps) {
);
};
+ const getTitle = (type: string) => {
+ if (type === "ARTIFICIAL_TYPE") {
+ return "新增人工类型费用";
+ }
+ if (type === "MATERIAL_TYPE") {
+ return "新增辅料类型费用";
+ }
+ if (type === "PRODUCTION_TYPE") {
+ return "新增产地类型费用";
+ }
+ if (type === "OTHER_TYPE") {
+ return "新增其他类型费用";
+ }
+
+ return "新增费用";
+ };
+
return (
count === 0,
- )
+ selectedCost?.type !== "OTHER_TYPE" &&
+ (!selectedCost ||
+ Array.from(costItemCounts.values()).every(
+ (count) => count === 0,
+ ))
}
onClick={addCostItems}
>
diff --git a/packages/app-client/src/components/purchase/cost/CostList.tsx b/packages/app-client/src/components/purchase/cost/CostList.tsx
index be7fe25..1d00521 100644
--- a/packages/app-client/src/components/purchase/cost/CostList.tsx
+++ b/packages/app-client/src/components/purchase/cost/CostList.tsx
@@ -27,11 +27,11 @@ export default function CostList(props: {
(cost) => !costIdList.includes(cost.costId) && cost.type === type,
);
- // 新增人工费弹窗状态
+ // 新增费弹窗状态
const [showAddCostPopup, setShowAddCostPopup] = useState(false);
- // 人工费类型
- const workerAdvanceCosts =
+ // 费类型
+ const orderCosts =
purchaseOrderVO.orderCostList?.filter((item) => item.type === type) || [];
const handleSaveNewCost = (
@@ -155,7 +155,7 @@ export default function CostList(props: {
)}
- {workerAdvanceCosts.map((orderCost) => {
+ {orderCosts.map((orderCost) => {
if (type === "MATERIAL_TYPE") {
if (orderCost.name === "空箱费" || orderCost.name === "纸箱费") {
return <>>;
diff --git a/packages/app-client/src/components/purchase/module/OrderCost.tsx b/packages/app-client/src/components/purchase/module/OrderCost.tsx
index d1e4c70..22d81a0 100644
--- a/packages/app-client/src/components/purchase/module/OrderCost.tsx
+++ b/packages/app-client/src/components/purchase/module/OrderCost.tsx
@@ -37,7 +37,7 @@ export default forwardRef(
const orderCostMap = new Map();
orderCostList?.forEach((item) => {
- if (item.costId && costIds.includes(item.costId)) {
+ if (item.costId && costIds?.includes(item.costId)) {
orderCostMap.set(item.costId, item);
}
});
diff --git a/packages/app-client/src/components/purchase/module/OrderCostItem.tsx b/packages/app-client/src/components/purchase/module/OrderCostItem.tsx
index 6d56d85..a974666 100644
--- a/packages/app-client/src/components/purchase/module/OrderCostItem.tsx
+++ b/packages/app-client/src/components/purchase/module/OrderCostItem.tsx
@@ -43,7 +43,10 @@ export default forwardRef(
const orderCostItemMap = new Map();
orderCostItemList?.forEach((item) => {
if (item.costItemId) {
- orderCostItemMap.set(item.costItemId, item);
+ orderCostItemMap.set(item.costItemId, {
+ ...item,
+ selected: true,
+ });
}
});
@@ -132,7 +135,7 @@ export default forwardRef(
// 校验工头姓名
const validatePrincipal = (principal: string) => {
- const isValid = principal.trim().length > 0;
+ const isValid = principal?.trim().length > 0;
setForemanError(!isValid);
return isValid;
};
@@ -170,8 +173,8 @@ export default forwardRef(
};
// 失去焦点时校验工头姓名
- const handlePrincipalBlur = (principal: string) => {
- validatePrincipal(principal);
+ const handlePrincipalBlur = (foreman: string) => {
+ validatePrincipal(foreman);
};
// 对外暴露的校验方法
diff --git a/packages/app-client/src/components/purchase/module/OrderOption.tsx b/packages/app-client/src/components/purchase/module/OrderOption.tsx
index 0526fc9..2c5058e 100644
--- a/packages/app-client/src/components/purchase/module/OrderOption.tsx
+++ b/packages/app-client/src/components/purchase/module/OrderOption.tsx
@@ -171,7 +171,26 @@ export default forwardRef(
// 空箱
orderPackageList: value.orderPackageList,
// 费用
- orderCostList: value.orderCostList.filter((item) => item.selected),
+ orderCostList: value.orderCostList.filter((item) => {
+ if (item.type === "PRODUCTION_TYPE") {
+ return item.selected;
+ }
+
+ if (
+ item.type === "ARTIFICIAL_TYPE" ||
+ item.type === "MATERIAL_TYPE"
+ ) {
+ return (
+ value.orderCostItemList.filter(
+ (orderCostItem) =>
+ item.costItemIds?.includes(orderCostItem.costItemId!) &&
+ orderCostItem.selected,
+ ).length > 0
+ );
+ }
+
+ return false;
+ }),
orderCostItemList: value.orderCostItemList.filter(
(item) => item.selected,
),
@@ -190,36 +209,18 @@ export default forwardRef(
};
const onFinish = async () => {
- Dialog.open("dialog", {
- title: "预览确认",
- content: "即将保存并预览当前采购订单,确定要继续吗?",
- confirmText: "确认预览",
- cancelText: "取消",
- onConfirm: async () => {
- // 只保存第六步的人工和辅料信息
- const costSuccess = await saveCostInfo();
- if (!costSuccess) {
- Dialog.close("dialog");
- return;
- }
+ // 只保存第六步的人工和辅料信息
+ const costSuccess = await saveCostInfo();
+ if (!costSuccess) {
+ Dialog.close("dialog");
+ return;
+ }
- Toast.show("toast", {
- icon: "success",
- title: "提示",
- content: "保存成功,正在跳转预览...",
- });
-
- // 跳转到预览页面
- Taro.redirectTo({
- url: buildUrl("/pages/purchase/enter/preview", {
- orderId: value.orderId,
- }),
- });
- Dialog.close("dialog");
- },
- onCancel: () => {
- Dialog.close("dialog");
- },
+ // 跳转到预览页面
+ Taro.redirectTo({
+ url: buildUrl("/pages/purchase/enter/preview", {
+ orderId: value.orderId,
+ }),
});
};
@@ -452,7 +453,7 @@ export default forwardRef(
setLoading(true);
// 第六步(人工辅料费用)时进行校验
if (
- orderCostRef.current?.validate() ||
+ orderCostRef.current?.validate() &&
orderCostItemRef.current?.validate()
) {
await onFinish();
diff --git a/packages/app-client/src/components/purchase/section/BasicInfoSection.tsx b/packages/app-client/src/components/purchase/section/BasicInfoSection.tsx
index 8b02bd3..6eb369e 100644
--- a/packages/app-client/src/components/purchase/section/BasicInfoSection.tsx
+++ b/packages/app-client/src/components/purchase/section/BasicInfoSection.tsx
@@ -1,5 +1,13 @@
import { ScrollView, Text, View } from "@tarojs/components";
-import { Button, Input, Popup, Radio, SafeArea } from "@nutui/nutui-react-taro";
+import {
+ Button,
+ DatePicker,
+ Input,
+ PickerOption,
+ Popup,
+ Radio,
+ SafeArea,
+} from "@nutui/nutui-react-taro";
import dayjs from "dayjs";
import { formatCurrency } from "@/utils";
import { useEffect, useState } from "react";
@@ -15,6 +23,34 @@ export default function BasicInfoSection(props: {
const { orderVehicle } = purchaseOrderVO;
+ // 当天和未来10天
+ const startDate = new Date();
+ const endDate = new Date(startDate.getTime() + 86400000 * 10);
+ const [show, setShow] = useState(false);
+
+ const formatter = (type: string, option: PickerOption) => {
+ switch (type) {
+ case "year":
+ option.label += "年";
+ break;
+ case "month":
+ option.label += "月";
+ break;
+ case "day":
+ option.label += "日";
+ break;
+ case "hour":
+ option.label += "时";
+ break;
+ case "minute":
+ option.label += "分";
+ break;
+ default:
+ break;
+ }
+ return option;
+ };
+
// 弹窗可见状态
const [visiblePopup, setVisiblePopup] = useState({
basicInfo: false, // 基础信息弹窗
@@ -40,9 +76,11 @@ export default function BasicInfoSection(props: {
const [loadingLastVehicleNo, setLoadingLastVehicleNo] = useState(false);
// 获取上一车次号
- const fetchLastVehicleNo = async () => {
+ const fetchLastVehicleNo = async (
+ dealerId: BusinessAPI.DealerVO["dealerId"],
+ ) => {
// 如果已经有车次号,则不需要获取上一车次号
- if (orderVehicle?.vehicleNo) {
+ if (orderVehicle?.vehicleNo || !dealerId) {
return;
}
@@ -55,7 +93,9 @@ export default function BasicInfoSection(props: {
try {
const { data: res } =
await businessServices.purchaseOrder.getLastVehicleNo({
- lastVehicleNoQry: {},
+ lastVehicleNoQry: {
+ dealerId: purchaseOrderVO.orderDealer.dealerId,
+ },
});
if (res.success && res.data) {
@@ -83,8 +123,8 @@ export default function BasicInfoSection(props: {
// 组件加载时获取上一车次号
useEffect(() => {
- fetchLastVehicleNo();
- }, []);
+ fetchLastVehicleNo(purchaseOrderVO.orderDealer.dealerId);
+ }, [purchaseOrderVO.orderDealer.dealerId]);
// 打开基础信息弹窗
const openBasicInfoPopup = () => {
@@ -246,26 +286,48 @@ export default function BasicInfoSection(props: {
/>
-
- 发货日期
-
-
- {
- setEditValues((prev) => ({
- ...prev,
- deliveryTime: value,
- }));
- }}
- />
+
+
+ 发货日期
+
+
+ setShow(true)}
+ >
+
+ {editValues.deliveryTime || "请输入发货日期"}
+
+
+
+ setShow(false)}
+ onConfirm={(_, values) => {
+ setEditValues((prev) => ({
+ ...prev,
+ deliveryTime: dayjs(values.join("-")).format(
+ "YYYY-MM-DD",
+ ),
+ }));
+ }}
+ />
+
diff --git a/packages/app-client/src/components/purchase/section/CostDifferenceSection.tsx b/packages/app-client/src/components/purchase/section/CostDifferenceSection.tsx
index f224b47..9b07f85 100644
--- a/packages/app-client/src/components/purchase/section/CostDifferenceSection.tsx
+++ b/packages/app-client/src/components/purchase/section/CostDifferenceSection.tsx
@@ -10,13 +10,14 @@ export default function CostDifferenceSection(props: {
}) {
const { purchaseOrderVO, onChange, readOnly, calculator } = props;
const orderDealer = purchaseOrderVO.orderDealer;
+ console.log("calculator.getShareProfit()", calculator.getShareProfit());
return (
{/* 卡片形式展示分成信息 */}
- 分成
+ 待分红金额
@@ -37,22 +38,20 @@ export default function CostDifferenceSection(props: {
},
});
}}
- readOnly={readOnly || !orderDealer?.shareAdjusted}
- label={orderDealer?.shareAdjusted ? "调分成金额" : "分成金额"}
+ readOnly={readOnly}
+ label={"调整的金额"}
unit="元"
hint="点击金额可直接编辑"
+ negative
/>
- 分成利润
+ 调整后的分成利润
- ¥{" "}
- {formatCurrency(
- orderDealer.profitSharing || calculator.getShareProfit() || 0,
- )}
+ ¥ {formatCurrency(calculator.getShareProfit() || 0)}
diff --git a/packages/app-client/src/components/purchase/section/DeliveryFormSection.tsx b/packages/app-client/src/components/purchase/section/DeliveryFormSection.tsx
index b3559cb..d16017b 100644
--- a/packages/app-client/src/components/purchase/section/DeliveryFormSection.tsx
+++ b/packages/app-client/src/components/purchase/section/DeliveryFormSection.tsx
@@ -1,5 +1,4 @@
import { useEffect, useState } from "react";
-import { View } from "@tarojs/components";
import { DeliveryStep1Form } from "@/components";
import {
convertPurchaseOrderToShipOrder,
@@ -21,10 +20,10 @@ export default function DeliveryFormSection(props: {
? purchaseOrderVO.shipOrderVOList[0]
: convertPurchaseOrderToShipOrder(purchaseOrderVO);
- const init = async (shipOrderVO: BusinessAPI.ShipOrderVO) => {
+ const init = async (purchaseOrderVO: BusinessAPI.PurchaseOrderVO) => {
const { data } = await business.dealer.showDealer({
dealerShowQry: {
- dealerId: shipOrderVO.dealerId,
+ dealerId: purchaseOrderVO.orderDealer.dealerId,
},
});
@@ -36,14 +35,15 @@ export default function DeliveryFormSection(props: {
template,
convertedData,
);
- console.log("updatedTemplate", updatedTemplate);
setModuleList(updatedTemplate);
+ } else {
+ setModuleList([]);
}
};
useEffect(() => {
- init(shipOrderVO);
- }, []);
+ init(purchaseOrderVO);
+ }, [purchaseOrderVO]);
// 更新模板配置
const updateTemplateConfig = async (template: any[], data: any) => {
@@ -64,18 +64,16 @@ export default function DeliveryFormSection(props: {
}
return (
-
- {
- onChange?.({
- ...purchaseOrderVO,
- shipOrderVOList: [shipOrderVO],
- });
- }}
- />
-
+ {
+ onChange?.({
+ ...purchaseOrderVO,
+ shipOrderVOList: [shipOrderVO],
+ });
+ }}
+ />
);
}
diff --git a/packages/app-client/src/components/purchase/section/EmptyBoxInfoSection.tsx b/packages/app-client/src/components/purchase/section/EmptyBoxInfoSection.tsx
index f704217..e6c86f0 100644
--- a/packages/app-client/src/components/purchase/section/EmptyBoxInfoSection.tsx
+++ b/packages/app-client/src/components/purchase/section/EmptyBoxInfoSection.tsx
@@ -12,18 +12,10 @@ export default function EmptyBoxInfoSection(props: {
const { purchaseOrderVO, onChange, readOnly } = props;
const defaultColumns = [
- {
- title: "品牌",
- key: "boxBrandName",
- fixed: "left",
- },
- {
- title: "规格",
- key: "boxSpecName",
- },
{
title: "纸箱型号",
key: "boxProductName",
+ fixed: "left",
},
{
title: "个数",
@@ -95,87 +87,11 @@ export default function EmptyBoxInfoSection(props: {
orderPackageId?: string;
isTotalRow?: boolean;
},
- ) => {
- // 合计行不显示编辑按钮
- if (value.isTotalRow) {
- return formatCurrency(value.boxProductWeight);
- }
-
- return (
- {
- if (!readOnly) {
- e.stopPropagation();
- // 设置临时编辑值为当前值
- setTempEditValues((prev) => ({
- ...prev,
- [value.orderPackageId || ""]:
- editValues[value.orderPackageId || ""],
- }));
- setVisiblePopup((prev) => ({
- ...prev,
- [value.orderPackageId || ""]: true,
- }));
- }
- }}
- >
-
- {formatCurrency(value.boxProductWeight)}
-
- {!readOnly && (
-
-
-
- )}
-
- );
- },
+ ) => formatCurrency(value.boxProductWeight),
},
{
- title: "成本单价(元)",
- key: "boxCostPrice",
- render: (
- value: BusinessAPI.OrderPackage & {
- orderPackageId?: string;
- isTotalRow?: boolean;
- },
- ) => {
- // 合计行不显示编辑按钮
- if (value.isTotalRow) {
- return formatCurrency(value.boxCostPrice as number);
- }
-
- return (
- {
- if (!readOnly) {
- e.stopPropagation();
- // 设置临时编辑值为当前值
- setTempEditValues((prev) => ({
- ...prev,
- [value.orderPackageId || ""]:
- editValues[value.orderPackageId || ""],
- }));
- setVisiblePopup((prev) => ({
- ...prev,
- [value.orderPackageId || ""]: true,
- }));
- }
- }}
- >
-
- {formatCurrency(value.boxCostPrice as number)}
-
- {!readOnly && (
-
-
-
- )}
-
- );
- },
+ title: "品牌",
+ key: "boxBrandName",
},
];
const [columns, setColumns] = useState(defaultColumns);
@@ -194,55 +110,38 @@ export default function EmptyBoxInfoSection(props: {
// 编辑值的状态
const [editValues, setEditValues] = useState<{
[key: string]: {
- boxCostPrice?: number;
boxSalePrice?: number;
- boxProductWeight?: number;
};
}>({});
// 临时编辑值的状态(用于在保存前暂存编辑的值)
const [tempEditValues, setTempEditValues] = useState<{
[key: string]: {
- boxCostPrice?: number;
boxSalePrice?: number;
- boxProductWeight?: number;
};
}>({});
// 初始化编辑值
- const initEditValues = (
- pkgId: string,
- boxCostPrice?: number,
- boxSalePrice?: number,
- boxProductWeight?: number,
- ) => {
+ const initEditValues = (pkgId: string, boxSalePrice?: number) => {
const updates: {
editValuesUpdate?: {
- boxCostPrice?: number;
boxSalePrice?: number;
- boxProductWeight?: number;
};
tempEditValuesUpdate?: {
- boxCostPrice?: number;
boxSalePrice?: number;
- boxProductWeight?: number;
};
} = {};
if (!editValues[pkgId]) {
updates.editValuesUpdate = {
- boxCostPrice,
boxSalePrice,
- boxProductWeight,
};
}
// 同时初始化临时编辑值
if (!tempEditValues[pkgId]) {
updates.tempEditValuesUpdate = {
- boxCostPrice,
boxSalePrice,
- boxProductWeight,
};
}
@@ -288,25 +187,21 @@ export default function EmptyBoxInfoSection(props: {
// 计算各项合计
let totalBoxProductCount = 0;
let totalBoxSalePayment = 0;
- let totalBoxCostPayment = 0;
let totalBoxProductWeight = 0;
packageData.forEach((pkg: any) => {
totalBoxProductCount += pkg.boxProductCount || 0;
totalBoxSalePayment +=
Number((pkg?.boxSalePrice || 0) * pkg.boxProductCount) || 0;
- totalBoxCostPayment +=
- Number((pkg?.boxCostPrice || 0) * pkg.boxProductCount) || 0;
totalBoxProductWeight +=
Number((pkg?.boxProductWeight || 0) * pkg.boxProductCount) || 0;
});
return {
- boxBrandName: "合计",
+ boxProductName: "合计",
boxProductCount: totalBoxProductCount,
boxSalePayment: totalBoxSalePayment,
boxProductWeight: totalBoxProductWeight,
- boxCostPrice: totalBoxCostPayment,
isTotalRow: true, // 标记这是合计行
};
};
@@ -322,12 +217,7 @@ export default function EmptyBoxInfoSection(props: {
packageData.forEach((pkg: BusinessAPI.OrderPackage) => {
const pkgId = pkg.orderPackageId || "";
- const updates = initEditValues(
- pkgId,
- pkg.boxCostPrice,
- pkg.boxSalePrice,
- pkg.boxProductWeight,
- );
+ const updates = initEditValues(pkgId, pkg.boxSalePrice);
if (updates.editValuesUpdate) {
newEditValues[pkgId] = updates.editValuesUpdate;
@@ -364,18 +254,10 @@ export default function EmptyBoxInfoSection(props: {
if (editValue) {
return {
...pkg,
- boxCostPrice:
- editValue.boxCostPrice !== undefined
- ? editValue.boxCostPrice
- : pkg.boxCostPrice,
boxSalePrice:
editValue.boxSalePrice !== undefined
? editValue.boxSalePrice
: pkg.boxSalePrice,
- boxProductWeight:
- editValue.boxProductWeight !== undefined
- ? editValue.boxProductWeight
- : pkg.boxProductWeight,
};
}
return pkg;
@@ -397,7 +279,7 @@ export default function EmptyBoxInfoSection(props: {
// 自定义列配置,对合计行特殊处理
const columnsWithTotalsRender = columns.map((column) => {
- if (column.key === "boxBrandName") {
+ if (column.key === "boxProductName") {
// 品牌列显示"合计"
return {
...column,
@@ -405,11 +287,11 @@ export default function EmptyBoxInfoSection(props: {
if (rowData.isTotalRow) {
return (
- {rowData.boxBrandName}
+ {rowData.boxProductName}
);
}
- return rowData.boxBrandName;
+ return rowData.boxProductName;
},
};
} else if (column.key === "boxProductCount") {
@@ -476,21 +358,6 @@ export default function EmptyBoxInfoSection(props: {
return column.render(rowData, rowData);
},
};
- } else if (column.key === "boxCostPrice") {
- // 成本单价列合计行处理
- return {
- ...column,
- render: (rowData: any) => {
- if (rowData.isTotalRow) {
- return (
-
- {formatCurrency(rowData.boxCostPrice as number)}
-
- );
- }
- return column.render(rowData, rowData);
- },
- };
}
// 其他列保持原有render函数或者默认显示
@@ -566,66 +433,6 @@ export default function EmptyBoxInfoSection(props: {
/>
元
-
-
-
- 成本单价
-
-
- {
- const numValue = validatePrice(value);
- if (numValue !== undefined) {
- setTempEditValues((prev) => ({
- ...prev,
- [pkg.orderPackageId || ""]: {
- ...prev[pkg.orderPackageId || ""],
- boxCostPrice: numValue as number,
- },
- }));
- }
- }}
- />
- 元
-
-
-
-
- 箱重
-
-
- {
- const numValue = validatePrice(value);
- if (numValue !== undefined) {
- setTempEditValues((prev) => ({
- ...prev,
- [pkg.orderPackageId || ""]: {
- ...prev[pkg.orderPackageId || ""],
- boxProductWeight: numValue as number,
- },
- }));
- }
- }}
- />
- 斤
-
diff --git a/packages/app-client/src/components/purchase/section/PackageInfoSection.tsx b/packages/app-client/src/components/purchase/section/PackageInfoSection.tsx
index f140479..e64e757 100644
--- a/packages/app-client/src/components/purchase/section/PackageInfoSection.tsx
+++ b/packages/app-client/src/components/purchase/section/PackageInfoSection.tsx
@@ -87,47 +87,11 @@ export default function PackageInfoSection(props: {
orderPackageId?: string;
isTotalRow?: boolean;
},
- ) => {
- // 合计行不显示编辑按钮
- if (value.isTotalRow) {
- return formatCurrency(value.boxProductWeight);
- }
-
- return (
- {
- if (!readOnly) {
- e.stopPropagation();
- // 设置临时编辑值为当前值
- setTempEditValues((prev) => ({
- ...prev,
- [value.orderPackageId || ""]:
- editValues[value.orderPackageId || ""],
- }));
- setVisiblePopup((prev) => ({
- ...prev,
- [value.orderPackageId || ""]: true,
- }));
- }
- }}
- >
-
- {formatCurrency(value.boxProductWeight)}
-
- {!readOnly && (
-
-
-
- )}
-
- );
- },
+ ) => formatCurrency(value.boxProductWeight),
},
{
title: "品牌",
key: "boxBrandName",
- fixed: "left",
},
];
const [columns, setColumns] = useState(defaultColumns);
@@ -146,55 +110,38 @@ export default function PackageInfoSection(props: {
// 编辑值的状态
const [editValues, setEditValues] = useState<{
[key: string]: {
- boxCostPrice?: number;
boxSalePrice?: number;
- boxProductWeight?: number;
};
}>({});
// 临时编辑值的状态(用于在保存前暂存编辑的值)
const [tempEditValues, setTempEditValues] = useState<{
[key: string]: {
- boxCostPrice?: number;
boxSalePrice?: number;
- boxProductWeight?: number;
};
}>({});
// 初始化编辑值
- const initEditValues = (
- pkgId: string,
- boxCostPrice?: number,
- boxSalePrice?: number,
- boxProductWeight?: number,
- ) => {
+ const initEditValues = (pkgId: string, boxSalePrice?: number) => {
const updates: {
editValuesUpdate?: {
- boxCostPrice?: number;
boxSalePrice?: number;
- boxProductWeight?: number;
};
tempEditValuesUpdate?: {
- boxCostPrice?: number;
boxSalePrice?: number;
- boxProductWeight?: number;
};
} = {};
if (!editValues[pkgId]) {
updates.editValuesUpdate = {
- boxCostPrice,
boxSalePrice,
- boxProductWeight,
};
}
// 同时初始化临时编辑值
if (!tempEditValues[pkgId]) {
updates.tempEditValuesUpdate = {
- boxCostPrice,
boxSalePrice,
- boxProductWeight,
};
}
@@ -244,15 +191,12 @@ export default function PackageInfoSection(props: {
// 计算各项合计
let totalBoxProductCount = 0;
let totalBoxSalePayment = 0;
- let totalBoxCostPayment = 0;
let totalBoxProductWeight = 0;
packageData.forEach((pkg: any) => {
totalBoxProductCount += pkg.boxProductCount || 0;
totalBoxSalePayment +=
Number((pkg?.boxSalePrice || 0) * pkg.boxProductCount) || 0;
- totalBoxCostPayment +=
- Number((pkg?.boxCostPrice || 0) * pkg.boxProductCount) || 0;
totalBoxProductWeight +=
Number((pkg?.boxProductWeight || 0) * pkg.boxProductCount) || 0;
});
@@ -262,7 +206,6 @@ export default function PackageInfoSection(props: {
boxProductCount: totalBoxProductCount,
boxSalePayment: totalBoxSalePayment,
boxProductWeight: totalBoxProductWeight,
- boxCostPrice: totalBoxCostPayment,
isTotalRow: true, // 标记这是合计行
};
};
@@ -278,12 +221,7 @@ export default function PackageInfoSection(props: {
packageData.forEach((pkg: BusinessAPI.OrderPackage) => {
const pkgId = pkg.orderPackageId || "";
- const updates = initEditValues(
- pkgId,
- pkg.boxCostPrice,
- pkg.boxSalePrice,
- pkg.boxProductWeight,
- );
+ const updates = initEditValues(pkgId, pkg.boxSalePrice);
if (updates.editValuesUpdate) {
newEditValues[pkgId] = updates.editValuesUpdate;
@@ -323,18 +261,10 @@ export default function PackageInfoSection(props: {
if (editValue) {
return {
...pkg,
- boxCostPrice:
- editValue.boxCostPrice !== undefined
- ? editValue.boxCostPrice
- : pkg.boxCostPrice,
boxSalePrice:
editValue.boxSalePrice !== undefined
? editValue.boxSalePrice
: pkg.boxSalePrice,
- boxProductWeight:
- editValue.boxProductWeight !== undefined
- ? editValue.boxProductWeight
- : pkg.boxProductWeight,
};
}
return pkg;
@@ -518,36 +448,6 @@ export default function PackageInfoSection(props: {
/>
元
-
-
-
- 箱重
-
-
- {
- const numValue = validatePrice(value);
- if (numValue !== undefined) {
- setTempEditValues((prev) => ({
- ...prev,
- [pkg.orderPackageId || ""]: {
- ...prev[pkg.orderPackageId || ""],
- boxProductWeight: numValue as number,
- },
- }));
- }
- }}
- />
- 斤
-
diff --git a/packages/app-client/src/pages/purchase/audit/audit.tsx b/packages/app-client/src/pages/purchase/audit/audit.tsx
index 3610535..764f9db 100644
--- a/packages/app-client/src/pages/purchase/audit/audit.tsx
+++ b/packages/app-client/src/pages/purchase/audit/audit.tsx
@@ -38,7 +38,12 @@ import {
TaxSubsidySection,
WorkerAdvanceSection,
} from "@/components";
-import { buildUrl, formatCurrency, PurchaseOrderCalculator } from "@/utils";
+import {
+ buildUrl,
+ formatCurrency,
+ generateShortId,
+ PurchaseOrderCalculator,
+} from "@/utils";
import classNames from "classnames";
const defaultSections = [
@@ -179,11 +184,11 @@ const fullSections = [
component: TaxProvisionSection,
title: "计提税金复核",
},
- // 调诚信志远分红
+ // 待分红金额复核
{
name: "costDifference",
component: CostDifferenceSection,
- title: "调诚信志远分红",
+ title: "待分红金额复核",
},
// 成本合计
{
@@ -215,24 +220,6 @@ export default hocAuth(function Page(props: CommonComponent) {
// 费用项目列表
const [costList, setCostList] = useState([]);
- // 获取费用项目列表
- useEffect(() => {
- const fetchCost = async () => {
- try {
- const { data } = await business.cost.listCost({
- costListQry: {
- status: true,
- },
- });
- setCostList(data.data || []);
- } catch (error) {
- console.error("获取费用项目列表失败:", error);
- }
- };
-
- fetchCost();
- }, []);
-
const [purchaseOrderVO, setPurchaseOrderVO] =
useState();
@@ -449,16 +436,63 @@ export default hocAuth(function Page(props: CommonComponent) {
};
const init = async (orderId: BusinessAPI.PurchaseOrderVO["orderId"]) => {
- const { data } = await business.purchaseOrder.showPurchaseOrder({
+ const {
+ data: { data: purchaseOrderVO, success },
+ } = await business.purchaseOrder.showPurchaseOrder({
purchaseOrderShowQry: {
orderId,
},
});
- if (data.success) {
- setPurchaseOrderVO(data.data);
+ if (success && purchaseOrderVO) {
+ await initDealer(purchaseOrderVO?.orderDealer?.dealerId!);
- await initDealer(data.data?.orderDealer?.dealerId!);
+ const orderCost = purchaseOrderVO?.orderCostList.find(
+ (item) => item.name === "计提费" && item.type === "OTHER_TYPE",
+ );
+
+ if (orderCost) {
+ await business.cost
+ .listCost({
+ costListQry: {
+ status: true,
+ },
+ })
+ .then(({ data: { data: costList } }) => {
+ setCostList(costList || []);
+ });
+ } else {
+ const {
+ data: { data: costList },
+ } = await business.cost.listCost({
+ costListQry: {
+ status: true,
+ },
+ });
+
+ setCostList(costList || []);
+
+ const cost = costList?.find(
+ (cost) => cost.name === "计提费" && cost.type === "OTHER_TYPE",
+ );
+
+ if (cost) {
+ purchaseOrderVO.orderCostList.push({
+ orderCostId: generateShortId(),
+ costId: cost.costId || "",
+ name: cost.name || "",
+ price: cost.price || 0,
+ unit: cost.unit || "元",
+ count: 1,
+ type: "OTHER_TYPE",
+ costItemIds: [],
+ principal: "",
+ selected: true,
+ });
+ }
+ }
+
+ setPurchaseOrderVO(purchaseOrderVO);
}
};
@@ -567,7 +601,10 @@ export default hocAuth(function Page(props: CommonComponent) {
return null;
}
- if (!orderDealer?.enableShare && sectionKey === "costDifference") {
+ if (
+ !orderDealer?.shareAdjusted &&
+ sectionKey === "costDifference"
+ ) {
return null;
}
@@ -603,7 +640,7 @@ export default hocAuth(function Page(props: CommonComponent) {
}
return (
- <>
+
{section.title}
- >
+
);
})}
diff --git a/packages/app-client/src/utils/classes/calculators/PurchaseOrderCalculator.ts b/packages/app-client/src/utils/classes/calculators/PurchaseOrderCalculator.ts
index 1f0f93f..cbfa106 100644
--- a/packages/app-client/src/utils/classes/calculators/PurchaseOrderCalculator.ts
+++ b/packages/app-client/src/utils/classes/calculators/PurchaseOrderCalculator.ts
@@ -49,7 +49,7 @@ export class PurchaseOrderCalculator {
{
分成利润: this.getShareProfit(),
西瓜利润: this.getMelonNetProfit(),
- 诚信志远分成: this.getShareProfitRatio(),
+ 分成: this.getShareProfitRatio(),
个人利润: this.getPersonalProfit(),
},
]);