1) 增加商品范围删除联动

This commit is contained in:
zhangds 2022-09-07 12:08:59 +08:00
parent 16dce65170
commit 7a215ea249
2 changed files with 18 additions and 8 deletions

View File

@ -387,22 +387,19 @@ 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 = {};
obj.key = res.only; obj.key = res;
obj.text = res.product_name; obj.text = res.product_name;
arr.push(obj); arr.push(obj);
return obj; return obj;
}); });
console.log("选中 =>", arr);
setState({ rank: arr }); setState({ rank: arr });
}; };
const onRankChange = (e) => { const onRankChange = (e) => {
console.log("e =>", e);
let new_table_data = state.tableData.map((item) => { let new_table_data = state.tableData.map((item) => {
item.checked = item.checked =
e.findIndex((checks) => { e.findIndex((checks) => {
@ -410,7 +407,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
}) > -1; }) > -1;
return item; return item;
}); });
console.log("new_table_data =>", new_table_data);
setState({ tableData: new_table_data, rank: e }); setState({ tableData: new_table_data, rank: e });
}; };
@ -444,10 +440,24 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
// //
const deleteGoodsScope = (index) => { const deleteGoodsScope = (index) => {
console.log(index);
let new_table = state.tableData; let new_table = state.tableData;
new_table = new_table.splice(index, 1); 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({ setState({
tableData: new_table, tableData: new_table,
rankoptions: select_opt,
}); });
}; };

View File

@ -31,7 +31,7 @@ const UseGoodsScopePop = forwardRef((props, ref) => {
const format_knockGold_model = () => { const format_knockGold_model = () => {
let form_model = knockGold_el.current.state.model; let form_model = knockGold_el.current.state.model;
let table_obj = {}; let table_obj = {};
table_obj.old = form_model; // table_obj.only = form_model; //
table_obj.product_id = "-"; // table_obj.product_id = "-"; //
table_obj.product_name = form_model.batch_goods_name; // table_obj.product_name = form_model.batch_goods_name; //