Commit e21f8016 authored by beisir's avatar beisir

feat: 新的分类接口

parent 52e2e6cd
......@@ -18,6 +18,7 @@ const filterCategoryOptions = (inputValue, path) =>
const FormInformationBasic = forwardRef((props, ref) => {
const {
editData,
newCategoryList,
categoryList,
virtualCategoryList,
brandList,
......@@ -95,7 +96,7 @@ const FormInformationBasic = forwardRef((props, ref) => {
placeholder="请选择商品类目!"
showSearch={{ filter: filterCategoryOptions }}
fieldNames={{ label: 'name', value: 'id', children: 'children' }}
options={customer.productType === 2 ? virtualCategoryList : categoryList}
options={newCategoryList[customer.productType]}
/>
</Form.Item>
{!customer.isCard && (
......
......@@ -17,6 +17,7 @@ import {
shopGetBySupplierId,
merchantProductAdd,
merchantProductEdit,
getByProductType,
} from './service';
import { isUrl, filterSendData, clearCurrent } from './utils';
import { ServiceContext } from './context';
......@@ -45,6 +46,7 @@ const ServiceGoods = options => {
const [brandList, setBrandList] = useState([]); // 获取商品牌
const [specList, setSpecList] = useState([]); // 规格列表
const [editData, setEditData] = useState({}); // 编辑保存数据
const [newCategoryList, setNewCategoryList] = useState({});
// const [shopList, setShopList] = useState([]); // 供应商列表
const [checkFormList] = useState([basicRef, stockRef, settingRef, settleOtrRef, picturesRef]);
......@@ -122,6 +124,18 @@ const ServiceGoods = options => {
}
};
const shopGetByProductType = async type => {
console.log(newCategoryList[type]);
if (!newCategoryList[type]?.length) {
const result = await getByProductType(type);
setNewCategoryList({
...newCategoryList,
[type]: result.data || [],
});
}
// console.log(result);
};
const submitEvent = async () => {
const checkPromiseList = clearCurrent(checkFormList).map(({ current }) => current.onCheck());
const resuslt = await Promise.all(checkPromiseList);
......@@ -179,6 +193,12 @@ const ServiceGoods = options => {
})();
}, [SourceData]);
useEffect(() => {
if (options.visible) {
shopGetByProductType(productType);
}
}, [productType, options.visible]);
const onSpecCommonImgEvent = useCallback(
keys => {
setSpecKeyList(keys);
......@@ -243,6 +263,7 @@ const ServiceGoods = options => {
<FormInformationBasic
ref={basicRef}
editData={editData.infoMation}
newCategoryList={newCategoryList}
categoryList={categoryList}
virtualCategoryList={virtualCategoryList}
brandList={brandList}
......
......@@ -92,3 +92,8 @@ export const shopGetBySupplierId = (state = 1, supplierId = 0) =>
prefix: goodsApi,
headers,
});
export const getByProductType = type =>
request.get(`/product/category/getByProductType/${type}`, {
prefix: goodsApi,
headers,
});
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