|
@@ -2,7 +2,7 @@
|
|
|
* @Author: code4eat awesomedema@gmail.com
|
|
|
* @Date: 2022-12-14 14:14:32
|
|
|
* @LastEditors: code4eat awesomedema@gmail.com
|
|
|
- * @LastEditTime: 2024-03-28 18:02:27
|
|
|
+ * @LastEditTime: 2024-06-11 16:15:45
|
|
|
* @FilePath: /BudgetManaSystem/src/app.ts
|
|
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
|
*/
|
|
@@ -15,7 +15,7 @@
|
|
|
|
|
|
|
|
|
import { AxiosResponse, history } from '@umijs/max';
|
|
|
-import { message, notification, Modal } from 'antd';
|
|
|
+import { message, notification, Modal, Menu } from 'antd';
|
|
|
import type { RequestConfig } from 'umi';
|
|
|
|
|
|
import iconEnum from './menuIcons.js';
|
|
@@ -34,6 +34,7 @@ import { Key, useEffect, useState } from 'react';
|
|
|
import './utils/zhongtaiC'
|
|
|
import { RuntimeAntdConfig } from '@umijs/max';
|
|
|
import { useLocation } from '@umijs/max';
|
|
|
+import ResizableContainer from './components/ResizableContainer/index';
|
|
|
|
|
|
|
|
|
const IconFont = createFromIconfontCN({
|
|
@@ -67,6 +68,62 @@ interface UserData {
|
|
|
youshuToken?: string
|
|
|
}
|
|
|
|
|
|
+interface TransformResult {
|
|
|
+ newTree: any[];
|
|
|
+ firstLeafNode: any | null;
|
|
|
+ firstLeafNodePath: any[];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+function transformTree(tree: any[]): TransformResult {
|
|
|
+ let firstLeafNode: any | null = null;
|
|
|
+ let firstLeafNodePath: any[] = [];
|
|
|
+
|
|
|
+ function traverse(node: any, path: any[]): any {
|
|
|
+ const newNode: any = {
|
|
|
+ ...node,
|
|
|
+ label: node.name,
|
|
|
+ };
|
|
|
+
|
|
|
+ const newPath = [...path, newNode];
|
|
|
+
|
|
|
+ if (node.children && node.children.length > 0) {
|
|
|
+ newNode.children = node.children.map((child: any) => traverse(child, newPath));
|
|
|
+ } else {
|
|
|
+ if (!firstLeafNode) {
|
|
|
+ firstLeafNode = newNode;
|
|
|
+ firstLeafNodePath = newPath;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Remove children property if it is an empty array
|
|
|
+ if (node.children && node.children.length === 0) {
|
|
|
+ newNode.children = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ return newNode;
|
|
|
+ }
|
|
|
+
|
|
|
+ const newTree = tree.map(node => traverse(node, []));
|
|
|
+
|
|
|
+ return { newTree, firstLeafNode, firstLeafNodePath };
|
|
|
+}
|
|
|
+
|
|
|
+const findItemByKey: any = (tree: any[], key: string, keyName: string) => {
|
|
|
+ for (const node of tree) {
|
|
|
+ if (node[`${keyName}`] === key) {
|
|
|
+ return node;
|
|
|
+ }
|
|
|
+ if (node.children) {
|
|
|
+ const result = findItemByKey(node.children, key, keyName);
|
|
|
+ if (result) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
|
|
|
export async function getInitialState(): Promise<{
|
|
@@ -134,7 +191,7 @@ export const request: RequestConfig = {
|
|
|
if (status == 200) {
|
|
|
// 网络请求成功
|
|
|
if (errorMessage && errorMessage.indexOf('Token') != -1) {
|
|
|
- console.log({response,errorMessage});
|
|
|
+ console.log({ response, errorMessage });
|
|
|
localStorage.removeItem('tokenExpired');
|
|
|
|
|
|
return false;
|
|
@@ -152,10 +209,12 @@ export const request: RequestConfig = {
|
|
|
|
|
|
} else {
|
|
|
notification.error({
|
|
|
- message: '',
|
|
|
+ top:72,
|
|
|
+ message: '提示',
|
|
|
description: errorMessage || msg,
|
|
|
placement: 'topRight',
|
|
|
- icon: <></>
|
|
|
+ icon:<IconFont type="icon-jinggaotishi" />,
|
|
|
+ style:{padding:16,borderRadius:8}
|
|
|
})
|
|
|
return false
|
|
|
}
|
|
@@ -170,10 +229,12 @@ export const request: RequestConfig = {
|
|
|
} else {
|
|
|
|
|
|
notification.error({
|
|
|
- message: '',
|
|
|
+ top:72,
|
|
|
+ message: '提示',
|
|
|
description: errorMessage || msg,
|
|
|
placement: 'topRight',
|
|
|
- icon: <></>
|
|
|
+ icon:<IconFont type="icon-jinggaotishi" />,
|
|
|
+ style:{padding:16,borderRadius:8}
|
|
|
})
|
|
|
return false;
|
|
|
}
|
|
@@ -273,7 +334,7 @@ export function patchClientRoutes({ routes }: { routes: any }) {
|
|
|
lanhuPagePaths.forEach((a: any) => {
|
|
|
treeData.routes.push(a);
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
if (treeData.routes && treeData.routes.length > 0) {
|
|
|
treeData.routes.forEach((a: any) => {
|
|
@@ -283,10 +344,10 @@ export function patchClientRoutes({ routes }: { routes: any }) {
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
treeLoop(routes[0]);
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -296,85 +357,245 @@ export function patchClientRoutes({ routes }: { routes: any }) {
|
|
|
export const layout = ({ initialState, setInitialState }: { initialState: any, setInitialState: any }) => {
|
|
|
|
|
|
const { isCollapsed } = initialState;
|
|
|
- const [openKeys, set_openKeys] = useState<string[]>([]);
|
|
|
- const [selectedKeys, set_selectedKeys] = useState<string[]>([]);
|
|
|
+
|
|
|
const location = useLocation();
|
|
|
const currentPath = location.pathname;
|
|
|
- const [menuData,set_menuData] = useState<any[]>([]);
|
|
|
|
|
|
const onCollapse = (isCollapsed: boolean): void => {
|
|
|
setInitialState({ ...initialState, isCollapsed }).then();
|
|
|
};
|
|
|
|
|
|
|
|
|
- useEffect(()=>{
|
|
|
-
|
|
|
- function findMenuItemByPath(menu:any, path:string) {
|
|
|
- let result:any = null;
|
|
|
-
|
|
|
- // 递归搜索函数
|
|
|
- function search(items:any) {
|
|
|
- for (let item of items) {
|
|
|
- if (item.path === path) {
|
|
|
- result = item;
|
|
|
- return; // 找到匹配项,提前终止搜索
|
|
|
- }
|
|
|
- if (item.children && item.children.length > 0) {
|
|
|
- search(item.children); // 递归搜索子菜单
|
|
|
- if (result) return; // 如果在子菜单中找到匹配项,提前终止搜索
|
|
|
- }
|
|
|
- }
|
|
|
+ useEffect(() => {
|
|
|
+
|
|
|
+ function findMenuItemByPath(menu: any, path: string) {
|
|
|
+ let result: any = null;
|
|
|
+
|
|
|
+ // 递归搜索函数
|
|
|
+ function search(items: any) {
|
|
|
+ for (let item of items) {
|
|
|
+ if (item.path === path) {
|
|
|
+ result = item;
|
|
|
+ return; // 找到匹配项,提前终止搜索
|
|
|
+ }
|
|
|
+ if (item.children && item.children.length > 0) {
|
|
|
+ search(item.children); // 递归搜索子菜单
|
|
|
+ if (result) return; // 如果在子菜单中找到匹配项,提前终止搜索
|
|
|
}
|
|
|
-
|
|
|
- search(menu); // 从顶层菜单开始搜索
|
|
|
- return result;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- const matchedItem = findMenuItemByPath(menuData, currentPath);
|
|
|
- if (matchedItem) {
|
|
|
-
|
|
|
- set_selectedKeys([matchedItem.key]);
|
|
|
- }
|
|
|
+ search(menu); // 从顶层菜单开始搜索
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
- },[currentPath])
|
|
|
+ // const matchedItem = findMenuItemByPath(menuData, currentPath);
|
|
|
+ // if (matchedItem) {
|
|
|
+
|
|
|
+ // set_selectedKeys([matchedItem.key]);
|
|
|
+ // }
|
|
|
+
|
|
|
+ }, [currentPath])
|
|
|
|
|
|
|
|
|
return {
|
|
|
menuHeaderRender: false,
|
|
|
- token: {
|
|
|
- sider: {
|
|
|
+ // token: {
|
|
|
+ // sider: {
|
|
|
+
|
|
|
+ // colorMenuBackground: '#fff',
|
|
|
+ // colorTextMenuActive: '#3376FE',
|
|
|
+ // colorTextMenuSelected: '#3376FE',
|
|
|
+ // colorTextMenuTitle: '#17181A',
|
|
|
+ // colorTextMenu: '#17181A',
|
|
|
+ // //colorBgMenuItemHover:'##f0f2f5',
|
|
|
+ // colorBgMenuItemSelected: '#F2F6FF',
|
|
|
+
|
|
|
+ // // colorBgMenuItemCollapsedHover:'#f0f2f5',
|
|
|
+ // // //colorBgMenuItemCollapsedSelected:'blue'
|
|
|
+
|
|
|
+ // }
|
|
|
+
|
|
|
+ // },
|
|
|
+
|
|
|
+ disableMobile: true,
|
|
|
+ // menuProps: {
|
|
|
+ // openKeys: [...openKeys],
|
|
|
+ // selectedKeys: [...selectedKeys],
|
|
|
+ // onSelect: ({ selectedKeys }: { selectedKeys: string[] }) => {
|
|
|
+ // set_selectedKeys(selectedKeys);
|
|
|
+ // localStorage.setItem('selectedKeys', JSON.stringify(selectedKeys));
|
|
|
+ // },
|
|
|
+ // onOpenChange: (keys: string[]) => {
|
|
|
+ // set_openKeys([...keys]);
|
|
|
+ // localStorage.setItem('openKeys', JSON.stringify(keys));
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ menu: {
|
|
|
+ locale: false,
|
|
|
+ // request: async () => {
|
|
|
+ // const userData = localStorage.getItem('userData');
|
|
|
+ // const currentSelectedTab = localStorage.getItem('currentSelectedTab');
|
|
|
+ // if (currentSelectedTab) {
|
|
|
+ // const { menuId } = JSON.parse(currentSelectedTab);
|
|
|
+ // const systemId = menuId;
|
|
|
+ // const data: any[] = await getPlatformMenu(systemId);
|
|
|
+ // if (data) {
|
|
|
+
|
|
|
+ // const selectedKeys = localStorage.getItem('selectedKeys');
|
|
|
+ // const openKeys = localStorage.getItem('openKeys');
|
|
|
+ // set_menuData(data);
|
|
|
+ // if (selectedKeys && openKeys) {
|
|
|
+ // const _selectedKeys = JSON.parse(selectedKeys);
|
|
|
+ // const _openKeys = JSON.parse(openKeys);
|
|
|
+ // set_openKeys(_openKeys);
|
|
|
+ // set_selectedKeys(_selectedKeys);
|
|
|
+ // } else {
|
|
|
+ // if (data[0].children && data[0].children.length > 0) {
|
|
|
+
|
|
|
+ // const childs = data[0].children;
|
|
|
+ // set_openKeys([data[0].key]);
|
|
|
+ // set_selectedKeys([childs[0].key]);
|
|
|
+ // localStorage.setItem('openKeys', JSON.stringify([data[0].key]));
|
|
|
+ // localStorage.setItem('selectedKeys', JSON.stringify([childs[0].key]));
|
|
|
+ // history.push(`${childs[0].path}`);
|
|
|
+
|
|
|
+ // } else {
|
|
|
+ // if (data[0]) {
|
|
|
+ // set_openKeys([data[0].key]);
|
|
|
+ // set_selectedKeys([data[0].key]);
|
|
|
+ // localStorage.setItem('openKeys', JSON.stringify([data[0].key]));
|
|
|
+ // localStorage.setItem('selectedKeys', JSON.stringify([data[0].key]));
|
|
|
+ // history.push(`${data[0].path}`);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+
|
|
|
+ // function processMenuItem(item: any) {
|
|
|
+ // if (!item) return null;
|
|
|
+
|
|
|
+ // let newItem = { ...item }; // 深拷贝当前节点
|
|
|
+
|
|
|
+ // // 如果是叶子节点
|
|
|
+ // if (!item.children || item.children.length === 0) {
|
|
|
+ // let queryParams = [];
|
|
|
+
|
|
|
+ // if (newItem.softUrl) {
|
|
|
+ // queryParams.push(`softUrl=${newItem.softUrl}`);
|
|
|
+ // }
|
|
|
+
|
|
|
+ // if (newItem.youshuUrl) {
|
|
|
+ // queryParams.push(`youshuUrl=${newItem.youshuUrl}`);
|
|
|
+ // }
|
|
|
+
|
|
|
+ // if (queryParams.length > 0) {
|
|
|
+ // newItem.path = `${newItem.path}?${queryParams.join('&')}`;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // return newItem; // 返回新的叶子节点
|
|
|
+ // }
|
|
|
+
|
|
|
+ // // 否则,递归处理子节点
|
|
|
+ // newItem.children = newItem.children.map(processMenuItem);
|
|
|
+ // return newItem;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // function processMenu(menuArray: any[]) {
|
|
|
+ // if (!menuArray) return [];
|
|
|
+ // return menuArray.map(processMenuItem);
|
|
|
+ // }
|
|
|
+
|
|
|
+ // const _menu = processMenu(data);
|
|
|
+
|
|
|
+ // setInitialState((t: any) => ({ ...t, spacicalPageParamsType: _menu, memuData: data, userData: JSON.parse(userData as string) }));
|
|
|
+
|
|
|
+
|
|
|
+ // function addIconToPath(node: any, paths: string[]) {
|
|
|
+ // if (paths.includes(node.path)) {
|
|
|
+ // if (node.path == '/home') {
|
|
|
+ // node.icon = <Icon component={imgNode} />;
|
|
|
+ // }
|
|
|
+ // if (node.path == '/baseSetting') {
|
|
|
+
|
|
|
+ // node.icon = <Icon component={setting} />;
|
|
|
+ // }
|
|
|
+ // if (node.path == '/monthlyInfoSearch') {
|
|
|
+ // node.icon = <Icon component={()=><IconFont type='icon-yueduxinxicaiji' />} />;
|
|
|
+ // }
|
|
|
+ // if (node.path == '/costAccounting') {
|
|
|
+ // node.icon = <Icon component={()=><IconFont type='icon-jixiaoguanli' />} />;
|
|
|
+ // }
|
|
|
+ // if (node.path == '/reportExport') {
|
|
|
+ // node.icon = <Icon component={()=><IconFont type='icon-jixiaoguanli' />} />;
|
|
|
+ // }
|
|
|
+ // if (node.path == '/costLibraryManagement') {
|
|
|
+ // node.icon = <Icon component={()=><IconFont type='icon-chengbenkuguanli' />} />;
|
|
|
+ // }
|
|
|
+ // if (node.path == '/static') {
|
|
|
+ // node.icon = <Icon component={()=><IconFont type='icon-baobiaochaxun' />} />;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if (node.children) {
|
|
|
+ // node.children.forEach((child: any) => addIconToPath(child, paths));
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ // _menu.forEach((item: any) => {
|
|
|
+ // addIconToPath(item, ['/home', '/baseInfoMana', '/costAccounting','/monthlyInfoSearch','/static','/reportExport','/costLibraryManagement','/baseSetting']);
|
|
|
+ // });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // return _menu
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ // },
|
|
|
+ },
|
|
|
+ onPageChange: () => { },
|
|
|
+ collapsedButtonRender: () => {
|
|
|
+ return (
|
|
|
+ <div style={{
|
|
|
+ position: 'absolute', zIndex: 10, right: 17, bottom: 12,
|
|
|
+ display: 'flex', justifyContent: 'center', alignItems: 'center',
|
|
|
+ cursor: 'pointer', width: 24, height: 24
|
|
|
+ }} onClick={
|
|
|
+ () => {
|
|
|
+ onCollapse(isCollapsed ? false : true);
|
|
|
+ }
|
|
|
+ }><IconFont className='menuCollapseIcon' type={isCollapsed ? 'icon-celanzhankai' : 'icon-celanshouqi'} /></div>
|
|
|
+ )
|
|
|
+ },
|
|
|
+ // collapsed: isCollapsed,
|
|
|
+ // fixSiderbar:false,
|
|
|
+ menuRender: (props: any) => {
|
|
|
+
|
|
|
+
|
|
|
+ const { location } = props;
|
|
|
+ const [menu, set_menu] = useState<any[]>([]);
|
|
|
+
|
|
|
+ const [slectedKey, set_slectedKey] = useState<string[]>([]);
|
|
|
+ const [openKeys, set_openKeys] = useState<string[]>([]);
|
|
|
+
|
|
|
+ // const currentSelectedItem = findItemByKey(menuData,location.pathname,'path');
|
|
|
|
|
|
- colorMenuBackground: '#fff',
|
|
|
- colorTextMenuActive: '#3376FE',
|
|
|
- colorTextMenuSelected: '#3376FE',
|
|
|
- colorTextMenuTitle: '#17181A',
|
|
|
- colorTextMenu: '#17181A',
|
|
|
- //colorBgMenuItemHover:'##f0f2f5',
|
|
|
- colorBgMenuItemSelected: '#F2F6FF',
|
|
|
+ const menuClickHandle = (info: any) => {
|
|
|
+ const foundItem = findItemByKey(menu, info.key, 'key');
|
|
|
+ // console.log({foundItem,info});
|
|
|
+ if (foundItem) {
|
|
|
+ set_slectedKey([`${info.key}`]);
|
|
|
+ history.push(foundItem.path);
|
|
|
|
|
|
- // colorBgMenuItemCollapsedHover:'#f0f2f5',
|
|
|
- // //colorBgMenuItemCollapsedSelected:'blue'
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
- },
|
|
|
-
|
|
|
- siderWidth: 200,
|
|
|
- menuProps: {
|
|
|
- openKeys: [...openKeys],
|
|
|
- selectedKeys: [...selectedKeys],
|
|
|
- onSelect: ({ selectedKeys }: { selectedKeys: string[] }) => {
|
|
|
- set_selectedKeys(selectedKeys);
|
|
|
- localStorage.setItem('selectedKeys', JSON.stringify(selectedKeys));
|
|
|
- },
|
|
|
- onOpenChange: (keys: string[]) => {
|
|
|
- set_openKeys([...keys]);
|
|
|
- localStorage.setItem('openKeys', JSON.stringify(keys));
|
|
|
- },
|
|
|
- },
|
|
|
- menu: {
|
|
|
- locale: false,
|
|
|
- request: async () => {
|
|
|
+ const onOpenChangeHandle = (openKeys: string[]) => {
|
|
|
+ set_openKeys(openKeys);
|
|
|
+ }
|
|
|
+
|
|
|
+ const getMenu = async () => {
|
|
|
const userData = localStorage.getItem('userData');
|
|
|
const currentSelectedTab = localStorage.getItem('currentSelectedTab');
|
|
|
if (currentSelectedTab) {
|
|
@@ -382,21 +603,21 @@ export const layout = ({ initialState, setInitialState }: { initialState: any, s
|
|
|
const systemId = menuId;
|
|
|
const data: any[] = await getPlatformMenu(systemId);
|
|
|
if (data) {
|
|
|
-
|
|
|
+
|
|
|
const selectedKeys = localStorage.getItem('selectedKeys');
|
|
|
const openKeys = localStorage.getItem('openKeys');
|
|
|
- set_menuData(data);
|
|
|
+
|
|
|
if (selectedKeys && openKeys) {
|
|
|
const _selectedKeys = JSON.parse(selectedKeys);
|
|
|
const _openKeys = JSON.parse(openKeys);
|
|
|
set_openKeys(_openKeys);
|
|
|
- set_selectedKeys(_selectedKeys);
|
|
|
+ set_slectedKey(_selectedKeys);
|
|
|
} else {
|
|
|
if (data[0].children && data[0].children.length > 0) {
|
|
|
|
|
|
const childs = data[0].children;
|
|
|
set_openKeys([data[0].key]);
|
|
|
- set_selectedKeys([childs[0].key]);
|
|
|
+ set_slectedKey([childs[0].key]);
|
|
|
localStorage.setItem('openKeys', JSON.stringify([data[0].key]));
|
|
|
localStorage.setItem('selectedKeys', JSON.stringify([childs[0].key]));
|
|
|
history.push(`${childs[0].path}`);
|
|
@@ -404,7 +625,7 @@ export const layout = ({ initialState, setInitialState }: { initialState: any, s
|
|
|
} else {
|
|
|
if (data[0]) {
|
|
|
set_openKeys([data[0].key]);
|
|
|
- set_selectedKeys([data[0].key]);
|
|
|
+ set_slectedKey([data[0].key]);
|
|
|
localStorage.setItem('openKeys', JSON.stringify([data[0].key]));
|
|
|
localStorage.setItem('selectedKeys', JSON.stringify([data[0].key]));
|
|
|
history.push(`${data[0].path}`);
|
|
@@ -448,33 +669,33 @@ export const layout = ({ initialState, setInitialState }: { initialState: any, s
|
|
|
}
|
|
|
|
|
|
const _menu = processMenu(data);
|
|
|
-
|
|
|
+
|
|
|
setInitialState((t: any) => ({ ...t, spacicalPageParamsType: _menu, memuData: data, userData: JSON.parse(userData as string) }));
|
|
|
|
|
|
|
|
|
function addIconToPath(node: any, paths: string[]) {
|
|
|
if (paths.includes(node.path)) {
|
|
|
if (node.path == '/home') {
|
|
|
- node.icon = <Icon component={imgNode} />;
|
|
|
+ node.icon = <Icon component={imgNode} />;
|
|
|
}
|
|
|
if (node.path == '/baseSetting') {
|
|
|
-
|
|
|
+
|
|
|
node.icon = <Icon component={setting} />;
|
|
|
}
|
|
|
if (node.path == '/monthlyInfoSearch') {
|
|
|
- node.icon = <Icon component={()=><IconFont type='icon-yueduxinxicaiji' />} />;
|
|
|
+ node.icon = <Icon component={() => <IconFont type='icon-yueduxinxicaiji' />} />;
|
|
|
}
|
|
|
if (node.path == '/costAccounting') {
|
|
|
- node.icon = <Icon component={()=><IconFont type='icon-jixiaoguanli' />} />;
|
|
|
+ node.icon = <Icon component={() => <IconFont type='icon-jixiaoguanli' />} />;
|
|
|
}
|
|
|
if (node.path == '/reportExport') {
|
|
|
- node.icon = <Icon component={()=><IconFont type='icon-jixiaoguanli' />} />;
|
|
|
+ node.icon = <Icon component={() => <IconFont type='icon-jixiaoguanli' />} />;
|
|
|
}
|
|
|
if (node.path == '/costLibraryManagement') {
|
|
|
- node.icon = <Icon component={()=><IconFont type='icon-chengbenkuguanli' />} />;
|
|
|
+ node.icon = <Icon component={() => <IconFont type='icon-chengbenkuguanli' />} />;
|
|
|
}
|
|
|
if (node.path == '/static') {
|
|
|
- node.icon = <Icon component={()=><IconFont type='icon-baobiaochaxun' />} />;
|
|
|
+ node.icon = <Icon component={() => <IconFont type='icon-baobiaochaxun' />} />;
|
|
|
}
|
|
|
}
|
|
|
if (node.children) {
|
|
@@ -483,33 +704,63 @@ export const layout = ({ initialState, setInitialState }: { initialState: any, s
|
|
|
}
|
|
|
|
|
|
_menu.forEach((item: any) => {
|
|
|
- addIconToPath(item, ['/home', '/baseInfoMana', '/costAccounting','/monthlyInfoSearch','/static','/reportExport','/costLibraryManagement','/baseSetting']);
|
|
|
+ addIconToPath(item, ['/home', '/baseInfoMana', '/costAccounting', '/monthlyInfoSearch', '/static', '/reportExport', '/costLibraryManagement', '/baseSetting']);
|
|
|
});
|
|
|
|
|
|
+ const { newTree, firstLeafNode, firstLeafNodePath } = transformTree(_menu);
|
|
|
+ // set_openKeys(firstLeafNodePath.map(a => `${a.key}`));
|
|
|
+ // set_slectedKey([`${firstLeafNode.key}`]);
|
|
|
+ set_menu(newTree);
|
|
|
|
|
|
-
|
|
|
- return _menu
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+
|
|
|
+ const foundItem = findItemByKey(menu, location.pathname, 'path');
|
|
|
+
|
|
|
+ if (foundItem) {
|
|
|
+ set_slectedKey(foundItem.key);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }, [menu]);
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ getMenu();
|
|
|
+ }, [])
|
|
|
|
|
|
- },
|
|
|
- },
|
|
|
- onPageChange: () => { },
|
|
|
- collapsedButtonRender: () => {
|
|
|
return (
|
|
|
- <div style={{
|
|
|
- position: 'absolute', zIndex: 10, right: 17, bottom: 12,
|
|
|
- display: 'flex', justifyContent: 'center', alignItems: 'center',
|
|
|
- cursor: 'pointer', width: 24, height: 24
|
|
|
- }} onClick={
|
|
|
- () => {
|
|
|
- onCollapse(isCollapsed ? false : true);
|
|
|
- }
|
|
|
- }><IconFont className='menuCollapseIcon' type={isCollapsed ? 'icon-celanzhankai' : 'icon-celanshouqi'} /></div>
|
|
|
- )
|
|
|
+ <ResizableContainer width={isCollapsed ? 64 : 200} minWidth={0} maxWidth={600} height={'calc(100vh - 58px)'}>
|
|
|
+ <div style={{ height: '100%', background: '#fff', position: 'relative' }}>
|
|
|
+ <div className='menuWrapper' style={{ height: 'calc(100% - 40px)', overflowY: 'scroll', overflowX: 'hidden' }}>
|
|
|
+ <Menu
|
|
|
+
|
|
|
+ onClick={menuClickHandle}
|
|
|
+ onOpenChange={onOpenChangeHandle}
|
|
|
+ style={{ width: '100%' }}
|
|
|
+ openKeys={openKeys}
|
|
|
+ selectedKeys={slectedKey}
|
|
|
+ mode="inline"
|
|
|
+ items={menu}
|
|
|
+ inlineCollapsed={isCollapsed}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div style={{
|
|
|
+ position: 'absolute', zIndex: 10, right: 17, bottom: 9,
|
|
|
+ display: 'flex', justifyContent: 'center', alignItems: 'center',
|
|
|
+ cursor: 'pointer', width: 24, height: 24
|
|
|
+ }} onClick={
|
|
|
+ () => {
|
|
|
+ onCollapse(isCollapsed ? false : true);
|
|
|
+ }
|
|
|
+ }><IconFont className='menuCollapseIcon' type={isCollapsed ? 'icon-celanzhankai' : 'icon-celanshouqi'} /></div>
|
|
|
+ </div>
|
|
|
+ </ResizableContainer>
|
|
|
+ );
|
|
|
},
|
|
|
- collapsed: isCollapsed,
|
|
|
- // fixSiderbar:false,
|
|
|
contentStyle: {
|
|
|
// border: '16px solid #F7F9FC',
|
|
|
//height: '94.5vh', //以去除顶部导航高度
|