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

View File

@ -13,6 +13,7 @@ const UseGoodsScopePop = forwardRef((props, ref) => {
productData, productData,
submit, submit,
tableData, tableData,
table_index,
} = props; } = props;
// ref // ref
@ -25,18 +26,24 @@ const UseGoodsScopePop = forwardRef((props, ref) => {
// //
const format_product_model = () => { 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.goods_type = 1;
form_model.upstream = "直连天下"; form_model.upstream = "直连天下";
form_model.all_budget = form_model.all_budget =
Number(form_model.contract_price) * Number(form_model.quantity); Number(form_model.contract_price) * Number(form_model.quantity);
form_model.effectDate = "-"; form_model.effectDate = "-";
let new_tableData = tableData; if (product_title === "编辑商品") {
new_tableData.push(form_model); 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; return new_tableData;
}; };

View File

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