diff --git a/locales/en.yaml b/locales/en.yaml index 1b20de73f..acb8fa696 100644 --- a/locales/en.yaml +++ b/locales/en.yaml @@ -24,7 +24,8 @@ menus: hssysManagement: System Manage hsBaseinfo: Base Info hsDict: Dict Manage - hsJob: Job Manage + hsPost: Post Manage + hsDept: Dept Manage hseditor: Editor hserror: Error Page hsfourZeroFour: "404" diff --git a/locales/zh-CN.yaml b/locales/zh-CN.yaml index fd74ebfbf..df5deaa9f 100644 --- a/locales/zh-CN.yaml +++ b/locales/zh-CN.yaml @@ -24,7 +24,8 @@ menus: hssysManagement: 系统管理 hsBaseinfo: 基础信息 hsDict: 字典管理 - hsJob: 岗位管理 + hsPost: 岗位管理 + hsDept: 部门管理 hseditor: 编辑器 hserror: 错误页面 hsfourZeroFour: "404" diff --git a/mock/asyncRoutes.ts b/mock/asyncRoutes.ts index 73da0a0b6..d94af5318 100644 --- a/mock/asyncRoutes.ts +++ b/mock/asyncRoutes.ts @@ -30,10 +30,18 @@ const systemRouter = { } }, { - path: "/system/job/index", - name: "job", + path: "/system/post/index", + name: "post", meta: { - title: "menus.hsJob", + title: "menus.hsPost", + i18n: true + } + }, + { + path: "/system/dept/index", + name: "dept", + meta: { + title: "menus.hsDept", i18n: true } } diff --git a/mock/system.ts b/mock/system.ts index a8dac3478..5057dc933 100644 --- a/mock/system.ts +++ b/mock/system.ts @@ -51,5 +51,137 @@ export default [ msg: "" }; } + }, + { + url: "/dept", + method: "post", + response: () => { + return { + code: 0, + data: [ + { + name: "pure-admin", + parentId: 0, + sort: 0, + leaderUserId: 1, + phone: "15888888888", + email: "ry@qq.com", + status: 0, + id: 100, + createTime: 1609837427000, + remark: "备注、备注、备注、备注、备注、备注、备注" + }, + { + name: "深圳总公司", + parentId: 100, + sort: 1, + leaderUserId: 104, + phone: "15888888888", + email: "ry@qq.com", + status: 0, + id: 101, + createTime: 1609837427000, + remark: "备注、备注、备注、备注、备注、备注、备注" + }, + { + name: "研发部门", + parentId: 101, + sort: 1, + leaderUserId: 104, + phone: "15888888888", + email: "ry@qq.com", + status: 0, + id: 103, + createTime: 1609837427000, + remark: "备注、备注、备注、备注、备注、备注、备注" + }, + { + name: "市场部门", + parentId: 102, + sort: 1, + leaderUserId: null, + phone: "15888888888", + email: "ry@qq.com", + status: 0, + id: 108, + createTime: 1609837427000, + remark: "备注、备注、备注、备注、备注、备注、备注" + }, + { + name: "长沙分公司", + parentId: 100, + sort: 2, + leaderUserId: null, + phone: "15888888888", + email: "ry@qq.com", + status: 0, + id: 102, + createTime: 1609837427000, + remark: "备注、备注、备注、备注、备注、备注、备注" + }, + { + name: "市场部门", + parentId: 101, + sort: 2, + leaderUserId: null, + phone: "15888888888", + email: "ry@qq.com", + status: 1, + id: 104, + createTime: 1609837427000, + remark: "备注、备注、备注、备注、备注、备注、备注" + }, + { + name: "财务部门", + parentId: 102, + sort: 2, + leaderUserId: null, + phone: "15888888888", + email: "ry@qq.com", + status: 0, + id: 109, + createTime: 1609837427000, + remark: "备注、备注、备注、备注、备注、备注、备注" + }, + { + name: "测试部门", + parentId: 101, + sort: 3, + leaderUserId: null, + phone: "15888888888", + email: "ry@qq.com", + status: 0, + id: 105, + createTime: 1609837427000, + remark: "备注、备注、备注、备注、备注、备注、备注" + }, + { + name: "财务部门", + parentId: 101, + sort: 4, + leaderUserId: 103, + phone: "15888888888", + email: "ry@qq.com", + status: 1, + id: 106, + createTime: 1609837427000, + remark: "备注、备注、备注、备注、备注、备注、备注" + }, + { + name: "运维部门", + parentId: 101, + sort: 5, + leaderUserId: null, + phone: "15888888888", + email: "ry@qq.com", + status: 0, + id: 107, + createTime: 1609837427000, + remark: "备注、备注、备注、备注、备注、备注、备注" + } + ], + msg: "" + }; + } } ] as MockMethod[]; diff --git a/src/api/system.ts b/src/api/system.ts index 33652d8ee..d35e5cb04 100644 --- a/src/api/system.ts +++ b/src/api/system.ts @@ -1,12 +1,17 @@ import { http } from "../utils/http"; -interface jobType extends Promise { +interface postType extends Promise { data?: object; code?: number; msg?: string; } // 获取岗位管理列表 -export const getJobList = (data?: object): jobType => { +export const getPostList = (data?: object): postType => { return http.request("post", "/system", { data }); }; + +// 获取部门管理列表 +export const getDeptList = (data?: object): postType => { + return http.request("post", "/dept", { data }); +}; diff --git a/src/components/ReIcon/src/iconifyIconOffline.ts b/src/components/ReIcon/src/iconifyIconOffline.ts index f9a9484a5..d2db83195 100644 --- a/src/components/ReIcon/src/iconifyIconOffline.ts +++ b/src/components/ReIcon/src/iconifyIconOffline.ts @@ -70,6 +70,7 @@ import closeCircleLine from "@iconify-icons/ri/close-circle-line"; import arrowUpLine from "@iconify-icons/ri/arrow-up-line"; import arrowDownLine from "@iconify-icons/ri/arrow-down-line"; import bookmark2Line from "@iconify-icons/ri/bookmark-2-line"; +import addFill from "@iconify-icons/ri/add-circle-line"; addIcon("arrow-right-s-line", arrowRightSLine); addIcon("arrow-left-s-line", arrowLeftSLine); addIcon("logout-circle-r-line", logoutCircleRLine); @@ -82,6 +83,7 @@ addIcon("close-circle-line", closeCircleLine); addIcon("arrow-up-line", arrowUpLine); addIcon("arrow-down-line", arrowDownLine); addIcon("bookmark-2-line", bookmark2Line); +addIcon("add", addFill); // Font Awesome 4 import faUser from "@iconify-icons/fa/user"; diff --git a/src/mockProdServer.ts b/src/mockProdServer.ts index 5a57c9bf7..2d4fb8a0e 100644 --- a/src/mockProdServer.ts +++ b/src/mockProdServer.ts @@ -1,9 +1,11 @@ import { createProdMockServer } from "vite-plugin-mock/es/createProdMockServer"; -import mapMock from "../mock/map"; -import systemMock from "../mock/system"; -import asyncRoutesMock from "../mock/asyncRoutes"; -export const mockModules = [...mapMock, ...systemMock, ...asyncRoutesMock]; +const modules = import.meta.globEager("../mock/*.ts"); +const mockModules = []; + +Object.keys(modules).forEach(key => { + mockModules.push(...modules[key].default); +}); export function setupProdMockServer() { createProdMockServer(mockModules); diff --git a/src/utils/tree.ts b/src/utils/tree.ts index 37a0fe87f..f6d6a168f 100644 --- a/src/utils/tree.ts +++ b/src/utils/tree.ts @@ -117,3 +117,59 @@ export function appendFieldByUniqueId( } return menuTree; } + +/** + * 构造树型结构数据 + * @param {*} data 数据源 + * @param {*} id id字段 默认 'id' + * @param {*} parentId 父节点字段 默认 'parentId' + * @param {*} children 孩子节点字段 默认 'children' + */ +export function handleTree( + data, + id?: string, + parentId?: string, + children?: string +) { + const config = { + id: id || "id", + parentId: parentId || "parentId", + childrenList: children || "children" + }; + + const childrenListMap = {}; + const nodeIds = {}; + const tree = []; + + for (const d of data) { + const parentId = d[config.parentId]; + if (childrenListMap[parentId] == null) { + childrenListMap[parentId] = []; + } + nodeIds[d[config.id]] = d; + childrenListMap[parentId].push(d); + } + + for (const d of data) { + const parentId = d[config.parentId]; + if (nodeIds[parentId] == null) { + tree.push(d); + } + } + + for (const t of tree) { + adaptToChildrenList(t); + } + + function adaptToChildrenList(o) { + if (childrenListMap[o[config.id]] !== null) { + o[config.childrenList] = childrenListMap[o[config.id]]; + } + if (o[config.childrenList]) { + for (const c of o[config.childrenList]) { + adaptToChildrenList(c); + } + } + } + return tree; +} diff --git a/src/views/system/dept/index.vue b/src/views/system/dept/index.vue new file mode 100644 index 000000000..ed390876a --- /dev/null +++ b/src/views/system/dept/index.vue @@ -0,0 +1,270 @@ + + + + + diff --git a/src/views/system/job/load.ts b/src/views/system/load.ts similarity index 100% rename from src/views/system/job/load.ts rename to src/views/system/load.ts diff --git a/src/views/system/job/index.vue b/src/views/system/post/index.vue similarity index 93% rename from src/views/system/job/index.vue rename to src/views/system/post/index.vue index 5dcfa1cc0..48bc21822 100644 --- a/src/views/system/job/index.vue +++ b/src/views/system/post/index.vue @@ -1,13 +1,13 @@