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