Commit 94dbfc8f authored by 武广's avatar 武广

Merge branch 'feature/goods-list' of git.quantgroup.cn:ui/merchant-manage-ui...

Merge branch 'feature/goods-list' of git.quantgroup.cn:ui/merchant-manage-ui into feature/20230327_public_takeaway
parents 81418c5b e81eac28
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect, forwardRef, useImperativeHandle } from 'react';
import { Button, Select, Tag } from 'antd'; import { Button, Select, Tag } from 'antd';
import { DndProvider } from 'react-dnd'; import { DndProvider } from 'react-dnd';
import HTML5Backend from 'react-dnd-html5-backend'; import HTML5Backend from 'react-dnd-html5-backend';
...@@ -8,7 +8,7 @@ import InsertTag from './InsertTag'; ...@@ -8,7 +8,7 @@ import InsertTag from './InsertTag';
import GroupInfo from './GroupInfo'; import GroupInfo from './GroupInfo';
import { apiDelStorage, apiSortStorage, apiStorageList, apiSupplierShopList } from '../../service'; import { apiDelStorage, apiSortStorage, apiStorageList, apiSupplierShopList } from '../../service';
const GoodsGroup = options => { const GoodsGroup = forwardRef((options, ref) => {
const [groupEdit, setGroupEdit] = useState(false); const [groupEdit, setGroupEdit] = useState(false);
const [selected, setSelected] = useState(0); const [selected, setSelected] = useState(0);
const [storageId, setStorageId] = useState(0); const [storageId, setStorageId] = useState(0);
...@@ -110,6 +110,10 @@ const GoodsGroup = options => { ...@@ -110,6 +110,10 @@ const GoodsGroup = options => {
options.changeGroup(selected); options.changeGroup(selected);
}, [selected]); }, [selected]);
useImperativeHandle(ref, () => ({
setSelected,
}));
return ( return (
<div className={styles.groupBox}> <div className={styles.groupBox}>
{(shops && shops.length && ( {(shops && shops.length && (
...@@ -182,6 +186,6 @@ const GoodsGroup = options => { ...@@ -182,6 +186,6 @@ const GoodsGroup = options => {
/> />
</div> </div>
); );
}; });
export default GoodsGroup; export default GoodsGroup;
import React, { useState, useEffect, useCallback, useMemo } from 'react'; import React, { useState, useEffect, useRef } from 'react';
import { Spin, Table, Pagination, message, notification } from 'antd'; import { Spin, Table, Pagination, message, notification } from 'antd';
import { unstable_batchedUpdates } from 'react-dom'; import { unstable_batchedUpdates } from 'react-dom';
import { SortableContainer, SortableElement, SortableHandle } from 'react-sortable-hoc'; import { SortableContainer, SortableElement, SortableHandle } from 'react-sortable-hoc';
...@@ -39,6 +39,8 @@ const Takeaway = options => { ...@@ -39,6 +39,8 @@ const Takeaway = options => {
const [visibleSwitchGroup, setVisibleSwitchGroup] = useState(false); const [visibleSwitchGroup, setVisibleSwitchGroup] = useState(false);
const [scribeToken, setScribeToken] = useState(''); const [scribeToken, setScribeToken] = useState('');
const groupRef = useRef(null);
const rowSelection = { const rowSelection = {
selectedRowKeys, selectedRowKeys,
onChange: setSelectedRowKeys, onChange: setSelectedRowKeys,
...@@ -184,11 +186,16 @@ const Takeaway = options => { ...@@ -184,11 +186,16 @@ const Takeaway = options => {
useEffect(() => { useEffect(() => {
const stoken = PubSub.subscribe('refreshTakeAway', (_, data) => { const stoken = PubSub.subscribe('refreshTakeAway', (_, data) => {
setShopId(data.shopId); console.log('refreshTakeAway :>> ', data);
setGroupId(data.groupId); if (data.groupId && groupId !== data.groupId) {
getDataList(0, pageSize, data.groupId); setGroupId(data.groupId);
if (groupRef.current) {
groupRef.current.setSelected(`${data.groupId}`);
}
}
}); });
setScribeToken(stoken); setScribeToken(stoken);
return () => { return () => {
PubSub.unsubscribe(scribeToken); PubSub.unsubscribe(scribeToken);
}; };
...@@ -208,7 +215,12 @@ const Takeaway = options => { ...@@ -208,7 +215,12 @@ const Takeaway = options => {
return ( return (
<div className={styles.takeawayBox}> <div className={styles.takeawayBox}>
<Spin spinning={loading}> <Spin spinning={loading}>
<GoodsGroup shopId={shopId} changeShop={setShopId} changeGroup={setGroupId} /> <GoodsGroup
ref={groupRef}
shopId={shopId}
changeShop={setShopId}
changeGroup={setGroupId}
/>
{(shopId && ( {(shopId && (
<ActionBar <ActionBar
selectedRowKeys={selectedRowKeys} selectedRowKeys={selectedRowKeys}
......
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