fix: 新建商品增加已经选择的不能选择
This commit is contained in:
parent
c89faffc0b
commit
dd6110e4d6
|
@ -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}
|
||||
|
|
|
@ -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) => {
|
|||
) : (
|
||||
<UseProductPop
|
||||
ref={productEl}
|
||||
checkedProduct={checkedProduct}
|
||||
productData={productData}
|
||||
directResellerId={directResellerId}
|
||||
productType={productType}
|
||||
|
|
|
@ -61,7 +61,7 @@ const formRules = {
|
|||
};
|
||||
|
||||
const UseProductPop = 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);
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue