diff --git a/mock/system/role.ts b/mock/system/role.ts new file mode 100644 index 0000000..bedef36 --- /dev/null +++ b/mock/system/role.ts @@ -0,0 +1,39 @@ +import { resultSuccess, doCustomTimes } from '../_util' + +const roleList = ((pageSize) => { + const result:any[] = [] + doCustomTimes(pageSize,()=> { + result.push({ + id: '@integer(10,100)', + name: '@cname()', + explain:'@cname()', + isDefault:'@boolean()', + create_date: `@date('yyyy-MM-dd')`, + 'status|1': ['normal', 'enable', 'disable'], + }); + }) + return result +}); + + +export default [ + //表格数据列表 + { + url: '/api/role/list', + timeout: 1000, + method: 'get', + response: ({ query }) => { + const { page = 1, pageSize = 10 } = query; + const list = roleList(Number(pageSize)) + return resultSuccess({ + page:Number(page), + pageSize:Number(pageSize), + pageCount: 60, + list + } + ); + }, + } +] + + diff --git a/src/api/system/role.ts b/src/api/system/role.ts new file mode 100644 index 0000000..a5b6661 --- /dev/null +++ b/src/api/system/role.ts @@ -0,0 +1,11 @@ +import http from '@/utils/http/axios' + +/** + * @description: 角色列表 + */ +export function getRoleList() { + return http.request({ + url: '/role/list', + method: 'GET' + }) +} \ No newline at end of file diff --git a/src/plugins/naive.ts b/src/plugins/naive.ts index 4577169..95780cd 100644 --- a/src/plugins/naive.ts +++ b/src/plugins/naive.ts @@ -60,7 +60,8 @@ import { NInputNumber, NLoadingBarProvider, NModal, - NUpload + NUpload, + NTree } from 'naive-ui' const naive = create({ @@ -124,7 +125,8 @@ const naive = create({ NInputNumber, NLoadingBarProvider, NModal, - NUpload + NUpload, + NTree ] }) diff --git a/src/router/modules/system.ts b/src/router/modules/system.ts new file mode 100644 index 0000000..237bec9 --- /dev/null +++ b/src/router/modules/system.ts @@ -0,0 +1,50 @@ +import { RouteRecordRaw } from 'vue-router' +import { Layout } from '@/router/constant'; +import { ToolOutlined } from '@vicons/antd' +import { OptionsSharp } from '@vicons/ionicons5' +import { renderIcon } from '@/utils/index' + +/** + * @param name 路由名称, 必须设置,且不能重名 + * @param meta 路由元信息(路由附带扩展信息) + * @param redirect 重定向地址, 访问这个路由时,自定进行重定向 + * @param meta.disabled 禁用整个菜单 + * @param meta.title 菜单名称 + * @param meta.icon 菜单图标 + * @param meta.keepAlive 缓存该路由 + * @param meta.sort 排序越小越排前 + * + * */ +const routes: Array = [ + { + path: '/system', + name: 'System', + redirect: '/system/menu', + component: Layout, + meta: { + title: '系统设置', + icon: renderIcon(OptionsSharp), + sort: 1 + }, + children: [ + { + path: 'menu', + name: 'system_menu', + meta: { + title: '菜单权限管理', + }, + component: () => import('@/views/system/menu/menu.vue') + }, + { + path: 'role', + name: 'system_role', + meta: { + title: '角色权限管理', + }, + component: () => import('@/views/system/role/role.vue') + } + ], + } +] + +export default routes diff --git a/src/views/system/menu/menu.vue b/src/views/system/menu/menu.vue new file mode 100644 index 0000000..a7c4fe8 --- /dev/null +++ b/src/views/system/menu/menu.vue @@ -0,0 +1,196 @@ + + + diff --git a/src/views/system/role/columns.ts b/src/views/system/role/columns.ts new file mode 100644 index 0000000..e266cfa --- /dev/null +++ b/src/views/system/role/columns.ts @@ -0,0 +1,66 @@ +import { h } from 'vue' +import { NTag, NButton } from 'naive-ui' + +export const columns = [ + { + title: 'id', + key: 'id' + }, + { + title: '角色名称', + key: 'name' + }, + { + title: '说明', + key: 'explain' + }, + { + title: '是否默认角色', + key: 'isDefault', + render(row) { + return h( + NTag, + { + type: row.isDefault ? 'success' : 'error' + }, + { + default: () => row.isDefault ? '是' : '否' + } + ) + } + }, + { + title: '创建时间', + key: 'create_date' + }, + { + title: '操作', + key: 'actions', + width: 150, + //简单写一下例子,不建议这么写,过段时间,这里封二次封装 + render() { + return [ + h( + NButton, + { + size: 'small', + type: 'error', + style: 'margin-right:10px', + onClick: () => { + } + }, + { default: () => '删除' } + ), + h( + NButton, + { + size: 'small', + onClick: () => { + } + }, + { default: () => '编辑' } + ) + ] + } + } +] diff --git a/src/views/system/role/role.vue b/src/views/system/role/role.vue new file mode 100644 index 0000000..bac02a3 --- /dev/null +++ b/src/views/system/role/role.vue @@ -0,0 +1,161 @@ + + + + +