员工花名册新增导入功能
parent
9df30e466a
commit
dfb4ce965e
|
|
@ -1,51 +1,55 @@
|
||||||
import request from '@/config/axios'
|
import request from '@/config/axios'
|
||||||
|
|
||||||
// 员工花名册 VO
|
// 员工花名册 VO
|
||||||
export interface EmployeeVO {
|
export interface EmployeeVO {
|
||||||
id: number // 唯一标识符
|
id: number // 唯一标识符
|
||||||
empName: string // 姓名
|
empName: string // 姓名
|
||||||
idNo: string // 身份证号
|
idNo: string // 身份证号
|
||||||
empNo: string // 工号
|
empNo: string // 工号
|
||||||
station: string // 岗位
|
station: string // 岗位
|
||||||
bankNo: string // 银行卡号
|
bankNo: string // 银行卡号
|
||||||
orgNo: number // 所属机构
|
orgNo: number // 所属机构
|
||||||
annuityNo: string // 企业年金帐号
|
annuityNo: string // 企业年金帐号
|
||||||
socialSecurityNo: string // 社保账号
|
socialSecurityNo: string // 社保账号
|
||||||
pensionNo: string // 养老金帐号
|
pensionNo: string // 养老金帐号
|
||||||
housingFundNo: string // 住房公积金账号
|
housingFundNo: string // 住房公积金账号
|
||||||
workTime: Date // 参加工作时间
|
workTime: Date // 参加工作时间
|
||||||
empStatus: string // 员工状态
|
empStatus: string // 员工状态
|
||||||
}
|
}
|
||||||
|
|
||||||
// 员工花名册 API
|
// 员工花名册 API
|
||||||
export const EmployeeApi = {
|
export const EmployeeApi = {
|
||||||
// 查询员工花名册分页
|
// 查询员工花名册分页
|
||||||
getEmployeePage: async (params: any) => {
|
getEmployeePage: async (params: any) => {
|
||||||
return await request.get({ url: `/salary/employee/page`, params })
|
return await request.get({ url: `/salary/employee/page`, params })
|
||||||
},
|
},
|
||||||
|
|
||||||
// 查询员工花名册详情
|
// 查询员工花名册详情
|
||||||
getEmployee: async (id: number) => {
|
getEmployee: async (id: number) => {
|
||||||
return await request.get({ url: `/salary/employee/get?id=` + id })
|
return await request.get({ url: `/salary/employee/get?id=` + id })
|
||||||
},
|
},
|
||||||
|
|
||||||
// 新增员工花名册
|
// 新增员工花名册
|
||||||
createEmployee: async (data: EmployeeVO) => {
|
createEmployee: async (data: EmployeeVO) => {
|
||||||
return await request.post({ url: `/salary/employee/create`, data })
|
return await request.post({ url: `/salary/employee/create`, data })
|
||||||
},
|
},
|
||||||
|
|
||||||
// 修改员工花名册
|
// 修改员工花名册
|
||||||
updateEmployee: async (data: EmployeeVO) => {
|
updateEmployee: async (data: EmployeeVO) => {
|
||||||
return await request.put({ url: `/salary/employee/update`, data })
|
return await request.put({ url: `/salary/employee/update`, data })
|
||||||
},
|
},
|
||||||
|
|
||||||
// 删除员工花名册
|
// 删除员工花名册
|
||||||
deleteEmployee: async (id: number) => {
|
deleteEmployee: async (id: number) => {
|
||||||
return await request.delete({ url: `/salary/employee/delete?id=` + id })
|
return await request.delete({ url: `/salary/employee/delete?id=` + id })
|
||||||
},
|
},
|
||||||
|
|
||||||
// 导出员工花名册 Excel
|
// 导出员工花名册 Excel
|
||||||
exportEmployee: async (params) => {
|
exportEmployee: async (params) => {
|
||||||
return await request.download({ url: `/salary/employee/export-excel`, params })
|
return await request.download({ url: `/salary/employee/export-excel`, params })
|
||||||
},
|
},
|
||||||
}
|
|
||||||
|
importEmpTemplate: async () => {
|
||||||
|
return request.download({ url: '/salary/employee/get-import-template' })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,138 @@
|
||||||
|
<template>
|
||||||
|
<Dialog v-model="dialogVisible" title="员工花名册导入" width="400">
|
||||||
|
<el-upload
|
||||||
|
ref="uploadRef"
|
||||||
|
v-model:file-list="fileList"
|
||||||
|
:action="importUrl + '?updateSupport=' + updateSupport"
|
||||||
|
:auto-upload="false"
|
||||||
|
:disabled="formLoading"
|
||||||
|
:headers="uploadHeaders"
|
||||||
|
:limit="1"
|
||||||
|
:on-error="submitFormError"
|
||||||
|
:on-exceed="handleExceed"
|
||||||
|
:on-success="submitFormSuccess"
|
||||||
|
accept=".xlsx, .xls"
|
||||||
|
drag
|
||||||
|
>
|
||||||
|
<Icon icon="ep:upload" />
|
||||||
|
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||||
|
<template #tip>
|
||||||
|
<div class="el-upload__tip text-center">
|
||||||
|
<div class="el-upload__tip">
|
||||||
|
<el-checkbox v-model="updateSupport" />
|
||||||
|
是否更新已经存在的员工数据
|
||||||
|
</div>
|
||||||
|
<span>仅允许导入 xls、xlsx 格式文件。</span>
|
||||||
|
<el-link
|
||||||
|
:underline="false"
|
||||||
|
style="font-size: 12px; vertical-align: baseline"
|
||||||
|
type="primary"
|
||||||
|
@click="importTemplate"
|
||||||
|
>
|
||||||
|
下载模板
|
||||||
|
</el-link>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-upload>
|
||||||
|
<template #footer>
|
||||||
|
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||||
|
</template>
|
||||||
|
</Dialog>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import * as EmpApi from '@/api/arcb/salary/employee'
|
||||||
|
import { getAccessToken, getTenantId } from '@/utils/auth'
|
||||||
|
import download from '@/utils/download'
|
||||||
|
|
||||||
|
defineOptions({ name: 'EmployeeImportForm' })
|
||||||
|
|
||||||
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
|
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||||
|
const formLoading = ref(false) // 表单的加载中
|
||||||
|
const uploadRef = ref()
|
||||||
|
const importUrl =
|
||||||
|
import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_URL + '/salary/employee/import'
|
||||||
|
const uploadHeaders = ref() // 上传 Header 头
|
||||||
|
const fileList = ref([]) // 文件列表
|
||||||
|
const updateSupport = ref(0) // 是否更新已经存在的用户数据
|
||||||
|
|
||||||
|
/** 打开弹窗 */
|
||||||
|
const open = () => {
|
||||||
|
dialogVisible.value = true
|
||||||
|
updateSupport.value = 0
|
||||||
|
fileList.value = []
|
||||||
|
resetForm()
|
||||||
|
}
|
||||||
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
||||||
|
/** 提交表单 */
|
||||||
|
const submitForm = async () => {
|
||||||
|
if (fileList.value.length == 0) {
|
||||||
|
message.error('请上传文件')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 提交请求
|
||||||
|
uploadHeaders.value = {
|
||||||
|
Authorization: 'Bearer ' + getAccessToken(),
|
||||||
|
'tenant-id': getTenantId()
|
||||||
|
}
|
||||||
|
formLoading.value = true
|
||||||
|
uploadRef.value!.submit()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 文件上传成功 */
|
||||||
|
const emits = defineEmits(['success'])
|
||||||
|
const submitFormSuccess = (response: any) => {
|
||||||
|
if (response.code !== 0) {
|
||||||
|
message.error(response.msg)
|
||||||
|
formLoading.value = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 拼接提示语
|
||||||
|
const data = response.data
|
||||||
|
let text = '上传成功数量:' + data.createUsernames.length + ';'
|
||||||
|
for (let username of data.createUsernames) {
|
||||||
|
text += '< ' + username + ' >'
|
||||||
|
}
|
||||||
|
text += '更新成功数量:' + data.updateUsernames.length + ';'
|
||||||
|
for (const username of data.updateUsernames) {
|
||||||
|
text += '< ' + username + ' >'
|
||||||
|
}
|
||||||
|
text += '更新失败数量:' + Object.keys(data.failureUsernames).length + ';'
|
||||||
|
for (const username in data.failureUsernames) {
|
||||||
|
text += '< ' + username + ': ' + data.failureUsernames[username] + ' >'
|
||||||
|
}
|
||||||
|
message.alert(text)
|
||||||
|
formLoading.value = false
|
||||||
|
dialogVisible.value = false
|
||||||
|
// 发送操作成功的事件
|
||||||
|
emits('success')
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 上传错误提示 */
|
||||||
|
const submitFormError = (): void => {
|
||||||
|
message.error('上传失败,请您重新上传!')
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置表单 */
|
||||||
|
const resetForm = async (): Promise<void> => {
|
||||||
|
// 重置上传状态和文件
|
||||||
|
formLoading.value = false
|
||||||
|
await nextTick()
|
||||||
|
uploadRef.value?.clearFiles()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 文件数超出提示 */
|
||||||
|
const handleExceed = (): void => {
|
||||||
|
message.error('最多只能上传一个文件!')
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 下载模板操作 */
|
||||||
|
const importTemplate = async () => {
|
||||||
|
const res = await EmpApi.EmployeeApi.importEmpTemplate()
|
||||||
|
download.excel(res, '员工花名册导入模版.xls')
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
@ -135,6 +135,14 @@
|
||||||
>
|
>
|
||||||
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="warning"
|
||||||
|
plain
|
||||||
|
@click="handleImport"
|
||||||
|
v-hasPermi="['salary:employee:import']"
|
||||||
|
>
|
||||||
|
<Icon icon="ep:upload" /> 导入
|
||||||
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
type="success"
|
type="success"
|
||||||
plain
|
plain
|
||||||
|
|
@ -200,6 +208,8 @@
|
||||||
|
|
||||||
<!-- 表单弹窗:添加/修改 -->
|
<!-- 表单弹窗:添加/修改 -->
|
||||||
<EmployeeForm ref="formRef" @success="getList" />
|
<EmployeeForm ref="formRef" @success="getList" />
|
||||||
|
<!-- 用户导入对话框 -->
|
||||||
|
<EmpImportForm ref="importFormRef" @success="getList" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|
@ -207,6 +217,7 @@ import { getStrDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||||
import download from '@/utils/download'
|
import download from '@/utils/download'
|
||||||
import { EmployeeApi, EmployeeVO } from '@/api/arcb/salary/employee'
|
import { EmployeeApi, EmployeeVO } from '@/api/arcb/salary/employee'
|
||||||
import EmployeeForm from './EmployeeForm.vue'
|
import EmployeeForm from './EmployeeForm.vue'
|
||||||
|
import EmpImportForm from './EmployeeImportForm.vue'
|
||||||
|
|
||||||
/** 员工花名册 列表 */
|
/** 员工花名册 列表 */
|
||||||
defineOptions({ name: 'Employee' })
|
defineOptions({ name: 'Employee' })
|
||||||
|
|
@ -260,6 +271,11 @@ const resetQuery = () => {
|
||||||
handleQuery()
|
handleQuery()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const importFormRef = ref()
|
||||||
|
const handleImport = () => {
|
||||||
|
importFormRef.value.open()
|
||||||
|
}
|
||||||
|
|
||||||
/** 添加/修改操作 */
|
/** 添加/修改操作 */
|
||||||
const formRef = ref()
|
const formRef = ref()
|
||||||
const openForm = (type: string, id?: number) => {
|
const openForm = (type: string, id?: number) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue