Compare commits
2 Commits
47c7bdf357
...
d467e25a76
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d467e25a76 | ||
|
|
1676290798 |
@ -1,6 +1,7 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { Input, Text, View } from "@tarojs/components";
|
||||
import { Icon, IconNames } from "@/components";
|
||||
import { formatCurrency } from "@/utils";
|
||||
|
||||
interface PriceEditorProps {
|
||||
value: number;
|
||||
@ -61,6 +62,13 @@ export default function PriceEditor(props: PriceEditorProps) {
|
||||
setIsEditing(false);
|
||||
};
|
||||
|
||||
// 清空输入
|
||||
const clearValue = (e: any) => {
|
||||
e.stopPropagation();
|
||||
setInputValue("");
|
||||
onSave(0);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{!readOnly ? (
|
||||
@ -73,7 +81,7 @@ export default function PriceEditor(props: PriceEditorProps) {
|
||||
<Text className="text-sm text-gray-500">{unit}</Text>
|
||||
</View>
|
||||
{isEditing ? (
|
||||
<View className="relative flex">
|
||||
<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">
|
||||
<Input
|
||||
ref={inputRef}
|
||||
@ -82,13 +90,36 @@ export default function PriceEditor(props: PriceEditorProps) {
|
||||
onInput={handleInputChange}
|
||||
onBlur={saveEdit}
|
||||
/>
|
||||
{inputValue !== "" && (
|
||||
<Icon
|
||||
name="circle-xmark"
|
||||
size={20}
|
||||
className="ml-2 cursor-pointer"
|
||||
onClick={clearValue}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
) : (
|
||||
<View className="relative flex" onClick={() => setIsEditing(true)}>
|
||||
<View
|
||||
className="relative flex flex-1 items-end"
|
||||
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">
|
||||
{value?.toFixed(2) || "0"}
|
||||
{formatCurrency(value || 0)}
|
||||
</Text>
|
||||
<Icon
|
||||
name={value !== 0 ? "circle-xmark" : "pen-to-square"}
|
||||
size={20}
|
||||
className="absolute right-0 bottom-2 ml-2 cursor-pointer"
|
||||
onClick={(event) => {
|
||||
if (value !== 0) {
|
||||
clearValue(event);
|
||||
} else {
|
||||
setIsEditing(true);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
<View className="mt-1 text-xs text-gray-400">{hint}</View>
|
||||
@ -104,7 +135,7 @@ export default function PriceEditor(props: PriceEditorProps) {
|
||||
</View>
|
||||
<View className="relative">
|
||||
<Text className="w-full py-2 text-3xl font-bold text-red-500">
|
||||
{value?.toFixed(2) || "0"}
|
||||
{formatCurrency(value || 0)}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@ -10,6 +10,7 @@ import dayjs from "dayjs";
|
||||
import { Icon } from "@/components";
|
||||
|
||||
interface Step1FormProps {
|
||||
readOnly?: boolean;
|
||||
moduleList: any[];
|
||||
shipOrderVO: any;
|
||||
setShipOrderVO: (value: any) => void;
|
||||
@ -20,7 +21,7 @@ export interface Step1FormRef {
|
||||
}
|
||||
|
||||
const Step1Form = forwardRef<Step1FormRef, Step1FormProps>((props, ref) => {
|
||||
const { moduleList, shipOrderVO, setShipOrderVO } = props;
|
||||
const { moduleList, shipOrderVO, setShipOrderVO, readOnly = false } = props;
|
||||
|
||||
// 当天和未来10天
|
||||
const startDate = new Date();
|
||||
@ -94,6 +95,7 @@ const Step1Form = forwardRef<Step1FormRef, Step1FormProps>((props, ref) => {
|
||||
className={`flex h-10 w-full items-center rounded-md ${formErrors.watermelonGrade ? "border-4 border-red-500" : "border-4 border-gray-300"}`}
|
||||
>
|
||||
<Input
|
||||
disabled={readOnly}
|
||||
value={shipOrderVO?.watermelonGrade || ""}
|
||||
onChange={(value) => {
|
||||
// 清除错误状态
|
||||
@ -104,11 +106,9 @@ const Step1Form = forwardRef<Step1FormRef, Step1FormProps>((props, ref) => {
|
||||
}));
|
||||
}
|
||||
|
||||
setShipOrderVO((prev: any) => {
|
||||
return {
|
||||
...prev!,
|
||||
setShipOrderVO({
|
||||
...shipOrderVO!,
|
||||
watermelonGrade: value,
|
||||
};
|
||||
});
|
||||
}}
|
||||
onBlur={() => {
|
||||
@ -158,6 +158,7 @@ const Step1Form = forwardRef<Step1FormRef, Step1FormProps>((props, ref) => {
|
||||
className={`flex h-10 w-full items-center rounded-md ${formErrors.shippingAddress ? "border-4 border-red-500" : "border-4 border-gray-300"}`}
|
||||
>
|
||||
<Input
|
||||
disabled={readOnly}
|
||||
value={shipOrderVO?.shippingAddress || ""}
|
||||
onChange={(value) => {
|
||||
// 清除错误状态
|
||||
@ -168,11 +169,9 @@ const Step1Form = forwardRef<Step1FormRef, Step1FormProps>((props, ref) => {
|
||||
}));
|
||||
}
|
||||
|
||||
setShipOrderVO((prev: any) => {
|
||||
return {
|
||||
...prev!,
|
||||
setShipOrderVO({
|
||||
...shipOrderVO!,
|
||||
shippingAddress: value,
|
||||
};
|
||||
});
|
||||
}}
|
||||
onBlur={() => {
|
||||
@ -223,12 +222,13 @@ const Step1Form = forwardRef<Step1FormRef, Step1FormProps>((props, ref) => {
|
||||
>
|
||||
<View
|
||||
className={
|
||||
"flex flex-1 flex-row items-center justify-between px-5"
|
||||
"flex flex-1 flex-row items-center justify-between px-5" +
|
||||
(readOnly ? " opacity-50" : "")
|
||||
}
|
||||
style={{
|
||||
color: "var(--nutui-color-title, #1a1a1a)",
|
||||
}}
|
||||
onClick={() => setShow(true)}
|
||||
onClick={() => readOnly || setShow(true)}
|
||||
>
|
||||
<View className={"text-sm"}>
|
||||
{shipOrderVO?.estimatedArrivalDate
|
||||
@ -257,13 +257,11 @@ const Step1Form = forwardRef<Step1FormRef, Step1FormProps>((props, ref) => {
|
||||
}));
|
||||
}
|
||||
|
||||
setShipOrderVO((prev: any) => {
|
||||
return {
|
||||
...prev!,
|
||||
setShipOrderVO({
|
||||
...shipOrderVO!,
|
||||
estimatedArrivalDate: dayjs(values.join("-")).format(
|
||||
"YYYY-MM-DD",
|
||||
),
|
||||
};
|
||||
});
|
||||
}}
|
||||
/>
|
||||
@ -290,6 +288,7 @@ const Step1Form = forwardRef<Step1FormRef, Step1FormProps>((props, ref) => {
|
||||
className={`flex h-10 w-full items-center rounded-md ${formErrors.remark ? "border-4 border-red-500" : "border-4 border-gray-300"}`}
|
||||
>
|
||||
<Input
|
||||
disabled={readOnly}
|
||||
value={shipOrderVO?.remark || ""}
|
||||
onChange={(value) => {
|
||||
// 清除错误状态
|
||||
@ -300,11 +299,9 @@ const Step1Form = forwardRef<Step1FormRef, Step1FormProps>((props, ref) => {
|
||||
}));
|
||||
}
|
||||
|
||||
setShipOrderVO((prev: any) => {
|
||||
return {
|
||||
...prev!,
|
||||
setShipOrderVO({
|
||||
...shipOrderVO!,
|
||||
remark: value,
|
||||
};
|
||||
});
|
||||
}}
|
||||
onBlur={() => {
|
||||
@ -362,6 +359,7 @@ const Step1Form = forwardRef<Step1FormRef, Step1FormProps>((props, ref) => {
|
||||
className={`flex h-10 items-center rounded-md ${formErrors.itemGrades?.[shipOrderItem.itemId] ? "border-4 border-red-500" : "border-4 border-gray-300"}`}
|
||||
>
|
||||
<Input
|
||||
disabled={readOnly}
|
||||
value={shipOrderItem.watermelonGrade || ""}
|
||||
onChange={(value) => {
|
||||
// 清除该项的错误状态
|
||||
@ -378,10 +376,10 @@ const Step1Form = forwardRef<Step1FormRef, Step1FormProps>((props, ref) => {
|
||||
}));
|
||||
}
|
||||
|
||||
setShipOrderVO((prev: any) => {
|
||||
return {
|
||||
...prev!,
|
||||
shipOrderItemList: prev?.shipOrderItemList?.map(
|
||||
setShipOrderVO({
|
||||
...shipOrderVO!,
|
||||
shipOrderItemList:
|
||||
shipOrderVO?.shipOrderItemList?.map(
|
||||
(item: any) => {
|
||||
if (item.itemId === shipOrderItem.itemId) {
|
||||
return {
|
||||
@ -392,7 +390,6 @@ const Step1Form = forwardRef<Step1FormRef, Step1FormProps>((props, ref) => {
|
||||
return item;
|
||||
},
|
||||
),
|
||||
};
|
||||
});
|
||||
}}
|
||||
onBlur={() => {
|
||||
@ -552,7 +549,7 @@ const Step1Form = forwardRef<Step1FormRef, Step1FormProps>((props, ref) => {
|
||||
};
|
||||
|
||||
return (
|
||||
<View className="flex flex-col rounded-lg bg-white p-2.5 shadow-md">
|
||||
<View>
|
||||
{moduleList.map((module) => {
|
||||
const contentFields = renderContentFields(module);
|
||||
// 如果没有内容配置字段,则不渲染该模块
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { Text, View } from "@tarojs/components";
|
||||
import { useState } from "react";
|
||||
import { Dialog } from "@nutui/nutui-react-taro";
|
||||
import { Icon, PriceEditor } from "@/components";
|
||||
import { PriceEditor } from "@/components";
|
||||
import CostCreate from "./CostCreate";
|
||||
|
||||
interface CostCardComponentProps {
|
||||
@ -58,18 +58,21 @@ export default function CostCard(props: CostCardComponentProps) {
|
||||
<View className="mb-2 flex items-center justify-between">
|
||||
<Text className="text-sm font-medium">{orderCost.name}</Text>
|
||||
{!readOnly && (
|
||||
<View className="flex flex-row gap-2.5">
|
||||
<Icon
|
||||
name="pen-to-square"
|
||||
size={16}
|
||||
<View className="flex gap-2">
|
||||
{orderCostItemList.length > 0 && (
|
||||
<View
|
||||
className="cursor-pointer rounded-lg bg-blue-100 px-3 py-1 text-xs font-medium text-blue-600 transition-colors hover:bg-blue-200"
|
||||
onClick={() => setShowEditModal(true)}
|
||||
/>
|
||||
<Icon
|
||||
name="circle-xmark"
|
||||
size={16}
|
||||
color={"var(--color-red-500)"}
|
||||
>
|
||||
编辑
|
||||
</View>
|
||||
)}
|
||||
<View
|
||||
className="cursor-pointer rounded-lg bg-red-100 px-3 py-1 text-xs font-medium text-red-600 transition-colors hover:bg-red-200"
|
||||
onClick={handleDelete}
|
||||
/>
|
||||
>
|
||||
删除
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
@ -94,6 +97,7 @@ export default function CostCard(props: CostCardComponentProps) {
|
||||
hint="点击金额可直接编辑"
|
||||
/>
|
||||
|
||||
{orderCostItemList.length > 0 && (
|
||||
<View className="flex flex-1 flex-col gap-2 pl-4">
|
||||
{orderCostItemList.map((orderCostItem) => {
|
||||
return (
|
||||
@ -111,6 +115,7 @@ export default function CostCard(props: CostCardComponentProps) {
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
|
||||
|
||||
@ -41,6 +41,7 @@ export { default as CostDifferenceSection } from "./section/CostDifferenceSectio
|
||||
export { default as MaterialCostSection } from "./section/MaterialCostSection";
|
||||
export { default as ProductionAdvanceSection } from "./section/ProductionAdvanceSection";
|
||||
export { default as WorkerAdvanceSection } from "./section/WorkerAdvanceSection";
|
||||
export { default as DeliveryFormSection } from "./section/DeliveryFormSection";
|
||||
|
||||
export { default as PurchaseStep1Form } from "./document/Step1Form";
|
||||
export type { Step1FormRef as PurchaseStep1FormRef } from "./document/Step1Form";
|
||||
|
||||
@ -128,7 +128,7 @@ export default function EmptyBoxModule(props: IEmptyBoxModuleProps) {
|
||||
initBoxBrandList().then();
|
||||
setEmptyBoxList(orderPackageList);
|
||||
|
||||
if (orderPackageList.length > 0) {
|
||||
if (orderPackageList?.length > 0) {
|
||||
// 根据当前供应商确定需要检查的纸箱类型
|
||||
let requiredTypes: string[] = ["EMPTY"];
|
||||
|
||||
|
||||
@ -549,6 +549,7 @@ export default forwardRef<MelonFarmerRef, IMelonFarmerProps>(
|
||||
});
|
||||
};
|
||||
|
||||
console.log("supplierVO", supplierVO);
|
||||
if (!supplierVO) {
|
||||
return;
|
||||
}
|
||||
@ -588,9 +589,9 @@ export default forwardRef<MelonFarmerRef, IMelonFarmerProps>(
|
||||
<Radio.Group
|
||||
direction="horizontal"
|
||||
value={
|
||||
supplierVO.isLast
|
||||
supplierVO.isLast === true
|
||||
? "true"
|
||||
: !supplierVO.isLast
|
||||
: supplierVO.isLast === false
|
||||
? "false"
|
||||
: undefined
|
||||
}
|
||||
|
||||
@ -3,7 +3,6 @@ import { Icon } from "@/components";
|
||||
import { forwardRef, useEffect, useImperativeHandle, useState } from "react";
|
||||
import { Checkbox, Input, Toast } from "@nutui/nutui-react-taro";
|
||||
import { generateShortId } from "@/utils";
|
||||
import { business } from "@/services";
|
||||
|
||||
// 定义ref暴露的方法接口
|
||||
export interface OrderCostRef {
|
||||
@ -30,38 +29,26 @@ export default forwardRef<OrderCostRef, IOrderCostProps>(
|
||||
|
||||
// 初始化函数
|
||||
const init = async (costIds: string[]) => {
|
||||
let newOrderCostList: BusinessAPI.OrderCost[] = [];
|
||||
// 创建一个映射,用于快速查找orderCostItemList中的项目
|
||||
const orderCostMap = new Map<string, BusinessAPI.OrderCost>();
|
||||
|
||||
// 获取成本列表
|
||||
const {
|
||||
data: { data: costList, success },
|
||||
} = await business.cost.listCost({
|
||||
costListQry: {
|
||||
status: true,
|
||||
},
|
||||
orderCostList?.forEach((item) => {
|
||||
if (item.costId && costIds.includes(item.costId)) {
|
||||
orderCostMap.set(item.costId, item);
|
||||
}
|
||||
});
|
||||
|
||||
if (success) {
|
||||
const newCostList = costList?.filter((item) => {
|
||||
return costIds.includes(item.costId);
|
||||
});
|
||||
// 构建初始列表,基于costTemplate中的项目
|
||||
const newOrderCostList: IOrderCost[] = [];
|
||||
|
||||
// 遍历costList,将costList中的项目添加到orderCostList中
|
||||
newCostList?.forEach((item) => {
|
||||
const orderCost = orderCostList.find(
|
||||
(cost) => cost.costId === item.costId,
|
||||
);
|
||||
parsedCostTemplate.productionTypeList?.forEach((item) => {
|
||||
const existingItem = orderCostMap.get(item.costItemId);
|
||||
|
||||
const selected = parsedCostTemplate.productionTypeList?.some(
|
||||
(cost) => {
|
||||
return cost.costId === item.costId;
|
||||
},
|
||||
);
|
||||
|
||||
if (orderCost) {
|
||||
if (existingItem) {
|
||||
newOrderCostList.push({
|
||||
...orderCost,
|
||||
selected: selected,
|
||||
...existingItem,
|
||||
selected: !!existingItem,
|
||||
});
|
||||
} else {
|
||||
newOrderCostList.push({
|
||||
@ -70,14 +57,13 @@ export default forwardRef<OrderCostRef, IOrderCostProps>(
|
||||
costId: item.costId,
|
||||
name: item.name,
|
||||
type: item.type,
|
||||
selected: selected,
|
||||
selected: false,
|
||||
count: 1,
|
||||
price: item.price || 0,
|
||||
unit: item.unit || "元",
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onChange?.({
|
||||
...value,
|
||||
|
||||
@ -47,8 +47,6 @@ export default forwardRef<OrderCostItemRef, IOrderCostItemProps>(
|
||||
}
|
||||
});
|
||||
|
||||
console.log("orderCostItemList,", orderCostItemList);
|
||||
|
||||
// 构建初始列表,基于costTemplate中的项目
|
||||
const newOrderCostItemList: IOrderCostItem[] = [];
|
||||
|
||||
@ -62,7 +60,7 @@ export default forwardRef<OrderCostItemRef, IOrderCostItemProps>(
|
||||
name: item.name,
|
||||
price: item.price,
|
||||
unit: item.unit,
|
||||
selected: true,
|
||||
selected: !!existingItem,
|
||||
count: existingItem?.count || 1,
|
||||
payerType: existingItem?.payerType,
|
||||
type: item.type,
|
||||
@ -82,7 +80,7 @@ export default forwardRef<OrderCostItemRef, IOrderCostItemProps>(
|
||||
name: item.name,
|
||||
price: item.price,
|
||||
unit: item.unit,
|
||||
selected: true,
|
||||
selected: !!existingItem,
|
||||
count: existingItem?.count || 1,
|
||||
payerType: existingItem?.payerType,
|
||||
type: item.type,
|
||||
@ -90,7 +88,6 @@ export default forwardRef<OrderCostItemRef, IOrderCostItemProps>(
|
||||
});
|
||||
});
|
||||
|
||||
console.log("newOrderCostItemList,", newOrderCostItemList);
|
||||
onChange?.({
|
||||
...value,
|
||||
orderCostItemList: newOrderCostItemList,
|
||||
|
||||
@ -41,7 +41,7 @@ export default forwardRef<OrderPackageRef, IOrderPackageProps>(
|
||||
|
||||
useEffect(() => {
|
||||
// 初始化数据
|
||||
if (orderPackageList.length > 0) {
|
||||
if (orderPackageList?.length > 0) {
|
||||
// 根据当前供应商确定需要检查的纸箱类型
|
||||
let requiredTypes: string[] = [];
|
||||
|
||||
|
||||
@ -245,7 +245,7 @@ export default function PurchasePreview(props: IPurchasePreviewProps) {
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{purchaseOrder.orderPackageList.length > 0 && (
|
||||
{purchaseOrder.orderPackageList?.length > 0 && (
|
||||
<>
|
||||
<View className="text-sm font-bold">空箱使用明细</View>
|
||||
<View className="flex flex-col gap-2.5">
|
||||
|
||||
@ -535,9 +535,9 @@ export default forwardRef<WeighRef, IWeightProps>(function Weigh(props, ref) {
|
||||
<Radio.Group
|
||||
direction="horizontal"
|
||||
value={
|
||||
supplierVO.isPaper
|
||||
supplierVO.isPaper === true
|
||||
? "true"
|
||||
: !supplierVO.isPaper
|
||||
: supplierVO.isPaper === false
|
||||
? "false"
|
||||
: undefined
|
||||
}
|
||||
@ -639,7 +639,7 @@ export default forwardRef<WeighRef, IWeightProps>(function Weigh(props, ref) {
|
||||
<Radio.Group
|
||||
direction="horizontal"
|
||||
value={
|
||||
supplierVO.isDepositPaid
|
||||
supplierVO.isDepositPaid === true
|
||||
? "true"
|
||||
: supplierVO.isDepositPaid === false
|
||||
? "false"
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Text, View } from "@tarojs/components";
|
||||
import { Button, Popup, SafeArea } from "@nutui/nutui-react-taro";
|
||||
import { PurchaseOrderCalculator } from "@/utils";
|
||||
import { formatCurrency, PurchaseOrderCalculator } from "@/utils";
|
||||
import { PriceEditor } from "@/components";
|
||||
|
||||
export default function CostDifferenceSection(props: {
|
||||
@ -13,49 +11,6 @@ export default function CostDifferenceSection(props: {
|
||||
const { purchaseOrderVO, onChange, readOnly, calculator } = props;
|
||||
const orderDealer = purchaseOrderVO.orderDealer;
|
||||
|
||||
const [visible, setVisible] = useState(false);
|
||||
|
||||
// 主状态,用于页面显示
|
||||
const costDifference =
|
||||
orderDealer?.costDifference || calculator.getCostDifference();
|
||||
|
||||
// 弹窗内的临时状态
|
||||
const [tempCostDifference, setTempCostDifference] = useState<number>(
|
||||
orderDealer?.costDifference || 0,
|
||||
);
|
||||
|
||||
const profitSharing = calculator.getShareProfit() || 0;
|
||||
|
||||
useEffect(() => {
|
||||
if (!orderDealer?.costDifference) {
|
||||
const defaultCostDifference = calculator.getCostDifference();
|
||||
setTempCostDifference(defaultCostDifference);
|
||||
// 更新父组件的状态
|
||||
onChange?.({
|
||||
...purchaseOrderVO,
|
||||
orderDealer: {
|
||||
...orderDealer,
|
||||
costDifference: defaultCostDifference,
|
||||
profitSharing: profitSharing,
|
||||
},
|
||||
});
|
||||
}
|
||||
}, []);
|
||||
|
||||
// 保存调整成本
|
||||
const saveCostDifference = () => {
|
||||
onChange?.({
|
||||
...purchaseOrderVO,
|
||||
orderDealer: {
|
||||
...orderDealer,
|
||||
costDifference: tempCostDifference,
|
||||
profitSharing: profitSharing,
|
||||
},
|
||||
});
|
||||
|
||||
setVisible(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<View className={"flex flex-col gap-2.5"}>
|
||||
{/* 卡片形式展示分成信息 */}
|
||||
@ -66,21 +21,26 @@ export default function CostDifferenceSection(props: {
|
||||
|
||||
<View className="flex">
|
||||
<PriceEditor
|
||||
value={costDifference}
|
||||
value={
|
||||
orderDealer.costDifference === null ||
|
||||
orderDealer.costDifference === undefined
|
||||
? calculator.getCostDifference()
|
||||
: orderDealer.costDifference
|
||||
}
|
||||
onSave={(newValue) => {
|
||||
onChange?.({
|
||||
...purchaseOrderVO,
|
||||
orderDealer: {
|
||||
...orderDealer,
|
||||
costDifference: newValue,
|
||||
profitSharing: profitSharing,
|
||||
profitSharing: calculator.getShareProfit(),
|
||||
},
|
||||
});
|
||||
}}
|
||||
readOnly={readOnly || !orderDealer?.shareAdjusted}
|
||||
label={orderDealer?.shareAdjusted ? "调分成金额" : "分成金额"}
|
||||
unit="元"
|
||||
hint=""
|
||||
hint="点击金额可直接编辑"
|
||||
/>
|
||||
|
||||
<View className="flex flex-1 flex-col gap-2 pl-4">
|
||||
@ -89,66 +49,15 @@ export default function CostDifferenceSection(props: {
|
||||
</View>
|
||||
<View className="flex items-center justify-between">
|
||||
<Text className="text-primary text-2xl font-bold text-nowrap">
|
||||
¥ {profitSharing}
|
||||
¥{" "}
|
||||
{formatCurrency(
|
||||
orderDealer.profitSharing || calculator.getShareProfit() || 0,
|
||||
)}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* 分成弹窗 */}
|
||||
<Popup
|
||||
duration={150}
|
||||
style={{
|
||||
minHeight: "auto",
|
||||
}}
|
||||
visible={visible}
|
||||
className={"flex flex-col"}
|
||||
position="bottom"
|
||||
title={"调分成金额"}
|
||||
onClose={() => setVisible(false)}
|
||||
onOverlayClick={() => {
|
||||
setVisible(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"
|
||||
}
|
||||
>
|
||||
<Button
|
||||
size={"large"}
|
||||
block
|
||||
type="primary"
|
||||
onClick={saveCostDifference}
|
||||
>
|
||||
保存
|
||||
</Button>
|
||||
</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={() => {
|
||||
setVisible(false);
|
||||
}}
|
||||
>
|
||||
取消
|
||||
</Button>
|
||||
</View>
|
||||
</View>
|
||||
<SafeArea position={"bottom"} />
|
||||
</View>
|
||||
</Popup>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@ import { View } from "@tarojs/components";
|
||||
import { DealerPicker, Icon } from "@/components";
|
||||
import { Button } from "@nutui/nutui-react-taro";
|
||||
|
||||
export default function (props: {
|
||||
export default function DealerInfoSection(props: {
|
||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||
onChange?: (orderDealer: BusinessAPI.PurchaseOrderVO) => void;
|
||||
readOnly?: boolean;
|
||||
@ -82,7 +82,7 @@ export default function (props: {
|
||||
fill="outline"
|
||||
block
|
||||
>
|
||||
{orderDealer ? "修改经销商" : "选择经销商"}
|
||||
{orderDealer ? "修改下游经销商" : "选择下游经销商"}
|
||||
</Button>
|
||||
</View>
|
||||
}
|
||||
|
||||
@ -0,0 +1,81 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { View } from "@tarojs/components";
|
||||
import { DeliveryStep1Form } from "@/components";
|
||||
import {
|
||||
convertPurchaseOrderToShipOrder,
|
||||
convertShipOrderVOToExamplesFormat,
|
||||
} from "@/utils";
|
||||
import { business } from "@/services";
|
||||
|
||||
export default function DeliveryFormSection(props: {
|
||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||
onChange?: (orderDealer: BusinessAPI.PurchaseOrderVO) => void;
|
||||
readOnly?: boolean;
|
||||
}) {
|
||||
const { purchaseOrderVO, onChange, readOnly } = props;
|
||||
const [moduleList, setModuleList] = useState<any[]>([]);
|
||||
|
||||
const shipOrderVO =
|
||||
purchaseOrderVO.shipOrderVOList &&
|
||||
purchaseOrderVO.shipOrderVOList.length > 0
|
||||
? purchaseOrderVO.shipOrderVOList[0]
|
||||
: convertPurchaseOrderToShipOrder(purchaseOrderVO);
|
||||
|
||||
const init = async (shipOrderVO: BusinessAPI.ShipOrderVO) => {
|
||||
const { data } = await business.dealer.showDealer({
|
||||
dealerShowQry: {
|
||||
dealerId: shipOrderVO.dealerId,
|
||||
},
|
||||
});
|
||||
|
||||
if (data.data?.deliveryTemplate!) {
|
||||
const template = JSON.parse(data.data?.deliveryTemplate!);
|
||||
// 将 shipOrderVO 转换为 examples 的数据格式,然后再替换 moduleList 里面的 config 数据
|
||||
const convertedData = convertShipOrderVOToExamplesFormat(shipOrderVO);
|
||||
const updatedTemplate = await updateTemplateConfig(
|
||||
template,
|
||||
convertedData,
|
||||
);
|
||||
console.log("updatedTemplate", updatedTemplate);
|
||||
setModuleList(updatedTemplate);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
init(shipOrderVO);
|
||||
}, []);
|
||||
|
||||
// 更新模板配置
|
||||
const updateTemplateConfig = async (template: any[], data: any) => {
|
||||
let templateList: any[] = [];
|
||||
template.map(async (module: any) => {
|
||||
let newModule = { ...module };
|
||||
if (data[module.type]) {
|
||||
newModule.config = { ...module.config, ...data[module.type] };
|
||||
}
|
||||
templateList.push(newModule);
|
||||
});
|
||||
|
||||
return templateList;
|
||||
};
|
||||
|
||||
if (!shipOrderVO) {
|
||||
return;
|
||||
}
|
||||
|
||||
return (
|
||||
<View className={"flex flex-col gap-2.5"}>
|
||||
<DeliveryStep1Form
|
||||
readOnly={readOnly}
|
||||
moduleList={moduleList}
|
||||
shipOrderVO={shipOrderVO}
|
||||
setShipOrderVO={(shipOrderVO) => {
|
||||
onChange?.({
|
||||
...purchaseOrderVO,
|
||||
shipOrderVOList: [shipOrderVO],
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@ -1,6 +1,5 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useEffect } from "react";
|
||||
import { Text, View } from "@tarojs/components";
|
||||
import { Button, Popup, SafeArea } from "@nutui/nutui-react-taro";
|
||||
import { PurchaseOrderCalculator } from "@/utils";
|
||||
import { PriceEditor } from "@/components";
|
||||
|
||||
@ -13,21 +12,13 @@ export default function ProductionLossSection(props: {
|
||||
const { purchaseOrderVO, onChange, readOnly, calculator } = props;
|
||||
const orderDealer = purchaseOrderVO.orderDealer;
|
||||
|
||||
const [visible, setVisible] = useState(false);
|
||||
|
||||
// 主状态 - 用于显示在页面上的值
|
||||
const displayLossAmount =
|
||||
orderDealer?.lossAmount || calculator.getDefaultLossAmount();
|
||||
|
||||
// 临时状态 - 用于弹窗内编辑的值
|
||||
const [tempLossAmount, setTempLossAmount] = useState<number>(
|
||||
orderDealer?.lossAmount || 0,
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!orderDealer?.lossAmount) {
|
||||
const defaultValue = calculator.getDefaultLossAmount();
|
||||
setTempLossAmount(defaultValue);
|
||||
// 更新父组件的状态
|
||||
onChange?.({
|
||||
...purchaseOrderVO,
|
||||
@ -39,31 +30,6 @@ export default function ProductionLossSection(props: {
|
||||
}
|
||||
}, []);
|
||||
|
||||
// 设置税费补贴默认值
|
||||
const setDefaultLossAmount = () => {
|
||||
const defaultValue = calculator.getDefaultLossAmount();
|
||||
setTempLossAmount(defaultValue);
|
||||
};
|
||||
|
||||
// 保存税费补贴
|
||||
const saveLossAmount = () => {
|
||||
// 更新父组件的状态
|
||||
onChange?.({
|
||||
...purchaseOrderVO,
|
||||
orderDealer: {
|
||||
...orderDealer,
|
||||
lossAmount: tempLossAmount,
|
||||
},
|
||||
});
|
||||
|
||||
setVisible(false);
|
||||
};
|
||||
|
||||
// 关闭弹窗时恢复临时值为显示值
|
||||
const closePopup = () => {
|
||||
setVisible(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<View className={"flex flex-col gap-2.5"}>
|
||||
{/* 卡片形式展示返点信息 */}
|
||||
@ -88,74 +54,10 @@ export default function ProductionLossSection(props: {
|
||||
readOnly={readOnly}
|
||||
label="损耗金额"
|
||||
unit="元"
|
||||
hint=""
|
||||
hint="点击金额可直接编辑"
|
||||
/>
|
||||
|
||||
<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>
|
||||
</View>
|
||||
<View className="flex items-center justify-between">
|
||||
<Text className="text-primary text-2xl font-bold text-nowrap">
|
||||
¥
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* 产地损耗弹窗 */}
|
||||
<Popup
|
||||
duration={150}
|
||||
style={{
|
||||
minHeight: "auto",
|
||||
}}
|
||||
visible={visible}
|
||||
className={"flex flex-col"}
|
||||
position="bottom"
|
||||
title={"编辑产地损耗金额"}
|
||||
onClose={closePopup}
|
||||
onOverlayClick={closePopup}
|
||||
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"
|
||||
}
|
||||
>
|
||||
<Button size="small" onClick={setDefaultLossAmount}>
|
||||
填入默认值
|
||||
</Button>
|
||||
<View className="ml-2 self-center text-xs text-gray-500">
|
||||
默认值: {orderDealer.lossAmount}
|
||||
</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={closePopup}>
|
||||
取消
|
||||
</Button>
|
||||
</View>
|
||||
<View className={"flex-1"}>
|
||||
<Button
|
||||
size={"large"}
|
||||
block
|
||||
type="primary"
|
||||
onClick={saveLossAmount}
|
||||
>
|
||||
保存
|
||||
</Button>
|
||||
</View>
|
||||
</View>
|
||||
<SafeArea position={"bottom"} />
|
||||
</View>
|
||||
</Popup>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@ -149,6 +149,7 @@ export default function PurchaseCostInfoSection(props: {
|
||||
return (
|
||||
<>
|
||||
<Table
|
||||
className={"table-sum"}
|
||||
columns={[
|
||||
{
|
||||
title: "项目",
|
||||
@ -279,6 +280,23 @@ export default function PurchaseCostInfoSection(props: {
|
||||
}, 0),
|
||||
),
|
||||
},
|
||||
{
|
||||
project: "定金(元)",
|
||||
icon: "money-bill",
|
||||
...(purchaseOrderVO?.orderSupplierList.length > 0
|
||||
? purchaseOrderVO?.orderSupplierList.reduce((acc, item) => {
|
||||
acc[item.orderSupplierId] = formatCurrency(
|
||||
Number(item.depositAmount),
|
||||
);
|
||||
return acc;
|
||||
}, {})
|
||||
: {}),
|
||||
total: formatCurrency(
|
||||
purchaseOrderVO?.orderSupplierList.reduce((sum, supplier) => {
|
||||
return sum + (supplier.depositAmount || 0);
|
||||
}, 0),
|
||||
),
|
||||
},
|
||||
{
|
||||
project: "合计(元)",
|
||||
icon: "money-bill",
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { ScrollView, Text, View } from "@tarojs/components";
|
||||
import { Button, Popup, SafeArea } from "@nutui/nutui-react-taro";
|
||||
import { PurchaseOrderCalculator } from "@/utils";
|
||||
import { Button, Input, Popup, SafeArea } from "@nutui/nutui-react-taro";
|
||||
import { PurchaseOrderCalculator, validatePrice } from "@/utils";
|
||||
import { business } from "@/services";
|
||||
import { PriceEditor } from "@/components";
|
||||
|
||||
export default function RebateCalcSection(props: {
|
||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||
@ -112,33 +111,34 @@ export default function RebateCalcSection(props: {
|
||||
</View>
|
||||
|
||||
<View className="flex">
|
||||
<PriceEditor
|
||||
value={calculateRebateAmount(orderRebate)}
|
||||
onSave={(newValue) => {
|
||||
if (orderRebate.calcMethod === "FIXED_AMOUNT") {
|
||||
const newOrderRebate = {
|
||||
...orderRebate,
|
||||
amount: newValue,
|
||||
};
|
||||
|
||||
const newPurchaseOrderVO = {
|
||||
...purchaseOrderVO,
|
||||
rebate: true,
|
||||
orderRebate: newOrderRebate,
|
||||
};
|
||||
|
||||
setOrderRebate(newOrderRebate);
|
||||
onChange?.(newPurchaseOrderVO);
|
||||
} else {
|
||||
// 对于按净重计算的情况,不能直接修改金额,需要通过单价或净重调整
|
||||
setVisible(true);
|
||||
}
|
||||
}}
|
||||
readOnly={readOnly}
|
||||
label="返点金额"
|
||||
unit="元"
|
||||
hint=""
|
||||
/>
|
||||
{!readOnly ? (
|
||||
<View
|
||||
className="flex flex-1 flex-col"
|
||||
onClick={() => setVisible(true)}
|
||||
>
|
||||
<View className="mb-2 flex items-center justify-between">
|
||||
<Text className="text-sm text-gray-500">返点金额</Text>
|
||||
<Text className="text-sm text-gray-500">元</Text>
|
||||
</View>
|
||||
<View className="relative flex flex-1 items-end">
|
||||
<Text className="w-full border-b-2 border-red-500 pb-2 text-3xl font-bold text-red-500 focus:outline-none">
|
||||
{calculateRebateAmount(orderRebate).toFixed(2) || "0"}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
) : (
|
||||
<View className="flex flex-1 flex-col">
|
||||
<View className="mb-2 flex items-center justify-between">
|
||||
<Text className="text-sm text-gray-500">返点金额</Text>
|
||||
<Text className="text-sm text-gray-500">元</Text>
|
||||
</View>
|
||||
<View className="relative flex flex-1 items-end">
|
||||
<Text className="w-full py-2 text-3xl font-bold text-red-500">
|
||||
{calculateRebateAmount(orderRebate).toFixed(2) || "0"}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
|
||||
<View className="flex flex-1 flex-col gap-2 pl-4">
|
||||
<View className="flex items-center justify-between">
|
||||
@ -239,14 +239,33 @@ export default function RebateCalcSection(props: {
|
||||
单价(元/斤)
|
||||
</View>
|
||||
<View className="border-neutral-base flex flex-row items-center rounded-md border border-solid">
|
||||
<Button
|
||||
size="large"
|
||||
block
|
||||
type="primary"
|
||||
onClick={handleSave}
|
||||
>
|
||||
保存
|
||||
</Button>
|
||||
<Input
|
||||
className="placeholder:text-neutral-dark flex-1"
|
||||
placeholder="请输入单价"
|
||||
type="digit"
|
||||
value={tempOrderRebate.unitPrice?.toString() || ""}
|
||||
onChange={(value) => {
|
||||
const numValue = validatePrice(value);
|
||||
if (numValue !== undefined) {
|
||||
handleRebateChange("unitPrice", numValue);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<View className="mr-2">元/斤</View>
|
||||
</View>
|
||||
|
||||
<View className="flex items-center justify-between rounded-md bg-gray-100 p-3">
|
||||
<View className="text-neutral-darkest text-sm font-medium">
|
||||
返点金额
|
||||
</View>
|
||||
<View className="text-neutral-darkest text-sm font-medium">
|
||||
{tempOrderRebate.netWeight && tempOrderRebate.unitPrice
|
||||
? (
|
||||
tempOrderRebate.netWeight * tempOrderRebate.unitPrice
|
||||
).toFixed(2)
|
||||
: "0.00"}{" "}
|
||||
元
|
||||
</View>
|
||||
</View>
|
||||
</>
|
||||
)}
|
||||
@ -255,15 +274,21 @@ export default function RebateCalcSection(props: {
|
||||
<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">
|
||||
<Button
|
||||
size="large"
|
||||
block
|
||||
type="primary"
|
||||
onClick={handleSave}
|
||||
>
|
||||
保存
|
||||
</Button>
|
||||
<Input
|
||||
className="placeholder:text-neutral-dark flex-1"
|
||||
placeholder="请输入返点金额"
|
||||
type="digit"
|
||||
value={tempOrderRebate.amount?.toString() || ""}
|
||||
onChange={(value) => {
|
||||
const numValue = validatePrice(value);
|
||||
if (numValue !== undefined) {
|
||||
handleRebateChange("amount", numValue);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<View className="mr-2">元</View>
|
||||
</View>
|
||||
</>
|
||||
)}
|
||||
@ -281,6 +306,11 @@ export default function RebateCalcSection(props: {
|
||||
取消
|
||||
</Button>
|
||||
</View>
|
||||
<View className="flex-1">
|
||||
<Button size="large" block type="primary" onClick={handleSave}>
|
||||
保存
|
||||
</Button>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</ScrollView>
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Text, View } from "@tarojs/components";
|
||||
import { Button, Popup, SafeArea } from "@nutui/nutui-react-taro";
|
||||
import { PurchaseOrderCalculator } from "@/utils";
|
||||
import { PriceEditor } from "@/components";
|
||||
|
||||
@ -13,56 +11,6 @@ export default function TaxProvisionSection(props: {
|
||||
const { purchaseOrderVO, onChange, readOnly, calculator } = props;
|
||||
const orderDealer = purchaseOrderVO.orderDealer;
|
||||
|
||||
const [visible, setVisible] = useState(false);
|
||||
|
||||
const displayTaxProvision =
|
||||
orderDealer.taxProvision || calculator.getDefaultTaxProvision();
|
||||
|
||||
// 临时状态 - 用于弹窗内编辑的值
|
||||
const [tempTaxProvision, setTempTaxProvision] = useState<number>(
|
||||
orderDealer?.taxProvision || 0,
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!orderDealer?.taxProvision) {
|
||||
const defaultValue = calculator.getDefaultTaxProvision();
|
||||
setTempTaxProvision(defaultValue);
|
||||
// 更新父组件的状态
|
||||
onChange?.({
|
||||
...purchaseOrderVO,
|
||||
orderDealer: {
|
||||
...orderDealer,
|
||||
taxProvision: defaultValue,
|
||||
},
|
||||
});
|
||||
}
|
||||
}, []);
|
||||
|
||||
// 设置计提税金默认值
|
||||
const setDefaultTaxProvision = () => {
|
||||
const defaultValue = calculator.getDefaultTaxProvision();
|
||||
setTempTaxProvision(defaultValue);
|
||||
};
|
||||
|
||||
// 保存计提税金
|
||||
const saveTaxProvision = () => {
|
||||
// 更新父组件的状态
|
||||
onChange?.({
|
||||
...purchaseOrderVO,
|
||||
orderDealer: {
|
||||
...orderDealer,
|
||||
taxProvision: tempTaxProvision,
|
||||
},
|
||||
});
|
||||
|
||||
setVisible(false);
|
||||
};
|
||||
|
||||
// 关闭弹窗时恢复临时值为显示值
|
||||
const closePopup = () => {
|
||||
setVisible(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<View className={"flex flex-col gap-2.5"}>
|
||||
{/* 卡片形式展示计提税金信息 */}
|
||||
@ -73,7 +21,12 @@ export default function TaxProvisionSection(props: {
|
||||
|
||||
<View className="flex">
|
||||
<PriceEditor
|
||||
value={displayTaxProvision}
|
||||
value={
|
||||
orderDealer.taxProvision === null ||
|
||||
orderDealer.taxProvision === undefined
|
||||
? calculator.getDefaultTaxProvision()
|
||||
: orderDealer.taxProvision
|
||||
}
|
||||
onSave={(newValue) => {
|
||||
// 更新父组件的状态
|
||||
onChange?.({
|
||||
@ -87,7 +40,7 @@ export default function TaxProvisionSection(props: {
|
||||
readOnly={readOnly}
|
||||
label="计提金额"
|
||||
unit="元"
|
||||
hint=""
|
||||
hint="点击金额可直接编辑"
|
||||
/>
|
||||
|
||||
<View className="flex flex-1 flex-col gap-2 pl-4">
|
||||
@ -102,60 +55,6 @@ export default function TaxProvisionSection(props: {
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* 计提税金弹窗 */}
|
||||
<Popup
|
||||
duration={150}
|
||||
style={{
|
||||
minHeight: "auto",
|
||||
}}
|
||||
visible={visible}
|
||||
className={"flex flex-col"}
|
||||
position="bottom"
|
||||
title={"编辑计提税金"}
|
||||
onClose={closePopup}
|
||||
onOverlayClick={closePopup}
|
||||
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"
|
||||
}
|
||||
>
|
||||
<Button size="small" onClick={setDefaultTaxProvision}>
|
||||
按公式填入默认值
|
||||
</Button>
|
||||
<View className="ml-2 self-center text-xs text-gray-500">
|
||||
默认值: (市场报价 - 税费补贴) ×{" "}
|
||||
{orderDealer.accrualTaxRatio || "未设置"}%
|
||||
</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={closePopup}>
|
||||
取消
|
||||
</Button>
|
||||
</View>
|
||||
<View className={"flex-1"}>
|
||||
<Button
|
||||
size={"large"}
|
||||
block
|
||||
type="primary"
|
||||
onClick={saveTaxProvision}
|
||||
>
|
||||
保存
|
||||
</Button>
|
||||
</View>
|
||||
</View>
|
||||
<SafeArea position={"bottom"} />
|
||||
</View>
|
||||
</Popup>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Text, View } from "@tarojs/components";
|
||||
import { Button, Popup, SafeArea } from "@nutui/nutui-react-taro";
|
||||
import { PurchaseOrderCalculator } from "@/utils";
|
||||
import { PriceEditor } from "@/components";
|
||||
|
||||
@ -13,57 +11,6 @@ export default function TaxSubsidySection(props: {
|
||||
const { purchaseOrderVO, onChange, readOnly, calculator } = props;
|
||||
const orderDealer = purchaseOrderVO.orderDealer;
|
||||
|
||||
const [visible, setVisible] = useState(false);
|
||||
|
||||
// 主状态 - 用于显示在页面上的值
|
||||
const displayTaxSubsidy =
|
||||
orderDealer?.taxSubsidy || calculator.getDefaultTaxSubsidy();
|
||||
|
||||
// 临时状态 - 用于弹窗内编辑的值
|
||||
const [tempTaxSubsidy, setTempTaxSubsidy] = useState<number>(
|
||||
orderDealer?.taxSubsidy || 0,
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!orderDealer?.taxSubsidy) {
|
||||
const defaultValue = calculator.getDefaultTaxSubsidy();
|
||||
setTempTaxSubsidy(defaultValue);
|
||||
// 更新父组件的状态
|
||||
onChange?.({
|
||||
...purchaseOrderVO,
|
||||
orderDealer: {
|
||||
...orderDealer,
|
||||
taxSubsidy: defaultValue,
|
||||
},
|
||||
});
|
||||
}
|
||||
}, []);
|
||||
|
||||
// 设置税费补贴默认值
|
||||
const setDefaultTaxSubsidy = () => {
|
||||
const defaultValue = calculator.getDefaultTaxSubsidy();
|
||||
setTempTaxSubsidy(defaultValue);
|
||||
};
|
||||
|
||||
// 保存税费补贴
|
||||
const saveTaxSubsidy = () => {
|
||||
// 更新父组件的状态
|
||||
onChange?.({
|
||||
...purchaseOrderVO,
|
||||
orderDealer: {
|
||||
...orderDealer,
|
||||
taxSubsidy: tempTaxSubsidy,
|
||||
},
|
||||
});
|
||||
|
||||
setVisible(false);
|
||||
};
|
||||
|
||||
// 关闭弹窗时恢复临时值为显示值
|
||||
const closePopup = () => {
|
||||
setVisible(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<View className={"flex flex-col gap-2.5"}>
|
||||
{/* 卡片形式展示返点信息 */}
|
||||
@ -74,7 +21,12 @@ export default function TaxSubsidySection(props: {
|
||||
|
||||
<View className="flex">
|
||||
<PriceEditor
|
||||
value={displayTaxSubsidy}
|
||||
value={
|
||||
orderDealer.taxSubsidy === null ||
|
||||
orderDealer.taxSubsidy === undefined
|
||||
? calculator.getDefaultTaxSubsidy()
|
||||
: orderDealer.taxSubsidy
|
||||
}
|
||||
onSave={(newValue) => {
|
||||
// 更新父组件的状态
|
||||
onChange?.({
|
||||
@ -88,7 +40,7 @@ export default function TaxSubsidySection(props: {
|
||||
readOnly={readOnly}
|
||||
label="返点金额"
|
||||
unit="元"
|
||||
hint=""
|
||||
hint="点击金额可直接编辑"
|
||||
/>
|
||||
|
||||
<View className="flex flex-1 flex-col gap-2 pl-4">
|
||||
@ -103,59 +55,6 @@ export default function TaxSubsidySection(props: {
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* 税费补贴弹窗 */}
|
||||
<Popup
|
||||
duration={150}
|
||||
style={{
|
||||
minHeight: "auto",
|
||||
}}
|
||||
visible={visible}
|
||||
className={"flex flex-col"}
|
||||
position="bottom"
|
||||
title={"编辑税费补贴"}
|
||||
onClose={closePopup}
|
||||
onOverlayClick={closePopup}
|
||||
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"
|
||||
}
|
||||
>
|
||||
<Button size="small" onClick={setDefaultTaxSubsidy}>
|
||||
按公式填入默认值
|
||||
</Button>
|
||||
<View className="ml-2 self-center text-xs text-gray-500">
|
||||
默认值: 市场报价 × {orderDealer.companyRebateRatio || "未设置"}%
|
||||
</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={closePopup}>
|
||||
取消
|
||||
</Button>
|
||||
</View>
|
||||
<View className={"flex-1"}>
|
||||
<Button
|
||||
size={"large"}
|
||||
block
|
||||
type="primary"
|
||||
onClick={saveTaxSubsidy}
|
||||
>
|
||||
保存
|
||||
</Button>
|
||||
</View>
|
||||
</View>
|
||||
<SafeArea position={"bottom"} />
|
||||
</View>
|
||||
</Popup>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
// App 相关常量
|
||||
export const APP_VERSION = "v0.0.26";
|
||||
export const APP_VERSION = "v0.0.28";
|
||||
|
||||
@ -7,8 +7,11 @@ import shipOrder from "@/constant/shipOrder";
|
||||
import Taro from "@tarojs/taro";
|
||||
import classNames from "classnames";
|
||||
import { business, poster } from "@/services";
|
||||
import dayjs from "dayjs";
|
||||
import { buildUrl, PdfTemplate } from "@/utils";
|
||||
import {
|
||||
buildUrl,
|
||||
convertShipOrderVOToExamplesFormat,
|
||||
PdfTemplate,
|
||||
} from "@/utils";
|
||||
import {
|
||||
DeliveryStep1Form,
|
||||
DeliveryStep1FormRef,
|
||||
@ -29,7 +32,7 @@ const updateOtherFeesModule = async (
|
||||
},
|
||||
});
|
||||
const costItems =
|
||||
data?.filter((item) => item.costType !== "HUMAN_COST") || [];
|
||||
data?.filter((item) => item.type !== "ARTIFICIAL_TYPE") || [];
|
||||
|
||||
console.log("module", module);
|
||||
|
||||
@ -38,7 +41,7 @@ const updateOtherFeesModule = async (
|
||||
config: {
|
||||
...module.config,
|
||||
feeItems: shipOrderVO.orderCostList?.filter(
|
||||
(item) => item.costType !== "HUMAN_COST",
|
||||
(item) => item.type !== "ARTIFICIAL_TYPE",
|
||||
),
|
||||
feeLabels: costItems.reduce((acc: any, item: any) => {
|
||||
acc[item.itemId] = item.name;
|
||||
@ -134,76 +137,6 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
}
|
||||
}, [shipOrderVO, deliveryTemplate]);
|
||||
|
||||
// 将 shipOrderVO 转换为 examples 的数据格式
|
||||
const convertShipOrderVOToExamplesFormat = (
|
||||
shipOrderVO: BusinessAPI.ShipOrderVO,
|
||||
) => {
|
||||
return {
|
||||
title: {
|
||||
title: "西瓜发货清单",
|
||||
},
|
||||
dealerInfo: {
|
||||
dealerName: shipOrderVO.dealerName || "",
|
||||
vehicleNumber: `第 ${shipOrderVO.vehicleNo || ""} 车`,
|
||||
destination: shipOrderVO.receivingAddress || "",
|
||||
watermelonGrade: shipOrderVO.watermelonGrade || "",
|
||||
},
|
||||
shippingInfo: {
|
||||
shippingFrom: shipOrderVO.shippingAddress || "",
|
||||
date: shipOrderVO.shippingDate || "",
|
||||
},
|
||||
weightInfo: {
|
||||
data: shipOrderVO.shipOrderItemList,
|
||||
accountCompany: shipOrderVO.companyName || "",
|
||||
sumAmount:
|
||||
shipOrderVO.shipOrderItemList?.reduce(
|
||||
(acc, item) => acc + item?.totalAmount!,
|
||||
0,
|
||||
) || "",
|
||||
},
|
||||
packingSpec: {
|
||||
data:
|
||||
shipOrderVO.shipOrderPackageList?.map((item) => ({
|
||||
boxSpecId: item.boxSpecId || "",
|
||||
boxSpecName: item.boxSpecName || "",
|
||||
boxType: item.boxProduct || "",
|
||||
quantity: item.quantity?.toString() || "",
|
||||
unitPrice: item.unitPrice?.toString() || "",
|
||||
amount: item.itemAmount?.toString() || "",
|
||||
unitWeight: item.singleWeight?.toString() || "",
|
||||
weight: item.totalWeight?.toString() || "",
|
||||
})) || [],
|
||||
},
|
||||
vehicleInfo: {
|
||||
driverPhone: shipOrderVO?.driverPhone || "",
|
||||
licensePlate: shipOrderVO.licensePlate || "",
|
||||
estimatedArrivalTime: shipOrderVO.estimatedArrivalDate
|
||||
? dayjs(shipOrderVO?.estimatedArrivalDate).format("YYYY年MM月DD日")
|
||||
: "",
|
||||
freightDebt: shipOrderVO.freightDebt?.toString() || "",
|
||||
strawMatDebt: shipOrderVO.strawMatDebt?.toString() || "",
|
||||
remarks: shipOrderVO.remark || "",
|
||||
},
|
||||
otherFees: {},
|
||||
totalAmount: {
|
||||
amount: shipOrderVO.totalAmount?.toString() || "",
|
||||
farmer: shipOrderVO.farmerInfo || "",
|
||||
},
|
||||
otherInfo: {
|
||||
data: shipOrderVO.shipOrderItemList,
|
||||
driverPhone: shipOrderVO?.driverPhone || "",
|
||||
licensePlate: shipOrderVO.licensePlate || "",
|
||||
accountCompany: shipOrderVO.companyName || "",
|
||||
vehicleNumber: `第 ${shipOrderVO.vehicleNo || ""} 车`,
|
||||
destination: shipOrderVO.receivingAddress || "",
|
||||
shippingFrom: shipOrderVO.shippingAddress || "",
|
||||
estimatedArrivalTime: shipOrderVO.estimatedArrivalDate
|
||||
? dayjs(shipOrderVO?.estimatedArrivalDate).format("YYYY年MM月DD日")
|
||||
: "1",
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
// 更新模板配置
|
||||
const updateTemplateConfig = async (
|
||||
template: any[],
|
||||
@ -424,12 +357,14 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
}}
|
||||
>
|
||||
{step === 1 && (
|
||||
<View className="flex flex-col rounded-lg bg-white p-2.5 shadow-md">
|
||||
<DeliveryStep1Form
|
||||
ref={step1FormRef}
|
||||
moduleList={moduleList}
|
||||
shipOrderVO={shipOrderVO}
|
||||
setShipOrderVO={setShipOrderVO}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{step === 2 && <DeliveryStep2Preview moduleList={moduleList} />}
|
||||
|
||||
@ -27,14 +27,17 @@ import {
|
||||
PackageInfoSection,
|
||||
PackagingCostSection,
|
||||
ProductionAdvanceSection,
|
||||
PurchaseCostInfoSection,
|
||||
RebateCalcSection,
|
||||
State,
|
||||
TaxProvisionSection,
|
||||
TaxSubsidySection,
|
||||
WorkerAdvanceSection,
|
||||
} from "@/components";
|
||||
import { buildUrl, PurchaseOrderCalculator } from "@/utils";
|
||||
import { buildUrl, formatCurrency, PurchaseOrderCalculator } from "@/utils";
|
||||
import ProductionLossSection from "../../../components/purchase/section/ProductionLossSection";
|
||||
import DeliveryFormSection from "../../../components/purchase/section/DeliveryFormSection";
|
||||
import classNames from "classnames";
|
||||
|
||||
const sections = {
|
||||
// 市场报价
|
||||
@ -62,11 +65,11 @@ const sections = {
|
||||
// component: SupplierInfoSection,
|
||||
// title: "瓜农信息",
|
||||
// },
|
||||
// // 采购成本
|
||||
// purchaseCostInfo: {
|
||||
// component: PurchaseCostInfoSection,
|
||||
// title: "采购成本",
|
||||
// },
|
||||
// 采购成本
|
||||
purchaseCostInfo: {
|
||||
component: PurchaseCostInfoSection,
|
||||
title: "采购成本复核",
|
||||
},
|
||||
// 包装纸箱费
|
||||
packageInfo: {
|
||||
component: PackageInfoSection,
|
||||
@ -127,6 +130,11 @@ const sections = {
|
||||
component: RebateCalcSection,
|
||||
title: "个人返点复核",
|
||||
},
|
||||
// 发货单复核
|
||||
deliveryForm: {
|
||||
component: DeliveryFormSection,
|
||||
title: "发货单复核",
|
||||
},
|
||||
};
|
||||
|
||||
export default hocAuth(function Page(props: CommonComponent) {
|
||||
@ -528,19 +536,14 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
}}
|
||||
>
|
||||
<View className={"flex-1 text-center"}>个人利润</View>
|
||||
{personalProfit > 0 ? (
|
||||
<View
|
||||
className={"text-primary flex-1 text-left text-2xl font-bold"}
|
||||
className={classNames("flex-1 text-left text-2xl font-bold", {
|
||||
"text-primary": personalProfit > 0,
|
||||
"text-red-500": personalProfit < 0,
|
||||
})}
|
||||
>
|
||||
¥ {personalProfit || "-"}
|
||||
¥ {formatCurrency(personalProfit) || "-"}
|
||||
</View>
|
||||
) : (
|
||||
<View
|
||||
className={"flex-1 text-left text-2xl font-bold text-red-500"}
|
||||
>
|
||||
¥ {personalProfit || "-"}
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@ -422,6 +422,9 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
purchaseOrder?.orderSupplierList[
|
||||
purchaseOrder?.orderSupplierList.length - 1
|
||||
]?.isLast && (
|
||||
<View className="flex flex-1 flex-col gap-2.5 bg-[#D1D5DB] p-2.5 pt-2.5">
|
||||
<View className={"flex flex-1 flex-col gap-2.5"}>
|
||||
<View className="text-sm font-bold">快捷操作</View>
|
||||
<Button
|
||||
icon={<Icon name={"plus"} size={20} />}
|
||||
type={"primary"}
|
||||
@ -435,6 +438,8 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
>
|
||||
<View>添加另一个瓜农</View>
|
||||
</Button>
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
|
||||
|
||||
@ -3924,6 +3924,8 @@ declare namespace BusinessAPI {
|
||||
orderPackageList: OrderPackage[];
|
||||
/** 采购订单项目信息 */
|
||||
orderCostItemList: OrderCostItem[];
|
||||
/** 发货单信息 */
|
||||
shipOrderVOList: ShipOrderVO[];
|
||||
};
|
||||
|
||||
type PurchaseOrderWithdrawReviewCmd = {
|
||||
@ -4264,7 +4266,7 @@ declare namespace BusinessAPI {
|
||||
/** 发货单ID */
|
||||
shipOrderId: string;
|
||||
/** 箱型ID */
|
||||
boxSpecId?: number;
|
||||
boxSpecId?: string;
|
||||
/** 箱型 */
|
||||
boxSpecName?: string;
|
||||
/** 箱号 */
|
||||
|
||||
@ -9,3 +9,6 @@ export {
|
||||
convertBoxBrandToOrderPackages,
|
||||
convertOrderPackagesToBoxBrands
|
||||
} from './boxBrandConverter'
|
||||
|
||||
export { convertPurchaseOrderToShipOrder } from './purchaseOrderConverter'
|
||||
export { convertShipOrderVOToExamplesFormat } from './shipOrderConverter'
|
||||
@ -0,0 +1,139 @@
|
||||
// 将PurchaseOrderVO转换为ShipOrderVO
|
||||
import { generateShortId } from "@/utils";
|
||||
|
||||
/**
|
||||
* 将PurchaseOrderVO转换为ShipOrderVO
|
||||
* @param purchaseOrderVO 采购订单对象
|
||||
* @returns 发货单对象
|
||||
*/
|
||||
export const convertPurchaseOrderToShipOrder = (
|
||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO
|
||||
): BusinessAPI.ShipOrderVO => {
|
||||
// 添加一个辅助函数用于分组
|
||||
const groupBy = <T>(
|
||||
array: T[],
|
||||
keyFn: (item: T) => string,
|
||||
): Record<string, T[]> => {
|
||||
return array.reduce(
|
||||
(groups, item) => {
|
||||
const key = keyFn(item);
|
||||
if (!groups[key]) {
|
||||
groups[key] = [];
|
||||
}
|
||||
groups[key].push(item);
|
||||
return groups;
|
||||
},
|
||||
{} as Record<string, T[]>,
|
||||
);
|
||||
};
|
||||
|
||||
// 转换供应商列表为发货单项列表,根据 purchasePrice 分组
|
||||
const suppliersByPrice = groupBy(
|
||||
purchaseOrderVO.orderSupplierList || [],
|
||||
(supplier) => String(supplier.purchasePrice)
|
||||
);
|
||||
|
||||
const shipOrderItemList: BusinessAPI.ShipOrderItem[] = Object.entries(suppliersByPrice).map(
|
||||
([price, suppliers]) => {
|
||||
// 计算该价格下的总毛重、总净重等
|
||||
const totalGrossWeight = suppliers.reduce(
|
||||
(sum, supplier) => sum + (supplier.grossWeight || 0), 0
|
||||
);
|
||||
|
||||
const totalNetWeight = suppliers.reduce(
|
||||
(sum, supplier) => sum + (supplier.netWeight || 0), 0
|
||||
);
|
||||
|
||||
const totalBoxWeight = suppliers.reduce(
|
||||
(sum, supplier) => {
|
||||
if (supplier.totalWeight && supplier.netWeight) {
|
||||
return sum + (supplier.totalWeight - supplier.netWeight);
|
||||
}
|
||||
return sum;
|
||||
}, 0
|
||||
);
|
||||
|
||||
const totalAmount = suppliers.reduce(
|
||||
(sum, supplier) => sum + (supplier.invoiceAmount || 0), 0
|
||||
);
|
||||
|
||||
return {
|
||||
itemId: generateShortId(),
|
||||
shipOrderId: "", // 将在创建发货单时填充
|
||||
grossWeight: totalGrossWeight,
|
||||
boxWeight: totalBoxWeight,
|
||||
netWeight: totalNetWeight,
|
||||
unitPrice: parseFloat(price),
|
||||
totalAmount: totalAmount,
|
||||
watermelonGrade: "", // 需要手动填写
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
// 转换包装信息,根据 boxSpecId 分组
|
||||
const allPackages: BusinessAPI.OrderPackage[] = [];
|
||||
purchaseOrderVO.orderSupplierList?.forEach(supplier => {
|
||||
if (supplier.orderPackageList) {
|
||||
allPackages.push(...supplier.orderPackageList);
|
||||
}
|
||||
});
|
||||
|
||||
const packagesBySpec = groupBy(
|
||||
allPackages,
|
||||
(pkg) => pkg.boxSpecId
|
||||
);
|
||||
|
||||
const shipOrderPackageList: BusinessAPI.ShipOrderPackage[] = Object.entries(packagesBySpec).map(
|
||||
([specId, packages]) => {
|
||||
// 计算该规格下的总数量、总重量等
|
||||
const totalQuantity = packages.reduce(
|
||||
(sum, pkg) => sum + (pkg.boxCount || 0), 0
|
||||
);
|
||||
|
||||
const totalWeight = packages.reduce(
|
||||
(sum, pkg) => sum + ((pkg.boxCount || 0) * (pkg.boxProductWeight || 0)), 0
|
||||
);
|
||||
|
||||
// 获取第一条记录的价格信息(假设同一规格价格一致)
|
||||
const firstPackage = packages[0];
|
||||
|
||||
const totalPrice = totalQuantity * (firstPackage.boxSalePrice || 0);
|
||||
|
||||
return {
|
||||
orderPackageId: generateShortId(),
|
||||
shipOrderId: "", // 将在创建发货单时填充
|
||||
boxSpecId: specId,
|
||||
boxSpecName: firstPackage.boxSpecName,
|
||||
boxProduct: firstPackage.boxProductName,
|
||||
quantity: totalQuantity,
|
||||
unitPrice: firstPackage.boxSalePrice,
|
||||
itemAmount: totalPrice,
|
||||
singleWeight: firstPackage.boxProductWeight,
|
||||
totalWeight: totalWeight,
|
||||
boxBrandImage: firstPackage.boxBrandImage,
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
// 构建ShipOrderVO对象,不转换费用信息
|
||||
return {
|
||||
shipOrderId: generateShortId(),
|
||||
purchaseOrderId: purchaseOrderVO.orderId,
|
||||
orderSn: purchaseOrderVO.orderSn,
|
||||
dealerId: purchaseOrderVO.orderDealer?.dealerId,
|
||||
dealerName: purchaseOrderVO.orderDealer?.shortName,
|
||||
companyId: purchaseOrderVO.orderCompany?.companyId,
|
||||
companyName: purchaseOrderVO.orderCompany?.fullName,
|
||||
vehicleNo: purchaseOrderVO.orderVehicle?.vehicleNo,
|
||||
shippingAddress: purchaseOrderVO.orderVehicle?.origin,
|
||||
receivingAddress: purchaseOrderVO.orderVehicle?.destination,
|
||||
shippingDate: purchaseOrderVO.orderVehicle?.deliveryTime,
|
||||
driverName: purchaseOrderVO.orderVehicle?.driver,
|
||||
driverPhone: purchaseOrderVO.orderVehicle?.phone,
|
||||
licensePlate: purchaseOrderVO.orderVehicle?.plate,
|
||||
shipOrderItemList,
|
||||
shipOrderPackageList,
|
||||
createdBy: purchaseOrderVO.createdBy,
|
||||
createdByName: purchaseOrderVO.createdByName,
|
||||
};
|
||||
};
|
||||
@ -0,0 +1,75 @@
|
||||
import dayjs from "dayjs";
|
||||
|
||||
/**
|
||||
* 将ShipOrderVO转换为示例数据格式
|
||||
* @param shipOrderVO 发货单对象
|
||||
* @returns 示例数据格式
|
||||
*/
|
||||
export const convertShipOrderVOToExamplesFormat = (
|
||||
shipOrderVO: BusinessAPI.ShipOrderVO,
|
||||
) => {
|
||||
return {
|
||||
title: {
|
||||
title: "西瓜发货清单",
|
||||
},
|
||||
dealerInfo: {
|
||||
dealerName: shipOrderVO.dealerName || "",
|
||||
vehicleNumber: `第 ${shipOrderVO.vehicleNo || ""} 车`,
|
||||
destination: shipOrderVO.receivingAddress || "",
|
||||
watermelonGrade: shipOrderVO.watermelonGrade || "",
|
||||
},
|
||||
shippingInfo: {
|
||||
shippingFrom: shipOrderVO.shippingAddress || "",
|
||||
date: shipOrderVO.shippingDate || "",
|
||||
},
|
||||
weightInfo: {
|
||||
data: shipOrderVO.shipOrderItemList,
|
||||
accountCompany: shipOrderVO.companyName || "",
|
||||
sumAmount:
|
||||
shipOrderVO.shipOrderItemList?.reduce(
|
||||
(acc, item) => acc + item?.totalAmount!,
|
||||
0,
|
||||
) || "",
|
||||
},
|
||||
packingSpec: {
|
||||
data:
|
||||
shipOrderVO.shipOrderPackageList?.map((item) => ({
|
||||
boxSpecId: item.boxSpecId || "",
|
||||
boxSpecName: item.boxSpecName || "",
|
||||
boxType: item.boxProduct || "",
|
||||
quantity: item.quantity?.toString() || "",
|
||||
unitPrice: item.unitPrice?.toString() || "",
|
||||
amount: item.itemAmount?.toString() || "",
|
||||
unitWeight: item.singleWeight?.toString() || "",
|
||||
weight: item.totalWeight?.toString() || "",
|
||||
})) || [],
|
||||
},
|
||||
vehicleInfo: {
|
||||
driverPhone: shipOrderVO?.driverPhone || "",
|
||||
licensePlate: shipOrderVO.licensePlate || "",
|
||||
estimatedArrivalTime: shipOrderVO.estimatedArrivalDate
|
||||
? dayjs(shipOrderVO?.estimatedArrivalDate).format("YYYY年MM月DD日")
|
||||
: "",
|
||||
freightDebt: shipOrderVO.freightDebt?.toString() || "",
|
||||
strawMatDebt: shipOrderVO.strawMatDebt?.toString() || "",
|
||||
remarks: shipOrderVO.remark || "",
|
||||
},
|
||||
otherFees: {},
|
||||
totalAmount: {
|
||||
amount: shipOrderVO.totalAmount?.toString() || "",
|
||||
farmer: shipOrderVO.farmerInfo || "",
|
||||
},
|
||||
otherInfo: {
|
||||
data: shipOrderVO.shipOrderItemList,
|
||||
driverPhone: shipOrderVO?.driverPhone || "",
|
||||
licensePlate: shipOrderVO.licensePlate || "",
|
||||
accountCompany: shipOrderVO.companyName || "",
|
||||
vehicleNumber: `第 ${shipOrderVO.vehicleNo || ""} 车`,
|
||||
destination: shipOrderVO.receivingAddress || "",
|
||||
shippingFrom: shipOrderVO.shippingAddress || "",
|
||||
estimatedArrivalTime: shipOrderVO.estimatedArrivalDate
|
||||
? dayjs(shipOrderVO?.estimatedArrivalDate).format("YYYY年MM月DD日")
|
||||
: "1",
|
||||
},
|
||||
};
|
||||
};
|
||||
@ -21,7 +21,7 @@ export function formatAmount(value: number): string {
|
||||
}
|
||||
|
||||
// 固定保留2位小数
|
||||
const fixedStr = value.toFixed(2);
|
||||
const fixedStr = Number(value).toFixed(2);
|
||||
|
||||
// 去除小数点后多余的零
|
||||
// 具体规则:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user