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,47 +259,63 @@ 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;
});
setState({ selectGoodsScopeData: arr });
};
const onRankChange = () => {};
const addProduct = (type) => {
// id
const direct_reseller_ids = 23329;
if (direct_reseller_ids <= 0) {
Notify.error(`请添加映射分销商`);
return;
} }
// : //
if (type === "addProduct") { let product_data = state.tableData.filter((item) => item.goods_type === 1);
setState({ if (product_data.length <= 0) {
product_title: "新建商品", sessionStorage.setItem("productData", "");
addProductBtnLoading: true,
scopePopType: "addProduct",
});
} else { } else {
setState({ sessionStorage.setItem("productData", JSON.stringify(product_data));
product_title: "新增立减金",
addGoldBtnLoading: true,
scopePopType: "addKnockGold",
});
} }
// //
let param = { let knockGold_data = state.tableData.filter(
reseller_id: direct_reseller_ids, (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 { 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) => { 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,33 +667,41 @@ 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>
<div className="step-btn-group"> {isAuditButton ? (
<Button type="primary" onClick={() => submit()}> <div className="step-btn-group">
提交审核 <Button type="primary" onClick={() => submit()}>
</Button> 提交审核
<Button type="normal" onClick={() => onReturn()}> </Button>
取消 <Button type="normal" onClick={() => onReturn()}>
</Button> 取消
</div> </Button>
</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,14 +692,16 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
/> />
</Card> </Card>
<div className="step-btn-group"> {isAuditButton ? (
<Button type="primary" onClick={() => submit()}> <div className="step-btn-group">
提交审核 <Button type="primary" onClick={() => submit()}>
</Button> 提交审核
<Button type="normal" onClick={() => onReturn()}> </Button>
取消 <Button type="normal" onClick={() => onReturn()}>
</Button> 取消
</div> </Button>
</div>
) : null}
<UseGoodsScopePop <UseGoodsScopePop
product_title={state.product_title} product_title={state.product_title}

File diff suppressed because it is too large Load Diff