* 'couponV1.5' of https://codeup.aliyun.com/5f9118049cffa29cfdd3be1c/marketing/frontend:
  1) 优惠计划优惠券
  1) 增加优惠券
This commit is contained in:
Apple 2022-09-21 14:26:07 +08:00
commit b78af56fb7
8 changed files with 1250 additions and 114 deletions

File diff suppressed because it is too large Load Diff

View File

@ -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}

View File

@ -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 1key ()
// 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() 1key (宿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()}>
提交审核

View File

@ -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>
);
};

View File

@ -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);
}

View File

@ -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}

View File

@ -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}

View File

@ -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 {