Commit e21f8016 authored by beisir's avatar beisir

feat: 新的分类接口

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