员工反馈模块完成

master
BINGWU 6 months ago
parent efffa22e74
commit 4c919a6451

@ -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
}

@ -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
}
},
{

@ -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,9 +18,18 @@
<el-input type="password" v-model="formData.password" />
</el-form-item>
</el-form>
<div class="bottom">
<el-switch
v-model="mode"
class="mb-2"
active-text="管理员"
inactive-text="员工"
size="large"
/>
<el-button type="primary" @click="login"></el-button>
</div>
</div>
</div>
</template>
<script setup>
@ -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)
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;
}
}
}
</style>

@ -1,7 +1,62 @@
<template>
<div>员工反馈</div>
<div class="feedback">
<el-input
v-model="content"
style="height: 50%"
:rows="2"
type="textarea"
placeholder="输入反馈信息"
/>
<div class="bottom">
<el-radio-group v-model="employeeName">
<el-radio label="保密">保密</el-radio>
<el-radio label="不保密">不保密</el-radio> </el-radio-group
><el-button type="primary" @click="handelSubmit"></el-button>
</div>
</div>
</template>
<script setup></script>
<script setup>
import { ref } from 'vue'
import { createFeedback } from '@/api/feedback'
import { getEmployee } from '@/api/employee'
import { getUserStore } from '@/stores'
const userStore = getUserStore()
const content = ref('')
const employeeName = ref('保密')
const handelSubmit = async () => {
const params = {
content: content.value,
employeeName: '保密',
status: '待处理'
}
if (userStore.userType !== 'employee') {
await createFeedback(params)
} else {
if (employeeName.value !== '保密') {
const res = await getEmployee(userStore._id)
params.employeeName = res.data.employeeName
}
await createFeedback(params)
}
ElMessage({
message: '反馈成功',
type: 'success',
plain: true
})
}
</script>
<style lang="scss" scoped></style>
<style lang="scss" scoped>
.feedback {
height: 100%;
.bottom {
margin-top: 20px;
display: flex;
justify-content: space-between;
}
}
:deep(.el-textarea__inner) {
height: 100%;
}
</style>

@ -3,7 +3,8 @@ from django.urls import path
from serve.utils.connectdb import connectdb
from bson.objectid import ObjectId
from serve.middleware.handleErrorMethod import handleErrorMethod
from serve.utils.pyjwt import decode_jwt_token
from serve.utils.decodeBody import decodeBody
from serve.utils.pyjwt import decode_jwt_token, get_jwt_token
from serve.commonViews.commonViews import delete, getAll, create, update
collection = connectdb('employee_model')
@ -44,10 +45,32 @@ def getEmployee(request):
return JsonResponse(result[1])
def loginEmployee(request):
result = handleErrorMethod(request.method, 'POST')
if result[0]:
data = decodeBody(request)
query = {
"$and": [
{"employeeName": data['employeeName']},
{"password": data['password']}
]
}
employee = collection.find_one(query)
if employee:
token = get_jwt_token(data['employeeName'], data['password'])
return JsonResponse({"code": 2000, "msg": "登陆成功", "token": token, "_id": str(employee['_id'])})
else:
return JsonResponse({"code": 1000, "msg": "数据不存在"})
else:
return JsonResponse(result[1])
employee_url = [
path('employee/create', createEmployee),
path('employee/delete', deleteEmployee),
path('employee/update', updateEmployee),
path('employee/get', getEmployee),
path('employee/get-all', getAllEmployee),
path('employee/login', loginEmployee),
]

Loading…
Cancel
Save