fix: 修改优惠券库存校验
This commit is contained in:
parent
7436db391b
commit
04cda1102f
|
@ -11,7 +11,7 @@ import Form from "@/components/form/main"
|
||||||
import Grid from "@/components/gird/main.js"
|
import Grid from "@/components/gird/main.js"
|
||||||
import Ipt from "@/components/input/main"
|
import Ipt from "@/components/input/main"
|
||||||
import { knockGoldFun, submitIsKm } from "@/tools/index"
|
import { knockGoldFun, submitIsKm } from "@/tools/index"
|
||||||
import { mulNum } from "@/tools/number"
|
import { mulNum, divNum } from "@/tools/number"
|
||||||
import { isAmount } from "@/tools/validate"
|
import { isAmount } from "@/tools/validate"
|
||||||
import { useSetState } from "ahooks"
|
import { useSetState } from "ahooks"
|
||||||
import { isSameDay } from "date-fns"
|
import { isSameDay } from "date-fns"
|
||||||
|
@ -31,6 +31,7 @@ import {
|
||||||
Sweetalert
|
Sweetalert
|
||||||
} from "zent"
|
} from "zent"
|
||||||
import UseGoodsScopePop from "../UseGoodsScopePop/index"
|
import UseGoodsScopePop from "../UseGoodsScopePop/index"
|
||||||
|
|
||||||
import "./style.less"
|
import "./style.less"
|
||||||
|
|
||||||
const initArray = (targetNum) => {
|
const initArray = (targetNum) => {
|
||||||
|
@ -498,13 +499,21 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
||||||
// 所选商品库存和总发行数校验 -- 总库存(不是消耗库存)
|
// 所选商品库存和总发行数校验 -- 总库存(不是消耗库存)
|
||||||
let sum = 0
|
let sum = 0
|
||||||
arr.map((item) => {
|
arr.map((item) => {
|
||||||
// sum += parseInt(item.quantity)
|
// 1.判断 如何是商品直接 返回库存
|
||||||
sum += item.all_budget
|
if (item.type === 1) {
|
||||||
|
sum += parseInt(item.quantity)
|
||||||
|
} else {
|
||||||
|
// 2.计算库存
|
||||||
|
sum += parseInt(
|
||||||
|
divNum(item.only.all_budget, mulNum(item.only.reduce_amount, item.only.send_num))
|
||||||
|
)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
if (sum < Number(form_rule_data.quantity)) {
|
if (sum < Number(form_rule_data.quantity)) {
|
||||||
Notify.error("所选商品库存总数小于发放量")
|
Notify.error("所选商品库存总数小于发放量")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// 第三步:判断提交类型 新建还是计划的新建
|
// 第三步:判断提交类型 新建还是计划的新建
|
||||||
if (couponType === 1) {
|
if (couponType === 1) {
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -175,7 +175,6 @@ const UseProductPop = forwardRef((props, ref) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// 编辑
|
// 编辑
|
||||||
if (productData) {
|
if (productData) {
|
||||||
debugger
|
|
||||||
setModel({
|
setModel({
|
||||||
goods_id: productData.goods_id,
|
goods_id: productData.goods_id,
|
||||||
cost_price: productData.cost_price,
|
cost_price: productData.cost_price,
|
||||||
|
|
Loading…
Reference in New Issue