Compare commits
No commits in common. "9c0c0de0c786d5cb98820a110137503cd6314fd2" and "5eb4e0f4bb6bd51032a99dc8fcca794b1ca9dc66" have entirely different histories.
9c0c0de0c7
...
5eb4e0f4bb
@ -22,10 +22,6 @@ export default {
|
||||
process.env.TARO_ENV === "h5"
|
||||
? '"/api"'
|
||||
: '"https://api.erp.qilincloud168.com"',
|
||||
"process.env.TARO_POSTER_DOMAIN":
|
||||
process.env.TARO_ENV === "h5"
|
||||
? '""'
|
||||
: '"https://poster.qilincloud168.com"',
|
||||
},
|
||||
mini: {
|
||||
miniCssExtractPluginOption: {
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import {
|
||||
Dialog,
|
||||
Input,
|
||||
Popup,
|
||||
SafeArea,
|
||||
SearchBar,
|
||||
Dialog,
|
||||
Input,
|
||||
} from "@nutui/nutui-react-taro";
|
||||
import { Icon } from "@/components";
|
||||
import { ScrollView, View } from "@tarojs/components";
|
||||
@ -64,10 +64,6 @@ export default function DealerPicker(props: IDealerPickerProps) {
|
||||
return (
|
||||
<>
|
||||
<View
|
||||
className={"flex flex-1 flex-row items-center justify-between px-5"}
|
||||
style={{
|
||||
color: "var(--nutui-color-title, #1a1a1a)",
|
||||
}}
|
||||
onClick={(event) => {
|
||||
setVisible(true);
|
||||
event.stopPropagation();
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import { Text, View } from "@tarojs/components";
|
||||
import {
|
||||
Button,
|
||||
Dialog,
|
||||
Input,
|
||||
Radio,
|
||||
Toast,
|
||||
Uploader,
|
||||
UploaderFileItem,
|
||||
Dialog,
|
||||
} from "@nutui/nutui-react-taro";
|
||||
import { Icon, SupplierPicker } from "@/components";
|
||||
import { forwardRef, useEffect, useImperativeHandle, useState } from "react";
|
||||
@ -47,6 +47,7 @@ export default forwardRef<MelonFarmerRef, IMelonFarmerProps>(
|
||||
} = props;
|
||||
|
||||
const [supplierVO, setSupplierVO] = useState<SupplierVO>();
|
||||
console.log("supplierVO", supplierVO);
|
||||
|
||||
// 初始化数据
|
||||
useEffect(() => {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -623,7 +623,7 @@ export default forwardRef<OrderPackageRef, IOrderPackageProps>(
|
||||
|
||||
return (
|
||||
<View
|
||||
className="mb-2.5 overflow-hidden rounded-xl border border-gray-200 bg-white p-2.5 shadow-sm"
|
||||
className="relative mb-2.5 overflow-hidden rounded-xl border border-gray-200 bg-white p-2.5 shadow-sm"
|
||||
key={item.id}
|
||||
>
|
||||
{/* 品牌背景水印 */}
|
||||
@ -785,6 +785,8 @@ export default forwardRef<OrderPackageRef, IOrderPackageProps>(
|
||||
<View className="flex w-fit flex-row gap-2.5">
|
||||
{boxBrandList
|
||||
?.filter((item) => {
|
||||
console.log("item: ", item);
|
||||
console.log("boxType: ", boxType);
|
||||
if (boxType === "OWN") {
|
||||
return item.boxBrandType === "FARMER_BOX";
|
||||
} else {
|
||||
@ -815,8 +817,7 @@ export default forwardRef<OrderPackageRef, IOrderPackageProps>(
|
||||
>
|
||||
<Image
|
||||
src={boxBrand.boxBrandImage}
|
||||
className="h-full w-full"
|
||||
mode="aspectFit"
|
||||
mode={"aspectFill"}
|
||||
alt={boxBrand.boxBrandImage}
|
||||
/>
|
||||
</View>
|
||||
|
||||
@ -25,7 +25,6 @@ interface IOrderVehicleProps {
|
||||
setOrderDealer: (orderDealer: BusinessAPI.OrderDealer) => void;
|
||||
orderCostList: CostItem[];
|
||||
setOrderCostList: (orderCostList: CostItem[]) => void;
|
||||
costItemVOList: BusinessAPI.CostItemVO[];
|
||||
}
|
||||
|
||||
export interface OrderVehicleRef {
|
||||
@ -41,7 +40,6 @@ export default forwardRef<OrderVehicleRef, IOrderVehicleProps>(
|
||||
orderDealer,
|
||||
orderCostList,
|
||||
setOrderCostList,
|
||||
costItemVOList,
|
||||
} = props;
|
||||
|
||||
const [dealerVO, setDealerVO] = useState<BusinessAPI.DealerVO>();
|
||||
@ -68,6 +66,28 @@ export default forwardRef<OrderVehicleRef, IOrderVehicleProps>(
|
||||
const startDate = new Date(currentYear, 0, 1); // 当年第一天
|
||||
const endDate = new Date(); // 今天
|
||||
|
||||
// 费用项目列表
|
||||
const [costItems, setCostItems] = useState<BusinessAPI.CostItemVO[]>([]);
|
||||
|
||||
// 获取费用项目列表
|
||||
useEffect(() => {
|
||||
const fetchCostItems = async () => {
|
||||
try {
|
||||
const { data } = await business.costItem.listCostItem({
|
||||
costItemListQry: {
|
||||
status: true,
|
||||
showInEntry: true,
|
||||
},
|
||||
});
|
||||
setCostItems(data.data || []);
|
||||
} catch (error) {
|
||||
console.error("获取费用项目列表失败:", error);
|
||||
}
|
||||
};
|
||||
|
||||
fetchCostItems();
|
||||
}, []);
|
||||
|
||||
// 当desc改变时更新车辆信息中的时间
|
||||
useEffect(() => {
|
||||
if (desc) {
|
||||
@ -407,7 +427,7 @@ export default forwardRef<OrderVehicleRef, IOrderVehicleProps>(
|
||||
};
|
||||
|
||||
const getCostItemByName = (name: string): BusinessAPI.CostItemVO => {
|
||||
return costItemVOList?.find(
|
||||
return costItems?.find(
|
||||
(item) => item.name === name && item.costType === "PRODUCTION_ADVANCE",
|
||||
)!;
|
||||
};
|
||||
@ -723,23 +743,27 @@ export default forwardRef<OrderVehicleRef, IOrderVehicleProps>(
|
||||
目的地
|
||||
</View>
|
||||
<View className={"flex flex-row gap-2.5"}>
|
||||
<View className={"flex-1"}>
|
||||
<View>
|
||||
<View
|
||||
id={"target2"}
|
||||
className={`flex h-10 w-full flex-1 items-center rounded-md ${dealerNameError ? "border-4 border-red-500" : "border-4 border-gray-300"}`}
|
||||
className={`relative flex h-10 w-full items-center rounded-md ${dealerNameError ? "border-4 border-red-500" : "border-4 border-gray-300"}`}
|
||||
>
|
||||
<DealerPicker
|
||||
onFinish={setDealerVO}
|
||||
enableManualInput
|
||||
trigger={
|
||||
<>
|
||||
<View className={"text-sm"}>
|
||||
{orderVehicle?.dealerName || "选择经销商"}
|
||||
</View>
|
||||
<Icon name={"chevron-down"} />
|
||||
</>
|
||||
<Input
|
||||
type="text"
|
||||
placeholder="选择经销商"
|
||||
value={orderVehicle?.dealerName}
|
||||
disabled
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<Icon
|
||||
name={"chevron-down"}
|
||||
className={"absolute -right-1 mr-4"}
|
||||
/>
|
||||
</View>
|
||||
{dealerNameError && (
|
||||
<View className="mt-1 text-xs text-red-500">
|
||||
@ -747,7 +771,7 @@ export default forwardRef<OrderVehicleRef, IOrderVehicleProps>(
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
<View className={"flex-1"}>
|
||||
<View>
|
||||
<View
|
||||
className={`flex h-10 w-full items-center rounded-md ${destinationError ? "border-4 border-red-500" : "border-4 border-gray-300"}`}
|
||||
>
|
||||
@ -878,22 +902,17 @@ export default forwardRef<OrderVehicleRef, IOrderVehicleProps>(
|
||||
<View
|
||||
className={`flex h-10 w-full items-center rounded-md ${deliveryTimeError ? "border-4 border-red-500" : "border-4 border-gray-300"}`}
|
||||
>
|
||||
<View
|
||||
className={
|
||||
"flex flex-1 flex-row items-center justify-between px-5"
|
||||
}
|
||||
style={{
|
||||
color: "var(--nutui-color-title, #1a1a1a)",
|
||||
}}
|
||||
onClick={() => setShow(true)}
|
||||
>
|
||||
<View className={"text-sm"}>
|
||||
{orderVehicle?.deliveryTime
|
||||
<Input
|
||||
type="text"
|
||||
placeholder="请选择发货时间"
|
||||
value={
|
||||
orderVehicle?.deliveryTime
|
||||
? dayjs(orderVehicle?.deliveryTime).format("YYYY年MM月DD日")
|
||||
: "请选择发货时间"}
|
||||
</View>
|
||||
<Icon name={"chevron-down"} />
|
||||
</View>
|
||||
: "请选择发货时间"
|
||||
}
|
||||
disabled
|
||||
onClick={() => setShow(true)}
|
||||
/>
|
||||
</View>
|
||||
{deliveryTimeError && (
|
||||
<View className="mt-1 text-xs text-red-500">请选择发货时间</View>
|
||||
|
||||
@ -265,146 +265,93 @@ export default function PurchasePreview(props: IPurchasePreviewProps) {
|
||||
<View>{formatCurrency(totalBoxWeight)} 斤</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{purchaseOrder.orderPackageList.length > 0 && (
|
||||
<>
|
||||
<View className="text-sm font-bold">空箱使用明细</View>
|
||||
<View className="flex flex-col gap-2.5">
|
||||
{purchaseOrder.orderCostList?.filter(
|
||||
(costItem: CostItem) => costItem.costType === "PACKAGING_MATERIALS",
|
||||
).length > 0 && (
|
||||
<>
|
||||
<View className="text-sm font-bold">辅料使用明细</View>
|
||||
<View className="rounded-lg bg-white p-2.5 shadow-sm">
|
||||
{/* 根据boxBrandName对packageInfoList进行分组显示 */}
|
||||
{(() => {
|
||||
const groupedPackageInfo = groupBy(
|
||||
purchaseOrder.orderPackageList || [],
|
||||
(item) => item.boxBrandName,
|
||||
);
|
||||
|
||||
return Object.entries(groupedPackageInfo).map(
|
||||
([brandName, packageInfos]) => (
|
||||
<View key={brandName} className="mb-2.5">
|
||||
<View className="text-primary mb-2.5 text-base font-bold">
|
||||
纸箱品牌:{brandName}
|
||||
<View className="flex flex-col gap-2.5">
|
||||
{purchaseOrder.orderCostList
|
||||
?.filter(
|
||||
(costItem: CostItem) =>
|
||||
costItem.costType === "PACKAGING_MATERIALS",
|
||||
)
|
||||
.map((costItem) => (
|
||||
<View
|
||||
className="flex items-center justify-between"
|
||||
key={costItem.orderCostId}
|
||||
>
|
||||
<View className="text-sm text-gray-600">
|
||||
{costItem.name}
|
||||
</View>
|
||||
<View className={"overflow-x-auto"}>
|
||||
<Table columns={columns} data={packageInfos} />
|
||||
<View className="text-sm font-medium">
|
||||
{costItem.count} {costItem.unit}
|
||||
</View>
|
||||
</View>
|
||||
),
|
||||
);
|
||||
})()}
|
||||
</View>
|
||||
<View className="rounded-lg bg-white p-2.5 shadow-md">
|
||||
<View className="flex items-center justify-between text-sm font-bold">
|
||||
<View>总箱数</View>
|
||||
<View>
|
||||
{purchaseOrder.orderPackageList.reduce(
|
||||
(sum, item) => sum + item.boxCount,
|
||||
0,
|
||||
)}
|
||||
箱
|
||||
</View>
|
||||
</View>
|
||||
<View className="mt-2 flex items-center justify-between text-sm font-bold">
|
||||
<View>总箱重</View>
|
||||
<View>
|
||||
{purchaseOrder.orderPackageList.reduce(
|
||||
(sum, item) => sum + item.boxProductWeight * item.boxCount,
|
||||
0,
|
||||
)}
|
||||
斤
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</>
|
||||
)}
|
||||
|
||||
{purchaseOrder.orderCostList?.filter(
|
||||
(costItem: CostItem) => costItem.costType === "PACKAGING_MATERIALS",
|
||||
).length > 0 && (
|
||||
<>
|
||||
<View className="text-sm font-bold">辅料使用明细</View>
|
||||
<View className="rounded-lg bg-white p-2.5 shadow-sm">
|
||||
<View className="flex flex-col gap-2.5">
|
||||
{purchaseOrder.orderCostList
|
||||
?.filter(
|
||||
(costItem: CostItem) =>
|
||||
costItem.costType === "PACKAGING_MATERIALS",
|
||||
)
|
||||
.map((costItem) => (
|
||||
<View
|
||||
className="flex items-center justify-between"
|
||||
key={costItem.orderCostId}
|
||||
>
|
||||
<View className="text-sm text-gray-600">
|
||||
{costItem.name}
|
||||
</View>
|
||||
<View className="text-sm font-medium">
|
||||
{costItem.count} {costItem.unit}
|
||||
</View>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
</>
|
||||
)}
|
||||
{purchaseOrder.orderCostList?.filter(
|
||||
(costItem: CostItem) => costItem.costType === "HUMAN_COST",
|
||||
).length > 0 && (
|
||||
<>
|
||||
<View className="text-sm font-bold">用工信息</View>
|
||||
<View className="rounded-lg bg-white p-2.5 shadow-sm">
|
||||
<View className="flex flex-col gap-2.5">
|
||||
{purchaseOrder.orderCostList
|
||||
?.filter(
|
||||
(costItem: CostItem) => costItem.costType === "HUMAN_COST",
|
||||
)
|
||||
.map((costItem) => (
|
||||
<View
|
||||
className="flex items-center justify-between"
|
||||
key={costItem.orderCostId}
|
||||
>
|
||||
<View className="text-sm text-gray-600">
|
||||
{costItem.name}
|
||||
</View>
|
||||
<View className="flex flex-1 items-center justify-end gap-1">
|
||||
<View className="text-sm font-normal text-gray-400">
|
||||
{costItem.payerType === "US"
|
||||
? "我方承担费用"
|
||||
: costItem.payerType === "OTHER"
|
||||
? "瓜农承担费用"
|
||||
: "未指定"}
|
||||
</>
|
||||
)}
|
||||
{purchaseOrder.orderCostList?.filter(
|
||||
(costItem: CostItem) => costItem.costType === "HUMAN_COST",
|
||||
).length > 0 && (
|
||||
<>
|
||||
<View className="text-sm font-bold">用工信息</View>
|
||||
<View className="rounded-lg bg-white p-2.5 shadow-sm">
|
||||
<View className="flex flex-col gap-2.5">
|
||||
{purchaseOrder.orderCostList
|
||||
?.filter(
|
||||
(costItem: CostItem) => costItem.costType === "HUMAN_COST",
|
||||
)
|
||||
.map((costItem) => (
|
||||
<View
|
||||
className="flex items-center justify-between"
|
||||
key={costItem.orderCostId}
|
||||
>
|
||||
<View className="text-sm text-gray-600">
|
||||
{costItem.name}
|
||||
</View>
|
||||
{costItem.payerType === "US" && (
|
||||
<View className="flex flex-1 items-center justify-end gap-1">
|
||||
<View className="text-sm font-normal text-gray-400">
|
||||
工头:{costItem.principal}
|
||||
{costItem.payerType === "US"
|
||||
? "我方承担费用"
|
||||
: costItem.payerType === "OTHER"
|
||||
? "瓜农承担费用"
|
||||
: "未指定"}
|
||||
</View>
|
||||
{costItem.payerType === "US" && (
|
||||
<View className="text-sm font-normal text-gray-400">
|
||||
工头:{costItem.principal}
|
||||
</View>
|
||||
)}
|
||||
<View className="mr-2 text-sm font-medium">
|
||||
共 {costItem.count} {costItem.unit}
|
||||
</View>
|
||||
)}
|
||||
<View className="mr-2 text-sm font-medium">
|
||||
共 {costItem.count} {costItem.unit}
|
||||
</View>
|
||||
</View>
|
||||
))}
|
||||
<View className="flex items-center justify-between border-t pt-2.5">
|
||||
<View className="text-sm font-semibold">总人数</View>
|
||||
<View className="text-primary text-sm font-semibold">
|
||||
{purchaseOrder.orderCostList
|
||||
?.filter(
|
||||
(costItem: CostItem) =>
|
||||
costItem.costType === "HUMAN_COST",
|
||||
)
|
||||
.reduce(
|
||||
(sum, costItem) => sum + (costItem.count || 0),
|
||||
0,
|
||||
) || 0}{" "}
|
||||
人
|
||||
</View>
|
||||
))}
|
||||
<View className="flex items-center justify-between border-t pt-2.5">
|
||||
<View className="text-sm font-semibold">总人数</View>
|
||||
<View className="text-primary text-sm font-semibold">
|
||||
{purchaseOrder.orderCostList
|
||||
?.filter(
|
||||
(costItem: CostItem) =>
|
||||
costItem.costType === "HUMAN_COST",
|
||||
)
|
||||
.reduce(
|
||||
(sum, costItem) => sum + (costItem.count || 0),
|
||||
0,
|
||||
) || 0}{" "}
|
||||
人
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@ -17,22 +17,22 @@ export default function CostDifferenceSection(props: {
|
||||
|
||||
// 主状态,用于页面显示
|
||||
const [costDifference, setCostDifference] = useState<number>(
|
||||
purchaseOrderVO.orderDealer?.costDifference || 0,
|
||||
purchaseOrderVO.orderDealer.costDifference || 0,
|
||||
);
|
||||
|
||||
// 弹窗内的临时状态
|
||||
const [tempCostDifference, setTempCostDifference] = useState<number>(
|
||||
purchaseOrderVO.orderDealer?.costDifference || 0,
|
||||
purchaseOrderVO.orderDealer.costDifference || 0,
|
||||
);
|
||||
|
||||
const profitSharing =
|
||||
calculator.getDefaultNetProfit() ||
|
||||
purchaseOrderVO.orderDealer?.profitSharing ||
|
||||
purchaseOrderVO.orderDealer.profitSharing ||
|
||||
0;
|
||||
|
||||
// 当dealerVO变化时,自动计算分成
|
||||
useEffect(() => {
|
||||
if (!purchaseOrderVO.orderDealer?.costDifference) {
|
||||
if (!purchaseOrderVO.orderDealer.costDifference) {
|
||||
const defaultCostDifference = calculator.getCostDifference();
|
||||
setCostDifference(defaultCostDifference);
|
||||
setTempCostDifference(defaultCostDifference);
|
||||
@ -113,7 +113,7 @@ export default function CostDifferenceSection(props: {
|
||||
<Text className="text-sm text-gray-500">分成利润</Text>
|
||||
</View>
|
||||
<View className="flex items-center justify-between">
|
||||
<Text className="text-primary text-2xl font-bold text-nowrap">
|
||||
<Text className="text-primary text-2xl font-bold">
|
||||
¥ {profitSharing}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
@ -29,7 +29,9 @@ export default function (props: {
|
||||
}, [purchaseOrderVO]);
|
||||
|
||||
// 处理经销商选择完成事件
|
||||
const handleDealerSelect = (dealerVO: BusinessAPI.DealerVO) => {
|
||||
const handleDealerSelect = (
|
||||
dealerVO: BusinessAPI.DealerVO,
|
||||
) => {
|
||||
if (readOnly) return;
|
||||
|
||||
const newOrderDealer: BusinessAPI.OrderDealer = {
|
||||
@ -97,25 +99,25 @@ export default function (props: {
|
||||
</View>
|
||||
|
||||
{!readOnly && (
|
||||
<DealerPicker
|
||||
onFinish={(dealer) => {
|
||||
handleDealerSelect(dealer);
|
||||
}}
|
||||
trigger={
|
||||
<View
|
||||
className={"flex flex-1 flex-row items-center justify-center"}
|
||||
>
|
||||
<View className="flex justify-center">
|
||||
<DealerPicker
|
||||
onFinish={(dealer) => {
|
||||
handleDealerSelect(dealer);
|
||||
}}
|
||||
trigger={
|
||||
<Button size="small" type="primary" fill="outline">
|
||||
重新选择经销商
|
||||
</Button>
|
||||
</View>
|
||||
}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
) : readOnly ? (
|
||||
<View className="flex flex-col items-center justify-center rounded-lg border border-dashed border-gray-300 p-2.5">
|
||||
<View className="text-neutral-darker text-sm">无经销商信息</View>
|
||||
<View className="text-neutral-darker text-sm">
|
||||
无经销商信息
|
||||
</View>
|
||||
</View>
|
||||
) : (
|
||||
<View className="flex flex-col items-center justify-center rounded-lg border border-dashed border-gray-300 p-2.5">
|
||||
@ -145,4 +147,4 @@ export default function (props: {
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,671 +1,95 @@
|
||||
import { formatCurrency, validatePrice } from "@/utils/format";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Button, Input, Popup, SafeArea, Table } from "@nutui/nutui-react-taro";
|
||||
import { Icon } from "@/components";
|
||||
import { View } from "@tarojs/components";
|
||||
import { Table } from "@nutui/nutui-react-taro";
|
||||
import { formatCurrency } from "@/utils/format";
|
||||
|
||||
export default function EmptyBoxInfoSection(props: {
|
||||
export default function EmptyBoxInfoSection(_props: {
|
||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||
onChange?: (purchaseOrderVO: BusinessAPI.PurchaseOrderVO) => void;
|
||||
readOnly?: boolean;
|
||||
}) {
|
||||
const { purchaseOrderVO, onChange, readOnly } = props;
|
||||
// 将所有空箱信息合并并按品牌、型号、规格分组
|
||||
// const groupedEmptyBoxData = purchaseOrderVO.orderSupplierList?.reduce(
|
||||
// (acc, supplier) => {
|
||||
// supplier.orderPackageList?.forEach((pkg) => {
|
||||
// // 生成分组键
|
||||
// const key = `${pkg.boxBrandName}-${pkg.boxProductName}-${pkg.boxCategoryId}`;
|
||||
//
|
||||
// // 转换规格字段
|
||||
// const boxCategoryName =
|
||||
// pkg.boxCategoryId === "FOUR_GRADE"
|
||||
// ? "4粒"
|
||||
// : pkg.boxCategoryId === "TWO_GRADE"
|
||||
// ? "2粒"
|
||||
// : "其他";
|
||||
//
|
||||
// if (!acc[key]) {
|
||||
// acc[key] = {
|
||||
// boxBrandName: pkg.boxBrandName,
|
||||
// boxProductName: pkg.boxProductName,
|
||||
// boxCategoryName,
|
||||
// boxProductCount: 0,
|
||||
// boxProductPrice: pkg.boxSalePrice,
|
||||
// boxProductWeight: pkg.boxProductWeight,
|
||||
// boxProductCostPrice: pkg.boxCostPrice,
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// // 累加数量
|
||||
// acc[key].boxProductCount += pkg.boxCount || 0;
|
||||
// });
|
||||
//
|
||||
// return acc;
|
||||
// },
|
||||
// {} as Record<string, any>,
|
||||
// );
|
||||
//
|
||||
// // 转换为数组格式并计算销售金额
|
||||
// const emptyBoxData = Object.values(groupedEmptyBoxData || {}).map(item => ({
|
||||
// ...item,
|
||||
// boxProductPayment: (item.boxProductCount || 0) * (item.boxProductPrice || 0)
|
||||
// }));
|
||||
|
||||
const defaultColumns = [
|
||||
{
|
||||
title: "品牌",
|
||||
key: "boxBrandName",
|
||||
fixed: "left",
|
||||
},
|
||||
{
|
||||
title: "规格",
|
||||
key: "boxSpecName",
|
||||
},
|
||||
{
|
||||
title: "纸箱型号",
|
||||
key: "boxProductName",
|
||||
},
|
||||
{
|
||||
title: "个数",
|
||||
key: "boxProductCount",
|
||||
},
|
||||
{
|
||||
title: "销售单价(元/斤)",
|
||||
key: "boxSalePrice",
|
||||
render: (
|
||||
value: BusinessAPI.OrderPackage & {
|
||||
orderPackageId?: string;
|
||||
isTotalRow?: boolean;
|
||||
},
|
||||
) => {
|
||||
// 合计行不显示编辑按钮
|
||||
if (value.isTotalRow) {
|
||||
return formatCurrency(value.boxSalePrice as number);
|
||||
}
|
||||
|
||||
return (
|
||||
<View
|
||||
className="flex w-full items-center justify-between"
|
||||
onClick={(e) => {
|
||||
if (!readOnly) {
|
||||
e.stopPropagation();
|
||||
// 设置临时编辑值为当前值
|
||||
setTempEditValues((prev) => ({
|
||||
...prev,
|
||||
[value.orderPackageId || ""]:
|
||||
editValues[value.orderPackageId || ""],
|
||||
}));
|
||||
setVisiblePopup((prev) => ({
|
||||
...prev,
|
||||
[value.orderPackageId || ""]: true,
|
||||
}));
|
||||
}
|
||||
}}
|
||||
>
|
||||
<View className={!readOnly ? "cursor-pointer underline" : ""}>
|
||||
{formatCurrency(value.boxSalePrice as number)}
|
||||
</View>
|
||||
{!readOnly && (
|
||||
<View className="-m-2 ml-2 flex items-center justify-center p-2">
|
||||
<Icon name={"pen-to-square"} size={16} color={"#1a73e8"} />
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "销售金额(元)",
|
||||
key: "boxSalePayment",
|
||||
render: (
|
||||
value: BusinessAPI.OrderPackage & {
|
||||
boxProductCount: number;
|
||||
isTotalRow?: boolean;
|
||||
},
|
||||
) =>
|
||||
formatCurrency(
|
||||
Number((value?.boxSalePrice || 0) * value.boxProductCount) as number,
|
||||
),
|
||||
},
|
||||
{
|
||||
title: "箱重(斤)",
|
||||
key: "boxProductWeight",
|
||||
render: (
|
||||
value: BusinessAPI.OrderPackage & {
|
||||
orderPackageId?: string;
|
||||
isTotalRow?: boolean;
|
||||
},
|
||||
) => {
|
||||
// 合计行不显示编辑按钮
|
||||
if (value.isTotalRow) {
|
||||
return formatCurrency(value.boxProductWeight);
|
||||
}
|
||||
|
||||
return (
|
||||
<View
|
||||
className="flex w-full items-center justify-between"
|
||||
onClick={(e) => {
|
||||
if (!readOnly) {
|
||||
e.stopPropagation();
|
||||
// 设置临时编辑值为当前值
|
||||
setTempEditValues((prev) => ({
|
||||
...prev,
|
||||
[value.orderPackageId || ""]:
|
||||
editValues[value.orderPackageId || ""],
|
||||
}));
|
||||
setVisiblePopup((prev) => ({
|
||||
...prev,
|
||||
[value.orderPackageId || ""]: true,
|
||||
}));
|
||||
}
|
||||
}}
|
||||
>
|
||||
<View className={!readOnly ? "cursor-pointer underline" : ""}>
|
||||
{formatCurrency(value.boxProductWeight)}
|
||||
</View>
|
||||
{!readOnly && (
|
||||
<View className="-m-2 ml-2 flex items-center justify-center p-2">
|
||||
<Icon name={"pen-to-square"} size={16} color={"#1a73e8"} />
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "成本单价(元)",
|
||||
key: "boxCostPrice",
|
||||
render: (
|
||||
value: BusinessAPI.OrderPackage & {
|
||||
orderPackageId?: string;
|
||||
isTotalRow?: boolean;
|
||||
},
|
||||
) => {
|
||||
// 合计行不显示编辑按钮
|
||||
if (value.isTotalRow) {
|
||||
return formatCurrency(value.boxCostPrice as number);
|
||||
}
|
||||
|
||||
return (
|
||||
<View
|
||||
className="flex w-full items-center justify-between"
|
||||
onClick={(e) => {
|
||||
if (!readOnly) {
|
||||
e.stopPropagation();
|
||||
// 设置临时编辑值为当前值
|
||||
setTempEditValues((prev) => ({
|
||||
...prev,
|
||||
[value.orderPackageId || ""]:
|
||||
editValues[value.orderPackageId || ""],
|
||||
}));
|
||||
setVisiblePopup((prev) => ({
|
||||
...prev,
|
||||
[value.orderPackageId || ""]: true,
|
||||
}));
|
||||
}
|
||||
}}
|
||||
>
|
||||
<View className={!readOnly ? "cursor-pointer underline" : ""}>
|
||||
{formatCurrency(value.boxCostPrice as number)}
|
||||
</View>
|
||||
{!readOnly && (
|
||||
<View className="-m-2 ml-2 flex items-center justify-center p-2">
|
||||
<Icon name={"pen-to-square"} size={16} color={"#1a73e8"} />
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
const [columns, setColumns] = useState<any[]>(defaultColumns);
|
||||
|
||||
useEffect(() => {
|
||||
if (!readOnly) {
|
||||
setColumns([...defaultColumns]);
|
||||
}
|
||||
}, [readOnly]);
|
||||
|
||||
// 弹窗可见状态
|
||||
const [visiblePopup, setVisiblePopup] = useState<{ [key: string]: boolean }>(
|
||||
{},
|
||||
);
|
||||
|
||||
// 编辑值的状态
|
||||
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 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,
|
||||
};
|
||||
}
|
||||
|
||||
return updates;
|
||||
};
|
||||
|
||||
// 将所有包装信息合并并按品牌、型号、规格分组
|
||||
const groupedPackageData = purchaseOrderVO.orderPackageList?.reduce(
|
||||
(acc, orderPackage) => {
|
||||
// 生成分组键
|
||||
const key = `${orderPackage.boxBrandName}-${orderPackage.boxProductName}-${orderPackage.boxSpecId}`;
|
||||
|
||||
// 转换规格字段
|
||||
const boxSpecId = orderPackage.boxSpecId;
|
||||
const boxSpecName = orderPackage.boxSpecName;
|
||||
|
||||
if (!acc[key]) {
|
||||
acc[key] = {
|
||||
...orderPackage,
|
||||
boxSpecId,
|
||||
boxSpecName,
|
||||
boxProductCount: 0,
|
||||
};
|
||||
}
|
||||
|
||||
// 累加数量
|
||||
acc[key].boxProductCount += orderPackage.boxCount || 0;
|
||||
|
||||
return acc;
|
||||
},
|
||||
{} as Record<string, any>,
|
||||
);
|
||||
|
||||
// 转换为数组格式
|
||||
const packageData = Object.values(groupedPackageData || {});
|
||||
|
||||
// 计算合计数据
|
||||
const calculateTotals = () => {
|
||||
if (!packageData || packageData.length === 0) {
|
||||
return {};
|
||||
}
|
||||
|
||||
// 计算各项合计
|
||||
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: "合计",
|
||||
boxProductCount: totalBoxProductCount,
|
||||
boxSalePayment: totalBoxSalePayment,
|
||||
boxProductWeight: totalBoxProductWeight,
|
||||
boxCostPrice: totalBoxCostPayment,
|
||||
isTotalRow: true, // 标记这是合计行
|
||||
};
|
||||
};
|
||||
|
||||
const totalsData = calculateTotals();
|
||||
|
||||
// 初始化所有包装项的编辑值
|
||||
useEffect(() => {
|
||||
const newEditValues = { ...editValues };
|
||||
const newTempEditValues = { ...tempEditValues };
|
||||
let hasEditValuesChanged = false;
|
||||
let hasTempEditValuesChanged = false;
|
||||
|
||||
packageData.forEach((pkg: BusinessAPI.OrderPackage) => {
|
||||
const pkgId = pkg.orderPackageId || "";
|
||||
const updates = initEditValues(
|
||||
pkgId,
|
||||
pkg.boxCostPrice,
|
||||
pkg.boxSalePrice,
|
||||
pkg.boxProductWeight,
|
||||
);
|
||||
|
||||
if (updates.editValuesUpdate) {
|
||||
newEditValues[pkgId] = updates.editValuesUpdate;
|
||||
hasEditValuesChanged = true;
|
||||
}
|
||||
|
||||
if (updates.tempEditValuesUpdate) {
|
||||
newTempEditValues[pkgId] = updates.tempEditValuesUpdate;
|
||||
hasTempEditValuesChanged = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (hasEditValuesChanged) {
|
||||
setEditValues(newEditValues);
|
||||
}
|
||||
|
||||
if (hasTempEditValuesChanged) {
|
||||
setTempEditValues(newTempEditValues);
|
||||
}
|
||||
}, [packageData]);
|
||||
|
||||
// 当editValues发生变化时,更新purchaseOrderVO
|
||||
useEffect(() => {
|
||||
// 只有当onChange存在时才更新
|
||||
if (onChange) {
|
||||
// 创建新的purchaseOrderVO对象
|
||||
const newPurchaseOrderVO = { ...purchaseOrderVO };
|
||||
|
||||
// 更新供应商列表中的包装信息
|
||||
if (newPurchaseOrderVO.orderPackageList) {
|
||||
newPurchaseOrderVO.orderPackageList =
|
||||
newPurchaseOrderVO.orderPackageList.map((pkg) => {
|
||||
const editValue = editValues[pkg.orderPackageId || ""];
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
||||
// 调用onChange回调
|
||||
onChange(newPurchaseOrderVO);
|
||||
}
|
||||
}, [editValues]);
|
||||
|
||||
// 自定义合计行渲染
|
||||
const renderTableWithTotals = () => {
|
||||
// 创建包含合计行的数据
|
||||
const dataWithTotals = [...packageData];
|
||||
if (Object.keys(totalsData).length > 0) {
|
||||
dataWithTotals.push(totalsData);
|
||||
}
|
||||
|
||||
// 自定义列配置,对合计行特殊处理
|
||||
const columnsWithTotalsRender = columns.map((column) => {
|
||||
if (column.key === "boxBrandName") {
|
||||
// 品牌列显示"合计"
|
||||
return {
|
||||
...column,
|
||||
render: (rowData: any) => {
|
||||
if (rowData.isTotalRow) {
|
||||
return (
|
||||
<span style={{ fontWeight: "bold" }}>
|
||||
{rowData.boxBrandName}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
return rowData.boxBrandName;
|
||||
},
|
||||
};
|
||||
} else if (column.key === "boxProductCount") {
|
||||
// 个数列显示合计
|
||||
return {
|
||||
...column,
|
||||
render: (rowData: any) => {
|
||||
if (rowData.isTotalRow) {
|
||||
return (
|
||||
<span style={{ fontWeight: "bold" }}>
|
||||
{rowData.boxProductCount}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
return rowData.boxProductCount;
|
||||
},
|
||||
};
|
||||
} else if (column.key === "boxSalePrice") {
|
||||
// 销售单价列合计行处理
|
||||
return {
|
||||
...column,
|
||||
render: (rowData: any) => {
|
||||
if (rowData.isTotalRow) {
|
||||
return (
|
||||
<span style={{ fontWeight: "bold" }}>
|
||||
{formatCurrency(rowData.boxSalePrice as number)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
return column.render(rowData, rowData);
|
||||
},
|
||||
};
|
||||
} else if (column.key === "boxSalePayment") {
|
||||
// 销售金额列显示合计
|
||||
return {
|
||||
...column,
|
||||
render: (rowData: any) => {
|
||||
if (rowData.isTotalRow) {
|
||||
return (
|
||||
<span style={{ fontWeight: "bold" }}>
|
||||
{formatCurrency(rowData.boxSalePayment)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
return formatCurrency(
|
||||
Number(
|
||||
(rowData?.boxSalePrice || 0) * rowData.boxProductCount,
|
||||
) as number,
|
||||
);
|
||||
},
|
||||
};
|
||||
} else if (column.key === "boxProductWeight") {
|
||||
// 重量列合计行处理
|
||||
return {
|
||||
...column,
|
||||
render: (rowData: any) => {
|
||||
if (rowData.isTotalRow) {
|
||||
return (
|
||||
<span style={{ fontWeight: "bold" }}>
|
||||
{formatCurrency(rowData.boxProductWeight)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
return column.render(rowData, rowData);
|
||||
},
|
||||
};
|
||||
} else if (column.key === "boxCostPrice") {
|
||||
// 成本单价列合计行处理
|
||||
return {
|
||||
...column,
|
||||
render: (rowData: any) => {
|
||||
if (rowData.isTotalRow) {
|
||||
return (
|
||||
<span style={{ fontWeight: "bold" }}>
|
||||
{formatCurrency(rowData.boxCostPrice as number)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
return column.render(rowData, rowData);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// 其他列保持原有render函数或者默认显示
|
||||
return column;
|
||||
});
|
||||
|
||||
return (
|
||||
<Table
|
||||
className={"table-sum"}
|
||||
columns={columnsWithTotalsRender}
|
||||
data={dataWithTotals}
|
||||
striped
|
||||
/>
|
||||
);
|
||||
};
|
||||
const emptyBoxData = [];
|
||||
|
||||
return (
|
||||
<>
|
||||
{renderTableWithTotals()}
|
||||
|
||||
{/* 纸箱价格编辑弹窗 */}
|
||||
{packageData.map((pkg: BusinessAPI.OrderPackage) => (
|
||||
<Popup
|
||||
key={pkg.orderPackageId}
|
||||
visible={visiblePopup[pkg.orderPackageId || ""]}
|
||||
position="bottom"
|
||||
title="编辑纸箱信息"
|
||||
onClose={() =>
|
||||
setVisiblePopup((prev) => ({
|
||||
...prev,
|
||||
[pkg.orderPackageId || ""]: false,
|
||||
}))
|
||||
}
|
||||
onOverlayClick={() =>
|
||||
setVisiblePopup((prev) => ({
|
||||
...prev,
|
||||
[pkg.orderPackageId || ""]: false,
|
||||
}))
|
||||
}
|
||||
lockScroll
|
||||
>
|
||||
<View className="flex flex-col gap-3 p-2.5">
|
||||
<View className="text-neutral-darkest text-sm font-medium">
|
||||
销售单价
|
||||
</View>
|
||||
<View className="border-neutral-base flex flex-row items-center rounded-md border border-solid">
|
||||
<Input
|
||||
className="placeholder:text-neutral-dark"
|
||||
placeholder="请输入销售单价"
|
||||
type="digit"
|
||||
value={
|
||||
tempEditValues[
|
||||
pkg.orderPackageId || ""
|
||||
]?.boxSalePrice?.toString() || ""
|
||||
}
|
||||
onChange={(value) => {
|
||||
const numValue = validatePrice(value);
|
||||
if (numValue !== undefined) {
|
||||
setTempEditValues((prev) => ({
|
||||
...prev,
|
||||
[pkg.orderPackageId || ""]: {
|
||||
...prev[pkg.orderPackageId || ""],
|
||||
boxSalePrice: numValue as number,
|
||||
},
|
||||
}));
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<View className="mr-2">元</View>
|
||||
</View>
|
||||
|
||||
<View className="text-neutral-darkest text-sm font-medium">
|
||||
成本单价
|
||||
</View>
|
||||
<View className="border-neutral-base flex flex-row items-center rounded-md border border-solid">
|
||||
<Input
|
||||
className="placeholder:text-neutral-dark"
|
||||
placeholder="请输入成本单价"
|
||||
type="digit"
|
||||
value={
|
||||
tempEditValues[
|
||||
pkg.orderPackageId || ""
|
||||
]?.boxCostPrice?.toString() || ""
|
||||
}
|
||||
onChange={(value) => {
|
||||
const numValue = validatePrice(value);
|
||||
if (numValue !== undefined) {
|
||||
setTempEditValues((prev) => ({
|
||||
...prev,
|
||||
[pkg.orderPackageId || ""]: {
|
||||
...prev[pkg.orderPackageId || ""],
|
||||
boxCostPrice: numValue as number,
|
||||
},
|
||||
}));
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<View className="mr-2">元</View>
|
||||
</View>
|
||||
|
||||
<View className="text-neutral-darkest text-sm font-medium">
|
||||
箱重
|
||||
</View>
|
||||
<View className="border-neutral-base flex flex-row items-center rounded-md border border-solid">
|
||||
<Input
|
||||
className="placeholder:text-neutral-dark"
|
||||
placeholder="请输入箱重"
|
||||
type="digit"
|
||||
value={
|
||||
tempEditValues[
|
||||
pkg.orderPackageId || ""
|
||||
]?.boxProductWeight?.toString() || ""
|
||||
}
|
||||
onChange={(value) => {
|
||||
const numValue = validatePrice(value);
|
||||
if (numValue !== undefined) {
|
||||
setTempEditValues((prev) => ({
|
||||
...prev,
|
||||
[pkg.orderPackageId || ""]: {
|
||||
...prev[pkg.orderPackageId || ""],
|
||||
boxProductWeight: numValue as number,
|
||||
},
|
||||
}));
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<View className="mr-2">斤</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className="flex w-full flex-col bg-white">
|
||||
<View className="flex flex-row gap-2 p-3">
|
||||
<View className="flex-1">
|
||||
<Button
|
||||
size="large"
|
||||
block
|
||||
type="default"
|
||||
onClick={() =>
|
||||
setVisiblePopup((prev) => ({
|
||||
...prev,
|
||||
[pkg.orderPackageId || ""]: false,
|
||||
}))
|
||||
}
|
||||
>
|
||||
取消
|
||||
</Button>
|
||||
</View>
|
||||
<View className="flex-1">
|
||||
<Button
|
||||
size="large"
|
||||
block
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
// 保存时才更新editValues状态
|
||||
setEditValues((prev) => ({
|
||||
...prev,
|
||||
[pkg.orderPackageId || ""]: {
|
||||
...tempEditValues[pkg.orderPackageId || ""],
|
||||
},
|
||||
}));
|
||||
|
||||
// 关闭弹窗
|
||||
setVisiblePopup((prev) => ({
|
||||
...prev,
|
||||
[pkg.orderPackageId || ""]: false,
|
||||
}));
|
||||
}}
|
||||
>
|
||||
保存
|
||||
</Button>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
<SafeArea position="bottom" />
|
||||
</Popup>
|
||||
))}
|
||||
</>
|
||||
<Table
|
||||
columns={[
|
||||
{
|
||||
title: "品牌",
|
||||
key: "boxBrandName",
|
||||
fixed: "left",
|
||||
},
|
||||
{
|
||||
title: "规格",
|
||||
key: "boxCategoryName",
|
||||
},
|
||||
{
|
||||
title: "纸箱型号",
|
||||
key: "boxProductName",
|
||||
},
|
||||
{
|
||||
title: "个数",
|
||||
key: "boxProductCount",
|
||||
},
|
||||
{
|
||||
title: "销售单价(元/斤)",
|
||||
key: "boxProductPrice",
|
||||
render: (value: any) => formatCurrency(value.boxProductPrice),
|
||||
},
|
||||
{
|
||||
title: "销售金额(元)",
|
||||
key: "boxProductPayment",
|
||||
render: (value: any) => formatCurrency(value.boxProductPayment),
|
||||
},
|
||||
{
|
||||
title: "箱重(斤)",
|
||||
key: "boxProductWeight",
|
||||
},
|
||||
{
|
||||
title: "成本单价(元/斤)",
|
||||
key: "boxProductCostPrice",
|
||||
render: (value: any) => formatCurrency(value.boxProductCostPrice),
|
||||
},
|
||||
]}
|
||||
data={emptyBoxData || []}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@ -8,16 +8,16 @@ import {
|
||||
} from "@nutui/nutui-react-taro";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Icon } from "@/components";
|
||||
import { business } from "@/services";
|
||||
import { formatCurrency, validatePrice } from "@/utils/format";
|
||||
import { generateShortId } from "@/utils/generateShortId";
|
||||
|
||||
export default function LaborInfoSection(props: {
|
||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||
costItemVOList: BusinessAPI.CostItemVO[];
|
||||
onChange?: (purchaseOrderVO: BusinessAPI.PurchaseOrderVO) => void;
|
||||
readOnly?: boolean;
|
||||
}) {
|
||||
const { purchaseOrderVO, onChange, readOnly, costItemVOList } = props;
|
||||
const { purchaseOrderVO, onChange, readOnly } = props;
|
||||
|
||||
// 弹窗相关状态
|
||||
const [visiblePopup, setVisiblePopup] = useState<{ [key: string]: boolean }>(
|
||||
@ -41,12 +41,17 @@ export default function LaborInfoSection(props: {
|
||||
requireQuantityAndPrice: false,
|
||||
});
|
||||
|
||||
console.log("newCostData", newCostData);
|
||||
|
||||
// Picker可见状态
|
||||
const [pickerVisible, setPickerVisible] = useState({
|
||||
costType: false, // 费用类型Picker
|
||||
costItem: false, // 费用项目Picker
|
||||
});
|
||||
|
||||
// 费用项目列表
|
||||
const [costItems, setCostItems] = useState<BusinessAPI.CostItemVO[]>([]);
|
||||
|
||||
// 编辑值的状态
|
||||
const [editValues, setEditValues] = useState<{
|
||||
[key: string]: {
|
||||
@ -103,6 +108,25 @@ export default function LaborInfoSection(props: {
|
||||
},
|
||||
];
|
||||
|
||||
// 获取费用项目列表
|
||||
useEffect(() => {
|
||||
const fetchCostItems = async () => {
|
||||
try {
|
||||
const { data } = await business.costItem.listCostItem({
|
||||
costItemListQry: {
|
||||
status: true,
|
||||
showInEntry: true,
|
||||
},
|
||||
});
|
||||
setCostItems(data.data || []);
|
||||
} catch (error) {
|
||||
console.error("获取费用项目列表失败:", error);
|
||||
}
|
||||
};
|
||||
|
||||
fetchCostItems();
|
||||
}, []);
|
||||
|
||||
// 人工费
|
||||
const humanCosts =
|
||||
purchaseOrderVO.orderCostList?.filter(
|
||||
@ -344,30 +368,28 @@ export default function LaborInfoSection(props: {
|
||||
<View className="text-neutral-darkest text-sm font-medium">
|
||||
垫付项目
|
||||
</View>
|
||||
<View className="border-neutral-base relative flex h-10 w-full items-center rounded-md border border-solid">
|
||||
<View
|
||||
className={
|
||||
"flex flex-1 flex-row items-center justify-between px-5"
|
||||
}
|
||||
style={{
|
||||
color: "var(--nutui-color-title, #1a1a1a)",
|
||||
}}
|
||||
onClick={(event) => {
|
||||
setPickerVisible((prev) => ({ ...prev, costItem: true }));
|
||||
event.stopPropagation();
|
||||
}}
|
||||
>
|
||||
<View className={"text-sm"}>
|
||||
{newCostData.name || "请选择垫付项目"}
|
||||
</View>
|
||||
<Icon name={"chevron-down"} />
|
||||
</View>
|
||||
<View
|
||||
className="border-neutral-base relative flex h-10 w-full items-center rounded-md border border-solid"
|
||||
onClick={() =>
|
||||
setPickerVisible((prev) => ({ ...prev, costItem: true }))
|
||||
}
|
||||
>
|
||||
<Input
|
||||
type="text"
|
||||
placeholder="请选择垫付项目"
|
||||
value={newCostData.name || ""}
|
||||
disabled
|
||||
/>
|
||||
<Icon
|
||||
name="chevron-down"
|
||||
className="absolute -right-1 mr-4"
|
||||
/>
|
||||
</View>
|
||||
<Picker
|
||||
title="请选择垫付项目"
|
||||
visible={pickerVisible.costItem}
|
||||
options={[
|
||||
costItemVOList
|
||||
costItems
|
||||
.filter((item) => item.costType === newCostData.costType)
|
||||
.filter((item) => {
|
||||
if (newCostData.costType === "PRODUCTION_ADVANCE") {
|
||||
@ -388,7 +410,7 @@ export default function LaborInfoSection(props: {
|
||||
]}
|
||||
onConfirm={(_, values) => {
|
||||
const selectedValue = values[0] as string;
|
||||
const selectedItem = costItemVOList.find(
|
||||
const selectedItem = costItems.find(
|
||||
(item) => item.itemId === selectedValue,
|
||||
);
|
||||
if (selectedItem) {
|
||||
@ -629,9 +651,7 @@ export default function LaborInfoSection(props: {
|
||||
{/* 产地垫付 */}
|
||||
{productionAdvanceCosts.map((item) => {
|
||||
// 获取费用项目的 requireQuantityAndPrice 属性
|
||||
const costItem = costItemVOList.find(
|
||||
(cost) => cost.itemId === item.itemId,
|
||||
);
|
||||
const costItem = costItems.find((cost) => cost.itemId === item.itemId);
|
||||
const requireQuantityAndPrice =
|
||||
costItem?.requireQuantityAndPrice ?? false;
|
||||
|
||||
@ -842,9 +862,7 @@ export default function LaborInfoSection(props: {
|
||||
{/* 工头垫付 */}
|
||||
{workerAdvanceCosts.map((item) => {
|
||||
// 获取费用项目的 requireQuantityAndPrice 属性
|
||||
const costItem = costItemVOList.find(
|
||||
(cost) => cost.itemId === item.itemId,
|
||||
);
|
||||
const costItem = costItems.find((cost) => cost.itemId === item.itemId);
|
||||
const requireQuantityAndPrice =
|
||||
costItem?.requireQuantityAndPrice ?? false;
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Text, View } from "@tarojs/components";
|
||||
import { Button, Input, Popup, Radio, SafeArea } from "@nutui/nutui-react-taro";
|
||||
import { validatePrice } from "@/utils/format";
|
||||
import { formatCurrency, validatePrice } from "@/utils/format";
|
||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
||||
|
||||
export default function MarketPriceSection(props: {
|
||||
@ -134,6 +134,7 @@ export default function MarketPriceSection(props: {
|
||||
const saleAmount = calculator.getSalesAmount();
|
||||
|
||||
const totalAmount = calculator.getTotalAmount();
|
||||
console.log("totalAmount", totalAmount)
|
||||
// 计算平均单价(所有供应商单价的平均值)
|
||||
const averagePurchasePrice = calculator.getAveragePurchasePrice();
|
||||
|
||||
@ -271,7 +272,7 @@ export default function MarketPriceSection(props: {
|
||||
销售金额
|
||||
</View>
|
||||
<View className="text-neutral-darkest text-sm font-medium">
|
||||
{pricingMethod ? `${saleAmount} 元` : "-"}
|
||||
{pricingMethod ? `${formatCurrency(saleAmount)} 元` : "-"}
|
||||
</View>
|
||||
</View>
|
||||
<View className="flex !h-8 flex-row items-center justify-between">
|
||||
@ -279,19 +280,17 @@ export default function MarketPriceSection(props: {
|
||||
平均单价
|
||||
</View>
|
||||
<View className="text-neutral-darkest text-sm font-medium">
|
||||
{pricingMethod ? `${averagePurchasePrice} 元/斤` : "-"}
|
||||
{pricingMethod
|
||||
? `${formatCurrency(averagePurchasePrice)} 元/斤`
|
||||
: "-"}
|
||||
</View>
|
||||
</View>
|
||||
<View className="flex !h-8 flex-row items-center justify-between bg-yellow-200">
|
||||
<View className="text-neutral-dark flex-shrink-0 text-sm">
|
||||
市场报价(
|
||||
{purchaseOrderVO.orderDealer?.includePackingFlag
|
||||
? "销售金额 + 包装费"
|
||||
: "销售金额"}
|
||||
)
|
||||
市场报价( 销售金额 + 包装费)
|
||||
</View>
|
||||
<View className="text-neutral-darkest text-sm font-medium">
|
||||
{pricingMethod ? `${totalAmount} 元` : "-"}
|
||||
{pricingMethod ? `${formatCurrency(totalAmount)} 元` : "-"}
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@ -328,11 +327,14 @@ export default function MarketPriceSection(props: {
|
||||
value={
|
||||
tempEditValues[
|
||||
supplier.orderSupplierId || ""
|
||||
]?.salePrice?.toString() || ""
|
||||
]?.salePrice?.toString() ||
|
||||
editValues[
|
||||
supplier.orderSupplierId || ""
|
||||
]?.salePrice?.toString() ||
|
||||
""
|
||||
}
|
||||
onChange={(value) => {
|
||||
const numValue = validatePrice(value);
|
||||
console.log("num", numValue);
|
||||
if (numValue !== undefined) {
|
||||
setTempEditValues((prev) => ({
|
||||
...prev,
|
||||
|
||||
@ -9,15 +9,15 @@ import {
|
||||
import { useEffect, useState } from "react";
|
||||
import { validatePrice } from "@/utils/format";
|
||||
import { generateShortId } from "@/utils/generateShortId";
|
||||
import { business } from "@/services";
|
||||
import { Icon } from "@/components";
|
||||
|
||||
export default function MaterialCostSection(props: {
|
||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||
costItemVOList: BusinessAPI.CostItemVO[];
|
||||
onChange?: (purchaseOrderVO: BusinessAPI.PurchaseOrderVO) => void;
|
||||
readOnly?: boolean;
|
||||
}) {
|
||||
const { purchaseOrderVO, onChange, readOnly, costItemVOList } = props;
|
||||
const { purchaseOrderVO, onChange, readOnly } = props;
|
||||
|
||||
// 弹窗相关状态
|
||||
const [visiblePopup, setVisiblePopup] = useState<{ [key: string]: boolean }>(
|
||||
@ -43,6 +43,9 @@ export default function MaterialCostSection(props: {
|
||||
costItem: false, // 费用项目Picker
|
||||
});
|
||||
|
||||
// 费用项目列表
|
||||
const [costItems, setCostItems] = useState<BusinessAPI.CostItemVO[]>([]);
|
||||
|
||||
// 编辑值的状态
|
||||
const [editValues, setEditValues] = useState<{
|
||||
[key: string]: {
|
||||
@ -109,6 +112,26 @@ export default function MaterialCostSection(props: {
|
||||
return updates;
|
||||
};
|
||||
|
||||
// 获取费用项目列表
|
||||
useEffect(() => {
|
||||
const fetchCostItems = async () => {
|
||||
try {
|
||||
const { data } = await business.costItem.listCostItem({
|
||||
costItemListQry: {
|
||||
status: true,
|
||||
showInEntry: true,
|
||||
costType: "PACKAGING_MATERIALS", // 只获取辅料费用项目
|
||||
},
|
||||
});
|
||||
setCostItems(data.data || []);
|
||||
} catch (error) {
|
||||
console.error("获取费用项目列表失败:", error);
|
||||
}
|
||||
};
|
||||
|
||||
fetchCostItems();
|
||||
}, []);
|
||||
|
||||
// 辅料费(商标费和网套费)
|
||||
const packagingMaterials =
|
||||
purchaseOrderVO.orderCostList?.filter(
|
||||
@ -323,31 +346,25 @@ export default function MaterialCostSection(props: {
|
||||
<View className="text-neutral-darkest text-sm font-medium">
|
||||
辅料项目
|
||||
</View>
|
||||
<View className="border-neutral-base relative flex h-10 w-full items-center rounded-md border border-solid">
|
||||
<View
|
||||
className={
|
||||
"flex flex-1 flex-row items-center justify-between px-5"
|
||||
}
|
||||
style={{
|
||||
color: "var(--nutui-color-title, #1a1a1a)",
|
||||
}}
|
||||
onClick={(event) => {
|
||||
setPickerVisible((prev) => ({ ...prev, costItem: true }));
|
||||
event.stopPropagation();
|
||||
}}
|
||||
>
|
||||
<View className={"text-sm"}>
|
||||
{newCostData.name || "请选择辅料项目"}
|
||||
</View>
|
||||
<Icon name={"chevron-down"} />
|
||||
</View>
|
||||
<View
|
||||
className="border-neutral-base relative flex h-10 w-full items-center rounded-md border border-solid"
|
||||
onClick={() =>
|
||||
setPickerVisible((prev) => ({ ...prev, costItem: true }))
|
||||
}
|
||||
>
|
||||
<Input
|
||||
type="text"
|
||||
placeholder="请选择辅料项目"
|
||||
value={newCostData.name || ""}
|
||||
disabled
|
||||
/>
|
||||
<Icon name="chevron-down" className="absolute -right-1 mr-4" />
|
||||
</View>
|
||||
<Picker
|
||||
title="请选择辅料项目"
|
||||
visible={pickerVisible.costItem}
|
||||
options={[
|
||||
costItemVOList
|
||||
.filter((item) => item.costType === "PACKAGING_MATERIALS")
|
||||
costItems
|
||||
.filter((item) => {
|
||||
// 检查该项目是否已经被选择
|
||||
return !packagingMaterials.some(
|
||||
@ -361,7 +378,7 @@ export default function MaterialCostSection(props: {
|
||||
]}
|
||||
onConfirm={(_, values) => {
|
||||
const selectedValue = values[0] as string;
|
||||
const selectedItem = costItemVOList.find(
|
||||
const selectedItem = costItems.find(
|
||||
(item) => item.itemId === selectedValue,
|
||||
);
|
||||
if (selectedItem) {
|
||||
@ -591,9 +608,7 @@ export default function MaterialCostSection(props: {
|
||||
{/* 辅料费编辑弹窗 */}
|
||||
{packagingMaterials.map((item) => {
|
||||
// 获取费用项目的 requireQuantityAndPrice 属性
|
||||
const costItem = costItemVOList.find(
|
||||
(cost) => cost.itemId === item.itemId,
|
||||
);
|
||||
const costItem = costItems.find((cost) => cost.itemId === item.itemId);
|
||||
const requireQuantityAndPrice =
|
||||
costItem?.requireQuantityAndPrice ?? false;
|
||||
|
||||
|
||||
@ -13,11 +13,10 @@ import { generateShortId } from "@/utils/generateShortId";
|
||||
|
||||
export default function PackagingCostSection(props: {
|
||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||
costItemVOList: BusinessAPI.CostItemVO[];
|
||||
onChange?: (purchaseOrderVO: BusinessAPI.PurchaseOrderVO) => void;
|
||||
readOnly?: boolean;
|
||||
}) {
|
||||
const { purchaseOrderVO, onChange, readOnly, costItemVOList } = props;
|
||||
const { purchaseOrderVO, onChange, readOnly } = props;
|
||||
|
||||
// 弹窗相关状态
|
||||
const [visiblePopup, setVisiblePopup] = useState<{ [key: string]: boolean }>(
|
||||
@ -29,16 +28,15 @@ export default function PackagingCostSection(props: {
|
||||
|
||||
// 新增包装费表单数据
|
||||
const [newCostData, setNewCostData] = useState({
|
||||
costType: "FIXED_COST", // 费用类型
|
||||
costType: "", // 费用类型
|
||||
itemId: "", // 费用项目ID
|
||||
name: "", // 费用名称
|
||||
quantity: 0, // 数量(人数)
|
||||
unit: "", // 单位
|
||||
payee: "", // 收款人
|
||||
quantity: "", // 数量(包数或人数)
|
||||
unitPrice: "", // 单价
|
||||
amount: "", // 金额
|
||||
payerType: "US", // 费用承担方,默认我方
|
||||
amount: "", // 金额(固定费用和其他费用使用)
|
||||
payerType: "", // 费用承担方,默认我方
|
||||
principal: "", // 工头姓名
|
||||
requireQuantityAndPrice: false,
|
||||
});
|
||||
|
||||
// Picker可见状态
|
||||
@ -101,6 +99,13 @@ export default function PackagingCostSection(props: {
|
||||
{ label: "其他费用", value: "OTHER_COST" },
|
||||
];
|
||||
|
||||
// 固定费用选项
|
||||
const fixedCostOptions = [
|
||||
{ label: "计提费", value: "accrual" },
|
||||
{ label: "王超费用", value: "wangchao" },
|
||||
{ label: "收代办费", value: "agency" },
|
||||
];
|
||||
|
||||
// 固定费用
|
||||
const fixedCosts =
|
||||
purchaseOrderVO.orderCostList?.filter(
|
||||
@ -117,16 +122,12 @@ export default function PackagingCostSection(props: {
|
||||
useEffect(() => {
|
||||
if (onChange) {
|
||||
// 检查是否已存在计提费
|
||||
const accrualFeeItem = costItemVOList.find(
|
||||
(item) => item.name === "计提费" && item.costType === "FIXED_COST",
|
||||
);
|
||||
|
||||
const hasAccrualFee = fixedCosts.some((item) => item.name === "计提费");
|
||||
|
||||
if (!hasAccrualFee && accrualFeeItem) {
|
||||
if (!hasAccrualFee) {
|
||||
// 创建默认计提费
|
||||
const defaultAccrualFee: BusinessAPI.OrderCost = {
|
||||
itemId: accrualFeeItem.itemId,
|
||||
itemId: generateShortId(),
|
||||
orderCostId: generateShortId(),
|
||||
name: "计提费",
|
||||
costType: "FIXED_COST",
|
||||
@ -206,46 +207,40 @@ export default function PackagingCostSection(props: {
|
||||
<>
|
||||
<View className="flex flex-col gap-2.5">
|
||||
{/* 固定费用 */}
|
||||
{fixedCosts
|
||||
.filter((item) => item.name !== "纸箱费" && item.name !== "空箱费")
|
||||
.map((item, index) => {
|
||||
// 初始化编辑值
|
||||
initEditValues(item.orderCostId, item.count, item.price);
|
||||
{fixedCosts.map((item, index) => {
|
||||
// 初始化编辑值
|
||||
initEditValues(item.orderCostId, item.count, item.price);
|
||||
|
||||
return (
|
||||
<View
|
||||
className="flex items-center justify-between gap-2.5"
|
||||
key={item.orderCostId}
|
||||
onClick={() =>
|
||||
setVisiblePopup((prev) => ({
|
||||
...prev,
|
||||
[item.orderCostId]: true,
|
||||
}))
|
||||
}
|
||||
>
|
||||
<View className="text-neutral-dark flex-shrink-0 text-sm">
|
||||
{index + 1}-{item.name}
|
||||
</View>
|
||||
<View className="text-neutral-darkest flex flex-row items-center justify-between gap-2.5 text-sm font-medium">
|
||||
{formatCurrency(
|
||||
Number(
|
||||
(editValues[item.orderCostId]?.price || item.price) *
|
||||
(editValues[item.orderCostId]?.count || item.count),
|
||||
),
|
||||
)}
|
||||
{!readOnly && (
|
||||
<View className="ml-1 text-gray-500">
|
||||
<Icon
|
||||
name={"pen-to-square"}
|
||||
size={16}
|
||||
color={"#1a73e8"}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
return (
|
||||
<View
|
||||
className="flex items-center justify-between gap-2.5"
|
||||
key={item.orderCostId}
|
||||
onClick={() =>
|
||||
setVisiblePopup((prev) => ({
|
||||
...prev,
|
||||
[item.orderCostId]: true,
|
||||
}))
|
||||
}
|
||||
>
|
||||
<View className="text-neutral-dark flex-shrink-0 text-sm">
|
||||
{index + 1}-{item.name}
|
||||
</View>
|
||||
);
|
||||
})}
|
||||
<View className="text-neutral-darkest flex flex-row items-center justify-between gap-2.5 text-sm font-medium">
|
||||
{formatCurrency(
|
||||
Number(
|
||||
(editValues[item.orderCostId]?.price || item.price) *
|
||||
(editValues[item.orderCostId]?.count || item.count),
|
||||
),
|
||||
)}
|
||||
{!readOnly && (
|
||||
<View className="ml-1 text-gray-500">
|
||||
<Icon name={"pen-to-square"} size={16} color={"#1a73e8"} />
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
})}
|
||||
|
||||
{/* 其他费用 */}
|
||||
{otherCosts.map((item, index) => {
|
||||
@ -331,12 +326,11 @@ export default function PackagingCostSection(props: {
|
||||
...prev,
|
||||
costType: option.value,
|
||||
itemId: "",
|
||||
name: "", // 费用名称
|
||||
quantity: 0, // 数量
|
||||
unit: "", // 单位
|
||||
unitPrice: "", // 单价
|
||||
amount: "", // 金额
|
||||
requireQuantityAndPrice: false,
|
||||
name: "",
|
||||
payee: "",
|
||||
quantity: "",
|
||||
unitPrice: "",
|
||||
amount: "",
|
||||
}));
|
||||
}}
|
||||
>
|
||||
@ -357,62 +351,37 @@ export default function PackagingCostSection(props: {
|
||||
setPickerVisible((prev) => ({ ...prev, fixedCost: true }))
|
||||
}
|
||||
>
|
||||
<View
|
||||
className={
|
||||
"flex flex-1 flex-row items-center justify-between px-5"
|
||||
}
|
||||
style={{
|
||||
color: "var(--nutui-color-title, #1a1a1a)",
|
||||
}}
|
||||
onClick={(event) => {
|
||||
setPickerVisible((prev) => ({ ...prev, costItem: true }));
|
||||
event.stopPropagation();
|
||||
}}
|
||||
>
|
||||
<View className={"text-sm"}>
|
||||
{newCostData.name || "请选择固定费用类型"}
|
||||
</View>
|
||||
<Icon name={"chevron-down"} />
|
||||
</View>
|
||||
<Input
|
||||
type="text"
|
||||
placeholder="请选择固定费用类型"
|
||||
value={newCostData.name || ""}
|
||||
disabled
|
||||
/>
|
||||
<Icon
|
||||
name="chevron-down"
|
||||
className="absolute -right-1 mr-4"
|
||||
/>
|
||||
</View>
|
||||
|
||||
<Picker
|
||||
title="请选择垫付项目"
|
||||
title="请选择固定费用类型"
|
||||
visible={pickerVisible.fixedCost}
|
||||
options={[
|
||||
costItemVOList
|
||||
.filter((item) => item.costType === newCostData.costType)
|
||||
.filter((item) => {
|
||||
// 检查该项目是否已经被选择
|
||||
return !fixedCosts.some(
|
||||
(hc) => hc.itemId === item.itemId,
|
||||
);
|
||||
})
|
||||
.map((item) => ({
|
||||
label: item.name,
|
||||
value: item.itemId,
|
||||
})),
|
||||
fixedCostOptions.filter((option) => {
|
||||
// 检查该固定费用类型是否已存在于fixedCosts中
|
||||
return !fixedCosts.some(
|
||||
(cost) => cost.name === option.label,
|
||||
);
|
||||
}),
|
||||
]}
|
||||
onConfirm={(_, values) => {
|
||||
const selectedValue = values[0] as string;
|
||||
const selectedItem = costItemVOList.find(
|
||||
(item) => item.itemId === selectedValue,
|
||||
const selectedItem = fixedCostOptions.find(
|
||||
(option) => option.value === selectedValue,
|
||||
);
|
||||
if (selectedItem) {
|
||||
setNewCostData((prev) => ({
|
||||
...prev,
|
||||
itemId: selectedValue,
|
||||
name: selectedItem.name,
|
||||
payerType: "US",
|
||||
quantity: selectedItem.requireQuantityAndPrice ? 0 : 1,
|
||||
unit: selectedItem.requireQuantityAndPrice
|
||||
? selectedItem.unit
|
||||
: "元", // 单位
|
||||
unitPrice: "", // 单价
|
||||
amount: "", // 金额
|
||||
principal: "", // 工头姓名
|
||||
requireQuantityAndPrice:
|
||||
selectedItem.requireQuantityAndPrice,
|
||||
name: selectedItem.label,
|
||||
}));
|
||||
}
|
||||
setPickerVisible((prev) => ({ ...prev, fixedCost: false }));
|
||||
@ -454,7 +423,7 @@ export default function PackagingCostSection(props: {
|
||||
<Input
|
||||
className="placeholder:text-neutral-dark flex-1"
|
||||
placeholder="请输入收款人姓名"
|
||||
value={newCostData.principal}
|
||||
value={newCostData.payee}
|
||||
onChange={(value) => {
|
||||
setNewCostData((prev) => ({
|
||||
...prev,
|
||||
@ -505,16 +474,15 @@ export default function PackagingCostSection(props: {
|
||||
setShowAddCostPopup(false);
|
||||
// 重置表单
|
||||
setNewCostData({
|
||||
itemId: generateShortId(),
|
||||
costType: "",
|
||||
payerType: "",
|
||||
principal: "",
|
||||
name: "", // 费用名称
|
||||
quantity: 0, // 数量
|
||||
unit: "", // 单位
|
||||
unitPrice: "", // 单价
|
||||
amount: "", // 金额
|
||||
requireQuantityAndPrice: false,
|
||||
costType: "",
|
||||
itemId: generateShortId(),
|
||||
name: "",
|
||||
payee: "",
|
||||
quantity: "",
|
||||
unitPrice: "",
|
||||
amount: "",
|
||||
});
|
||||
}}
|
||||
>
|
||||
@ -535,7 +503,7 @@ export default function PackagingCostSection(props: {
|
||||
|
||||
if (
|
||||
newCostData.costType === "OTHER_COST" &&
|
||||
(!newCostData.name || !newCostData.principal)
|
||||
(!newCostData.name || !newCostData.payee)
|
||||
) {
|
||||
console.log("请填写费用名称和收款人姓名");
|
||||
return;
|
||||
@ -601,16 +569,15 @@ export default function PackagingCostSection(props: {
|
||||
setShowAddCostPopup(false);
|
||||
// 重置表单
|
||||
setNewCostData({
|
||||
itemId: generateShortId(),
|
||||
costType: "",
|
||||
payerType: "",
|
||||
principal: "",
|
||||
name: "", // 费用名称
|
||||
quantity: 0, // 数量
|
||||
unit: "", // 单位
|
||||
unitPrice: "", // 单价
|
||||
amount: "", // 金额
|
||||
requireQuantityAndPrice: false,
|
||||
costType: "",
|
||||
itemId: generateShortId(),
|
||||
name: "",
|
||||
payee: "",
|
||||
quantity: "",
|
||||
unitPrice: "",
|
||||
amount: "",
|
||||
});
|
||||
}}
|
||||
>
|
||||
|
||||
@ -8,16 +8,16 @@ import {
|
||||
} from "@nutui/nutui-react-taro";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Icon } from "@/components";
|
||||
import { business } from "@/services";
|
||||
import { formatCurrency, validatePrice } from "@/utils/format";
|
||||
import { generateShortId } from "@/utils/generateShortId";
|
||||
|
||||
export default function ProductionAdvanceSection(props: {
|
||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||
costItemVOList: BusinessAPI.CostItemVO[];
|
||||
onChange?: (purchaseOrderVO: BusinessAPI.PurchaseOrderVO) => void;
|
||||
readOnly?: boolean;
|
||||
}) {
|
||||
const { purchaseOrderVO, onChange, readOnly, costItemVOList } = props;
|
||||
const { purchaseOrderVO, onChange, readOnly } = props;
|
||||
|
||||
// 弹窗相关状态
|
||||
const [visiblePopup, setVisiblePopup] = useState<{ [key: string]: boolean }>(
|
||||
@ -41,12 +41,17 @@ export default function ProductionAdvanceSection(props: {
|
||||
requireQuantityAndPrice: false,
|
||||
});
|
||||
|
||||
console.log("newCostData", newCostData);
|
||||
|
||||
// Picker可见状态
|
||||
const [pickerVisible, setPickerVisible] = useState({
|
||||
costType: false, // 费用类型Picker
|
||||
costItem: false, // 费用项目Picker
|
||||
});
|
||||
|
||||
// 费用项目列表
|
||||
const [costItems, setCostItems] = useState<BusinessAPI.CostItemVO[]>([]);
|
||||
|
||||
// 编辑值的状态
|
||||
const [editValues, setEditValues] = useState<{
|
||||
[key: string]: {
|
||||
@ -94,6 +99,25 @@ export default function ProductionAdvanceSection(props: {
|
||||
}
|
||||
};
|
||||
|
||||
// 获取费用项目列表
|
||||
useEffect(() => {
|
||||
const fetchCostItems = async () => {
|
||||
try {
|
||||
const { data } = await business.costItem.listCostItem({
|
||||
costItemListQry: {
|
||||
status: true,
|
||||
showInEntry: true,
|
||||
},
|
||||
});
|
||||
setCostItems(data.data || []);
|
||||
} catch (error) {
|
||||
console.error("获取费用项目列表失败:", error);
|
||||
}
|
||||
};
|
||||
|
||||
fetchCostItems();
|
||||
}, []);
|
||||
|
||||
// 产地垫付
|
||||
const productionAdvanceCosts =
|
||||
purchaseOrderVO.orderCostList?.filter(
|
||||
@ -152,60 +176,58 @@ export default function ProductionAdvanceSection(props: {
|
||||
return (
|
||||
<>
|
||||
<View className={"flex flex-col gap-2.5 divide-y divide-[#eaeaea]"}>
|
||||
{productionAdvanceCosts && productionAdvanceCosts.length > 0 && (
|
||||
<View className="flex flex-col gap-2.5">
|
||||
<View className={"text-sm font-bold"}>
|
||||
产地负责人:{purchaseOrderVO.originPrincipal}
|
||||
</View>
|
||||
{/* 产地垫付 */}
|
||||
{productionAdvanceCosts.map((item, index) => {
|
||||
// 初始化编辑值,包括费用承担方和工头姓名
|
||||
initEditValues(
|
||||
item.orderCostId,
|
||||
item.count,
|
||||
item.price,
|
||||
item.name,
|
||||
item.principal,
|
||||
item.payerType,
|
||||
);
|
||||
|
||||
return (
|
||||
<View
|
||||
className="flex items-center justify-between gap-2.5"
|
||||
key={item.orderCostId}
|
||||
onClick={() =>
|
||||
setVisiblePopup((prev) => ({
|
||||
...prev,
|
||||
[item.orderCostId]: true,
|
||||
}))
|
||||
}
|
||||
>
|
||||
<View className="text-neutral-dark flex-shrink-0 text-sm">
|
||||
{index + 1}-{item.name}
|
||||
{item.principal && `(${item.principal})`}
|
||||
</View>
|
||||
<View className="text-neutral-darkest flex flex-row items-center justify-between gap-2.5 text-sm font-medium">
|
||||
{formatCurrency(
|
||||
Number(
|
||||
(editValues[item.orderCostId]?.price || item.price) *
|
||||
(editValues[item.orderCostId]?.count || item.count),
|
||||
),
|
||||
)}
|
||||
{!readOnly && (
|
||||
<View className="ml-1 text-gray-500">
|
||||
<Icon
|
||||
name={"pen-to-square"}
|
||||
size={16}
|
||||
color={"#1a73e8"}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
})}
|
||||
<View className="flex flex-col gap-2.5">
|
||||
<View className={"text-sm font-bold"}>
|
||||
产地负责人:{purchaseOrderVO.originPrincipal}
|
||||
</View>
|
||||
)}
|
||||
{/* 产地垫付 */}
|
||||
{productionAdvanceCosts.map((item, index) => {
|
||||
// 初始化编辑值,包括费用承担方和工头姓名
|
||||
initEditValues(
|
||||
item.orderCostId,
|
||||
item.count,
|
||||
item.price,
|
||||
item.name,
|
||||
item.principal,
|
||||
item.payerType,
|
||||
);
|
||||
|
||||
return (
|
||||
<View
|
||||
className="flex items-center justify-between gap-2.5"
|
||||
key={item.orderCostId}
|
||||
onClick={() =>
|
||||
setVisiblePopup((prev) => ({
|
||||
...prev,
|
||||
[item.orderCostId]: true,
|
||||
}))
|
||||
}
|
||||
>
|
||||
<View className="text-neutral-dark flex-shrink-0 text-sm">
|
||||
{index + 1}-{item.name}
|
||||
{item.principal && `(${item.principal})`}
|
||||
</View>
|
||||
<View className="text-neutral-darkest flex flex-row items-center justify-between gap-2.5 text-sm font-medium">
|
||||
{formatCurrency(
|
||||
Number(
|
||||
(editValues[item.orderCostId]?.price || item.price) *
|
||||
(editValues[item.orderCostId]?.count || item.count),
|
||||
),
|
||||
)}
|
||||
{!readOnly && (
|
||||
<View className="ml-1 text-gray-500">
|
||||
<Icon
|
||||
name={"pen-to-square"}
|
||||
size={16}
|
||||
color={"#1a73e8"}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
|
||||
{!readOnly && (
|
||||
<Button
|
||||
@ -236,30 +258,28 @@ export default function ProductionAdvanceSection(props: {
|
||||
<View className="text-neutral-darkest text-sm font-medium">
|
||||
垫付项目
|
||||
</View>
|
||||
<View className="border-neutral-base relative flex h-10 w-full items-center rounded-md border border-solid">
|
||||
<View
|
||||
className={
|
||||
"flex flex-1 flex-row items-center justify-between px-5"
|
||||
}
|
||||
style={{
|
||||
color: "var(--nutui-color-title, #1a1a1a)",
|
||||
}}
|
||||
onClick={(event) => {
|
||||
setPickerVisible((prev) => ({ ...prev, costItem: true }));
|
||||
event.stopPropagation();
|
||||
}}
|
||||
>
|
||||
<View className={"text-sm"}>
|
||||
{newCostData.name || "请选择垫付项目"}
|
||||
</View>
|
||||
<Icon name={"chevron-down"} />
|
||||
</View>
|
||||
<View
|
||||
className="border-neutral-base relative flex h-10 w-full items-center rounded-md border border-solid"
|
||||
onClick={() =>
|
||||
setPickerVisible((prev) => ({ ...prev, costItem: true }))
|
||||
}
|
||||
>
|
||||
<Input
|
||||
type="text"
|
||||
placeholder="请选择垫付项目"
|
||||
value={newCostData.name || ""}
|
||||
disabled
|
||||
/>
|
||||
<Icon
|
||||
name="chevron-down"
|
||||
className="absolute -right-1 mr-4"
|
||||
/>
|
||||
</View>
|
||||
<Picker
|
||||
title="请选择垫付项目"
|
||||
visible={pickerVisible.costItem}
|
||||
options={[
|
||||
costItemVOList
|
||||
costItems
|
||||
.filter((item) => item.costType === newCostData.costType)
|
||||
.filter((item) => {
|
||||
// 检查该项目是否已经被选择
|
||||
@ -274,7 +294,7 @@ export default function ProductionAdvanceSection(props: {
|
||||
]}
|
||||
onConfirm={(_, values) => {
|
||||
const selectedValue = values[0] as string;
|
||||
const selectedItem = costItemVOList.find(
|
||||
const selectedItem = costItems.find(
|
||||
(item) => item.itemId === selectedValue,
|
||||
);
|
||||
if (selectedItem) {
|
||||
|
||||
@ -25,7 +25,7 @@ export default function RebateCalcSection(props: {
|
||||
const { data } =
|
||||
await business.dealerRebateCustomer.showDealerRebateCustomer({
|
||||
dealerRebateCustomerShowQry: {
|
||||
dealerId: purchaseOrderVO.orderDealer?.dealerId,
|
||||
dealerId: purchaseOrderVO.orderDealer.dealerId,
|
||||
status: true,
|
||||
},
|
||||
});
|
||||
|
||||
@ -16,12 +16,12 @@ export default function TaxProvisionSection(props: {
|
||||
const [visible, setVisible] = useState(false);
|
||||
|
||||
const [taxProvision, setTaxProvision] = useState<number>(
|
||||
purchaseOrderVO.orderDealer?.taxProvision || 0,
|
||||
purchaseOrderVO.orderDealer.taxProvision || 0,
|
||||
);
|
||||
|
||||
// 当dealerVO变化时,自动计算计提税金
|
||||
useEffect(() => {
|
||||
if (!purchaseOrderVO.orderDealer?.taxProvision) {
|
||||
if (!purchaseOrderVO.orderDealer.taxProvision) {
|
||||
const defaultValue = calculator.getDefaultTaxProvision();
|
||||
setTaxProvision(defaultValue);
|
||||
// 更新父组件的状态
|
||||
|
||||
@ -16,12 +16,12 @@ export default function TaxSubsidySection(props: {
|
||||
const [visible, setVisible] = useState(false);
|
||||
|
||||
const [taxSubsidy, setTaxSubsidy] = useState<number>(
|
||||
purchaseOrderVO.orderDealer?.taxSubsidy || 0,
|
||||
purchaseOrderVO.orderDealer.taxSubsidy || 0,
|
||||
);
|
||||
|
||||
// 当dealerVO变化时,自动计算税费补贴
|
||||
useEffect(() => {
|
||||
if (!purchaseOrderVO.orderDealer?.taxSubsidy) {
|
||||
if (!purchaseOrderVO.orderDealer.taxSubsidy) {
|
||||
const defaultValue = calculator.getDefaultTaxSubsidy();
|
||||
setTaxSubsidy(defaultValue);
|
||||
// 更新父组件的状态
|
||||
|
||||
@ -8,16 +8,16 @@ import {
|
||||
} from "@nutui/nutui-react-taro";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Icon } from "@/components";
|
||||
import { business } from "@/services";
|
||||
import { formatCurrency, validatePrice } from "@/utils/format";
|
||||
import { generateShortId } from "@/utils/generateShortId";
|
||||
|
||||
export default function WorkerAdvanceSection(props: {
|
||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||
costItemVOList: BusinessAPI.CostItemVO[];
|
||||
onChange?: (purchaseOrderVO: BusinessAPI.PurchaseOrderVO) => void;
|
||||
readOnly?: boolean;
|
||||
}) {
|
||||
const { purchaseOrderVO, onChange, readOnly, costItemVOList } = props;
|
||||
const { purchaseOrderVO, onChange, readOnly } = props;
|
||||
|
||||
// 弹窗相关状态
|
||||
const [visiblePopup, setVisiblePopup] = useState<{ [key: string]: boolean }>(
|
||||
@ -41,12 +41,17 @@ export default function WorkerAdvanceSection(props: {
|
||||
requireQuantityAndPrice: false,
|
||||
});
|
||||
|
||||
console.log("newCostData", newCostData);
|
||||
|
||||
// Picker可见状态
|
||||
const [pickerVisible, setPickerVisible] = useState({
|
||||
costType: false, // 费用类型Picker
|
||||
costItem: false, // 费用项目Picker
|
||||
});
|
||||
|
||||
// 费用项目列表
|
||||
const [costItems, setCostItems] = useState<BusinessAPI.CostItemVO[]>([]);
|
||||
|
||||
// 编辑值的状态
|
||||
const [editValues, setEditValues] = useState<{
|
||||
[key: string]: {
|
||||
@ -94,6 +99,25 @@ export default function WorkerAdvanceSection(props: {
|
||||
}
|
||||
};
|
||||
|
||||
// 获取费用项目列表
|
||||
useEffect(() => {
|
||||
const fetchCostItems = async () => {
|
||||
try {
|
||||
const { data } = await business.costItem.listCostItem({
|
||||
costItemListQry: {
|
||||
status: true,
|
||||
showInEntry: true,
|
||||
},
|
||||
});
|
||||
setCostItems(data.data || []);
|
||||
} catch (error) {
|
||||
console.error("获取费用项目列表失败:", error);
|
||||
}
|
||||
};
|
||||
|
||||
fetchCostItems();
|
||||
}, []);
|
||||
|
||||
// 人工费
|
||||
const humanCosts =
|
||||
purchaseOrderVO.orderCostList?.filter(
|
||||
@ -162,25 +186,22 @@ export default function WorkerAdvanceSection(props: {
|
||||
<>
|
||||
<View className={"flex flex-col gap-2.5 divide-y divide-[#eaeaea]"}>
|
||||
<View className="flex flex-col gap-2.5">
|
||||
{humanCosts && humanCosts.length > 0 && (
|
||||
<View className={"flex flex-col gap-2.5"}>
|
||||
<View className={"text-sm font-bold"}>
|
||||
工头:{humanCosts?.[0].principal}
|
||||
</View>
|
||||
<View
|
||||
className={
|
||||
"text-neutral-dark flex flex-row flex-wrap gap-2.5 text-xs font-medium"
|
||||
}
|
||||
>
|
||||
{humanCosts.map((item, index) => {
|
||||
return (
|
||||
<View key={index}>{`${item.name} ${item.count}人`}</View>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
<View className={"flex flex-col gap-2.5"}>
|
||||
<View className={"text-sm font-bold"}>
|
||||
工头:{humanCosts?.[0].principal}
|
||||
</View>
|
||||
)}
|
||||
|
||||
<View
|
||||
className={
|
||||
"text-neutral-dark flex flex-row flex-wrap gap-2.5 text-xs font-medium"
|
||||
}
|
||||
>
|
||||
{humanCosts.map((item, index) => {
|
||||
return (
|
||||
<View key={index}>{`${item.name} ${item.count}人`}</View>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
</View>
|
||||
{/* 工头垫付 */}
|
||||
{workerAdvanceCosts.map((item, index) => {
|
||||
// 初始化编辑值,包括费用承担方和工头姓名
|
||||
@ -229,6 +250,7 @@ export default function WorkerAdvanceSection(props: {
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
|
||||
{!readOnly && (
|
||||
<Button
|
||||
type={"primary"}
|
||||
@ -258,30 +280,28 @@ export default function WorkerAdvanceSection(props: {
|
||||
<View className="text-neutral-darkest text-sm font-medium">
|
||||
垫付项目
|
||||
</View>
|
||||
<View className="border-neutral-base relative flex h-10 w-full items-center rounded-md border border-solid">
|
||||
<View
|
||||
className={
|
||||
"flex flex-1 flex-row items-center justify-between px-5"
|
||||
}
|
||||
style={{
|
||||
color: "var(--nutui-color-title, #1a1a1a)",
|
||||
}}
|
||||
onClick={(event) => {
|
||||
setPickerVisible((prev) => ({ ...prev, costItem: true }));
|
||||
event.stopPropagation();
|
||||
}}
|
||||
>
|
||||
<View className={"text-sm"}>
|
||||
{newCostData.name || "请选择垫付项目"}
|
||||
</View>
|
||||
<Icon name={"chevron-down"} />
|
||||
</View>
|
||||
<View
|
||||
className="border-neutral-base relative flex h-10 w-full items-center rounded-md border border-solid"
|
||||
onClick={() =>
|
||||
setPickerVisible((prev) => ({ ...prev, costItem: true }))
|
||||
}
|
||||
>
|
||||
<Input
|
||||
type="text"
|
||||
placeholder="请选择垫付项目"
|
||||
value={newCostData.name || ""}
|
||||
disabled
|
||||
/>
|
||||
<Icon
|
||||
name="chevron-down"
|
||||
className="absolute -right-1 mr-4"
|
||||
/>
|
||||
</View>
|
||||
<Picker
|
||||
title="请选择垫付项目"
|
||||
visible={pickerVisible.costItem}
|
||||
options={[
|
||||
costItemVOList
|
||||
costItems
|
||||
.filter((item) => item.costType === newCostData.costType)
|
||||
.filter((item) => {
|
||||
return !workerAdvanceCosts.some(
|
||||
@ -295,7 +315,7 @@ export default function WorkerAdvanceSection(props: {
|
||||
]}
|
||||
onConfirm={(_, values) => {
|
||||
const selectedValue = values[0] as string;
|
||||
const selectedItem = costItemVOList.find(
|
||||
const selectedItem = costItems.find(
|
||||
(item) => item.itemId === selectedValue,
|
||||
);
|
||||
if (selectedItem) {
|
||||
@ -510,7 +530,7 @@ export default function WorkerAdvanceSection(props: {
|
||||
setShowAddCostPopup(false);
|
||||
// 重置表单
|
||||
setNewCostData({
|
||||
costType: "WORKER_ADVANCE", // 费用类型
|
||||
costType: "PRODUCTION_ADVANCE", // 费用类型
|
||||
itemId: "",
|
||||
name: "", // 费用名称
|
||||
quantity: 0, // 数量(人数)
|
||||
|
||||
@ -19,7 +19,6 @@ import classNames from "classnames";
|
||||
import { business, poster } from "@/services";
|
||||
import dayjs from "dayjs";
|
||||
import buildUrl from "@/utils/buildUrl";
|
||||
import { Icon } from "@/components";
|
||||
|
||||
// 特殊处理:其他费用要实时获取费用项目
|
||||
const updateOtherFeesModule = async (
|
||||
@ -433,24 +432,37 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
<View
|
||||
className={`flex h-10 w-full items-center rounded-md ${formErrors.estimatedArrivalDate ? "border-4 border-red-500" : "border-4 border-gray-300"}`}
|
||||
>
|
||||
<View
|
||||
className={
|
||||
"flex flex-1 flex-row items-center justify-between px-5"
|
||||
}
|
||||
style={{
|
||||
color: "var(--nutui-color-title, #1a1a1a)",
|
||||
}}
|
||||
onClick={() => setShow(true)}
|
||||
>
|
||||
<View className={"text-sm"}>
|
||||
{shipOrderVO?.estimatedArrivalDate
|
||||
<Input
|
||||
value={
|
||||
shipOrderVO?.estimatedArrivalDate
|
||||
? dayjs(shipOrderVO?.estimatedArrivalDate).format(
|
||||
"YYYY年MM月DD日",
|
||||
)
|
||||
: column.fieldProps?.placeholder || `请${column.title}`}
|
||||
</View>
|
||||
<Icon name={"chevron-down"} />
|
||||
</View>
|
||||
: ""
|
||||
}
|
||||
placeholder={
|
||||
column.fieldProps?.placeholder || `请${column.title}`
|
||||
}
|
||||
type="text"
|
||||
className="flex-1"
|
||||
disabled
|
||||
onClick={() => setShow(true)}
|
||||
onBlur={() => {
|
||||
// 失焦时校验
|
||||
if (!shipOrderVO?.estimatedArrivalDate) {
|
||||
setFormErrors((prev) => ({
|
||||
...prev,
|
||||
estimatedArrivalDate: true,
|
||||
}));
|
||||
Toast.show("toast", {
|
||||
icon: "fail",
|
||||
title:
|
||||
column.fieldProps?.placeholder ||
|
||||
`请选择${column.title}`,
|
||||
});
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<DatePicker
|
||||
title="发货时间选择"
|
||||
type="date"
|
||||
|
||||
@ -19,7 +19,6 @@ import classNames from "classnames";
|
||||
import { business } from "@/services";
|
||||
import dayjs from "dayjs";
|
||||
import buildUrl from "@/utils/buildUrl";
|
||||
import { Icon } from "@/components";
|
||||
|
||||
export default hocAuth(function Page(props: CommonComponent) {
|
||||
const { router, setLoading } = props;
|
||||
@ -361,24 +360,37 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
<View
|
||||
className={`flex h-10 w-full items-center rounded-md ${formErrors.estimatedArrivalDate ? "border-4 border-red-500" : "border-4 border-gray-300"}`}
|
||||
>
|
||||
<View
|
||||
className={
|
||||
"flex flex-1 flex-row items-center justify-between px-5"
|
||||
}
|
||||
style={{
|
||||
color: "var(--nutui-color-title, #1a1a1a)",
|
||||
}}
|
||||
onClick={() => setShow(true)}
|
||||
>
|
||||
<View className={"text-sm"}>
|
||||
{shipOrderVO?.estimatedArrivalDate
|
||||
<Input
|
||||
value={
|
||||
shipOrderVO?.estimatedArrivalDate
|
||||
? dayjs(shipOrderVO?.estimatedArrivalDate).format(
|
||||
"YYYY年MM月DD日",
|
||||
)
|
||||
: column.fieldProps?.placeholder || `请${column.title}`}
|
||||
</View>
|
||||
<Icon name={"chevron-down"} />
|
||||
</View>
|
||||
: ""
|
||||
}
|
||||
placeholder={
|
||||
column.fieldProps?.placeholder || `请${column.title}`
|
||||
}
|
||||
type="text"
|
||||
className="flex-1"
|
||||
disabled
|
||||
onClick={() => setShow(true)}
|
||||
onBlur={() => {
|
||||
// 失焦时校验
|
||||
if (!shipOrderVO?.estimatedArrivalDate) {
|
||||
setFormErrors((prev) => ({
|
||||
...prev,
|
||||
estimatedArrivalDate: true,
|
||||
}));
|
||||
Toast.show("toast", {
|
||||
icon: "fail",
|
||||
title:
|
||||
column.fieldProps?.placeholder ||
|
||||
`请选择${column.title}`,
|
||||
});
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<DatePicker
|
||||
title="发货时间选择"
|
||||
type="date"
|
||||
|
||||
@ -97,7 +97,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
¥{formatCurrency(calculator.getSupplierPurchaseCost())}
|
||||
</View>
|
||||
</View>
|
||||
{purchaseOrderVO.orderDealer?.freightCostFlag && (
|
||||
{purchaseOrderVO.orderDealer.freightCostFlag && (
|
||||
<View className="cost-item flex flex-col px-3 py-2">
|
||||
<View className="text-sm text-gray-500">运输费</View>
|
||||
<View className="font-medium">
|
||||
@ -143,13 +143,13 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
<View className="cost-item flex flex-col px-3 py-2">
|
||||
<View className="text-sm text-gray-500">果多美返点</View>
|
||||
<View className="font-medium">
|
||||
¥{purchaseOrderVO.orderDealer?.taxSubsidy}
|
||||
¥{purchaseOrderVO.orderDealer.taxSubsidy}
|
||||
</View>
|
||||
</View>
|
||||
<View className="cost-item flex flex-col px-3 py-2">
|
||||
<View className="text-sm text-gray-500">计提税金</View>
|
||||
<View className="font-medium">
|
||||
¥{purchaseOrderVO.orderDealer?.taxSubsidy}
|
||||
¥{purchaseOrderVO.orderDealer.taxSubsidy}
|
||||
</View>
|
||||
</View>
|
||||
<View className="cost-total col-span-2 grid grid-cols-2 bg-yellow-50 px-3 py-2">
|
||||
|
||||
@ -30,7 +30,6 @@ import { generateShortId } from "@/utils/generateShortId";
|
||||
import Taro from "@tarojs/taro";
|
||||
import buildUrl from "@/utils/buildUrl";
|
||||
import { SupplierWeightCalculator } from "@/utils/SupplierWeightCalculator";
|
||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
||||
|
||||
const defaultSupplierList: SupplierVO[] = [
|
||||
{
|
||||
@ -114,33 +113,6 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
const [orderSupplierList, setOrderSupplierList] =
|
||||
useState<SupplierVO[]>(defaultSupplierList);
|
||||
const [orderCostList, setOrderCostList] = useState<CostItem[]>([]);
|
||||
const [orderPackageList, setOrderPackageList] = useState<
|
||||
BusinessAPI.OrderPackage[]
|
||||
>([]);
|
||||
|
||||
// 费用项目列表
|
||||
const [costItemVOList, setCostItemVOList] = useState<
|
||||
BusinessAPI.CostItemVO[]
|
||||
>([]);
|
||||
|
||||
// 获取费用项目列表
|
||||
useEffect(() => {
|
||||
const fetchCostItems = async () => {
|
||||
try {
|
||||
const { data } = await business.costItem.listCostItem({
|
||||
costItemListQry: {
|
||||
status: true,
|
||||
showInEntry: true,
|
||||
},
|
||||
});
|
||||
setCostItemVOList(data.data || []);
|
||||
} catch (error) {
|
||||
console.error("获取费用项目列表失败:", error);
|
||||
}
|
||||
};
|
||||
|
||||
fetchCostItems();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (orderId) {
|
||||
@ -166,6 +138,11 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
setPurchaseOrder(purchaseOrder);
|
||||
setOrderVehicle(purchaseOrder.orderVehicle);
|
||||
const orderSupplierList1 = purchaseOrder.orderSupplierList as any;
|
||||
console.log(
|
||||
"orderSupplierList1",
|
||||
orderSupplierList1,
|
||||
defaultSupplierId,
|
||||
);
|
||||
if (defaultSupplierId) {
|
||||
const index = orderSupplierList1.findIndex(
|
||||
(item: any) => item.supplierId === defaultSupplierId,
|
||||
@ -194,8 +171,6 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
}),
|
||||
) as any;
|
||||
setOrderCostList(orderCostList1);
|
||||
|
||||
setOrderPackageList(purchaseOrder.orderPackageList);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
@ -248,13 +223,6 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
}));
|
||||
}, [orderCostList]);
|
||||
|
||||
useEffect(() => {
|
||||
setPurchaseOrder((prev) => ({
|
||||
...prev!,
|
||||
orderPackageList: orderPackageList || [],
|
||||
}));
|
||||
}, [orderPackageList]);
|
||||
|
||||
if (step === undefined) {
|
||||
return;
|
||||
}
|
||||
@ -417,7 +385,6 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
orderCostList: purchaseOrder.orderCostList.filter(
|
||||
(item: CostItem) => item.selected,
|
||||
),
|
||||
orderPackageList: purchaseOrder.orderPackageList,
|
||||
});
|
||||
|
||||
if (data.success) {
|
||||
@ -584,18 +551,13 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
<OrderVehicle
|
||||
ref={vehicleRef}
|
||||
orderVehicle={orderVehicle!}
|
||||
setOrderVehicle={(orderVehicle) => {
|
||||
setOrderVehicle(orderVehicle);
|
||||
}}
|
||||
setOrderVehicle={setOrderVehicle}
|
||||
orderDealer={orderDealer!}
|
||||
setOrderDealer={(orderDealer) => {
|
||||
setOrderDealer(orderDealer);
|
||||
}}
|
||||
setOrderDealer={setOrderDealer}
|
||||
orderCostList={orderCostList}
|
||||
setOrderCostList={(costItemList: CostItem[]) => {
|
||||
setOrderCostList(costItemList);
|
||||
}}
|
||||
costItemVOList={costItemVOList}
|
||||
/>
|
||||
)}
|
||||
|
||||
@ -662,7 +624,6 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
onChange={(supplierVO: SupplierVO) => {
|
||||
orderSupplierList[index] = { ...item, ...supplierVO };
|
||||
setOrderSupplierList([...orderSupplierList]);
|
||||
console.log("supplierVO", supplierVO);
|
||||
}}
|
||||
isLast={index === orderSupplierList.length - 1}
|
||||
selectedSupplierIds={selectedSupplierIds}
|
||||
@ -698,12 +659,11 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
return item;
|
||||
}),
|
||||
]);
|
||||
setOrderCostList((prev) => {
|
||||
setPurchaseOrder((prev) => {
|
||||
const costItemVOList = productVO.costItemVOList;
|
||||
|
||||
console.log("prev", prev);
|
||||
// 将 orderCostList 中 不存在与 costItemVOList 的项 删除,剩余项保留
|
||||
const orderCostList = prev?.filter((item) => {
|
||||
const orderCostList = prev?.orderCostList.filter((item) => {
|
||||
return (
|
||||
(item.costType === "WORKER_ADVANCE" ||
|
||||
item.costType === "PRODUCTION_ADVANCE" ||
|
||||
@ -733,21 +693,23 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
principal: "",
|
||||
costType: item.costType,
|
||||
requireQuantityAndPrice: item.requireQuantityAndPrice,
|
||||
selected: true,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return [
|
||||
...(prev?.filter((item) => {
|
||||
return (
|
||||
item.costType !== "WORKER_ADVANCE" &&
|
||||
item.costType !== "PRODUCTION_ADVANCE" &&
|
||||
item.costType !== "PACKAGING_MATERIALS"
|
||||
);
|
||||
}) || []),
|
||||
...(orderCostList || []),
|
||||
];
|
||||
return {
|
||||
...prev!,
|
||||
orderCostList: [
|
||||
...(prev?.orderCostList?.filter((item) => {
|
||||
return (
|
||||
item.costType !== "WORKER_ADVANCE" &&
|
||||
item.costType !== "PRODUCTION_ADVANCE" &&
|
||||
item.costType !== "PACKAGING_MATERIALS"
|
||||
);
|
||||
}) || []),
|
||||
...(orderCostList || []),
|
||||
],
|
||||
};
|
||||
});
|
||||
}}
|
||||
isFirst={index === 0}
|
||||
@ -787,59 +749,6 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
onChange={(supplierVO: SupplierVO) => {
|
||||
orderSupplierList[index] = { ...item, ...supplierVO };
|
||||
setOrderSupplierList([...orderSupplierList]);
|
||||
|
||||
setOrderCostList((prev) => {
|
||||
console.log("prev", prev);
|
||||
// 检查是否已存在纸箱费项目
|
||||
const hasBoxFee = prev?.some(
|
||||
(item) =>
|
||||
item.name === "纸箱费" &&
|
||||
item.costType === "FIXED_COST",
|
||||
);
|
||||
const boxCostItem = costItemVOList.find(
|
||||
(item) =>
|
||||
item.name === "纸箱费" &&
|
||||
item.costType === "FIXED_COST",
|
||||
);
|
||||
|
||||
const calculator = new PurchaseOrderCalculator(
|
||||
purchaseOrder as any,
|
||||
);
|
||||
|
||||
// 如果不存在空箱费项目,则添加
|
||||
if (!hasBoxFee) {
|
||||
const boxFeeItem: CostItem = {
|
||||
orderCostId: generateShortId(),
|
||||
itemId: boxCostItem?.itemId || "",
|
||||
name: "纸箱费",
|
||||
price: calculator.getBoxSale(),
|
||||
unit: "项",
|
||||
selected: true,
|
||||
count: 1,
|
||||
payerType: "US",
|
||||
principal: "",
|
||||
costType: "FIXED_COST",
|
||||
requireQuantityAndPrice: false,
|
||||
};
|
||||
|
||||
return [...prev, boxFeeItem];
|
||||
} else {
|
||||
// 如果已存在空箱费项目,更新其数量
|
||||
return prev.map((item) => {
|
||||
if (
|
||||
item.name === "纸箱费" &&
|
||||
item.costType === "FIXED_COST"
|
||||
) {
|
||||
return {
|
||||
...item,
|
||||
price: calculator.getBoxSale(),
|
||||
count: 1,
|
||||
};
|
||||
}
|
||||
return item;
|
||||
});
|
||||
}
|
||||
});
|
||||
}}
|
||||
/>
|
||||
);
|
||||
@ -871,15 +780,9 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
}}
|
||||
ref={orderCostRef}
|
||||
value={orderCostList}
|
||||
onChange={(costItemList: CostItem[]) => {
|
||||
// 修改标识将在useEffect中自动更新
|
||||
setOrderCostList(costItemList);
|
||||
}}
|
||||
emptyBoxList={orderPackageList}
|
||||
onEmptyBoxChange={(emptyBoxList: BusinessAPI.OrderPackage[]) => {
|
||||
setOrderPackageList(emptyBoxList);
|
||||
}}
|
||||
costItemVOList={costItemVOList}
|
||||
onChange={(costItemList: CostItem[]) =>
|
||||
setOrderCostList(costItemList)
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
|
||||
@ -121,29 +121,6 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
const orderId = router.params
|
||||
.orderId as BusinessAPI.PurchaseOrderVO["orderId"];
|
||||
|
||||
// 费用项目列表
|
||||
const [costItemVOList, setCostItemVOList] = useState<
|
||||
BusinessAPI.CostItemVO[]
|
||||
>([]);
|
||||
|
||||
// 获取费用项目列表
|
||||
useEffect(() => {
|
||||
const fetchCostItems = async () => {
|
||||
try {
|
||||
const { data } = await business.costItem.listCostItem({
|
||||
costItemListQry: {
|
||||
status: true,
|
||||
},
|
||||
});
|
||||
setCostItemVOList(data.data || []);
|
||||
} catch (error) {
|
||||
console.error("获取费用项目列表失败:", error);
|
||||
}
|
||||
};
|
||||
|
||||
fetchCostItems();
|
||||
}, []);
|
||||
|
||||
const [purchaseOrderVO, setPurchaseOrderVO] =
|
||||
useState<BusinessAPI.PurchaseOrderVO>();
|
||||
|
||||
@ -459,7 +436,6 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
dealerVO={dealerVO}
|
||||
purchaseOrderVO={purchaseOrderVO}
|
||||
onChange={setPurchaseOrderVO}
|
||||
costItemVOList={costItemVOList}
|
||||
/>
|
||||
</View>
|
||||
</>
|
||||
|
||||
@ -2576,7 +2576,7 @@ declare namespace BusinessAPI {
|
||||
/** 销售单价(元/个) */
|
||||
boxSalePrice?: number;
|
||||
/** 箱子类型:1_本次使用;2_额外运输;3_已使用额外运输;4_车上剩余; */
|
||||
boxType: "USED" | "EXTRA" | "EXTRA_USED" | "REMAIN" | "OWN" | "EMPTY";
|
||||
boxType: "USED" | "EXTRA" | "EXTRA_USED" | "REMAIN" | "OWN";
|
||||
};
|
||||
|
||||
type OrderRebate = {
|
||||
@ -3362,8 +3362,6 @@ declare namespace BusinessAPI {
|
||||
orderSupplierList: OrderSupplier[];
|
||||
/** 采购订单费用信息 */
|
||||
orderCostList: OrderCost[];
|
||||
/** 采购订单空箱费用 */
|
||||
orderPackageList: OrderPackage[];
|
||||
};
|
||||
|
||||
type PurchaseOrderDestroyCmd = {
|
||||
@ -3469,8 +3467,6 @@ declare namespace BusinessAPI {
|
||||
active?: number;
|
||||
/** 采购订单费用信息 */
|
||||
orderCostList: OrderCost[];
|
||||
/** 采购订单空箱费用 */
|
||||
orderPackageList: OrderPackage[];
|
||||
};
|
||||
|
||||
type PurchaseOrderSubmitReviewCmd = {
|
||||
@ -3556,8 +3552,6 @@ declare namespace BusinessAPI {
|
||||
orderSupplierList: OrderSupplier[];
|
||||
/** 采购订单费用信息 */
|
||||
orderCostList: OrderCost[];
|
||||
/** 采购订单空箱费用 */
|
||||
orderPackageList: OrderPackage[];
|
||||
};
|
||||
|
||||
type PurchaseOrderWithdrawReviewCmd = {
|
||||
|
||||
@ -36,7 +36,7 @@ export interface BoxBrand {
|
||||
boxBrandName: string;
|
||||
boxBrandImage: string;
|
||||
boxBrandType: "OUR_BOX" | "FARMER_BOX" | "THIRD_PARTY_BOX" | "GIFT_BOX";
|
||||
boxType: "USED" | "EXTRA" | "EXTRA_USED" | "REMAIN" | "OWN" | "EMPTY";
|
||||
boxType: "USED" | "EXTRA" | "EXTRA_USED" | "REMAIN" | "OWN" | "DEFAULT";
|
||||
boxSpecList: BoxSpec[];
|
||||
}
|
||||
|
||||
|
||||
@ -258,23 +258,24 @@ export class PurchaseOrderCalculator {
|
||||
* 分成后净利润(CXZY)
|
||||
*/
|
||||
getNetProfit(): number {
|
||||
if (this.purchaseOrderVO.orderDealer?.profitSharing) {
|
||||
return this.purchaseOrderVO.orderDealer?.profitSharing;
|
||||
if (this.purchaseOrderVO.orderDealer.profitSharing) {
|
||||
return this.purchaseOrderVO.orderDealer.profitSharing;
|
||||
}
|
||||
|
||||
return this.getDefaultNetProfit();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 默认分成后净利润(CXZY)
|
||||
*/
|
||||
getDefaultNetProfit(): number {
|
||||
if (!this.purchaseOrderVO.orderDealer?.enableShare) {
|
||||
if (!this.purchaseOrderVO.orderDealer.enableShare) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return new Decimal(this.getMelonNetProfit())
|
||||
.mul(new Decimal(this.purchaseOrderVO.orderDealer?.shareRatio || 0))
|
||||
.mul(new Decimal(this.purchaseOrderVO.orderDealer.shareRatio || 0))
|
||||
.div(100)
|
||||
.toNumber();
|
||||
}
|
||||
@ -321,7 +322,7 @@ export class PurchaseOrderCalculator {
|
||||
* 成本差异(调诚信志远分成)
|
||||
*/
|
||||
getCostDifference(): number {
|
||||
return this.purchaseOrderVO.orderDealer?.costDifference || 0;
|
||||
return this.purchaseOrderVO.orderDealer.costDifference || 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -335,14 +336,14 @@ export class PurchaseOrderCalculator {
|
||||
* 计提税金
|
||||
*/
|
||||
getTaxProvision(): number {
|
||||
return this.purchaseOrderVO.orderDealer?.taxProvision || 0;
|
||||
return this.purchaseOrderVO.orderDealer.taxProvision || 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 税费补贴(公司返利)
|
||||
*/
|
||||
getTaxSubsidy(): number {
|
||||
return this.purchaseOrderVO.orderDealer?.taxSubsidy || 0;
|
||||
return this.purchaseOrderVO.orderDealer.taxSubsidy || 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -384,17 +385,9 @@ export class PurchaseOrderCalculator {
|
||||
* 计算市场报价(销售金额 + 包装费)
|
||||
*/
|
||||
getTotalAmount(): number {
|
||||
const decimal = new Decimal(this.getSalesAmount());
|
||||
|
||||
const includePackingFlag =
|
||||
this.purchaseOrderVO.orderDealer?.includePackingFlag;
|
||||
if (includePackingFlag) {
|
||||
return decimal
|
||||
.plus(this.getTotalPackagingCost())
|
||||
.toNumber();
|
||||
}
|
||||
|
||||
return decimal.toNumber();
|
||||
return new Decimal(this.getSalesAmount())
|
||||
.add(this.getTotalPackagingCost())
|
||||
.toNumber();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -34,7 +34,7 @@ export class SupplierWeightCalculator {
|
||||
}
|
||||
|
||||
// 使用第一个瓜农的空磅重量作为初始空磅重量
|
||||
const initialEmptyWeight = this.suppliers[0].emptyWeight || 0;
|
||||
const initialEmptyWeight = this.suppliers[0].emptyWeight;
|
||||
let previousTotalWeight = initialEmptyWeight; // 上一个农户的总磅重量(kg)
|
||||
|
||||
for (let i = 0; i < this.suppliers.length; i++) {
|
||||
@ -46,7 +46,7 @@ export class SupplierWeightCalculator {
|
||||
if (isFirstSupplier) {
|
||||
// 第一个农户的空磅重量已经是正确的
|
||||
} else {
|
||||
supplier.emptyWeight = this.suppliers[i - 1].totalWeight || 0;
|
||||
supplier.emptyWeight = this.suppliers[i - 1].totalWeight;
|
||||
}
|
||||
|
||||
// 计算本次使用纸箱的总重量(斤)
|
||||
@ -69,19 +69,19 @@ export class SupplierWeightCalculator {
|
||||
|
||||
if (!supplier.isPaper) {
|
||||
// 如果不是纸箱包装,直接使用原始重量(kg转斤)
|
||||
supplier.grossWeight = new Decimal(supplier.totalWeight || 0)
|
||||
.sub(supplier.emptyWeight || 0)
|
||||
supplier.grossWeight = new Decimal(supplier.totalWeight)
|
||||
.sub(supplier.emptyWeight)
|
||||
.mul(2)
|
||||
.toNumber();
|
||||
|
||||
supplier.netWeight = new Decimal(supplier.grossWeight || 0)
|
||||
supplier.netWeight = new Decimal(supplier.grossWeight)
|
||||
.sub(usedBoxesWeight)
|
||||
.sub(extraUsedBoxesWeight)
|
||||
.toNumber();
|
||||
|
||||
previousTotalWeight = supplier.totalWeight;
|
||||
supplier.invoiceAmount = new Decimal(supplier.netWeight || 0)
|
||||
.mul(supplier.purchasePrice || 0)
|
||||
supplier.invoiceAmount = new Decimal(supplier.netWeight)
|
||||
.mul(supplier.purchasePrice)
|
||||
.toNumber();
|
||||
continue;
|
||||
}
|
||||
@ -101,58 +101,58 @@ export class SupplierWeightCalculator {
|
||||
if (isFirstSupplier && isLastSupplier) {
|
||||
// 既是第一个也是最后一个瓜农(单个瓜农情况)- 优先使用最后一个瓜农算法
|
||||
// 净重 = (总磅 - 空磅) * 2 + 剩余空箱子重量 - 已使用额外纸箱重量
|
||||
supplier.netWeight = new Decimal(supplier.totalWeight || 0)
|
||||
supplier.netWeight = new Decimal(supplier.totalWeight)
|
||||
.sub(initialEmptyWeight)
|
||||
.mul(2)
|
||||
.add(remainingBoxesWeight)
|
||||
.sub(extraUsedBoxesWeight)
|
||||
.toNumber();
|
||||
// 毛重 = 净重 + 本次使用纸箱重量
|
||||
supplier.grossWeight = new Decimal(supplier.netWeight || 0)
|
||||
supplier.grossWeight = new Decimal(supplier.netWeight)
|
||||
.add(usedBoxesWeight)
|
||||
.toNumber();
|
||||
} else if (isLastSupplier) {
|
||||
// 最后一个农户(根据isLast标识判断)
|
||||
// 净重 = (总磅 - 前一个总磅) * 2 + 剩余空箱子重量 - 额外纸箱重量
|
||||
supplier.netWeight = new Decimal(supplier.totalWeight || 0)
|
||||
supplier.netWeight = new Decimal(supplier.totalWeight)
|
||||
.sub(previousTotalWeight)
|
||||
.mul(2)
|
||||
.add(remainingBoxesWeight)
|
||||
.sub(extraBoxesWeight)
|
||||
.toNumber();
|
||||
// 毛重 = 净重 + 本次使用纸箱重量
|
||||
supplier.grossWeight = new Decimal(supplier.netWeight || 0)
|
||||
supplier.grossWeight = new Decimal(supplier.netWeight)
|
||||
.add(usedBoxesWeight)
|
||||
.toNumber();
|
||||
} else if (isFirstSupplier) {
|
||||
// 第一个农户(但不是最后一个)
|
||||
// 净重 = (总磅 - 空磅) * 2 - 额外纸箱重量
|
||||
supplier.netWeight = new Decimal(supplier.totalWeight || 0)
|
||||
supplier.netWeight = new Decimal(supplier.totalWeight)
|
||||
.sub(initialEmptyWeight)
|
||||
.mul(2)
|
||||
.sub(extraBoxesWeight)
|
||||
.toNumber();
|
||||
// 毛重 = 净重 + 本次使用纸箱重量
|
||||
supplier.grossWeight = new Decimal(supplier.netWeight || 0)
|
||||
supplier.grossWeight = new Decimal(supplier.netWeight)
|
||||
.add(usedBoxesWeight)
|
||||
.toNumber();
|
||||
} else {
|
||||
// 中间农户
|
||||
// 净重 = (总磅 - 前一个总磅) * 2 - 额外纸箱重量
|
||||
supplier.netWeight = new Decimal(supplier.totalWeight || 0)
|
||||
supplier.netWeight = new Decimal(supplier.totalWeight)
|
||||
.sub(previousTotalWeight)
|
||||
.mul(2)
|
||||
.sub(extraBoxesWeight)
|
||||
.toNumber();
|
||||
// 毛重 = 净重 + 本次使用纸箱重量
|
||||
supplier.grossWeight = new Decimal(supplier.netWeight || 0)
|
||||
supplier.grossWeight = new Decimal(supplier.netWeight)
|
||||
.add(usedBoxesWeight)
|
||||
.toNumber();
|
||||
}
|
||||
|
||||
previousTotalWeight = supplier.totalWeight || 0;
|
||||
supplier.invoiceAmount = new Decimal(supplier.netWeight || 0)
|
||||
.mul(supplier.purchasePrice || 0)
|
||||
previousTotalWeight = supplier.totalWeight;
|
||||
supplier.invoiceAmount = new Decimal(supplier.netWeight)
|
||||
.mul(supplier.purchasePrice)
|
||||
.toNumber();
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user