Merge branch 'couponV2.0' of codeup.aliyun.com:5f9118049cffa29cfdd3be1c/marketing/frontend into couponV2.0

This commit is contained in:
wangsongsole 2022-10-31 18:19:16 +08:00
commit d2262ea923
3 changed files with 40 additions and 9 deletions

View File

@ -217,6 +217,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
productType: 1,
checkedProduct: [],
KeyPcType: sessionStorage.getItem("KeyPcType"),
isLoadingBtn: false,
});
//
@ -602,6 +603,9 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
};
const onAuditSubmit = () => {
setState({
isLoadingBtn: true,
});
// 3 1
if (state.KeyPcType === "1") {
let param = {
@ -658,6 +662,9 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
console.log("编辑 大提交 =>", param);
editCoupon(editData.id, param).then((res) => {
setState({
isLoadingBtn: false,
});
handelResponse(
res,
(req, msg) => {
@ -714,6 +721,9 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
});
}
addCoupon(param).then((res) => {
setState({
isLoadingBtn: false,
});
handelResponse(
res,
(req, msg) => {
@ -1115,6 +1125,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
</Button>
<Button
type="primary"
loading={state.isLoadingBtn}
onClick={(e) => {
onAuditSubmit();
}}

View File

@ -10,6 +10,7 @@ import {
Sweetalert,
} from "zent";
import _ from "lodash";
import moment from "moment";
import TabPage from "@/components/tabPage/main.js";
import Ipt from "@/components/input/main";
import Grid from "@/components/gird/main.js";
@ -203,13 +204,19 @@ const UseCouponList = () => {
setState({ limit: data, isQuery: !state.isQuery });
};
const onChangeCombinedDate = (data) => {
setState({ combinedValue: data });
if (data[0]) {
let years = moment(data[1]).diff(moment(data[0]), "years");
if (years > 2) {
Notify.error("查询时间不能超过3年");
return;
} else {
setState({ combinedValue: data });
setState({
begin_time: data[0],
end_time: data[1],
isQuery: !state.isQuery,
});
}
} else {
setState({
combinedValue: data,

View File

@ -1,4 +1,19 @@
import { divNum } from "./number";
// 判断
const kgType = (item) => {
let type = sessionStorage.getItem("KeyPcType");
if (type === "2" || type === "3") {
return parseInt(divNum(item.all_budget, item.reduce_amount));
} else {
if (item.stock) {
return item.stock;
} else {
return parseInt(divNum(item.all_budget, item.reduce_amount));
}
}
};
// 立减金对象重构
export const knockGoldFun = (item) => {
let table_obj = {};
@ -11,9 +26,7 @@ export const knockGoldFun = (item) => {
table_obj.official_price = item.reduce_amount; // 官方价
table_obj.contract_price = item.price; // 合同价格
table_obj.quantity = item.total_stock; // 库存数量
table_obj.stock = item.stock
? item.stock
: divNum(item.all_budget, item.reduce_amount); // 剩余库存数量
table_obj.stock = kgType(item); // 剩余库存数量
table_obj.channel_activity_id = item.channel_activity_id; // 批次号
table_obj.all_budget = Number(item.all_budget); // 总预算
table_obj.effectDate = `${item.time_limit.effect_time.start_time}${item.time_limit.effect_time.end_time}`; // 有效时间段