feat(purchase): 优化采购模块费用与箱型信息处理逻辑
- 在 PriceEditor 组件中增加 negative 属性以支持负数显示 - 优化 Step1Form 表单模块渲染结构,提升可读性 - 修正 CostCard 中价格与数量的展示顺序 - 在 CostCreate 组件中过滤掉“空箱费”和“纸箱费”的选项 - 增加 getTitle 方法动态设置费用类型的标题 - 重构 OrderOption 中费用保存的筛选逻辑 - 强化 OrderCostItem 中字段校验及数据初始化处理 - 完善 BasicInfoSection 的发货日期选择器功能 - 调整 CostDifferenceSection 中分红金额相关文案与计算方式 - 简化 DeliveryFormSection 数据初始化流程 - 移除 EmptyBoxInfoSection 和 PackageInfoSection 中冗余的成本单价和箱重编辑功能 - 在 audit 页面中优化费用项目的初始化加载逻辑并确保计提费正确附加到订单中
This commit is contained in:
parent
dfe9a89213
commit
881685a653
@ -11,6 +11,8 @@ interface PriceEditorProps {
|
||||
unit?: string;
|
||||
icon?: IconNames;
|
||||
hint?: string;
|
||||
// 是否负数
|
||||
negative?: boolean;
|
||||
}
|
||||
|
||||
export default function PriceEditor(props: PriceEditorProps) {
|
||||
@ -22,6 +24,7 @@ export default function PriceEditor(props: PriceEditorProps) {
|
||||
unit = "元/斤",
|
||||
icon = "money-bill",
|
||||
hint = "点击销售单价可直接编辑",
|
||||
negative = false,
|
||||
} = props;
|
||||
|
||||
// 控制区域是否处于编辑状态
|
||||
@ -34,7 +37,11 @@ export default function PriceEditor(props: PriceEditorProps) {
|
||||
// 当开始编辑时,设置初始值并聚焦输入框
|
||||
useEffect(() => {
|
||||
if (isEditing) {
|
||||
setInputValue(value.toFixed(2));
|
||||
if (value == 0) {
|
||||
setInputValue("");
|
||||
} else {
|
||||
setInputValue(value.toString());
|
||||
}
|
||||
// 聚焦到输入框
|
||||
setTimeout(() => {
|
||||
if (inputRef.current) {
|
||||
@ -83,6 +90,7 @@ export default function PriceEditor(props: PriceEditorProps) {
|
||||
{isEditing ? (
|
||||
<View className="relative flex flex-1 items-end">
|
||||
<View className="input-bold flex h-10 w-full items-center border-b-2 border-red-500 !pb-2 text-3xl font-bold text-red-500 focus:outline-none">
|
||||
{negative && <View>-</View>}
|
||||
<Input
|
||||
ref={inputRef}
|
||||
type="digit"
|
||||
@ -106,6 +114,7 @@ export default function PriceEditor(props: PriceEditorProps) {
|
||||
onClick={() => setIsEditing(true)}
|
||||
>
|
||||
<Text className="h-10 w-full border-b-2 border-red-500 pb-2 text-3xl font-bold text-red-500 focus:outline-none">
|
||||
{negative && "-"}
|
||||
{formatCurrency(value || 0)}
|
||||
</Text>
|
||||
<Icon
|
||||
@ -135,7 +144,7 @@ export default function PriceEditor(props: PriceEditorProps) {
|
||||
</View>
|
||||
<View className="relative">
|
||||
<Text className="w-full py-2 text-3xl font-bold text-red-500">
|
||||
{formatCurrency(value || 0)}
|
||||
{Number.isNaN(value) ? "" : formatCurrency(value)}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@ -548,24 +548,20 @@ const Step1Form = forwardRef<Step1FormRef, Step1FormProps>((props, ref) => {
|
||||
return !hasErrors;
|
||||
};
|
||||
|
||||
return (
|
||||
<View>
|
||||
{moduleList.map((module) => {
|
||||
const contentFields = renderContentFields(module);
|
||||
// 如果没有内容配置字段,则不渲染该模块
|
||||
if (!contentFields) return null;
|
||||
return moduleList.map((module) => {
|
||||
const contentFields = renderContentFields(module);
|
||||
// 如果没有内容配置字段,则不渲染该模块
|
||||
if (!contentFields) return null;
|
||||
|
||||
return (
|
||||
<View key={module.id} className="flex flex-col gap-2.5">
|
||||
<View className="border-b border-b-gray-200 pb-2.5">
|
||||
<Text className="text-base font-semibold">{module.title}</Text>
|
||||
</View>
|
||||
{contentFields}
|
||||
</View>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
);
|
||||
return (
|
||||
<View key={module.id} className="flex flex-col gap-2.5">
|
||||
<View className="border-b border-b-gray-200 pb-2.5">
|
||||
<Text className="text-base font-semibold">{module.title}</Text>
|
||||
</View>
|
||||
{contentFields}
|
||||
</View>
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
export default Step1Form;
|
||||
|
||||
@ -116,7 +116,8 @@ export default function CostCard(props: CostCardComponentProps) {
|
||||
{orderCostItem.name}
|
||||
</Text>
|
||||
<Text className="text-sm font-medium">
|
||||
{orderCostItem.count} {orderCostItem.unit}
|
||||
{orderCostItem.price} {orderCostItem.count}{" "}
|
||||
{orderCostItem.unit}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
|
||||
@ -224,40 +224,44 @@ export default function CostCreate(props: AddCostComponentProps) {
|
||||
<View className="mb-2 text-sm text-gray-600">选择费用类型</View>
|
||||
<ScrollView className="mb-2.5" scrollX>
|
||||
<View className="flex w-fit flex-row gap-2.5">
|
||||
{costList?.map((cost) => (
|
||||
<View
|
||||
key={cost.costId}
|
||||
className={"flex flex-col items-center justify-center"}
|
||||
onClick={() => handleCostSelect(cost)}
|
||||
>
|
||||
{costList
|
||||
.filter((cost) => {
|
||||
return !(cost.name === "空箱费" || cost.name === "纸箱费");
|
||||
})
|
||||
?.map((cost) => (
|
||||
<View
|
||||
className={classNames(
|
||||
"border-primary box-content !size-16 overflow-hidden rounded-xl border-4 object-cover",
|
||||
{
|
||||
"border-primary": selectedCost?.costId === cost.costId,
|
||||
"border-transparent":
|
||||
selectedCost?.costId !== cost.costId,
|
||||
},
|
||||
)}
|
||||
key={cost.costId}
|
||||
className={"flex flex-col items-center justify-center"}
|
||||
onClick={() => handleCostSelect(cost)}
|
||||
>
|
||||
{/*@ts-ignore*/}
|
||||
{cost.image ? (
|
||||
<Image
|
||||
//@ts-ignore
|
||||
src={cost.image}
|
||||
className="h-full w-full"
|
||||
mode={"aspectFill"}
|
||||
alt={cost.name}
|
||||
/>
|
||||
) : (
|
||||
<View className="flex h-full w-full items-center justify-center bg-gray-100 text-xs text-gray-500">
|
||||
{cost.name.substring(0, 2)}
|
||||
</View>
|
||||
)}
|
||||
<View
|
||||
className={classNames(
|
||||
"border-primary box-content !size-16 overflow-hidden rounded-xl border-4 object-cover",
|
||||
{
|
||||
"border-primary": selectedCost?.costId === cost.costId,
|
||||
"border-transparent":
|
||||
selectedCost?.costId !== cost.costId,
|
||||
},
|
||||
)}
|
||||
>
|
||||
{/*@ts-ignore*/}
|
||||
{cost.image ? (
|
||||
<Image
|
||||
//@ts-ignore
|
||||
src={cost.image}
|
||||
className="h-full w-full"
|
||||
mode={"aspectFill"}
|
||||
alt={cost.name}
|
||||
/>
|
||||
) : (
|
||||
<View className="flex h-full w-full items-center justify-center bg-gray-100 text-xs text-gray-500">
|
||||
{cost.name.substring(0, 2)}
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
<View className="text-center text-xs">{cost.name}</View>
|
||||
</View>
|
||||
<View className="text-center text-xs">{cost.name}</View>
|
||||
</View>
|
||||
))}
|
||||
))}
|
||||
</View>
|
||||
</ScrollView>
|
||||
{/* 显示金额输入框 */}
|
||||
@ -362,6 +366,23 @@ export default function CostCreate(props: AddCostComponentProps) {
|
||||
);
|
||||
};
|
||||
|
||||
const getTitle = (type: string) => {
|
||||
if (type === "ARTIFICIAL_TYPE") {
|
||||
return "新增人工类型费用";
|
||||
}
|
||||
if (type === "MATERIAL_TYPE") {
|
||||
return "新增辅料类型费用";
|
||||
}
|
||||
if (type === "PRODUCTION_TYPE") {
|
||||
return "新增产地类型费用";
|
||||
}
|
||||
if (type === "OTHER_TYPE") {
|
||||
return "新增其他类型费用";
|
||||
}
|
||||
|
||||
return "新增费用";
|
||||
};
|
||||
|
||||
return (
|
||||
<Popup
|
||||
duration={150}
|
||||
@ -370,7 +391,7 @@ export default function CostCreate(props: AddCostComponentProps) {
|
||||
}}
|
||||
visible={visible}
|
||||
position="bottom"
|
||||
title={editMode ? `编辑${orderCost?.name || "费用"}` : "新增其他人工费用"}
|
||||
title={editMode ? `编辑${orderCost?.name || "费用"}` : getTitle(type)}
|
||||
onClose={onClose}
|
||||
onOverlayClick={onClose}
|
||||
lockScroll
|
||||
@ -411,10 +432,11 @@ export default function CostCreate(props: AddCostComponentProps) {
|
||||
block
|
||||
type="primary"
|
||||
disabled={
|
||||
!selectedCost ||
|
||||
Array.from(costItemCounts.values()).every(
|
||||
(count) => count === 0,
|
||||
)
|
||||
selectedCost?.type !== "OTHER_TYPE" &&
|
||||
(!selectedCost ||
|
||||
Array.from(costItemCounts.values()).every(
|
||||
(count) => count === 0,
|
||||
))
|
||||
}
|
||||
onClick={addCostItems}
|
||||
>
|
||||
|
||||
@ -27,11 +27,11 @@ export default function CostList(props: {
|
||||
(cost) => !costIdList.includes(cost.costId) && cost.type === type,
|
||||
);
|
||||
|
||||
// 新增人工费弹窗状态
|
||||
// 新增费弹窗状态
|
||||
const [showAddCostPopup, setShowAddCostPopup] = useState(false);
|
||||
|
||||
// 人工费类型
|
||||
const workerAdvanceCosts =
|
||||
// 费类型
|
||||
const orderCosts =
|
||||
purchaseOrderVO.orderCostList?.filter((item) => item.type === type) || [];
|
||||
|
||||
const handleSaveNewCost = (
|
||||
@ -155,7 +155,7 @@ export default function CostList(props: {
|
||||
</View>
|
||||
)}
|
||||
|
||||
{workerAdvanceCosts.map((orderCost) => {
|
||||
{orderCosts.map((orderCost) => {
|
||||
if (type === "MATERIAL_TYPE") {
|
||||
if (orderCost.name === "空箱费" || orderCost.name === "纸箱费") {
|
||||
return <></>;
|
||||
|
||||
@ -37,7 +37,7 @@ export default forwardRef<OrderCostRef, IOrderCostProps>(
|
||||
const orderCostMap = new Map<string, BusinessAPI.OrderCost>();
|
||||
|
||||
orderCostList?.forEach((item) => {
|
||||
if (item.costId && costIds.includes(item.costId)) {
|
||||
if (item.costId && costIds?.includes(item.costId)) {
|
||||
orderCostMap.set(item.costId, item);
|
||||
}
|
||||
});
|
||||
|
||||
@ -43,7 +43,10 @@ export default forwardRef<OrderCostItemRef, IOrderCostItemProps>(
|
||||
const orderCostItemMap = new Map<string, BusinessAPI.OrderCostItem>();
|
||||
orderCostItemList?.forEach((item) => {
|
||||
if (item.costItemId) {
|
||||
orderCostItemMap.set(item.costItemId, item);
|
||||
orderCostItemMap.set(item.costItemId, {
|
||||
...item,
|
||||
selected: true,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@ -132,7 +135,7 @@ export default forwardRef<OrderCostItemRef, IOrderCostItemProps>(
|
||||
|
||||
// 校验工头姓名
|
||||
const validatePrincipal = (principal: string) => {
|
||||
const isValid = principal.trim().length > 0;
|
||||
const isValid = principal?.trim().length > 0;
|
||||
setForemanError(!isValid);
|
||||
return isValid;
|
||||
};
|
||||
@ -170,8 +173,8 @@ export default forwardRef<OrderCostItemRef, IOrderCostItemProps>(
|
||||
};
|
||||
|
||||
// 失去焦点时校验工头姓名
|
||||
const handlePrincipalBlur = (principal: string) => {
|
||||
validatePrincipal(principal);
|
||||
const handlePrincipalBlur = (foreman: string) => {
|
||||
validatePrincipal(foreman);
|
||||
};
|
||||
|
||||
// 对外暴露的校验方法
|
||||
|
||||
@ -171,7 +171,26 @@ export default forwardRef<OrderOptionRef, IOrderOptionProps>(
|
||||
// 空箱
|
||||
orderPackageList: value.orderPackageList,
|
||||
// 费用
|
||||
orderCostList: value.orderCostList.filter((item) => item.selected),
|
||||
orderCostList: value.orderCostList.filter((item) => {
|
||||
if (item.type === "PRODUCTION_TYPE") {
|
||||
return item.selected;
|
||||
}
|
||||
|
||||
if (
|
||||
item.type === "ARTIFICIAL_TYPE" ||
|
||||
item.type === "MATERIAL_TYPE"
|
||||
) {
|
||||
return (
|
||||
value.orderCostItemList.filter(
|
||||
(orderCostItem) =>
|
||||
item.costItemIds?.includes(orderCostItem.costItemId!) &&
|
||||
orderCostItem.selected,
|
||||
).length > 0
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
}),
|
||||
orderCostItemList: value.orderCostItemList.filter(
|
||||
(item) => item.selected,
|
||||
),
|
||||
@ -190,36 +209,18 @@ export default forwardRef<OrderOptionRef, IOrderOptionProps>(
|
||||
};
|
||||
|
||||
const onFinish = async () => {
|
||||
Dialog.open("dialog", {
|
||||
title: "预览确认",
|
||||
content: "即将保存并预览当前采购订单,确定要继续吗?",
|
||||
confirmText: "确认预览",
|
||||
cancelText: "取消",
|
||||
onConfirm: async () => {
|
||||
// 只保存第六步的人工和辅料信息
|
||||
const costSuccess = await saveCostInfo();
|
||||
if (!costSuccess) {
|
||||
Dialog.close("dialog");
|
||||
return;
|
||||
}
|
||||
// 只保存第六步的人工和辅料信息
|
||||
const costSuccess = await saveCostInfo();
|
||||
if (!costSuccess) {
|
||||
Dialog.close("dialog");
|
||||
return;
|
||||
}
|
||||
|
||||
Toast.show("toast", {
|
||||
icon: "success",
|
||||
title: "提示",
|
||||
content: "保存成功,正在跳转预览...",
|
||||
});
|
||||
|
||||
// 跳转到预览页面
|
||||
Taro.redirectTo({
|
||||
url: buildUrl("/pages/purchase/enter/preview", {
|
||||
orderId: value.orderId,
|
||||
}),
|
||||
});
|
||||
Dialog.close("dialog");
|
||||
},
|
||||
onCancel: () => {
|
||||
Dialog.close("dialog");
|
||||
},
|
||||
// 跳转到预览页面
|
||||
Taro.redirectTo({
|
||||
url: buildUrl("/pages/purchase/enter/preview", {
|
||||
orderId: value.orderId,
|
||||
}),
|
||||
});
|
||||
};
|
||||
|
||||
@ -452,7 +453,7 @@ export default forwardRef<OrderOptionRef, IOrderOptionProps>(
|
||||
setLoading(true);
|
||||
// 第六步(人工辅料费用)时进行校验
|
||||
if (
|
||||
orderCostRef.current?.validate() ||
|
||||
orderCostRef.current?.validate() &&
|
||||
orderCostItemRef.current?.validate()
|
||||
) {
|
||||
await onFinish();
|
||||
|
||||
@ -1,5 +1,13 @@
|
||||
import { ScrollView, Text, View } from "@tarojs/components";
|
||||
import { Button, Input, Popup, Radio, SafeArea } from "@nutui/nutui-react-taro";
|
||||
import {
|
||||
Button,
|
||||
DatePicker,
|
||||
Input,
|
||||
PickerOption,
|
||||
Popup,
|
||||
Radio,
|
||||
SafeArea,
|
||||
} from "@nutui/nutui-react-taro";
|
||||
import dayjs from "dayjs";
|
||||
import { formatCurrency } from "@/utils";
|
||||
import { useEffect, useState } from "react";
|
||||
@ -15,6 +23,34 @@ export default function BasicInfoSection(props: {
|
||||
|
||||
const { orderVehicle } = purchaseOrderVO;
|
||||
|
||||
// 当天和未来10天
|
||||
const startDate = new Date();
|
||||
const endDate = new Date(startDate.getTime() + 86400000 * 10);
|
||||
const [show, setShow] = useState(false);
|
||||
|
||||
const formatter = (type: string, option: PickerOption) => {
|
||||
switch (type) {
|
||||
case "year":
|
||||
option.label += "年";
|
||||
break;
|
||||
case "month":
|
||||
option.label += "月";
|
||||
break;
|
||||
case "day":
|
||||
option.label += "日";
|
||||
break;
|
||||
case "hour":
|
||||
option.label += "时";
|
||||
break;
|
||||
case "minute":
|
||||
option.label += "分";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return option;
|
||||
};
|
||||
|
||||
// 弹窗可见状态
|
||||
const [visiblePopup, setVisiblePopup] = useState({
|
||||
basicInfo: false, // 基础信息弹窗
|
||||
@ -40,9 +76,11 @@ export default function BasicInfoSection(props: {
|
||||
const [loadingLastVehicleNo, setLoadingLastVehicleNo] = useState(false);
|
||||
|
||||
// 获取上一车次号
|
||||
const fetchLastVehicleNo = async () => {
|
||||
const fetchLastVehicleNo = async (
|
||||
dealerId: BusinessAPI.DealerVO["dealerId"],
|
||||
) => {
|
||||
// 如果已经有车次号,则不需要获取上一车次号
|
||||
if (orderVehicle?.vehicleNo) {
|
||||
if (orderVehicle?.vehicleNo || !dealerId) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -55,7 +93,9 @@ export default function BasicInfoSection(props: {
|
||||
try {
|
||||
const { data: res } =
|
||||
await businessServices.purchaseOrder.getLastVehicleNo({
|
||||
lastVehicleNoQry: {},
|
||||
lastVehicleNoQry: {
|
||||
dealerId: purchaseOrderVO.orderDealer.dealerId,
|
||||
},
|
||||
});
|
||||
|
||||
if (res.success && res.data) {
|
||||
@ -83,8 +123,8 @@ export default function BasicInfoSection(props: {
|
||||
|
||||
// 组件加载时获取上一车次号
|
||||
useEffect(() => {
|
||||
fetchLastVehicleNo();
|
||||
}, []);
|
||||
fetchLastVehicleNo(purchaseOrderVO.orderDealer.dealerId);
|
||||
}, [purchaseOrderVO.orderDealer.dealerId]);
|
||||
|
||||
// 打开基础信息弹窗
|
||||
const openBasicInfoPopup = () => {
|
||||
@ -246,26 +286,48 @@ export default function BasicInfoSection(props: {
|
||||
/>
|
||||
</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={"text"}
|
||||
value={editValues.deliveryTime}
|
||||
onChange={(value) => {
|
||||
setEditValues((prev) => ({
|
||||
...prev,
|
||||
deliveryTime: value,
|
||||
}));
|
||||
}}
|
||||
/>
|
||||
<View>
|
||||
<View className="mb-1 block text-sm font-normal text-[#000000]">
|
||||
发货日期
|
||||
</View>
|
||||
<View
|
||||
className={
|
||||
"border-neutral-base flex flex-row 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={() => setShow(true)}
|
||||
>
|
||||
<View className={"text-sm"}>
|
||||
{editValues.deliveryTime || "请输入发货日期"}
|
||||
</View>
|
||||
<Icon name={"chevron-down"} />
|
||||
</View>
|
||||
<DatePicker
|
||||
title="发货时间选择"
|
||||
type="date"
|
||||
startDate={startDate}
|
||||
endDate={endDate}
|
||||
visible={show}
|
||||
defaultValue={new Date()}
|
||||
formatter={formatter}
|
||||
onClose={() => setShow(false)}
|
||||
onConfirm={(_, values) => {
|
||||
setEditValues((prev) => ({
|
||||
...prev,
|
||||
deliveryTime: dayjs(values.join("-")).format(
|
||||
"YYYY-MM-DD",
|
||||
),
|
||||
}));
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className={"text-neutral-darkest text-sm font-medium"}>
|
||||
|
||||
@ -10,13 +10,14 @@ export default function CostDifferenceSection(props: {
|
||||
}) {
|
||||
const { purchaseOrderVO, onChange, readOnly, calculator } = props;
|
||||
const orderDealer = purchaseOrderVO.orderDealer;
|
||||
console.log("calculator.getShareProfit()", calculator.getShareProfit());
|
||||
|
||||
return (
|
||||
<View className={"flex flex-col gap-2.5"}>
|
||||
{/* 卡片形式展示分成信息 */}
|
||||
<View className="bg-primary/3 rounded-lg border-b border-gray-100 p-2.5">
|
||||
<View className="mb-2">
|
||||
<Text className="text-sm font-medium">分成</Text>
|
||||
<Text className="text-sm font-medium">待分红金额</Text>
|
||||
</View>
|
||||
|
||||
<View className="flex">
|
||||
@ -37,22 +38,20 @@ export default function CostDifferenceSection(props: {
|
||||
},
|
||||
});
|
||||
}}
|
||||
readOnly={readOnly || !orderDealer?.shareAdjusted}
|
||||
label={orderDealer?.shareAdjusted ? "调分成金额" : "分成金额"}
|
||||
readOnly={readOnly}
|
||||
label={"调整的金额"}
|
||||
unit="元"
|
||||
hint="点击金额可直接编辑"
|
||||
negative
|
||||
/>
|
||||
|
||||
<View className="flex flex-1 flex-col gap-2 pl-4">
|
||||
<View className="flex items-center justify-between">
|
||||
<Text className="text-sm text-gray-500">分成利润</Text>
|
||||
<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">
|
||||
¥{" "}
|
||||
{formatCurrency(
|
||||
orderDealer.profitSharing || calculator.getShareProfit() || 0,
|
||||
)}
|
||||
¥ {formatCurrency(calculator.getShareProfit() || 0)}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { View } from "@tarojs/components";
|
||||
import { DeliveryStep1Form } from "@/components";
|
||||
import {
|
||||
convertPurchaseOrderToShipOrder,
|
||||
@ -21,10 +20,10 @@ export default function DeliveryFormSection(props: {
|
||||
? purchaseOrderVO.shipOrderVOList[0]
|
||||
: convertPurchaseOrderToShipOrder(purchaseOrderVO);
|
||||
|
||||
const init = async (shipOrderVO: BusinessAPI.ShipOrderVO) => {
|
||||
const init = async (purchaseOrderVO: BusinessAPI.PurchaseOrderVO) => {
|
||||
const { data } = await business.dealer.showDealer({
|
||||
dealerShowQry: {
|
||||
dealerId: shipOrderVO.dealerId,
|
||||
dealerId: purchaseOrderVO.orderDealer.dealerId,
|
||||
},
|
||||
});
|
||||
|
||||
@ -36,14 +35,15 @@ export default function DeliveryFormSection(props: {
|
||||
template,
|
||||
convertedData,
|
||||
);
|
||||
console.log("updatedTemplate", updatedTemplate);
|
||||
setModuleList(updatedTemplate);
|
||||
} else {
|
||||
setModuleList([]);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
init(shipOrderVO);
|
||||
}, []);
|
||||
init(purchaseOrderVO);
|
||||
}, [purchaseOrderVO]);
|
||||
|
||||
// 更新模板配置
|
||||
const updateTemplateConfig = async (template: any[], data: any) => {
|
||||
@ -64,18 +64,16 @@ export default function DeliveryFormSection(props: {
|
||||
}
|
||||
|
||||
return (
|
||||
<View className={"flex flex-col gap-2.5"}>
|
||||
<DeliveryStep1Form
|
||||
readOnly={readOnly}
|
||||
moduleList={moduleList}
|
||||
shipOrderVO={shipOrderVO}
|
||||
setShipOrderVO={(shipOrderVO) => {
|
||||
onChange?.({
|
||||
...purchaseOrderVO,
|
||||
shipOrderVOList: [shipOrderVO],
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
<DeliveryStep1Form
|
||||
readOnly={readOnly}
|
||||
moduleList={moduleList}
|
||||
shipOrderVO={shipOrderVO}
|
||||
setShipOrderVO={(shipOrderVO) => {
|
||||
onChange?.({
|
||||
...purchaseOrderVO,
|
||||
shipOrderVOList: [shipOrderVO],
|
||||
});
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@ -12,18 +12,10 @@ export default function EmptyBoxInfoSection(props: {
|
||||
const { purchaseOrderVO, onChange, readOnly } = props;
|
||||
|
||||
const defaultColumns = [
|
||||
{
|
||||
title: "品牌",
|
||||
key: "boxBrandName",
|
||||
fixed: "left",
|
||||
},
|
||||
{
|
||||
title: "规格",
|
||||
key: "boxSpecName",
|
||||
},
|
||||
{
|
||||
title: "纸箱型号",
|
||||
key: "boxProductName",
|
||||
fixed: "left",
|
||||
},
|
||||
{
|
||||
title: "个数",
|
||||
@ -95,87 +87,11 @@ export default function EmptyBoxInfoSection(props: {
|
||||
orderPackageId?: string;
|
||||
isTotalRow?: boolean;
|
||||
},
|
||||
) => {
|
||||
// 合计行不显示编辑按钮
|
||||
if (value.isTotalRow) {
|
||||
return formatCurrency(value.boxProductWeight);
|
||||
}
|
||||
|
||||
return (
|
||||
<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>
|
||||
);
|
||||
},
|
||||
) => formatCurrency(value.boxProductWeight),
|
||||
},
|
||||
{
|
||||
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>
|
||||
);
|
||||
},
|
||||
title: "品牌",
|
||||
key: "boxBrandName",
|
||||
},
|
||||
];
|
||||
const [columns, setColumns] = useState<any[]>(defaultColumns);
|
||||
@ -194,55 +110,38 @@ export default function EmptyBoxInfoSection(props: {
|
||||
// 编辑值的状态
|
||||
const [editValues, setEditValues] = useState<{
|
||||
[key: string]: {
|
||||
boxCostPrice?: number;
|
||||
boxSalePrice?: number;
|
||||
boxProductWeight?: number;
|
||||
};
|
||||
}>({});
|
||||
|
||||
// 临时编辑值的状态(用于在保存前暂存编辑的值)
|
||||
const [tempEditValues, setTempEditValues] = useState<{
|
||||
[key: string]: {
|
||||
boxCostPrice?: number;
|
||||
boxSalePrice?: number;
|
||||
boxProductWeight?: number;
|
||||
};
|
||||
}>({});
|
||||
|
||||
// 初始化编辑值
|
||||
const initEditValues = (
|
||||
pkgId: string,
|
||||
boxCostPrice?: number,
|
||||
boxSalePrice?: number,
|
||||
boxProductWeight?: number,
|
||||
) => {
|
||||
const initEditValues = (pkgId: string, boxSalePrice?: number) => {
|
||||
const updates: {
|
||||
editValuesUpdate?: {
|
||||
boxCostPrice?: number;
|
||||
boxSalePrice?: number;
|
||||
boxProductWeight?: number;
|
||||
};
|
||||
tempEditValuesUpdate?: {
|
||||
boxCostPrice?: number;
|
||||
boxSalePrice?: number;
|
||||
boxProductWeight?: number;
|
||||
};
|
||||
} = {};
|
||||
|
||||
if (!editValues[pkgId]) {
|
||||
updates.editValuesUpdate = {
|
||||
boxCostPrice,
|
||||
boxSalePrice,
|
||||
boxProductWeight,
|
||||
};
|
||||
}
|
||||
|
||||
// 同时初始化临时编辑值
|
||||
if (!tempEditValues[pkgId]) {
|
||||
updates.tempEditValuesUpdate = {
|
||||
boxCostPrice,
|
||||
boxSalePrice,
|
||||
boxProductWeight,
|
||||
};
|
||||
}
|
||||
|
||||
@ -288,25 +187,21 @@ export default function EmptyBoxInfoSection(props: {
|
||||
// 计算各项合计
|
||||
let totalBoxProductCount = 0;
|
||||
let totalBoxSalePayment = 0;
|
||||
let totalBoxCostPayment = 0;
|
||||
let totalBoxProductWeight = 0;
|
||||
|
||||
packageData.forEach((pkg: any) => {
|
||||
totalBoxProductCount += pkg.boxProductCount || 0;
|
||||
totalBoxSalePayment +=
|
||||
Number((pkg?.boxSalePrice || 0) * pkg.boxProductCount) || 0;
|
||||
totalBoxCostPayment +=
|
||||
Number((pkg?.boxCostPrice || 0) * pkg.boxProductCount) || 0;
|
||||
totalBoxProductWeight +=
|
||||
Number((pkg?.boxProductWeight || 0) * pkg.boxProductCount) || 0;
|
||||
});
|
||||
|
||||
return {
|
||||
boxBrandName: "合计",
|
||||
boxProductName: "合计",
|
||||
boxProductCount: totalBoxProductCount,
|
||||
boxSalePayment: totalBoxSalePayment,
|
||||
boxProductWeight: totalBoxProductWeight,
|
||||
boxCostPrice: totalBoxCostPayment,
|
||||
isTotalRow: true, // 标记这是合计行
|
||||
};
|
||||
};
|
||||
@ -322,12 +217,7 @@ export default function EmptyBoxInfoSection(props: {
|
||||
|
||||
packageData.forEach((pkg: BusinessAPI.OrderPackage) => {
|
||||
const pkgId = pkg.orderPackageId || "";
|
||||
const updates = initEditValues(
|
||||
pkgId,
|
||||
pkg.boxCostPrice,
|
||||
pkg.boxSalePrice,
|
||||
pkg.boxProductWeight,
|
||||
);
|
||||
const updates = initEditValues(pkgId, pkg.boxSalePrice);
|
||||
|
||||
if (updates.editValuesUpdate) {
|
||||
newEditValues[pkgId] = updates.editValuesUpdate;
|
||||
@ -364,18 +254,10 @@ export default function EmptyBoxInfoSection(props: {
|
||||
if (editValue) {
|
||||
return {
|
||||
...pkg,
|
||||
boxCostPrice:
|
||||
editValue.boxCostPrice !== undefined
|
||||
? editValue.boxCostPrice
|
||||
: pkg.boxCostPrice,
|
||||
boxSalePrice:
|
||||
editValue.boxSalePrice !== undefined
|
||||
? editValue.boxSalePrice
|
||||
: pkg.boxSalePrice,
|
||||
boxProductWeight:
|
||||
editValue.boxProductWeight !== undefined
|
||||
? editValue.boxProductWeight
|
||||
: pkg.boxProductWeight,
|
||||
};
|
||||
}
|
||||
return pkg;
|
||||
@ -397,7 +279,7 @@ export default function EmptyBoxInfoSection(props: {
|
||||
|
||||
// 自定义列配置,对合计行特殊处理
|
||||
const columnsWithTotalsRender = columns.map((column) => {
|
||||
if (column.key === "boxBrandName") {
|
||||
if (column.key === "boxProductName") {
|
||||
// 品牌列显示"合计"
|
||||
return {
|
||||
...column,
|
||||
@ -405,11 +287,11 @@ export default function EmptyBoxInfoSection(props: {
|
||||
if (rowData.isTotalRow) {
|
||||
return (
|
||||
<span style={{ fontWeight: "bold" }}>
|
||||
{rowData.boxBrandName}
|
||||
{rowData.boxProductName}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
return rowData.boxBrandName;
|
||||
return rowData.boxProductName;
|
||||
},
|
||||
};
|
||||
} else if (column.key === "boxProductCount") {
|
||||
@ -476,21 +358,6 @@ export default function EmptyBoxInfoSection(props: {
|
||||
return column.render(rowData, rowData);
|
||||
},
|
||||
};
|
||||
} else if (column.key === "boxCostPrice") {
|
||||
// 成本单价列合计行处理
|
||||
return {
|
||||
...column,
|
||||
render: (rowData: any) => {
|
||||
if (rowData.isTotalRow) {
|
||||
return (
|
||||
<span style={{ fontWeight: "bold" }}>
|
||||
{formatCurrency(rowData.boxCostPrice as number)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
return column.render(rowData, rowData);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// 其他列保持原有render函数或者默认显示
|
||||
@ -566,66 +433,6 @@ export default function EmptyBoxInfoSection(props: {
|
||||
/>
|
||||
<View className="mr-2">元</View>
|
||||
</View>
|
||||
|
||||
<View className="text-neutral-darkest flex flex-row text-sm font-medium">
|
||||
<Icon name="money-bill" size={16} className="mr-1" />
|
||||
成本单价
|
||||
</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 flex flex-row text-sm font-medium">
|
||||
<Icon name="weight-scale" size={16} className="mr-1" />
|
||||
箱重
|
||||
</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">
|
||||
|
||||
@ -87,47 +87,11 @@ export default function PackageInfoSection(props: {
|
||||
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>
|
||||
);
|
||||
},
|
||||
) => formatCurrency(value.boxProductWeight),
|
||||
},
|
||||
{
|
||||
title: "品牌",
|
||||
key: "boxBrandName",
|
||||
fixed: "left",
|
||||
},
|
||||
];
|
||||
const [columns, setColumns] = useState<any[]>(defaultColumns);
|
||||
@ -146,55 +110,38 @@ export default function PackageInfoSection(props: {
|
||||
// 编辑值的状态
|
||||
const [editValues, setEditValues] = useState<{
|
||||
[key: string]: {
|
||||
boxCostPrice?: number;
|
||||
boxSalePrice?: number;
|
||||
boxProductWeight?: number;
|
||||
};
|
||||
}>({});
|
||||
|
||||
// 临时编辑值的状态(用于在保存前暂存编辑的值)
|
||||
const [tempEditValues, setTempEditValues] = useState<{
|
||||
[key: string]: {
|
||||
boxCostPrice?: number;
|
||||
boxSalePrice?: number;
|
||||
boxProductWeight?: number;
|
||||
};
|
||||
}>({});
|
||||
|
||||
// 初始化编辑值
|
||||
const initEditValues = (
|
||||
pkgId: string,
|
||||
boxCostPrice?: number,
|
||||
boxSalePrice?: number,
|
||||
boxProductWeight?: number,
|
||||
) => {
|
||||
const initEditValues = (pkgId: string, boxSalePrice?: number) => {
|
||||
const updates: {
|
||||
editValuesUpdate?: {
|
||||
boxCostPrice?: number;
|
||||
boxSalePrice?: number;
|
||||
boxProductWeight?: number;
|
||||
};
|
||||
tempEditValuesUpdate?: {
|
||||
boxCostPrice?: number;
|
||||
boxSalePrice?: number;
|
||||
boxProductWeight?: number;
|
||||
};
|
||||
} = {};
|
||||
|
||||
if (!editValues[pkgId]) {
|
||||
updates.editValuesUpdate = {
|
||||
boxCostPrice,
|
||||
boxSalePrice,
|
||||
boxProductWeight,
|
||||
};
|
||||
}
|
||||
|
||||
// 同时初始化临时编辑值
|
||||
if (!tempEditValues[pkgId]) {
|
||||
updates.tempEditValuesUpdate = {
|
||||
boxCostPrice,
|
||||
boxSalePrice,
|
||||
boxProductWeight,
|
||||
};
|
||||
}
|
||||
|
||||
@ -244,15 +191,12 @@ export default function PackageInfoSection(props: {
|
||||
// 计算各项合计
|
||||
let totalBoxProductCount = 0;
|
||||
let totalBoxSalePayment = 0;
|
||||
let totalBoxCostPayment = 0;
|
||||
let totalBoxProductWeight = 0;
|
||||
|
||||
packageData.forEach((pkg: any) => {
|
||||
totalBoxProductCount += pkg.boxProductCount || 0;
|
||||
totalBoxSalePayment +=
|
||||
Number((pkg?.boxSalePrice || 0) * pkg.boxProductCount) || 0;
|
||||
totalBoxCostPayment +=
|
||||
Number((pkg?.boxCostPrice || 0) * pkg.boxProductCount) || 0;
|
||||
totalBoxProductWeight +=
|
||||
Number((pkg?.boxProductWeight || 0) * pkg.boxProductCount) || 0;
|
||||
});
|
||||
@ -262,7 +206,6 @@ export default function PackageInfoSection(props: {
|
||||
boxProductCount: totalBoxProductCount,
|
||||
boxSalePayment: totalBoxSalePayment,
|
||||
boxProductWeight: totalBoxProductWeight,
|
||||
boxCostPrice: totalBoxCostPayment,
|
||||
isTotalRow: true, // 标记这是合计行
|
||||
};
|
||||
};
|
||||
@ -278,12 +221,7 @@ export default function PackageInfoSection(props: {
|
||||
|
||||
packageData.forEach((pkg: BusinessAPI.OrderPackage) => {
|
||||
const pkgId = pkg.orderPackageId || "";
|
||||
const updates = initEditValues(
|
||||
pkgId,
|
||||
pkg.boxCostPrice,
|
||||
pkg.boxSalePrice,
|
||||
pkg.boxProductWeight,
|
||||
);
|
||||
const updates = initEditValues(pkgId, pkg.boxSalePrice);
|
||||
|
||||
if (updates.editValuesUpdate) {
|
||||
newEditValues[pkgId] = updates.editValuesUpdate;
|
||||
@ -323,18 +261,10 @@ export default function PackageInfoSection(props: {
|
||||
if (editValue) {
|
||||
return {
|
||||
...pkg,
|
||||
boxCostPrice:
|
||||
editValue.boxCostPrice !== undefined
|
||||
? editValue.boxCostPrice
|
||||
: pkg.boxCostPrice,
|
||||
boxSalePrice:
|
||||
editValue.boxSalePrice !== undefined
|
||||
? editValue.boxSalePrice
|
||||
: pkg.boxSalePrice,
|
||||
boxProductWeight:
|
||||
editValue.boxProductWeight !== undefined
|
||||
? editValue.boxProductWeight
|
||||
: pkg.boxProductWeight,
|
||||
};
|
||||
}
|
||||
return pkg;
|
||||
@ -518,36 +448,6 @@ export default function PackageInfoSection(props: {
|
||||
/>
|
||||
<View className="mr-2">元</View>
|
||||
</View>
|
||||
|
||||
<View className="text-neutral-darkest flex flex-row text-sm font-medium">
|
||||
<Icon name="weight-scale" size={16} className="mr-1" />
|
||||
箱重
|
||||
</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">
|
||||
|
||||
@ -38,7 +38,12 @@ import {
|
||||
TaxSubsidySection,
|
||||
WorkerAdvanceSection,
|
||||
} from "@/components";
|
||||
import { buildUrl, formatCurrency, PurchaseOrderCalculator } from "@/utils";
|
||||
import {
|
||||
buildUrl,
|
||||
formatCurrency,
|
||||
generateShortId,
|
||||
PurchaseOrderCalculator,
|
||||
} from "@/utils";
|
||||
import classNames from "classnames";
|
||||
|
||||
const defaultSections = [
|
||||
@ -179,11 +184,11 @@ const fullSections = [
|
||||
component: TaxProvisionSection,
|
||||
title: "计提税金复核",
|
||||
},
|
||||
// 调诚信志远分红
|
||||
// 待分红金额复核
|
||||
{
|
||||
name: "costDifference",
|
||||
component: CostDifferenceSection,
|
||||
title: "调诚信志远分红",
|
||||
title: "待分红金额复核",
|
||||
},
|
||||
// 成本合计
|
||||
{
|
||||
@ -215,24 +220,6 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
// 费用项目列表
|
||||
const [costList, setCostList] = useState<BusinessAPI.CostVO[]>([]);
|
||||
|
||||
// 获取费用项目列表
|
||||
useEffect(() => {
|
||||
const fetchCost = async () => {
|
||||
try {
|
||||
const { data } = await business.cost.listCost({
|
||||
costListQry: {
|
||||
status: true,
|
||||
},
|
||||
});
|
||||
setCostList(data.data || []);
|
||||
} catch (error) {
|
||||
console.error("获取费用项目列表失败:", error);
|
||||
}
|
||||
};
|
||||
|
||||
fetchCost();
|
||||
}, []);
|
||||
|
||||
const [purchaseOrderVO, setPurchaseOrderVO] =
|
||||
useState<BusinessAPI.PurchaseOrderVO>();
|
||||
|
||||
@ -449,16 +436,63 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
};
|
||||
|
||||
const init = async (orderId: BusinessAPI.PurchaseOrderVO["orderId"]) => {
|
||||
const { data } = await business.purchaseOrder.showPurchaseOrder({
|
||||
const {
|
||||
data: { data: purchaseOrderVO, success },
|
||||
} = await business.purchaseOrder.showPurchaseOrder({
|
||||
purchaseOrderShowQry: {
|
||||
orderId,
|
||||
},
|
||||
});
|
||||
|
||||
if (data.success) {
|
||||
setPurchaseOrderVO(data.data);
|
||||
if (success && purchaseOrderVO) {
|
||||
await initDealer(purchaseOrderVO?.orderDealer?.dealerId!);
|
||||
|
||||
await initDealer(data.data?.orderDealer?.dealerId!);
|
||||
const orderCost = purchaseOrderVO?.orderCostList.find(
|
||||
(item) => item.name === "计提费" && item.type === "OTHER_TYPE",
|
||||
);
|
||||
|
||||
if (orderCost) {
|
||||
await business.cost
|
||||
.listCost({
|
||||
costListQry: {
|
||||
status: true,
|
||||
},
|
||||
})
|
||||
.then(({ data: { data: costList } }) => {
|
||||
setCostList(costList || []);
|
||||
});
|
||||
} else {
|
||||
const {
|
||||
data: { data: costList },
|
||||
} = await business.cost.listCost({
|
||||
costListQry: {
|
||||
status: true,
|
||||
},
|
||||
});
|
||||
|
||||
setCostList(costList || []);
|
||||
|
||||
const cost = costList?.find(
|
||||
(cost) => cost.name === "计提费" && cost.type === "OTHER_TYPE",
|
||||
);
|
||||
|
||||
if (cost) {
|
||||
purchaseOrderVO.orderCostList.push({
|
||||
orderCostId: generateShortId(),
|
||||
costId: cost.costId || "",
|
||||
name: cost.name || "",
|
||||
price: cost.price || 0,
|
||||
unit: cost.unit || "元",
|
||||
count: 1,
|
||||
type: "OTHER_TYPE",
|
||||
costItemIds: [],
|
||||
principal: "",
|
||||
selected: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
setPurchaseOrderVO(purchaseOrderVO);
|
||||
}
|
||||
};
|
||||
|
||||
@ -567,7 +601,10 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!orderDealer?.enableShare && sectionKey === "costDifference") {
|
||||
if (
|
||||
!orderDealer?.shareAdjusted &&
|
||||
sectionKey === "costDifference"
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -603,7 +640,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<View key={sectionKey} className={"flex flex-col gap-2.5"}>
|
||||
<View className="text-sm font-bold">{section.title}</View>
|
||||
<View
|
||||
className={`overflow-x-auto rounded-md rounded-b-lg bg-white p-2.5 shadow-sm`}
|
||||
@ -612,12 +649,12 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
readOnly={purchaseOrderVO.state !== "WAITING_AUDIT"}
|
||||
purchaseOrderVO={purchaseOrderVO}
|
||||
onChange={setPurchaseOrderVO}
|
||||
//@ts-ignore
|
||||
// @ts-ignore
|
||||
costList={costList}
|
||||
calculator={calculator}
|
||||
/>
|
||||
</View>
|
||||
</>
|
||||
</View>
|
||||
);
|
||||
})}
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ export class PurchaseOrderCalculator {
|
||||
{
|
||||
分成利润: this.getShareProfit(),
|
||||
西瓜利润: this.getMelonNetProfit(),
|
||||
诚信志远分成: this.getShareProfitRatio(),
|
||||
分成: this.getShareProfitRatio(),
|
||||
个人利润: this.getPersonalProfit(),
|
||||
},
|
||||
]);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user