1) 优惠计划优惠券

This commit is contained in:
zhangds 2022-09-21 14:21:11 +08:00
parent 54d7b196a8
commit 24b1744063
3 changed files with 74 additions and 72 deletions

View File

@ -162,8 +162,7 @@ const rule_rules = {
const UseCouponAddEdit = forwardRef((props, ref) => { const UseCouponAddEdit = forwardRef((props, ref) => {
// couponType 0() 1key (宿key) // couponType 0() 1key (宿key)
// comType 0 1 2 const { couponType = 0, direct_reseller_id, editData } = props;
const { couponType = 0, direct_reseller_id, editData, comType } = props;
const [state, setState] = useSetState({ const [state, setState] = useSetState({
setup1_title: "基本信息", setup1_title: "基本信息",
@ -225,16 +224,16 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
if (couponType === 0) { if (couponType === 0) {
sessionStorage.setItem("keyType", 2); sessionStorage.setItem("keyType", 2);
// 1.1 // 1.1
await getPlanList(); // await getPlanList(); //
// 1.2 comType 0 1 2 // 1.2
if (comType === 0) { if (editData && editData !== "") {
AddFun();
} else if (comType === 1) {
editFun(); editFun();
} else {
copyFun();
} }
} else { } else {
// 1.3
if (editData && editData !== "") {
editFun();
}
} }
})(); })();
}, []); }, []);
@ -242,70 +241,68 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
// //
const editFun = () => { const editFun = () => {
try { try {
if (editData && editData !== "") { //
// setForm_info_data({
setForm_info_data({ title: editData.title,
title: editData.title, date_time: [editData.begin_time, editData.end_time],
date_time: [editData.begin_time, editData.end_time], });
}); //
// setForm_rule_data({
setForm_rule_data({ full: editData.full,
full: editData.full, reduce: editData.reduce,
reduce: editData.reduce, quantity: editData.quantity,
quantity: editData.quantity, budget: editData.budget,
budget: editData.budget, restrict: editData.restrict,
restrict: editData.restrict, });
}); //
// //
// let goods_arr = editData.product.legal.map((item) => {
let goods_arr = editData.product.legal.map((item) => { return {
return { ...item,
...item, type: 1,
type: 1, upstream: "直连天下",
upstream: "直连天下", all_budget: Number(item.contract_price) * Number(item.quantity),
all_budget: Number(item.contract_price) * Number(item.quantity), effectDate: "-",
effectDate: "-", };
}; });
});
// //
let lj_arr = editData.product.reduce.map((item) => { let lj_arr = editData.product.reduce.map((item) => {
let table_obj = {}; let table_obj = {};
table_obj.type = 2; // table_obj.type = 2; //
table_obj.upstream = String(item.channel) === "1" ? "支付宝" : "微信"; // table_obj.upstream = String(item.channel) === "1" ? "支付宝" : "微信"; //
table_obj.only = item; // table_obj.only = item; //
table_obj.product_id = item.channel_activity_id; // table_obj.product_id = item.channel_activity_id; //
table_obj.product_name = item.batch_goods_name; // table_obj.product_name = item.batch_goods_name; //
table_obj.official_price = item.reduce_amount; // table_obj.official_price = item.reduce_amount; //
table_obj.contract_price = item.price; // table_obj.contract_price = item.price; //
table_obj.quantity = Math.trunc(item.all_budget / item.reduce_amount); // table_obj.quantity = Math.trunc(item.all_budget / item.reduce_amount); //
table_obj.channel_activity_id = item.channel_activity_id; // table_obj.channel_activity_id = item.channel_activity_id; //
table_obj.all_budget = Number(item.all_budget); // table_obj.all_budget = Number(item.all_budget); //
table_obj.effectDate = `${item.time_limit.effect_time.end_time}${item.time_limit.effect_time.start_time}`; // table_obj.effectDate = `${item.time_limit.effect_time.end_time}${item.time_limit.effect_time.start_time}`; //
table_obj.createDate = ""; // table_obj.createDate = ""; //
return table_obj; return table_obj;
}); });
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;
}); });
let arr = _.map(scope_data, (res) => { let arr = _.map(scope_data, (res) => {
let obj = {}; let obj = {};
obj.key = res.product_id; obj.key = res.product_id;
obj.text = res.product_name; obj.text = res.product_name;
return obj; return obj;
}); });
setState({ setState({
rankoptions: arr, rankoptions: arr,
rank: arr, rank: arr,
tableData: scope_data, tableData: scope_data,
}); });
}
} catch (err) {} } catch (err) {}
}; };
// //

View File

@ -45,7 +45,6 @@ const CouponAddEdit = () => {
{state.isShow ? ( {state.isShow ? (
<UseCouponAddEdit <UseCouponAddEdit
couponType={0} couponType={0}
comType={state.comType}
editData={state.editModel} editData={state.editModel}
isAuditButton={false} isAuditButton={false}
ref={addEditCouponEl} ref={addEditCouponEl}

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, "");
this.state.distdata[index].restrict = text;
this.setState({ distdata: this.state.distdata }); 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) => { onDisabledCombinedDate = (val) => {
@ -1725,8 +1731,8 @@ export default class acclist extends React.Component {
</div> </div>
) : ( ) : (
<UseCouponAddEdit <UseCouponAddEdit
editData={this.state.rowCouponData}
couponType={1} couponType={1}
editData={this.state.rowCouponData}
isAuditButton={false} isAuditButton={false}
ref="addEditCouponEl" ref="addEditCouponEl"
direct_reseller_id={this.props.direct_reseller_id} direct_reseller_id={this.props.direct_reseller_id}