1) 优惠计划优惠券
This commit is contained in:
parent
54d7b196a8
commit
24b1744063
|
@ -162,8 +162,7 @@ const rule_rules = {
|
|||
|
||||
const UseCouponAddEdit = forwardRef((props, ref) => {
|
||||
// 注意 !!!!!!!!couponType 入口类型 0优惠券新增(显示) 1计划、key批次 (是否显示归属计划和归宿key两个字段)!!!!
|
||||
// comType 组件操作类型 0新增 1编辑 2复制
|
||||
const { couponType = 0, direct_reseller_id, editData, comType } = props;
|
||||
const { couponType = 0, direct_reseller_id, editData } = props;
|
||||
|
||||
const [state, setState] = useSetState({
|
||||
setup1_title: "基本信息",
|
||||
|
@ -225,16 +224,16 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
if (couponType === 0) {
|
||||
sessionStorage.setItem("keyType", 2);
|
||||
// 1.1 获取归属计划下拉框数据
|
||||
await getPlanList(); // 获取计划
|
||||
// 1.2 判断组件操作函数 comType操作 0新增 1编辑 2复制
|
||||
if (comType === 0) {
|
||||
AddFun();
|
||||
} else if (comType === 1) {
|
||||
await getPlanList(); // 获取归属计划
|
||||
// 1.2 优惠券管理判断是新增还是编辑
|
||||
if (editData && editData !== "") {
|
||||
editFun();
|
||||
} else {
|
||||
copyFun();
|
||||
}
|
||||
} else {
|
||||
// 1.3 计划的优惠券编辑
|
||||
if (editData && editData !== "") {
|
||||
editFun();
|
||||
}
|
||||
}
|
||||
})();
|
||||
}, []);
|
||||
|
@ -242,70 +241,68 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
// 编辑处理函数
|
||||
const editFun = () => {
|
||||
try {
|
||||
if (editData && editData !== "") {
|
||||
// 基本信息
|
||||
setForm_info_data({
|
||||
title: editData.title,
|
||||
date_time: [editData.begin_time, editData.end_time],
|
||||
});
|
||||
// 规则
|
||||
setForm_rule_data({
|
||||
full: editData.full,
|
||||
reduce: editData.reduce,
|
||||
quantity: editData.quantity,
|
||||
budget: editData.budget,
|
||||
restrict: editData.restrict,
|
||||
});
|
||||
// 商品范围
|
||||
// 商品的数组
|
||||
let goods_arr = editData.product.legal.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
type: 1,
|
||||
upstream: "直连天下",
|
||||
all_budget: Number(item.contract_price) * Number(item.quantity),
|
||||
effectDate: "-",
|
||||
};
|
||||
});
|
||||
// 基本信息
|
||||
setForm_info_data({
|
||||
title: editData.title,
|
||||
date_time: [editData.begin_time, editData.end_time],
|
||||
});
|
||||
// 规则
|
||||
setForm_rule_data({
|
||||
full: editData.full,
|
||||
reduce: editData.reduce,
|
||||
quantity: editData.quantity,
|
||||
budget: editData.budget,
|
||||
restrict: editData.restrict,
|
||||
});
|
||||
// 商品范围
|
||||
// 商品的数组
|
||||
let goods_arr = editData.product.legal.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
type: 1,
|
||||
upstream: "直连天下",
|
||||
all_budget: Number(item.contract_price) * Number(item.quantity),
|
||||
effectDate: "-",
|
||||
};
|
||||
});
|
||||
|
||||
// 立减金
|
||||
let lj_arr = editData.product.reduce.map((item) => {
|
||||
let table_obj = {};
|
||||
table_obj.type = 2; // 类型
|
||||
table_obj.upstream = String(item.channel) === "1" ? "支付宝" : "微信"; // 上游平台
|
||||
// 立减金
|
||||
let lj_arr = editData.product.reduce.map((item) => {
|
||||
let table_obj = {};
|
||||
table_obj.type = 2; // 类型
|
||||
table_obj.upstream = String(item.channel) === "1" ? "支付宝" : "微信"; // 上游平台
|
||||
|
||||
table_obj.only = item; // 存储就数据 编辑好用
|
||||
table_obj.product_id = item.channel_activity_id; // 商品编号
|
||||
table_obj.product_name = item.batch_goods_name; // 商品名
|
||||
table_obj.official_price = item.reduce_amount; // 官方价
|
||||
table_obj.contract_price = item.price; // 合同价格
|
||||
table_obj.quantity = Math.trunc(item.all_budget / item.reduce_amount); // 库存数量
|
||||
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.end_time} 至 ${item.time_limit.effect_time.start_time}`; // 有效时间段
|
||||
table_obj.createDate = ""; // 创建时间
|
||||
return table_obj;
|
||||
});
|
||||
table_obj.only = item; // 存储就数据 编辑好用
|
||||
table_obj.product_id = item.channel_activity_id; // 商品编号
|
||||
table_obj.product_name = item.batch_goods_name; // 商品名
|
||||
table_obj.official_price = item.reduce_amount; // 官方价
|
||||
table_obj.contract_price = item.price; // 合同价格
|
||||
table_obj.quantity = Math.trunc(item.all_budget / item.reduce_amount); // 库存数量
|
||||
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.end_time} 至 ${item.time_limit.effect_time.start_time}`; // 有效时间段
|
||||
table_obj.createDate = ""; // 创建时间
|
||||
return table_obj;
|
||||
});
|
||||
|
||||
let scope_data = goods_arr.concat(lj_arr);
|
||||
scope_data = _.map(scope_data, (o) => {
|
||||
o.checked = true;
|
||||
return o;
|
||||
});
|
||||
let scope_data = goods_arr.concat(lj_arr);
|
||||
scope_data = _.map(scope_data, (o) => {
|
||||
o.checked = true;
|
||||
return o;
|
||||
});
|
||||
|
||||
let arr = _.map(scope_data, (res) => {
|
||||
let obj = {};
|
||||
obj.key = res.product_id;
|
||||
obj.text = res.product_name;
|
||||
return obj;
|
||||
});
|
||||
let arr = _.map(scope_data, (res) => {
|
||||
let obj = {};
|
||||
obj.key = res.product_id;
|
||||
obj.text = res.product_name;
|
||||
return obj;
|
||||
});
|
||||
|
||||
setState({
|
||||
rankoptions: arr,
|
||||
rank: arr,
|
||||
tableData: scope_data,
|
||||
});
|
||||
}
|
||||
setState({
|
||||
rankoptions: arr,
|
||||
rank: arr,
|
||||
tableData: scope_data,
|
||||
});
|
||||
} catch (err) {}
|
||||
};
|
||||
// 新增处理函数
|
||||
|
|
|
@ -45,7 +45,6 @@ const CouponAddEdit = () => {
|
|||
{state.isShow ? (
|
||||
<UseCouponAddEdit
|
||||
couponType={0}
|
||||
comType={state.comType}
|
||||
editData={state.editModel}
|
||||
isAuditButton={false}
|
||||
ref={addEditCouponEl}
|
||||
|
|
|
@ -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, "");
|
||||
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) => {
|
||||
|
@ -1725,8 +1731,8 @@ export default class acclist extends React.Component {
|
|||
</div>
|
||||
) : (
|
||||
<UseCouponAddEdit
|
||||
editData={this.state.rowCouponData}
|
||||
couponType={1}
|
||||
editData={this.state.rowCouponData}
|
||||
isAuditButton={false}
|
||||
ref="addEditCouponEl"
|
||||
direct_reseller_id={this.props.direct_reseller_id}
|
||||
|
|
Loading…
Reference in New Issue