From bcb704afd26769efff53d9b3e3918f32a7d8ebad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=80=A1?= Date: Wed, 16 Jul 2025 09:38:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8F=9C=E5=8D=95=EF=BC=8C?= =?UTF-8?q?=E8=A7=92=E8=89=B2=EF=BC=8C=E9=83=A8=E9=97=A8=EF=BC=8C=E5=AD=97?= =?UTF-8?q?=E5=85=B8=E7=AD=89=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/proxy.ts | 16 +- config/router_system.ts | 4 + src/layouts/BasicLayout.tsx | 738 +++++++++--------- src/layouts/services.ts | 4 +- src/pages/Dict/DictionaryList.tsx | 386 --------- src/pages/Dict/DictionaryPage.tsx | 28 - src/pages/LoadingPage/index.tsx | 3 +- src/pages/LoadingPage/service.ts | 2 +- src/pages/Menu/MenuManagementPage.tsx | 426 ---------- src/pages/Menu/MenuService.ts | 31 - src/pages/System/Department/index.tsx | 14 +- src/pages/System/Dict/index.tsx | 283 +++++++ .../DictService.ts => System/Dict/service.ts} | 0 src/pages/System/Role/index.tsx | 129 +-- src/pages/System/Role/service.ts | 7 + src/pages/System/Scheduled/service.ts | 8 +- 16 files changed, 749 insertions(+), 1330 deletions(-) delete mode 100644 src/pages/Dict/DictionaryList.tsx delete mode 100644 src/pages/Dict/DictionaryPage.tsx delete mode 100644 src/pages/Menu/MenuManagementPage.tsx delete mode 100644 src/pages/Menu/MenuService.ts create mode 100644 src/pages/System/Dict/index.tsx rename src/pages/{Dict/DictService.ts => System/Dict/service.ts} (100%) diff --git a/config/proxy.ts b/config/proxy.ts index d811250..9aac713 100644 --- a/config/proxy.ts +++ b/config/proxy.ts @@ -14,7 +14,7 @@ export default { }, UAT: { '/api/sys-manager-ebtp-project': { - target: 'http://localhost:18023', + target: 'http://localhost:18030', changeOrigin: true, pathRewrite: { '/api/sys-manager-ebtp-project': '' }, }, @@ -57,8 +57,8 @@ export default { target: 'http://localhost:18096', changeOrigin: true, pathRewrite: { '/api/biz-supplier-manage': '' }, - } - + }, + // '/api/wfap/v1/audit/bill/find/by/procid': { // target: 'http://10.242.31.158:8891/',//审批单 uat环境自动审批,暂时用不到 // changeOrigin: true, @@ -70,11 +70,11 @@ export default { // changeOrigin: true, // pathRewrite: { '/living/api': '' }, // }, - // '/api/*': { - // target: 'http://10.242.31.158:18022',//连接天宫的ng - // changeOrigin: true, - // pathRewrite: { '^': '' }, - // }, + '/api/*': { + target: 'http://localhost:18030',//连接天宫的ng + changeOrigin: true, + pathRewrite: { '^/api': '' }, + }, // '/doc/v1.0/*': { // target: 'http://10.242.31.158:8806',//连接天宫的ng // changeOrigin: true, diff --git a/config/router_system.ts b/config/router_system.ts index 2276db7..16e61e6 100644 --- a/config/router_system.ts +++ b/config/router_system.ts @@ -19,6 +19,10 @@ export default [{ path: '/System/Menu', component: './System/Menu', }, + {//字典管理 + path: '/System/Dict', + component: './System/Dict', + }, {//定时任务管理 path: '/System/Scheduled', component: './System/Scheduled', diff --git a/src/layouts/BasicLayout.tsx b/src/layouts/BasicLayout.tsx index 8dc9fe1..149bdf1 100644 --- a/src/layouts/BasicLayout.tsx +++ b/src/layouts/BasicLayout.tsx @@ -107,379 +107,373 @@ const BasicLayout: React.FC = (props) => { const children = useKeepOutlets(); useEffect(() => { if (getSessionRoleData()?.roleId) { - // let params = { - // roleIdList: [getSessionRoleData()?.roleId] + let params = { + roleIdList: [getSessionRoleData()?.roleId] + } + // const res = { + // "code": "1", + // "success": true, + // "message": "操作成功", + // "data": [ + // { + // "menuId": "2", + // "path": "", + // "name": "我的工作台", + // "icon": "DesktopOutlined", + // "menuScope": "EBTP", + // "menuOu": null, + // "isTop": 0, + // "children": [ + // { + // "path": "/workbench/files", + // "name": "共享文档下载", + // "frame": "N" + // }, + // { + // "path": "/SystemMessage/message", + // "name": "系统消息", + // "frame": "N" + // }, + // { + // "path": "/api/auth/oauth/authorize?response_type\u003dcode\u0026client_id\u003d3FjMVIzt\u0026redirect_uri\u003dhttps://10.242.31.158:18023/Expertlibraryworkbench/MyExpertHome/Extract?proxyCompanyNo\u003d{organizationId}\u0026sign\u003dprocure\u0026urlSign\u003dSubagenT\u0026mall3_token\u003d{mall3_token}", + // "name": "代理机构信息管理", + // "frame": "S" + // }, + // { + // "path": "/api/auth/oauth/authorize?response_type\u003dcode\u0026client_id\u003dCOsHJydx\u0026redirect_uri\u003dhttps://uat-uscm.chinaunicom.cn:8631/redirect?page\u003dcustomerservice/support/conversation/index\u0026mall3_token\u003d{mall3_token}", + // "name": "我的客服", + // "frame": "S" + // }, + // { + // "path": "/Lowcode/LowcodeRedirect", + // "name": "我的服务单", + // "frame": "Y" + // }, + // { + // "path": "/api/auth/oauth/authorize?response_type\u003dcode\u0026client_id\u003ds3FXwGQh\u0026redirect_uri\u003dhttps://uat-uscm.chinaunicom.cn:18024/supplierInfo/redirect?page\u003d/supplier-info-ordinary\u0026mall3_token\u003d{mall3_token}", + // "name": "智企查", + // "frame": "S" + // } + // ], + // "feignFlag": null + // }, + // { + // "menuId": "3", + // "path": "", + // "name": "通知公告", + // "icon": "NotificationOutlined", + // "menuScope": "EBTP", + // "menuOu": null, + // "isTop": 0, + // "children": [ + // { + // "path": "/notice/noticeList", + // "name": "通知公告查看", + // "frame": "N" + // } + // ], + // "feignFlag": null + // }, + // { + // "menuId": "99", + // "path": "", + // "name": "系统管理", + // "icon": "BookOutlined", + // "menuScope": "EBTP", + // "menuOu": null, + // "isTop": 0, + // "children": [ + // { + // "path": "/System/User", + // "name": "用户管理", + // "frame": "N" + // }, + // { + // "path": "/System/Dept", + // "name": "部门管理", + // "frame": "N" + // }, + // { + // "path": "/System/Role", + // "name": "角色管理", + // "frame": "N" + // }, + // { + // "path": "/System/Menu", + // "name": "菜单管理", + // "frame": "N" + // }, + // { + // "path": "/System/Scheduled", + // "name": "定时任务管理", + // "frame": "N" + // } + // ], + // "feignFlag": null + // }, + // { + // "menuId": "41", + // "path": "", + // "name": "分派项目管理", + // "icon": "BookOutlined", + // "menuScope": "EBTP", + // "menuOu": null, + // "isTop": 0, + // "children": [ + // { + // "path": "/Project/EntrustAssign/Operator", + // "name": "分派给我的项目", + // "frame": "N" + // }, + // { + // "path": "/Project/EntrustWithdraw", + // "name": "委托撤回记录", + // "frame": "N" + // } + // ], + // "feignFlag": null + // }, + // { + // "menuId": "1000001", + // "path": "", + // "name": "招标项目管理", + // "icon": "ProfileOutlined", + // "menuScope": "EBTP", + // "menuOu": null, + // "isTop": 0, + // "children": [ + // { + // "path": "/Bid/Manage", + // "name": "项目管理", + // "frame": "N" + // } + // ], + // "feignFlag": null + // }, + // { + // "menuId": "1000006", + // "path": "Negotiation", + // "name": "谈判项目管理", + // "icon": "CommentOutlined", + // "menuScope": "EBTP", + // "menuOu": null, + // "isTop": 0, + // "children": [ + // { + // "path": "/Negotiation/Manage", + // "name": "项目管理", + // "frame": "N" + // } + // ], + // "feignFlag": null + // }, + // { + // "menuId": "1843567845937700866", + // "path": "DirectProc", + // "name": "直接采购管理", + // "icon": "SelectOutlined", + // "menuScope": "EBTP", + // "menuOu": null, + // "isTop": 0, + // "children": [ + // { + // "path": "/DirectProc/Manage", + // "name": "项目管理", + // "frame": "N" + // } + // ], + // "feignFlag": null + // }, + // { + // "menuId": "100009", + // "path": "ComparisonProc", + // "name": "询比采购管理", + // "icon": "PartitionOutlined", + // "menuScope": "EBTP", + // "menuOu": null, + // "isTop": 0, + // "children": [ + // { + // "path": "/ComparisonProc/Manage", + // "name": "项目管理", + // "frame": "N" + // } + // ], + // "feignFlag": null + // }, + // { + // "menuId": "1000008", + // "path": "Inquiry", + // "name": "询价项目管理", + // "icon": "ProjectOutlined", + // "menuScope": "EBTP", + // "menuOu": null, + // "isTop": 0, + // "children": [ + // { + // "path": "/Inquiry/Manage", + // "name": "项目管理", + // "frame": "N" + // } + // ], + // "feignFlag": null + // }, + // { + // "menuId": "1000007", + // "path": "Recruit", + // "name": "招募项目管理", + // "icon": "MacCommandOutlined", + // "menuScope": "EBTP", + // "menuOu": null, + // "isTop": 0, + // "children": [ + // { + // "path": "/Recruit/Manage", + // "name": "项目管理", + // "frame": "N" + // } + // ], + // "feignFlag": null + // }, + // { + // "menuId": "11111111", + // "path": "Finance", + // "name": "财务管理", + // "icon": "PayCircleOutlined", + // "menuScope": "EBTP", + // "menuOu": null, + // "isTop": 0, + // "children": [ + // { + // "path": "/Finance/ProjectManager/RevenueRecognition", + // "name": "招标收入确认", + // "frame": "N" + // }, + // { + // "path": "/Finance/EnsureAmount", + // "name": "投标保证金查询", + // "frame": "N" + // }, + // { + // "path": "/Finance/EnsureAmountRefund", + // "name": "保证金退还", + // "frame": "N" + // } + // ], + // "feignFlag": null + // }, + // { + // "menuId": "11", + // "path": "Invoice", + // "name": "发票管理", + // "icon": "WalletOutlined", + // "menuScope": "EBTP", + // "menuOu": null, + // "isTop": 0, + // "children": [ + // { + // "path": "/Invoice/Manager", + // "name": "发票列表", + // "frame": "N" + // } + // ], + // "feignFlag": null + // }, + // { + // "menuId": "1565509326829727746", + // "path": "ExpertManage", + // "name": "专家管理", + // "icon": "IdcardOutlined", + // "menuScope": "EBTP", + // "menuOu": null, + // "isTop": 0, + // "children": [ + // { + // "path": "/api/auth/oauth/authorize?response_type\u003dcode\u0026client_id\u003d3FjMVIzt\u0026redirect_uri\u003dhttps://10.242.31.158:18023/Expertlibraryworkbench/MyExpertHome/Extract?proxyCompanyNo\u003d{organizationId}\u0026sign\u003dprocure\u0026mall3_token\u003d{mall3_token}", + // "name": "专家抽取", + // "frame": "S" + // }, + // { + // "path": "/api/auth/oauth/authorize?response_type\u003dcode\u0026client_id\u003d3FjMVIzt\u0026redirect_uri\u003dhttps://10.242.31.158:18023/Expertlibraryworkbench/MyExpertHome/Extract?proxyCompanyNo\u003d{organizationId}\u0026sign\u003dprocure\u0026urlSign\u003dEvaluate\u0026mall3_token\u003d{mall3_token}", + // "name": "专家评价", + // "frame": "S" + // }, + // { + // "path": "/ExpertInfo/ExpertInformationManage", + // "name": "专家信息管理", + // "frame": "N" + // }, + // { + // "path": "/ExpertInfo/ExpertExtractionAvoidance", + // "name": "专家抽取回避", + // "frame": "N" + // } + // ], + // "feignFlag": null + // }, + // { + // "menuId": "1565574276328947714", + // "path": "VideoMonitor", + // "name": "视频监控查询", + // "icon": "PlaySquareOutlined", + // "menuScope": "EBTP", + // "menuOu": null, + // "isTop": 0, + // "children": [ + // { + // "path": "/HistoryVideo", + // "name": "历史视频上传列表", + // "frame": "N" + // } + // ], + // "feignFlag": null + // }, + // { + // "menuId": "1722061270189662209", + // "path": "PurchaseReOffer", + // "name": "采购复盘与检查", + // "icon": "BookOutlined", + // "menuScope": "EBTP", + // "menuOu": null, + // "isTop": 0, + // "children": [ + // { + // "path": "/PurchaseReOffer", + // "name": "采购复盘与检查表", + // "frame": "N" + // } + // ], + // "feignFlag": null + // }, + // { + // "menuId": "1767358998249476098", + // "path": "UnbalancedBid", + // "name": "不均衡报价分析", + // "icon": "BookOutlined", + // "menuScope": "EBTP", + // "menuOu": null, + // "isTop": 0, + // "children": [ + // { + // "path": "/UnbalancedBidList", + // "name": "不均衡报价分析表", + // "frame": "N" + // } + // ], + // "feignFlag": null + // } + // ] // } - const res = { - "code": "1", - "success": true, - "message": "操作成功", - "data": [ - { - "menuId": "2", - "path": "", - "name": "我的工作台", - "icon": "DesktopOutlined", - "menuScope": "EBTP", - "menuOu": null, - "isTop": 0, - "children": [ - { - "path": "/workbench/files", - "name": "共享文档下载", - "frame": "N" - }, - { - "path": "/SystemMessage/message", - "name": "系统消息", - "frame": "N" - }, - { - "path": "/api/auth/oauth/authorize?response_type\u003dcode\u0026client_id\u003d3FjMVIzt\u0026redirect_uri\u003dhttps://10.242.31.158:18023/Expertlibraryworkbench/MyExpertHome/Extract?proxyCompanyNo\u003d{organizationId}\u0026sign\u003dprocure\u0026urlSign\u003dSubagenT\u0026mall3_token\u003d{mall3_token}", - "name": "代理机构信息管理", - "frame": "S" - }, - { - "path": "/api/auth/oauth/authorize?response_type\u003dcode\u0026client_id\u003dCOsHJydx\u0026redirect_uri\u003dhttps://uat-uscm.chinaunicom.cn:8631/redirect?page\u003dcustomerservice/support/conversation/index\u0026mall3_token\u003d{mall3_token}", - "name": "我的客服", - "frame": "S" - }, - { - "path": "/Lowcode/LowcodeRedirect", - "name": "我的服务单", - "frame": "Y" - }, - { - "path": "/api/auth/oauth/authorize?response_type\u003dcode\u0026client_id\u003ds3FXwGQh\u0026redirect_uri\u003dhttps://uat-uscm.chinaunicom.cn:18024/supplierInfo/redirect?page\u003d/supplier-info-ordinary\u0026mall3_token\u003d{mall3_token}", - "name": "智企查", - "frame": "S" - } - ], - "feignFlag": null - }, - { - "menuId": "3", - "path": "", - "name": "通知公告", - "icon": "NotificationOutlined", - "menuScope": "EBTP", - "menuOu": null, - "isTop": 0, - "children": [ - { - "path": "/notice/noticeList", - "name": "通知公告查看", - "frame": "N" - } - ], - "feignFlag": null - }, - { - "menuId": "99", - "path": "", - "name": "系统管理", - "icon": "BookOutlined", - "menuScope": "EBTP", - "menuOu": null, - "isTop": 0, - "children": [ - { - "path": "/System/User", - "name": "用户管理", - "frame": "N" - }, - { - "path": "/System/Dept", - "name": "部门管理", - "frame": "N" - }, - { - "path": "/System/Role", - "name": "角色管理", - "frame": "N" - }, - { - "path": "/System/Menu", - "name": "菜单管理", - "frame": "N" - }, - { - "path": "/System/Scheduled", - "name": "定时任务管理", - "frame": "N" - } - ], - "feignFlag": null - }, - { - "menuId": "41", - "path": "", - "name": "分派项目管理", - "icon": "BookOutlined", - "menuScope": "EBTP", - "menuOu": null, - "isTop": 0, - "children": [ - { - "path": "/Project/EntrustAssign/Operator", - "name": "分派给我的项目", - "frame": "N" - }, - { - "path": "/Project/EntrustWithdraw", - "name": "委托撤回记录", - "frame": "N" - } - ], - "feignFlag": null - }, - { - "menuId": "1000001", - "path": "", - "name": "招标项目管理", - "icon": "ProfileOutlined", - "menuScope": "EBTP", - "menuOu": null, - "isTop": 0, - "children": [ - { - "path": "/Bid/Manage", - "name": "项目管理", - "frame": "N" - } - ], - "feignFlag": null - }, - { - "menuId": "1000006", - "path": "Negotiation", - "name": "谈判项目管理", - "icon": "CommentOutlined", - "menuScope": "EBTP", - "menuOu": null, - "isTop": 0, - "children": [ - { - "path": "/Negotiation/Manage", - "name": "项目管理", - "frame": "N" - } - ], - "feignFlag": null - }, - { - "menuId": "1843567845937700866", - "path": "DirectProc", - "name": "直接采购管理", - "icon": "SelectOutlined", - "menuScope": "EBTP", - "menuOu": null, - "isTop": 0, - "children": [ - { - "path": "/DirectProc/Manage", - "name": "项目管理", - "frame": "N" - } - ], - "feignFlag": null - }, - { - "menuId": "100009", - "path": "ComparisonProc", - "name": "询比采购管理", - "icon": "PartitionOutlined", - "menuScope": "EBTP", - "menuOu": null, - "isTop": 0, - "children": [ - { - "path": "/ComparisonProc/Manage", - "name": "项目管理", - "frame": "N" - } - ], - "feignFlag": null - }, - { - "menuId": "1000008", - "path": "Inquiry", - "name": "询价项目管理", - "icon": "ProjectOutlined", - "menuScope": "EBTP", - "menuOu": null, - "isTop": 0, - "children": [ - { - "path": "/Inquiry/Manage", - "name": "项目管理", - "frame": "N" - } - ], - "feignFlag": null - }, - { - "menuId": "1000007", - "path": "Recruit", - "name": "招募项目管理", - "icon": "MacCommandOutlined", - "menuScope": "EBTP", - "menuOu": null, - "isTop": 0, - "children": [ - { - "path": "/Recruit/Manage", - "name": "项目管理", - "frame": "N" - } - ], - "feignFlag": null - }, - { - "menuId": "11111111", - "path": "Finance", - "name": "财务管理", - "icon": "PayCircleOutlined", - "menuScope": "EBTP", - "menuOu": null, - "isTop": 0, - "children": [ - { - "path": "/Finance/ProjectManager/RevenueRecognition", - "name": "招标收入确认", - "frame": "N" - }, - { - "path": "/Finance/EnsureAmount", - "name": "投标保证金查询", - "frame": "N" - }, - { - "path": "/Finance/EnsureAmountRefund", - "name": "保证金退还", - "frame": "N" - } - ], - "feignFlag": null - }, - { - "menuId": "11", - "path": "Invoice", - "name": "发票管理", - "icon": "WalletOutlined", - "menuScope": "EBTP", - "menuOu": null, - "isTop": 0, - "children": [ - { - "path": "/Invoice/Manager", - "name": "发票列表", - "frame": "N" - } - ], - "feignFlag": null - }, - { - "menuId": "1565509326829727746", - "path": "ExpertManage", - "name": "专家管理", - "icon": "IdcardOutlined", - "menuScope": "EBTP", - "menuOu": null, - "isTop": 0, - "children": [ - { - "path": "/api/auth/oauth/authorize?response_type\u003dcode\u0026client_id\u003d3FjMVIzt\u0026redirect_uri\u003dhttps://10.242.31.158:18023/Expertlibraryworkbench/MyExpertHome/Extract?proxyCompanyNo\u003d{organizationId}\u0026sign\u003dprocure\u0026mall3_token\u003d{mall3_token}", - "name": "专家抽取", - "frame": "S" - }, - { - "path": "/api/auth/oauth/authorize?response_type\u003dcode\u0026client_id\u003d3FjMVIzt\u0026redirect_uri\u003dhttps://10.242.31.158:18023/Expertlibraryworkbench/MyExpertHome/Extract?proxyCompanyNo\u003d{organizationId}\u0026sign\u003dprocure\u0026urlSign\u003dEvaluate\u0026mall3_token\u003d{mall3_token}", - "name": "专家评价", - "frame": "S" - }, - { - "path": "/ExpertInfo/ExpertInformationManage", - "name": "专家信息管理", - "frame": "N" - }, - { - "path": "/ExpertInfo/ExpertExtractionAvoidance", - "name": "专家抽取回避", - "frame": "N" - } - ], - "feignFlag": null - }, - { - "menuId": "1565574276328947714", - "path": "VideoMonitor", - "name": "视频监控查询", - "icon": "PlaySquareOutlined", - "menuScope": "EBTP", - "menuOu": null, - "isTop": 0, - "children": [ - { - "path": "/HistoryVideo", - "name": "历史视频上传列表", - "frame": "N" - } - ], - "feignFlag": null - }, - { - "menuId": "1722061270189662209", - "path": "PurchaseReOffer", - "name": "采购复盘与检查", - "icon": "BookOutlined", - "menuScope": "EBTP", - "menuOu": null, - "isTop": 0, - "children": [ - { - "path": "/PurchaseReOffer", - "name": "采购复盘与检查表", - "frame": "N" - } - ], - "feignFlag": null - }, - { - "menuId": "1767358998249476098", - "path": "UnbalancedBid", - "name": "不均衡报价分析", - "icon": "BookOutlined", - "menuScope": "EBTP", - "menuOu": null, - "isTop": 0, - "children": [ - { - "path": "/UnbalancedBidList", - "name": "不均衡报价分析表", - "frame": "N" - } - ], - "feignFlag": null - } - ] - } - setMenuData(res.data || []) - if (dispatch) { - dispatch({ - type: 'user/saveMenuData', - payload: res.data || [], - }); - } - setmenuShow(true) - // getMenu(params).then(res => { - // if (res.code == 1) { - // setMenuData(res.data || []) - // setmenuShow(true) - // } else { - // message.error("数据错误请联系管理员") - // } - // }) + // setMenuData( res.data || []) + // setmenuShow(true) + getMenu(params).then(res => { + if (res.code == 200) { + setMenuData(res.data || []) + setmenuShow(true) + } else { + message.error("数据错误请联系管理员") + } + }) } }, []); diff --git a/src/layouts/services.ts b/src/layouts/services.ts index 06780e8..46d20ae 100644 --- a/src/layouts/services.ts +++ b/src/layouts/services.ts @@ -1,9 +1,9 @@ import request from '@/utils/request'; export async function getMenu(params: any) { - let requestUrl = '/api/core-service-usercenter-public/v1.0/menu/findMenuList'; + let requestUrl = '/api/sys-manager-ebtp-project/v1/menu/findMenuList'; return request(requestUrl, { method: 'POST', data: params, }); -} \ No newline at end of file +} diff --git a/src/pages/Dict/DictionaryList.tsx b/src/pages/Dict/DictionaryList.tsx deleted file mode 100644 index e430f7c..0000000 --- a/src/pages/Dict/DictionaryList.tsx +++ /dev/null @@ -1,386 +0,0 @@ -import React, { useEffect, useState } from 'react'; -import { Table, Space, Button, Modal, Form, Input, Popconfirm, message, Tag } from 'antd'; -import { DeleteOutlined, EditOutlined, PlusOutlined, SearchOutlined, CheckCircleOutlined, CaretRightOutlined, CaretDownOutlined } from '@ant-design/icons'; -import {DictionaryItem, createDictionary, updateDictionary, deleteDictionary, fetchDictionaries} from './DictService'; - -interface DictionaryListProps {} - -const DictionaryList: React.FC = () => { - const [dataSource, setDataSource] = useState([]); - const [form] = Form.useForm(); - const [searchForm] = Form.useForm(); - const [isModalVisible, setIsModalVisible] = useState(false); - const [modalTitle, setModalTitle] = useState(''); - const [currentId, setCurrentId] = useState(null); - const [loading, setLoading] = useState(false); - const [searchParams, setSearchParams] = useState({ - parentCode: '', - parentType: '' - }); - // 选中的行ID - const [selectedRowId, setSelectedRowId] = useState(null); - // 选中的行数据 - const [selectedRow, setSelectedRow] = useState(null); - // 展开的行ID - const [expandedRowKeys, setExpandedRowKeys] = useState([]); - // 是否为新增子节点模式 - const [isChildAddMode, setIsChildAddMode] = useState(false); - - // const tableData: DictionaryItem[] = [ - // { - // "id": '1164', - // "code": "code", - // "dicName": "行政区划", - // "parentCode": '', - // "parentType": "", - // "orderFlag": 0, - // "description": '', - // "children": [ - // { - // "id": 1163, - // "code": "province", - // "dicName": "省份", - // "parentCode": "code", - // "parentType": "行政区划", - // "orderFlag": 1, - // "description": '' - // }, - // { - // "id": 1162, - // "code": "city", - // "dicName": "地市", - // "parentCode": "code", - // "parentType": "行政区域", - // "orderFlag": 3, - // "description": '' - // }, - // { - // "id": 1161, - // "code": "distict", - // "dicName": "区县", - // "parentCode": "code", - // "parentType": "行政区域", - // "orderFlag": 4, - // "description": "区县级" - // } - // ] - // } - // ]; - - const fetchData = async () => { - setLoading(true); - try { - const result = await fetchDictionaries(searchParams); // 传递搜索参数 - setDataSource(result.data); - } catch (error) { - message.error('获取字典列表失败'); - } finally { - setLoading(false); - } - }; - - useEffect(() => { - fetchData(); - }, [searchParams]); - - const handleAdd = () => { - form.resetFields(); - setModalTitle('新增字典'); - setIsModalVisible(true); - setCurrentId(null); - setIsChildAddMode(false); - }; - - const handleChildAdd = (record: DictionaryItem) =>{ - // 先清空表单 - form.resetFields(); - // 使用 setTimeout 确保表单重置完成后再设置值 - setTimeout(() => { - form.setFieldsValue({ - code: '', - dicName: '', - parentCode: record.code, - parentType: record.dicName, - orderFlag: '', - description: '', - }); - }, 0); - - setModalTitle(`新增${record.dicName}的子字典`); - setIsModalVisible(true); - setCurrentId(null); - setIsChildAddMode(true); - } - - const handleEdit = (record: DictionaryItem) => { - form.resetFields(); - - setTimeout(() => { - form.setFieldsValue({ - code: record.code, - dicName: record.dicName, - parentCode: record.parentCode, - parentType: record.parentType, - orderFlag: record.orderFlag, - description: record.description, - }); - }, 0); - - setModalTitle('编辑字典'); - setIsModalVisible(true); - setCurrentId(record.id); - setIsChildAddMode(false); - }; - - const handleDelete = async (id: string) => { - try { - await deleteDictionary(id); - message.success('删除成功'); - setSelectedRowId(null); - setSelectedRow(null); - fetchData(); - } catch (error) { - message.error('删除失败'); - } - }; - - const handleRowClick = (record: DictionaryItem) => { - if (selectedRowId === record.id) { - setSelectedRowId(null); - setSelectedRow(null); - } else { - setSelectedRowId(record.id); - setSelectedRow(record); - } - }; - - const handleExpand = (expanded: boolean, record: DictionaryItem) => { - if (expanded) { - setExpandedRowKeys([...expandedRowKeys, record.id]); - } else { - setExpandedRowKeys(expandedRowKeys.filter(key => key !== record.id)); - } - }; - - const handleSubmit = async () => { - try { - const values = await form.validateFields(); - if (currentId) { - values.id = currentId; - await updateDictionary(values); - message.success('更新成功'); - } else { - await createDictionary(values); - message.success('创建成功'); - } - setIsModalVisible(false); - fetchData(); - } catch (error) { - message.error(error.message || '操作失败'); - } - }; - - const handleSearch = (values: any) => { - setSearchParams({ - parentCode: values.parentCode || '', - parentType: values.parentType || '' - }); - }; - - const handleReset = () => { - searchForm.resetFields(); - setSearchParams({ - parentCode: '', - parentType: '' - }); - }; - - const expandIcon = ({ expanded, onExpand, record }: any) => { - if (record.children && record.children.length > 0) { - return ( - { - e.stopPropagation(); - onExpand(record); - }}> - {expanded ? : } - - ); - } - return null; - }; - - const columns = [ - { - title: '字典编号', - dataIndex: 'code', - key: 'code', - }, - { - title: '字典名称', - dataIndex: 'dicName', - key: 'dicName', - }, - { - title: '分组编码', - dataIndex: 'parentCode', - key: 'parentCode', - }, - { - title: '分组名称', - dataIndex: 'parentType', - key: 'parentType', - }, - { - title: '排序', - dataIndex: 'orderFlag', - key: 'orderFlag', - }, - { - title: '描述', - dataIndex: 'description', - key: 'description', - }, - { - title: '操作', - key: 'action', - render: (_: any, record: DictionaryItem) => ( - - - - handleDelete(record.id)} - okText="确定" - cancelText="取消" - > - - - - ), - }, - ]; - - return ( -
-
- - - - - - - - - - - - -
- -
- - - - {selectedRow && ( - - 已选择: {selectedRow.dicName} - - )} -
- - ({ - onClick: () => handleRowClick(record), - style: { - cursor: 'pointer', - backgroundColor: selectedRowId === record.id ? '#e6f7ff' : 'transparent', - }, - })} - expandable={{ - expandedRowKeys, - onExpand: handleExpand, - expandIcon, - }} - /> - - setIsModalVisible(false)} - onOk={handleSubmit} - okText="保存" - cancelText="取消" - > -
- - {/* 使用 readOnly 替代 disabled,并添加灰色背景 */} - - - - - - - - - - - - - - - - - - -
- - ); -}; - -export default DictionaryList; diff --git a/src/pages/Dict/DictionaryPage.tsx b/src/pages/Dict/DictionaryPage.tsx deleted file mode 100644 index 5fba497..0000000 --- a/src/pages/Dict/DictionaryPage.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import React from 'react'; -import { Layout, Breadcrumb } from 'antd'; -import DictionaryList from './DictionaryList'; - -const { Content } = Layout; - -const DictionaryPage: React.FC = () => { - return ( - - - 系统管理 - 字典管理 - - - - - - ); -}; - -export default DictionaryPage; diff --git a/src/pages/LoadingPage/index.tsx b/src/pages/LoadingPage/index.tsx index 47f2c36..b40b4cf 100644 --- a/src/pages/LoadingPage/index.tsx +++ b/src/pages/LoadingPage/index.tsx @@ -88,7 +88,7 @@ const Loading: React.FC<{}> = () => { } setUserData(userData, role, roleData); // } - // await setDict();//存字典 + await setDict();//存字典 setTimeout(() => { history.push({ pathname: `/${url}`, @@ -256,6 +256,7 @@ const Loading: React.FC<{}> = () => { url == 'ExamineAndApprove/ExternalReference' || url == 'ExamineAndApprove/FailureAnnouncement') { const newAuthority: any[] = [] + debugger newAuthority.push({ authorities: [null, "system:user:test", "system:user:test", "system:user:test", "system:user:test", null, null], roleCode: "ebtp-cosco-default", diff --git a/src/pages/LoadingPage/service.ts b/src/pages/LoadingPage/service.ts index dc5401e..8666a71 100644 --- a/src/pages/LoadingPage/service.ts +++ b/src/pages/LoadingPage/service.ts @@ -57,7 +57,7 @@ export function cooperReloadToken(params: any, header: any) { * @returns */ export async function getDictionaries() { - return request('/api/biz-service-ebtp-project/v1/dictProject/refreshDictCache'); + return request('/api/sys-manager-ebtp-project/v1/dictProject/refreshDictCache'); } /** * 根据projectId获取项目信息 diff --git a/src/pages/Menu/MenuManagementPage.tsx b/src/pages/Menu/MenuManagementPage.tsx deleted file mode 100644 index 19a0d42..0000000 --- a/src/pages/Menu/MenuManagementPage.tsx +++ /dev/null @@ -1,426 +0,0 @@ -import React, {useState, useEffect} from 'react'; -import {Button, Form, Input, Select, Table, Modal, message, Popconfirm} from 'antd'; -import { DeleteOutlined } from '@ant-design/icons'; -import { - fetchMenuList, - updateMenu, - deleteMenu, - createMenu -} from "@/pages/Menu/MenuService"; - -const {Option} = Select; - -// 模拟菜单数据结构 -type MenuItem = { - id: number; - menuId: number; - key: number; - menuName: string; - parentId: number; - orderNum: number; - path: string; - component: string; - isFrame: number; - isCache: number; - menuType: 'M' | 'C' | 'F'; - visible: string; - status: string; - perms: string; - icon: string; - createBy: string; - createTime: string; - updateBy: string; - updateTime: string; - remark: string; - children?: MenuItem[]; // 用于处理树结构 -}; - -// 模拟后端返回数据 -// @ts-ignore -const mockMenuData: MenuItem[] = []; - -const MenuManagement: React.FC = () => { - const [form] = Form.useForm(); - const [folder, setFolder] = useState(false); - const [btn, setBtn] = useState(false); - const [loading, setLoading] = useState(false); - const [menuList, setMenuList] = useState([]); - const [visible, setVisible] = useState(false); - const [editingItem, setEditingItem] = useState(null); - // const [status, setStatus] = useState(''); - const [searchMenuName, setSearchMenuName] = useState(''); - const [searchStatus, setSearchStatus] = useState(''); - const [expandedRowKeys, setExpandedRowKeys] = useState([]); - - const onExpand = (expanded: any, record: any) => { - if (expanded) { - setExpandedRowKeys([record.id]); - } else { - setExpandedRowKeys([]); - } - }; - - const fetchMenu = async () => { - setLoading(true); - try { - const result = await fetchMenuList({}); // 传递搜索参数 - setMenuList(result.data); - } catch (error) { - message.error('获取字典列表失败'); - } finally { - setLoading(false); - } - }; - - useEffect(() => { - fetchMenu(); - }, [searchMenuName, searchStatus]); - - // 处理编辑 - const handleEdit = (item: MenuItem) => { - debugger; - setEditingItem(item); - form.setFieldsValue({ - id: item.menuId, - parentId: item.parentId, - // parentName: item.parentName, - menuName: item.menuName, - orderNum: item.orderNum, - path: item.path, - component: item.component, - isFrame: item.isFrame, - isCache: item.isCache, - menuType: item.menuType, - visible: item.visible, - status: item.status, - perms: item.perms, - icon: item.icon, - remark: item.remark, - }); - setVisible(true); - }; - - const handleDelete = async (menuItem: MenuItem) => { - const id = menuItem.menuId; - try { - await deleteMenu(id); // 使用 `await` 等待删除接口完成 - message.success('删除成功'); - await fetchMenu(); // 调用已有的 `fetchMenu` 刷新数据 - } catch (error) { - message.error('删除失败'); - } - }; - - // 处理新增子菜单 - const handleAddSub = (parentItem: MenuItem) => { - setEditingItem({ - ...parentItem, - menuId: -1, // 临时标识新增项 - }); - form.setFieldsValue({ - id: null, - menuName: '', - orderNum: 0, - path: '', - component: '', - isFrame: 1, - isCache: 0, - menuType: 'C', - visible: '0', - status: '0', - perms: '', - icon: '', - remark: '', - parentId: parentItem.menuId - }); - setVisible(true); - }; - // 表格列配置 - // @ts-ignore - const columns: Table.ColumnType[] = [ - { - title: '菜单名称', - dataIndex: 'menuName', - key: 'menuName', - }, - { - title: '排序', - dataIndex: 'orderNum', - key: 'orderNum', - }, - { - title: '权限标识', - dataIndex: 'perms', - key: 'perms', - }, - { - title: '组件路径', - dataIndex: 'component', - key: 'component', - }, - { - title: '状态', - dataIndex: 'status', - key: 'status', - render: (text: string) => (text === '0' ? '正常' : '停用'), - }, - { - title: '创建时间', - dataIndex: 'createTime', - key: 'createTime', - }, - { - title: '操作', - key: 'action', - render: (_: any, record: any) => ( -
- - - handleDelete(record)} - okText="确定" - cancelText="取消" - > - - -
- ), - }, - ]; - - // 显示模态框 - const handleAdd = () => { - setEditingItem(null); - form.resetFields(); - setVisible(true); - }; - - // 模态框确定按钮处理 - const handleOk = async () => { - const values = await form.validateFields(); - debugger; - if (editingItem) { - if (editingItem.menuId === -1) { - // 新增操作 - const newItem: MenuItem = { - ...values - }; - await createMenu(newItem); - message.success('创建成功'); - fetchMenu(); - } else { - // 编辑操作 - const newItem: MenuItem = { - ...values - }; - await updateMenu(newItem); - message.success('修改成功'); - fetchMenu(); - } - } else { - await createMenu(values); - message.success('创建成功'); - fetchMenu(); - } - setVisible(false); - }; - - // 模态框取消按钮处理 - const handleCancel = () => { - setVisible(false); - form.resetFields(); - }; - - // 搜索功能处理 - const handleSearch = () => { - const filteredData = menuList.filter(item => { - const nameMatch = item.menuName.includes(searchMenuName); - const statusMatch = searchStatus === '' || item.status === searchStatus; - return nameMatch && statusMatch; - }); - setMenuList(filteredData); - }; - - // 重置搜索功能处理 - const handleReset = () => { - setSearchMenuName(''); - setSearchStatus(''); - setMenuList(mockMenuData); - }; - - const handleMenuTypeChange = (value: string) => { - if (value == 'M') { - setFolder(true) - setBtn(false) - } else if (value == 'F') { - setBtn(true) - setFolder(false) - } else { - setFolder(false) - setBtn(false) - } - }; - - - // @ts-ignore - return ( -
-
- - setSearchMenuName(e.target.value)} - /> - - - - - - - - -
record.id} - dataSource={menuList} - columns={columns} - expandable={{ - expandedRowKeys, - onExpand, - }}> -
- -
- - - - - - - - - - - - - - - - - - - - - -
-
-
- ); -}; - -export default MenuManagement; diff --git a/src/pages/Menu/MenuService.ts b/src/pages/Menu/MenuService.ts deleted file mode 100644 index 2931d89..0000000 --- a/src/pages/Menu/MenuService.ts +++ /dev/null @@ -1,31 +0,0 @@ -import request from "@/utils/request"; - - -const prefix = '/api/sys-manager-ebtp-project/'; - -export async function fetchMenuList(params: any) { - return request(prefix + 'v1/menu/treeselect', { - params: params, - method: 'GET' - }); -} - -export async function createMenu(params: any) { - return request(prefix + 'v1/menu', { - data: params, - method: 'POST' - }); -} - -export async function updateMenu(params: any) { - return request(prefix + 'v1/menu', { - data: params, - method: 'PUT' - }); -} - -export async function deleteMenu(param: any) { - return request(prefix + 'v1/menu/delete/' + param, { - method: 'DELETE', - }); -} diff --git a/src/pages/System/Department/index.tsx b/src/pages/System/Department/index.tsx index 6c3444a..6601162 100644 --- a/src/pages/System/Department/index.tsx +++ b/src/pages/System/Department/index.tsx @@ -15,20 +15,20 @@ const Index: React.FC<{}> = () => { wrapperCol: { span: 13 }, }; const columns: ProColumns[] = [ - { - title: '组织编码', - dataIndex: 'orgNum', - width: '10%', - }, + // { + // title: '组织编码', + // dataIndex: 'orgNum', + // width: '15%', + // }, { title: '组织名称', dataIndex: 'orgName', - width: '30%', + width: '45%', }, { title: '组织全称', dataIndex: 'orgFullName', - width: '45%', + width: '40%', hideInSearch: true, }, { diff --git a/src/pages/System/Dict/index.tsx b/src/pages/System/Dict/index.tsx new file mode 100644 index 0000000..5582246 --- /dev/null +++ b/src/pages/System/Dict/index.tsx @@ -0,0 +1,283 @@ +import React, { useRef, useState } from 'react'; +import { Button, Form, Input, message, Modal, Spin, Tag } from 'antd'; +import ProTable, { ProColumns, ActionType } from '@ant-design/pro-table'; +import { PlusOutlined, EditOutlined, DeleteOutlined, CheckCircleOutlined } from '@ant-design/icons'; +import { DictionaryItem, createDictionary, updateDictionary, deleteDictionary, fetchDictionaries } from './service'; + +const Index: React.FC = () => { + const [form] = Form.useForm(); + const [modalTitle, setModalTitle] = useState(''); + const [isModalVisible, setIsModalVisible] = useState(false); + const [currentId, setCurrentId] = useState(null); + const [loading, setLoading] = useState(false); + const [isChildAddMode, setIsChildAddMode] = useState(false); + const [selectedRow, setSelectedRow] = useState(null); + const [selectedRowId, setSelectedRowId] = useState(null); + const actionRef = useRef(); + + // 搜索参数 + const [searchParams, setSearchParams] = useState({ + parentCode: '', + parentType: '' + }); + + // 新增字典 + const handleAdd = () => { + form.resetFields(); + setModalTitle('新增字典'); + setIsModalVisible(true); + setCurrentId(null); + setIsChildAddMode(false); + }; + + // 新增子节点 + const handleChildAdd = (record: DictionaryItem) => { + form.resetFields(); + setTimeout(() => { + form.setFieldsValue({ + code: '', + dicName: '', + parentCode: record.code, + parentType: '', + orderFlag: '', + description: '', + }); + }, 0); + setModalTitle(`新增${record.dicName}的子字典`); + setIsModalVisible(true); + setCurrentId(null); + setIsChildAddMode(true); + }; + + // 编辑 + const handleEdit = (record: DictionaryItem) => { + form.resetFields(); + setTimeout(() => { + form.setFieldsValue({ + code: record.code, + dicName: record.dicName, + parentCode: record.parentCode, + parentType: record.parentType, + orderFlag: record.orderFlag, + description: record.description, + }); + }, 0); + setModalTitle('编辑字典'); + setIsModalVisible(true); + setCurrentId(record.id); + setIsChildAddMode(false); + }; + + // 删除 + const handleDelete = (id: string) => { + Modal.confirm({ + title: '确定要删除该字典吗?', + onOk: async () => { + setLoading(true); + try { + await deleteDictionary(id); + message.success('删除成功'); + setSelectedRowId(null); + setSelectedRow(null); + actionRef.current?.reload(); + } catch { + message.error('删除失败'); + } finally { + setLoading(false); + } + }, + }); + }; + + // 选中行高亮 + const handleRowClick = (record: DictionaryItem) => { + if (selectedRowId === record.id) { + setSelectedRowId(null); + setSelectedRow(null); + } else { + setSelectedRowId(record.id); + setSelectedRow(record); + } + }; + + // 弹窗表单提交 + const handleSubmit = async () => { + try { + const values = await form.validateFields(); + debugger + setLoading(true); + if (currentId) { + values.id = currentId; + await updateDictionary(values); + message.success('更新成功'); + } else { + await createDictionary(values); + message.success('创建成功'); + } + setIsModalVisible(false); + actionRef.current?.reload(); + } catch (error: any) { + message.error(error.message || '操作失败'); + } finally { + setLoading(false); + } + }; + + // 表格列 + const columns: ProColumns[] = [ + { title: '字典编号', dataIndex: 'code', width: 120 }, + { title: '字典名称', dataIndex: 'dicName', width: 120 }, + { title: '上级编码', dataIndex: 'parentCode', width: 120, search: false }, + { title: '分组类别', dataIndex: 'parentType', width: 120, search: false }, + { title: '排序', dataIndex: 'orderFlag', width: 80, search: false }, + { title: '描述', dataIndex: 'description', width: 180, search: false }, + { + title: '操作', + valueType: 'option', + width: 180, + render: (_, record) => [ + , + , + , + ], + }, + ]; + + // 弹窗表单 + const modalForm = ( + setIsModalVisible(false)} + okText="保存" + cancelText="取消" + > +
+ {/* 新增下级时只读,编辑时 parentCode 也只读 */} + {isChildAddMode && !currentId && ( + <> + + + + + + + + )} + {/* 编辑时 parentCode 只读,parentType 可编辑 */} + {currentId && ( + <> + + + + + + + + )} + + + + + + + + + + + + +
+
+ ); + + return ( + +
+
+ + {selectedRow && ( + + 已选择: {selectedRow.dicName} + + )} +
+ + actionRef={actionRef} + columns={columns} + rowKey="id" + search={{ + labelWidth: 'auto', + span: 6, + defaultCollapsed: false, + }} + options={false} + bordered={false} + size="small" + pagination={{ defaultPageSize: 10 }} + request={async (params) => { + setSearchParams({ + parentCode: '', + parentType: '' + }); + setLoading(true); + try { + const result = await fetchDictionaries({ + code: params.code || '', + dicName: params.dicName || '', + pageNo: params.current, + pageSize: params.pageSize + }); + return { + data: result.data.records || result.data || [], + total: result.data.total || (result.data.records ? result.data.records.length : 0), + success: true, + pageSize: result.data.size || 10, + current: result.data.current || 1 + }; + } catch { + return { data: [], total: 0, success: false }; + } finally { + setLoading(false); + } + }} + onRow={(record) => { + return { + onClick: () => handleRowClick(record), + style: { + cursor: 'pointer', + backgroundColor: selectedRowId === record.id ? '#e6f7ff' : 'transparent', + }, + }; + }} + toolBarRender={false} + /> + {modalForm} +
+
+ ); +}; + +export default Index; diff --git a/src/pages/Dict/DictService.ts b/src/pages/System/Dict/service.ts similarity index 100% rename from src/pages/Dict/DictService.ts rename to src/pages/System/Dict/service.ts diff --git a/src/pages/System/Role/index.tsx b/src/pages/System/Role/index.tsx index 3325fbb..b0add3b 100644 --- a/src/pages/System/Role/index.tsx +++ b/src/pages/System/Role/index.tsx @@ -1,15 +1,16 @@ import React, { useState, useRef } from 'react'; import { message, Modal, Input, Form, PageHeader, Button, Spin, Select, Tree } from 'antd'; import ProTable, { ProColumns, ActionType } from '@ant-design/pro-table'; -import tableProps from '@/utils/tableProps'; -import { getPage, getDataById, deleteRole, addRole, updateRole } from './service'; +import { getPage, getDataById, deleteRole, addRole, updateRole, getMenuTreeAll } from './service'; // import './styles.less'; import { getDicData } from '@/utils/session'; import TextArea from 'antd/lib/input/TextArea'; +import { proTableValueEnum } from '@/utils/CommonUtils'; const entrust: React.FC<{}> = () => { //获取字典 const getDict: any = getDicData(); + const { Option } = Select; const [form] = Form.useForm(); const [title, setTitle] = useState(''); const [open, setOpen] = useState(false); @@ -17,6 +18,7 @@ const entrust: React.FC<{}> = () => { const [checkedKeys, setCheckedKeys] = useState([]); const [currentRoleId, setCurrentRoleId] = useState(null); const dictData = JSON.parse(getDict); + console.log(dictData) const actionRef = useRef(); const [spin, spinSet] = useState(false); //查询分页数据 @@ -32,9 +34,21 @@ const entrust: React.FC<{}> = () => { value: string; label: string; } - const sys_normal_scope: DictType[] = [ - { value: 'EBTP', label: '招标采购中心' }, - ]; + const sys_normal_scope = createSelect(dictData['role_scope=system']) + + /** + * 加载Option + * @param data 数据源 + */ +function createSelect(data: any) { + let value = []; + for (const item of data) { + value.push( + + ) + } + return value; +} //委托列表 const columns: ProColumns[] = [ @@ -43,7 +57,7 @@ const entrust: React.FC<{}> = () => { { title: '权限字符', dataIndex: 'roleCode', width: '10%' }, { title: '角色范围', dataIndex: 'roleScope', - valueEnum: { 'EBTP': { text: '招标采购中心', status: 'EBTP' }, }, + valueEnum: proTableValueEnum(dictData['role_scope=system']), render: (_, record) => { if (record.roleScope === 'EBTP') { return (<>招标采购中心) @@ -78,45 +92,11 @@ const entrust: React.FC<{}> = () => { }, }); }; - const handleAdd = async () => { - form.resetFields(); - // const menus = await menuTreeselect(); - // setMenuOptions(menus.data || []); - // setMenuOptions(menu || []); - - // 使用时转换 - setMenuOptions(formatMenuOptions(menu) || []); - setOpen(true); - setTitle('添加角色'); - }; - const [menuOptions, setMenuOptions] = useState([]); - let menu = [{ - "id": '1', "parentId": '0', "label": "系统管理", "weight": 1, - "children": [{ - "id": '101', "parentId": '1', "label": "角色管理", "weight": 2, - "children": [{ "id": '1008', "parentId": '101', "label": "角色查询", "weight": 1 }, - { "id": '1009', "parentId": '101', "label": "角色新增", "weight": 2 }, - { "id": '1010', "parentId": '101', "label": "角色修改", "weight": 3 }, - { "id": '1011', "parentId": '101', "label": "角色删除", "weight": 4 }, - { "id": '1012', "parentId": '101', "label": "角色导出", "weight": 5 }] - }, - { - "id": '105', "parentId": '1', "label": "字典管理", "weight": 6, - "children": [{ "id": '1026', "parentId": '105', "label": "字典查询", "weight": 1 }, - { "id": '1027', "parentId": '105', "label": "字典新增", "weight": 2 }, - { "id": '1028', "parentId": '105', "label": "字典修改", "weight": 3 }, - { "id": '1029', "parentId": '105', "label": "字典删除", "weight": 4 }, - { "id": '1030', "parentId": '105', "label": "字典导出", "weight": 5 }] - }] - }, - { "id": '4', "parentId": '0', "label": "PLUS官网", "weight": 4 }, - { - "id": "1494925781048545281", "parentId": '0', "label": "个人待办", "weight": 18, - "children": [{ "id": "1494926258733633538", "parentId": "1494925781048545281", "label": "待办任务", "weight": 1 }, - { "id": "1494926586677874690", "parentId": "1494925781048545281", "label": "已办任务", "weight": 2 }] - }]; - const formatMenuOptions = (data: any[]) => { + const [menuLoading, setMenuLoading] = useState(false); + // 新增格式化菜单树函数 + const formatMenuOptions = (data: any[]): any[] => { + if (!data) return []; return data.map(item => ({ title: item.label, key: item.id, @@ -124,18 +104,41 @@ const entrust: React.FC<{}> = () => { })); }; + // 新增菜单树加载函数 + const loadMenuTree = async () => { + setMenuLoading(true); + try { + const res = await getMenuTreeAll(); + if (res?.code === 200 && Array.isArray(res.data)) { + setMenuOptions(formatMenuOptions(res.data)); + } else { + setMenuOptions([]); + message.error('菜单数据获取失败'); + } + } catch (e) { + setMenuOptions([]); + message.error('菜单数据获取异常'); + } + setMenuLoading(false); + }; + + const handleAdd = async () => { + form.resetFields(); + setCheckedKeys([]); + await loadMenuTree(); + setOpen(true); + setTitle('添加角色'); + }; + const handleUpdate = async (record: any) => { form.resetFields(); const role = await getDataById(record.roleId); - // const menus = await roleMenuTreeselect(record.roleId); - // setMenuOptions(menus.data.menus || []); - setMenuOptions(formatMenuOptions(menu) || []); + await loadMenuTree(); setCheckedKeys(role.data.menuIds || []); form.setFieldsValue({ ...role.data, menuIds: role.data.menuIds || [], }); - // form.setFieldsValue(role.data); setCurrentRoleId(record.roleId); setOpen(true); setTitle('修改角色'); @@ -198,27 +201,25 @@ const entrust: React.FC<{}> = () => {