Merge branch 'couponV1.5' of https://codeup.aliyun.com/5f9118049cffa29cfdd3be1c/marketing/frontend into couponV1.5
This commit is contained in:
commit
a79f5628df
|
@ -88,8 +88,8 @@ const tableColumn = [
|
|||
},
|
||||
{
|
||||
title: "类型",
|
||||
name: "type",
|
||||
prop: "type",
|
||||
name: "goods_type",
|
||||
prop: "goods_type",
|
||||
type: "slot",
|
||||
width: "auto",
|
||||
},
|
||||
|
@ -136,7 +136,7 @@ const rule_rules = {
|
|||
};
|
||||
|
||||
const UseCouponAddEdit = forwardRef((props, ref) => {
|
||||
const { type = 0 } = props; // type 入口类型 0优惠券新增 1计划、key批次 (是否显示两个字段)
|
||||
const { type = 0, isAuditButton = true } = props; // type 入口类型 0优惠券新增 1计划、key批次 (是否显示两个字段)
|
||||
|
||||
useEffect(() => {
|
||||
if (type === 0) {
|
||||
|
@ -187,7 +187,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
showScopePop: false,
|
||||
scopePopType: "",
|
||||
productData: [],
|
||||
selectGoodsScopeData: [],
|
||||
});
|
||||
|
||||
// 基础信息
|
||||
|
@ -234,9 +233,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
let el_setup2 = form_rule_el.current.validator();
|
||||
// console.log("el_setup2 =>", el_setup2);
|
||||
// console.log("发放规则 =>", form_rule_data);
|
||||
|
||||
// 商品范围
|
||||
console.log("用户商品范围 =>", state.selectGoodsScopeData);
|
||||
};
|
||||
|
||||
const onReturn = () => {};
|
||||
|
@ -263,47 +259,63 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
};
|
||||
const onPageChange = () => {};
|
||||
const onCountChange = () => {};
|
||||
const selectionFun = (e) => {
|
||||
console.log("e =>", e);
|
||||
let arr = [];
|
||||
_.map(e, (item) => {
|
||||
let obj = {};
|
||||
obj.key = item.product_id;
|
||||
obj.text = item.product_name;
|
||||
arr.push(obj);
|
||||
return obj;
|
||||
});
|
||||
setState({ selectGoodsScopeData: arr });
|
||||
};
|
||||
const onRankChange = () => {};
|
||||
const addProduct = (type) => {
|
||||
// 第一步:获取直连天下的商品数据需要分销商 id
|
||||
const direct_reseller_ids = 23329;
|
||||
if (direct_reseller_ids <= 0) {
|
||||
Notify.error(`请添加映射分销商`);
|
||||
return;
|
||||
|
||||
// 清除商品和立减金本地存储
|
||||
const clearStorageData = () => {
|
||||
if (state.tableData.length <= 0) {
|
||||
sessionStorage.setItem("productData", "");
|
||||
sessionStorage.setItem("knockGoldData", "");
|
||||
}
|
||||
|
||||
// 第二步: 区分是新建商品还是立减金
|
||||
if (type === "addProduct") {
|
||||
setState({
|
||||
product_title: "新建商品",
|
||||
addProductBtnLoading: true,
|
||||
scopePopType: "addProduct",
|
||||
});
|
||||
// 新建商品
|
||||
let product_data = state.tableData.filter((item) => item.goods_type === 1);
|
||||
if (product_data.length <= 0) {
|
||||
sessionStorage.setItem("productData", "");
|
||||
} else {
|
||||
setState({
|
||||
product_title: "新增立减金",
|
||||
addGoldBtnLoading: true,
|
||||
scopePopType: "addKnockGold",
|
||||
});
|
||||
sessionStorage.setItem("productData", JSON.stringify(product_data));
|
||||
}
|
||||
|
||||
// 第三步:获取商品数据
|
||||
let param = {
|
||||
reseller_id: direct_reseller_ids,
|
||||
};
|
||||
// 立减金
|
||||
let knockGold_data = state.tableData.filter(
|
||||
(item) => item.goods_type === 2
|
||||
);
|
||||
if (knockGold_data.length <= 0) {
|
||||
sessionStorage.setItem("knockGoldData", "");
|
||||
} else {
|
||||
sessionStorage.setItem("knockGoldData", JSON.stringify(knockGold_data));
|
||||
}
|
||||
};
|
||||
|
||||
const addProduct = (type) => {
|
||||
try {
|
||||
// 第一步:获取直连天下的商品数据需要分销商 id
|
||||
const direct_reseller_ids = 23329;
|
||||
if (direct_reseller_ids <= 0) {
|
||||
Notify.error(`请添加映射分销商`);
|
||||
return;
|
||||
}
|
||||
// 第二步:清除本地存储数据
|
||||
clearStorageData();
|
||||
|
||||
// 第三步: 区分是新建商品还是立减金
|
||||
if (type === "addProduct") {
|
||||
setState({
|
||||
product_title: "新建商品",
|
||||
addProductBtnLoading: true,
|
||||
scopePopType: "addProduct",
|
||||
});
|
||||
} else {
|
||||
setState({
|
||||
product_title: "新增立减金",
|
||||
addGoldBtnLoading: true,
|
||||
scopePopType: "addKnockGold",
|
||||
});
|
||||
}
|
||||
|
||||
// 第四步:获取商品数据
|
||||
let param = {
|
||||
reseller_id: direct_reseller_ids,
|
||||
};
|
||||
getProductInfoSelect(param).then((res) => {
|
||||
setState({ addProductBtnLoading: false, addGoldBtnLoading: false });
|
||||
handelResponse(
|
||||
|
@ -320,11 +332,11 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
}
|
||||
);
|
||||
});
|
||||
// !!!!!!!!!!!!!! 为了兼容老版本 新增商品设为空!!!老版本使用 productsList 获取商品数据!!!!!!!!!!
|
||||
setState({ productData: null });
|
||||
} catch (err) {
|
||||
setState({ addProductBtnLoading: false, addGoldBtnLoading: false });
|
||||
}
|
||||
// !!!!!!!!!!!!!! 为了兼容老版本 新增商品设为空!!!老版本使用 productsList 获取商品数据!!!!!!!!!!
|
||||
setState({ productData: null });
|
||||
};
|
||||
const renderOptionList = (options, renderOption) => {
|
||||
return (
|
||||
|
@ -374,25 +386,77 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
});
|
||||
};
|
||||
|
||||
const selectionFun = (e) => {
|
||||
let arr = [];
|
||||
_.map(e, (res) => {
|
||||
let obj = {};
|
||||
obj.key = res;
|
||||
obj.text = res.product_name;
|
||||
arr.push(obj);
|
||||
return obj;
|
||||
});
|
||||
setState({ rank: arr });
|
||||
};
|
||||
|
||||
const onRankChange = (e) => {
|
||||
let new_table_data = state.tableData.map((item) => {
|
||||
item.checked =
|
||||
e.findIndex((checks) => {
|
||||
return checks.key === item;
|
||||
}) > -1;
|
||||
return item;
|
||||
});
|
||||
setState({ tableData: new_table_data, rank: e });
|
||||
};
|
||||
|
||||
// 优惠券弹窗 提交
|
||||
const scopePopSubmit = (data) => {
|
||||
try {
|
||||
// 格式化表格数据
|
||||
let data_new = data;
|
||||
data_new.key_batch_id = form_info_data.key_batch_id.key;
|
||||
data_new.effectDate = `${form_info_data.date_time[0]} 至 ${form_info_data.date_time[1]}`;
|
||||
let new_table = state.tableData;
|
||||
new_table.push(data_new);
|
||||
// 设置商品范围选择
|
||||
let select_opt = [];
|
||||
new_table.map((item) => {
|
||||
let obj = {};
|
||||
obj.key = item; // 确保差异
|
||||
obj.text = item.product_name;
|
||||
select_opt.push(obj);
|
||||
});
|
||||
|
||||
// 格式化商品范围
|
||||
setState({
|
||||
tableData: new_table,
|
||||
rankoptions: [],
|
||||
rankoptions: select_opt,
|
||||
});
|
||||
} catch (err) {
|
||||
console.log("err =>", err);
|
||||
}
|
||||
};
|
||||
|
||||
// 商品范围删除
|
||||
const deleteGoodsScope = (index) => {
|
||||
let new_table = state.tableData;
|
||||
if (index === 0) {
|
||||
new_table = [];
|
||||
} else {
|
||||
new_table = new_table.splice(index, 1);
|
||||
}
|
||||
let select_opt = [];
|
||||
new_table.map((item) => {
|
||||
let obj = {};
|
||||
obj.key = item; // 确保差异
|
||||
obj.text = item.product_name;
|
||||
select_opt.push(obj);
|
||||
});
|
||||
selectionFun(new_table);
|
||||
setState({
|
||||
tableData: new_table,
|
||||
rankoptions: select_opt,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="coupon-box">
|
||||
<Card style={{ margin: "10px auto" }} title={state.setup1_title}>
|
||||
|
@ -603,33 +667,41 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
}
|
||||
countChange={(e) => onCountChange(e)}
|
||||
checkChange={(data) => selectionFun(data)}
|
||||
ComponentHandler={(com, rowData) => {
|
||||
ComponentHandler={(com, rowData, rowIndex) => {
|
||||
if (com === "opearo") {
|
||||
return (
|
||||
<div>
|
||||
<span className="grid-link">编辑</span>
|
||||
<span style={{ color: "red" }} className="grid-link">
|
||||
<span
|
||||
style={{ color: "red" }}
|
||||
className="grid-link"
|
||||
onClick={() => deleteGoodsScope(rowIndex)}
|
||||
>
|
||||
删除
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (com === "type") {
|
||||
return <span>{rowData.type === 1 ? "商品" : "立减金"}</span>;
|
||||
if (com === "goods_type") {
|
||||
return (
|
||||
<span>{rowData.goods_type === 1 ? "商品" : "立减金"}</span>
|
||||
);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</Card>
|
||||
|
||||
<div className="step-btn-group">
|
||||
<Button type="primary" onClick={() => submit()}>
|
||||
提交审核
|
||||
</Button>
|
||||
<Button type="normal" onClick={() => onReturn()}>
|
||||
取消
|
||||
</Button>
|
||||
</div>
|
||||
{isAuditButton ? (
|
||||
<div className="step-btn-group">
|
||||
<Button type="primary" onClick={() => submit()}>
|
||||
提交审核
|
||||
</Button>
|
||||
<Button type="normal" onClick={() => onReturn()}>
|
||||
取消
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<UseGoodsScopePop
|
||||
product_title={state.product_title}
|
||||
|
|
|
@ -136,7 +136,7 @@ const rule_rules = {
|
|||
};
|
||||
|
||||
const UseCouponAddEdit = forwardRef((props, ref) => {
|
||||
const { type = 0 } = props; // type 入口类型 0优惠券新增 1计划、key批次 (是否显示两个字段)
|
||||
const { type = 0, isAuditButton = true } = props; // type 入口类型 0优惠券新增 1计划、key批次 (是否显示两个字段)
|
||||
|
||||
useEffect(() => {
|
||||
if (type === 0) {
|
||||
|
@ -387,7 +387,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
};
|
||||
|
||||
const selectionFun = (e) => {
|
||||
console.log("e =>", e);
|
||||
let arr = [];
|
||||
_.map(e, (res) => {
|
||||
let obj = {};
|
||||
|
@ -417,8 +416,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
let data_new = data;
|
||||
let new_table = state.tableData;
|
||||
new_table.push(data_new);
|
||||
console.log("table_data =>", new_table);
|
||||
|
||||
// 设置商品范围选择
|
||||
let select_opt = [];
|
||||
new_table.map((item) => {
|
||||
|
@ -440,7 +437,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
|
||||
// 商品范围删除
|
||||
const deleteGoodsScope = (index) => {
|
||||
console.log(index);
|
||||
let new_table = state.tableData;
|
||||
if (index === 0) {
|
||||
new_table = [];
|
||||
|
@ -696,14 +692,16 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
/>
|
||||
</Card>
|
||||
|
||||
<div className="step-btn-group">
|
||||
<Button type="primary" onClick={() => submit()}>
|
||||
提交审核
|
||||
</Button>
|
||||
<Button type="normal" onClick={() => onReturn()}>
|
||||
取消
|
||||
</Button>
|
||||
</div>
|
||||
{isAuditButton ? (
|
||||
<div className="step-btn-group">
|
||||
<Button type="primary" onClick={() => submit()}>
|
||||
提交审核
|
||||
</Button>
|
||||
<Button type="normal" onClick={() => onReturn()}>
|
||||
取消
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<UseGoodsScopePop
|
||||
product_title={state.product_title}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue