员工管理模块完成

master
BINGWU 6 months ago
parent b9458fe4c1
commit 0d2fe87dca

@ -0,0 +1,30 @@
import http from '@/utils/http'
import { deleteRequest } from '@/utils/http'
const getEmployee = (_id) => {
return http.get('/employee/get', {
params: {
_id
}
})
}
const createEmployee = (params) => {
return http.post('/employee/create', params)
}
const updateEmployee = (params) => {
return http.put('/employee/update', params)
}
const deleteEmployee = (params) => {
return deleteRequest('/employee/delete', params)
}
const getAllEmployee = (params) => {
return http.get('/employee/get-all', {
params
})
}
export {
getEmployee,
createEmployee,
getAllEmployee,
updateEmployee,
deleteEmployee
}

@ -0,0 +1,33 @@
/*
* @Author: BINGWU
* @Date: 2024-05-21 23:05:12
* @LastEditors: BINGWU HuJiaCheng2003@163.com
* @LastEditTime: 2024-05-21 23:05:24
* @FilePath: \reward-information-management-system\app\src\api\reward.js
* @Describe:
* @Mark: (˶ ˶)
*/
import http from '@/utils/http'
import { deleteRequest } from '@/utils/http'
const getReward = (_id) => {
return http.get('/reward/get', {
params: {
_id
}
})
}
const createReward = (params) => {
return http.post('/reward/create', params)
}
const updateReward = (params) => {
return http.put('/reward/update', params)
}
const deleteReward = (params) => {
return deleteRequest('/reward/delete', params)
}
const getAllReward = (params) => {
return http.get('/reward/get-all', {
params
})
}
export { getReward, createReward, getAllReward, updateReward, deleteReward }

@ -92,12 +92,58 @@ export const asideData = [
} }
] ]
export const employeeAsideData = [
{
index: '/feedback',
icon: 'icon iconfont icon-fankui',
name: '员工反馈与投诉管理',
pid: 0,
children: [
{
id: 7,
index: '/feedback/view',
name: '员工反馈',
pid: 5
}
]
},
{
index: '/request',
icon: 'icon iconfont icon-qingjiashenqing',
name: '请假管理',
children: [
{
id: 10,
index: '/request/view',
name: '个人请假信息',
pid: 8
}
]
},
{
index: '/person',
icon: 'icon iconfont icon-gerenxinxiguanli',
name: '个人信息管理',
children: [
{
index: '/person/password',
name: '修改密码'
},
{
index: '/person/avatar',
name: '修改个人信息'
}
]
}
]
export const keys = { export const keys = {
employeeAdmin: [1, 3, 11], employeeAdmin: [1, 3, 11],
customAdmin: [], customAdmin: [],
feedbackAdmin: [1, 11, 5], feedbackAdmin: [1, 11, 5],
rewardAdmin: [1, 4, 11], rewardAdmin: [1, 4, 11],
requestAdmin: [1, 11, 8] requestAdmin: [1, 11, 8],
employee:[]
} }
export function generateNested(nodes, parentId = 0) { export function generateNested(nodes, parentId = 0) {

@ -1,15 +1,108 @@
<template> <template>
<div class="employee-manage"> <div class="employee-manage">
<el-button type="primary">添加职工</el-button> <el-button type="primary" @click="openDialog"></el-button>
<div clase="table"> <div clase="table">
<BaseTableCom></BaseTableCom> <BaseTableCom
:column-data="columnData"
:table-data="tableData"
:total="total"
:show-pagination="true"
:page-sizes="[5, 8]"
:dropdown-data="dropdownData"
ref="baseTableComRef"
@update-table-data="updateTableData"
></BaseTableCom>
</div> </div>
<EmployeeFormCom
:title="title"
ref="employeeFormComRef"
@update-table-data="getTableData"
></EmployeeFormCom>
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref } from 'vue' import { ref, onMounted } from 'vue'
import BaseTableCom from '@/components/table/BaseTableCom.vue' import BaseTableCom from '@/components/table/BaseTableCom.vue'
import EmployeeFormCom from './components/form/EmployeeFormCom.vue'
import { deleteEmployee, getAllEmployee } from '@/api/employee'
const tableData = ref([])
const dropdownData = [
{
command: 'command1',
handleAction: (row) => {
returnData(row, '查看')
},
icon: 'View',
actionName: '查看'
},
{
command: 'command2',
handleAction: (row) => {
returnData(row, '修改')
},
icon: 'Edit',
actionName: '修改'
},
{
command: 'command3',
handleAction: async (row) => {
const { _id } = row
const res = await deleteEmployee({ _ids: [_id] })
const { msg } = res.data
await getTableData()
ElMessage({
message: msg,
type: 'success'
})
},
icon: 'Delete',
actionName: '删除'
}
]
const columnData = [
{
prop: '_id',
label: '职工ID'
},
{
prop: 'employeeName',
label: '职工名'
},
{
prop: 'userType',
label: '用户类型'
}
]
const total = ref(0)
const title = ref('')
const employeeFormComRef = ref(null)
const baseTableComRef = ref(null)
const getTableData = async (params = null) => {
if (!params) {
const { currentPage, pageSize } = baseTableComRef.value.getPaginationData()
params = { pageIndex: currentPage, pageSize }
}
const res = await getAllEmployee(params)
tableData.value = res.data.data
total.value = res.data.total
}
const openDialog = () => {
title.value = '添加'
employeeFormComRef.value.openDialog()
}
const updateTableData = async (pageSize, pageIndex) => {
console.log('pp')
await getTableData({ pageSize, pageIndex })
}
const returnData = (row, newTiltle) => {
title.value = newTiltle
const { employeeName, password, userType, _id } = row
employeeFormComRef.value.openDialog(employeeName, password, userType, _id)
}
onMounted(async () => {
await getTableData({ pageSize: 5, pageIndex: 1 })
})
</script> </script>
<style lang="scss" scoped></style> <style lang="scss" scoped></style>

@ -4,12 +4,14 @@
<div clase="table"> <div clase="table">
<BaseTableCom></BaseTableCom> <BaseTableCom></BaseTableCom>
</div> </div>
<RewardFormCom></RewardFormCom>
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref } from 'vue' import { ref } from 'vue'
import BaseTableCom from '@/components/table/BaseTableCom.vue' import BaseTableCom from '@/components/table/BaseTableCom.vue'
import RewardFormCom from './components/form/RewardFormCom.vue'
</script> </script>
<style lang="scss" scoped></style> <style lang="scss" scoped></style>

@ -0,0 +1,168 @@
<!--
* @Author: BINGWU
* @Date: 2024-05-14 23:46:48
* @LastEditors: BINGWU HuJiaCheng2003@163.com
* @LastEditTime: 2024-05-21 22:48:01
* @FilePath: \employee-information-management-system\app\src\views\components\form\EmployeeFormCom.vue
* @Describe:
* @Mark: (˶ ˶)
-->
<template>
<div class="employee-form">
<el-dialog
v-model="dialogVisible"
:title="props.title + '职工'"
width="500"
:before-close="handleClose"
>
<el-form
:model="formData"
:rules="rules"
label-width="auto"
style="max-width: 600px"
ref="formRef"
>
<el-form-item label="职工名" prop="employeeName">
<el-input
type="text"
v-model="formData.employeeName"
:disabled="title === '查看'"
/>
</el-form-item>
<el-form-item label="密码" prop="password">
<el-input type="password" show-password v-model="formData.password" />
</el-form-item>
<el-form-item label="角色类型" prop="userType">
<el-radio-group
v-model="formData.userType"
@change="handleRadioChange"
disabled
>
<el-radio label="employee">普通员工</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer" v-show="title !== '查看'">
<el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="handleConfirm"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup>
import { ref, reactive, nextTick } from 'vue'
import { getRouterDataByIds } from '@/db/routerData'
import { employeeAsideData } from '@/db/asideData'
import { createEmployee, updateEmployee } from '@/api/employee'
import axios from 'axios'
const formData = reactive({
name: '',
password: '',
userType: 'employee',
asideData: ['default']
})
const dialogVisible = ref(false)
const props = defineProps({
title: {
type: String,
default: '添加'
}
})
const formRef = ref(null)
let newId = ''
const getAsideData = () => {
return employeeAsideData
}
const rules = ref({
employeeName: [
{ required: true, message: '请输入职工名', trigger: 'blur' },
{ min: 5, max: 10, message: '长度为5~10个字符', trigger: 'blur' }
],
password: [
{ required: true, message: '请输入密码', trigger: 'blur' },
{ min: 5, max: 10, message: '长度为5~10个字符', trigger: 'blur' }
]
})
const emits = defineEmits(['updateTableData'])
const handleConfirm = () => {
formRef.value
.validate()
.then(async () => {
let message = ''
const asideData = getAsideData()
const routerData = getRouterDataByIds([7, 10, 12, 13])
if (props.title === '添加') {
const res = await axios.get(
'https://api.thecatapi.com/v1/images/search'
)
const avatar = res.data[0].url
const params = {
asideData,
routerData,
userType: formData.userType,
employeeName: formData.employeeName,
password: formData.password,
avatar
}
const {
data: { msg }
} = await createEmployee(params)
message = msg
} else if (props.title === '修改') {
const params = {
asideData,
routerData,
employeeName: formData.employeeName,
password: formData.password
}
const {
data: { msg }
} = await updateEmployee({
data: params,
_id: newId
})
message = msg
}
ElMessage({
message,
type: 'success'
})
emits('updateTableData')
offDialog()
})
.catch(() => {})
}
const openDialog = (employeeName, password, _, _id) => {
dialogVisible.value = true
nextTick(() => {
formRef.value.clearValidate()
})
newId = _id
formData.password = password
formData.employeeName = employeeName
}
const handleClose = () => {
offDialog()
}
const offDialog = () => (dialogVisible.value = false)
defineExpose({
openDialog,
offDialog
})
</script>
<style lang="scss" scoped>
.employee-form {
.tree-content {
width: 100%;
border: 1px solid #e5e6e7;
border-radius: 2px;
}
}
</style>

@ -0,0 +1,172 @@
<!--
* @Author: BINGWU
* @Date: 2024-05-14 23:46:48
* @LastEditors: BINGWU HuJiaCheng2003@163.com
* @LastEditTime: 2024-05-21 23:03:00
* @FilePath: \employee-information-management-system\app\src\views\components\form\RewardFormCom.vue
* @Describe:
* @Mark: (˶ ˶)
-->
<template>
<div class="reward-form">
<el-dialog
v-model="dialogVisible"
:title="props.title + '用户'"
width="500"
:before-close="handleClose"
>
<el-form
:model="formData"
:rules="rules"
label-width="auto"
style="max-width: 600px"
ref="formRef"
>
<el-form-item label="类型" prop="rewardType" required>
<el-radio-group
v-model="formData.userType"
@change="handleRadioChange"
:disabled="title === '查看'"
>
<el-radio label="award"></el-radio>
<el-radio label="punish"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="绩效类型" prop="contentType" required>
<el-radio-group
v-model="formData.userType"
@change="handleRadioChange"
:disabled="title === '查看'"
>
<el-radio label="selfReward">个人绩效</el-radio>
<el-radio label="companyReward">公司绩效</el-radio>
<el-radio label="departmentReward">部门绩效</el-radio>
<el-radio label="otherReward">其他</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="职工名" prop="employeeName">
<el-input
type="text"
v-model="formData.employeeName"
:disabled="title === '查看'"
/>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input
type="text"
v-model="formData.remark"
:disabled="title === '查看'"
/>
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer" v-show="title !== '查看'">
<el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="handleConfirm"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup>
import { ref, reactive, nextTick } from 'vue'
import { createReward, updateReward } from '@/api/reward'
const formData = reactive({
employeeName: '',
rewardType: 'award',
contentType: 'selfReward',
remark: '',
emloyeeId: ''
})
const dialogVisible = ref(true)
const props = defineProps({
title: {
type: String,
default: '添加'
}
})
const elTreeRef = ref(null)
const formRef = ref(null)
let newId = ''
const rules = ref({
employeeName: [
{ required: true, message: '请输入职工名', trigger: 'blur' },
{ min: 5, max: 10, message: '长度为5~10个字符', trigger: 'blur' }
]
})
const emits = defineEmits(['updateTableData'])
const handleConfirm = () => {
formRef.value
.validate()
.then(async () => {
let message = ''
if (props.title === '添加') {
const params = {
...formData.value
}
const {
data: { msg }
} = await createReward(params)
message = msg
} else if (props.title === '修改') {
const params = {
...formData.value
}
const {
data: { msg }
} = await updateReward({
data: params,
_id: newId
})
message = msg
}
ElMessage({
message,
type: 'success'
})
emits('updateTableData')
offDialog()
})
.catch(() => {})
}
const setCheckedKeys = (keys = []) => {
nextTick(() => {
elTreeRef.value.setCheckedKeys(keys)
})
}
const openDialog = (keys, username, password, userType, _id) => {
dialogVisible.value = true
nextTick(() => {
formRef.value.clearValidate()
})
if (keys) {
setCheckedKeys(keys)
}
newId = _id
formData.userType = userType
formData.password = password
formData.username = username
}
const handleClose = () => {
setCheckedKeys()
offDialog()
}
const offDialog = () => (dialogVisible.value = false)
defineExpose({
openDialog,
offDialog
})
</script>
<style lang="scss" scoped>
.reward-form {
.tree-content {
width: 100%;
border: 1px solid #e5e6e7;
border-radius: 2px;
}
}
</style>

@ -79,7 +79,6 @@ def update(request, collection, useDate=False):
data['date'] = datetime.now() data['date'] = datetime.now()
_id = data['_id'] _id = data['_id']
update_data = data['data'] update_data = data['data']
print(_id)
updateResult = collection.update_one({'_id': ObjectId(_id)}, {"$set": update_data}) updateResult = collection.update_one({'_id': ObjectId(_id)}, {"$set": update_data})
res = handleEmpty(updateResult.modified_count, '更新') res = handleEmpty(updateResult.modified_count, '更新')
return JsonResponse(res) return JsonResponse(res)

Loading…
Cancel
Save