盲改通知中心与下载中心的左侧菜单字典
This commit is contained in:
@ -3,19 +3,18 @@ import { Card, Menu, Row, Col, Pagination, Button, Typography, Space, message }
|
|||||||
import { FileOutlined, BookOutlined, DownloadOutlined } from '@ant-design/icons';
|
import { FileOutlined, BookOutlined, DownloadOutlined } from '@ant-design/icons';
|
||||||
import { useIntl, FormattedMessage } from 'umi';
|
import { useIntl, FormattedMessage } from 'umi';
|
||||||
import styles from './download.less';
|
import styles from './download.less';
|
||||||
import { downloadFile, getDownloadList, DownloadRecord } from '@/servers/api/download';
|
import { getDownloadList } from '@/servers/api/download';
|
||||||
|
import type { DownloadRecord } from '@/servers/api/download';
|
||||||
|
import { getDictList } from '@/servers/api/dict';
|
||||||
|
import type { DictItem } from '@/servers/api/dict';
|
||||||
|
|
||||||
const { Title, Text } = Typography;
|
const { Title, Text } = Typography;
|
||||||
|
|
||||||
// 模拟模板文件数据 - 后期将通过API获取分类
|
|
||||||
const mockCategories: { [key: string]: string } = {
|
|
||||||
template: '模板文件',
|
|
||||||
manual: '操作手册'
|
|
||||||
};
|
|
||||||
|
|
||||||
const DownloadPage: React.FC = () => {
|
const DownloadPage: React.FC = () => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const [activeMenu, setActiveMenu] = useState<string>('template');
|
const [activeMenu, setActiveMenu] = useState<string>('template');
|
||||||
|
const [menuList, setMenuList] = useState<DictItem[]>([]);
|
||||||
const [downloadData, setDownloadData] = useState<DownloadRecord[]>([]);
|
const [downloadData, setDownloadData] = useState<DownloadRecord[]>([]);
|
||||||
const [loading, setLoading] = useState<boolean>(true);
|
const [loading, setLoading] = useState<boolean>(true);
|
||||||
const [pagination, setPagination] = useState({
|
const [pagination, setPagination] = useState({
|
||||||
@ -55,6 +54,15 @@ const DownloadPage: React.FC = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 获取下载中心左侧菜单字典
|
||||||
|
useEffect(() => {
|
||||||
|
getDictList('download_section').then((res) => {
|
||||||
|
if (res.code === 200 && res.success) {
|
||||||
|
setMenuList(res.data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
// 初始加载和分页变化时加载数据
|
// 初始加载和分页变化时加载数据
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadDownloadData(pagination.current, pagination.pageSize);
|
loadDownloadData(pagination.current, pagination.pageSize);
|
||||||
@ -105,12 +113,11 @@ const DownloadPage: React.FC = () => {
|
|||||||
onClick={handleMenuClick}
|
onClick={handleMenuClick}
|
||||||
className={styles.downloadMenu}
|
className={styles.downloadMenu}
|
||||||
>
|
>
|
||||||
<Menu.Item key="template" icon={<FileOutlined />}>
|
{menuList.map((item) => (
|
||||||
<FormattedMessage id="download.menu.template" />
|
<Menu.Item key={item.code} icon={<FileOutlined />}>
|
||||||
</Menu.Item>
|
{item.dicName}
|
||||||
<Menu.Item key="manual" icon={<BookOutlined />}>
|
|
||||||
<FormattedMessage id="download.menu.manual" />
|
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
|
))}
|
||||||
</Menu>
|
</Menu>
|
||||||
</Col>
|
</Col>
|
||||||
|
|
||||||
|
@ -3,17 +3,16 @@ import { Table, Menu, Row, Col, message } from 'antd';
|
|||||||
import { history, useIntl, FormattedMessage } from 'umi';
|
import { history, useIntl, FormattedMessage } from 'umi';
|
||||||
import { BellOutlined, AppstoreOutlined } from '@ant-design/icons';
|
import { BellOutlined, AppstoreOutlined } from '@ant-design/icons';
|
||||||
import styles from './notice.less';
|
import styles from './notice.less';
|
||||||
import { getNoticeList, NoticeRecord } from '@/servers/api/notice';
|
import { getNoticeList } from '@/servers/api/notice';
|
||||||
|
import type { NoticeRecord } from '@/servers/api/notice';
|
||||||
|
import { getDictList } from '@/servers/api/dict';
|
||||||
|
import type { DictItem } from '@/servers/api/dict';
|
||||||
|
|
||||||
// 通知类型映射
|
|
||||||
const noticeTypes: { [key: string]: string } = {
|
|
||||||
system: '系统更新通知',
|
|
||||||
other: '其他通知'
|
|
||||||
};
|
|
||||||
|
|
||||||
const NoticePage: React.FC = () => {
|
const NoticePage: React.FC = () => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const [activeMenu, setActiveMenu] = useState<string>('system');
|
const [activeMenu, setActiveMenu] = useState<string>('system');
|
||||||
|
const [menuList, setMenuList] = useState<DictItem[]>([]);
|
||||||
const [noticeData, setNoticeData] = useState<NoticeRecord[]>([]);
|
const [noticeData, setNoticeData] = useState<NoticeRecord[]>([]);
|
||||||
const [loading, setLoading] = useState<boolean>(true);
|
const [loading, setLoading] = useState<boolean>(true);
|
||||||
const [pagination, setPagination] = useState({
|
const [pagination, setPagination] = useState({
|
||||||
@ -53,6 +52,15 @@ const NoticePage: React.FC = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 获取通知中心左侧菜单字典
|
||||||
|
useEffect(() => {
|
||||||
|
getDictList('notification_center').then((res) => {
|
||||||
|
if (res.code === 200 && res.success) {
|
||||||
|
setMenuList(res.data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
// 初始加载和分页变化时加载数据
|
// 初始加载和分页变化时加载数据
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadNoticeData(pagination.current, pagination.pageSize);
|
loadNoticeData(pagination.current, pagination.pageSize);
|
||||||
@ -121,12 +129,11 @@ const NoticePage: React.FC = () => {
|
|||||||
onClick={handleMenuClick}
|
onClick={handleMenuClick}
|
||||||
className={styles.noticeMenu}
|
className={styles.noticeMenu}
|
||||||
>
|
>
|
||||||
<Menu.Item key="system" icon={<AppstoreOutlined />}>
|
{menuList.map((item) => (
|
||||||
<FormattedMessage id="notice.menu.system" />
|
<Menu.Item key={item.code} icon={<AppstoreOutlined />}>
|
||||||
</Menu.Item>
|
{item.dicName}
|
||||||
<Menu.Item key="other" icon={<BellOutlined />}>
|
|
||||||
<FormattedMessage id="notice.menu.other" />
|
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
|
))}
|
||||||
</Menu>
|
</Menu>
|
||||||
</Col>
|
</Col>
|
||||||
|
|
||||||
|
45
src/servers/api/dict.ts
Normal file
45
src/servers/api/dict.ts
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import request from '@/utils/request';
|
||||||
|
|
||||||
|
// 定义接口返回数据类型
|
||||||
|
export type DictResponse = {
|
||||||
|
code: number;
|
||||||
|
data: DictItem[];
|
||||||
|
message: string;
|
||||||
|
success: boolean;
|
||||||
|
[property: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type DictItem = {
|
||||||
|
basePageRequest: null;
|
||||||
|
code: string;
|
||||||
|
createBy: null;
|
||||||
|
createDate: null;
|
||||||
|
defaultFlag: null;
|
||||||
|
deleteFlag: null;
|
||||||
|
description: string;
|
||||||
|
dicName: string;
|
||||||
|
dictTypeCode: null | string;
|
||||||
|
dictTypeName: null | string;
|
||||||
|
id: string;
|
||||||
|
lastUpdateTime: null;
|
||||||
|
orderFlag: string;
|
||||||
|
parentCode: string;
|
||||||
|
parentType: string;
|
||||||
|
tenantId: null;
|
||||||
|
tenantName: null;
|
||||||
|
updateBy: null;
|
||||||
|
updateDate: null;
|
||||||
|
useFlag: string;
|
||||||
|
[property: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取字典列表
|
||||||
|
* @param code 字典编码
|
||||||
|
* @returns 字典列表
|
||||||
|
*/
|
||||||
|
export async function getDictList(code: string): Promise<DictResponse> {
|
||||||
|
return request(`/cosco/dictProject/getAllList/${code}`, {
|
||||||
|
method: 'GET',
|
||||||
|
});
|
||||||
|
}
|
Reference in New Issue
Block a user