特殊考勤管理
parent
29efa7b985
commit
d3562c9cc2
|
|
@ -0,0 +1,48 @@
|
|||
import request from '@/config/axios'
|
||||
|
||||
// 特殊考勤 VO
|
||||
export interface AttendanceVO {
|
||||
id: number // 唯一标识符
|
||||
idNo: string // 身份证号
|
||||
month: string // 月份
|
||||
attendStatus: string // 考勤状态
|
||||
attendDays: number // 天数
|
||||
deduction: number // 扣款
|
||||
note: string // 备注
|
||||
}
|
||||
|
||||
// 特殊考勤 API
|
||||
export const AttendanceApi = {
|
||||
// 查询特殊考勤分页
|
||||
getAttendancePage: async (params: any) => {
|
||||
return await request.get({ url: `arcb/salary/attendance/page`, params })
|
||||
},
|
||||
|
||||
// 查询特殊考勤详情
|
||||
getAttendance: async (id: number) => {
|
||||
return await request.get({ url: `arcb/salary/attendance/get?id=` + id })
|
||||
},
|
||||
|
||||
// 新增特殊考勤
|
||||
createAttendance: async (data: AttendanceVO) => {
|
||||
return await request.post({ url: `arcb/salary/attendance/create`, data })
|
||||
},
|
||||
|
||||
// 修改特殊考勤
|
||||
updateAttendance: async (data: AttendanceVO) => {
|
||||
return await request.put({ url: `arcb/salary/attendance/update`, data })
|
||||
},
|
||||
|
||||
// 删除特殊考勤
|
||||
deleteAttendance: async (id: number) => {
|
||||
return await request.delete({ url: `arcb/salary/attendance/delete?id=` + id })
|
||||
},
|
||||
|
||||
// 导出特殊考勤 Excel
|
||||
exportAttendance: async (params) => {
|
||||
return await request.download({ url: `arcb/salary/attendance/export-excel`, params })
|
||||
},
|
||||
importAttendanceTemplate: async () => {
|
||||
return request.download({ url: 'arcb/salary/attendance/get-import-template' })
|
||||
}
|
||||
}
|
||||
|
|
@ -243,5 +243,8 @@ export enum DICT_TYPE {
|
|||
|
||||
// ===================人力资源模块======================
|
||||
ARCB_EMP_STATUS = 'arcb_emp_status', //员工状态
|
||||
ARCB_POSITION_CATEGORY = 'arcb_position_category' //岗位序列
|
||||
ARCB_POSITION_CATEGORY = 'arcb_position_category', //岗位序列
|
||||
ARCB_SALARY_SPECIAL_ATTENDANCE = 'arcb_salary_special_attendance' //特殊考勤-考勤状态
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,123 @@
|
|||
<template>
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="100px"
|
||||
v-loading="formLoading"
|
||||
>
|
||||
<el-form-item label="身份证号" prop="idNo">
|
||||
<el-input v-model="formData.idNo" placeholder="请输入身份证号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="月份" prop="month">
|
||||
<el-input v-model="formData.month" placeholder="请输入月份" />
|
||||
</el-form-item>
|
||||
<el-form-item label="考勤状态" prop="attendStatus">
|
||||
<el-radio-group v-model="formData.attendStatus">
|
||||
<el-radio value="1">请选择字典生成</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="天数" prop="attendDays">
|
||||
<el-input v-model="formData.attendDays" placeholder="请输入天数" />
|
||||
</el-form-item>
|
||||
<el-form-item label="扣款" prop="deduction">
|
||||
<el-input v-model="formData.deduction" placeholder="请输入扣款" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="note">
|
||||
<el-input v-model="formData.note" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { AttendanceApi, AttendanceVO } from '@/api/arcb/salary/attendance'
|
||||
|
||||
/** 特殊考勤 表单 */
|
||||
defineOptions({ name: 'AttendanceForm' })
|
||||
|
||||
const { t } = useI18n() // 国际化
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const dialogTitle = ref('') // 弹窗的标题
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||
const formData = ref({
|
||||
id: undefined,
|
||||
idNo: undefined,
|
||||
month: undefined,
|
||||
attendStatus: undefined,
|
||||
attendDays: undefined,
|
||||
deduction: undefined,
|
||||
note: undefined,
|
||||
})
|
||||
const formRules = reactive({
|
||||
idNo: [{ required: true, message: '身份证号不能为空', trigger: 'blur' }],
|
||||
month: [{ required: true, message: '月份不能为空', trigger: 'blur' }],
|
||||
attendStatus: [{ required: true, message: '考勤状态不能为空', trigger: 'blur' }],
|
||||
attendDays: [{ required: true, message: '天数不能为空', trigger: 'blur' }],
|
||||
deduction: [{ required: true, message: '扣款不能为空', trigger: 'blur' }],
|
||||
})
|
||||
const formRef = ref() // 表单 Ref
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async (type: string, id?: number) => {
|
||||
dialogVisible.value = true
|
||||
dialogTitle.value = t('action.' + type)
|
||||
formType.value = type
|
||||
resetForm()
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
formLoading.value = true
|
||||
try {
|
||||
formData.value = await AttendanceApi.getAttendance(id)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
const submitForm = async () => {
|
||||
// 校验表单
|
||||
await formRef.value.validate()
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = formData.value as unknown as AttendanceVO
|
||||
if (formType.value === 'create') {
|
||||
await AttendanceApi.createAttendance(data)
|
||||
message.success(t('common.createSuccess'))
|
||||
} else {
|
||||
await AttendanceApi.updateAttendance(data)
|
||||
message.success(t('common.updateSuccess'))
|
||||
}
|
||||
dialogVisible.value = false
|
||||
// 发送操作成功的事件
|
||||
emit('success')
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = () => {
|
||||
formData.value = {
|
||||
id: undefined,
|
||||
idNo: undefined,
|
||||
month: undefined,
|
||||
attendStatus: undefined,
|
||||
attendDays: undefined,
|
||||
deduction: undefined,
|
||||
note: undefined,
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
</script>
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
<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 { getAccessToken, getTenantId } from '@/utils/auth'
|
||||
import download from '@/utils/download'
|
||||
import * as attendanceApi from "@/api/arcb/salary/attendance";
|
||||
|
||||
defineOptions({ name: 'AttendanceImportForm' })
|
||||
|
||||
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 + '/arcb/salary/attendance/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.createData.length + ';'
|
||||
for (let idNo of data.createData) {
|
||||
text += '< ' + idNo + ' >'
|
||||
}
|
||||
text += '更新成功数量:' + data.updateData.length + ';'
|
||||
for (const idNo of data.updateData) {
|
||||
text += '< ' + idNo + ' >'
|
||||
}
|
||||
text += '更新失败数量:' + Object.keys(data.failureData).length + ';'
|
||||
for (const idNo in data.failureData) {
|
||||
text += '< ' + idNo + ': ' + data.failureData[idNo] + ' >'
|
||||
}
|
||||
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 attendanceApi.AttendanceApi.importAttendanceTemplate()
|
||||
download.excel(res, '特殊考勤导入模版.xlsx')
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
|
@ -0,0 +1,250 @@
|
|||
<template>
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
>
|
||||
<el-form-item label="身份证号" prop="idNo">
|
||||
<el-input
|
||||
v-model="queryParams.idNo"
|
||||
placeholder="请输入身份证号"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="月份" prop="month">
|
||||
<el-input
|
||||
v-model="queryParams.month"
|
||||
placeholder="请输入月份"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="考勤状态" prop="attendStatus">
|
||||
<el-select
|
||||
v-model="queryParams.attendStatus"
|
||||
placeholder="请选择考勤状态"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.ARCB_SALARY_SPECIAL_ATTENDANCE)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="天数" prop="attendDays">
|
||||
<el-input
|
||||
v-model="queryParams.attendDays"
|
||||
placeholder="请输入天数"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="扣款" prop="deduction">
|
||||
<el-input
|
||||
v-model="queryParams.deduction"
|
||||
placeholder="请输入扣款"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="note">
|
||||
<el-input
|
||||
v-model="queryParams.note"
|
||||
placeholder="请输入备注"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
@click="openForm('create')"
|
||||
v-hasPermi="['arcb:attendance:create']"
|
||||
>
|
||||
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||
</el-button>
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
@click="handleImport"
|
||||
v-hasPermi="['arcb:attendance:create']"
|
||||
>
|
||||
<Icon icon="ep:upload"/>
|
||||
导入
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
@click="handleExport"
|
||||
:loading="exportLoading"
|
||||
v-hasPermi="['arcb:attendance:export']"
|
||||
>
|
||||
<Icon icon="ep:download" class="mr-5px" /> 导出
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
||||
<el-table-column label="ID" align="center" prop="id" />
|
||||
<el-table-column label="身份证号" align="center" prop="idNo" />
|
||||
<el-table-column label="月份" align="center" prop="month" />
|
||||
<el-table-column label="考勤状态" align="center" prop="attendStatus">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.ARCB_SALARY_SPECIAL_ATTENDANCE" :value="scope.row.attendStatus" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="天数" align="center" prop="attendDays" />
|
||||
<el-table-column label="扣款" align="center" prop="deduction" />
|
||||
<el-table-column label="备注" align="center" prop="note" />
|
||||
<el-table-column label="操作" align="center" min-width="120px">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
@click="openForm('update', scope.row.id)"
|
||||
v-hasPermi="['arcb:attendance:update']"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete(scope.row.id)"
|
||||
v-hasPermi="['arcb:attendance:delete']"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页 -->
|
||||
<Pagination
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNo"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<AttendanceForm ref="formRef" @success="getList" />
|
||||
<AttendanceImportForm ref="importFormRef" @success="getList"/>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { getStrDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||
import download from '@/utils/download'
|
||||
import { AttendanceApi, AttendanceVO } from '@/api/arcb/salary/attendance'
|
||||
import AttendanceForm from './AttendanceForm.vue'
|
||||
import AttendanceImportForm from './AttendanceImportForm.vue'
|
||||
|
||||
/** 特殊考勤 列表 */
|
||||
defineOptions({ name: 'Attendance' })
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const list = ref<AttendanceVO[]>([]) // 列表的数据
|
||||
const total = ref(0) // 列表的总页数
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
idNo: undefined,
|
||||
month: undefined,
|
||||
attendStatus: undefined,
|
||||
attendDays: undefined,
|
||||
deduction: undefined,
|
||||
note: undefined,
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await AttendanceApi.getAttendancePage(queryParams)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value.resetFields()
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 添加/修改操作 */
|
||||
const formRef = ref()
|
||||
const openForm = (type: string, id?: number) => {
|
||||
formRef.value.open(type, id)
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
// 删除的二次确认
|
||||
await message.delConfirm()
|
||||
// 发起删除
|
||||
await AttendanceApi.deleteAttendance(id)
|
||||
message.success(t('common.delSuccess'))
|
||||
// 刷新列表
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
// 导出的二次确认
|
||||
await message.exportConfirm()
|
||||
// 发起导出
|
||||
exportLoading.value = true
|
||||
const data = await AttendanceApi.exportAttendance(queryParams)
|
||||
download.excel(data, '特殊考勤.xlsx')
|
||||
} catch {
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const importFormRef = ref()
|
||||
const handleImport = () => {
|
||||
importFormRef.value.open()
|
||||
}
|
||||
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
Loading…
Reference in New Issue