From 7318922eaf9482bc7eaffea980d2b58cc03ab39d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E6=80=9D?= Date: Thu, 17 Mar 2022 16:50:34 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=90=8E=E5=8F=B0=E5=B7=A6?= =?UTF-8?q?=E4=BE=A7=E8=8F=9C=E5=8D=95=EF=BC=88=E6=9C=AA=E5=AE=8C=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/pagination-table/index.jsx | 3 +- src/managements/api.js | 15 ++- src/managements/components/layouts/index.jsx | 106 +++++++++++------- .../jurisdiction/menuList/index.jsx | 1 + src/military/expert/fetch.js | 3 +- src/military/task/fetch.js | 4 +- src/military/task/taskAdmin/index.jsx | 2 +- src/military/task/taskAdmin/index.scss | 2 +- src/modules/tpm/NewHeader.js | 6 +- 9 files changed, 92 insertions(+), 50 deletions(-) diff --git a/src/components/pagination-table/index.jsx b/src/components/pagination-table/index.jsx index 717c0e26..91647e0b 100644 --- a/src/components/pagination-table/index.jsx +++ b/src/components/pagination-table/index.jsx @@ -3,13 +3,12 @@ import { Table, Pagination } from 'antd'; import './index.scss'; export default (props) => { - const { loading, dataSource, columns, handleRow, total, setCurPage, current, rowSelection, expandedRowRender, expandIconColumnIndex, expandIconAsCell, onShowSizeChange, showSizeChanger, pagination, scroll, indentSize } = props; + const {handleRow, total, setCurPage, current, onShowSizeChange, showSizeChanger, pagination} = props; return (
row.id || i} pagination={false} onRow={handleRow} /> diff --git a/src/managements/api.js b/src/managements/api.js index 67829c84..a40c4fb5 100644 --- a/src/managements/api.js +++ b/src/managements/api.js @@ -45,11 +45,10 @@ export async function menuList(parentId,params) { return res; } // 树形结构返回所有菜单列表 -export async function treeList(parentId,params) { +export async function treeList() { let res = await fetch({ url: `/api/menu/treeList`, method: 'get', - params, }); return res; } @@ -97,7 +96,7 @@ export async function deleteRole(roleId){ return res; } -//为用户赋予菜单 +//为角色赋予菜单 export async function allocMenu(roleId, menuIds){ let res = await fetch({ url: `/api/role/allocMenu?roleId=${roleId}&menuIds=${menuIds}`, @@ -105,7 +104,7 @@ export async function allocMenu(roleId, menuIds){ }); return res; } -// +//通过角色id获取菜单列表 export async function listMenu(roleId) { let res = await fetch({ url: `/api/role/listMenu/${roleId}`, @@ -128,4 +127,12 @@ export async function adminUserList() { method: 'get', }); return res; +} +// 获取用户角色 +export async function getUserRole(adminId) { + let res = await fetch({ + url: `/api/admin/role/${adminId}`, + method: 'get', + }); + return res; } \ No newline at end of file diff --git a/src/managements/components/layouts/index.jsx b/src/managements/components/layouts/index.jsx index 4546b498..8118e814 100644 --- a/src/managements/components/layouts/index.jsx +++ b/src/managements/components/layouts/index.jsx @@ -1,48 +1,79 @@ import React, { useState, useEffect, Fragment } from "react"; import { Link } from "react-router-dom"; import { Menu } from "antd"; -import urlConfig from "./config"; import "./index.scss"; const { SubMenu } = Menu; -const titleObj = {}; -const locationObj = {}; -const parentKeyObj = {}; -const allRouter = []; -const rootSubmenuKeys = []; -function titleFun(menus) { - menus.forEach(i => { - titleObj[i.key] = i.title; - locationObj[i.location] = i; - i.location && allRouter.push(i.location); - !i.parentKey && rootSubmenuKeys.push(i.key); - if (Array.isArray(i.children) && i.children.length > 0) { - titleFun(i.children); - i.parentKey && (parentKeyObj[i.key] = i.parentKey); - } - }) -} -titleFun(urlConfig); export default (props) => { const { current_user, children, history, location: { pathname } } = props; const setting = (localStorage.chromesetting && JSON.parse(localStorage.chromesetting)) || {}; + const urlConfig = JSON.parse(localStorage.menuList) || []; + // import urlConfig from "./config"; + console.log('urlConfig', urlConfig); + console.log(props); + const [openKeys, setOpenKeys] = useState(); + const [current, setCurrent] = useState(); + const [keyPath, setKeyPath] = useState(); + const [acitve, setActive] = useState({}); + const [titleObj,setTitleObj] =useState({}); + const [locationObj, setLocationObj] = useState({}); + const [parentKeyObj,setParentKeyObj] =useState({}); + const [allRouter,setAllRouter] =useState([]); + const [rootSubmenuKeys,setRootSubmenuKeys] =useState([]); + + const titleObjNew = {}; + const locationObjNew = {}; + const parentKeyObjNew = {}; + const allRouterNew = []; + const rootSubmenuKeysNew = []; + + function titleFun(menus) { + menus.forEach(i => { + titleObjNew[i.key] = i.title; + locationObjNew[i.location] = i; + i.location && allRouterNew.push(i.location); + !i.parentKey && rootSubmenuKeysNew.push(i.key); + if (Array.isArray(i.children) && i.children.length > 0) { + titleFun(i.children); + i.parentKey && (parentKeyObjNew[i.key] = i.parentKey); + } + }) + } + + + useEffect(()=>{ + urlConfig.length && titleFun(urlConfig); + console.log(urlConfig); + // setTitleObj(titleObjNew); + // setLocationObj(locationObjNew); + // setParentKeyObj(parentKeyObjNew); + // setAllRouter(allRouterNew); + // setRootSubmenuKeys(rootSubmenuKeysNew); + },[urlConfig]); + + + useEffect(() => { sessionStorage.setItem("current_user", JSON.stringify(current_user)); }, [current_user.login]); - let initCurrent = locationObj[pathname] ? [locationObj[pathname].key] : []; - let initKeyPath = locationObj[pathname] ? [locationObj[pathname].parentKey, locationObj[pathname].key] : []; - const defaultOpenKeys = []; - const myKey = pathname && locationObj[pathname] && locationObj[pathname].parentKey; - defaultOpenKeys.push(myKey ? myKey : "task"); - parentKeyObj[myKey] && defaultOpenKeys.push(parentKeyObj[myKey]); - const [openKeys, setOpenKeys] = useState(defaultOpenKeys); - const [current, setCurrent] = useState(initCurrent); - const [keyPath, setKeyPath] = useState(initKeyPath); - const [acitve, setActive] = useState(locationObj[pathname] || {}); + useEffect(() => { + if (locationObj[pathname]) { + setCurrent(locationObj[pathname] ? [locationObj[pathname].key] : []); + setKeyPath(locationObj[pathname] ? [locationObj[pathname].parentKey, locationObj[pathname].key] : []); + const defaultOpenKeys = []; + const myKey = pathname && locationObj[pathname] && locationObj[pathname].parentKey; + defaultOpenKeys.push(myKey ? myKey : "task"); + parentKeyObj[myKey] && defaultOpenKeys.push(parentKeyObj[myKey]); + setActive(locationObj[pathname]); + setOpenKeys(defaultOpenKeys); + } + }, [locationObj[pathname]]) + + function handleClick(e) { console.log(e.item); @@ -69,9 +100,9 @@ export default (props) => { } else { return ( - { itemClick(item) }}>{item.title} - {/* {item.urltype == "self" ? {item.title} - : {item.title}} */} + {/* { itemClick(item) }}>{item.title} */} + {item.location ? { itemClick(item) }}>{item.title} + : item.title} ); } @@ -79,9 +110,10 @@ export default (props) => { } function head(keyPath) { - return keyPath.map((i, index) => { + console.log(titleObj); + return keyPath ? keyPath.map((i, index) => { return {titleObj[i]}{index !== keyPath.length - 1 && ' / '} - }) + }) : } function iframeLoad() { @@ -99,7 +131,6 @@ export default (props) => { } else { setOpenKeys(latestOpenKey ? [latestOpenKey] : []); } - console.log(newOpenKeys); } useEffect(() => { @@ -113,8 +144,7 @@ export default (props) => { }) }, [history]); - console.log(acitve.urltype); - + console.log(acitve); return (
@@ -125,7 +155,7 @@ export default (props) => { onOpenChange={onOpenChange} openKeys={openKeys} > - {getMenuList(urlConfig)} + {urlConfig.length && getMenuList(urlConfig)}
diff --git a/src/managements/jurisdiction/menuList/index.jsx b/src/managements/jurisdiction/menuList/index.jsx index ebf35aad..6c2072da 100644 --- a/src/managements/jurisdiction/menuList/index.jsx +++ b/src/managements/jurisdiction/menuList/index.jsx @@ -257,6 +257,7 @@ export default Form.create()(({ form}) => {
row.key} dataSource={dataList} columns={columns} total={total} diff --git a/src/military/expert/fetch.js b/src/military/expert/fetch.js index ca278fde..41dc9307 100644 --- a/src/military/expert/fetch.js +++ b/src/military/expert/fetch.js @@ -3,7 +3,8 @@ import javaFetch from '../javaFetch'; let settings = localStorage.chromesetting && JSON.parse(localStorage.chromesetting); -let actionUrl = settings && settings.api_urls && settings.api_urls.task ? settings.api_urls.task : 'https://task.osredm.com'; +// let actionUrl = settings && settings.api_urls && settings.api_urls.task ? settings.api_urls.task : 'https://task.osredm.com'; +let actionUrl = 'http://10.47.38.60:8088'; const service = javaFetch(actionUrl); export const httpUrl = actionUrl; export const main_web_site_url = settings && settings.main_web_site_url; diff --git a/src/military/task/fetch.js b/src/military/task/fetch.js index b5773130..2505af36 100644 --- a/src/military/task/fetch.js +++ b/src/military/task/fetch.js @@ -3,8 +3,8 @@ import javaFetch from '../javaFetch'; let settings=localStorage.chromesetting&&JSON.parse(localStorage.chromesetting); -let actionUrl = settings && settings.api_urls? settings.api_urls.task :'https://task.osredm.com'; -// let actionUrl = 'http://111.8.36.180:8094' +// let actionUrl = settings && settings.api_urls? settings.api_urls.task :'https://task.osredm.com'; +let actionUrl = 'http://10.47.38.60:8088' const service = javaFetch(actionUrl); export const httpUrl = actionUrl; diff --git a/src/military/task/taskAdmin/index.jsx b/src/military/task/taskAdmin/index.jsx index 5d4b2a01..af1ea0c1 100644 --- a/src/military/task/taskAdmin/index.jsx +++ b/src/military/task/taskAdmin/index.jsx @@ -648,7 +648,7 @@ export default Form.create()(({ form, showNotification, match, history, state })
-
+
row.id} diff --git a/src/military/task/taskAdmin/index.scss b/src/military/task/taskAdmin/index.scss index b55754e6..e5ca065c 100644 --- a/src/military/task/taskAdmin/index.scss +++ b/src/military/task/taskAdmin/index.scss @@ -206,7 +206,7 @@ padding: 3px 8px; } } -.center-content{ +.taskListCont{ .publishMode{ position: relative; &:before{ diff --git a/src/modules/tpm/NewHeader.js b/src/modules/tpm/NewHeader.js index deb235d1..3987e7e8 100644 --- a/src/modules/tpm/NewHeader.js +++ b/src/modules/tpm/NewHeader.js @@ -60,7 +60,11 @@ class NewHeader extends Component { } componentDidMount() { getUserInfo().then(response =>{ - response && this.setState({isExpert: response.data && response.data.expert}); + // response && this.setState({isExpert: response.data && response.data.expert}); + if(response){ + this.setState({isExpert: response.data && response.data.expert}); + localStorage.setItem('menuList', JSON.stringify(response.data.menuNodes)); + } }); // this.getAppdata(); this.geturlsdata();