1) 增加商品编辑选中联动
This commit is contained in:
parent
53ac05411f
commit
72bcc02051
|
@ -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>
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue