Commit 97e42a3b authored by 武广's avatar 武广

fix: 修改获取企业餐段问题

parent 10f7fb21
...@@ -65,7 +65,7 @@ export const takeawayGoodsColumn = options => { ...@@ -65,7 +65,7 @@ export const takeawayGoodsColumn = options => {
hideInTable: true, hideInTable: true,
valueType: 'select', valueType: 'select',
fieldProps: { fieldProps: {
value: +enterpriseId, value: enterpriseId ? +enterpriseId : null,
showSearch: true, showSearch: true,
filterOption: (v, option) => (option?.label ?? '').toLowerCase().includes(v.toLowerCase()), filterOption: (v, option) => (option?.label ?? '').toLowerCase().includes(v.toLowerCase()),
onChange: onChangeEnterprise, onChange: onChangeEnterprise,
...@@ -484,7 +484,7 @@ export const virtualGoodsColumn = options => { ...@@ -484,7 +484,7 @@ export const virtualGoodsColumn = options => {
hideInTable: true, hideInTable: true,
valueType: 'select', valueType: 'select',
fieldProps: { fieldProps: {
value: +enterpriseId, value: enterpriseId ? +enterpriseId : null,
showSearch: true, showSearch: true,
filterOption: (v, option) => (option?.label ?? '').toLowerCase().includes(v.toLowerCase()), filterOption: (v, option) => (option?.label ?? '').toLowerCase().includes(v.toLowerCase()),
onChange: onChangeEnterprise, onChange: onChangeEnterprise,
......
...@@ -27,9 +27,9 @@ const TakeawayGoods = () => { ...@@ -27,9 +27,9 @@ const TakeawayGoods = () => {
const [visibleSaleSection, setVisibleSaleSection] = useState(false); // 可售餐段弹窗 const [visibleSaleSection, setVisibleSaleSection] = useState(false); // 可售餐段弹窗
const [visiblePrice, setVisiblePrice] = useState(false); // 修改企业商品价格弹窗 const [visiblePrice, setVisiblePrice] = useState(false); // 修改企业商品价格弹窗
const [visibleSort, setVisibleSort] = useState(false); // 商品排序弹窗 const [visibleSort, setVisibleSort] = useState(false); // 商品排序弹窗
const [enterprises, setEnterprises] = useState({}); // 企业列表 const [enterprises, setEnterprises] = useState(null); // 企业列表
const [activeKey, setActiveKey] = useState(''); // 自提点ID const [activeKey, setActiveKey] = useState(''); // 自提点ID
const [enterpriseId, setEnterpriseId] = useState(); // 企业ID const [enterpriseId, setEnterpriseId] = useState(''); // 企业ID
const [pickSelfList, setPickSelfList] = useState([]); // 取餐点列表 const [pickSelfList, setPickSelfList] = useState([]); // 取餐点列表
const [recordID, setRecordID] = useState(''); // 编辑的记录ID const [recordID, setRecordID] = useState(''); // 编辑的记录ID
const [editItem, setEditItem] = useState({}); // 编辑的记录信息 const [editItem, setEditItem] = useState({}); // 编辑的记录信息
...@@ -137,8 +137,10 @@ const TakeawayGoods = () => { ...@@ -137,8 +137,10 @@ const TakeawayGoods = () => {
setEnterprises(obj.list); setEnterprises(obj.list);
setEnterpriseId(`${obj.id}`); setEnterpriseId(`${obj.id}`);
await getPickSelf(obj.id); await getPickSelf(obj.id);
setPageLoaded(true); } else if (!enterpriseId) {
notification.error({ message: '未找到企业' });
} }
setPageLoaded(true);
}; };
useEffect(() => { useEffect(() => {
...@@ -160,6 +162,14 @@ const TakeawayGoods = () => { ...@@ -160,6 +162,14 @@ const TakeawayGoods = () => {
onRefresh, onRefresh,
}; };
let request = () => ({
data: [],
total: 0,
});
if (enterpriseId) {
request = params => searchList({ ...params });
}
return ( return (
<div className={utilStyle.formPageBox}> <div className={utilStyle.formPageBox}>
{pageLoaded && ( {pageLoaded && (
...@@ -173,7 +183,7 @@ const TakeawayGoods = () => { ...@@ -173,7 +183,7 @@ const TakeawayGoods = () => {
actionRef={refTable} actionRef={refTable}
tableClassName={utilStyle.formTable} tableClassName={utilStyle.formTable}
columns={takeawayGoodsColumn(options)} columns={takeawayGoodsColumn(options)}
request={params => searchList({ ...params })} request={request}
rowKey={r => r.id} rowKey={r => r.id}
bordered bordered
options={false} options={false}
......
...@@ -14,8 +14,8 @@ const VirtualGoods = () => { ...@@ -14,8 +14,8 @@ const VirtualGoods = () => {
const history = useHistory(); const history = useHistory();
const refTable = useRef(); const refTable = useRef();
const [pageLoaded, setPageLoaded] = useState(false); const [pageLoaded, setPageLoaded] = useState(false);
const [enterprises, setEnterprises] = useState({}); // 企业列表 const [enterprises, setEnterprises] = useState(null); // 企业列表
const [enterpriseId, setEnterpriseId] = useState(); const [enterpriseId, setEnterpriseId] = useState(''); // 选中企业ID
// 刷新列表 // 刷新列表
const onRefresh = () => { const onRefresh = () => {
...@@ -90,8 +90,10 @@ const VirtualGoods = () => { ...@@ -90,8 +90,10 @@ const VirtualGoods = () => {
if (obj.list && Object.keys(obj.list).length) { if (obj.list && Object.keys(obj.list).length) {
setEnterprises(obj.list); setEnterprises(obj.list);
setEnterpriseId(`${obj.id}`); setEnterpriseId(`${obj.id}`);
setPageLoaded(true); } else if (!enterpriseId) {
notification.error({ message: '未找到企业' });
} }
setPageLoaded(true);
}; };
useEffect(() => { useEffect(() => {
...@@ -105,7 +107,10 @@ const VirtualGoods = () => { ...@@ -105,7 +107,10 @@ const VirtualGoods = () => {
onChangeEnterprise, onChangeEnterprise,
}; };
let request = () => []; let request = () => ({
data: [],
total: 0,
});
if (enterpriseId) { if (enterpriseId) {
request = params => searchList({ ...params }); request = params => searchList({ ...params });
} }
......
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