This commit is contained in:
zhangds 2022-09-07 12:22:15 +08:00
commit a79f5628df
3 changed files with 1003 additions and 949 deletions

View File

@ -88,8 +88,8 @@ const tableColumn = [
}, },
{ {
title: "类型", title: "类型",
name: "type", name: "goods_type",
prop: "type", prop: "goods_type",
type: "slot", type: "slot",
width: "auto", width: "auto",
}, },
@ -136,7 +136,7 @@ const rule_rules = {
}; };
const UseCouponAddEdit = forwardRef((props, ref) => { const UseCouponAddEdit = forwardRef((props, ref) => {
const { type = 0 } = props; // type 0 1key () const { type = 0, isAuditButton = true } = props; // type 0 1key ()
useEffect(() => { useEffect(() => {
if (type === 0) { if (type === 0) {
@ -187,7 +187,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
showScopePop: false, showScopePop: false,
scopePopType: "", scopePopType: "",
productData: [], productData: [],
selectGoodsScopeData: [],
}); });
// //
@ -234,9 +233,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
let el_setup2 = form_rule_el.current.validator(); let el_setup2 = form_rule_el.current.validator();
// console.log("el_setup2 =>", el_setup2); // console.log("el_setup2 =>", el_setup2);
// console.log(" =>", form_rule_data); // console.log(" =>", form_rule_data);
//
console.log("用户商品范围 =>", state.selectGoodsScopeData);
}; };
const onReturn = () => {}; const onReturn = () => {};
@ -263,28 +259,45 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
}; };
const onPageChange = () => {}; const onPageChange = () => {};
const onCountChange = () => {}; const onCountChange = () => {};
const selectionFun = (e) => {
console.log("e =>", e); //
let arr = []; const clearStorageData = () => {
_.map(e, (item) => { if (state.tableData.length <= 0) {
let obj = {}; sessionStorage.setItem("productData", "");
obj.key = item.product_id; sessionStorage.setItem("knockGoldData", "");
obj.text = item.product_name; }
arr.push(obj);
return obj; //
}); let product_data = state.tableData.filter((item) => item.goods_type === 1);
setState({ selectGoodsScopeData: arr }); if (product_data.length <= 0) {
sessionStorage.setItem("productData", "");
} else {
sessionStorage.setItem("productData", JSON.stringify(product_data));
}
//
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 onRankChange = () => {};
const addProduct = (type) => { const addProduct = (type) => {
try {
// id // id
const direct_reseller_ids = 23329; const direct_reseller_ids = 23329;
if (direct_reseller_ids <= 0) { if (direct_reseller_ids <= 0) {
Notify.error(`请添加映射分销商`); Notify.error(`请添加映射分销商`);
return; return;
} }
//
clearStorageData();
// : // :
if (type === "addProduct") { if (type === "addProduct") {
setState({ setState({
product_title: "新建商品", product_title: "新建商品",
@ -299,11 +312,10 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
}); });
} }
// //
let param = { let param = {
reseller_id: direct_reseller_ids, reseller_id: direct_reseller_ids,
}; };
try {
getProductInfoSelect(param).then((res) => { getProductInfoSelect(param).then((res) => {
setState({ addProductBtnLoading: false, addGoldBtnLoading: false }); setState({ addProductBtnLoading: false, addGoldBtnLoading: false });
handelResponse( handelResponse(
@ -320,11 +332,11 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
} }
); );
}); });
// !!!!!!!!!!!!!! 使 productsList
setState({ productData: null });
} catch (err) { } catch (err) {
setState({ addProductBtnLoading: false, addGoldBtnLoading: false }); setState({ addProductBtnLoading: false, addGoldBtnLoading: false });
} }
// !!!!!!!!!!!!!! 使 productsList
setState({ productData: null });
}; };
const renderOptionList = (options, renderOption) => { const renderOptionList = (options, renderOption) => {
return ( 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) => { const scopePopSubmit = (data) => {
try { try {
// //
let data_new = data; 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; let new_table = state.tableData;
new_table.push(data_new); 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({ setState({
tableData: new_table, tableData: new_table,
rankoptions: [], rankoptions: select_opt,
}); });
} catch (err) { } catch (err) {
console.log("err =>", 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 ( return (
<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}>
@ -603,25 +667,32 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
} }
countChange={(e) => onCountChange(e)} countChange={(e) => onCountChange(e)}
checkChange={(data) => selectionFun(data)} checkChange={(data) => selectionFun(data)}
ComponentHandler={(com, rowData) => { ComponentHandler={(com, rowData, rowIndex) => {
if (com === "opearo") { if (com === "opearo") {
return ( return (
<div> <div>
<span className="grid-link">编辑</span> <span className="grid-link">编辑</span>
<span style={{ color: "red" }} className="grid-link"> <span
style={{ color: "red" }}
className="grid-link"
onClick={() => deleteGoodsScope(rowIndex)}
>
删除 删除
</span> </span>
</div> </div>
); );
} }
if (com === "type") { if (com === "goods_type") {
return <span>{rowData.type === 1 ? "商品" : "立减金"}</span>; return (
<span>{rowData.goods_type === 1 ? "商品" : "立减金"}</span>
);
} }
}} }}
/> />
</Card> </Card>
{isAuditButton ? (
<div className="step-btn-group"> <div className="step-btn-group">
<Button type="primary" onClick={() => submit()}> <Button type="primary" onClick={() => submit()}>
提交审核 提交审核
@ -630,6 +701,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
取消 取消
</Button> </Button>
</div> </div>
) : null}
<UseGoodsScopePop <UseGoodsScopePop
product_title={state.product_title} product_title={state.product_title}

View File

@ -136,7 +136,7 @@ const rule_rules = {
}; };
const UseCouponAddEdit = forwardRef((props, ref) => { const UseCouponAddEdit = forwardRef((props, ref) => {
const { type = 0 } = props; // type 0 1key () const { type = 0, isAuditButton = true } = props; // type 0 1key ()
useEffect(() => { useEffect(() => {
if (type === 0) { if (type === 0) {
@ -387,7 +387,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
}; };
const selectionFun = (e) => { const selectionFun = (e) => {
console.log("e =>", e);
let arr = []; let arr = [];
_.map(e, (res) => { _.map(e, (res) => {
let obj = {}; let obj = {};
@ -417,8 +416,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
let data_new = data; let data_new = data;
let new_table = state.tableData; let new_table = state.tableData;
new_table.push(data_new); new_table.push(data_new);
console.log("table_data =>", new_table);
// //
let select_opt = []; let select_opt = [];
new_table.map((item) => { new_table.map((item) => {
@ -440,7 +437,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
// //
const deleteGoodsScope = (index) => { const deleteGoodsScope = (index) => {
console.log(index);
let new_table = state.tableData; let new_table = state.tableData;
if (index === 0) { if (index === 0) {
new_table = []; new_table = [];
@ -696,6 +692,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
/> />
</Card> </Card>
{isAuditButton ? (
<div className="step-btn-group"> <div className="step-btn-group">
<Button type="primary" onClick={() => submit()}> <Button type="primary" onClick={() => submit()}>
提交审核 提交审核
@ -704,6 +701,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
取消 取消
</Button> </Button>
</div> </div>
) : null}
<UseGoodsScopePop <UseGoodsScopePop
product_title={state.product_title} product_title={state.product_title}

File diff suppressed because it is too large Load Diff