fix: 新建商品增加已经选择的不能选择

This commit is contained in:
zhangds 2022-10-24 11:23:06 +08:00
parent c89faffc0b
commit dd6110e4d6
3 changed files with 20 additions and 2 deletions

View File

@ -216,6 +216,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
status: -1, status: -1,
statusDisabled: false, // 312 statusDisabled: false, // 312
productType: 1, 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) => { const addProduct = (type) => {
try { try {
// id // id
@ -870,6 +879,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
setState({ setState({
product_title: "新建商品", product_title: "新建商品",
scopePopType: "addProduct", scopePopType: "addProduct",
checkedProduct: getCheckedProduct(), //
productData: null, productData: null,
table_index: -1, table_index: -1,
productType: 1, productType: 1,
@ -1423,6 +1433,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
productData={state.productData} productData={state.productData}
onClose={() => scopePopClose()} onClose={() => scopePopClose()}
tableData={state.tableData} tableData={state.tableData}
checkedProduct={state.checkedProduct}
table_index={state.table_index} table_index={state.table_index}
directResellerId={state.direct_reseller_id} directResellerId={state.direct_reseller_id}
productType={state.productType} productType={state.productType}

View File

@ -19,6 +19,7 @@ const UseGoodsScopePop = forwardRef((props, ref) => {
table_index, table_index,
directResellerId, directResellerId,
productType, productType,
checkedProduct,
} = props; } = props;
// ref // ref
@ -131,6 +132,7 @@ const UseGoodsScopePop = forwardRef((props, ref) => {
) : ( ) : (
<UseProductPop <UseProductPop
ref={productEl} ref={productEl}
checkedProduct={checkedProduct}
productData={productData} productData={productData}
directResellerId={directResellerId} directResellerId={directResellerId}
productType={productType} productType={productType}

View File

@ -61,7 +61,7 @@ const formRules = {
}; };
const UseProductPop = forwardRef((props, ref) => { const UseProductPop = forwardRef((props, ref) => {
const { productData, directResellerId, productType } = props; const { productData, checkedProduct, directResellerId, productType } = props;
const formEl = useRef(null); const formEl = useRef(null);
const swiperWrapperEl = useRef(null); const swiperWrapperEl = useRef(null);
@ -160,13 +160,18 @@ const UseProductPop = forwardRef((props, ref) => {
setState({ setState({
productDataAll: req.data, productDataAll: req.data,
}); });
let optArr = req.data.map((item) => { let optArr = req.data.map((item) => {
return { return {
key: item.id, key: item.id,
text: item.title, text: item.title,
disabled:
checkedProduct.indexOf(item.id) !== -1 ? true : false,
}; };
}); });
console.log("opt-arr =>", optArr);
console.log("checkedProduct =>", checkedProduct);
//
setState({ productOption: optArr }); setState({ productOption: optArr });
resolve(optArr); resolve(optArr);
}, },