1:首页优化 2:首页适配手机

This commit is contained in:
2025-10-14 16:27:25 +08:00
parent f6b02a9bd9
commit ba366587f4
6 changed files with 54 additions and 29 deletions
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react';
import { Space, Button, TreeSelect, Checkbox, message } from 'antd';
import { Space, Button, TreeSelect, Checkbox, message, Grid } from 'antd';
import { tenantApi } from '@/services/tenant';
interface TenantNode {
@@ -19,6 +19,8 @@ interface Props {
}
const TenantScopeFilter: React.FC<Props> = ({ onChanged, useSwitchTenant = false, autoApply = false }) => {
const screens = Grid.useBreakpoint();
const isMobile = !screens.md;
const [tree, setTree] = useState<TenantNode[]>([]);
const [tenantId, setTenantId] = useState<string | undefined>();
const [includeChildren, setIncludeChildren] = useState<boolean>(true);
@@ -41,7 +43,7 @@ const TenantScopeFilter: React.FC<Props> = ({ onChanged, useSwitchTenant = false
const curId = curRes?.data?.tenantId || (curRes?.resp_code === 0 ? curRes?.data?.tenantId : undefined);
if (curId) setTenantId(curId);
} catch {
// 忽略错误,展示空树
// 忽略错误,展示空
} finally {
setLoading(false);
}
@@ -82,13 +84,15 @@ const TenantScopeFilter: React.FC<Props> = ({ onChanged, useSwitchTenant = false
};
return (
<Space>
<Space direction={isMobile ? 'vertical' : 'horizontal'} style={{ width: isMobile ? '100%' : 'auto' }}>
<TreeSelect
style={{ minWidth: 260 }}
style={{ minWidth: isMobile ? 0 : 260, width: isMobile ? '100%' : undefined }}
showSearch
loading={loading}
treeNodeFilterProp="title"
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
dropdownMatchSelectWidth
getPopupContainer={(trigger) => (trigger?.parentElement as HTMLElement) || document.body}
placeholder="选择租户(含子租户)"
value={tenantId}
onChange={(val) => setTenantId(val)}
@@ -96,11 +100,10 @@ const TenantScopeFilter: React.FC<Props> = ({ onChanged, useSwitchTenant = false
/>
<Checkbox checked={includeChildren} onChange={(e) => setIncludeChildren(e.target.checked)}>包含子租户</Checkbox>
{!autoApply && (
<Button type="primary" onClick={handleApply}>应用</Button>
<Button type="primary" size={isMobile ? 'small' : 'middle'} onClick={handleApply}>应用</Button>
)}
</Space>
);
};
export default TenantScopeFilter;