fix: 新建商品增加已经选择的不能选择
This commit is contained in:
parent
c89faffc0b
commit
dd6110e4d6
|
@ -216,6 +216,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
||||||
status: -1,
|
status: -1,
|
||||||
statusDisabled: false, // 3未开始、1进行中、2暂停中,有数据的审核驳回
|
statusDisabled: false, // 3未开始、1进行中、2暂停中,有数据的审核驳回
|
||||||
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}
|
||||||
|
|
|
@ -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}
|
||||||
|
|
|
@ -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);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue