From 755cea0990d9e3b64c936f29c02e4053393a1a19 Mon Sep 17 00:00:00 2001 From: kailong321200875 <321200875@qq.com> Date: Sun, 23 Jul 2023 19:34:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=94=A8=E6=88=B7=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mock/department/index.ts | 105 ++++++++++++ src/api/department/index.ts | 10 ++ src/api/department/types.ts | 31 ++++ src/components/Form/src/Form.vue | 2 +- src/components/Sticky/index.ts | 3 - src/components/Sticky/src/Sticky.vue | 141 ---------------- src/components/TagsView/src/TagsView.vue | 11 +- src/locales/en.ts | 9 +- src/locales/zh-CN.ts | 12 +- src/router/index.ts | 82 +++++----- src/store/modules/app.ts | 4 +- src/store/modules/tagsView.ts | 4 +- src/views/Authorization/User.vue | 197 +++++++++++++++++------ src/views/Components/Sticky.vue | 62 ------- 14 files changed, 355 insertions(+), 318 deletions(-) create mode 100644 mock/department/index.ts create mode 100644 src/api/department/index.ts create mode 100644 src/api/department/types.ts delete mode 100644 src/components/Sticky/index.ts delete mode 100644 src/components/Sticky/src/Sticky.vue delete mode 100644 src/views/Components/Sticky.vue diff --git a/mock/department/index.ts b/mock/department/index.ts new file mode 100644 index 0000000..8512f07 --- /dev/null +++ b/mock/department/index.ts @@ -0,0 +1,105 @@ +import config from '@/config/axios/config' +import { MockMethod } from 'vite-plugin-mock' +import { toAnyString } from '@/utils' +import Mock from 'mockjs' + +const { code } = config + +const departmentList: any = [] + +const citys = ['厦门总公司', '北京分公司', '上海分公司', '福州分公司', '深圳分公司', '杭州分公司'] + +for (let i = 0; i < 5; i++) { + departmentList.push({ + // 部门名称 + departmentName: citys[i], + id: toAnyString(), + children: [ + { + // 部门名称 + departmentName: '研发部', + id: toAnyString() + }, + { + // 部门名称 + departmentName: '产品部', + id: toAnyString() + }, + { + // 部门名称 + departmentName: '运营部', + id: toAnyString() + }, + { + // 部门名称 + departmentName: '市场部', + id: toAnyString() + }, + { + // 部门名称 + departmentName: '销售部', + id: toAnyString() + }, + { + // 部门名称 + departmentName: '客服部', + id: toAnyString() + } + ] + }) +} + +export default [ + // 列表接口 + { + url: '/department/list', + method: 'get', + response: () => { + return { + data: { + code: code, + data: { + list: departmentList + } + } + } + } + }, + { + url: '/department/users', + method: 'get', + timeout: 1000, + response: ({ query }) => { + const { pageSize } = query + // 根据pageSize来创建数据 + const mockList: any = [] + for (let i = 0; i < pageSize; i++) { + mockList.push( + Mock.mock({ + // 用户名 + username: '@cname', + // 账号 + account: '@first', + // 邮箱 + email: '@EMAIL', + // 创建时间 + createTime: '@datetime', + // 角色 + role: '@first', + // 用户id + id: toAnyString() + }) + ) + } + return { + data: { + code: code, + data: { + total: 100, + list: mockList + } + } + } + } + } +] as MockMethod[] diff --git a/src/api/department/index.ts b/src/api/department/index.ts new file mode 100644 index 0000000..7c74aa3 --- /dev/null +++ b/src/api/department/index.ts @@ -0,0 +1,10 @@ +import request from '@/config/axios' +import { DepartmentListResponse, DepartmentUserParams, DepartmentUserResponse } from './types' + +export const getDepartmentApi = () => { + return request.get({ url: '/department/list' }) +} + +export const getUserByIdApi = (params: DepartmentUserParams) => { + return request.get({ url: '/department/users', params }) +} diff --git a/src/api/department/types.ts b/src/api/department/types.ts new file mode 100644 index 0000000..f838c7b --- /dev/null +++ b/src/api/department/types.ts @@ -0,0 +1,31 @@ +export interface DepartmentItem { + id: string + departmentName: string + children?: DepartmentItem[] +} + +export interface DepartmentListResponse { + list: DepartmentItem[] +} + +export interface DepartmentUserParams { + pageSize: number + pageIndex: number + id: string + username?: string + account?: string +} + +export interface DepartmentUserItem { + id: string + username: string + account: string + email: string + createTime: string + role: string +} + +export interface DepartmentUserResponse { + list: DepartmentUserItem[] + total: number +} diff --git a/src/components/Form/src/Form.vue b/src/components/Form/src/Form.vue index 4e23ff8..5b37abe 100644 --- a/src/components/Form/src/Form.vue +++ b/src/components/Form/src/Form.vue @@ -255,7 +255,7 @@ export default defineComponent({ const renderFormItem = (item: FormSchema) => { // 如果有optionApi,优先使用optionApi if (item.optionApi) { - // 内部自动调用接口,不影响其他渲染 + // 内部自动调用接口,不影响其它渲染 getOptions(item.optionApi, item) } const formItemSlots: Recordable = { diff --git a/src/components/Sticky/index.ts b/src/components/Sticky/index.ts deleted file mode 100644 index 5e1de45..0000000 --- a/src/components/Sticky/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import Sticky from './src/Sticky.vue' - -export { Sticky } diff --git a/src/components/Sticky/src/Sticky.vue b/src/components/Sticky/src/Sticky.vue deleted file mode 100644 index 6906fbc..0000000 --- a/src/components/Sticky/src/Sticky.vue +++ /dev/null @@ -1,141 +0,0 @@ - - diff --git a/src/components/TagsView/src/TagsView.vue b/src/components/TagsView/src/TagsView.vue index e6b0acb..3eb2d98 100644 --- a/src/components/TagsView/src/TagsView.vue +++ b/src/components/TagsView/src/TagsView.vue @@ -75,7 +75,7 @@ const closeAllTags = () => { toLastView() } -// 关闭其他 +// 关闭其它 const closeOthersTags = () => { tagsViewStore.delOthersViews(unref(selectedTag) as RouteLocationNormalizedLoaded) } @@ -482,7 +482,8 @@ watch( &__tool { position: relative; - &:before { + + &::before { position: absolute; top: 1px; left: 0; @@ -493,14 +494,14 @@ watch( } &--first { - &:before { + &::before { position: absolute; top: 1px; left: 0; width: 100%; height: calc(~'100% - 1px'); - border-left: none; border-right: 1px solid var(--el-border-color); + border-left: none; content: ''; } } @@ -553,7 +554,7 @@ watch( .@{prefix-cls} { &__tool { &--first { - &:after { + &::after { display: none; } } diff --git a/src/locales/en.ts b/src/locales/en.ts index 5391274..098b1e0 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -487,7 +487,14 @@ export default { role: 'Role', remark: 'Remark', remarkMessage1: 'Back end control routing permission', - remarkMessage2: 'Front end control routing permission' + remarkMessage2: 'Front end control routing permission', + // 部门列表 + departmentList: 'Department list', + // 搜索部门 + searchDepartment: 'Search department', + account: 'Account', + email: 'Email', + createTime: 'Create time' }, inputPasswordDemo: { title: 'InputPassword', diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index e459763..2aa242c 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -17,7 +17,7 @@ export default { closeTab: '关闭标签页', closeTheLeftTab: '关闭左侧标签页', closeTheRightTab: '关闭右侧标签页', - closeOther: '关闭其他标签页', + closeOther: '关闭其它标签页', closeAll: '关闭全部标签页', prevLabel: '上一步', nextLabel: '下一步', @@ -106,7 +106,7 @@ export default { register: '注册', checkPassword: '确认密码', login: '登录', - otherLogin: '其他登录方式', + otherLogin: '其它登录方式', remember: '记住我', hasUser: '已有账号?去登录', forgetPassword: '忘记密码', @@ -480,7 +480,13 @@ export default { role: '角色', remark: '备注', remarkMessage1: '后端控制路由权限', - remarkMessage2: '前端控制路由权限' + remarkMessage2: '前端控制路由权限', + // 部门列表 + departmentList: '部门列表', + searchDepartment: '搜索部门', + account: '账号', + email: '邮箱', + createTime: '创建时间' }, inputPasswordDemo: { title: '密码输入框', diff --git a/src/router/index.ts b/src/router/index.ts index a0f63cb..ba366e9 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -311,14 +311,6 @@ export const asyncRouterMap: AppRouteRecordRaw[] = [ title: t('router.inputPassword') } } - // { - // path: 'sticky', - // component: () => import('@/views/Components/Sticky.vue'), - // name: 'Sticky', - // meta: { - // title: t('router.sticky') - // } - // } ] }, { @@ -339,15 +331,15 @@ export const asyncRouterMap: AppRouteRecordRaw[] = [ meta: { title: 'useWatermark' } - }, - { - path: 'useCrudSchemas', - component: () => import('@/views/hooks/useCrudSchemas.vue'), - name: 'UseCrudSchemas', - meta: { - title: 'useCrudSchemas' - } } + // { + // path: 'useCrudSchemas', + // component: () => import('@/views/hooks/useCrudSchemas.vue'), + // name: 'UseCrudSchemas', + // meta: { + // title: 'useCrudSchemas' + // } + // } ] }, { @@ -513,36 +505,36 @@ export const asyncRouterMap: AppRouteRecordRaw[] = [ } } ] + }, + { + path: '/authorization', + component: Layout, + redirect: '/authorization/user', + name: 'Authorization', + meta: { + title: t('router.authorization'), + icon: 'eos-icons:role-binding', + alwaysShow: true + }, + children: [ + { + path: 'user', + component: () => import('@/views/Authorization/User.vue'), + name: 'User', + meta: { + title: t('router.user') + } + }, + { + path: 'role', + component: () => import('@/views/Authorization/Role.vue'), + name: 'Role', + meta: { + title: t('router.role') + } + } + ] } - // { - // path: '/authorization', - // component: Layout, - // redirect: '/authorization/user', - // name: 'Authorization', - // meta: { - // title: t('router.authorization'), - // icon: 'eos-icons:role-binding', - // alwaysShow: true - // }, - // children: [ - // { - // path: 'user', - // component: () => import('@/views/Authorization/User.vue'), - // name: 'User', - // meta: { - // title: t('router.user') - // } - // }, - // { - // path: 'role', - // component: () => import('@/views/Authorization/Role.vue'), - // name: 'Role', - // meta: { - // title: t('router.role') - // } - // } - // ] - // } ] const router = createRouter({ diff --git a/src/store/modules/app.ts b/src/store/modules/app.ts index fa22379..d9e45b0 100644 --- a/src/store/modules/app.ts +++ b/src/store/modules/app.ts @@ -37,7 +37,7 @@ interface AppState { export const useAppStore = defineStore('app', { state: (): AppState => { return { - userInfo: 'userInfo', // 登录信息存储字段-建议每个项目换一个字段,避免与其他项目冲突 + userInfo: 'userInfo', // 登录信息存储字段-建议每个项目换一个字段,避免与其它项目冲突 sizeMap: ['default', 'large', 'small'], mobile: false, // 是否是移动端 title: import.meta.env.VITE_APP_TITLE, // 标题 @@ -225,7 +225,7 @@ export const useAppStore = defineStore('app', { }, setLayout(layout: LayoutType) { if (this.mobile && layout !== 'classic') { - ElMessage.warning('移动端模式下不支持切换其他布局') + ElMessage.warning('移动端模式下不支持切换其它布局') return } this.layout = layout diff --git a/src/store/modules/tagsView.ts b/src/store/modules/tagsView.ts index e9fbf37..34281ef 100644 --- a/src/store/modules/tagsView.ts +++ b/src/store/modules/tagsView.ts @@ -87,12 +87,12 @@ export const useTagsViewStore = defineStore('tagsView', { // const affixTags = this.visitedViews.filter((tag) => tag.meta.affix) this.visitedViews = [] }, - // 删除其他 + // 删除其它 delOthersViews(view: RouteLocationNormalizedLoaded) { this.delOthersVisitedViews(view) this.addCachedView() }, - // 删除其他tag + // 删除其它tag delOthersVisitedViews(view: RouteLocationNormalizedLoaded) { this.visitedViews = this.visitedViews.filter((v) => { return v?.meta?.affix || v.path === view.path diff --git a/src/views/Authorization/User.vue b/src/views/Authorization/User.vue index 1b49b7a..da8c4c6 100644 --- a/src/views/Authorization/User.vue +++ b/src/views/Authorization/User.vue @@ -1,20 +1,35 @@ - diff --git a/src/views/Components/Sticky.vue b/src/views/Components/Sticky.vue deleted file mode 100644 index 44fd2b9..0000000 --- a/src/views/Components/Sticky.vue +++ /dev/null @@ -1,62 +0,0 @@ - - -