* '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: "", plan_id: "",
key_batch_id: "", key_batch_id: "",
title: "", title: "",
date_time: "", date_time: JSON.parse(sessionStorage.getItem("datetime")),
}); });
const form_info_el = useRef(null); const form_info_el = useRef(null);
@ -600,7 +600,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
scopePopType: "addKnockGold", scopePopType: "addKnockGold",
}); });
} }
// //
let param = { let param = {
reseller_id: direct_reseller_ids, reseller_id: direct_reseller_ids,
@ -1146,6 +1145,8 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
{state.examinePopShow ? examinePop() : null} {state.examinePopShow ? examinePop() : null}
<UseGoodsScopePop <UseGoodsScopePop
full={form_rule_data.full}
reduce={form_rule_data.reduce}
product_title={state.product_title} product_title={state.product_title}
drawerVisible={state.showScopePop} drawerVisible={state.showScopePop}
type={state.scopePopType} type={state.scopePopType}

View File

@ -6,6 +6,7 @@ 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 { useHistory } from "react-router-dom";
import { import {
Card, Card,
DateRangePicker, DateRangePicker,
@ -16,26 +17,26 @@ import {
Icon, Icon,
RadioGroup, RadioGroup,
Radio, Radio,
Sweetalert,
} from "zent"; } from "zent";
import moment from "moment"; import moment from "moment";
import _ from "lodash"; 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 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 { isAmount } from "@/tools/validate";
import {
getProductInfoSelect,
handelResponse,
queryPlans,
queryKeyBatch,
addCoupon,
getCouponDetails,
} from "@/assets/api.js";
import { mulNum } from "@/tools/number";
import "./style.less"; import "./style.less";
const tableColumn = [ const tableColumn = [
@ -160,24 +161,8 @@ const rule_rules = {
}; };
const UseCouponAddEdit = forwardRef((props, ref) => { const UseCouponAddEdit = forwardRef((props, ref) => {
const { // couponType 0() 1key (宿key)
type = 0, const { couponType = 0, direct_reseller_id, editData } = props;
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" },
// ];
// }
// }, []);
const [state, setState] = useSetState({ const [state, setState] = useSetState({
setup1_title: "基本信息", setup1_title: "基本信息",
@ -213,16 +198,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
editModel: {}, // editModel: {}, //
}); });
useEffect(() => {
(async function init() {
//
if (type === 0) {
await getPlanList(); //
await initEditAndCopy(); //
}
})();
}, []);
// //
const [form_info_data, setForm_info_data] = useSetState({ const [form_info_data, setForm_info_data] = useSetState({
plan_id: "", plan_id: "",
@ -242,9 +217,30 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
}); });
const form_rule_el = useRef(null); const form_rule_el = useRef(null);
// // //
useEffect(() => { 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({ setForm_info_data({
title: editData.title, title: editData.title,
@ -290,7 +286,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
}); });
let scope_data = goods_arr.concat(lj_arr); let scope_data = goods_arr.concat(lj_arr);
scope_data = _.map(scope_data, (o) => { scope_data = _.map(scope_data, (o) => {
o.checked = true; o.checked = true;
return o; return o;
@ -308,8 +303,39 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
rank: arr, rank: arr,
tableData: scope_data, 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(() => { useEffect(() => {
@ -328,57 +354,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
getModel: getModel, 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 = () => { const submit = () => {
let validator = false; let validator = false;
@ -416,7 +391,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
return false; return false;
} }
// //
if (type === 1) { if (couponType === 1) {
return true; return true;
} else { } else {
setState({ setState({
@ -487,6 +462,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
...item.only, ...item.only,
}; };
}); });
console.log("param 优惠券新增 大提交 =>", param);
addCoupon(param).then((res) => { addCoupon(param).then((res) => {
handelResponse( handelResponse(
res, res,
@ -505,13 +481,15 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
// select // select
const changePlan = (e) => { 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 }); 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( queryKeyBatch({ status: "4,5", plan_id: e.key.key, bind_object: 2 }).then(
(res) => { (res) => {
handelResponse(res, (req, msg) => { handelResponse(res, (req, msg) => {
console.log("req =>", req);
let arr = req.map((item) => { let arr = req.map((item) => {
return { return {
key: item.id, 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) => { const onChangeCombinedDate = (e) => {
setForm_info_data({ date_time: e }); setForm_info_data({ date_time: e });
// //
@ -868,7 +859,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
<div className="coupon-box"> <div className="coupon-box">
<Card style={{ margin: "10px auto" }} title={state.setup1_title}> <Card style={{ margin: "10px auto" }} title={state.setup1_title}>
<Form model={form_info_data} rules={info_rules} ref={form_info_el}> <Form model={form_info_data} rules={info_rules} ref={form_info_el}>
{type === 0 ? ( {couponType === 0 ? (
<FormItem labelname="归属计划" prop="plan_id"> <FormItem labelname="归属计划" prop="plan_id">
<Select <Select
clearable clearable
@ -878,13 +869,12 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
value={form_info_data.plan_id} value={form_info_data.plan_id}
onChange={(e) => { onChange={(e) => {
changePlan(e); changePlan(e);
// setForm_info_data({ plan_id: e });
}} }}
/> />
</FormItem> </FormItem>
) : null} ) : null}
{type === 0 ? ( {couponType === 0 ? (
<FormItem labelname="归属key" prop="key_batch_id"> <FormItem labelname="归属key" prop="key_batch_id">
<Select <Select
clearable clearable
@ -1131,7 +1121,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
</BlockLoading> </BlockLoading>
</Card> </Card>
{isAuditButton ? ( {couponType === 0 ? (
<div className="step-btn-group"> <div className="step-btn-group">
<Button type="primary" onClick={() => submit()}> <Button type="primary" onClick={() => submit()}>
提交审核 提交审核

View File

@ -1,12 +1,56 @@
import React from "react"; import React, { useEffect, useRef } from "react";
import "./style.less"; import { useSetState } from "ahooks";
import { handelResponse, getCouponDetails } from "@/assets/api.js";
import UseCouponAddEdit from "@/components/UseCouponAddEdit"; import UseCouponAddEdit from "@/components/UseCouponAddEdit";
import "./style.less";
const CouponAddEdit = () => { 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 ( return (
<div className="coupon-add-edit"> <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> </div>
); );
}; };

View File

@ -274,7 +274,7 @@ const UseCouponList = () => {
sessionStorage.setItem("keyBatch_id", param.key_batch_id); sessionStorage.setItem("keyBatch_id", param.key_batch_id);
} else if (type === 2) { } else if (type === 2) {
activerou[0].pagetitle = "编辑"; 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_id", param.approval_id);
sessionStorage.setItem("approval_status", param.status); sessionStorage.setItem("approval_status", param.status);
} }

View File

@ -1726,7 +1726,7 @@ export default class acclist extends React.Component {
) : ( ) : (
<UseCouponAddEdit <UseCouponAddEdit
editData={this.state.rowCouponData} editData={this.state.rowCouponData}
type={1} couponType={1}
isAuditButton={false} isAuditButton={false}
ref="addEditCouponEl" ref="addEditCouponEl"
direct_reseller_id={this.props.direct_reseller_id} 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) { onRestrict(e, rowdata, index) {
let text = e.target.value; let text = e.target.value;
text = text.replace(/[^\d]/g, ""); text = text.replace(/[^\d]/g, "");
if (this.props.keyType === 1) {
this.state.distdata[index].restrict = text; this.state.distdata[index].restrict = text;
this.setState({ distdata: this.state.distdata }); this.setState({ distdata: this.state.distdata });
} else {
this.state.couponData[index].restrict = text;
this.setState({ couponData: this.state.couponData });
}
} }
onDisabledCombinedDate = (val) => { onDisabledCombinedDate = (val) => {
@ -1725,8 +1731,8 @@ export default class acclist extends React.Component {
</div> </div>
) : ( ) : (
<UseCouponAddEdit <UseCouponAddEdit
couponType={1}
editData={this.state.rowCouponData} editData={this.state.rowCouponData}
type={1}
isAuditButton={false} isAuditButton={false}
ref="addEditCouponEl" ref="addEditCouponEl"
direct_reseller_id={this.props.direct_reseller_id} 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>{" "} <span style={{ fontSize: "14px" }}>¥</span>{" "}
{this.state.model.official_price} {this.state.model.official_price}
</p> </p>
<p className="foot-mobile-infos">共省¥ {this.props.reduce}</p>; <p className="foot-mobile-infos">共省¥ {this.props.reduce}</p>
</div> </div>
); );
} else { } else {