Commit 6bf82f45 authored by XieZhiXiong's avatar XieZhiXiong

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

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