feat(purchase): 优化采购模块UI与逻辑处理
- 在CostCard组件中添加了对空成本项列表的条件渲染 - 更新EmptyBoxModule和OrderPackage组件中的数组长度判断为可选链形式 - 在MelonFarmer组件中增加supplierVO的日志输出并修正isLast属性比较逻辑 - 重构OrderCost组件的成本初始化逻辑,提升性能和代码可读性 - 移除OrderCostItem组件中不必要的控制台日志 - 优化OrderCostItem组件中selected状态的赋值逻辑 - 升级Weigh组件中关于供应商字段的布尔值判断方式 - 将PurchasePreview组件中空箱使用明细的显示条件改为可选链判断 - 提升create页面中添加瓜农按钮的视觉样式与布局结构 - 更新应用版本号从v0.0.26至v0.0.28
This commit is contained in:
parent
47c7bdf357
commit
1676290798
@ -94,23 +94,25 @@ export default function CostCard(props: CostCardComponentProps) {
|
|||||||
hint="点击金额可直接编辑"
|
hint="点击金额可直接编辑"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<View className="flex flex-1 flex-col gap-2 pl-4">
|
{orderCostItemList.length > 0 && (
|
||||||
{orderCostItemList.map((orderCostItem) => {
|
<View className="flex flex-1 flex-col gap-2 pl-4">
|
||||||
return (
|
{orderCostItemList.map((orderCostItem) => {
|
||||||
<View
|
return (
|
||||||
key={orderCostItem.orderCostItemId}
|
<View
|
||||||
className="flex items-center justify-between"
|
key={orderCostItem.orderCostItemId}
|
||||||
>
|
className="flex items-center justify-between"
|
||||||
<Text className="text-sm text-gray-500">
|
>
|
||||||
{orderCostItem.name}
|
<Text className="text-sm text-gray-500">
|
||||||
</Text>
|
{orderCostItem.name}
|
||||||
<Text className="text-sm font-medium">
|
</Text>
|
||||||
{orderCostItem.count} {orderCostItem.unit}
|
<Text className="text-sm font-medium">
|
||||||
</Text>
|
{orderCostItem.count} {orderCostItem.unit}
|
||||||
</View>
|
</Text>
|
||||||
);
|
</View>
|
||||||
})}
|
);
|
||||||
</View>
|
})}
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
|||||||
@ -128,7 +128,7 @@ export default function EmptyBoxModule(props: IEmptyBoxModuleProps) {
|
|||||||
initBoxBrandList().then();
|
initBoxBrandList().then();
|
||||||
setEmptyBoxList(orderPackageList);
|
setEmptyBoxList(orderPackageList);
|
||||||
|
|
||||||
if (orderPackageList.length > 0) {
|
if (orderPackageList?.length > 0) {
|
||||||
// 根据当前供应商确定需要检查的纸箱类型
|
// 根据当前供应商确定需要检查的纸箱类型
|
||||||
let requiredTypes: string[] = ["EMPTY"];
|
let requiredTypes: string[] = ["EMPTY"];
|
||||||
|
|
||||||
|
|||||||
@ -549,6 +549,7 @@ export default forwardRef<MelonFarmerRef, IMelonFarmerProps>(
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log("supplierVO", supplierVO);
|
||||||
if (!supplierVO) {
|
if (!supplierVO) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -588,9 +589,9 @@ export default forwardRef<MelonFarmerRef, IMelonFarmerProps>(
|
|||||||
<Radio.Group
|
<Radio.Group
|
||||||
direction="horizontal"
|
direction="horizontal"
|
||||||
value={
|
value={
|
||||||
supplierVO.isLast
|
supplierVO.isLast === true
|
||||||
? "true"
|
? "true"
|
||||||
: !supplierVO.isLast
|
: supplierVO.isLast === false
|
||||||
? "false"
|
? "false"
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import { Icon } from "@/components";
|
|||||||
import { forwardRef, useEffect, useImperativeHandle, useState } from "react";
|
import { forwardRef, useEffect, useImperativeHandle, useState } from "react";
|
||||||
import { Checkbox, Input, Toast } from "@nutui/nutui-react-taro";
|
import { Checkbox, Input, Toast } from "@nutui/nutui-react-taro";
|
||||||
import { generateShortId } from "@/utils";
|
import { generateShortId } from "@/utils";
|
||||||
import { business } from "@/services";
|
|
||||||
|
|
||||||
// 定义ref暴露的方法接口
|
// 定义ref暴露的方法接口
|
||||||
export interface OrderCostRef {
|
export interface OrderCostRef {
|
||||||
@ -30,54 +29,41 @@ export default forwardRef<OrderCostRef, IOrderCostProps>(
|
|||||||
|
|
||||||
// 初始化函数
|
// 初始化函数
|
||||||
const init = async (costIds: string[]) => {
|
const init = async (costIds: string[]) => {
|
||||||
let newOrderCostList: BusinessAPI.OrderCost[] = [];
|
// 创建一个映射,用于快速查找orderCostItemList中的项目
|
||||||
|
const orderCostMap = new Map<string, BusinessAPI.OrderCost>();
|
||||||
|
|
||||||
// 获取成本列表
|
orderCostList?.forEach((item) => {
|
||||||
const {
|
if (item.costId && costIds.includes(item.costId)) {
|
||||||
data: { data: costList, success },
|
orderCostMap.set(item.costId, item);
|
||||||
} = await business.cost.listCost({
|
}
|
||||||
costListQry: {
|
|
||||||
status: true,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (success) {
|
// 构建初始列表,基于costTemplate中的项目
|
||||||
const newCostList = costList?.filter((item) => {
|
const newOrderCostList: IOrderCost[] = [];
|
||||||
return costIds.includes(item.costId);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 遍历costList,将costList中的项目添加到orderCostList中
|
// 遍历costList,将costList中的项目添加到orderCostList中
|
||||||
newCostList?.forEach((item) => {
|
parsedCostTemplate.productionTypeList?.forEach((item) => {
|
||||||
const orderCost = orderCostList.find(
|
const existingItem = orderCostMap.get(item.costItemId);
|
||||||
(cost) => cost.costId === item.costId,
|
|
||||||
);
|
|
||||||
|
|
||||||
const selected = parsedCostTemplate.productionTypeList?.some(
|
if (existingItem) {
|
||||||
(cost) => {
|
newOrderCostList.push({
|
||||||
return cost.costId === item.costId;
|
...existingItem,
|
||||||
},
|
selected: !!existingItem,
|
||||||
);
|
});
|
||||||
|
} else {
|
||||||
if (orderCost) {
|
newOrderCostList.push({
|
||||||
newOrderCostList.push({
|
orderCostId: generateShortId(),
|
||||||
...orderCost,
|
costItemIds: item.costItemIds,
|
||||||
selected: selected,
|
costId: item.costId,
|
||||||
});
|
name: item.name,
|
||||||
} else {
|
type: item.type,
|
||||||
newOrderCostList.push({
|
selected: false,
|
||||||
orderCostId: generateShortId(),
|
count: 1,
|
||||||
costItemIds: item.costItemIds,
|
price: item.price || 0,
|
||||||
costId: item.costId,
|
unit: item.unit || "元",
|
||||||
name: item.name,
|
});
|
||||||
type: item.type,
|
}
|
||||||
selected: selected,
|
});
|
||||||
count: 1,
|
|
||||||
price: item.price || 0,
|
|
||||||
unit: item.unit || "元",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
onChange?.({
|
onChange?.({
|
||||||
...value,
|
...value,
|
||||||
|
|||||||
@ -47,8 +47,6 @@ export default forwardRef<OrderCostItemRef, IOrderCostItemProps>(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("orderCostItemList,", orderCostItemList);
|
|
||||||
|
|
||||||
// 构建初始列表,基于costTemplate中的项目
|
// 构建初始列表,基于costTemplate中的项目
|
||||||
const newOrderCostItemList: IOrderCostItem[] = [];
|
const newOrderCostItemList: IOrderCostItem[] = [];
|
||||||
|
|
||||||
@ -62,7 +60,7 @@ export default forwardRef<OrderCostItemRef, IOrderCostItemProps>(
|
|||||||
name: item.name,
|
name: item.name,
|
||||||
price: item.price,
|
price: item.price,
|
||||||
unit: item.unit,
|
unit: item.unit,
|
||||||
selected: true,
|
selected: !!existingItem,
|
||||||
count: existingItem?.count || 1,
|
count: existingItem?.count || 1,
|
||||||
payerType: existingItem?.payerType,
|
payerType: existingItem?.payerType,
|
||||||
type: item.type,
|
type: item.type,
|
||||||
@ -82,7 +80,7 @@ export default forwardRef<OrderCostItemRef, IOrderCostItemProps>(
|
|||||||
name: item.name,
|
name: item.name,
|
||||||
price: item.price,
|
price: item.price,
|
||||||
unit: item.unit,
|
unit: item.unit,
|
||||||
selected: true,
|
selected: !!existingItem,
|
||||||
count: existingItem?.count || 1,
|
count: existingItem?.count || 1,
|
||||||
payerType: existingItem?.payerType,
|
payerType: existingItem?.payerType,
|
||||||
type: item.type,
|
type: item.type,
|
||||||
@ -90,7 +88,6 @@ export default forwardRef<OrderCostItemRef, IOrderCostItemProps>(
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("newOrderCostItemList,", newOrderCostItemList);
|
|
||||||
onChange?.({
|
onChange?.({
|
||||||
...value,
|
...value,
|
||||||
orderCostItemList: newOrderCostItemList,
|
orderCostItemList: newOrderCostItemList,
|
||||||
|
|||||||
@ -41,7 +41,7 @@ export default forwardRef<OrderPackageRef, IOrderPackageProps>(
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// 初始化数据
|
// 初始化数据
|
||||||
if (orderPackageList.length > 0) {
|
if (orderPackageList?.length > 0) {
|
||||||
// 根据当前供应商确定需要检查的纸箱类型
|
// 根据当前供应商确定需要检查的纸箱类型
|
||||||
let requiredTypes: string[] = [];
|
let requiredTypes: string[] = [];
|
||||||
|
|
||||||
|
|||||||
@ -245,7 +245,7 @@ export default function PurchasePreview(props: IPurchasePreviewProps) {
|
|||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{purchaseOrder.orderPackageList.length > 0 && (
|
{purchaseOrder.orderPackageList?.length > 0 && (
|
||||||
<>
|
<>
|
||||||
<View className="text-sm font-bold">空箱使用明细</View>
|
<View className="text-sm font-bold">空箱使用明细</View>
|
||||||
<View className="flex flex-col gap-2.5">
|
<View className="flex flex-col gap-2.5">
|
||||||
|
|||||||
@ -535,9 +535,9 @@ export default forwardRef<WeighRef, IWeightProps>(function Weigh(props, ref) {
|
|||||||
<Radio.Group
|
<Radio.Group
|
||||||
direction="horizontal"
|
direction="horizontal"
|
||||||
value={
|
value={
|
||||||
supplierVO.isPaper
|
supplierVO.isPaper === true
|
||||||
? "true"
|
? "true"
|
||||||
: !supplierVO.isPaper
|
: supplierVO.isPaper === false
|
||||||
? "false"
|
? "false"
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
@ -639,7 +639,7 @@ export default forwardRef<WeighRef, IWeightProps>(function Weigh(props, ref) {
|
|||||||
<Radio.Group
|
<Radio.Group
|
||||||
direction="horizontal"
|
direction="horizontal"
|
||||||
value={
|
value={
|
||||||
supplierVO.isDepositPaid
|
supplierVO.isDepositPaid === true
|
||||||
? "true"
|
? "true"
|
||||||
: supplierVO.isDepositPaid === false
|
: supplierVO.isDepositPaid === false
|
||||||
? "false"
|
? "false"
|
||||||
|
|||||||
@ -1,2 +1,2 @@
|
|||||||
// App 相关常量
|
// App 相关常量
|
||||||
export const APP_VERSION = "v0.0.26";
|
export const APP_VERSION = "v0.0.28";
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
import hocAuth from "@/hocs/auth";
|
import hocAuth from "@/hocs/auth";
|
||||||
import { CommonComponent } from "@/types/typings";
|
import {CommonComponent} from "@/types/typings";
|
||||||
import { View } from "@tarojs/components";
|
import {View} from "@tarojs/components";
|
||||||
import { purchase } from "@/constant";
|
import {purchase} from "@/constant";
|
||||||
import { useEffect, useRef, useState } from "react";
|
import {useEffect, useRef, useState} from "react";
|
||||||
import {
|
import {
|
||||||
Icon,
|
Icon,
|
||||||
MelonFarmer,
|
MelonFarmer,
|
||||||
@ -22,10 +22,10 @@ import {
|
|||||||
Weigh,
|
Weigh,
|
||||||
WeighRef,
|
WeighRef,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { business } from "@/services";
|
import {business} from "@/services";
|
||||||
import { buildUrl, generateShortId, SupplierWeightCalculator } from "@/utils";
|
import {buildUrl, generateShortId, SupplierWeightCalculator} from "@/utils";
|
||||||
import Taro from "@tarojs/taro";
|
import Taro from "@tarojs/taro";
|
||||||
import { Button } from "@nutui/nutui-react-taro";
|
import {Button} from "@nutui/nutui-react-taro";
|
||||||
|
|
||||||
const defaultSupplierList: Partial<BusinessAPI.OrderSupplier>[] = [
|
const defaultSupplierList: Partial<BusinessAPI.OrderSupplier>[] = [
|
||||||
{
|
{
|
||||||
@ -422,19 +422,24 @@ export default hocAuth(function Page(props: CommonComponent) {
|
|||||||
purchaseOrder?.orderSupplierList[
|
purchaseOrder?.orderSupplierList[
|
||||||
purchaseOrder?.orderSupplierList.length - 1
|
purchaseOrder?.orderSupplierList.length - 1
|
||||||
]?.isLast && (
|
]?.isLast && (
|
||||||
<Button
|
<View className="flex flex-1 flex-col gap-2.5 bg-[#D1D5DB] p-2.5 pt-2.5">
|
||||||
icon={<Icon name={"plus"} size={20} />}
|
<View className={"flex flex-1 flex-col gap-2.5"}>
|
||||||
type={"primary"}
|
<View className="text-sm font-bold">快捷操作</View>
|
||||||
size={"xlarge"}
|
<Button
|
||||||
fill={"outline"}
|
icon={<Icon name={"plus"} size={20} />}
|
||||||
block
|
type={"primary"}
|
||||||
className="border-primary text-primary flex w-full items-center justify-center !border-4 !bg-white"
|
size={"xlarge"}
|
||||||
onClick={() => {
|
fill={"outline"}
|
||||||
orderOptionRef.current?.onAdd();
|
block
|
||||||
}}
|
className="border-primary text-primary flex w-full items-center justify-center !border-4 !bg-white"
|
||||||
>
|
onClick={() => {
|
||||||
<View>添加另一个瓜农</View>
|
orderOptionRef.current?.onAdd();
|
||||||
</Button>
|
}}
|
||||||
|
>
|
||||||
|
<View>添加另一个瓜农</View>
|
||||||
|
</Button>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user