feat(components): 为输入组件添加清除功能并优化类型定义

- 为多个 Input 组件添加 clearable 属性提升用户体验
- 将部分 number 类型输入改为 digit 类型以适配移动端
- 调整布局样式类名如 flex-1 和 flex-shrink-0 的应用
- 修正 API 类型定义中 roleId、costItemIds 等字段从 number[] 到 string[]
- 优化档口重量计算器中的方法参数和计算逻辑
- 新增采购报价重量计算方法支持毛重/净重切换
This commit is contained in:
shenyifei 2025-12-27 19:56:20 +08:00
parent 1802e904ec
commit d019257566
25 changed files with 183 additions and 65 deletions

View File

@ -158,6 +158,7 @@ export default function DealerPicker(props: IDealerPickerProps) {
className={`flex h-10 w-full items-center rounded-md border-4 border-gray-300`} className={`flex h-10 w-full items-center rounded-md border-4 border-gray-300`}
> >
<Input <Input
clearable
type="text" type="text"
placeholder="请输入经销商名称" placeholder="请输入经销商名称"
value={inputValue} value={inputValue}

View File

@ -96,6 +96,7 @@ const Step1Form = forwardRef<Step1FormRef, Step1FormProps>((props, ref) => {
className={`flex h-10 w-full items-center rounded-md ${formErrors.watermelonGrade ? "border-4 border-red-500" : "border-4 border-gray-300"}`} className={`flex h-10 w-full items-center rounded-md ${formErrors.watermelonGrade ? "border-4 border-red-500" : "border-4 border-gray-300"}`}
> >
<Input <Input
clearable
disabled={readOnly} disabled={readOnly}
value={orderShip?.watermelonGrade || ""} value={orderShip?.watermelonGrade || ""}
onChange={(value) => { onChange={(value) => {
@ -159,6 +160,7 @@ const Step1Form = forwardRef<Step1FormRef, Step1FormProps>((props, ref) => {
className={`flex h-10 w-full items-center rounded-md ${formErrors.shippingAddress ? "border-4 border-red-500" : "border-4 border-gray-300"}`} className={`flex h-10 w-full items-center rounded-md ${formErrors.shippingAddress ? "border-4 border-red-500" : "border-4 border-gray-300"}`}
> >
<Input <Input
clearable
disabled={readOnly} disabled={readOnly}
value={orderShip?.shippingAddress || ""} value={orderShip?.shippingAddress || ""}
onChange={(value) => { onChange={(value) => {
@ -351,14 +353,15 @@ const Step1Form = forwardRef<Step1FormRef, Step1FormProps>((props, ref) => {
key={orderShipItem.orderShipItemId} key={orderShipItem.orderShipItemId}
className={"flex flex-row gap-2.5"} className={"flex flex-row gap-2.5"}
> >
<View className="flex flex-1 items-center text-sm font-normal text-[#000000]"> <View className="flex flex-shrink-0 items-center text-sm font-normal text-[#000000]">
{orderShipItem.unitPrice} / {orderShipItem.unitPrice} /
</View> </View>
<View <View
className={`flex h-10 items-center rounded-md ${formErrors.itemGrades?.[orderShipItem.orderShipItemId] ? "border-4 border-red-500" : "border-4 border-gray-300"}`} className={`flex h-10 flex-1 items-center rounded-md ${formErrors.itemGrades?.[orderShipItem.orderShipItemId] ? "border-4 border-red-500" : "border-4 border-gray-300"}`}
> >
<Input <Input
clearable
disabled={readOnly} disabled={readOnly}
value={orderShipItem.watermelonGrade || ""} value={orderShipItem.watermelonGrade || ""}
onChange={(value) => { onChange={(value) => {

View File

@ -186,6 +186,7 @@ export default function ExpenseCostCreate(props: IExpenseCostCreateProps) {
className={`border-neutral-base flex flex-row items-center rounded-md ${formErrors.expenseAmount ? "border-4 border-red-500" : "border-4 border-gray-300"}`} className={`border-neutral-base flex flex-row items-center rounded-md ${formErrors.expenseAmount ? "border-4 border-red-500" : "border-4 border-gray-300"}`}
> >
<Input <Input
clearable
className={"placeholder:text-neutral-dark"} className={"placeholder:text-neutral-dark"}
type={"digit"} type={"digit"}
value={expressCost?.expenseAmount?.toString() || ""} value={expressCost?.expenseAmount?.toString() || ""}

View File

@ -164,6 +164,7 @@ export default function ExpenseProvisionCreate(
className={`border-neutral-base flex flex-row items-center rounded-md ${formErrors.provisionAmount ? "border-4 border-red-500" : "border-4 border-gray-300"}`} className={`border-neutral-base flex flex-row items-center rounded-md ${formErrors.provisionAmount ? "border-4 border-red-500" : "border-4 border-gray-300"}`}
> >
<Input <Input
clearable
className={"placeholder:text-neutral-dark"} className={"placeholder:text-neutral-dark"}
type={"digit"} type={"digit"}
value={expenseProvision?.provisionAmount?.toString() || ""} value={expenseProvision?.provisionAmount?.toString() || ""}

View File

@ -203,6 +203,7 @@ export default function CostCreate(props: AddCostComponentProps) {
} }
> >
<Input <Input
clearable
className={"placeholder:text-neutral-dark"} className={"placeholder:text-neutral-dark"}
type={"digit"} type={"digit"}
value={amount?.toString()} value={amount?.toString()}
@ -275,6 +276,7 @@ export default function CostCreate(props: AddCostComponentProps) {
} }
> >
<Input <Input
clearable
className={"placeholder:text-neutral-dark"} className={"placeholder:text-neutral-dark"}
type={"digit"} type={"digit"}
value={amount?.toString()} value={amount?.toString()}
@ -332,7 +334,8 @@ export default function CostCreate(props: AddCostComponentProps) {
</View> </View>
<View className="flex h-8 w-12 items-center justify-center border-y border-gray-200"> <View className="flex h-8 w-12 items-center justify-center border-y border-gray-200">
<Input <Input
type="number" clearable
type="digit"
value={currentCount.toString()} value={currentCount.toString()}
align={"center"} align={"center"}
className="!h-8 !w-12 !p-0 !text-center" className="!h-8 !w-12 !p-0 !text-center"

View File

@ -344,6 +344,7 @@ const Step1Form = forwardRef<Step1FormRef, Step1FormProps>((props, ref) => {
</View> </View>
<View className="border-neutral-base relative flex h-10 w-full items-center rounded-md border border-solid"> <View className="border-neutral-base relative flex h-10 w-full items-center rounded-md border border-solid">
<Input <Input
clearable
className="placeholder:text-neutral-dark flex-1" className="placeholder:text-neutral-dark flex-1"
placeholder="请输入商品名称" placeholder="请输入商品名称"
value={goodsFormData.productName} value={goodsFormData.productName}
@ -366,6 +367,7 @@ const Step1Form = forwardRef<Step1FormRef, Step1FormProps>((props, ref) => {
</View> </View>
<View className="border-neutral-base relative flex h-10 w-full items-center rounded-md border border-solid"> <View className="border-neutral-base relative flex h-10 w-full items-center rounded-md border border-solid">
<Input <Input
clearable
className="placeholder:text-neutral-dark flex-1" className="placeholder:text-neutral-dark flex-1"
placeholder="请输入商品产地" placeholder="请输入商品产地"
value={goodsFormData.origin} value={goodsFormData.origin}
@ -431,6 +433,7 @@ const Step1Form = forwardRef<Step1FormRef, Step1FormProps>((props, ref) => {
</View> </View>
<View className="border-neutral-base relative flex h-10 w-full items-center rounded-md border border-solid"> <View className="border-neutral-base relative flex h-10 w-full items-center rounded-md border border-solid">
<Input <Input
clearable
className="placeholder:text-neutral-dark flex-1" className="placeholder:text-neutral-dark flex-1"
type="number" type="number"
placeholder="请输入数量" placeholder="请输入数量"
@ -452,6 +455,7 @@ const Step1Form = forwardRef<Step1FormRef, Step1FormProps>((props, ref) => {
</View> </View>
<View className="border-neutral-base relative flex h-10 w-full items-center rounded-md border border-solid"> <View className="border-neutral-base relative flex h-10 w-full items-center rounded-md border border-solid">
<Input <Input
clearable
className="placeholder:text-neutral-dark flex-1" className="placeholder:text-neutral-dark flex-1"
type="number" type="number"
placeholder="请输入总重量" placeholder="请输入总重量"
@ -473,6 +477,7 @@ const Step1Form = forwardRef<Step1FormRef, Step1FormProps>((props, ref) => {
</View> </View>
<View className="border-neutral-base relative flex h-10 w-full items-center rounded-md border border-solid"> <View className="border-neutral-base relative flex h-10 w-full items-center rounded-md border border-solid">
<Input <Input
clearable
className="placeholder:text-neutral-dark flex-1" className="placeholder:text-neutral-dark flex-1"
type="number" type="number"
placeholder="请输入单价" placeholder="请输入单价"

View File

@ -238,7 +238,8 @@ export default forwardRef<OrderCostRef, IOrderCostProps>(
className={`flex h-12 w-full shrink items-center border-4 ${countError[orderCostId] && selected ? "border-red-500" : "border-gray-200"} bg-white`} className={`flex h-12 w-full shrink items-center border-4 ${countError[orderCostId] && selected ? "border-red-500" : "border-gray-200"} bg-white`}
> >
<Input <Input
type="number" clearable
type="digit"
value={price.toString()} value={price.toString()}
align={"center"} align={"center"}
placeholder={"输入多少钱"} placeholder={"输入多少钱"}

View File

@ -435,6 +435,7 @@ export default forwardRef<OrderCostItemRef, IOrderCostItemProps>(
className={`flex h-12 w-full shrink items-center border-4 border-gray-200`} className={`flex h-12 w-full shrink items-center border-4 border-gray-200`}
> >
<Input <Input
clearable
type="number" type="number"
value={count?.toString()} value={count?.toString()}
align={"center"} align={"center"}
@ -490,7 +491,8 @@ export default forwardRef<OrderCostItemRef, IOrderCostItemProps>(
className={`flex h-12 w-full shrink items-center border-4 ${countError[orderCostItemId] && selected ? "border-red-500" : "border-gray-200"} bg-white`} className={`flex h-12 w-full shrink items-center border-4 ${countError[orderCostItemId] && selected ? "border-red-500" : "border-gray-200"} bg-white`}
> >
<Input <Input
type="number" clearable
type="digit"
value={price.toString()} value={price.toString()}
align={"center"} align={"center"}
placeholder={"输入多少钱"} placeholder={"输入多少钱"}
@ -553,6 +555,7 @@ export default forwardRef<OrderCostItemRef, IOrderCostItemProps>(
className={`flex h-12 items-center rounded-md ${foremanError ? "border-2 border-red-500 bg-red-100" : "border-2 border-gray-300 bg-white"}`} className={`flex h-12 items-center rounded-md ${foremanError ? "border-2 border-red-500 bg-red-100" : "border-2 border-gray-300 bg-white"}`}
> >
<Input <Input
clearable
className="text-base" className="text-base"
type="text" type="text"
placeholder={"工头的名字"} placeholder={"工头的名字"}

View File

@ -608,6 +608,7 @@ export default forwardRef<OrderVehicleRef, IOrderVehicleProps>(
className={`flex h-10 w-full items-center rounded-md ${plateError ? "border-4 border-red-500" : "border-4 border-gray-300"}`} className={`flex h-10 w-full items-center rounded-md ${plateError ? "border-4 border-red-500" : "border-4 border-gray-300"}`}
> >
<Input <Input
clearable
type="text" type="text"
placeholder="请输入车牌号" placeholder="请输入车牌号"
value={orderVehicle?.plate} value={orderVehicle?.plate}
@ -629,6 +630,7 @@ export default forwardRef<OrderVehicleRef, IOrderVehicleProps>(
className={`flex h-10 w-full items-center rounded-md ${driverError ? "border-4 border-red-500" : "border-4 border-gray-300"}`} className={`flex h-10 w-full items-center rounded-md ${driverError ? "border-4 border-red-500" : "border-4 border-gray-300"}`}
> >
<Input <Input
clearable
type="text" type="text"
placeholder="请输入司机姓名" placeholder="请输入司机姓名"
value={orderVehicle?.driver} value={orderVehicle?.driver}
@ -650,6 +652,7 @@ export default forwardRef<OrderVehicleRef, IOrderVehicleProps>(
className={`flex h-10 w-full items-center rounded-md ${phoneError ? "border-4 border-red-500" : "border-4 border-gray-300"}`} className={`flex h-10 w-full items-center rounded-md ${phoneError ? "border-4 border-red-500" : "border-4 border-gray-300"}`}
> >
<Input <Input
clearable
type="tel" type="tel"
placeholder="请输入联系电话" placeholder="请输入联系电话"
value={orderVehicle?.phone} value={orderVehicle?.phone}
@ -671,6 +674,7 @@ export default forwardRef<OrderVehicleRef, IOrderVehicleProps>(
className={`flex h-10 w-full items-center rounded-md ${originError ? "border-4 border-red-500" : "border-4 border-gray-300"}`} className={`flex h-10 w-full items-center rounded-md ${originError ? "border-4 border-red-500" : "border-4 border-gray-300"}`}
> >
<Input <Input
clearable
type="text" type="text"
placeholder="请输入出发地" placeholder="请输入出发地"
value={orderVehicle?.origin} value={orderVehicle?.origin}
@ -739,6 +743,7 @@ export default forwardRef<OrderVehicleRef, IOrderVehicleProps>(
className={`flex h-10 w-full items-center rounded-md ${destinationError ? "border-4 border-red-500" : "border-4 border-gray-300"}`} className={`flex h-10 w-full items-center rounded-md ${destinationError ? "border-4 border-red-500" : "border-4 border-gray-300"}`}
> >
<Input <Input
clearable
type="text" type="text"
placeholder="请输入目的地" placeholder="请输入目的地"
value={orderVehicle?.destination} value={orderVehicle?.destination}
@ -762,6 +767,7 @@ export default forwardRef<OrderVehicleRef, IOrderVehicleProps>(
className={`flex h-10 w-full items-center rounded-md ${priceError ? "border-4 border-red-500" : "border-4 border-gray-300"}`} className={`flex h-10 w-full items-center rounded-md ${priceError ? "border-4 border-red-500" : "border-4 border-gray-300"}`}
> >
<Input <Input
clearable
type="digit" type="digit"
placeholder="请输入运费可填0" placeholder="请输入运费可填0"
value={orderVehicle?.price?.toString()} value={orderVehicle?.price?.toString()}
@ -811,6 +817,7 @@ export default forwardRef<OrderVehicleRef, IOrderVehicleProps>(
className={`flex h-10 w-full items-center rounded-md ${strawCurtainPriceError ? "border-4 border-red-500" : "border-4 border-gray-300"}`} className={`flex h-10 w-full items-center rounded-md ${strawCurtainPriceError ? "border-4 border-red-500" : "border-4 border-gray-300"}`}
> >
<Input <Input
clearable
type="digit" type="digit"
placeholder="请输入草帘费用" placeholder="请输入草帘费用"
value={orderVehicle?.strawCurtainPrice?.toString()} value={orderVehicle?.strawCurtainPrice?.toString()}

View File

@ -908,6 +908,7 @@ export default forwardRef<StallInfoRef, IStallInfoProps>(
> >
<Icon name="user" size={16} color="#999" className="mx-2" /> <Icon name="user" size={16} color="#999" className="mx-2" />
<Input <Input
clearable
type="text" type="text"
placeholder="请输入档口名称" placeholder="请输入档口名称"
value={supplierVO.name} value={supplierVO.name}
@ -934,6 +935,7 @@ export default forwardRef<StallInfoRef, IStallInfoProps>(
> >
<Icon name="user" size={16} color="#999" className="mx-2" /> <Icon name="user" size={16} color="#999" className="mx-2" />
<Input <Input
clearable
type="text" type="text"
placeholder="请输入收款人姓名" placeholder="请输入收款人姓名"
value={supplierVO.payeeName} value={supplierVO.payeeName}
@ -967,6 +969,7 @@ export default forwardRef<StallInfoRef, IStallInfoProps>(
className="mx-2" className="mx-2"
/> />
<Input <Input
clearable
type="text" type="text"
placeholder="请输入银行名称" placeholder="请输入银行名称"
value={supplierVO.bankName} value={supplierVO.bankName}
@ -1000,6 +1003,7 @@ export default forwardRef<StallInfoRef, IStallInfoProps>(
className="mx-2" className="mx-2"
/> />
<Input <Input
clearable
type="digit" type="digit"
placeholder="请输入银行卡号" placeholder="请输入银行卡号"
value={supplierVO.bankCard} value={supplierVO.bankCard}
@ -1028,6 +1032,7 @@ export default forwardRef<StallInfoRef, IStallInfoProps>(
> >
<Icon name="phone" size={16} color="#999" className="mx-2" /> <Icon name="phone" size={16} color="#999" className="mx-2" />
<Input <Input
clearable
type="tel" type="tel"
placeholder="请输入手机号码" placeholder="请输入手机号码"
value={supplierVO.phone} value={supplierVO.phone}

View File

@ -244,6 +244,7 @@ export default forwardRef<StallWeighRef, IStallWeighProps>(
className={`flex h-10 w-full items-center rounded-md ${selectedProduct === "其他(请注明)" && customProduct ? "border-primary border-4" : "border-4 border-gray-300"}`} className={`flex h-10 w-full items-center rounded-md ${selectedProduct === "其他(请注明)" && customProduct ? "border-primary border-4" : "border-4 border-gray-300"}`}
> >
<Input <Input
clearable
placeholder="请输入品种" placeholder="请输入品种"
type="text" type="text"
value={customProduct} value={customProduct}
@ -417,6 +418,7 @@ export default forwardRef<StallWeighRef, IStallWeighProps>(
className={`flex h-10 w-full items-center rounded-md ${priceError[supplierVO.orderSupplierId] ? "border-4 border-red-500" : "border-4 border-yellow-300"}`} className={`flex h-10 w-full items-center rounded-md ${priceError[supplierVO.orderSupplierId] ? "border-4 border-red-500" : "border-4 border-yellow-300"}`}
> >
<Input <Input
clearable
placeholder="0.00" placeholder="0.00"
type="digit" type="digit"
value={supplierVO.purchasePrice?.toString()} value={supplierVO.purchasePrice?.toString()}
@ -476,6 +478,7 @@ export default forwardRef<StallWeighRef, IStallWeighProps>(
className={`flex h-10 w-full items-center rounded-md ${grossWeightError[supplierVO.orderSupplierId] ? "border-4 border-red-500" : "border-4 border-blue-300"}`} className={`flex h-10 w-full items-center rounded-md ${grossWeightError[supplierVO.orderSupplierId] ? "border-4 border-red-500" : "border-4 border-blue-300"}`}
> >
<Input <Input
clearable
placeholder="0" placeholder="0"
type="digit" type="digit"
value={supplierVO.grossWeight?.toString()} value={supplierVO.grossWeight?.toString()}

View File

@ -865,6 +865,7 @@ export default forwardRef<SupplierInfoRef, ISupplierInfoProps>(
> >
<Icon name="user" size={16} color="#999" className="mx-2" /> <Icon name="user" size={16} color="#999" className="mx-2" />
<Input <Input
clearable
type="text" type="text"
placeholder="请输入姓名" placeholder="请输入姓名"
value={supplierVO.name} value={supplierVO.name}
@ -891,6 +892,7 @@ export default forwardRef<SupplierInfoRef, ISupplierInfoProps>(
> >
<Icon name="id-card" size={16} color="#999" className="mx-2" /> <Icon name="id-card" size={16} color="#999" className="mx-2" />
<Input <Input
clearable
type="idcard" type="idcard"
placeholder="请输入身份证号" placeholder="请输入身份证号"
value={supplierVO.idCard} value={supplierVO.idCard}
@ -915,6 +917,7 @@ export default forwardRef<SupplierInfoRef, ISupplierInfoProps>(
> >
<Icon name="building" size={16} color="#999" className="mx-2" /> <Icon name="building" size={16} color="#999" className="mx-2" />
<Input <Input
clearable
type="text" type="text"
placeholder="请输入银行名称" placeholder="请输入银行名称"
value={supplierVO.bankName} value={supplierVO.bankName}
@ -946,6 +949,7 @@ export default forwardRef<SupplierInfoRef, ISupplierInfoProps>(
className="mx-2" className="mx-2"
/> />
<Input <Input
clearable
type="digit" type="digit"
placeholder="请输入银行卡号" placeholder="请输入银行卡号"
value={supplierVO.bankCard} value={supplierVO.bankCard}
@ -970,6 +974,7 @@ export default forwardRef<SupplierInfoRef, ISupplierInfoProps>(
> >
<Icon name="phone" size={16} color="#999" className="mx-2" /> <Icon name="phone" size={16} color="#999" className="mx-2" />
<Input <Input
clearable
type="tel" type="tel"
placeholder="请输入手机号码" placeholder="请输入手机号码"
value={supplierVO.phone} value={supplierVO.phone}

View File

@ -532,6 +532,7 @@ export default forwardRef<SupplierWeighRef, IWeightProps>(
className={`flex h-10 w-full items-center rounded-md ${selectedProduct === "其他(请注明)" && customProduct ? "border-primary border-4" : "border-4 border-gray-300"}`} className={`flex h-10 w-full items-center rounded-md ${selectedProduct === "其他(请注明)" && customProduct ? "border-primary border-4" : "border-4 border-gray-300"}`}
> >
<Input <Input
clearable
placeholder="请输入品种" placeholder="请输入品种"
type="text" type="text"
value={customProduct} value={customProduct}
@ -835,6 +836,7 @@ export default forwardRef<SupplierWeighRef, IWeightProps>(
className={`flex h-10 w-full items-center rounded-md ${depositError[supplierVO.orderSupplierId] ? "border-4 border-red-500" : "border-4 border-gray-300"}`} className={`flex h-10 w-full items-center rounded-md ${depositError[supplierVO.orderSupplierId] ? "border-4 border-red-500" : "border-4 border-gray-300"}`}
> >
<Input <Input
clearable
placeholder="0" placeholder="0"
type="digit" type="digit"
value={supplierVO.depositAmount?.toString()} value={supplierVO.depositAmount?.toString()}
@ -894,6 +896,7 @@ export default forwardRef<SupplierWeighRef, IWeightProps>(
className={`flex h-10 w-full items-center rounded-md ${priceError[supplierVO.orderSupplierId] ? "border-4 border-red-500" : "border-4 border-yellow-300"}`} className={`flex h-10 w-full items-center rounded-md ${priceError[supplierVO.orderSupplierId] ? "border-4 border-red-500" : "border-4 border-yellow-300"}`}
> >
<Input <Input
clearable
placeholder="0.00" placeholder="0.00"
type="digit" type="digit"
value={supplierVO.purchasePrice?.toString()} value={supplierVO.purchasePrice?.toString()}
@ -953,6 +956,7 @@ export default forwardRef<SupplierWeighRef, IWeightProps>(
className={`flex h-10 w-full items-center rounded-md ${emptyWeightError[supplierVO.orderSupplierId] ? "border-4 border-red-500" : "border-4 border-blue-300"}`} className={`flex h-10 w-full items-center rounded-md ${emptyWeightError[supplierVO.orderSupplierId] ? "border-4 border-red-500" : "border-4 border-blue-300"}`}
> >
<Input <Input
clearable
placeholder="0" placeholder="0"
type="digit" type="digit"
value={supplierVO.emptyWeight?.toString()} value={supplierVO.emptyWeight?.toString()}
@ -1012,6 +1016,7 @@ export default forwardRef<SupplierWeighRef, IWeightProps>(
className={`flex h-10 w-full items-center rounded-md ${totalWeightError[supplierVO.orderSupplierId] ? "border-4 border-red-500" : "border-4 border-green-300"}`} className={`flex h-10 w-full items-center rounded-md ${totalWeightError[supplierVO.orderSupplierId] ? "border-4 border-red-500" : "border-4 border-green-300"}`}
> >
<Input <Input
clearable
placeholder="0" placeholder="0"
type="digit" type="digit"
value={supplierVO.totalWeight?.toString()} value={supplierVO.totalWeight?.toString()}

View File

@ -271,6 +271,7 @@ export default function BasicInfoSection(props: {
} }
> >
<Input <Input
clearable
className={"placeholder:text-neutral-dark"} className={"placeholder:text-neutral-dark"}
placeholder={"请输入本车次号"} placeholder={"请输入本车次号"}
type={"text"} type={"text"}
@ -293,6 +294,7 @@ export default function BasicInfoSection(props: {
} }
> >
<Input <Input
clearable
className={"placeholder:text-neutral-dark"} className={"placeholder:text-neutral-dark"}
placeholder={"请输入发货地"} placeholder={"请输入发货地"}
type={"text"} type={"text"}
@ -315,6 +317,7 @@ export default function BasicInfoSection(props: {
} }
> >
<Input <Input
clearable
className={"placeholder:text-neutral-dark"} className={"placeholder:text-neutral-dark"}
placeholder={"请输入收货地"} placeholder={"请输入收货地"}
type={"text"} type={"text"}
@ -381,6 +384,7 @@ export default function BasicInfoSection(props: {
} }
> >
<Input <Input
clearable
className={"placeholder:text-neutral-dark"} className={"placeholder:text-neutral-dark"}
placeholder={"请输入车牌号"} placeholder={"请输入车牌号"}
type={"text"} type={"text"}
@ -403,6 +407,7 @@ export default function BasicInfoSection(props: {
} }
> >
<Input <Input
clearable
className={"placeholder:text-neutral-dark"} className={"placeholder:text-neutral-dark"}
placeholder={"请输入联系电话"} placeholder={"请输入联系电话"}
type={"text"} type={"text"}
@ -461,6 +466,7 @@ export default function BasicInfoSection(props: {
} }
> >
<Input <Input
clearable
className={"placeholder:text-neutral-dark"} className={"placeholder:text-neutral-dark"}
placeholder={"请输入运费"} placeholder={"请输入运费"}
type={"digit"} type={"digit"}
@ -522,6 +528,7 @@ export default function BasicInfoSection(props: {
} }
> >
<Input <Input
clearable
className={"placeholder:text-neutral-dark"} className={"placeholder:text-neutral-dark"}
placeholder={"请输入草帘费金额"} placeholder={"请输入草帘费金额"}
type={"digit"} type={"digit"}
@ -603,6 +610,7 @@ export default function BasicInfoSection(props: {
className={`flex h-10 flex-1 items-center rounded-md border-4 border-gray-300`} className={`flex h-10 flex-1 items-center rounded-md border-4 border-gray-300`}
> >
<Input <Input
clearable
placeholder="请输入车次号" placeholder="请输入车次号"
type="text" type="text"
value={orderVehicle?.vehicleNo || ""} value={orderVehicle?.vehicleNo || ""}

View File

@ -409,6 +409,7 @@ export default function EmptyBoxInfoSection(props: {
</View> </View>
<View className="border-neutral-base flex flex-row items-center rounded-md border border-solid"> <View className="border-neutral-base flex flex-row items-center rounded-md border border-solid">
<Input <Input
clearable
className="placeholder:text-neutral-dark" className="placeholder:text-neutral-dark"
placeholder="请输入销售单价" placeholder="请输入销售单价"
type="digit" type="digit"

View File

@ -164,6 +164,22 @@ export default function MarketPriceSection(props: {
</Text> </Text>
</View> </View>
)} )}
{supplier.type === "STALL" && (
<View className="flex items-center justify-between">
<Text className="text-sm text-gray-500"></Text>
<Text className="text-sm font-medium">
{supplier.pricingMethod === "BY_GROSS_WEIGHT"
? "毛重"
: "净重"}
</Text>
</View>
)}
<View className="flex items-center justify-between">
<Text className="text-sm text-gray-500"></Text>
<Text className="text-sm font-medium">
{supplier.invoiceAmount}
</Text>
</View>
<View className="flex items-center justify-between"> <View className="flex items-center justify-between">
<Text className="text-sm text-gray-500"></Text> <Text className="text-sm text-gray-500"></Text>
<Text className="text-sm font-medium"> <Text className="text-sm font-medium">

View File

@ -351,6 +351,7 @@ export default function PurchaseCostInfoSection(props: {
</View> </View>
<View className="border-neutral-base flex flex-row items-center rounded-md border border-solid"> <View className="border-neutral-base flex flex-row items-center rounded-md border border-solid">
<Input <Input
clearable
className="placeholder:text-neutral-dark" className="placeholder:text-neutral-dark"
placeholder="请输入采购单价" placeholder="请输入采购单价"
type="digit" type="digit"

View File

@ -191,6 +191,7 @@ export default function RebateCalcSection(props: {
</View> </View>
<View className="border-neutral-base flex flex-row items-center rounded-md border border-solid"> <View className="border-neutral-base flex flex-row items-center rounded-md border border-solid">
<Input <Input
clearable
className="placeholder:text-neutral-dark flex-1" className="placeholder:text-neutral-dark flex-1"
placeholder="请输入单价" placeholder="请输入单价"
type="digit" type="digit"
@ -223,6 +224,7 @@ export default function RebateCalcSection(props: {
<View className="border-neutral-base flex flex-row items-center rounded-md border border-solid"> <View className="border-neutral-base flex flex-row items-center rounded-md border border-solid">
<Input <Input
clearable
className="placeholder:text-neutral-dark flex-1" className="placeholder:text-neutral-dark flex-1"
placeholder="请输入返点金额" placeholder="请输入返点金额"
type="digit" type="digit"

View File

@ -785,6 +785,7 @@ export default hocAuth(function Page(props: CommonComponent) {
className={`flex h-10 flex-1 items-center rounded-md border-4 border-gray-300`} className={`flex h-10 flex-1 items-center rounded-md border-4 border-gray-300`}
> >
<Input <Input
clearable
type="text" type="text"
disabled={ disabled={
!( !(

View File

@ -96,6 +96,7 @@ export default base(function Page() {
/> />
</View> </View>
<Input <Input
clearable
type="text" type="text"
id="username" id="username"
name="username" name="username"
@ -128,6 +129,7 @@ export default base(function Page() {
/> />
</View> </View>
<Input <Input
clearable
style={{ style={{
// @ts-ignore // @ts-ignore
"--nutui-input-font-size": "var(--text-sm)", "--nutui-input-font-size": "var(--text-sm)",

View File

@ -470,6 +470,7 @@ export default hocAuth(function Page(props: CommonComponent) {
> >
<Icon name="user" size={16} color="#999" className="mx-2" /> <Icon name="user" size={16} color="#999" className="mx-2" />
<Input <Input
clearable
type="text" type="text"
placeholder="请输入档口名称" placeholder="请输入档口名称"
value={supplierVO.name} value={supplierVO.name}
@ -496,6 +497,7 @@ export default hocAuth(function Page(props: CommonComponent) {
> >
<Icon name="user" size={16} color="#999" className="mx-2" /> <Icon name="user" size={16} color="#999" className="mx-2" />
<Input <Input
clearable
type="text" type="text"
placeholder="请输入收款人姓名" placeholder="请输入收款人姓名"
value={supplierVO.payeeName} value={supplierVO.payeeName}
@ -517,6 +519,7 @@ export default hocAuth(function Page(props: CommonComponent) {
> >
<Icon name="building" size={16} color="#999" className="mx-2" /> <Icon name="building" size={16} color="#999" className="mx-2" />
<Input <Input
clearable
type="text" type="text"
placeholder="请输入银行名称" placeholder="请输入银行名称"
value={supplierVO.bankName} value={supplierVO.bankName}
@ -543,6 +546,7 @@ export default hocAuth(function Page(props: CommonComponent) {
className="mx-2" className="mx-2"
/> />
<Input <Input
clearable
type="digit" type="digit"
placeholder="请输入银行卡号" placeholder="请输入银行卡号"
value={supplierVO.bankCard} value={supplierVO.bankCard}
@ -564,6 +568,7 @@ export default hocAuth(function Page(props: CommonComponent) {
> >
<Icon name="phone" size={16} color="#999" className="mx-2" /> <Icon name="phone" size={16} color="#999" className="mx-2" />
<Input <Input
clearable
type="tel" type="tel"
placeholder="请输入手机号码" placeholder="请输入手机号码"
value={supplierVO.phone} value={supplierVO.phone}

View File

@ -504,6 +504,7 @@ export default hocAuth(function Page(props: CommonComponent) {
> >
<Icon name="user" size={16} color="#999" className="mx-2" /> <Icon name="user" size={16} color="#999" className="mx-2" />
<Input <Input
clearable
type="text" type="text"
placeholder="请输入姓名" placeholder="请输入姓名"
value={supplierVO.name} value={supplierVO.name}
@ -530,6 +531,7 @@ export default hocAuth(function Page(props: CommonComponent) {
> >
<Icon name="id-card" size={16} color="#999" className="mx-2" /> <Icon name="id-card" size={16} color="#999" className="mx-2" />
<Input <Input
clearable
type="idcard" type="idcard"
placeholder="请输入身份证号" placeholder="请输入身份证号"
value={supplierVO.idCard} value={supplierVO.idCard}
@ -551,6 +553,7 @@ export default hocAuth(function Page(props: CommonComponent) {
> >
<Icon name="building" size={16} color="#999" className="mx-2" /> <Icon name="building" size={16} color="#999" className="mx-2" />
<Input <Input
clearable
type="text" type="text"
placeholder="请输入银行名称" placeholder="请输入银行名称"
value={supplierVO.bankName} value={supplierVO.bankName}
@ -577,6 +580,7 @@ export default hocAuth(function Page(props: CommonComponent) {
className="mx-2" className="mx-2"
/> />
<Input <Input
clearable
type="digit" type="digit"
placeholder="请输入银行卡号" placeholder="请输入银行卡号"
value={supplierVO.bankCard} value={supplierVO.bankCard}
@ -598,6 +602,7 @@ export default hocAuth(function Page(props: CommonComponent) {
> >
<Icon name="phone" size={16} color="#999" className="mx-2" /> <Icon name="phone" size={16} color="#999" className="mx-2" />
<Input <Input
clearable
type="tel" type="tel"
placeholder="请输入手机号码" placeholder="请输入手机号码"
value={supplierVO.phone} value={supplierVO.phone}

View File

@ -100,7 +100,7 @@ declare namespace AuthAPI {
/** 用户ID */ /** 用户ID */
userId: string; userId: string;
/** 角色ID */ /** 角色ID */
roleIdList: number[]; roleIdList: string[];
/** 角色信息 */ /** 角色信息 */
userRoleList?: UserRoleVO[]; userRoleList?: UserRoleVO[];
}; };
@ -195,7 +195,7 @@ declare namespace AuthAPI {
type RoleMenuTreeQry = { type RoleMenuTreeQry = {
/** 角色权限 */ /** 角色权限 */
roleId?: number[]; roleId?: string[];
/** 平台ID */ /** 平台ID */
platformId: string; platformId: string;
}; };
@ -329,7 +329,7 @@ declare namespace AuthAPI {
/** 备注 */ /** 备注 */
remark?: string; remark?: string;
/** 客户标签 */ /** 客户标签 */
labelId?: number[]; labelId?: string[];
/** 用户ID */ /** 用户ID */
userId: string; userId: string;
}; };

View File

@ -208,7 +208,7 @@ declare namespace BusinessAPI {
/** 品牌图片URL */ /** 品牌图片URL */
image?: string; image?: string;
/** 纸箱规格ID */ /** 纸箱规格ID */
specIds?: number[]; specIds?: string[];
/** 备注 */ /** 备注 */
remark?: string; remark?: string;
/** 状态1_启用0_禁用 */ /** 状态1_启用0_禁用 */
@ -279,7 +279,7 @@ declare namespace BusinessAPI {
/** 品牌图片URL */ /** 品牌图片URL */
image?: string; image?: string;
/** 纸箱规格ID */ /** 纸箱规格ID */
specIds?: number[]; specIds?: string[];
/** 备注 */ /** 备注 */
remark?: string; remark?: string;
/** 状态1_启用0_禁用 */ /** 状态1_启用0_禁用 */
@ -296,7 +296,7 @@ declare namespace BusinessAPI {
/** 品牌图片URL */ /** 品牌图片URL */
image?: string; image?: string;
/** 纸箱规格ID */ /** 纸箱规格ID */
specIds?: number[]; specIds?: string[];
/** 备注 */ /** 备注 */
remark?: string; remark?: string;
/** 状态1_启用0_禁用 */ /** 状态1_启用0_禁用 */
@ -1021,7 +1021,7 @@ declare namespace BusinessAPI {
/** 状态1_启用0_禁用 */ /** 状态1_启用0_禁用 */
status: boolean; status: boolean;
/** 成本项ID */ /** 成本项ID */
costItemIds?: number[]; costItemIds?: string[];
}; };
type CostDestroyCmd = { type CostDestroyCmd = {
@ -1241,7 +1241,7 @@ declare namespace BusinessAPI {
/** 状态1_启用0_禁用 */ /** 状态1_启用0_禁用 */
status: boolean; status: boolean;
/** 成本项ID */ /** 成本项ID */
costItemIds?: number[]; costItemIds?: string[];
}; };
type CostVO = { type CostVO = {
@ -1272,7 +1272,7 @@ declare namespace BusinessAPI {
/** 状态1_启用0_禁用 */ /** 状态1_启用0_禁用 */
status: boolean; status: boolean;
/** 项目id集合 */ /** 项目id集合 */
costItemIds?: number[]; costItemIds?: string[];
/** 创建时间 */ /** 创建时间 */
createdAt?: string; createdAt?: string;
/** 项目列表 */ /** 项目列表 */
@ -1971,7 +1971,7 @@ declare namespace BusinessAPI {
/** 登录密码 */ /** 登录密码 */
password: string; password: string;
/** 角色ID */ /** 角色ID */
roleId: number[]; roleId: string[];
}; };
type EmployeeDestroyCmd = { type EmployeeDestroyCmd = {
@ -2064,7 +2064,7 @@ declare namespace BusinessAPI {
/** 用户ID */ /** 用户ID */
userId: string; userId: string;
/** 角色ID */ /** 角色ID */
roleIdList: number[]; roleIdList: string[];
/** 角色信息 */ /** 角色信息 */
userRoleList?: UserRoleVO[]; userRoleList?: UserRoleVO[];
}; };
@ -2485,7 +2485,7 @@ declare namespace BusinessAPI {
/** 平台id */ /** 平台id */
platformId: string; platformId: string;
/** 角色Id */ /** 角色Id */
roleId?: number[]; roleId?: string[];
/** 是否隐藏 */ /** 是否隐藏 */
hideInMenu?: boolean; hideInMenu?: boolean;
/** 权限Id */ /** 权限Id */
@ -2558,7 +2558,7 @@ declare namespace BusinessAPI {
/** 平台id */ /** 平台id */
platformId: string; platformId: string;
/** 角色Id */ /** 角色Id */
roleId?: number[]; roleId?: string[];
/** 是否隐藏 */ /** 是否隐藏 */
hideInMenu?: boolean; hideInMenu?: boolean;
/** 权限Id */ /** 权限Id */
@ -2945,7 +2945,7 @@ declare namespace BusinessAPI {
| "LOGISTICS_TYPE" | "LOGISTICS_TYPE"
| "EXPENSE_TYPE"; | "EXPENSE_TYPE";
/** 关联项目id */ /** 关联项目id */
costItemIds?: number[]; costItemIds?: string[];
/** 是否选中 */ /** 是否选中 */
selected: boolean; selected: boolean;
/** 是否已付款 */ /** 是否已付款 */
@ -2978,7 +2978,7 @@ declare namespace BusinessAPI {
| "LOGISTICS_TYPE" | "LOGISTICS_TYPE"
| "EXPENSE_TYPE"; | "EXPENSE_TYPE";
/** 关联项目id */ /** 关联项目id */
costItemIds?: number[]; costItemIds?: string[];
/** 是否付款 */ /** 是否付款 */
isPaid?: boolean; isPaid?: boolean;
}; };
@ -3073,7 +3073,7 @@ declare namespace BusinessAPI {
| "LOGISTICS_TYPE" | "LOGISTICS_TYPE"
| "EXPENSE_TYPE"; | "EXPENSE_TYPE";
/** 关联项目id */ /** 关联项目id */
costItemIds?: number[]; costItemIds?: string[];
/** 创建时间 */ /** 创建时间 */
createdAt: string; createdAt: string;
/** 采购订单状态: 0_草稿1_审核中2_已完成3_已关闭 */ /** 采购订单状态: 0_草稿1_审核中2_已完成3_已关闭 */
@ -3781,7 +3781,7 @@ declare namespace BusinessAPI {
/** 产品名称 */ /** 产品名称 */
productName?: string; productName?: string;
/** 关联费用id */ /** 关联费用id */
costIds?: number[]; costIds?: string[];
/** 成本模板 */ /** 成本模板 */
costTemplate?: string; costTemplate?: string;
/** 是否已付定金 */ /** 是否已付定金 */
@ -3804,7 +3804,7 @@ declare namespace BusinessAPI {
type OrderSupplierBatchInvoiceUploadCmd = { type OrderSupplierBatchInvoiceUploadCmd = {
/** 供应商ID列表 */ /** 供应商ID列表 */
orderSupplierIdList: number[]; orderSupplierIdList: string[];
/** 是否上传票证 */ /** 是否上传票证 */
invoiceUpload?: boolean; invoiceUpload?: boolean;
/** 发票照片 */ /** 发票照片 */
@ -4671,7 +4671,7 @@ declare namespace BusinessAPI {
/** 产品名称 */ /** 产品名称 */
name: string; name: string;
/** 关联成本费用id */ /** 关联成本费用id */
costIds?: number[]; costIds?: string[];
/** 成本模板 */ /** 成本模板 */
costTemplate?: string; costTemplate?: string;
/** 备注 */ /** 备注 */
@ -4738,7 +4738,7 @@ declare namespace BusinessAPI {
/** 产品名称 */ /** 产品名称 */
name: string; name: string;
/** 关联成本费用id */ /** 关联成本费用id */
costIds?: number[]; costIds?: string[];
/** 成本模板 */ /** 成本模板 */
costTemplate?: string; costTemplate?: string;
/** 备注 */ /** 备注 */
@ -4763,7 +4763,7 @@ declare namespace BusinessAPI {
/** 状态1_启用0_禁用 */ /** 状态1_启用0_禁用 */
status: boolean; status: boolean;
/** 成本ID集合 */ /** 成本ID集合 */
costIds?: number[]; costIds?: string[];
/** 成本费用 */ /** 成本费用 */
costVOList?: CostVO[]; costVOList?: CostVO[];
/** 成本模板 */ /** 成本模板 */
@ -4790,7 +4790,7 @@ declare namespace BusinessAPI {
/** 角色详情 */ /** 角色详情 */
description?: string; description?: string;
/** 角色id */ /** 角色id */
menuId: number[]; menuId: string[];
}; };
type RoleDestroyCmd = { type RoleDestroyCmd = {
@ -4812,7 +4812,7 @@ declare namespace BusinessAPI {
/** 角色编号 */ /** 角色编号 */
roleId?: string; roleId?: string;
/** 应用角色Id */ /** 应用角色Id */
roleIdList?: number[]; roleIdList?: string[];
/** 平台Id */ /** 平台Id */
platformId?: string; platformId?: string;
/** 平台Id */ /** 平台Id */
@ -4859,7 +4859,7 @@ declare namespace BusinessAPI {
/** 角色详情 */ /** 角色详情 */
description?: string; description?: string;
/** 角色id */ /** 角色id */
menuId: number[]; menuId: string[];
/** 角色ID */ /** 角色ID */
roleId: string; roleId: string;
}; };
@ -4880,9 +4880,9 @@ declare namespace BusinessAPI {
/** 平台 */ /** 平台 */
platformVO?: PlatformVO; platformVO?: PlatformVO;
/** 权限列表 */ /** 权限列表 */
permissionId: number[]; permissionId: string[];
/** 菜单列表 */ /** 菜单列表 */
menuId: number[]; menuId: string[];
/** 创建时间 */ /** 创建时间 */
createdAt: string; createdAt: string;
}; };
@ -5610,7 +5610,7 @@ declare namespace BusinessAPI {
/** 备注 */ /** 备注 */
remark?: string; remark?: string;
/** 客户标签 */ /** 客户标签 */
labelId?: number[]; labelId?: string[];
}; };
type UserDestroyCmd = { type UserDestroyCmd = {
@ -5632,7 +5632,7 @@ declare namespace BusinessAPI {
/** 状态1_启用0_禁用 */ /** 状态1_启用0_禁用 */
status?: boolean; status?: boolean;
/** 用户ID */ /** 用户ID */
userIdList?: number[]; userIdList?: string[];
/** 用户名 */ /** 用户名 */
name?: string; name?: string;
}; };
@ -5675,9 +5675,9 @@ declare namespace BusinessAPI {
/** 是否是管理员 */ /** 是否是管理员 */
isAdmin?: boolean; isAdmin?: boolean;
/** 会员id列表 */ /** 会员id列表 */
userIdList?: number[]; userIdList?: string[];
/** 排除的用户id列表 */ /** 排除的用户id列表 */
excludeUserIdList?: number[]; excludeUserIdList?: string[];
/** 小区id */ /** 小区id */
communityId?: number; communityId?: number;
offset?: number; offset?: number;
@ -5687,7 +5687,7 @@ declare namespace BusinessAPI {
/** 用户ID */ /** 用户ID */
userId: string; userId: string;
/** 角色ID */ /** 角色ID */
roleIdList?: number[]; roleIdList?: string[];
/** 是否覆盖 */ /** 是否覆盖 */
cover: boolean; cover: boolean;
}; };
@ -5732,7 +5732,7 @@ declare namespace BusinessAPI {
/** 备注 */ /** 备注 */
remark?: string; remark?: string;
/** 客户标签 */ /** 客户标签 */
labelId?: number[]; labelId?: string[];
/** 用户ID */ /** 用户ID */
userId: string; userId: string;
}; };

View File

@ -35,7 +35,10 @@ export class StallWeightCalculator {
/** /**
* *
*/ */
private calculateSupplierWeight(supplier: BusinessAPI.OrderSupplier, index: number): void { private calculateSupplierWeight(
supplier: BusinessAPI.OrderSupplier,
index: number,
): void {
const isFirstSupplier = index === 0; const isFirstSupplier = index === 0;
const isLastSupplier = supplier.isLast; const isLastSupplier = supplier.isLast;
@ -43,14 +46,21 @@ export class StallWeightCalculator {
this.setEmptyWeight(supplier, index); this.setEmptyWeight(supplier, index);
// 计算各类纸箱重量 // 计算各类纸箱重量
const weights = this.calculateAllBoxWeights(supplier.orderPackageList || []); const weights = this.calculateAllBoxWeights(
supplier.orderPackageList || [],
);
if (!supplier.isPaper) { if (!supplier.isPaper) {
// 非纸箱包装的简化计算 // 非纸箱包装的简化计算
this.calculateNonPaperSupplier(supplier, weights.used); this.calculateNonPaperSupplier(supplier, weights.used);
} else { } else {
// 纸箱包装的复杂计算 // 纸箱包装的复杂计算
this.calculatePaperSupplier(supplier, weights, isFirstSupplier, isLastSupplier); this.calculatePaperSupplier(
supplier,
weights,
isFirstSupplier,
isLastSupplier,
);
} }
// 计算发票金额 // 计算发票金额
@ -63,7 +73,10 @@ export class StallWeightCalculator {
/** /**
* *
*/ */
private setEmptyWeight(supplier: BusinessAPI.OrderSupplier, index: number): void { private setEmptyWeight(
supplier: BusinessAPI.OrderSupplier,
index: number,
): void {
if (index === 0) { if (index === 0) {
// 第一个农户保持原有空磅重量 // 第一个农户保持原有空磅重量
} else { } else {
@ -87,17 +100,23 @@ export class StallWeightCalculator {
/** /**
* *
*/ */
private calculateNonPaperSupplier(supplier: BusinessAPI.OrderSupplier, usedBoxesWeight: number): void { private calculateNonPaperSupplier(
supplier: BusinessAPI.OrderSupplier,
usedBoxesWeight: number,
): void {
// 毛重 = (总磅 - 空磅) × 2 // 毛重 = (总磅 - 空磅) × 2
supplier.grossWeight = DecimalUtils.multiply( supplier.grossWeight = DecimalUtils.multiply(
DecimalUtils.subtract(supplier.totalWeight || 0, supplier.emptyWeight || 0), DecimalUtils.subtract(
2 supplier.totalWeight || 0,
supplier.emptyWeight || 0,
),
2,
); );
// 净重 = 毛重 - 使用纸箱重量 // 净重 = 毛重 - 使用纸箱重量
supplier.netWeight = DecimalUtils.subtract( supplier.netWeight = DecimalUtils.subtract(
supplier.grossWeight || 0, supplier.grossWeight || 0,
usedBoxesWeight usedBoxesWeight,
); );
} }
@ -108,11 +127,17 @@ export class StallWeightCalculator {
supplier: BusinessAPI.OrderSupplier, supplier: BusinessAPI.OrderSupplier,
weights: { used: number; extra: number; remain: number; extraUsed: number }, weights: { used: number; extra: number; remain: number; extraUsed: number },
isFirstSupplier: boolean, isFirstSupplier: boolean,
isLastSupplier: boolean isLastSupplier: boolean,
): void { ): void {
const weightDiff = isFirstSupplier const weightDiff = isFirstSupplier
? DecimalUtils.subtract(supplier.totalWeight || 0, this.initialEmptyWeight) ? DecimalUtils.subtract(
: DecimalUtils.subtract(supplier.totalWeight || 0, this.previousTotalWeight); supplier.totalWeight || 0,
this.initialEmptyWeight,
)
: DecimalUtils.subtract(
supplier.totalWeight || 0,
this.previousTotalWeight,
);
const weightDiffInJin = DecimalUtils.multiply(weightDiff, 2); const weightDiffInJin = DecimalUtils.multiply(weightDiff, 2);
@ -121,37 +146,46 @@ export class StallWeightCalculator {
supplier.netWeight = DecimalUtils.add( supplier.netWeight = DecimalUtils.add(
DecimalUtils.subtract( DecimalUtils.subtract(
DecimalUtils.add(weightDiffInJin, weights.remain), DecimalUtils.add(weightDiffInJin, weights.remain),
weights.extraUsed weights.extraUsed,
) ),
); );
} else if (isLastSupplier) { } else if (isLastSupplier) {
// 最后一个农户 // 最后一个农户
supplier.netWeight = DecimalUtils.add( supplier.netWeight = DecimalUtils.add(
DecimalUtils.subtract( DecimalUtils.subtract(weightDiffInJin, weights.extraUsed),
weightDiffInJin, weights.remain,
weights.extraUsed
),
weights.remain
); );
} else { } else {
// 中间农户(包括第一个但不是最后一个) // 中间农户(包括第一个但不是最后一个)
supplier.netWeight = DecimalUtils.subtract(weightDiffInJin, weights.extra); supplier.netWeight = DecimalUtils.subtract(
weightDiffInJin,
weights.extra,
);
} }
// 毛重 = 净重 + 本次使用纸箱重量 // 毛重 = 净重 + 本次使用纸箱重量
supplier.grossWeight = DecimalUtils.add( supplier.grossWeight = DecimalUtils.add(
supplier.netWeight || 0, supplier.netWeight || 0,
weights.used weights.used,
); );
} }
/**
*
*/
private calculateQuoteWeight(supplier: BusinessAPI.OrderSupplier): number {
return supplier.pricingMethod === "BY_GROSS_WEIGHT"
? supplier.grossWeight
: supplier.netWeight;
}
/** /**
* *
*/ */
private calculateInvoiceAmount(supplier: BusinessAPI.OrderSupplier): void { private calculateInvoiceAmount(supplier: BusinessAPI.OrderSupplier): void {
supplier.invoiceAmount = DecimalUtils.multiply( supplier.invoiceAmount = DecimalUtils.multiply(
supplier.netWeight || 0, this.calculateQuoteWeight(supplier),
supplier.purchasePrice || 0 supplier.purchasePrice || 0,
); );
} }
@ -160,16 +194,16 @@ export class StallWeightCalculator {
*/ */
private calculateBoxWeightByType( private calculateBoxWeightByType(
packages: BusinessAPI.OrderPackage[], packages: BusinessAPI.OrderPackage[],
boxType?: string boxType?: string,
): number { ): number {
const filteredPackages = boxType const filteredPackages = boxType
? packages.filter(pkg => pkg.boxType === boxType) ? packages.filter((pkg) => pkg.boxType === boxType)
: packages; : packages;
return filteredPackages.reduce((total, pkg) => { return filteredPackages.reduce((total, pkg) => {
const weight = DecimalUtils.multiply( const weight = DecimalUtils.multiply(
pkg.boxCount || 0, pkg.boxCount || 0,
pkg.boxProductWeight || 0 pkg.boxProductWeight || 0,
); );
return DecimalUtils.add(total, weight); return DecimalUtils.add(total, weight);
}, 0); }, 0);
@ -186,7 +220,7 @@ export class StallWeightCalculator {
* *
*/ */
getSupplierNetWeight(supplierId: string | number): number { getSupplierNetWeight(supplierId: string | number): number {
const supplier = this.suppliers.find(s => s.supplierId === supplierId); const supplier = this.suppliers.find((s) => s.supplierId === supplierId);
return supplier?.netWeight || 0; return supplier?.netWeight || 0;
} }
@ -194,7 +228,7 @@ export class StallWeightCalculator {
* *
*/ */
getSupplierGrossWeight(supplierId: string | number): number { getSupplierGrossWeight(supplierId: string | number): number {
const supplier = this.suppliers.find(s => s.supplierId === supplierId); const supplier = this.suppliers.find((s) => s.supplierId === supplierId);
return supplier?.grossWeight || 0; return supplier?.grossWeight || 0;
} }
@ -245,7 +279,7 @@ export class StallWeightCalculator {
return { return {
isValid: errors.length === 0, isValid: errors.length === 0,
errors errors,
}; };
} }
} }