1) 增加商品编辑选中联动

This commit is contained in:
zhangds 2022-09-07 18:17:56 +08:00
parent 53ac05411f
commit 72bcc02051
3 changed files with 42 additions and 13 deletions

View File

@ -195,6 +195,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
productData: {},
direct_reseller_id: 23329,
tableLoading: false,
table_index: -1,
});
//
@ -349,7 +350,9 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
};
//
const productEditShow = (rowData) => {
const productEditShow = (rowData, index) => {
console.log("rowData =>", rowData);
console.log("index =>", index);
try {
// id
const direct_reseller_ids = state.direct_reseller_id;
@ -357,6 +360,8 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
Notify.error(`请添加映射分销商`);
return;
}
//
clearStorageData();
setState({
tableLoading: true,
});
@ -379,6 +384,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
productData: obj,
addIsType: "addKnockGold",
showScopePop: true,
table_index: index,
});
} else {
setState({
@ -386,6 +392,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
productData: rowData,
addIsType: "addProduct",
showScopePop: true,
table_index: index,
});
}
},
@ -488,10 +495,25 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
});
console.log("select_opt =>", select_opt);
console.log("rank =>", state.rank);
let select_arr = [];
new_table.map((item) => {
console.log("item =>", item);
let obj = {};
if (item.checked) {
obj.key = item.product_id;
obj.text = item.product_name;
select_arr.push(obj);
}
});
console.log("select_arr =>", select_arr);
//
setState({
tableData: new_table,
rankoptions: select_opt,
rank: select_arr,
});
} catch (err) {
console.log("err =>", err);
@ -500,12 +522,9 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
//
const deleteGoodsScope = (index) => {
console.log("index deleat", index);
let new_table = state.tableData;
if (index === 0) {
new_table = [];
} else {
new_table = new_table.splice(index, 1);
}
new_table.splice(index, 1);
let select_opt = [];
new_table.map((item) => {
let obj = {};
@ -743,7 +762,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
<div>
<span
className="grid-link"
onClick={() => productEditShow(rowData)}
onClick={() => productEditShow(rowData, rowIndex)}
>
编辑
</span>
@ -786,6 +805,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
productData={state.productData}
onClose={() => scopePopClose()}
tableData={state.tableData}
table_index={state.table_index}
submit={(data) => scopePopSubmit(data)}
></UseGoodsScopePop>
</div>

View File

@ -13,6 +13,7 @@ const UseGoodsScopePop = forwardRef((props, ref) => {
productData,
submit,
tableData,
table_index,
} = props;
// ref
@ -25,18 +26,24 @@ const UseGoodsScopePop = forwardRef((props, ref) => {
//
const format_product_model = () => {
//
let new_tableData = tableData;
//
let form_model = product_el.current.state.model;
let form_model = product_el.current.state.form_data;
form_model.goods_type = 1;
form_model.upstream = "直连天下";
form_model.all_budget =
Number(form_model.contract_price) * Number(form_model.quantity);
form_model.effectDate = "-";
let new_tableData = tableData;
if (product_title === "编辑商品") {
if (table_index !== -1) {
form_model.checked = false;
new_tableData[table_index] = form_model;
console.log("new_tableData =>", new_tableData);
}
} else {
new_tableData.push(form_model);
}
return new_tableData;
};

View File

@ -46,6 +46,7 @@ export default class adduserinfo extends React.Component {
detail_url: "",
account_type: "",
},
form_data: {},
cur_product: {},
productOption: [],
products: [],
@ -200,7 +201,7 @@ export default class adduserinfo extends React.Component {
}
temp[index].describe_url = urls;
temp[index].map_product_name = this.state.model.map_product_name;
this.setState({ form_data: temp[index] });
sessionStorage.setItem("productData", JSON.stringify(temp));
return true;
}
@ -227,6 +228,7 @@ export default class adduserinfo extends React.Component {
let data = temp ? temp : [];
data.push(this.state.model);
sessionStorage.setItem("productData", JSON.stringify(data));
this.setState({ form_data: model });
return true;
}
}