Merge branch 'couponV1.5' of https://codeup.aliyun.com/5f9118049cffa29cfdd3be1c/marketing/frontend into couponV1.5
* 'couponV1.5' of https://codeup.aliyun.com/5f9118049cffa29cfdd3be1c/marketing/frontend: 1) 优惠计划优惠券 1) 增加优惠券
This commit is contained in:
commit
b78af56fb7
File diff suppressed because it is too large
Load Diff
|
@ -228,7 +228,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
plan_id: "",
|
||||
key_batch_id: "",
|
||||
title: "",
|
||||
date_time: "",
|
||||
date_time: JSON.parse(sessionStorage.getItem("datetime")),
|
||||
});
|
||||
const form_info_el = useRef(null);
|
||||
|
||||
|
@ -600,7 +600,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
scopePopType: "addKnockGold",
|
||||
});
|
||||
}
|
||||
|
||||
// 第四步:获取商品数据
|
||||
let param = {
|
||||
reseller_id: direct_reseller_ids,
|
||||
|
@ -1146,6 +1145,8 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
{state.examinePopShow ? examinePop() : null}
|
||||
|
||||
<UseGoodsScopePop
|
||||
full={form_rule_data.full}
|
||||
reduce={form_rule_data.reduce}
|
||||
product_title={state.product_title}
|
||||
drawerVisible={state.showScopePop}
|
||||
type={state.scopePopType}
|
||||
|
|
|
@ -6,6 +6,7 @@ import React, {
|
|||
} from "react";
|
||||
import { useSetState } from "ahooks";
|
||||
import { FixedSizeList } from "react-window";
|
||||
import { useHistory } from "react-router-dom";
|
||||
import {
|
||||
Card,
|
||||
DateRangePicker,
|
||||
|
@ -16,26 +17,26 @@ import {
|
|||
Icon,
|
||||
RadioGroup,
|
||||
Radio,
|
||||
Sweetalert,
|
||||
} from "zent";
|
||||
import moment from "moment";
|
||||
import _ from "lodash";
|
||||
import { isAmount } from "@/tools/validate";
|
||||
import { mulNum } from "@/tools/number";
|
||||
import {
|
||||
getProductInfoSelect,
|
||||
handelResponse,
|
||||
queryKeyBatch,
|
||||
addCoupon,
|
||||
queryPlans,
|
||||
} from "@/assets/api.js";
|
||||
|
||||
import Ipt from "@/components/input/main";
|
||||
import Form from "@/components/form/main";
|
||||
import FormItem from "@/components/form-item/main";
|
||||
import Grid from "@/components/gird/main.js";
|
||||
import UseGoodsScopePop from "../UseGoodsScopePop/index";
|
||||
import { isAmount } from "@/tools/validate";
|
||||
|
||||
import {
|
||||
getProductInfoSelect,
|
||||
handelResponse,
|
||||
queryPlans,
|
||||
queryKeyBatch,
|
||||
addCoupon,
|
||||
getCouponDetails,
|
||||
} from "@/assets/api.js";
|
||||
import { mulNum } from "@/tools/number";
|
||||
import "./style.less";
|
||||
|
||||
const tableColumn = [
|
||||
|
@ -160,24 +161,8 @@ const rule_rules = {
|
|||
};
|
||||
|
||||
const UseCouponAddEdit = forwardRef((props, ref) => {
|
||||
const {
|
||||
type = 0,
|
||||
isAuditButton = true,
|
||||
direct_reseller_id,
|
||||
editData,
|
||||
} = props; // type 入口类型 0优惠券新增 1计划、key批次 (是否显示两个字段)
|
||||
|
||||
// useEffect(() => {
|
||||
// if (type === 0) {
|
||||
// delete info_rules.plan_id;
|
||||
// delete info_rules.key_batch_id;
|
||||
// } else {
|
||||
// info_rules.plan_id = [{ type: "required", message: "请选择归属计划" }];
|
||||
// info_rules.key_batch_id = [
|
||||
// { type: "required", message: "请选择归属key" },
|
||||
// ];
|
||||
// }
|
||||
// }, []);
|
||||
// 注意 !!!!!!!!couponType 入口类型 0优惠券新增(显示) 1计划、key批次 (是否显示归属计划和归宿key两个字段)!!!!
|
||||
const { couponType = 0, direct_reseller_id, editData } = props;
|
||||
|
||||
const [state, setState] = useSetState({
|
||||
setup1_title: "基本信息",
|
||||
|
@ -213,16 +198,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
editModel: {}, // 编辑数据
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
(async function init() {
|
||||
// 如果是计划进入不执行以下数据
|
||||
if (type === 0) {
|
||||
await getPlanList(); // 获取计划
|
||||
await initEditAndCopy(); // 获取详情
|
||||
}
|
||||
})();
|
||||
}, []);
|
||||
|
||||
// 基础信息
|
||||
const [form_info_data, setForm_info_data] = useSetState({
|
||||
plan_id: "",
|
||||
|
@ -242,9 +217,30 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
});
|
||||
const form_rule_el = useRef(null);
|
||||
|
||||
// 编辑
|
||||
// 编辑/新增/复制
|
||||
useEffect(() => {
|
||||
if (editData !== "" && editData) {
|
||||
(async function init() {
|
||||
// 第一步:1.判断组件是否是 优惠券管理 couponType
|
||||
if (couponType === 0) {
|
||||
sessionStorage.setItem("keyType", 2);
|
||||
// 1.1 获取归属计划下拉框数据
|
||||
await getPlanList(); // 获取归属计划
|
||||
// 1.2 优惠券管理判断是新增还是编辑
|
||||
if (editData && editData !== "") {
|
||||
editFun();
|
||||
}
|
||||
} else {
|
||||
// 1.3 计划的优惠券编辑
|
||||
if (editData && editData !== "") {
|
||||
editFun();
|
||||
}
|
||||
}
|
||||
})();
|
||||
}, []);
|
||||
|
||||
// 编辑处理函数
|
||||
const editFun = () => {
|
||||
try {
|
||||
// 基本信息
|
||||
setForm_info_data({
|
||||
title: editData.title,
|
||||
|
@ -290,7 +286,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
});
|
||||
|
||||
let scope_data = goods_arr.concat(lj_arr);
|
||||
|
||||
scope_data = _.map(scope_data, (o) => {
|
||||
o.checked = true;
|
||||
return o;
|
||||
|
@ -308,8 +303,39 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
rank: arr,
|
||||
tableData: scope_data,
|
||||
});
|
||||
} catch (err) {}
|
||||
};
|
||||
// 新增处理函数
|
||||
const AddFun = () => {};
|
||||
// 复制处理函数
|
||||
const copyFun = () => {};
|
||||
|
||||
const getPlanList = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
queryPlans({ status: "3,4,5" }).then((res) => {
|
||||
handelResponse(res, (req, msg) => {
|
||||
let arr = req.map((item) => {
|
||||
return {
|
||||
key: {
|
||||
key: item.id,
|
||||
reseller_id: item.reseller_id,
|
||||
dateTime: [item.begin_time, item.end_time],
|
||||
},
|
||||
text: item.title,
|
||||
};
|
||||
});
|
||||
setState({
|
||||
plan_OPTIONS: arr,
|
||||
});
|
||||
resolve(true);
|
||||
});
|
||||
});
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
}, []);
|
||||
});
|
||||
};
|
||||
|
||||
// 设置发放总量是否可用
|
||||
useEffect(() => {
|
||||
|
@ -328,57 +354,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
getModel: getModel,
|
||||
}));
|
||||
|
||||
// 获取 计划
|
||||
const getPlanList = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
queryPlans({ status: "3,4,5" }).then((res) => {
|
||||
handelResponse(res, (req, msg) => {
|
||||
let arr = req.map((item) => {
|
||||
return {
|
||||
key: { key: item.id, reseller_id: item.reseller_id },
|
||||
text: item.title,
|
||||
};
|
||||
});
|
||||
setState({
|
||||
plan_OPTIONS: arr,
|
||||
});
|
||||
resolve(true);
|
||||
});
|
||||
});
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
};
|
||||
// 编辑-复制流程
|
||||
const initEditAndCopy = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
const isState = sessionStorage.getItem("isState"); /*复制1 编辑2 */
|
||||
const coupon_batch_id =
|
||||
sessionStorage.getItem("code_id"); /* 兑换码id */
|
||||
setState({
|
||||
isState: isState ? isState : "",
|
||||
coupon_batch_id: coupon_batch_id ? coupon_batch_id : "",
|
||||
});
|
||||
if (coupon_batch_id !== "undefined" && coupon_batch_id !== undefined) {
|
||||
getCouponDetails(coupon_batch_id).then((res) => {
|
||||
handelResponse(res, (req, msg) => {
|
||||
console.log("优惠券详情 =>", req);
|
||||
setState({ editModel: req });
|
||||
resolve(true);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
resolve(true);
|
||||
}
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 表单提交
|
||||
const submit = () => {
|
||||
let validator = false;
|
||||
|
@ -416,7 +391,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
return false;
|
||||
}
|
||||
// 第三步:判断提交类型 新建还是计划的新建
|
||||
if (type === 1) {
|
||||
if (couponType === 1) {
|
||||
return true;
|
||||
} else {
|
||||
setState({
|
||||
|
@ -487,6 +462,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
...item.only,
|
||||
};
|
||||
});
|
||||
console.log("param 优惠券新增 大提交 =>", param);
|
||||
addCoupon(param).then((res) => {
|
||||
handelResponse(
|
||||
res,
|
||||
|
@ -505,13 +481,15 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
|
||||
// 计划select改变
|
||||
const changePlan = (e) => {
|
||||
setForm_info_data({ plan_id: e });
|
||||
setForm_info_data({
|
||||
plan_id: e,
|
||||
key_batch_id: "",
|
||||
date_time: e.key.dateTime,
|
||||
});
|
||||
setState({ direct_reseller_id: e.key.reseller_id });
|
||||
setForm_info_data({ key_batch_id: "" });
|
||||
queryKeyBatch({ status: "4,5", plan_id: e.key.key, bind_object: 2 }).then(
|
||||
(res) => {
|
||||
handelResponse(res, (req, msg) => {
|
||||
console.log("req =>", req);
|
||||
let arr = req.map((item) => {
|
||||
return {
|
||||
key: item.id,
|
||||
|
@ -526,7 +504,20 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
);
|
||||
};
|
||||
|
||||
const onReturn = () => {};
|
||||
const onReturn = () => {
|
||||
Sweetalert.confirm({
|
||||
type: "warning",
|
||||
closeBtn: true,
|
||||
title: "确认操作",
|
||||
content: <p> 是否返回?</p>,
|
||||
onConfirm: () => {
|
||||
window.history.back();
|
||||
},
|
||||
onCancel: this.onCancel,
|
||||
className: "questModal",
|
||||
parentComponent: this,
|
||||
});
|
||||
};
|
||||
const onChangeCombinedDate = (e) => {
|
||||
setForm_info_data({ date_time: e });
|
||||
// 传入时间
|
||||
|
@ -868,7 +859,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
<div className="coupon-box">
|
||||
<Card style={{ margin: "10px auto" }} title={state.setup1_title}>
|
||||
<Form model={form_info_data} rules={info_rules} ref={form_info_el}>
|
||||
{type === 0 ? (
|
||||
{couponType === 0 ? (
|
||||
<FormItem labelname="归属计划" prop="plan_id">
|
||||
<Select
|
||||
clearable
|
||||
|
@ -878,13 +869,12 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
value={form_info_data.plan_id}
|
||||
onChange={(e) => {
|
||||
changePlan(e);
|
||||
// setForm_info_data({ plan_id: e });
|
||||
}}
|
||||
/>
|
||||
</FormItem>
|
||||
) : null}
|
||||
|
||||
{type === 0 ? (
|
||||
{couponType === 0 ? (
|
||||
<FormItem labelname="归属key" prop="key_batch_id">
|
||||
<Select
|
||||
clearable
|
||||
|
@ -1131,7 +1121,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
</BlockLoading>
|
||||
</Card>
|
||||
|
||||
{isAuditButton ? (
|
||||
{couponType === 0 ? (
|
||||
<div className="step-btn-group">
|
||||
<Button type="primary" onClick={() => submit()}>
|
||||
提交审核
|
||||
|
|
|
@ -1,12 +1,56 @@
|
|||
import React from "react";
|
||||
import "./style.less";
|
||||
import React, { useEffect, useRef } from "react";
|
||||
import { useSetState } from "ahooks";
|
||||
import { handelResponse, getCouponDetails } from "@/assets/api.js";
|
||||
|
||||
import UseCouponAddEdit from "@/components/UseCouponAddEdit";
|
||||
|
||||
import "./style.less";
|
||||
|
||||
const CouponAddEdit = () => {
|
||||
const addEditCouponEl = useRef(null);
|
||||
const [state, setState] = useSetState({
|
||||
isShow: false,
|
||||
editModel: "",
|
||||
direct_reseller_id: 0,
|
||||
comType: 0, // 优惠券组件类型 0新增 1编辑 2复制
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const coupon_batch_id = sessionStorage.getItem("code_id"); /* 兑换码id */
|
||||
// 编辑
|
||||
if (
|
||||
coupon_batch_id &&
|
||||
coupon_batch_id !== "undefined" &&
|
||||
coupon_batch_id !== undefined
|
||||
) {
|
||||
getCouponDetails(coupon_batch_id).then((res) => {
|
||||
handelResponse(res, (req, msg) => {
|
||||
console.log("优惠券详情 =>", req);
|
||||
setState({ editModel: req, isShow: true });
|
||||
});
|
||||
});
|
||||
} else {
|
||||
setState({ isShow: true });
|
||||
}
|
||||
}, []);
|
||||
|
||||
// 获取 计划
|
||||
const getPlanList = () => {};
|
||||
|
||||
// 编辑-复制流程
|
||||
const initEditAndCopy = () => {};
|
||||
|
||||
return (
|
||||
<div className="coupon-add-edit">
|
||||
<UseCouponAddEdit type={0}></UseCouponAddEdit>
|
||||
{state.isShow ? (
|
||||
<UseCouponAddEdit
|
||||
couponType={0}
|
||||
editData={state.editModel}
|
||||
isAuditButton={false}
|
||||
ref={addEditCouponEl}
|
||||
direct_reseller_id={state.direct_reseller_id}
|
||||
></UseCouponAddEdit>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -274,7 +274,7 @@ const UseCouponList = () => {
|
|||
sessionStorage.setItem("keyBatch_id", param.key_batch_id);
|
||||
} else if (type === 2) {
|
||||
activerou[0].pagetitle = "编辑";
|
||||
activerou[0].items[1].name = `编辑:${param.title}优惠券的商品范围列表`;
|
||||
activerou[0].items[1].name = `编辑:${param.title}`;
|
||||
sessionStorage.setItem("approval_id", param.approval_id);
|
||||
sessionStorage.setItem("approval_status", param.status);
|
||||
}
|
||||
|
|
|
@ -1726,7 +1726,7 @@ export default class acclist extends React.Component {
|
|||
) : (
|
||||
<UseCouponAddEdit
|
||||
editData={this.state.rowCouponData}
|
||||
type={1}
|
||||
couponType={1}
|
||||
isAuditButton={false}
|
||||
ref="addEditCouponEl"
|
||||
direct_reseller_id={this.props.direct_reseller_id}
|
||||
|
|
|
@ -646,8 +646,14 @@ export default class acclist extends React.Component {
|
|||
onRestrict(e, rowdata, index) {
|
||||
let text = e.target.value;
|
||||
text = text.replace(/[^\d]/g, "");
|
||||
|
||||
if (this.props.keyType === 1) {
|
||||
this.state.distdata[index].restrict = text;
|
||||
this.setState({ distdata: this.state.distdata });
|
||||
} else {
|
||||
this.state.couponData[index].restrict = text;
|
||||
this.setState({ couponData: this.state.couponData });
|
||||
}
|
||||
}
|
||||
|
||||
onDisabledCombinedDate = (val) => {
|
||||
|
@ -1725,8 +1731,8 @@ export default class acclist extends React.Component {
|
|||
</div>
|
||||
) : (
|
||||
<UseCouponAddEdit
|
||||
couponType={1}
|
||||
editData={this.state.rowCouponData}
|
||||
type={1}
|
||||
isAuditButton={false}
|
||||
ref="addEditCouponEl"
|
||||
direct_reseller_id={this.props.direct_reseller_id}
|
||||
|
|
|
@ -490,7 +490,7 @@ export default class adduserinfo extends React.Component {
|
|||
<span style={{ fontSize: "14px" }}>¥</span>{" "}
|
||||
{this.state.model.official_price}
|
||||
</p>
|
||||
<p className="foot-mobile-infos">共省¥ {this.props.reduce}</p>;
|
||||
<p className="foot-mobile-infos">共省¥ {this.props.reduce}</p>
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue