From 4c919a6451fdb6c78b36b73adca802098ec8bb80 Mon Sep 17 00:00:00 2001 From: BINGWU Date: Thu, 23 May 2024 11:48:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=98=E5=B7=A5=E5=8F=8D=E9=A6=88=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/api/employee.js | 6 +- app/src/stores/modules/user.js | 210 ++---------------- app/src/views/LoginView.vue | 74 ++++-- app/src/views/feedback/FeedbackView.vue | 61 ++++- .../__pycache__/employee.cpython-311.pyc | Bin 2840 -> 3918 bytes serve/serve/views/employee.py | 25 ++- 6 files changed, 167 insertions(+), 209 deletions(-) diff --git a/app/src/api/employee.js b/app/src/api/employee.js index d73321c..b9a3c59 100644 --- a/app/src/api/employee.js +++ b/app/src/api/employee.js @@ -21,10 +21,14 @@ const getAllEmployee = (params) => { params }) } +const loginEmployee = (params) => { + return http.post('/employee/login', params) +} export { getEmployee, createEmployee, getAllEmployee, updateEmployee, - deleteEmployee + deleteEmployee, + loginEmployee } diff --git a/app/src/stores/modules/user.js b/app/src/stores/modules/user.js index 3c8efa3..39dc49f 100644 --- a/app/src/stores/modules/user.js +++ b/app/src/stores/modules/user.js @@ -14,204 +14,26 @@ const useUserStore = defineStore( () => { // 模拟后台返回的token const token = ref('') + const _id = ref('') + const name = ref('') + const userType = ref('') const setToken = (newToken) => { token.value = newToken } + const setId = (newId) => { + _id.value = newId + } + const setName = (newName) => { + name.value = newName + } + const setUserType = (newUserType) => { + userType.value = newUserType + } // 模拟后台返回的侧边栏数据 const asideData = ref([]) - // const asideData = ref([ - // { - // index: '/home', - // icon: 'icon iconfont icon-shujutongji', - // name: '数据统计' - // }, - // // - // { - // index: '/user-manage', - // icon: 'icon iconfont icon-yonghuguanli', - // name: '用户管理' - // }, - // { - // index: '/employee-manage', - // icon: 'icon iconfont icon-shenfenzhongxin-xinxiguanlizhigongxinxiguanli', - // name: '职工管理' - // }, - // { - // index: '/reward-manage', - // icon: 'icon iconfont icon-gerenjixiao', - // name: '绩效管理' - // }, - // // 二级 - // { - // index: '/feedback', - // icon: 'icon iconfont icon-fankui', - // name: '员工反馈与投诉管理', - // children: [ - // { - // index: '/feedback/manage', - // name: '投诉管理' - // }, - // { - // index: '/feedback/view', - // name: '员工反馈' - // } - // ] - // }, - // { - // index: '/request', - // icon: 'icon iconfont icon-qingjiashenqing', - // name: '请假管理', - // children: [ - // { - // index: '/request/manage', - // name: '请假信息管理' - // }, - // { - // index: '/request/view', - // name: '个人请假信息' - // } - // ] - // }, - // { - // index: '/person', - // icon: 'icon iconfont icon-gerenxinxiguanli', - // name: '个人信息管理', - // children: [ - // { - // index: '/person/password', - // name: '修改密码' - // }, - // { - // index: '/person/avatar', - // name: '修改个人信息' - // } - // ] - // } - // ]) // 模拟后台返回的路由数据 const routerData = ref([]) - // const routerData = ref([ - // { - // path: 'home', - // name: 'home', - // meta: { - // // 路由组件的路径 - // url: '../views/HomeView.vue' - // } - // }, - // { - // path: 'table/main-table1', - // name: 'main-table', - // meta: { - // name: '表格1', - // url: '../views/table/MainTableView.vue' - // } - // }, - // { - // path: 'excel', - // name: 'excel', - - // meta: { - // name: 'excel', - // url: '../views/ExcelView.vue' - // } - // }, - - // { - // path: 'tx-yun', - // name: 'tx-yun', - - // meta: { - // name: 'tx-yun', - // url: '../views/TxView.vue' - // } - // }, - - // { - // path: 'preview-picture', - // name: 'preview-picture', - - // meta: { - // name: 'preview-picture', - // url: '../views/PreviewPictureView.vue' - // } - // }, - // // - // { - // path: 'user-manage', - // name: 'user-manage', - // meta: { - // // 路由组件的路径 - // url: '../views/UserManageView.vue' - // } - // }, - // { - // path: 'employee-manage', - // name: 'employee-manage', - // meta: { - // // 路由组件的路径 - // url: '../views/EmployeeManageView.vue' - // } - // }, - // { - // path: 'reward-manage', - // name: 'reward-manage', - // meta: { - // // 路由组件的路径 - // url: '../views/RewardManageView.vue' - // } - // }, - // // 二级 - // { - // path: 'feedback/manage', - // name: 'feedback-manage', - // meta: { - // // 路由组件的路径 - // url: '../views/feedback/FeedbackManageView.vue' - // } - // }, - // { - // path: 'feedback/view', - // name: 'feedback-view', - // meta: { - // // 路由组件的路径 - // url: '../views/feedback/FeedbackView.vue' - // } - // }, - // { - // path: 'request/manage', - // name: 'request-manage', - // meta: { - // // 路由组件的路径 - // url: '../views/request/RequestManageView.vue' - // } - // }, - // { - // path: 'request/view', - // name: 'request-view', - // meta: { - // // 路由组件的路径 - // url: '../views/request/RequestView.vue' - // } - // }, - // { - // path: 'person/password', - // name: 'person-password', - // meta: { - // // 路由组件的路径 - // url: '../views/PersonInfo/ChangePasswordView.vue' - // } - // }, - // { - // path: 'person/avatar', - // name: 'person-avatar', - // meta: { - // // 路由组件的路径 - // url: '../views/PersonInfo/ChangeAvatarView.vue' - // } - // } - // ]) // 动态添加路由 const addUserRoute = (router, modules) => { routerData.value.forEach((item) => { @@ -236,7 +58,13 @@ const useUserStore = defineStore( routerData, setToken, token, - asideData + asideData, + _id, + setId, + userType, + name, + setName, + setUserType } }, { diff --git a/app/src/views/LoginView.vue b/app/src/views/LoginView.vue index ef5fa2e..9df43ce 100644 --- a/app/src/views/LoginView.vue +++ b/app/src/views/LoginView.vue @@ -2,7 +2,7 @@ * @Author: BINGWU * @Date: 2024-04-10 16:15:37 * @LastEditors: BINGWU HuJiaCheng2003@163.com - * @LastEditTime: 2024-05-19 17:07:18 + * @LastEditTime: 2024-05-23 11:34:56 * @FilePath: \employee-information-management-system\app\src\views\LoginView.vue * @Describe: * @Mark: ૮(˶ᵔ ᵕ ᵔ˶)ა @@ -18,7 +18,16 @@ - 登陆 +
+ + 登陆 +
@@ -28,6 +37,7 @@ import { ref } from 'vue' import { useRouter } from 'vue-router' import { getUserStore } from '@/stores' import { loginUser, getUser } from '@/api/user' +import { loginEmployee, getEmployee } from '@/api/employee' const modules = import.meta.glob('../views/**/**.vue') const router = useRouter() const userStore = getUserStore() @@ -35,29 +45,63 @@ const formData = ref({ username: '', password: '' }) -const login = () => { - loginUser({ - ...formData.value +const mode = ref(true) + +const handleLogin = (callback, params) => { + callback(params) + return new Promise((reslove, reject) => { + callback(params) + .then((res) => { + reslove(res.data) + }) + .catch((error) => { + reject(error) + }) }) - .then(async (res) => { - const { token, _id } = res.data +} + +const login = async () => { + const callback = mode.value ? loginUser : loginEmployee + const params = { + password: formData.value.password + } + if (mode.value) { + params.username = formData.value.username + } else { + params.employeeName = formData.value.username + } + handleLogin(callback, params) + .then(async ({ token, _id, msg }) => { + let data = null ElMessage({ - message: res.data.msg, + message: msg, type: 'success', plain: true }) userStore.setToken(token) - const data = await getUser(_id) - const { asideData, routerData } = data.data + userStore.setId(_id) + if (mode.value) { + data = await getUser(_id) + } else { + data = await getEmployee(_id) + } + const { asideData, routerData, userType } = data.data userStore.addUserRoute(router, modules) userStore.asideData = asideData userStore.routerData = routerData + userStore.setUserType(userType) - router.push('/home') + if (mode.value) { + userStore.setName(data.data.username) + router.push('/home') + } else { + userStore.setName(data.data.employeeName) + router.push('/feedback/view') + } }) - .catch((message) => { + .catch((error) => { ElMessage({ - message, + message: error, type: 'error', plain: true }) @@ -72,6 +116,10 @@ const login = () => { .content { margin-top: 100px; text-align: center; + .bottom { + display: flex; + justify-content: space-between; + } } } diff --git a/app/src/views/feedback/FeedbackView.vue b/app/src/views/feedback/FeedbackView.vue index f1353ab..efa9456 100644 --- a/app/src/views/feedback/FeedbackView.vue +++ b/app/src/views/feedback/FeedbackView.vue @@ -1,7 +1,62 @@ - + - + diff --git a/serve/serve/views/__pycache__/employee.cpython-311.pyc b/serve/serve/views/__pycache__/employee.cpython-311.pyc index 2660912ff7e1d7442697ccb6f4d33f50012a2fdd..b6b98b3d6914df188199c77af9210d43f6aef105 100644 GIT binary patch delta 1735 zcmaJ>>uV!b6u3ZBlq^=vr`pBWqF*Zh0qPf-$cSN}qG+oXguuFA{N%Zl^bx3@x%11M-#z!_ z-gC}9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