From 71047d64150178452c49b648a9f542e1c9058f71 Mon Sep 17 00:00:00 2001 From: zhangds Date: Fri, 14 Oct 2022 14:08:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E7=AB=8B=E5=87=8F?= =?UTF-8?q?=E9=87=91=E5=8A=A0=E8=BD=BD=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/UseCouponAddEdit/index.jsx | 105 +++++++++++----------- 1 file changed, 54 insertions(+), 51 deletions(-) diff --git a/src/components/UseCouponAddEdit/index.jsx b/src/components/UseCouponAddEdit/index.jsx index c5ff9f17..d75dea33 100644 --- a/src/components/UseCouponAddEdit/index.jsx +++ b/src/components/UseCouponAddEdit/index.jsx @@ -864,6 +864,28 @@ const UseCouponAddEdit = forwardRef((props, ref) => { addProductBtnLoading: true, scopePopType: "addProduct", }); + // 第四步:获取商品数据 + let param = { + reseller_id: direct_reseller_ids, + }; + getProductInfoSelect(param).then((res) => { + setState({ addProductBtnLoading: false, addGoldBtnLoading: false }); + handelResponse( + res, + (req, msg) => { + // !!!!!!!!!!!!!! 为了兼容老版本 新增商品设为空!!!老版本使用 productsList 获取商品数据!!!!!!!!!! + sessionStorage.setItem("productsList", JSON.stringify(req.data)); + // !!!!!!!!!!!!!! 为了兼容老版本 新增商品设为空!!!老版本使用 productsList 获取商品数据!!!!!!!!!! + setState({ productData: null }); + setState({ + showScopePop: true, + }); + }, + (err) => { + console.log("err =>", err); + } + ); + }); } else { // 设置立减金时间 sessionStorage.setItem( @@ -877,30 +899,12 @@ const UseCouponAddEdit = forwardRef((props, ref) => { product_title: "新增立减金", addGoldBtnLoading: true, scopePopType: "addKnockGold", + productData: null, + }); + setState({ + showScopePop: true, }); } - // 第四步:获取商品数据 - let param = { - reseller_id: direct_reseller_ids, - }; - getProductInfoSelect(param).then((res) => { - setState({ addProductBtnLoading: false, addGoldBtnLoading: false }); - handelResponse( - res, - (req, msg) => { - // !!!!!!!!!!!!!! 为了兼容老版本 新增商品设为空!!!老版本使用 productsList 获取商品数据!!!!!!!!!! - sessionStorage.setItem("productsList", JSON.stringify(req.data)); - // !!!!!!!!!!!!!! 为了兼容老版本 新增商品设为空!!!老版本使用 productsList 获取商品数据!!!!!!!!!! - setState({ productData: null }); - setState({ - showScopePop: true, - }); - }, - (err) => { - console.log("err =>", err); - } - ); - }); } catch (err) { setState({ addProductBtnLoading: false, addGoldBtnLoading: false }); } @@ -920,33 +924,32 @@ const UseCouponAddEdit = forwardRef((props, ref) => { setState({ tableLoading: true, }); - // 第二步:获取商品数据 - let param = { - reseller_id: direct_reseller_ids, - }; - getProductInfoSelect(param).then((res) => { - setState({ tableLoading: false }); - handelResponse( - res, - (req, msg) => { - // 设置所有的商品数据 - sessionStorage.setItem("productsList", JSON.stringify(req.data)); - /* 区分立减金 */ - if (rowData.type === 2) { - let obj = rowData.only; - setState({ - product_title: "编辑立减金", - productData: obj, - scopePopType: "addKnockGold", - showScopePop: true, - table_index: index, - }); - } else { + // 第三步:区分是新建商品还是立减金 + /* 区分立减金 */ + if (rowData.type === 2) { + let obj = rowData.only; + setState({ + product_title: "编辑立减金", + productData: obj, + scopePopType: "addKnockGold", + showScopePop: true, + table_index: index, + }); + } else { + let param = { + reseller_id: direct_reseller_ids, + }; + getProductInfoSelect(param).then((res) => { + setState({ tableLoading: false }); + handelResponse( + res, + (req, msg) => { + // 设置所有的商品数据 + sessionStorage.setItem("productsList", JSON.stringify(req.data)); // 如果是复制删除 code_batch_id if (state.isState === "1") { delete rowData.code_batch_id; } - console.log("rowData =>", rowData); setState({ product_title: "编辑商品", productData: rowData, @@ -954,13 +957,13 @@ const UseCouponAddEdit = forwardRef((props, ref) => { showScopePop: true, table_index: index, }); + }, + (err) => { + console.log("err =>", err); } - }, - (err) => { - console.log("err =>", err); - } - ); - }); + ); + }); + } } catch (err) { setState({ tableLoading: false }); }