考勤管理还在做
This commit is contained in:
parent
4e1496dfae
commit
02c56341a4
44
src/api/home/kqgl/index.ts
Normal file
44
src/api/home/kqgl/index.ts
Normal file
@ -0,0 +1,44 @@
|
||||
import request from '@/config/axios'
|
||||
|
||||
// 考勤管理 VO
|
||||
export interface KqglVO {
|
||||
id: number // id
|
||||
userId: number // 用户id
|
||||
userName: string // 用户名字
|
||||
deptId: number // 部门id
|
||||
deptName: string // 部门名字
|
||||
date: Date // 考勤日期
|
||||
}
|
||||
|
||||
// 考勤管理 API
|
||||
export const KqglApi = {
|
||||
// 查询考勤管理分页
|
||||
getKqglPage: async (params: any) => {
|
||||
return await request.get({ url: `/home/kqgl/page`, params })
|
||||
},
|
||||
|
||||
// 查询考勤管理详情
|
||||
getKqgl: async (id: number) => {
|
||||
return await request.get({ url: `/home/kqgl/get?id=` + id })
|
||||
},
|
||||
|
||||
// 新增考勤管理
|
||||
createKqgl: async (data: KqglVO) => {
|
||||
return await request.post({ url: `/home/kqgl/create`, data })
|
||||
},
|
||||
|
||||
// 修改考勤管理
|
||||
updateKqgl: async (data: KqglVO) => {
|
||||
return await request.put({ url: `/home/kqgl/update`, data })
|
||||
},
|
||||
|
||||
// 删除考勤管理
|
||||
deleteKqgl: async (id: number) => {
|
||||
return await request.delete({ url: `/home/kqgl/delete?id=` + id })
|
||||
},
|
||||
|
||||
// 导出考勤管理 Excel
|
||||
exportKqgl: async (params) => {
|
||||
return await request.download({ url: `/home/kqgl/export-excel`, params })
|
||||
},
|
||||
}
|
249
src/views/Home/kqnr/kqgl/index.vue
Normal file
249
src/views/Home/kqnr/kqgl/index.vue
Normal file
@ -0,0 +1,249 @@
|
||||
<template>
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
>
|
||||
<!-- <el-form-item label="id" prop="id">-->
|
||||
<!-- <el-input-->
|
||||
<!-- v-model="queryParams.id"-->
|
||||
<!-- placeholder="请输入id"-->
|
||||
<!-- clearable-->
|
||||
<!-- @keyup.enter="handleQuery"-->
|
||||
<!-- class="!w-240px"-->
|
||||
<!-- />-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- <el-form-item label="用户id" prop="userId">-->
|
||||
<!-- <el-input-->
|
||||
<!-- v-model="queryParams.userId"-->
|
||||
<!-- placeholder="请输入用户id"-->
|
||||
<!-- clearable-->
|
||||
<!-- @keyup.enter="handleQuery"-->
|
||||
<!-- class="!w-240px"-->
|
||||
<!-- />-->
|
||||
<!-- </el-form-item>-->
|
||||
<el-form-item label="用户名字" prop="userName">
|
||||
<el-input
|
||||
v-model="queryParams.userName"
|
||||
placeholder="请输入用户名字"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="部门id" prop="deptId">-->
|
||||
<!-- <el-input-->
|
||||
<!-- v-model="queryParams.deptId"-->
|
||||
<!-- placeholder="请输入部门id"-->
|
||||
<!-- clearable-->
|
||||
<!-- @keyup.enter="handleQuery"-->
|
||||
<!-- class="!w-240px"-->
|
||||
<!-- />-->
|
||||
<!-- </el-form-item>-->
|
||||
<el-form-item label="部门名字" prop="deptName">
|
||||
<el-input
|
||||
v-model="queryParams.deptName"
|
||||
placeholder="请输入部门名字"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="考勤日期" prop="date">-->
|
||||
<!-- <el-date-picker-->
|
||||
<!-- v-model="queryParams.date"-->
|
||||
<!-- value-format="YYYY-MM-DD HH:mm:ss"-->
|
||||
<!-- type="daterange"-->
|
||||
<!-- start-placeholder="开始日期"-->
|
||||
<!-- end-placeholder="结束日期"-->
|
||||
<!-- :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"-->
|
||||
<!-- class="!w-240px"-->
|
||||
<!-- />-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- <el-form-item label="创建时间" prop="createTime">-->
|
||||
<!-- <el-date-picker-->
|
||||
<!-- v-model="queryParams.createTime"-->
|
||||
<!-- value-format="YYYY-MM-DD HH:mm:ss"-->
|
||||
<!-- type="daterange"-->
|
||||
<!-- start-placeholder="开始日期"-->
|
||||
<!-- end-placeholder="结束日期"-->
|
||||
<!-- :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"-->
|
||||
<!-- 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="['home:kqgl:create']"
|
||||
>
|
||||
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
@click="handleExport"
|
||||
:loading="exportLoading"
|
||||
v-hasPermi="['home:kqgl: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="序号" align="center" type="index" width="70" />
|
||||
<!-- <el-table-column label="用户id" align="center" prop="userId" />-->
|
||||
<el-table-column label="用户名字" align="center" prop="userName" />
|
||||
<!-- <el-table-column label="部门id" align="center" prop="deptId" />-->
|
||||
<el-table-column label="部门名字" align="center" prop="deptName" />
|
||||
<el-table-column
|
||||
label="考勤日期"
|
||||
align="center"
|
||||
prop="date"
|
||||
:formatter="dateFormatter"
|
||||
width="180px"
|
||||
/>
|
||||
<!-- <el-table-column-->
|
||||
<!-- label="创建时间"-->
|
||||
<!-- align="center"-->
|
||||
<!-- prop="createTime"-->
|
||||
<!-- :formatter="dateFormatter"-->
|
||||
<!-- width="180px"-->
|
||||
<!-- />-->
|
||||
<el-table-column label="操作" align="center">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
@click="openForm('update', scope.row.id)"
|
||||
v-hasPermi="['home:kqgl:update']"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete(scope.row.id)"
|
||||
v-hasPermi="['home:kqgl: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>
|
||||
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<KqglForm ref="formRef" @success="getList" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import download from '@/utils/download'
|
||||
import { KqglApi, KqglVO } from '@/api/home/kqgl'
|
||||
import KqglForm from './KqglForm.vue'
|
||||
|
||||
/** 考勤管理 列表 */
|
||||
defineOptions({ name: 'Kqgl' })
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const list = ref<KqglVO[]>([]) // 列表的数据
|
||||
const total = ref(0) // 列表的总页数
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
id: undefined,
|
||||
userId: undefined,
|
||||
userName: undefined,
|
||||
deptId: undefined,
|
||||
deptName: undefined,
|
||||
date: [],
|
||||
createTime: [],
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await KqglApi.getKqglPage(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 KqglApi.deleteKqgl(id)
|
||||
message.success(t('common.delSuccess'))
|
||||
// 刷新列表
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
// 导出的二次确认
|
||||
await message.exportConfirm()
|
||||
// 发起导出
|
||||
exportLoading.value = true
|
||||
const data = await KqglApi.exportKqgl(queryParams)
|
||||
download.excel(data, '考勤管理.xls')
|
||||
} catch {
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
160
src/views/Home/kqnr2/kqglForm.vue
Normal file
160
src/views/Home/kqnr2/kqglForm.vue
Normal file
@ -0,0 +1,160 @@
|
||||
<template>
|
||||
<ContentWrap>
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<span style="font-size: 16px">创建考勤管理流程</span>
|
||||
</template>
|
||||
<el-form label-width="70">
|
||||
<el-form-item label="申请人" prop="userName">
|
||||
<el-input
|
||||
v-model="queryParams.userName"
|
||||
placeholder="请输入申请人名字"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="申请部门" prop="deptName">
|
||||
<el-input
|
||||
v-model="queryParams.deptName"
|
||||
placeholder="请输入申请部门"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="申请时间" prop="date">
|
||||
<el-date-picker
|
||||
v-model="queryParams.date"
|
||||
placeholder="申请时间"
|
||||
disabled
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="考勤表单">
|
||||
<el-table :data="queryParams.attendanceData" border style="width: 100%">
|
||||
<!-- 固定姓名和部门列 -->
|
||||
<el-table-column fixed prop="employeeName" label="姓名" width="100" />
|
||||
<!-- 动态生成 1-31 天的列 -->
|
||||
<el-table-column
|
||||
v-for="day in 31"
|
||||
:key="day"
|
||||
:label="day.toString()+'号'"
|
||||
width="80"
|
||||
>
|
||||
<template #default="{$index, row}">
|
||||
<span :style="{
|
||||
color
|
||||
: row.dailyStatus[day - 1] === 1 ? 'green'
|
||||
: row.dailyStatus[day - 1] === 2 ? 'orange'
|
||||
: row.dailyStatus[day - 1] === 3 ? 'yellow'
|
||||
: row.dailyStatus[day - 1] === 4 ? 'red'
|
||||
: row.dailyStatus[day - 1] === 5 ? 'lime'
|
||||
: row.dailyStatus[day - 1] === 6 ? 'violet'
|
||||
: 'gray'
|
||||
}"
|
||||
>
|
||||
<el-popover placement="bottom" width="Min" trigger="click">
|
||||
<template #reference>
|
||||
{{workType[row.dailyStatus[day - 1]]}}
|
||||
</template>
|
||||
<el-row style="padding-bottom: 5px;" :gutter="5" >
|
||||
<el-col :span="12">
|
||||
<el-button @click="changeDay($index,day,1)" color="green">上班</el-button>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-button @click="changeDay($index,day,2)" color="orange">缺勤</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row style="padding-bottom: 5px;" :gutter="5" >
|
||||
<el-col :span="12">
|
||||
<el-button @click="changeDay($index,day,4)" color="lime" >加班</el-button>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-button @click="changeDay($index,day,5)" color="violet" >年班</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-popover>
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="工作日" prop="workDay"/>
|
||||
<el-table-column label="加班" prop="Overtime"/>
|
||||
<el-table-column label="年班" prop="yOvertime"/>
|
||||
</el-table>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<!-- @click="submitForm"-->
|
||||
<el-button type="primary">确 定</el-button>
|
||||
</template>
|
||||
</el-card>
|
||||
</ContentWrap>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" >
|
||||
const workType = ref(
|
||||
{
|
||||
undefined:'选择',
|
||||
1:'正常',
|
||||
2:'缺勤',
|
||||
3:'休息',
|
||||
4:'加班',
|
||||
5:'年班',
|
||||
}
|
||||
)
|
||||
//改变状态后更改对应缩影为对应值
|
||||
const changeDay = async (index:number,day:number,val:number)=>{
|
||||
queryParams.value.attendanceData[index].dailyStatus[day - 1] = val
|
||||
await getWorkDay(index)
|
||||
}
|
||||
//根据现有索引来更新相应的加班年班
|
||||
const getWorkDay = async (index?:number)=>{
|
||||
if (index != undefined){
|
||||
const date = queryParams.value.attendanceData[index]
|
||||
date.workDay = date.dailyStatus.filter(_ => _ === 1).length
|
||||
date.Overtime = date.dailyStatus.filter(_ => _ === 4).length
|
||||
date.yOvertime = date.dailyStatus.filter(_ => _ === 5).length
|
||||
//date为引用类型所以不需要再赋值回去了
|
||||
}else {
|
||||
for (let item of queryParams.value.attendanceData){
|
||||
item.workDay = item.dailyStatus.filter(_ => _ === 1).length
|
||||
item.Overtime = item.dailyStatus.filter(_ => _ === 4).length
|
||||
item.yOvertime = item.dailyStatus.filter(_ => _ === 5).length
|
||||
}
|
||||
}
|
||||
}
|
||||
const queryParams = ref({
|
||||
userName: undefined,
|
||||
userId: undefined,
|
||||
deptName: undefined,
|
||||
deptId: undefined,
|
||||
date: new Date(),
|
||||
attendanceData: [
|
||||
{
|
||||
employeeName: "张三",
|
||||
dailyStatus: [
|
||||
1, 1, 4, 2, 2, 3, 1,
|
||||
1, 1, 1, 4, 1, 1, 1,
|
||||
1, 1, 1, 1, 3, 1, 2,
|
||||
1, 1, 1, 1, 3, 1, 1,
|
||||
2,2,2,
|
||||
],
|
||||
workDay: 0,
|
||||
Overtime: 0,
|
||||
yOvertime:0,
|
||||
},
|
||||
{
|
||||
employeeName: "李四",
|
||||
dailyStatus: [
|
||||
1, 1, 4, 2, 1, 3, 1,
|
||||
1, 1, 1, 4, 1, 1, 1,
|
||||
2, 2, 1, 1, 1, 1, 2,
|
||||
1, 1, 1, 1, 3, 1, 1,
|
||||
2,2,2,
|
||||
],
|
||||
workDay:0,
|
||||
Overtime: 0,
|
||||
yOvertime:0,
|
||||
},
|
||||
],
|
||||
})
|
||||
onMounted(async ()=>{
|
||||
await getWorkDay()
|
||||
})
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user