Commit d48e5574 authored by GuanHua's avatar GuanHua

fix: 进货单购买数量不在价格范围内时取值问题

parent e3a9a36e
...@@ -201,8 +201,8 @@ ...@@ -201,8 +201,8 @@
color: #FFF; color: #FFF;
height: 50px; height: 50px;
font-size: 16px; font-size: 16px;
background-color: #D32F2F; background-color: var(--mall_main_color);
border-color: #D32F2F; border-color: var(--mall_main_color);
border-radius: 0; border-radius: 0;
outline: none; outline: none;
cursor: pointer; cursor: pointer;
...@@ -264,4 +264,4 @@ ...@@ -264,4 +264,4 @@
} }
} }
} }
} }
\ No newline at end of file
...@@ -309,7 +309,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => { ...@@ -309,7 +309,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
} }
} }
if (isEmpty(priceItem)) { if (isEmpty(priceItem)) {
priceItem = getMaxCountRange(priceRange) priceItem = getMaxCountRange(priceRange, count)
} }
return parseFloat(priceItem.price) * count return parseFloat(priceItem.price) * count
} }
...@@ -663,7 +663,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => { ...@@ -663,7 +663,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
return Number(count) >= Number(item.min) && Number(count) <= Number(item.max) return Number(count) >= Number(item.min) && Number(count) <= Number(item.max)
}) })
if (isEmpty(temp)) { if (isEmpty(temp)) {
const maxItem = getMaxCountRange(detail.priceRange) const maxItem = getMaxCountRange(detail.priceRange, count)
unitPrice = maxItem.price unitPrice = maxItem.price
} else { } else {
unitPrice = temp[0]?.price unitPrice = temp[0]?.price
...@@ -673,14 +673,12 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => { ...@@ -673,14 +673,12 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
return unitPrice return unitPrice
} }
const getMaxCountRange = (priceRange) => { const getMaxCountRange = (priceRange, buyCount) => {
let maxItem: any = {} const priceList = [...priceRange]
for (const item of priceRange) {
if (Number(item.max) > Number(maxItem.max || 0)) { const result = priceList.sort((a, b) => (Number(b.max) < Number(buyCount) && Number(buyCount) < Number(a.min) ? 1 : -1))
maxItem = item // const result = priceList.sort((a, b) => Math.abs(Number(b.max) - Number(buyCount)) < Math.abs(Number(a.min) - Number(buyCount)) ? 1 : -1 )
} return result[0]
}
return maxItem
} }
const getDetailLink = (info) => { const getDetailLink = (info) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment