From dd6110e4d6a09e0dfcfd831dd22c9e447b625aa1 Mon Sep 17 00:00:00 2001 From: zhangds Date: Mon, 24 Oct 2022 11:23:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=96=B0=E5=BB=BA=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=B7=B2=E7=BB=8F=E9=80=89=E6=8B=A9=E7=9A=84?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/UseCouponAddEdit/index.jsx | 11 +++++++++++ src/components/UseGoodsScopePop/index.jsx | 2 ++ src/components/UseProductPop/index.jsx | 9 +++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/components/UseCouponAddEdit/index.jsx b/src/components/UseCouponAddEdit/index.jsx index 07f07002..b1aa410b 100644 --- a/src/components/UseCouponAddEdit/index.jsx +++ b/src/components/UseCouponAddEdit/index.jsx @@ -216,6 +216,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => { status: -1, statusDisabled: false, // 3未开始、1进行中、2暂停中,有数据的审核驳回 productType: 1, + checkedProduct: [], }); // 基础信息 @@ -850,6 +851,14 @@ const UseCouponAddEdit = forwardRef((props, ref) => { } }; + // 获取已经选择的商品数据(禁用商品选择) + const getCheckedProduct = () => { + console.log("state.tableData =>", state.tableData); + let arr = state.tableData.map((item) => item.product_id); + return arr; + }; + + // 新建商品 const addProduct = (type) => { try { // 第一步:获取直连天下的商品数据需要分销商 id @@ -870,6 +879,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => { setState({ product_title: "新建商品", scopePopType: "addProduct", + checkedProduct: getCheckedProduct(), // 已经选择的商品 productData: null, table_index: -1, productType: 1, @@ -1423,6 +1433,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => { productData={state.productData} onClose={() => scopePopClose()} tableData={state.tableData} + checkedProduct={state.checkedProduct} table_index={state.table_index} directResellerId={state.direct_reseller_id} productType={state.productType} diff --git a/src/components/UseGoodsScopePop/index.jsx b/src/components/UseGoodsScopePop/index.jsx index a0f99b36..23590452 100644 --- a/src/components/UseGoodsScopePop/index.jsx +++ b/src/components/UseGoodsScopePop/index.jsx @@ -19,6 +19,7 @@ const UseGoodsScopePop = forwardRef((props, ref) => { table_index, directResellerId, productType, + checkedProduct, } = props; // 如果需要 通过ref 控制此组件 放开注释 @@ -131,6 +132,7 @@ const UseGoodsScopePop = forwardRef((props, ref) => { ) : ( { - const { productData, directResellerId, productType } = props; + const { productData, checkedProduct, directResellerId, productType } = props; const formEl = useRef(null); const swiperWrapperEl = useRef(null); @@ -160,13 +160,18 @@ const UseProductPop = forwardRef((props, ref) => { setState({ productDataAll: req.data, }); - let optArr = req.data.map((item) => { return { key: item.id, text: item.title, + disabled: + checkedProduct.indexOf(item.id) !== -1 ? true : false, }; }); + console.log("opt-arr =>", optArr); + console.log("checkedProduct =>", checkedProduct); + + // 设置是否已经选择 setState({ productOption: optArr }); resolve(optArr); },