Commit c432831d authored by 皮倩雯's avatar 皮倩雯

fix: '产品配置'

parent 01139da3
Pipeline #45151 skipped with stages
...@@ -13,6 +13,43 @@ const ProductConfig = props => { ...@@ -13,6 +13,43 @@ const ProductConfig = props => {
const [flag, setFlag] = useState(1); const [flag, setFlag] = useState(1);
const [list, setList] = useState(new Set()); const [list, setList] = useState(new Set());
// 默认展示第一项 // 默认展示第一项
// useEffect(() => {
// setLoading(true);
// getProductList()
// .then(res => {
// const { code } = res;
// if (code === 0) {
// const {
// data: { AllProducts, UserProducts },
// } = res;
// // setProductList(AllProducts);
// setUserProductsList(UserProducts);
// setProductObj(AllProducts[0]);
// AllProducts.map(i => {
// list.add(i.ProductType);
// });
// let a = [];
// list.map(i => {
// a.push(i);
// });
// let aa = [];
// a.map((i, j) => {
// let ad = [];
// AllProducts.map(k => {
// if (k.ProductType == i) {
// ad.push(k);
// }
// });
// aa.push(ad);
// });
// setProductList(aa);
// }
// })
// .finally(() => {
// setLoading(false);
// });
// }, []);
useEffect(() => { useEffect(() => {
setLoading(true); setLoading(true);
getProductList() getProductList()
...@@ -24,46 +61,9 @@ const ProductConfig = props => { ...@@ -24,46 +61,9 @@ const ProductConfig = props => {
} = res; } = res;
// setProductList(AllProducts); // setProductList(AllProducts);
setUserProductsList(UserProducts); setUserProductsList(UserProducts);
if (!productObj && AllProducts.length > 0) {
setProductObj(AllProducts[0]); setProductObj(AllProducts[0]);
AllProducts.map(i => {
list.add(i.ProductType);
});
let a = [];
list.map(i => {
a.push(i);
});
let aa = [];
a.map((i, j) => {
let ad = [];
AllProducts.map(k => {
if (k.ProductType == i) {
ad.push(k);
}
});
aa.push(ad);
});
setProductList(aa);
} }
})
.finally(() => {
setLoading(false);
});
}, []);
useEffect(() => {
setLoading(true);
getProductList()
.then(res => {
const { code } = res;
if (code === 0) {
const {
data: { AllProducts, UserProducts },
} = res;
// setProductList(AllProducts);
setUserProductsList(UserProducts);
// if (!productObj && data.length > 0) {
// setProductObj(data[0]);
// }
// setProductList(data); // setProductList(data);
AllProducts.map(i => { AllProducts.map(i => {
list.add(i.ProductType); list.add(i.ProductType);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment