refactor(purchase): 重构纸箱规格相关逻辑
- 将 BoxCategory 相关类型和逻辑替换为 BoxSpec - 更新 OrderPackage 组件中的分类展示和数量统计逻辑 - 修改采购预览页面的规格字段展示方式 - 调整配送单据中的纸箱规格数据结构 - 新增 BoxSpec 相关服务接口和类型定义 - 移除旧的 calculateSupplierWeights 工具函数 - 更新组件内部变量命名以匹配新规范 - 修正空箱信息区域组件的属性传递问题
This commit is contained in:
parent
323fe4c83d
commit
5eb4e0f4bb
@ -12,7 +12,7 @@ import {
|
|||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { forwardRef, useEffect, useImperativeHandle, useState } from "react";
|
import { forwardRef, useEffect, useImperativeHandle, useState } from "react";
|
||||||
import { business } from "@/services";
|
import { business } from "@/services";
|
||||||
import { BoxBrand, BoxCategory, BoxProduct, SupplierVO } from "@/types/typings";
|
import { BoxBrand, BoxProduct, BoxSpec, SupplierVO } from "@/types/typings";
|
||||||
import { generateShortId } from "@/utils/generateShortId";
|
import { generateShortId } from "@/utils/generateShortId";
|
||||||
import {
|
import {
|
||||||
convertBoxBrandToOrderPackages,
|
convertBoxBrandToOrderPackages,
|
||||||
@ -183,20 +183,15 @@ export default forwardRef<OrderPackageRef, IOrderPackageProps>(
|
|||||||
)
|
)
|
||||||
.map((boxBrand) => {
|
.map((boxBrand) => {
|
||||||
// 将产品按规格分类
|
// 将产品按规格分类
|
||||||
const boxCategoryList: BoxCategory[] = [
|
const boxSpecList: BoxSpec[] =
|
||||||
{
|
boxBrand.boxSpecVOList?.map((item) => {
|
||||||
id: generateShortId(),
|
return {
|
||||||
boxCategoryId: "FOUR_GRAIN",
|
id: generateShortId(),
|
||||||
boxCategoryName: "4粒装",
|
boxSpecId: item.specId,
|
||||||
boxProductList: [],
|
boxSpecName: item.name,
|
||||||
},
|
boxProductList: [],
|
||||||
{
|
};
|
||||||
id: generateShortId(),
|
}) || [];
|
||||||
boxCategoryId: "TWO_GRAIN",
|
|
||||||
boxCategoryName: "2粒装",
|
|
||||||
boxProductList: [],
|
|
||||||
},
|
|
||||||
];
|
|
||||||
const boxProductList = boxBrand.boxProductVOList?.map(
|
const boxProductList = boxBrand.boxProductVOList?.map(
|
||||||
(boxProductVO) => {
|
(boxProductVO) => {
|
||||||
const boxProduct: BoxProduct = {
|
const boxProduct: BoxProduct = {
|
||||||
@ -204,7 +199,8 @@ export default forwardRef<OrderPackageRef, IOrderPackageProps>(
|
|||||||
boxProductId: boxProductVO.productId,
|
boxProductId: boxProductVO.productId,
|
||||||
boxProductName: boxProductVO.name,
|
boxProductName: boxProductVO.name,
|
||||||
boxProductWeight: boxProductVO.weight,
|
boxProductWeight: boxProductVO.weight,
|
||||||
boxCategoryId: boxProductVO.specType,
|
boxSpecId: boxProductVO.specId,
|
||||||
|
boxSpecName: boxProductVO.specName,
|
||||||
boxCostPrice: boxProductVO.costPrice,
|
boxCostPrice: boxProductVO.costPrice,
|
||||||
boxSalePrice: boxProductVO.salePrice,
|
boxSalePrice: boxProductVO.salePrice,
|
||||||
boxBrandId: boxBrand.brandId,
|
boxBrandId: boxBrand.brandId,
|
||||||
@ -222,25 +218,24 @@ export default forwardRef<OrderPackageRef, IOrderPackageProps>(
|
|||||||
boxBrandName: boxBrand.name,
|
boxBrandName: boxBrand.name,
|
||||||
boxBrandImage: boxBrand.image,
|
boxBrandImage: boxBrand.image,
|
||||||
boxBrandType: boxBrand.type,
|
boxBrandType: boxBrand.type,
|
||||||
boxCategoryList:
|
boxSpecList:
|
||||||
boxCategoryList
|
boxSpecList
|
||||||
.map((boxCategory) => {
|
.map((boxSpec) => {
|
||||||
return {
|
return {
|
||||||
id: generateShortId(),
|
id: generateShortId(),
|
||||||
boxCategoryId: boxCategory.boxCategoryId,
|
boxSpecId: boxSpec.boxSpecId,
|
||||||
boxCategoryName: boxCategory.boxCategoryName,
|
boxSpecName: boxSpec.boxSpecName,
|
||||||
boxProductList:
|
boxProductList:
|
||||||
boxProductList?.filter(
|
boxProductList?.filter(
|
||||||
(boxProduct) =>
|
(boxProduct) =>
|
||||||
boxProduct.boxCategoryId ===
|
boxProduct.boxSpecId === boxSpec.boxSpecId,
|
||||||
boxCategory.boxCategoryId,
|
|
||||||
) || [],
|
) || [],
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.filter(
|
.filter(
|
||||||
(boxCategory) =>
|
(boxSpec) =>
|
||||||
boxCategory.boxProductList &&
|
boxSpec.boxProductList &&
|
||||||
boxCategory.boxProductList.length > 0,
|
boxSpec.boxProductList.length > 0,
|
||||||
) || [],
|
) || [],
|
||||||
};
|
};
|
||||||
}) || [];
|
}) || [];
|
||||||
@ -311,8 +306,8 @@ export default forwardRef<OrderPackageRef, IOrderPackageProps>(
|
|||||||
setSelectedBrand(brand);
|
setSelectedBrand(brand);
|
||||||
// 初始化所有产品的数量为0
|
// 初始化所有产品的数量为0
|
||||||
const initialCounts = new Map<string, number>();
|
const initialCounts = new Map<string, number>();
|
||||||
brand.boxCategoryList?.forEach((category) => {
|
brand.boxSpecList?.forEach((boxSpec) => {
|
||||||
category.boxProductList.forEach((product) => {
|
boxSpec.boxProductList.forEach((product) => {
|
||||||
initialCounts.set(product.id, 0);
|
initialCounts.set(product.id, 0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -331,17 +326,15 @@ export default forwardRef<OrderPackageRef, IOrderPackageProps>(
|
|||||||
if (selectedBrand) {
|
if (selectedBrand) {
|
||||||
const updatedBrand = { ...selectedBrand };
|
const updatedBrand = { ...selectedBrand };
|
||||||
|
|
||||||
updatedBrand.boxCategoryList = updatedBrand.boxCategoryList?.map(
|
updatedBrand.boxSpecList = updatedBrand.boxSpecList?.map((boxSpec) => {
|
||||||
(category) => {
|
const updatedProducts = boxSpec.boxProductList.map((product) => {
|
||||||
const updatedProducts = category.boxProductList.map((product) => {
|
if (product.id === productId) {
|
||||||
if (product.id === productId) {
|
return { ...product, boxCount: count };
|
||||||
return { ...product, boxCount: count };
|
}
|
||||||
}
|
return product;
|
||||||
return product;
|
});
|
||||||
});
|
return { ...boxSpec, boxProductList: updatedProducts };
|
||||||
return { ...category, boxProductList: updatedProducts };
|
});
|
||||||
},
|
|
||||||
);
|
|
||||||
setSelectedBrand(updatedBrand);
|
setSelectedBrand(updatedBrand);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -361,7 +354,7 @@ export default forwardRef<OrderPackageRef, IOrderPackageProps>(
|
|||||||
// 过滤掉数量为0的项目
|
// 过滤掉数量为0的项目
|
||||||
const filteredOrderPackages = newOrderPackages.filter((pkg) => {
|
const filteredOrderPackages = newOrderPackages.filter((pkg) => {
|
||||||
// 从productCounts中获取对应产品的数量
|
// 从productCounts中获取对应产品的数量
|
||||||
const product = selectedBrand.boxCategoryList
|
const product = selectedBrand.boxSpecList
|
||||||
?.flatMap((c) => c.boxProductList)
|
?.flatMap((c) => c.boxProductList)
|
||||||
.find((p) => p.id === pkg.orderPackageId);
|
.find((p) => p.id === pkg.orderPackageId);
|
||||||
const count = product ? productCounts.get(product.id) || 0 : 0;
|
const count = product ? productCounts.get(product.id) || 0 : 0;
|
||||||
@ -371,7 +364,7 @@ export default forwardRef<OrderPackageRef, IOrderPackageProps>(
|
|||||||
// 更新数量信息
|
// 更新数量信息
|
||||||
const updatedOrderPackages = filteredOrderPackages.map((pkg) => {
|
const updatedOrderPackages = filteredOrderPackages.map((pkg) => {
|
||||||
// 从productCounts中获取对应产品的数量
|
// 从productCounts中获取对应产品的数量
|
||||||
const product = selectedBrand.boxCategoryList
|
const product = selectedBrand.boxSpecList
|
||||||
?.flatMap((c) => c.boxProductList)
|
?.flatMap((c) => c.boxProductList)
|
||||||
.find((p) => p.id === pkg.orderPackageId);
|
.find((p) => p.id === pkg.orderPackageId);
|
||||||
const count = product ? productCounts.get(product.id) || 0 : 0;
|
const count = product ? productCounts.get(product.id) || 0 : 0;
|
||||||
@ -453,17 +446,17 @@ export default forwardRef<OrderPackageRef, IOrderPackageProps>(
|
|||||||
? {
|
? {
|
||||||
...fullBrandInfo,
|
...fullBrandInfo,
|
||||||
boxType: item.boxType, // 保持boxType
|
boxType: item.boxType, // 保持boxType
|
||||||
boxCategoryList: fullBrandInfo.boxCategoryList?.map((category) => {
|
boxSpecList: fullBrandInfo.boxSpecList?.map((boxSpec) => {
|
||||||
// 找到对应的已存在分类数据
|
// 找到对应的已存在分类数据
|
||||||
const existingCategory = brandToEdit?.boxCategoryList?.find(
|
const existingSpec = brandToEdit?.boxSpecList?.find(
|
||||||
(cat) => cat.boxCategoryId === category.boxCategoryId,
|
(spec) => spec.boxSpecId === boxSpec.boxSpecId,
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...category,
|
...boxSpec,
|
||||||
boxProductList: category.boxProductList.map((product) => {
|
boxProductList: boxSpec.boxProductList.map((product) => {
|
||||||
// 找到对应的产品数据
|
// 找到对应的产品数据
|
||||||
const existingProduct = existingCategory?.boxProductList.find(
|
const existingProduct = existingSpec?.boxProductList.find(
|
||||||
(prod) => prod.boxProductId === product.boxProductId,
|
(prod) => prod.boxProductId === product.boxProductId,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -486,7 +479,7 @@ export default forwardRef<OrderPackageRef, IOrderPackageProps>(
|
|||||||
|
|
||||||
// 更新编辑项中的数量
|
// 更新编辑项中的数量
|
||||||
const updateEditingItemCount = (
|
const updateEditingItemCount = (
|
||||||
categoryIndex: number,
|
specIndex: number,
|
||||||
detailIndex: number,
|
detailIndex: number,
|
||||||
count: number,
|
count: number,
|
||||||
) => {
|
) => {
|
||||||
@ -501,25 +494,23 @@ export default forwardRef<OrderPackageRef, IOrderPackageProps>(
|
|||||||
|
|
||||||
const updatedItem = { ...editingItem };
|
const updatedItem = { ...editingItem };
|
||||||
|
|
||||||
// 确保boxCategoryList存在
|
// 确保boxSpecList存在
|
||||||
if (!updatedItem.boxCategoryList) {
|
if (!updatedItem.boxSpecList) {
|
||||||
updatedItem.boxCategoryList = fullBrandInfo.boxCategoryList.map(
|
updatedItem.boxSpecList = fullBrandInfo.boxSpecList.map((boxSpec) => ({
|
||||||
(category) => ({
|
...boxSpec,
|
||||||
...category,
|
boxProductList: boxSpec.boxProductList.map((product) => ({
|
||||||
boxProductList: category.boxProductList.map((product) => ({
|
...product,
|
||||||
...product,
|
boxCount: 0,
|
||||||
boxCount: 0,
|
})),
|
||||||
})),
|
}));
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 确保category存在
|
// 确保spec存在
|
||||||
if (!updatedItem.boxCategoryList[categoryIndex]) {
|
if (!updatedItem.boxSpecList[specIndex]) {
|
||||||
updatedItem.boxCategoryList[categoryIndex] = {
|
updatedItem.boxSpecList[specIndex] = {
|
||||||
...fullBrandInfo.boxCategoryList[categoryIndex],
|
...fullBrandInfo.boxSpecList[specIndex],
|
||||||
boxProductList: fullBrandInfo.boxCategoryList[
|
boxProductList: fullBrandInfo.boxSpecList[
|
||||||
categoryIndex
|
specIndex
|
||||||
].boxProductList.map((product) => ({
|
].boxProductList.map((product) => ({
|
||||||
...product,
|
...product,
|
||||||
boxCount: 0,
|
boxCount: 0,
|
||||||
@ -528,26 +519,24 @@ export default forwardRef<OrderPackageRef, IOrderPackageProps>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 更新对应的产品数量
|
// 更新对应的产品数量
|
||||||
const category = { ...updatedItem.boxCategoryList[categoryIndex] };
|
const boxSpec = { ...updatedItem.boxSpecList[specIndex] };
|
||||||
|
|
||||||
// 确保boxProductList存在
|
// 确保boxProductList存在
|
||||||
if (!category.boxProductList) {
|
if (!boxSpec.boxProductList) {
|
||||||
category.boxProductList = fullBrandInfo.boxCategoryList[
|
boxSpec.boxProductList = fullBrandInfo.boxSpecList[
|
||||||
categoryIndex
|
specIndex
|
||||||
].boxProductList.map((product) => ({
|
].boxProductList.map((product) => ({
|
||||||
...product,
|
...product,
|
||||||
boxCount: 0,
|
boxCount: 0,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
const boxProductList = [...category.boxProductList];
|
const boxProductList = [...boxSpec.boxProductList];
|
||||||
|
|
||||||
// 确保产品存在
|
// 确保产品存在
|
||||||
if (!boxProductList[detailIndex]) {
|
if (!boxProductList[detailIndex]) {
|
||||||
boxProductList[detailIndex] = {
|
boxProductList[detailIndex] = {
|
||||||
...fullBrandInfo.boxCategoryList[categoryIndex].boxProductList[
|
...fullBrandInfo.boxSpecList[specIndex].boxProductList[detailIndex],
|
||||||
detailIndex
|
|
||||||
],
|
|
||||||
boxCount: 0,
|
boxCount: 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -557,10 +546,10 @@ export default forwardRef<OrderPackageRef, IOrderPackageProps>(
|
|||||||
boxCount: count,
|
boxCount: count,
|
||||||
};
|
};
|
||||||
|
|
||||||
category.boxProductList = boxProductList;
|
boxSpec.boxProductList = boxProductList;
|
||||||
const updatedCategories = [...updatedItem.boxCategoryList];
|
const updatedSpecList = [...updatedItem.boxSpecList];
|
||||||
updatedCategories[categoryIndex] = category;
|
updatedSpecList[specIndex] = boxSpec;
|
||||||
updatedItem.boxCategoryList = updatedCategories;
|
updatedItem.boxSpecList = updatedSpecList;
|
||||||
|
|
||||||
setEditingItem(updatedItem);
|
setEditingItem(updatedItem);
|
||||||
};
|
};
|
||||||
@ -686,17 +675,17 @@ export default forwardRef<OrderPackageRef, IOrderPackageProps>(
|
|||||||
|
|
||||||
{/* 详细信息展示,按分类显示 */}
|
{/* 详细信息展示,按分类显示 */}
|
||||||
<View className="space-y-2">
|
<View className="space-y-2">
|
||||||
{item.boxCategoryList &&
|
{item.boxSpecList &&
|
||||||
item.boxCategoryList.map((categoryData, categoryIndex) => (
|
item.boxSpecList.map((boxSpec, boxIndex) => (
|
||||||
<View
|
<View
|
||||||
key={categoryIndex}
|
key={boxIndex}
|
||||||
className="rounded-lg bg-gray-50 p-3 text-sm text-gray-600"
|
className="rounded-lg bg-gray-50 p-3 text-sm text-gray-600"
|
||||||
>
|
>
|
||||||
<View className="mb-1 font-medium text-gray-700">
|
<View className="mb-1 font-medium text-gray-700">
|
||||||
{categoryData.boxCategoryName}
|
{boxSpec.boxSpecName}
|
||||||
</View>
|
</View>
|
||||||
<View>
|
<View>
|
||||||
{categoryData.boxProductList
|
{boxSpec.boxProductList
|
||||||
.map(
|
.map(
|
||||||
(detail) =>
|
(detail) =>
|
||||||
`${detail.boxProductName} 共 ${detail.boxCount} 个`,
|
`${detail.boxProductName} 共 ${detail.boxCount} 个`,
|
||||||
@ -854,13 +843,13 @@ export default forwardRef<OrderPackageRef, IOrderPackageProps>(
|
|||||||
<View className="mb-2 text-sm text-gray-600">
|
<View className="mb-2 text-sm text-gray-600">
|
||||||
纸箱规格(点击 +/- 修改数量,0表示不使用)
|
纸箱规格(点击 +/- 修改数量,0表示不使用)
|
||||||
</View>
|
</View>
|
||||||
{selectedBrand.boxCategoryList?.map((category) => (
|
{selectedBrand.boxSpecList?.map((boxSpec) => (
|
||||||
<View key={category.id} className="mb-4">
|
<View key={boxSpec.id} className="mb-4">
|
||||||
<View className="mb-2 text-base font-medium">
|
<View className="mb-2 text-base font-medium">
|
||||||
{category.boxCategoryName}
|
{boxSpec.boxSpecName}
|
||||||
</View>
|
</View>
|
||||||
<View className="space-y-3">
|
<View className="space-y-3">
|
||||||
{category.boxProductList.map((boxProduct) => {
|
{boxSpec.boxProductList.map((boxProduct) => {
|
||||||
const currentCount =
|
const currentCount =
|
||||||
productCounts.get(boxProduct.id) || 0;
|
productCounts.get(boxProduct.id) || 0;
|
||||||
return (
|
return (
|
||||||
@ -1005,91 +994,81 @@ export default forwardRef<OrderPackageRef, IOrderPackageProps>(
|
|||||||
<View className="mb-4">
|
<View className="mb-4">
|
||||||
<View className="mb-2 text-sm text-gray-600">纸箱详情</View>
|
<View className="mb-2 text-sm text-gray-600">纸箱详情</View>
|
||||||
<View className="space-y-3">
|
<View className="space-y-3">
|
||||||
{editingItem?.boxCategoryList &&
|
{editingItem?.boxSpecList &&
|
||||||
editingItem.boxCategoryList.map(
|
editingItem.boxSpecList.map((boxSpec, specId) => (
|
||||||
(categoryData, categoryIndex) => (
|
<View key={specId} className="rounded-lg bg-gray-50 p-3">
|
||||||
<View
|
<View className="mb-2 text-base font-medium text-gray-800">
|
||||||
key={categoryIndex}
|
{boxSpec.boxSpecName}
|
||||||
className="rounded-lg bg-gray-50 p-3"
|
|
||||||
>
|
|
||||||
<View className="mb-2 text-base font-medium text-gray-800">
|
|
||||||
{categoryData.boxCategoryName}
|
|
||||||
</View>
|
|
||||||
<View className="space-y-2">
|
|
||||||
{categoryData.boxProductList.map(
|
|
||||||
(detail, detailIndex) => {
|
|
||||||
const currentCount = detail?.boxCount || 0;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<View
|
|
||||||
key={detailIndex}
|
|
||||||
className="flex items-center justify-between py-1"
|
|
||||||
>
|
|
||||||
<View className="text-gray-600">
|
|
||||||
{detail.boxProductName}
|
|
||||||
</View>
|
|
||||||
<View className="flex items-center">
|
|
||||||
<View
|
|
||||||
className="flex h-8 w-8 items-center justify-center rounded-l bg-gray-200"
|
|
||||||
onClick={() => {
|
|
||||||
const newCount = Math.max(
|
|
||||||
0,
|
|
||||||
currentCount - 1,
|
|
||||||
);
|
|
||||||
updateEditingItemCount(
|
|
||||||
categoryIndex,
|
|
||||||
detailIndex,
|
|
||||||
newCount,
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Icon name="minus" size={16} />
|
|
||||||
</View>
|
|
||||||
<View className="flex h-8 w-12 items-center justify-center border-y border-gray-200">
|
|
||||||
<Input
|
|
||||||
type="number"
|
|
||||||
value={currentCount.toString()}
|
|
||||||
align={"center"}
|
|
||||||
className="!h-8 !w-12 !p-0 !text-center"
|
|
||||||
onChange={(value) => {
|
|
||||||
const num = Number(value);
|
|
||||||
if (
|
|
||||||
!Number.isNaN(num) &&
|
|
||||||
num >= 0
|
|
||||||
) {
|
|
||||||
updateEditingItemCount(
|
|
||||||
categoryIndex,
|
|
||||||
detailIndex,
|
|
||||||
num,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
<View
|
|
||||||
className="flex h-8 w-8 items-center justify-center rounded-r bg-gray-200"
|
|
||||||
onClick={() => {
|
|
||||||
updateEditingItemCount(
|
|
||||||
categoryIndex,
|
|
||||||
detailIndex,
|
|
||||||
currentCount + 1,
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Icon name="plus" size={16} />
|
|
||||||
</View>
|
|
||||||
<View className="ml-2 font-medium text-gray-800">
|
|
||||||
个
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
)}
|
|
||||||
</View>
|
|
||||||
</View>
|
</View>
|
||||||
),
|
<View className="space-y-2">
|
||||||
)}
|
{boxSpec.boxProductList.map((detail, detailIndex) => {
|
||||||
|
const currentCount = detail?.boxCount || 0;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View
|
||||||
|
key={detailIndex}
|
||||||
|
className="flex items-center justify-between py-1"
|
||||||
|
>
|
||||||
|
<View className="text-gray-600">
|
||||||
|
{detail.boxProductName}
|
||||||
|
</View>
|
||||||
|
<View className="flex items-center">
|
||||||
|
<View
|
||||||
|
className="flex h-8 w-8 items-center justify-center rounded-l bg-gray-200"
|
||||||
|
onClick={() => {
|
||||||
|
const newCount = Math.max(
|
||||||
|
0,
|
||||||
|
currentCount - 1,
|
||||||
|
);
|
||||||
|
updateEditingItemCount(
|
||||||
|
specId,
|
||||||
|
detailIndex,
|
||||||
|
newCount,
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Icon name="minus" size={16} />
|
||||||
|
</View>
|
||||||
|
<View className="flex h-8 w-12 items-center justify-center border-y border-gray-200">
|
||||||
|
<Input
|
||||||
|
type="number"
|
||||||
|
value={currentCount.toString()}
|
||||||
|
align={"center"}
|
||||||
|
className="!h-8 !w-12 !p-0 !text-center"
|
||||||
|
onChange={(value) => {
|
||||||
|
const num = Number(value);
|
||||||
|
if (!Number.isNaN(num) && num >= 0) {
|
||||||
|
updateEditingItemCount(
|
||||||
|
specId,
|
||||||
|
detailIndex,
|
||||||
|
num,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<View
|
||||||
|
className="flex h-8 w-8 items-center justify-center rounded-r bg-gray-200"
|
||||||
|
onClick={() => {
|
||||||
|
updateEditingItemCount(
|
||||||
|
specId,
|
||||||
|
detailIndex,
|
||||||
|
currentCount + 1,
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Icon name="plus" size={16} />
|
||||||
|
</View>
|
||||||
|
<View className="ml-2 font-medium text-gray-800">
|
||||||
|
个
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
))}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|||||||
@ -68,18 +68,7 @@ export default function PurchasePreview(props: IPurchasePreviewProps) {
|
|||||||
const [columns] = useState<Array<TableColumnProps>>([
|
const [columns] = useState<Array<TableColumnProps>>([
|
||||||
{
|
{
|
||||||
title: "规格",
|
title: "规格",
|
||||||
key: "boxCategoryId",
|
key: "boxSpecName",
|
||||||
render: (record: any) => {
|
|
||||||
return (
|
|
||||||
<View>
|
|
||||||
{record.boxCategoryId === "FOUR_GRAIN"
|
|
||||||
? "4粒"
|
|
||||||
: record.boxCategoryId === "TWO_GRAIN"
|
|
||||||
? "2粒"
|
|
||||||
: "其他"}
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
fixed: "left",
|
fixed: "left",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,12 +1,10 @@
|
|||||||
import { Table } from "@nutui/nutui-react-taro";
|
import { Table } from "@nutui/nutui-react-taro";
|
||||||
import { formatCurrency } from "@/utils/format";
|
import { formatCurrency } from "@/utils/format";
|
||||||
|
|
||||||
export default function EmptyBoxInfoSection(props: {
|
export default function EmptyBoxInfoSection(_props: {
|
||||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||||
readOnly?: boolean;
|
readOnly?: boolean;
|
||||||
}) {
|
}) {
|
||||||
const { purchaseOrderVO } = props;
|
|
||||||
|
|
||||||
// 将所有空箱信息合并并按品牌、型号、规格分组
|
// 将所有空箱信息合并并按品牌、型号、规格分组
|
||||||
// const groupedEmptyBoxData = purchaseOrderVO.orderSupplierList?.reduce(
|
// const groupedEmptyBoxData = purchaseOrderVO.orderSupplierList?.reduce(
|
||||||
// (acc, supplier) => {
|
// (acc, supplier) => {
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import { Button, Input, Popup, SafeArea, Table } from "@nutui/nutui-react-taro";
|
|||||||
import { Icon } from "@/components";
|
import { Icon } from "@/components";
|
||||||
import { View } from "@tarojs/components";
|
import { View } from "@tarojs/components";
|
||||||
|
|
||||||
|
|
||||||
export default function PackageInfoSection(props: {
|
export default function PackageInfoSection(props: {
|
||||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||||
onChange?: (purchaseOrderVO: BusinessAPI.PurchaseOrderVO) => void;
|
onChange?: (purchaseOrderVO: BusinessAPI.PurchaseOrderVO) => void;
|
||||||
@ -20,7 +19,7 @@ export default function PackageInfoSection(props: {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "规格",
|
title: "规格",
|
||||||
key: "boxCategoryName",
|
key: "boxSpecName",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "纸箱型号",
|
title: "纸箱型号",
|
||||||
@ -33,7 +32,12 @@ export default function PackageInfoSection(props: {
|
|||||||
{
|
{
|
||||||
title: "销售单价(元/斤)",
|
title: "销售单价(元/斤)",
|
||||||
key: "boxSalePrice",
|
key: "boxSalePrice",
|
||||||
render: (value: BusinessAPI.OrderPackage & { orderPackageId?: string, isTotalRow?: boolean }) => {
|
render: (
|
||||||
|
value: BusinessAPI.OrderPackage & {
|
||||||
|
orderPackageId?: string;
|
||||||
|
isTotalRow?: boolean;
|
||||||
|
},
|
||||||
|
) => {
|
||||||
// 合计行不显示编辑按钮
|
// 合计行不显示编辑按钮
|
||||||
if (value.isTotalRow) {
|
if (value.isTotalRow) {
|
||||||
return formatCurrency(value.boxSalePrice as number);
|
return formatCurrency(value.boxSalePrice as number);
|
||||||
@ -41,14 +45,15 @@ export default function PackageInfoSection(props: {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
className="flex items-center justify-between w-full"
|
className="flex w-full items-center justify-between"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
if (!readOnly) {
|
if (!readOnly) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
// 设置临时编辑值为当前值
|
// 设置临时编辑值为当前值
|
||||||
setTempEditValues((prev) => ({
|
setTempEditValues((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
[value.orderPackageId || ""]: editValues[value.orderPackageId || ""],
|
[value.orderPackageId || ""]:
|
||||||
|
editValues[value.orderPackageId || ""],
|
||||||
}));
|
}));
|
||||||
setVisiblePopup((prev) => ({
|
setVisiblePopup((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
@ -57,9 +62,11 @@ export default function PackageInfoSection(props: {
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<View className={!readOnly ? "underline cursor-pointer" : ""}>{formatCurrency(value.boxSalePrice as number)}</View>
|
<View className={!readOnly ? "cursor-pointer underline" : ""}>
|
||||||
|
{formatCurrency(value.boxSalePrice as number)}
|
||||||
|
</View>
|
||||||
{!readOnly && (
|
{!readOnly && (
|
||||||
<View className="flex items-center justify-center ml-2 p-2 -m-2">
|
<View className="-m-2 ml-2 flex items-center justify-center p-2">
|
||||||
<Icon name={"pen-to-square"} size={16} color={"#1a73e8"} />
|
<Icon name={"pen-to-square"} size={16} color={"#1a73e8"} />
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
@ -70,7 +77,12 @@ export default function PackageInfoSection(props: {
|
|||||||
{
|
{
|
||||||
title: "销售金额(元)",
|
title: "销售金额(元)",
|
||||||
key: "boxSalePayment",
|
key: "boxSalePayment",
|
||||||
render: (value: BusinessAPI.OrderPackage & { boxProductCount: number, isTotalRow?: boolean }) =>
|
render: (
|
||||||
|
value: BusinessAPI.OrderPackage & {
|
||||||
|
boxProductCount: number;
|
||||||
|
isTotalRow?: boolean;
|
||||||
|
},
|
||||||
|
) =>
|
||||||
formatCurrency(
|
formatCurrency(
|
||||||
Number((value?.boxSalePrice || 0) * value.boxProductCount) as number,
|
Number((value?.boxSalePrice || 0) * value.boxProductCount) as number,
|
||||||
),
|
),
|
||||||
@ -78,7 +90,12 @@ export default function PackageInfoSection(props: {
|
|||||||
{
|
{
|
||||||
title: "箱重(斤)",
|
title: "箱重(斤)",
|
||||||
key: "boxProductWeight",
|
key: "boxProductWeight",
|
||||||
render: (value: BusinessAPI.OrderPackage & { orderPackageId?: string, isTotalRow?: boolean }) => {
|
render: (
|
||||||
|
value: BusinessAPI.OrderPackage & {
|
||||||
|
orderPackageId?: string;
|
||||||
|
isTotalRow?: boolean;
|
||||||
|
},
|
||||||
|
) => {
|
||||||
// 合计行不显示编辑按钮
|
// 合计行不显示编辑按钮
|
||||||
if (value.isTotalRow) {
|
if (value.isTotalRow) {
|
||||||
return formatCurrency(value.boxProductWeight);
|
return formatCurrency(value.boxProductWeight);
|
||||||
@ -86,14 +103,15 @@ export default function PackageInfoSection(props: {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
className="flex items-center justify-between w-full"
|
className="flex w-full items-center justify-between"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
if (!readOnly) {
|
if (!readOnly) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
// 设置临时编辑值为当前值
|
// 设置临时编辑值为当前值
|
||||||
setTempEditValues((prev) => ({
|
setTempEditValues((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
[value.orderPackageId || ""]: editValues[value.orderPackageId || ""],
|
[value.orderPackageId || ""]:
|
||||||
|
editValues[value.orderPackageId || ""],
|
||||||
}));
|
}));
|
||||||
setVisiblePopup((prev) => ({
|
setVisiblePopup((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
@ -102,9 +120,11 @@ export default function PackageInfoSection(props: {
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<View className={!readOnly ? "underline cursor-pointer" : ""}>{formatCurrency(value.boxProductWeight)}</View>
|
<View className={!readOnly ? "cursor-pointer underline" : ""}>
|
||||||
|
{formatCurrency(value.boxProductWeight)}
|
||||||
|
</View>
|
||||||
{!readOnly && (
|
{!readOnly && (
|
||||||
<View className="flex items-center justify-center ml-2 p-2 -m-2">
|
<View className="-m-2 ml-2 flex items-center justify-center p-2">
|
||||||
<Icon name={"pen-to-square"} size={16} color={"#1a73e8"} />
|
<Icon name={"pen-to-square"} size={16} color={"#1a73e8"} />
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
@ -115,7 +135,12 @@ export default function PackageInfoSection(props: {
|
|||||||
{
|
{
|
||||||
title: "成本单价(元)",
|
title: "成本单价(元)",
|
||||||
key: "boxCostPrice",
|
key: "boxCostPrice",
|
||||||
render: (value: BusinessAPI.OrderPackage & { orderPackageId?: string, isTotalRow?: boolean }) => {
|
render: (
|
||||||
|
value: BusinessAPI.OrderPackage & {
|
||||||
|
orderPackageId?: string;
|
||||||
|
isTotalRow?: boolean;
|
||||||
|
},
|
||||||
|
) => {
|
||||||
// 合计行不显示编辑按钮
|
// 合计行不显示编辑按钮
|
||||||
if (value.isTotalRow) {
|
if (value.isTotalRow) {
|
||||||
return formatCurrency(value.boxCostPrice as number);
|
return formatCurrency(value.boxCostPrice as number);
|
||||||
@ -123,14 +148,15 @@ export default function PackageInfoSection(props: {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
className="flex items-center justify-between w-full"
|
className="flex w-full items-center justify-between"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
if (!readOnly) {
|
if (!readOnly) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
// 设置临时编辑值为当前值
|
// 设置临时编辑值为当前值
|
||||||
setTempEditValues((prev) => ({
|
setTempEditValues((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
[value.orderPackageId || ""]: editValues[value.orderPackageId || ""],
|
[value.orderPackageId || ""]:
|
||||||
|
editValues[value.orderPackageId || ""],
|
||||||
}));
|
}));
|
||||||
setVisiblePopup((prev) => ({
|
setVisiblePopup((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
@ -139,9 +165,11 @@ export default function PackageInfoSection(props: {
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<View className={!readOnly ? "underline cursor-pointer" : ""}>{formatCurrency(value.boxCostPrice as number)}</View>
|
<View className={!readOnly ? "cursor-pointer underline" : ""}>
|
||||||
|
{formatCurrency(value.boxCostPrice as number)}
|
||||||
|
</View>
|
||||||
{!readOnly && (
|
{!readOnly && (
|
||||||
<View className="flex items-center justify-center ml-2 p-2 -m-2">
|
<View className="-m-2 ml-2 flex items-center justify-center p-2">
|
||||||
<Icon name={"pen-to-square"} size={16} color={"#1a73e8"} />
|
<Icon name={"pen-to-square"} size={16} color={"#1a73e8"} />
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
@ -226,20 +254,17 @@ export default function PackageInfoSection(props: {
|
|||||||
(acc, supplier) => {
|
(acc, supplier) => {
|
||||||
supplier.orderPackageList?.forEach((pkg) => {
|
supplier.orderPackageList?.forEach((pkg) => {
|
||||||
// 生成分组键
|
// 生成分组键
|
||||||
const key = `${pkg.boxBrandName}-${pkg.boxProductName}-${pkg.boxCategoryId}`;
|
const key = `${pkg.boxBrandName}-${pkg.boxProductName}-${pkg.boxSpecId}`;
|
||||||
|
|
||||||
// 转换规格字段
|
// 转换规格字段
|
||||||
const boxCategoryName =
|
const boxSpecId = pkg.boxSpecId;
|
||||||
pkg.boxCategoryId === "FOUR_GRAIN"
|
const boxSpecName = pkg.boxSpecName;
|
||||||
? "4粒"
|
|
||||||
: pkg.boxCategoryId === "TWO_GRAIN"
|
|
||||||
? "2粒"
|
|
||||||
: "其他";
|
|
||||||
|
|
||||||
if (!acc[key]) {
|
if (!acc[key]) {
|
||||||
acc[key] = {
|
acc[key] = {
|
||||||
...pkg,
|
...pkg,
|
||||||
boxCategoryName,
|
boxSpecId,
|
||||||
|
boxSpecName,
|
||||||
boxProductCount: 0,
|
boxProductCount: 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -213,7 +213,8 @@ export default hocAuth(function Page(props: CommonComponent) {
|
|||||||
packingSpec: {
|
packingSpec: {
|
||||||
data:
|
data:
|
||||||
shipOrderVO.shipOrderPackageList?.map((item) => ({
|
shipOrderVO.shipOrderPackageList?.map((item) => ({
|
||||||
boxCategory: item.boxCategory || "",
|
boxSpecId: item.boxSpecId || "",
|
||||||
|
boxSpecName: item.boxSpecName || "",
|
||||||
boxType: item.boxProduct || "",
|
boxType: item.boxProduct || "",
|
||||||
quantity: item.quantity?.toString() || "",
|
quantity: item.quantity?.toString() || "",
|
||||||
unitPrice: item.unitPrice?.toString() || "",
|
unitPrice: item.unitPrice?.toString() || "",
|
||||||
@ -1078,13 +1079,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
|||||||
htmlString += `
|
htmlString += `
|
||||||
<div class="${gridClass} ${index > 0 ? "border-t-0" : ""}">
|
<div class="${gridClass} ${index > 0 ? "border-t-0" : ""}">
|
||||||
<div class="flex items-end justify-center">
|
<div class="flex items-end justify-center">
|
||||||
${
|
${item.boxSpecName}
|
||||||
item.boxCategory === "FOUR_GRAIN"
|
|
||||||
? "4粒装"
|
|
||||||
: item.boxCategory === "TWO_GRAIN"
|
|
||||||
? "2粒装"
|
|
||||||
: "未知"
|
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@ -2126,11 +2121,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
|||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<View className={"flex items-end justify-center"}>
|
<View className={"flex items-end justify-center"}>
|
||||||
{item.boxCategory === "FOUR_GRAIN"
|
{item.boxSpecName}
|
||||||
? "4粒装"
|
|
||||||
: item.boxCategory === "TWO_GRAIN"
|
|
||||||
? "2粒装"
|
|
||||||
: "未知"}
|
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View className={"flex items-end justify-center"}>
|
<View className={"flex items-end justify-center"}>
|
||||||
|
|||||||
@ -151,7 +151,8 @@ export default hocAuth(function Page(props: CommonComponent) {
|
|||||||
packingSpec: {
|
packingSpec: {
|
||||||
data:
|
data:
|
||||||
shipOrderVO.shipOrderPackageList?.map((item) => ({
|
shipOrderVO.shipOrderPackageList?.map((item) => ({
|
||||||
boxCategory: item.boxCategory || "",
|
boxSpecId: item.boxSpecId || "",
|
||||||
|
boxSpecName: item.boxSpecName || "",
|
||||||
boxType: item.boxProduct || "",
|
boxType: item.boxProduct || "",
|
||||||
quantity: item.quantity?.toString() || "",
|
quantity: item.quantity?.toString() || "",
|
||||||
unitPrice: item.unitPrice?.toString() || "",
|
unitPrice: item.unitPrice?.toString() || "",
|
||||||
@ -1006,13 +1007,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
|||||||
htmlString += `
|
htmlString += `
|
||||||
<div class="${gridClass} ${index > 0 ? "border-t-0" : ""}">
|
<div class="${gridClass} ${index > 0 ? "border-t-0" : ""}">
|
||||||
<div class="flex items-end justify-center">
|
<div class="flex items-end justify-center">
|
||||||
${
|
${item.boxSpecName}
|
||||||
item.boxCategory === "FOUR_GRAIN"
|
|
||||||
? "4粒装"
|
|
||||||
: item.boxCategory === "TWO_GRAIN"
|
|
||||||
? "2粒装"
|
|
||||||
: "未知"
|
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@ -1948,11 +1943,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
|||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<View className={"flex items-end justify-center"}>
|
<View className={"flex items-end justify-center"}>
|
||||||
{item.boxCategory === "FOUR_GRAIN"
|
{item.boxSpecName}
|
||||||
? "4粒装"
|
|
||||||
: item.boxCategory === "TWO_GRAIN"
|
|
||||||
? "2粒装"
|
|
||||||
: "未知"}
|
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View className={"flex items-end justify-center"}>
|
<View className={"flex items-end justify-center"}>
|
||||||
|
|||||||
@ -25,11 +25,11 @@ import {
|
|||||||
Weigh,
|
Weigh,
|
||||||
WeighRef,
|
WeighRef,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { calculateSupplierWeights } from "@/utils/calculateSupplierWeights";
|
|
||||||
import { business } from "@/services";
|
import { business } from "@/services";
|
||||||
import { generateShortId } from "@/utils/generateShortId";
|
import { generateShortId } from "@/utils/generateShortId";
|
||||||
import Taro from "@tarojs/taro";
|
import Taro from "@tarojs/taro";
|
||||||
import buildUrl from "@/utils/buildUrl";
|
import buildUrl from "@/utils/buildUrl";
|
||||||
|
import { SupplierWeightCalculator } from "@/utils/SupplierWeightCalculator";
|
||||||
|
|
||||||
const defaultSupplierList: SupplierVO[] = [
|
const defaultSupplierList: SupplierVO[] = [
|
||||||
{
|
{
|
||||||
@ -191,10 +191,15 @@ export default hocAuth(function Page(props: CommonComponent) {
|
|||||||
}, [active]);
|
}, [active]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setPurchaseOrder((prev) => ({
|
if (orderSupplierList) {
|
||||||
...prev!,
|
const supplierWeightCalculator = new SupplierWeightCalculator(
|
||||||
orderSupplierList: calculateSupplierWeights(orderSupplierList),
|
orderSupplierList as any,
|
||||||
}));
|
);
|
||||||
|
setPurchaseOrder((prev) => ({
|
||||||
|
...prev!,
|
||||||
|
orderSupplierList: supplierWeightCalculator.calculate(),
|
||||||
|
}));
|
||||||
|
}
|
||||||
}, [orderSupplierList]);
|
}, [orderSupplierList]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
126
packages/app-client/src/services/business/boxSpec.ts
Normal file
126
packages/app-client/src/services/business/boxSpec.ts
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
// @ts-ignore
|
||||||
|
/* eslint-disable */
|
||||||
|
import request from "../request";
|
||||||
|
|
||||||
|
/** 创建纸箱规格 POST /operation/createBoxSpec */
|
||||||
|
export async function createBoxSpec(
|
||||||
|
body: BusinessAPI.BoxSpecCreateCmd,
|
||||||
|
options?: { [key: string]: any },
|
||||||
|
) {
|
||||||
|
return request<BusinessAPI.SingleResponseBoxSpecVO>(
|
||||||
|
"/operation/createBoxSpec",
|
||||||
|
{
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
data: body,
|
||||||
|
...(options || {}),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 纸箱规格删除 DELETE /operation/destroyBoxSpec */
|
||||||
|
export async function destroyBoxSpec(
|
||||||
|
body: BusinessAPI.BoxSpecDestroyCmd,
|
||||||
|
options?: { [key: string]: any },
|
||||||
|
) {
|
||||||
|
return request<BusinessAPI.Response>("/operation/destroyBoxSpec", {
|
||||||
|
method: "DELETE",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
data: body,
|
||||||
|
...(options || {}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 纸箱规格列表 GET /operation/listBoxSpec */
|
||||||
|
export async function listBoxSpec(
|
||||||
|
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
|
||||||
|
params: BusinessAPI.listBoxSpecParams,
|
||||||
|
options?: { [key: string]: any },
|
||||||
|
) {
|
||||||
|
return request<BusinessAPI.MultiResponseBoxSpecVO>("/operation/listBoxSpec", {
|
||||||
|
method: "GET",
|
||||||
|
params: {
|
||||||
|
...params,
|
||||||
|
boxSpecListQry: undefined,
|
||||||
|
...params["boxSpecListQry"],
|
||||||
|
},
|
||||||
|
...(options || {}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 纸箱规格列表 GET /operation/pageBoxSpec */
|
||||||
|
export async function pageBoxSpec(
|
||||||
|
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
|
||||||
|
params: BusinessAPI.pageBoxSpecParams,
|
||||||
|
options?: { [key: string]: any },
|
||||||
|
) {
|
||||||
|
return request<BusinessAPI.PageResponseBoxSpecVO>("/operation/pageBoxSpec", {
|
||||||
|
method: "GET",
|
||||||
|
params: {
|
||||||
|
...params,
|
||||||
|
boxSpecPageQry: undefined,
|
||||||
|
...params["boxSpecPageQry"],
|
||||||
|
},
|
||||||
|
...(options || {}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 纸箱规格详情 GET /operation/showBoxSpec */
|
||||||
|
export async function showBoxSpec(
|
||||||
|
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
|
||||||
|
params: BusinessAPI.showBoxSpecParams,
|
||||||
|
options?: { [key: string]: any },
|
||||||
|
) {
|
||||||
|
return request<BusinessAPI.SingleResponseBoxSpecVO>(
|
||||||
|
"/operation/showBoxSpec",
|
||||||
|
{
|
||||||
|
method: "GET",
|
||||||
|
params: {
|
||||||
|
...params,
|
||||||
|
boxSpecShowQry: undefined,
|
||||||
|
...params["boxSpecShowQry"],
|
||||||
|
},
|
||||||
|
...(options || {}),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 纸箱规格更新 PUT /operation/updateBoxSpec */
|
||||||
|
export async function updateBoxSpec(
|
||||||
|
body: BusinessAPI.BoxSpecUpdateCmd,
|
||||||
|
options?: { [key: string]: any },
|
||||||
|
) {
|
||||||
|
return request<BusinessAPI.SingleResponseBoxSpecVO>(
|
||||||
|
"/operation/updateBoxSpec",
|
||||||
|
{
|
||||||
|
method: "PUT",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
data: body,
|
||||||
|
...(options || {}),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 纸箱规格更新 PATCH /operation/updateBoxSpec */
|
||||||
|
export async function updateBoxSpec1(
|
||||||
|
body: BusinessAPI.BoxSpecUpdateCmd,
|
||||||
|
options?: { [key: string]: any },
|
||||||
|
) {
|
||||||
|
return request<BusinessAPI.SingleResponseBoxSpecVO>(
|
||||||
|
"/operation/updateBoxSpec",
|
||||||
|
{
|
||||||
|
method: "PATCH",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
data: body,
|
||||||
|
...(options || {}),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -23,12 +23,14 @@ import * as costItem from "./costItem";
|
|||||||
import * as company from "./company";
|
import * as company from "./company";
|
||||||
import * as companyPaymentAccount from "./companyPaymentAccount";
|
import * as companyPaymentAccount from "./companyPaymentAccount";
|
||||||
import * as channel from "./channel";
|
import * as channel from "./channel";
|
||||||
|
import * as boxSpec from "./boxSpec";
|
||||||
import * as boxProduct from "./boxProduct";
|
import * as boxProduct from "./boxProduct";
|
||||||
import * as boxBrand from "./boxBrand";
|
import * as boxBrand from "./boxBrand";
|
||||||
import * as agreement from "./agreement";
|
import * as agreement from "./agreement";
|
||||||
import * as role from "./role";
|
import * as role from "./role";
|
||||||
import * as permission from "./permission";
|
import * as permission from "./permission";
|
||||||
import * as extraction from "./extraction";
|
import * as extraction from "./extraction";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
user,
|
user,
|
||||||
supplier,
|
supplier,
|
||||||
@ -51,6 +53,7 @@ export default {
|
|||||||
company,
|
company,
|
||||||
companyPaymentAccount,
|
companyPaymentAccount,
|
||||||
channel,
|
channel,
|
||||||
|
boxSpec,
|
||||||
boxProduct,
|
boxProduct,
|
||||||
boxBrand,
|
boxBrand,
|
||||||
agreement,
|
agreement,
|
||||||
|
|||||||
@ -103,12 +103,14 @@ declare namespace BusinessAPI {
|
|||||||
name: string;
|
name: string;
|
||||||
/** 品牌图片URL */
|
/** 品牌图片URL */
|
||||||
image?: string;
|
image?: string;
|
||||||
|
/** 纸箱规格ID */
|
||||||
|
specIds?: number[];
|
||||||
/** 备注 */
|
/** 备注 */
|
||||||
remark?: string;
|
remark?: string;
|
||||||
/** 状态:1_启用;0_禁用 */
|
/** 状态:1_启用;0_禁用 */
|
||||||
status: boolean;
|
status: boolean;
|
||||||
/** 品牌类型:1_我方纸箱;2_瓜农纸箱;3_第三方纸箱 */
|
/** 品牌类型:1_我方纸箱;2_瓜农纸箱;3_第三方纸箱;4_礼盒; */
|
||||||
type: "OUR_BOX" | "FARMER_BOX" | "THIRD_PARTY_BOX";
|
type: "OUR_BOX" | "FARMER_BOX" | "THIRD_PARTY_BOX" | "GIFT_BOX";
|
||||||
};
|
};
|
||||||
|
|
||||||
type BoxBrandDestroyCmd = {
|
type BoxBrandDestroyCmd = {
|
||||||
@ -132,8 +134,8 @@ declare namespace BusinessAPI {
|
|||||||
brandId?: string;
|
brandId?: string;
|
||||||
/** 是否包含纸箱产品 */
|
/** 是否包含纸箱产品 */
|
||||||
withProduct?: boolean;
|
withProduct?: boolean;
|
||||||
/** 品牌类型:1_我方纸箱;2_瓜农纸箱;3_第三方纸箱 */
|
/** 品牌类型:1_我方纸箱;2_瓜农纸箱;3_第三方纸箱;4_礼盒; */
|
||||||
type?: "OUR_BOX" | "FARMER_BOX" | "THIRD_PARTY_BOX";
|
type?: "OUR_BOX" | "FARMER_BOX" | "THIRD_PARTY_BOX" | "GIFT_BOX";
|
||||||
};
|
};
|
||||||
|
|
||||||
type BoxBrandPageQry = {
|
type BoxBrandPageQry = {
|
||||||
@ -153,8 +155,8 @@ declare namespace BusinessAPI {
|
|||||||
status?: boolean;
|
status?: boolean;
|
||||||
/** 纸箱品牌ID */
|
/** 纸箱品牌ID */
|
||||||
brandId?: string;
|
brandId?: string;
|
||||||
/** 品牌类型:1_我方纸箱;2_瓜农纸箱;3_第三方纸箱 */
|
/** 品牌类型:1_我方纸箱;2_瓜农纸箱;3_第三方纸箱;4_礼盒; */
|
||||||
type?: "OUR_BOX" | "FARMER_BOX" | "THIRD_PARTY_BOX";
|
type?: "OUR_BOX" | "FARMER_BOX" | "THIRD_PARTY_BOX" | "GIFT_BOX";
|
||||||
offset?: number;
|
offset?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -172,12 +174,14 @@ declare namespace BusinessAPI {
|
|||||||
name: string;
|
name: string;
|
||||||
/** 品牌图片URL */
|
/** 品牌图片URL */
|
||||||
image?: string;
|
image?: string;
|
||||||
|
/** 纸箱规格ID */
|
||||||
|
specIds?: number[];
|
||||||
/** 备注 */
|
/** 备注 */
|
||||||
remark?: string;
|
remark?: string;
|
||||||
/** 状态:1_启用;0_禁用 */
|
/** 状态:1_启用;0_禁用 */
|
||||||
status: boolean;
|
status: boolean;
|
||||||
/** 品牌类型:1_我方纸箱;2_瓜农纸箱;3_第三方纸箱 */
|
/** 品牌类型:1_我方纸箱;2_瓜农纸箱;3_第三方纸箱;4_礼盒; */
|
||||||
type: "OUR_BOX" | "FARMER_BOX" | "THIRD_PARTY_BOX";
|
type: "OUR_BOX" | "FARMER_BOX" | "THIRD_PARTY_BOX" | "GIFT_BOX";
|
||||||
};
|
};
|
||||||
|
|
||||||
type BoxBrandVO = {
|
type BoxBrandVO = {
|
||||||
@ -187,14 +191,18 @@ declare namespace BusinessAPI {
|
|||||||
name: string;
|
name: string;
|
||||||
/** 品牌图片URL */
|
/** 品牌图片URL */
|
||||||
image?: string;
|
image?: string;
|
||||||
|
/** 纸箱规格ID */
|
||||||
|
specIds?: number[];
|
||||||
/** 备注 */
|
/** 备注 */
|
||||||
remark?: string;
|
remark?: string;
|
||||||
/** 状态:1_启用;0_禁用 */
|
/** 状态:1_启用;0_禁用 */
|
||||||
status: boolean;
|
status: boolean;
|
||||||
/** 品牌类型:1_我方纸箱;2_瓜农纸箱;3_第三方纸箱 */
|
/** 品牌类型:1_我方纸箱;2_瓜农纸箱;3_第三方纸箱;4_礼盒; */
|
||||||
type: "OUR_BOX" | "FARMER_BOX" | "THIRD_PARTY_BOX";
|
type: "OUR_BOX" | "FARMER_BOX" | "THIRD_PARTY_BOX" | "GIFT_BOX";
|
||||||
/** 纸箱产品列表 */
|
/** 纸箱产品列表 */
|
||||||
boxProductVOList?: BoxProductVO[];
|
boxProductVOList?: BoxProductVO[];
|
||||||
|
/** 纸箱规格列表 */
|
||||||
|
boxSpecVOList?: BoxSpecVO[];
|
||||||
/** 创建时间 */
|
/** 创建时间 */
|
||||||
createdAt?: string;
|
createdAt?: string;
|
||||||
};
|
};
|
||||||
@ -210,16 +218,18 @@ declare namespace BusinessAPI {
|
|||||||
costPrice?: number;
|
costPrice?: number;
|
||||||
/** 销售价 */
|
/** 销售价 */
|
||||||
salePrice?: number;
|
salePrice?: number;
|
||||||
/** 规格:1_2粒装;2_4粒装 */
|
/** 规格ID */
|
||||||
specType: "TWO_GRAIN" | "FOUR_GRAIN";
|
specId?: string;
|
||||||
|
/** 规格名称 */
|
||||||
|
specName?: string;
|
||||||
/** 品牌ID */
|
/** 品牌ID */
|
||||||
brandId: string;
|
brandId: string;
|
||||||
/** 备注 */
|
/** 备注 */
|
||||||
remark?: string;
|
remark?: string;
|
||||||
/** 状态:1_启用;0_禁用 */
|
/** 状态:1_启用;0_禁用 */
|
||||||
status: boolean;
|
status: boolean;
|
||||||
/** 品牌类型:1_我方纸箱;2_瓜农纸箱;3_第三方纸箱 */
|
/** 品牌类型:1_我方纸箱;2_瓜农纸箱;3_第三方纸箱;4_礼盒; */
|
||||||
type: "OUR_BOX" | "FARMER_BOX" | "THIRD_PARTY_BOX";
|
type: "OUR_BOX" | "FARMER_BOX" | "THIRD_PARTY_BOX" | "GIFT_BOX";
|
||||||
};
|
};
|
||||||
|
|
||||||
type BoxProductDestroyCmd = {
|
type BoxProductDestroyCmd = {
|
||||||
@ -245,10 +255,10 @@ declare namespace BusinessAPI {
|
|||||||
name?: string;
|
name?: string;
|
||||||
/** 纸箱品牌ID */
|
/** 纸箱品牌ID */
|
||||||
brandId?: string;
|
brandId?: string;
|
||||||
/** 规格:1_2粒装;2_4粒装 */
|
/** 规格ID */
|
||||||
specType?: "TWO_GRAIN" | "FOUR_GRAIN";
|
specId?: string;
|
||||||
/** 品牌类型:1_我方纸箱;2_瓜农纸箱;3_第三方纸箱 */
|
/** 品牌类型:1_我方纸箱;2_瓜农纸箱;3_第三方纸箱;4_礼盒; */
|
||||||
type?: "OUR_BOX" | "FARMER_BOX" | "THIRD_PARTY_BOX";
|
type?: "OUR_BOX" | "FARMER_BOX" | "THIRD_PARTY_BOX" | "GIFT_BOX";
|
||||||
};
|
};
|
||||||
|
|
||||||
type BoxProductPageQry = {
|
type BoxProductPageQry = {
|
||||||
@ -272,10 +282,10 @@ declare namespace BusinessAPI {
|
|||||||
name?: string;
|
name?: string;
|
||||||
/** 纸箱品牌ID */
|
/** 纸箱品牌ID */
|
||||||
brandId?: string;
|
brandId?: string;
|
||||||
/** 规格:1_2粒装;2_4粒装 */
|
/** 规格ID */
|
||||||
specType?: "TWO_GRAIN" | "FOUR_GRAIN";
|
specId?: string;
|
||||||
/** 品牌类型:1_我方纸箱;2_瓜农纸箱;3_第三方纸箱 */
|
/** 品牌类型:1_我方纸箱;2_瓜农纸箱;3_第三方纸箱;4_礼盒; */
|
||||||
type?: "OUR_BOX" | "FARMER_BOX" | "THIRD_PARTY_BOX";
|
type?: "OUR_BOX" | "FARMER_BOX" | "THIRD_PARTY_BOX" | "GIFT_BOX";
|
||||||
offset?: number;
|
offset?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -297,16 +307,18 @@ declare namespace BusinessAPI {
|
|||||||
costPrice?: number;
|
costPrice?: number;
|
||||||
/** 销售价 */
|
/** 销售价 */
|
||||||
salePrice?: number;
|
salePrice?: number;
|
||||||
/** 规格:1_2粒装;2_4粒装 */
|
/** 规格ID */
|
||||||
specType: "TWO_GRAIN" | "FOUR_GRAIN";
|
specId?: string;
|
||||||
|
/** 规格名称 */
|
||||||
|
specName?: string;
|
||||||
/** 品牌ID */
|
/** 品牌ID */
|
||||||
brandId: string;
|
brandId: string;
|
||||||
/** 备注 */
|
/** 备注 */
|
||||||
remark?: string;
|
remark?: string;
|
||||||
/** 状态:1_启用;0_禁用 */
|
/** 状态:1_启用;0_禁用 */
|
||||||
status: boolean;
|
status: boolean;
|
||||||
/** 品牌类型:1_我方纸箱;2_瓜农纸箱;3_第三方纸箱 */
|
/** 品牌类型:1_我方纸箱;2_瓜农纸箱;3_第三方纸箱;4_礼盒; */
|
||||||
type: "OUR_BOX" | "FARMER_BOX" | "THIRD_PARTY_BOX";
|
type: "OUR_BOX" | "FARMER_BOX" | "THIRD_PARTY_BOX" | "GIFT_BOX";
|
||||||
};
|
};
|
||||||
|
|
||||||
type BoxProductVO = {
|
type BoxProductVO = {
|
||||||
@ -320,12 +332,94 @@ declare namespace BusinessAPI {
|
|||||||
costPrice: number;
|
costPrice: number;
|
||||||
/** 销售价 */
|
/** 销售价 */
|
||||||
salePrice: number;
|
salePrice: number;
|
||||||
/** 规格:1_2粒装;2_4粒装 */
|
/** 规格ID */
|
||||||
specType: "TWO_GRAIN" | "FOUR_GRAIN";
|
specId: string;
|
||||||
|
/** 规格名称 */
|
||||||
|
specName: string;
|
||||||
/** 品牌ID */
|
/** 品牌ID */
|
||||||
brandId: string;
|
brandId: string;
|
||||||
/** 品牌类型:1_我方纸箱;2_瓜农纸箱;3_第三方纸箱 */
|
/** 品牌类型:1_我方纸箱;2_瓜农纸箱;3_第三方纸箱;4_礼盒; */
|
||||||
type: "OUR_BOX" | "FARMER_BOX" | "THIRD_PARTY_BOX";
|
type: "OUR_BOX" | "FARMER_BOX" | "THIRD_PARTY_BOX" | "GIFT_BOX";
|
||||||
|
/** 备注 */
|
||||||
|
remark?: string;
|
||||||
|
/** 状态:1_启用;0_禁用 */
|
||||||
|
status: boolean;
|
||||||
|
/** 创建时间 */
|
||||||
|
createdAt?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type BoxSpecCreateCmd = {
|
||||||
|
/** 规格ID */
|
||||||
|
specId: string;
|
||||||
|
/** 规格名称 */
|
||||||
|
name: string;
|
||||||
|
/** 排序号 */
|
||||||
|
sort: number;
|
||||||
|
/** 备注 */
|
||||||
|
remark?: string;
|
||||||
|
/** 状态:1_启用;0_禁用 */
|
||||||
|
status: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
type BoxSpecDestroyCmd = {
|
||||||
|
/** 纸箱规格ID */
|
||||||
|
specId: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type BoxSpecListQry = {
|
||||||
|
/** 状态:1_启用;0_禁用; */
|
||||||
|
status?: boolean;
|
||||||
|
/** 纸箱规格ID */
|
||||||
|
specId?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type BoxSpecPageQry = {
|
||||||
|
pageSize?: number;
|
||||||
|
pageIndex?: number;
|
||||||
|
orderBy?: string;
|
||||||
|
orderDirection?: string;
|
||||||
|
groupBy?: string;
|
||||||
|
needTotalCount?: boolean;
|
||||||
|
/** 自定义字段key */
|
||||||
|
customFieldKey?: string;
|
||||||
|
/** 自定义字段value */
|
||||||
|
customFieldValue?: string;
|
||||||
|
/** 备注 */
|
||||||
|
remark?: string;
|
||||||
|
/** 状态:1_启用;0_禁用; */
|
||||||
|
status?: boolean;
|
||||||
|
/** 纸箱规格ID */
|
||||||
|
specId?: string;
|
||||||
|
offset?: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
type BoxSpecShowQry = {
|
||||||
|
/** 状态:1_启用;0_禁用; */
|
||||||
|
status?: boolean;
|
||||||
|
/** 纸箱规格ID */
|
||||||
|
specId?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type BoxSpecUpdateCmd = {
|
||||||
|
/** 纸箱规格ID */
|
||||||
|
specId: string;
|
||||||
|
/** 规格名称 */
|
||||||
|
name: string;
|
||||||
|
/** 排序号 */
|
||||||
|
sort: number;
|
||||||
|
/** 备注 */
|
||||||
|
remark?: string;
|
||||||
|
/** 状态:1_启用;0_禁用 */
|
||||||
|
status: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
type BoxSpecVO = {
|
||||||
|
/** 规格ID */
|
||||||
|
specId: string;
|
||||||
|
/** 规格名称 */
|
||||||
|
name: string;
|
||||||
|
/** 排序号 */
|
||||||
|
sort: number;
|
||||||
/** 备注 */
|
/** 备注 */
|
||||||
remark?: string;
|
remark?: string;
|
||||||
/** 状态:1_启用;0_禁用 */
|
/** 状态:1_启用;0_禁用 */
|
||||||
@ -878,6 +972,8 @@ declare namespace BusinessAPI {
|
|||||||
| "FIXED_COST"
|
| "FIXED_COST"
|
||||||
| "WORKER_ADVANCE"
|
| "WORKER_ADVANCE"
|
||||||
| "PRODUCTION_ADVANCE";
|
| "PRODUCTION_ADVANCE";
|
||||||
|
/** 是否在录入时显示 */
|
||||||
|
showInEntry?: boolean;
|
||||||
/** 项目名称 */
|
/** 项目名称 */
|
||||||
name?: string;
|
name?: string;
|
||||||
offset?: number;
|
offset?: number;
|
||||||
@ -1823,6 +1919,10 @@ declare namespace BusinessAPI {
|
|||||||
boxProductListQry: BoxProductListQry;
|
boxProductListQry: BoxProductListQry;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type listBoxSpecParams = {
|
||||||
|
boxSpecListQry: BoxSpecListQry;
|
||||||
|
};
|
||||||
|
|
||||||
type listCompanyParams = {
|
type listCompanyParams = {
|
||||||
companyListQry: CompanyListQry;
|
companyListQry: CompanyListQry;
|
||||||
};
|
};
|
||||||
@ -2145,6 +2245,15 @@ declare namespace BusinessAPI {
|
|||||||
notEmpty?: boolean;
|
notEmpty?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type MultiResponseBoxSpecVO = {
|
||||||
|
success?: boolean;
|
||||||
|
errCode?: string;
|
||||||
|
errMessage?: string;
|
||||||
|
data?: BoxSpecVO[];
|
||||||
|
empty?: boolean;
|
||||||
|
notEmpty?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
type MultiResponseCompanyPaymentAccountVO = {
|
type MultiResponseCompanyPaymentAccountVO = {
|
||||||
success?: boolean;
|
success?: boolean;
|
||||||
errCode?: string;
|
errCode?: string;
|
||||||
@ -2384,6 +2493,8 @@ declare namespace BusinessAPI {
|
|||||||
payerType?: "US" | "OTHER";
|
payerType?: "US" | "OTHER";
|
||||||
/** 负责人 */
|
/** 负责人 */
|
||||||
principal?: string;
|
principal?: string;
|
||||||
|
/** 是否需要数量和价格 */
|
||||||
|
requireQuantityAndPrice?: boolean;
|
||||||
/** 费用类型:1_包装材料;2_人工费用;3_其他费用;4_固定费用;5_工头垫付;6_产地垫付 */
|
/** 费用类型:1_包装材料;2_人工费用;3_其他费用;4_固定费用;5_工头垫付;6_产地垫付 */
|
||||||
costType:
|
costType:
|
||||||
| "PACKAGING_MATERIALS"
|
| "PACKAGING_MATERIALS"
|
||||||
@ -2392,8 +2503,6 @@ declare namespace BusinessAPI {
|
|||||||
| "FIXED_COST"
|
| "FIXED_COST"
|
||||||
| "WORKER_ADVANCE"
|
| "WORKER_ADVANCE"
|
||||||
| "PRODUCTION_ADVANCE";
|
| "PRODUCTION_ADVANCE";
|
||||||
/** 是否需要填写数量和单价 */
|
|
||||||
requireQuantityAndPrice: boolean;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
type OrderDealer = {
|
type OrderDealer = {
|
||||||
@ -2448,8 +2557,12 @@ declare namespace BusinessAPI {
|
|||||||
boxBrandName: string;
|
boxBrandName: string;
|
||||||
/** 箱子品牌图片 */
|
/** 箱子品牌图片 */
|
||||||
boxBrandImage?: string;
|
boxBrandImage?: string;
|
||||||
/** 箱子分类ID */
|
/** 箱子品牌类型:1_我方纸箱;2_瓜农纸箱;3_第三方纸箱;4_礼盒; */
|
||||||
boxCategoryId: string;
|
boxBrandType: "OUR_BOX" | "FARMER_BOX" | "THIRD_PARTY_BOX" | "GIFT_BOX";
|
||||||
|
/** 箱子规格ID */
|
||||||
|
boxSpecId: string;
|
||||||
|
/** 箱子规格名称 */
|
||||||
|
boxSpecName: string;
|
||||||
/** 箱子产品ID */
|
/** 箱子产品ID */
|
||||||
boxProductId: string;
|
boxProductId: string;
|
||||||
/** 箱子产品名称 */
|
/** 箱子产品名称 */
|
||||||
@ -2596,6 +2709,10 @@ declare namespace BusinessAPI {
|
|||||||
boxProductPageQry: BoxProductPageQry;
|
boxProductPageQry: BoxProductPageQry;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type pageBoxSpecParams = {
|
||||||
|
boxSpecPageQry: BoxSpecPageQry;
|
||||||
|
};
|
||||||
|
|
||||||
type pageChannelParams = {
|
type pageChannelParams = {
|
||||||
channelPageQry: ChannelPageQry;
|
channelPageQry: ChannelPageQry;
|
||||||
};
|
};
|
||||||
@ -2699,6 +2816,19 @@ declare namespace BusinessAPI {
|
|||||||
totalPages?: number;
|
totalPages?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type PageResponseBoxSpecVO = {
|
||||||
|
success?: boolean;
|
||||||
|
errCode?: string;
|
||||||
|
errMessage?: string;
|
||||||
|
totalCount?: number;
|
||||||
|
pageSize?: number;
|
||||||
|
pageIndex?: number;
|
||||||
|
data?: BoxSpecVO[];
|
||||||
|
empty?: boolean;
|
||||||
|
notEmpty?: boolean;
|
||||||
|
totalPages?: number;
|
||||||
|
};
|
||||||
|
|
||||||
type PageResponseChannelVO = {
|
type PageResponseChannelVO = {
|
||||||
success?: boolean;
|
success?: boolean;
|
||||||
errCode?: string;
|
errCode?: string;
|
||||||
@ -3752,8 +3882,10 @@ declare namespace BusinessAPI {
|
|||||||
orderPackageId: string;
|
orderPackageId: string;
|
||||||
/** 发货单ID */
|
/** 发货单ID */
|
||||||
shipOrderId: string;
|
shipOrderId: string;
|
||||||
|
/** 箱型ID */
|
||||||
|
boxSpecId?: number;
|
||||||
/** 箱型 */
|
/** 箱型 */
|
||||||
boxCategory?: string;
|
boxSpecName?: string;
|
||||||
/** 箱号 */
|
/** 箱号 */
|
||||||
boxProduct?: string;
|
boxProduct?: string;
|
||||||
/** 数量 */
|
/** 数量 */
|
||||||
@ -3921,7 +4053,7 @@ declare namespace BusinessAPI {
|
|||||||
shipOrderItemList?: ShipOrderItem[];
|
shipOrderItemList?: ShipOrderItem[];
|
||||||
/** 发货单子项表 */
|
/** 发货单子项表 */
|
||||||
shipOrderPackageList?: ShipOrderPackage[];
|
shipOrderPackageList?: ShipOrderPackage[];
|
||||||
/** 发货单费用项 */
|
/** 发货单成本项目信息 */
|
||||||
orderCostList?: OrderCost[];
|
orderCostList?: OrderCost[];
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -3937,6 +4069,10 @@ declare namespace BusinessAPI {
|
|||||||
boxProductShowQry: BoxProductShowQry;
|
boxProductShowQry: BoxProductShowQry;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type showBoxSpecParams = {
|
||||||
|
boxSpecShowQry: BoxSpecShowQry;
|
||||||
|
};
|
||||||
|
|
||||||
type showChannelParams = {
|
type showChannelParams = {
|
||||||
channelShowQry: ChannelShowQry;
|
channelShowQry: ChannelShowQry;
|
||||||
};
|
};
|
||||||
@ -4050,6 +4186,13 @@ declare namespace BusinessAPI {
|
|||||||
data?: BoxProductVO;
|
data?: BoxProductVO;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type SingleResponseBoxSpecVO = {
|
||||||
|
success?: boolean;
|
||||||
|
errCode?: string;
|
||||||
|
errMessage?: string;
|
||||||
|
data?: BoxSpecVO;
|
||||||
|
};
|
||||||
|
|
||||||
type SingleResponseCategoryVO = {
|
type SingleResponseCategoryVO = {
|
||||||
success?: boolean;
|
success?: boolean;
|
||||||
errCode?: string;
|
errCode?: string;
|
||||||
|
|||||||
@ -13,7 +13,9 @@ export interface CommonComponent {
|
|||||||
user: AuthAPI.UserVO;
|
user: AuthAPI.UserVO;
|
||||||
shareOptions: any;
|
shareOptions: any;
|
||||||
role: "origin-entry" | "market-buyer" | "reviewer" | "boss";
|
role: "origin-entry" | "market-buyer" | "reviewer" | "boss";
|
||||||
setRole: (role: "origin-entry" | "market-buyer" | "reviewer" | "boss") => void;
|
setRole: (
|
||||||
|
role: "origin-entry" | "market-buyer" | "reviewer" | "boss",
|
||||||
|
) => void;
|
||||||
router: Router;
|
router: Router;
|
||||||
options: Taro.getLaunchOptionsSync.LaunchOptions;
|
options: Taro.getLaunchOptionsSync.LaunchOptions;
|
||||||
isInitialized: boolean;
|
isInitialized: boolean;
|
||||||
@ -33,9 +35,9 @@ export interface BoxBrand {
|
|||||||
boxBrandId: string;
|
boxBrandId: string;
|
||||||
boxBrandName: string;
|
boxBrandName: string;
|
||||||
boxBrandImage: string;
|
boxBrandImage: string;
|
||||||
boxBrandType: "OUR_BOX" | "FARMER_BOX" | "THIRD_PARTY_BOX";
|
boxBrandType: "OUR_BOX" | "FARMER_BOX" | "THIRD_PARTY_BOX" | "GIFT_BOX";
|
||||||
boxType: "USED" | "EXTRA" | "EXTRA_USED" | "REMAIN" | "OWN" | "DEFAULT";
|
boxType: "USED" | "EXTRA" | "EXTRA_USED" | "REMAIN" | "OWN" | "DEFAULT";
|
||||||
boxCategoryList: BoxCategory[];
|
boxSpecList: BoxSpec[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BoxProduct {
|
export interface BoxProduct {
|
||||||
@ -46,15 +48,16 @@ export interface BoxProduct {
|
|||||||
boxProductName: string;
|
boxProductName: string;
|
||||||
boxCount: number;
|
boxCount: number;
|
||||||
boxProductWeight: number;
|
boxProductWeight: number;
|
||||||
boxCategoryId: "FOUR_GRAIN" | "TWO_GRAIN";
|
boxSpecId: string;
|
||||||
|
boxSpecName: string;
|
||||||
boxCostPrice: number;
|
boxCostPrice: number;
|
||||||
boxSalePrice: number;
|
boxSalePrice: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BoxCategory {
|
export interface BoxSpec {
|
||||||
id: string;
|
id: string;
|
||||||
boxCategoryId: "FOUR_GRAIN" | "TWO_GRAIN";
|
boxSpecId: string;
|
||||||
boxCategoryName: string;
|
boxSpecName: string;
|
||||||
boxProductList: BoxProduct[];
|
boxProductList: BoxProduct[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
189
packages/app-client/src/utils/SupplierWeightCalculator.ts
Normal file
189
packages/app-client/src/utils/SupplierWeightCalculator.ts
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
import { Decimal } from "decimal.js";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 农户重量计算器类
|
||||||
|
* 用于计算每个农户的净重和毛重,并赋值到原数据中
|
||||||
|
*/
|
||||||
|
export class SupplierWeightCalculator {
|
||||||
|
private suppliers: BusinessAPI.OrderSupplier[];
|
||||||
|
|
||||||
|
constructor(suppliers: BusinessAPI.OrderSupplier[]) {
|
||||||
|
this.suppliers = suppliers;
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化计算规则
|
||||||
|
*/
|
||||||
|
private init() {
|
||||||
|
Decimal.set({
|
||||||
|
precision: 20,
|
||||||
|
rounding: 0, // 向下舍入(更保守的计算方式)
|
||||||
|
toExpNeg: -7,
|
||||||
|
toExpPos: 21,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算所有农户的重量信息
|
||||||
|
* @returns {Array} 包含净重、毛重和空磅的农户数据
|
||||||
|
*/
|
||||||
|
calculate(): BusinessAPI.OrderSupplier[] {
|
||||||
|
if (!this.suppliers || this.suppliers.length === 0) {
|
||||||
|
return this.suppliers;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用第一个瓜农的空磅重量作为初始空磅重量
|
||||||
|
const initialEmptyWeight = this.suppliers[0].emptyWeight;
|
||||||
|
let previousTotalWeight = initialEmptyWeight; // 上一个农户的总磅重量(kg)
|
||||||
|
|
||||||
|
for (let i = 0; i < this.suppliers.length; i++) {
|
||||||
|
const supplier = this.suppliers[i];
|
||||||
|
const isFirstSupplier = i === 0;
|
||||||
|
const isLastSupplier = supplier.isLast;
|
||||||
|
|
||||||
|
// 设置空磅重量(第一个农户使用自己的空磅重量,其他使用前一个农户的总磅重量)
|
||||||
|
if (isFirstSupplier) {
|
||||||
|
// 第一个农户的空磅重量已经是正确的
|
||||||
|
} else {
|
||||||
|
supplier.emptyWeight = this.suppliers[i - 1].totalWeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算本次使用纸箱的总重量(斤)
|
||||||
|
const usedBoxesWeight = new Decimal(
|
||||||
|
this.calculateBoxesTotalWeight(supplier.orderPackageList || [], "USED"),
|
||||||
|
)
|
||||||
|
.add(
|
||||||
|
this.calculateBoxesTotalWeight(
|
||||||
|
supplier.orderPackageList || [],
|
||||||
|
"OWN",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toNumber();
|
||||||
|
|
||||||
|
// 计算额外配送的已使用纸箱总重量(斤)
|
||||||
|
const extraUsedBoxesWeight = this.calculateBoxesTotalWeight(
|
||||||
|
supplier.orderPackageList || [],
|
||||||
|
"EXTRA_USED",
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!supplier.isPaper) {
|
||||||
|
// 如果不是纸箱包装,直接使用原始重量(kg转斤)
|
||||||
|
supplier.grossWeight = new Decimal(supplier.totalWeight)
|
||||||
|
.sub(supplier.emptyWeight)
|
||||||
|
.mul(2)
|
||||||
|
.toNumber();
|
||||||
|
|
||||||
|
supplier.netWeight = new Decimal(supplier.grossWeight)
|
||||||
|
.sub(usedBoxesWeight)
|
||||||
|
.sub(extraUsedBoxesWeight)
|
||||||
|
.toNumber();
|
||||||
|
|
||||||
|
previousTotalWeight = supplier.totalWeight;
|
||||||
|
supplier.invoiceAmount = new Decimal(supplier.netWeight)
|
||||||
|
.mul(supplier.purchasePrice)
|
||||||
|
.toNumber();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算额外配送的纸箱总重量(斤)
|
||||||
|
const extraBoxesWeight = this.calculateBoxesTotalWeight(
|
||||||
|
supplier.orderPackageList || [],
|
||||||
|
"EXTRA",
|
||||||
|
);
|
||||||
|
|
||||||
|
// 计算车上剩余纸箱(斤)
|
||||||
|
const remainingBoxesWeight = this.calculateBoxesTotalWeight(
|
||||||
|
supplier.orderPackageList || [],
|
||||||
|
"REMAIN",
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isFirstSupplier && isLastSupplier) {
|
||||||
|
// 既是第一个也是最后一个瓜农(单个瓜农情况)- 优先使用最后一个瓜农算法
|
||||||
|
// 净重 = (总磅 - 空磅) * 2 + 剩余空箱子重量 - 已使用额外纸箱重量
|
||||||
|
supplier.netWeight = new Decimal(supplier.totalWeight)
|
||||||
|
.sub(initialEmptyWeight)
|
||||||
|
.mul(2)
|
||||||
|
.add(remainingBoxesWeight)
|
||||||
|
.sub(extraUsedBoxesWeight)
|
||||||
|
.toNumber();
|
||||||
|
// 毛重 = 净重 + 本次使用纸箱重量
|
||||||
|
supplier.grossWeight = new Decimal(supplier.netWeight)
|
||||||
|
.add(usedBoxesWeight)
|
||||||
|
.toNumber();
|
||||||
|
} else if (isLastSupplier) {
|
||||||
|
// 最后一个农户(根据isLast标识判断)
|
||||||
|
// 净重 = (总磅 - 前一个总磅) * 2 + 剩余空箱子重量 - 额外纸箱重量
|
||||||
|
supplier.netWeight = new Decimal(supplier.totalWeight)
|
||||||
|
.sub(previousTotalWeight)
|
||||||
|
.mul(2)
|
||||||
|
.add(remainingBoxesWeight)
|
||||||
|
.sub(extraBoxesWeight)
|
||||||
|
.toNumber();
|
||||||
|
// 毛重 = 净重 + 本次使用纸箱重量
|
||||||
|
supplier.grossWeight = new Decimal(supplier.netWeight)
|
||||||
|
.add(usedBoxesWeight)
|
||||||
|
.toNumber();
|
||||||
|
} else if (isFirstSupplier) {
|
||||||
|
// 第一个农户(但不是最后一个)
|
||||||
|
// 净重 = (总磅 - 空磅) * 2 - 额外纸箱重量
|
||||||
|
supplier.netWeight = new Decimal(supplier.totalWeight)
|
||||||
|
.sub(initialEmptyWeight)
|
||||||
|
.mul(2)
|
||||||
|
.sub(extraBoxesWeight)
|
||||||
|
.toNumber();
|
||||||
|
// 毛重 = 净重 + 本次使用纸箱重量
|
||||||
|
supplier.grossWeight = new Decimal(supplier.netWeight)
|
||||||
|
.add(usedBoxesWeight)
|
||||||
|
.toNumber();
|
||||||
|
} else {
|
||||||
|
// 中间农户
|
||||||
|
// 净重 = (总磅 - 前一个总磅) * 2 - 额外纸箱重量
|
||||||
|
supplier.netWeight = new Decimal(supplier.totalWeight)
|
||||||
|
.sub(previousTotalWeight)
|
||||||
|
.mul(2)
|
||||||
|
.sub(extraBoxesWeight)
|
||||||
|
.toNumber();
|
||||||
|
// 毛重 = 净重 + 本次使用纸箱重量
|
||||||
|
supplier.grossWeight = new Decimal(supplier.netWeight)
|
||||||
|
.add(usedBoxesWeight)
|
||||||
|
.toNumber();
|
||||||
|
}
|
||||||
|
|
||||||
|
previousTotalWeight = supplier.totalWeight;
|
||||||
|
supplier.invoiceAmount = new Decimal(supplier.netWeight)
|
||||||
|
.mul(supplier.purchasePrice)
|
||||||
|
.toNumber();
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.suppliers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算纸箱的总重量(斤)
|
||||||
|
* @param {Array} orderPackageList - 包装信息列表
|
||||||
|
* @param {string} boxType - 箱子类型 ('USED' 或 'EXTRA',不传则计算所有)
|
||||||
|
* @returns {number} 总重量(斤)
|
||||||
|
*/
|
||||||
|
private calculateBoxesTotalWeight(
|
||||||
|
orderPackageList: BusinessAPI.OrderPackage[],
|
||||||
|
boxType?: any,
|
||||||
|
): number {
|
||||||
|
if (!orderPackageList) return 0;
|
||||||
|
|
||||||
|
let filteredPackages = orderPackageList;
|
||||||
|
if (boxType) {
|
||||||
|
filteredPackages = orderPackageList.filter(
|
||||||
|
(pkg) => pkg.boxType === boxType,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return filteredPackages.reduce((sum, pkg) => {
|
||||||
|
// 纸箱重量单位是斤,直接使用
|
||||||
|
const boxWeight = pkg.boxProductWeight || 0;
|
||||||
|
return new Decimal(sum)
|
||||||
|
.add(new Decimal(pkg.boxCount || 0).mul(boxWeight))
|
||||||
|
.toNumber();
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,293 +0,0 @@
|
|||||||
/**
|
|
||||||
* 计算每个农户的净重和毛重,并赋值到原数据中
|
|
||||||
* @param {Array} suppliers - 农户数据数组
|
|
||||||
* @returns {Array} 包含净重、毛重和空磅的农户数据
|
|
||||||
*/
|
|
||||||
export function calculateSupplierWeights(suppliers) {
|
|
||||||
if (!suppliers || suppliers.length === 0) {
|
|
||||||
return suppliers;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 使用第一个瓜农的空磅重量作为初始空磅重量
|
|
||||||
const initialEmptyWeight = suppliers[0].emptyWeight;
|
|
||||||
let previousTotalWeight = initialEmptyWeight; // 上一个农户的总磅重量(kg)
|
|
||||||
|
|
||||||
for (let i = 0; i < suppliers.length; i++) {
|
|
||||||
const supplier = suppliers[i];
|
|
||||||
const isFirstSupplier = i === 0;
|
|
||||||
const isLastSupplier = supplier.isLast === true;
|
|
||||||
|
|
||||||
// 设置空磅重量(第一个农户使用自己的空磅重量,其他使用前一个农户的总磅重量)
|
|
||||||
if (isFirstSupplier) {
|
|
||||||
// 第一个农户的空磅重量已经是正确的
|
|
||||||
} else {
|
|
||||||
supplier.emptyWeight = suppliers[i - 1].totalWeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 计算本次使用纸箱的总重量(斤)
|
|
||||||
const usedBoxesWeight = calculateBoxesTotalWeight(supplier.orderPackageList, 'USED') + calculateBoxesTotalWeight(supplier.orderPackageList, 'OWN');
|
|
||||||
|
|
||||||
if (!supplier.isPaper) {
|
|
||||||
// 如果不是纸箱包装,直接使用原始重量(kg转斤)
|
|
||||||
supplier.grossWeight = (supplier.totalWeight - supplier.emptyWeight) * 2;
|
|
||||||
supplier.netWeight = supplier.grossWeight - usedBoxesWeight;
|
|
||||||
previousTotalWeight = supplier.totalWeight;
|
|
||||||
supplier.invoiceAmount = supplier.netWeight * supplier.purchasePrice;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 计算额外配送的纸箱总重量(斤)
|
|
||||||
const extraBoxesWeight = calculateBoxesTotalWeight(
|
|
||||||
supplier.orderPackageList,
|
|
||||||
'EXTRA'
|
|
||||||
);
|
|
||||||
|
|
||||||
// 计算额外配送的已使用纸箱总重量(斤)
|
|
||||||
const extraUsedBoxesWeight = calculateBoxesTotalWeight(
|
|
||||||
supplier.orderPackageList,
|
|
||||||
'EXTRA_USED'
|
|
||||||
);
|
|
||||||
|
|
||||||
// 计算车上剩余纸箱(斤)
|
|
||||||
const remainingBoxesWeight = calculateBoxesTotalWeight(
|
|
||||||
supplier.orderPackageList,
|
|
||||||
'REMAIN'
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isFirstSupplier && isLastSupplier) {
|
|
||||||
// 既是第一个也是最后一个瓜农(单个瓜农情况)- 优先使用最后一个瓜农算法
|
|
||||||
// 净重 = (总磅 - 空磅) * 2 + 剩余空箱子重量 - 已使用额外纸箱重量
|
|
||||||
supplier.netWeight = (supplier.totalWeight - initialEmptyWeight) * 2 + remainingBoxesWeight - extraUsedBoxesWeight;
|
|
||||||
// 毛重 = 净重 + 本次使用纸箱重量
|
|
||||||
supplier.grossWeight = supplier.netWeight + usedBoxesWeight;
|
|
||||||
|
|
||||||
} else if (isLastSupplier) {
|
|
||||||
// 最后一个农户(根据isLast标识判断)
|
|
||||||
// 净重 = (总磅 - 前一个总磅) * 2 + 剩余空箱子重量 - 额外纸箱重量
|
|
||||||
supplier.netWeight = (supplier.totalWeight - previousTotalWeight) * 2 + remainingBoxesWeight - extraBoxesWeight;
|
|
||||||
// 毛重 = 净重 + 本次使用纸箱重量
|
|
||||||
supplier.grossWeight = supplier.netWeight + usedBoxesWeight;
|
|
||||||
|
|
||||||
} else if (isFirstSupplier) {
|
|
||||||
// 第一个农户(但不是最后一个)
|
|
||||||
// 净重 = (总磅 - 空磅) * 2 - 额外纸箱重量
|
|
||||||
supplier.netWeight = (supplier.totalWeight - initialEmptyWeight) * 2 - extraBoxesWeight;
|
|
||||||
// 毛重 = 净重 + 本次使用纸箱重量
|
|
||||||
supplier.grossWeight = supplier.netWeight + usedBoxesWeight;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// 中间农户
|
|
||||||
// 净重 = (总磅 - 前一个总磅) * 2 - 额外纸箱重量
|
|
||||||
supplier.netWeight = (supplier.totalWeight - previousTotalWeight) * 2 - extraBoxesWeight;
|
|
||||||
// 毛重 = 净重 + 本次使用纸箱重量
|
|
||||||
supplier.grossWeight = supplier.netWeight + usedBoxesWeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
previousTotalWeight = supplier.totalWeight;
|
|
||||||
supplier.invoiceAmount = supplier.netWeight * supplier.purchasePrice;
|
|
||||||
}
|
|
||||||
|
|
||||||
return suppliers;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 计算纸箱的总重量(斤)
|
|
||||||
* @param {Array} orderPackageList - 包装信息列表
|
|
||||||
* @param {string} boxType - 箱子类型 ('used' 或 'extra',不传则计算所有)
|
|
||||||
* @returns {number} 总重量(斤)
|
|
||||||
*/
|
|
||||||
function calculateBoxesTotalWeight(orderPackageList, boxType?: any) {
|
|
||||||
if (!orderPackageList) return 0;
|
|
||||||
|
|
||||||
let filteredPackages = orderPackageList;
|
|
||||||
if (boxType) {
|
|
||||||
filteredPackages = orderPackageList.filter((pkg) => pkg.boxType === boxType);
|
|
||||||
}
|
|
||||||
|
|
||||||
return filteredPackages.reduce((sum, pkg) => {
|
|
||||||
// 纸箱重量单位是斤,直接使用
|
|
||||||
const boxWeight = pkg.boxProductWeight || 0;
|
|
||||||
return sum + pkg.boxCount * boxWeight;
|
|
||||||
}, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// // 使用示例 - 单个瓜农(既是第一个也是最后一个)
|
|
||||||
// const singleSupplier = [
|
|
||||||
// {
|
|
||||||
// id: "1",
|
|
||||||
// name: "瓜农1",
|
|
||||||
// isPaper: true,
|
|
||||||
// isLast: true, // 单个瓜农也是最后一个
|
|
||||||
// emptyWeight: 25, // kg
|
|
||||||
// totalWeight: 50, // kg
|
|
||||||
// orderPackageList: [
|
|
||||||
// {
|
|
||||||
// boxBrandId: "brand1",
|
|
||||||
// boxCategoryId: "TWO_GRAIN",
|
|
||||||
// boxProductId: "product1",
|
|
||||||
// boxProductWeight: 0.6, // 斤
|
|
||||||
// boxCount: 2,
|
|
||||||
// boxType: "used"
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// boxBrandId: "brand1",
|
|
||||||
// boxCategoryId: "TWO_GRAIN",
|
|
||||||
// boxProductId: "product1",
|
|
||||||
// boxProductWeight: 0.6, // 斤
|
|
||||||
// boxCount: 1,
|
|
||||||
// boxType: "extra-used"
|
|
||||||
// }
|
|
||||||
// ]
|
|
||||||
// }
|
|
||||||
// ];
|
|
||||||
//
|
|
||||||
// // 使用示例 - 多个瓜农
|
|
||||||
// const multipleSuppliers = [
|
|
||||||
// {
|
|
||||||
// id: "1",
|
|
||||||
// name: "瓜农1",
|
|
||||||
// isPaper: true,
|
|
||||||
// emptyWeight: 25, // kg
|
|
||||||
// totalWeight: 50, // kg
|
|
||||||
// orderPackageList: [
|
|
||||||
// {
|
|
||||||
// boxBrandId: "brand1",
|
|
||||||
// boxCategoryId: "TWO_GRAIN",
|
|
||||||
// boxProductId: "product1",
|
|
||||||
// boxProductWeight: 0.6, // 斤
|
|
||||||
// boxCount: 2,
|
|
||||||
// boxType: "used"
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// boxBrandId: "brand1",
|
|
||||||
// boxCategoryId: "TWO_GRAIN",
|
|
||||||
// boxProductId: "product1",
|
|
||||||
// boxProductWeight: 0.6, // 斤
|
|
||||||
// boxCount: 1,
|
|
||||||
// boxType: "extra"
|
|
||||||
// }
|
|
||||||
// ]
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// id: "2",
|
|
||||||
// name: "瓜农2",
|
|
||||||
// isPaper: true,
|
|
||||||
// isLast: true, // 标记为最后一个瓜农
|
|
||||||
// totalWeight: 80, // kg
|
|
||||||
// orderPackageList: [
|
|
||||||
// {
|
|
||||||
// boxBrandId: "brand2",
|
|
||||||
// boxCategoryId: "THREE_GRAIN",
|
|
||||||
// boxProductId: "product2",
|
|
||||||
// boxProductWeight: 1.0, // 斤
|
|
||||||
// boxCount: 2,
|
|
||||||
// boxType: "used"
|
|
||||||
// }
|
|
||||||
// ]
|
|
||||||
// }
|
|
||||||
// ];
|
|
||||||
//
|
|
||||||
// // 使用示例 - 第一个但不是最后一个
|
|
||||||
// const firstNotLastSuppliers = [
|
|
||||||
// {
|
|
||||||
// id: "1",
|
|
||||||
// name: "瓜农1",
|
|
||||||
// isPaper: true,
|
|
||||||
// emptyWeight: 25, // kg
|
|
||||||
// totalWeight: 50, // kg
|
|
||||||
// orderPackageList: [
|
|
||||||
// {
|
|
||||||
// boxBrandId: "brand1",
|
|
||||||
// boxCategoryId: "TWO_GRAIN",
|
|
||||||
// boxProductId: "product1",
|
|
||||||
// boxProductWeight: 0.6, // 斤
|
|
||||||
// boxCount: 2,
|
|
||||||
// boxType: "used"
|
|
||||||
// }
|
|
||||||
// ]
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// id: "2",
|
|
||||||
// name: "瓜农2",
|
|
||||||
// isPaper: true,
|
|
||||||
// // 没有isLast标记,当作中间农户
|
|
||||||
// totalWeight: 80, // kg
|
|
||||||
// orderPackageList: [
|
|
||||||
// {
|
|
||||||
// boxBrandId: "brand2",
|
|
||||||
// boxCategoryId: "THREE_GRAIN",
|
|
||||||
// boxProductId: "product2",
|
|
||||||
// boxProductWeight: 1.0, // 斤
|
|
||||||
// boxCount: 2,
|
|
||||||
// boxType: "used"
|
|
||||||
// }
|
|
||||||
// ]
|
|
||||||
// }
|
|
||||||
// ];
|
|
||||||
//
|
|
||||||
// console.log("=== 单个瓜农测试(既是第一个也是最后一个)===");
|
|
||||||
// const result1 = calculateSupplierWeights(singleSupplier);
|
|
||||||
// console.log(JSON.stringify(result1, null, 2));
|
|
||||||
//
|
|
||||||
// console.log("\n=== 多个瓜农测试 ===");
|
|
||||||
// const result2 = calculateSupplierWeights(multipleSuppliers);
|
|
||||||
// console.log(JSON.stringify(result2, null, 2));
|
|
||||||
//
|
|
||||||
// console.log("\n=== 第一个但不是最后一个测试 ===");
|
|
||||||
// const result3 = calculateSupplierWeights(firstNotLastSuppliers);
|
|
||||||
// console.log(JSON.stringify(result3, null, 2));
|
|
||||||
//
|
|
||||||
// // 详细显示结果
|
|
||||||
// function displayResults(suppliers, title) {
|
|
||||||
// console.log(`\n${title}:`);
|
|
||||||
// suppliers.forEach((supplier, index) => {
|
|
||||||
//
|
|
||||||
// const isFirstSupplier = index === 0;
|
|
||||||
// const isLastSupplier = supplier.isLast === true;
|
|
||||||
//
|
|
||||||
// console.log(`\n农户${index + 1} ${supplier.name}:`);
|
|
||||||
// console.log(` 是否第一个: ${index === 0 ? '是' : '否'}`);
|
|
||||||
// console.log(` 是否最后一个: ${supplier.isLast ? '是' : '否'}`);
|
|
||||||
// console.log(` 空磅重量: ${supplier.emptyWeight} kg`);
|
|
||||||
// console.log(` 总磅重量: ${supplier.totalWeight} kg`);
|
|
||||||
// console.log(` 净重: ${supplier.netWeight?.toFixed(2) || 'N/A'} 斤`);
|
|
||||||
// console.log(` 毛重: ${supplier.grossWeight?.toFixed(2) || 'N/A'} 斤`);
|
|
||||||
//
|
|
||||||
// if (supplier.isPaper) {
|
|
||||||
// const usedBoxesWeight = calculateBoxesTotalWeight(supplier.orderPackageList, 'used');
|
|
||||||
// const extraUsedBoxesWeight = calculateBoxesTotalWeight(supplier.orderPackageList, 'extra-used');
|
|
||||||
// const extraBoxesWeight = calculateBoxesTotalWeight(supplier.orderPackageList, 'extra');
|
|
||||||
// const remainingEmptyBoxesWeight = calculateBoxesTotalWeight(supplier.orderPackageList, 'remaining');
|
|
||||||
//
|
|
||||||
// if (isFirstSupplier && isLastSupplier) {
|
|
||||||
// console.log(` 本次使用纸箱重量: ${usedBoxesWeight.toFixed(2)} 斤`);
|
|
||||||
// console.log(` 已用额外运输纸箱重量: ${extraUsedBoxesWeight.toFixed(2)} 斤`);
|
|
||||||
// console.log(` 车上剩余纸箱重量: ${remainingEmptyBoxesWeight.toFixed(2)} 斤`);
|
|
||||||
// console.log(` 净重 = (总磅${supplier.totalWeight} - 空磅${supplier.emptyWeight}) × 2 + 车上剩余纸箱重量${remainingEmptyBoxesWeight.toFixed(2)} - 已用额外运输纸箱重量${extraUsedBoxesWeight.toFixed(2)} = ${supplier.netWeight?.toFixed(2)}斤`);
|
|
||||||
// console.log(` 毛重 = 净重${supplier.netWeight?.toFixed(2)} + 本次使用纸箱重量${usedBoxesWeight.toFixed(2)} = ${supplier.grossWeight?.toFixed(2)}斤`);
|
|
||||||
// } else if (isFirstSupplier) {
|
|
||||||
// // 第一个瓜农
|
|
||||||
// console.log(` 本次使用纸箱重量: ${usedBoxesWeight.toFixed(2)} 斤`);
|
|
||||||
// console.log(` 额外运输纸箱重量: ${extraBoxesWeight.toFixed(2)} 斤`);
|
|
||||||
// console.log(` 净重 = (总磅${supplier.totalWeight} - 空磅${supplier.emptyWeight}) × 2 - 额外运输纸箱重量${extraBoxesWeight.toFixed(2)} = ${supplier.netWeight?.toFixed(2)}斤`);
|
|
||||||
// console.log(` 毛重 = 净重${supplier.netWeight?.toFixed(2)} + 本次使用纸箱重量${usedBoxesWeight.toFixed(2)} = ${supplier.grossWeight?.toFixed(2)}斤`);
|
|
||||||
// } else if (isLastSupplier) {
|
|
||||||
// // 最后一个瓜农
|
|
||||||
// console.log(` 本次使用纸箱重量: ${usedBoxesWeight.toFixed(2)} 斤`);
|
|
||||||
// console.log(` 已用额外运输纸箱重量: ${extraUsedBoxesWeight.toFixed(2)} 斤`);
|
|
||||||
// console.log(` 车上剩余纸箱重量: ${remainingEmptyBoxesWeight.toFixed(2)} 斤`);
|
|
||||||
// console.log(` 净重 = (总磅${supplier.totalWeight} - 空磅${suppliers[index-1]?.totalWeight}) × 2 + 车上剩余纸箱重量${remainingEmptyBoxesWeight.toFixed(2)} - 已用额外运输纸箱重量${extraUsedBoxesWeight.toFixed(2)} = ${supplier.netWeight?.toFixed(2)}斤`);
|
|
||||||
// console.log(` 毛重 = 净重${supplier.netWeight?.toFixed(2)} + 本次使用纸箱重量${usedBoxesWeight.toFixed(2)} = ${supplier.grossWeight?.toFixed(2)}斤`);
|
|
||||||
// } else {
|
|
||||||
// console.log(` 本次使用纸箱重量: ${usedBoxesWeight.toFixed(2)} 斤`);
|
|
||||||
// console.log(` 额外运输纸箱重量: ${extraBoxesWeight.toFixed(2)} 斤`);
|
|
||||||
// console.log(` 净重 = (总磅${supplier.totalWeight} - 空磅${suppliers[index-1]?.totalWeight}) × 2 - 额外运输纸箱重量${extraBoxesWeight.toFixed(2)} = ${supplier.netWeight?.toFixed(2)}斤`);
|
|
||||||
// console.log(` 毛重 = 净重${supplier.netWeight?.toFixed(2)} + 本次使用纸箱重量${usedBoxesWeight.toFixed(2)} = ${supplier.grossWeight?.toFixed(2)}斤`);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// displayResults(result1, "单个瓜农结果");
|
|
||||||
// displayResults(result2, "多个瓜农结果");
|
|
||||||
// displayResults(result3, "第一个但不是最后一个结果");
|
|
||||||
@ -1,9 +1,9 @@
|
|||||||
// 将BoxBrand转换为OrderPackage数组
|
// 将BoxBrand转换为OrderPackage数组
|
||||||
import { BoxBrand, BoxCategory, BoxProduct } from "@/types/typings";
|
import { BoxBrand, BoxProduct, BoxSpec } from "@/types/typings";
|
||||||
import { generateShortId } from "@/utils/generateShortId";
|
import { generateShortId } from "@/utils/generateShortId";
|
||||||
|
|
||||||
// 添加一个辅助函数用于分组
|
// 添加一个辅助函数用于分组
|
||||||
const groupBy = <T,>(
|
const groupBy = <T>(
|
||||||
array: T[],
|
array: T[],
|
||||||
keyFn: (item: T) => string,
|
keyFn: (item: T) => string,
|
||||||
): Record<string, T[]> => {
|
): Record<string, T[]> => {
|
||||||
@ -22,19 +22,21 @@ const groupBy = <T,>(
|
|||||||
|
|
||||||
export const convertBoxBrandToOrderPackages = (
|
export const convertBoxBrandToOrderPackages = (
|
||||||
boxBrand: BoxBrand,
|
boxBrand: BoxBrand,
|
||||||
boxType: BusinessAPI.OrderPackage["boxType"] = "USED"
|
boxType: BusinessAPI.OrderPackage["boxType"] = "USED",
|
||||||
): BusinessAPI.OrderPackage[] => {
|
): BusinessAPI.OrderPackage[] => {
|
||||||
const orderPackages: BusinessAPI.OrderPackage[] = [];
|
const orderPackages: BusinessAPI.OrderPackage[] = [];
|
||||||
|
|
||||||
boxBrand.boxCategoryList?.forEach((category) => {
|
boxBrand.boxSpecList?.forEach((category) => {
|
||||||
category.boxProductList.forEach((product) => {
|
category.boxProductList.forEach((product) => {
|
||||||
orderPackages.push({
|
orderPackages.push({
|
||||||
orderPackageId: product.id,
|
orderPackageId: product.id,
|
||||||
boxBrandId: product.boxBrandId,
|
boxBrandId: product.boxBrandId,
|
||||||
boxBrandName: product.boxBrandName,
|
boxBrandName: product.boxBrandName,
|
||||||
boxBrandImage: boxBrand.boxBrandImage,
|
boxBrandImage: boxBrand.boxBrandImage,
|
||||||
boxCategoryId: product.boxCategoryId,
|
boxSpecId: product.boxSpecId,
|
||||||
|
boxSpecName: product.boxSpecName,
|
||||||
boxProductId: product.boxProductId,
|
boxProductId: product.boxProductId,
|
||||||
|
boxBrandType: boxBrand.boxBrandType,
|
||||||
boxProductName: product.boxProductName,
|
boxProductName: product.boxProductName,
|
||||||
boxProductWeight: product.boxProductWeight,
|
boxProductWeight: product.boxProductWeight,
|
||||||
boxCount: product.boxCount || 0,
|
boxCount: product.boxCount || 0,
|
||||||
@ -50,54 +52,48 @@ export const convertBoxBrandToOrderPackages = (
|
|||||||
|
|
||||||
// 将OrderPackage数组转换为BoxBrand数组
|
// 将OrderPackage数组转换为BoxBrand数组
|
||||||
export const convertOrderPackagesToBoxBrands = (
|
export const convertOrderPackagesToBoxBrands = (
|
||||||
orderPackages: BusinessAPI.OrderPackage[]
|
orderPackages: BusinessAPI.OrderPackage[],
|
||||||
): BoxBrand[] => {
|
): BoxBrand[] => {
|
||||||
// 按品牌ID分组
|
// 按品牌ID分组
|
||||||
const packagesByBrand = groupBy(
|
const packagesByBrand = groupBy(orderPackages, (pkg) => pkg.boxBrandId);
|
||||||
orderPackages,
|
|
||||||
(pkg) => pkg.boxBrandId
|
|
||||||
);
|
|
||||||
|
|
||||||
// 转换为BoxBrand数组
|
// 转换为BoxBrand数组
|
||||||
return Object.entries(packagesByBrand).map(([brandId, packages]) => {
|
return Object.entries(packagesByBrand).map(([brandId, packages]) => {
|
||||||
const firstPackage = packages[0];
|
const firstPackage = packages[0];
|
||||||
|
|
||||||
// 按分类ID分组
|
// 按分类ID分组
|
||||||
const packagesByCategory = groupBy(
|
const packagesBySpec = groupBy(packages, (pkg) => pkg.boxSpecId);
|
||||||
packages,
|
|
||||||
(pkg) => pkg.boxCategoryId
|
|
||||||
);
|
|
||||||
|
|
||||||
// 创建BoxCategory数组
|
// 创建BoxCategory数组
|
||||||
const boxCategories: BoxCategory[] = Object.entries(packagesByCategory).map(
|
const boxSpecList: BoxSpec[] = Object.entries(packagesBySpec).map(
|
||||||
([categoryId, categoryPackages]) => {
|
([specId, specList]) => {
|
||||||
const firstCategoryPackage = categoryPackages[0];
|
const firstCategoryPackage = specList[0];
|
||||||
|
|
||||||
// 创建BoxProduct数组
|
// 创建BoxProduct数组
|
||||||
const boxProducts: BoxProduct[] = categoryPackages.map((pkg) => ({
|
const boxProducts: BoxProduct[] = specList.map(
|
||||||
id: pkg.orderPackageId || generateShortId(),
|
(pkg) =>
|
||||||
boxBrandId: pkg.boxBrandId,
|
({
|
||||||
boxBrandName: pkg.boxBrandName,
|
id: pkg.orderPackageId || generateShortId(),
|
||||||
boxProductId: pkg.boxProductId,
|
boxBrandId: pkg.boxBrandId,
|
||||||
boxProductName: pkg.boxProductName,
|
boxBrandName: pkg.boxBrandName,
|
||||||
boxProductWeight: pkg.boxProductWeight,
|
boxProductId: pkg.boxProductId,
|
||||||
boxCategoryId: pkg.boxCategoryId,
|
boxProductName: pkg.boxProductName,
|
||||||
boxCostPrice: pkg.boxCostPrice,
|
boxProductWeight: pkg.boxProductWeight,
|
||||||
boxSalePrice: pkg.boxSalePrice,
|
boxSpecId: pkg.boxSpecId,
|
||||||
boxCount: pkg.boxCount,
|
boxSpecName: pkg.boxSpecName,
|
||||||
} as BoxProduct));
|
boxCostPrice: pkg.boxCostPrice,
|
||||||
|
boxSalePrice: pkg.boxSalePrice,
|
||||||
|
boxCount: pkg.boxCount,
|
||||||
|
}) as BoxProduct,
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: generateShortId(),
|
id: generateShortId(),
|
||||||
boxCategoryId: categoryId as "FOUR_GRAIN" | "TWO_GRAIN",
|
boxSpecId: specId,
|
||||||
boxCategoryName: firstCategoryPackage.boxCategoryId === "FOUR_GRAIN"
|
boxSpecName: firstCategoryPackage.boxSpecName,
|
||||||
? "4粒装"
|
|
||||||
: firstCategoryPackage.boxCategoryId === "TWO_GRAIN"
|
|
||||||
? "2粒装"
|
|
||||||
: "未知",
|
|
||||||
boxProductList: boxProducts,
|
boxProductList: boxProducts,
|
||||||
};
|
};
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -105,8 +101,9 @@ export const convertOrderPackagesToBoxBrands = (
|
|||||||
boxBrandId: brandId,
|
boxBrandId: brandId,
|
||||||
boxType: firstPackage.boxType,
|
boxType: firstPackage.boxType,
|
||||||
boxBrandName: firstPackage.boxBrandName,
|
boxBrandName: firstPackage.boxBrandName,
|
||||||
boxBrandImage: firstPackage.boxBrandImage,
|
boxBrandImage: firstPackage.boxBrandImage!,
|
||||||
boxCategoryList: boxCategories,
|
boxBrandType: firstPackage.boxBrandType,
|
||||||
|
boxSpecList: boxSpecList,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user