Commit 6bf82f45 authored by XieZhiXiong's avatar XieZhiXiong

chore: 跟进或者商品列表相关

parent 14712a2d
......@@ -2,20 +2,27 @@
* @Author: XieZhiXiong
* @Date: 2021-06-24 16:11:55
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-07-28 14:13:43
* @LastEditTime: 2021-07-30 10:10:15
* @Description: 商品选择抽屉
*/
import React, { useEffect } from 'react';
import { Drawer, Button, message } from 'antd';
import { FormEffectHooks } from '@formily/antd';
import { PublicApi } from '@/services/api';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { useRowSelectionTable } from '@/hooks/useRowSelectionTable';
import { useLinkageUtils } from '@/utils/formEffectUtils';
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect';
import PolymericTable, { EditableColumns, FetchParamsType } from '@/components/PolymericTable';
import { normalizeUnitPrice } from '../../../utils';
import { querySchema } from './schema';
import styles from './index.less';
const {
onFormInit$,
} = FormEffectHooks;
export type ProductItemType = {
/**
* 数据id
......@@ -78,9 +85,17 @@ interface IProps {
type ExtraFetchType = FetchParamsType & {
/**
* 商城id
* 商品名称
*/
commodityName?: string,
/**
* 会员品类id
*/
shopId: number,
customerCategoryId?: number,
/**
* 品牌id
*/
brandId?: number,
}
const GoodsDrawer: React.FC<IProps> = (props) => {
......@@ -101,11 +116,14 @@ const GoodsDrawer: React.FC<IProps> = (props) => {
}, [checkeds]);
const fetchData = async (params: ExtraFetchType) => {
const res = await PublicApi.getProductCommodityGetCommoditySkuListByShopId({
if (!shopIds || !shopIds.length) {
return;
}
const res = await PublicApi.postProductCommodityGetCommoditySkuListByShopId({
...params,
current: `${params.current}`,
pageSize: `${params.pageSize}`,
shopId: `${shopIds[0] || ''}`,
shopIdList: shopIds,
}, {
ctlType: 'none',
});
if (res.code === 1000) {
return res.data;
......@@ -174,6 +192,26 @@ const GoodsDrawer: React.FC<IProps> = (props) => {
}
};
// 获取品牌
const fetchBrand = async (name = '') => {
const res = await PublicApi.getProductSelectGetSelectBrand({
name,
});
if (res.code === 1000) {
return res.data;
}
return [];
}
// 获取会员品类
const fetchCustomerCategory = async () => {
const res = await PublicApi.getProductCustomerGetCustomerCategoryTree();
if (res.code === 1000) {
return res.data;
}
return [];
}
return (
<Drawer
title="选择适用商品"
......@@ -205,12 +243,25 @@ const GoodsDrawer: React.FC<IProps> = (props) => {
searchFormProps={{
schema: querySchema,
effects: ($, actions) => {
const linkage = useLinkageUtils();
useStateFilterSearchLinkageEffect(
$,
actions,
'name',
FORM_FILTER_PATH,
);
useAsyncSelect('brandId', fetchBrand, ['name', 'id']);
onFormInit$().subscribe(() => {
// 初始化远程检索逻辑
fetchCustomerCategory().then(res => {
linkage.componentProps('customerCategoryId', {
dataoption: res,
});
});
});
},
}}
full
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-06-24 16:19:18
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-07-28 10:54:23
* @LastEditTime: 2021-07-30 10:06:32
* @Description:
*/
import { ISchema } from '@formily/antd';
......@@ -34,20 +34,36 @@ export const querySchema: ISchema = {
columns: 6,
},
properties: {
category: {
customerCategoryId: {
type: 'string',
'x-component': 'CustomCategorySearch',
'x-component-props': {
placeholder: '商品品类',
allowClear: true,
showSearch: true,
notFoundContent: null,
dataoption: [],
fieldNames: { label: 'title', value: 'id', children: 'children' },
changeOnSelect: true,
expandTrigger: 'hover',
},
},
brand: {
brandId: {
type: 'string',
'x-component-props': {
placeholder: '商品品牌',
allowClear: true,
},
},
submit: {
type: 'string',
'x-component': 'Submit',
'x-mega-props': {
span: 1,
},
'x-component-props': {
children: '查询',
},
},
},
},
},
......
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