1) 增加新建优惠券table
This commit is contained in:
parent
8cb1e3670c
commit
30dd092399
|
@ -6,7 +6,6 @@ import React, {
|
||||||
} from "react";
|
} from "react";
|
||||||
import { useSetState } from "ahooks";
|
import { useSetState } from "ahooks";
|
||||||
import { FixedSizeList } from "react-window";
|
import { FixedSizeList } from "react-window";
|
||||||
import { isAmount } from "@/tools/validate";
|
|
||||||
import { Card, DateRangePicker, Button, Select, Notify } from "zent";
|
import { Card, DateRangePicker, Button, Select, Notify } from "zent";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
|
|
||||||
|
@ -14,11 +13,12 @@ import Ipt from "@/components/input/main";
|
||||||
import Form from "@/components/form/main";
|
import Form from "@/components/form/main";
|
||||||
import FormItem from "@/components/form-item/main";
|
import FormItem from "@/components/form-item/main";
|
||||||
import Grid from "@/components/gird/main.js";
|
import Grid from "@/components/gird/main.js";
|
||||||
|
|
||||||
import UseGoodsScopePop from "../UseGoodsScopePop/index";
|
import UseGoodsScopePop from "../UseGoodsScopePop/index";
|
||||||
|
|
||||||
import { getProductInfoSelect, handelResponse } from "@/assets/api.js";
|
import { isAmount } from "@/tools/validate";
|
||||||
|
|
||||||
|
import { getProductInfoSelect, handelResponse } from "@/assets/api.js";
|
||||||
|
import { mulNum } from "@/tools/number";
|
||||||
import "./style.less";
|
import "./style.less";
|
||||||
|
|
||||||
const tableColumn = [
|
const tableColumn = [
|
||||||
|
@ -186,6 +186,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
||||||
showScopePop: false,
|
showScopePop: false,
|
||||||
scopePopType: "",
|
scopePopType: "",
|
||||||
productData: [],
|
productData: [],
|
||||||
|
selectGoodsScopeData: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
// 基础信息
|
// 基础信息
|
||||||
|
@ -225,19 +226,22 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
||||||
const submit = () => {
|
const submit = () => {
|
||||||
// 基础信息
|
// 基础信息
|
||||||
let el_setup1 = form_info_el.current.validator();
|
let el_setup1 = form_info_el.current.validator();
|
||||||
console.log("el_setup1 =>", el_setup1);
|
// console.log("el_setup1 =>", el_setup1);
|
||||||
console.log("form_info_data =>", form_info_data);
|
// console.log("form_info_data =>", form_info_data);
|
||||||
|
|
||||||
// 发放规则
|
// 发放规则
|
||||||
let el_setup2 = form_rule_el.current.validator();
|
let el_setup2 = form_rule_el.current.validator();
|
||||||
console.log("el_setup2 =>", el_setup2);
|
// console.log("el_setup2 =>", el_setup2);
|
||||||
console.log("form_rule_data =>", form_rule_data);
|
// console.log("发放规则 =>", form_rule_data);
|
||||||
|
|
||||||
// 商品范围
|
// 商品范围
|
||||||
|
console.log("用户商品范围 =>", state.selectGoodsScopeData);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onReturn = () => {};
|
const onReturn = () => {};
|
||||||
const onChangeCombinedDate = () => {};
|
const onChangeCombinedDate = (e) => {
|
||||||
|
setForm_info_data({ date_time: e });
|
||||||
|
};
|
||||||
const onDisabledRange = (date, type) => {
|
const onDisabledRange = (date, type) => {
|
||||||
let disabled = false;
|
let disabled = false;
|
||||||
if (type === "end") {
|
if (type === "end") {
|
||||||
|
@ -250,7 +254,9 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
||||||
};
|
};
|
||||||
const onPageChange = () => {};
|
const onPageChange = () => {};
|
||||||
const onCountChange = () => {};
|
const onCountChange = () => {};
|
||||||
const selectionFun = () => {};
|
const selectionFun = (e) => {
|
||||||
|
setState({ selectGoodsScopeData: e });
|
||||||
|
};
|
||||||
const onRankChange = () => {};
|
const onRankChange = () => {};
|
||||||
const addProduct = (type) => {
|
const addProduct = (type) => {
|
||||||
// 第一步:获取直连天下的商品数据需要分销商 id
|
// 第一步:获取直连天下的商品数据需要分销商 id
|
||||||
|
@ -329,7 +335,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
||||||
// 计算总预算
|
// 计算总预算
|
||||||
const setQuantity = () => {
|
const setQuantity = () => {
|
||||||
if (isAmount(form_rule_data.reduce) && isAmount(form_rule_data.restrict)) {
|
if (isAmount(form_rule_data.reduce) && isAmount(form_rule_data.restrict)) {
|
||||||
let num = Math.mulNum(
|
let num = mulNum(
|
||||||
Number(form_rule_data.reduce),
|
Number(form_rule_data.reduce),
|
||||||
Number(form_rule_data.restrict)
|
Number(form_rule_data.restrict)
|
||||||
);
|
);
|
||||||
|
@ -352,7 +358,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
||||||
|
|
||||||
// 优惠券弹窗 提交
|
// 优惠券弹窗 提交
|
||||||
const scopePopSubmit = (data) => {
|
const scopePopSubmit = (data) => {
|
||||||
console.log("data =>", data);
|
console.log("scopePopSubmit =>", data);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -20,9 +20,10 @@ const UseGoodsScopePop = forwardRef((props, ref) => {
|
||||||
|
|
||||||
// 提交数据
|
// 提交数据
|
||||||
const submitPop = async () => {
|
const submitPop = async () => {
|
||||||
let data = null;
|
let scope_table_data = [];
|
||||||
let temp = null;
|
let temp = null;
|
||||||
let concatData = [];
|
let concatData = [];
|
||||||
|
|
||||||
// 第一步:判断是立减金还是新建商品
|
// 第一步:判断是立减金还是新建商品
|
||||||
let visible = false;
|
let visible = false;
|
||||||
if (type === "addProduct") {
|
if (type === "addProduct") {
|
||||||
|
@ -30,13 +31,16 @@ const UseGoodsScopePop = forwardRef((props, ref) => {
|
||||||
} else {
|
} else {
|
||||||
visible = await knockGold_el.current.submit();
|
visible = await knockGold_el.current.submit();
|
||||||
}
|
}
|
||||||
console.log("visible =>", visible);
|
|
||||||
if (visible) {
|
try {
|
||||||
if (type === "addProduct") {
|
if (visible) {
|
||||||
data = sessionStorage.getItem("productData");
|
if (type === "addProduct") {
|
||||||
console.log("商品data =>", JSON.parse(data));
|
scope_table_data = sessionStorage.getItem("productData");
|
||||||
|
}
|
||||||
|
submit(JSON.parse(scope_table_data));
|
||||||
}
|
}
|
||||||
submit(1);
|
} catch (err) {
|
||||||
|
console.log("err =>", err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,20 +4,20 @@
|
||||||
* @param {Number} b
|
* @param {Number} b
|
||||||
* @example Math.addNum(0.3 , 0.6) // => 0.9
|
* @example Math.addNum(0.3 , 0.6) // => 0.9
|
||||||
*/
|
*/
|
||||||
const addNum = (a, b) => {
|
export const addNum = (a, b) => {
|
||||||
var c, d, e
|
var c, d, e;
|
||||||
try {
|
try {
|
||||||
c = a.toString().split('.')[1].length
|
c = a.toString().split(".")[1].length;
|
||||||
} catch (f) {
|
} catch (f) {
|
||||||
c = 0
|
c = 0;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
d = b.toString().split('.')[1].length
|
d = b.toString().split(".")[1].length;
|
||||||
} catch (f) {
|
} catch (f) {
|
||||||
d = 0
|
d = 0;
|
||||||
}
|
}
|
||||||
return (e = Math.pow(10, Math.max(c, d))), (mulNum(a, e) + mulNum(b, e)) / e
|
return (e = Math.pow(10, Math.max(c, d))), (mulNum(a, e) + mulNum(b, e)) / e;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 减法运算
|
* 减法运算
|
||||||
|
@ -25,20 +25,20 @@ const addNum = (a, b) => {
|
||||||
* @param {Number} b
|
* @param {Number} b
|
||||||
* @example Math.subNum(0.3 , 0.2) // => 0.1
|
* @example Math.subNum(0.3 , 0.2) // => 0.1
|
||||||
*/
|
*/
|
||||||
const subNum = (a, b) => {
|
export const subNum = (a, b) => {
|
||||||
var c, d, e
|
var c, d, e;
|
||||||
try {
|
try {
|
||||||
c = a.toString().split('.')[1].length
|
c = a.toString().split(".")[1].length;
|
||||||
} catch (f) {
|
} catch (f) {
|
||||||
c = 0
|
c = 0;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
d = b.toString().split('.')[1].length
|
d = b.toString().split(".")[1].length;
|
||||||
} catch (f) {
|
} catch (f) {
|
||||||
d = 0
|
d = 0;
|
||||||
}
|
}
|
||||||
return (e = Math.pow(10, Math.max(c, d))), (mulNum(a, e) - mulNum(b, e)) / e
|
return (e = Math.pow(10, Math.max(c, d))), (mulNum(a, e) - mulNum(b, e)) / e;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 乘法运算
|
* 乘法运算
|
||||||
|
@ -46,18 +46,20 @@ const subNum = (a, b) => {
|
||||||
* @param {Number} b
|
* @param {Number} b
|
||||||
* @example Math.mulNum(0.3 , 1.5) // => 0.45
|
* @example Math.mulNum(0.3 , 1.5) // => 0.45
|
||||||
*/
|
*/
|
||||||
const mulNum = (a, b) => {
|
export const mulNum = (a, b) => {
|
||||||
var c = 0,
|
var c = 0,
|
||||||
d = a.toString(),
|
d = a.toString(),
|
||||||
e = b.toString()
|
e = b.toString();
|
||||||
try {
|
try {
|
||||||
c += d.split('.')[1].length
|
c += d.split(".")[1].length;
|
||||||
} catch (f) {}
|
} catch (f) {}
|
||||||
try {
|
try {
|
||||||
c += e.split('.')[1].length
|
c += e.split(".")[1].length;
|
||||||
} catch (f) {}
|
} catch (f) {}
|
||||||
return (Number(d.replace('.', '')) * Number(e.replace('.', ''))) / Math.pow(10, c)
|
return (
|
||||||
}
|
(Number(d.replace(".", "")) * Number(e.replace(".", ""))) / Math.pow(10, c)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 除法运算
|
* 除法运算
|
||||||
|
@ -65,24 +67,20 @@ const mulNum = (a, b) => {
|
||||||
* @param {Number} b
|
* @param {Number} b
|
||||||
* @example Math.divNum(0.3 , 0.1) // => 3
|
* @example Math.divNum(0.3 , 0.1) // => 3
|
||||||
*/
|
*/
|
||||||
const divNum = (a, b) => {
|
export const divNum = (a, b) => {
|
||||||
var c,
|
var c,
|
||||||
d,
|
d,
|
||||||
e = 0,
|
e = 0,
|
||||||
f = 0
|
f = 0;
|
||||||
try {
|
try {
|
||||||
e = a.toString().split('.')[1].length
|
e = a.toString().split(".")[1].length;
|
||||||
} catch (g) {}
|
} catch (g) {}
|
||||||
try {
|
try {
|
||||||
f = b.toString().split('.')[1].length
|
f = b.toString().split(".")[1].length;
|
||||||
} catch (g) {}
|
} catch (g) {}
|
||||||
return (
|
return (
|
||||||
(c = Number(a.toString().replace('.', ''))),
|
(c = Number(a.toString().replace(".", ""))),
|
||||||
(d = Number(b.toString().replace('.', ''))),
|
(d = Number(b.toString().replace(".", ""))),
|
||||||
mulNum(c / d, Math.pow(10, f - e))
|
mulNum(c / d, Math.pow(10, f - e))
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
Math.divNum = divNum
|
|
||||||
Math.addNum = addNum
|
|
||||||
Math.subNum = subNum
|
|
||||||
Math.mulNum = mulNum
|
|
||||||
|
|
Loading…
Reference in New Issue