考勤草稿内容
This commit is contained in:
parent
6f61827bb5
commit
c16fd32699
@ -45,4 +45,12 @@ export const KqglApi = {
|
||||
exportKqgl: async (params) => {
|
||||
return await request.download({ url: `/home/kqgl/export-excel`, params })
|
||||
},
|
||||
// 保存为草稿
|
||||
saveDraft: async (data: KqglVO) => {
|
||||
return await request.post({ url: `/home/kqgl/saveDraft`, data })
|
||||
},
|
||||
// 查询草稿
|
||||
getDraft: async (params: any) => {
|
||||
return await request.get({ url: `/home/kqgl/draft`, params })
|
||||
},
|
||||
}
|
||||
|
209
src/views/Home/kqnr/draft/indexDraftKqgl.vue
Normal file
209
src/views/Home/kqnr/draft/indexDraftKqgl.vue
Normal file
@ -0,0 +1,209 @@
|
||||
<template>
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
>
|
||||
<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="部门名字" prop="deptName">
|
||||
<el-input
|
||||
v-model="queryParams.deptName"
|
||||
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="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="用户名字" align="center" prop="userName" />
|
||||
<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">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
v-hasPermi="['home:clgl:update']"
|
||||
link
|
||||
type="primary"
|
||||
@click="handleDetail(scope.row)"
|
||||
>
|
||||
详情
|
||||
</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 "@/views/Home/kqnr/kqgl/KqglForm.vue";
|
||||
import * as LeaveApi from '@/api/bpm/leave'
|
||||
|
||||
/** 考勤管理 列表 */
|
||||
defineOptions({ name: 'KqglDraft' })
|
||||
|
||||
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,
|
||||
title: undefined,
|
||||
userId: undefined,
|
||||
userName: undefined,
|
||||
deptId: undefined,
|
||||
deptName: undefined,
|
||||
status: undefined,
|
||||
date: [],
|
||||
createTime: [],
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
|
||||
const router = useRouter() // 路由
|
||||
/**发起操作 */
|
||||
// const handleCreate = () => {
|
||||
// router.push({ name: 'KqglCreate' })
|
||||
// }
|
||||
/** 详情操作 */
|
||||
const handleDetail = (row: LeaveApi.LeaveVO) => {
|
||||
router.push({
|
||||
name: 'KqglCreate',
|
||||
query: {
|
||||
id: row.id
|
||||
}
|
||||
})
|
||||
}
|
||||
/** 审批进度 */
|
||||
// const handleProcessDetail = (row) => {
|
||||
// router.push({
|
||||
// name: 'BpmProcessInstanceDetail',
|
||||
// query: {
|
||||
// id: row.processInstanceId
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// fix: 列表不刷新的问题。
|
||||
watch(
|
||||
() => router.currentRoute.value,
|
||||
() => {
|
||||
getList()
|
||||
}
|
||||
)
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await KqglApi.getDraft(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>
|
@ -76,6 +76,7 @@
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
||||
<el-button @click="saveDraft" type="warning" :disabled="draftButton">存为草稿</el-button>
|
||||
</template>
|
||||
</el-card>
|
||||
</template>
|
||||
@ -297,6 +298,10 @@ const changeStatus = async ()=>{
|
||||
}
|
||||
};
|
||||
|
||||
//流程
|
||||
const { query } = useRoute() // 查询参数
|
||||
const queryId = query.id as unknown as number // 从 URL 传递过来的 id 编号
|
||||
|
||||
/** 打开弹窗 设置时间戳为固定信息 */
|
||||
const open = async () => {
|
||||
pop.value=false//每次打开渲染span
|
||||
@ -306,9 +311,15 @@ const open = async () => {
|
||||
formLoading.value = true
|
||||
try {
|
||||
await getUserInfo() //获取当前用户,部门数据
|
||||
//创建的我就新建数据,还有新建标识,把标识传递过去
|
||||
await createUser()
|
||||
await getList(dateKey.value)
|
||||
// 通过queryId判断 草稿模式走草稿逻辑 新建模式走新建逻辑
|
||||
if (queryId){
|
||||
formData.value = await KqglApi.getKqgl(queryId)
|
||||
await getList() //如果是修改那么我获取列表标识使用有的标识
|
||||
} else {
|
||||
//创建的我就新建数据,还有新建标识,把标识传递过去
|
||||
await createUser()
|
||||
await getList(dateKey.value)
|
||||
}
|
||||
await changeStatus()//把字符串工作状态更改为数组
|
||||
await getWorkDay()//获取工作日信息
|
||||
} finally {
|
||||
@ -336,19 +347,29 @@ const submitForm = async () => {
|
||||
data.startUserSelectAssignees = startUserSelectAssignees.value
|
||||
}
|
||||
|
||||
const curFullPath = currentRoute.value.fullPath
|
||||
let curFullPath = currentRoute.value.fullPath
|
||||
|
||||
if( curFullPath ) {
|
||||
data.curfullpath = curFullPath
|
||||
}
|
||||
if (curFullPath.includes("?")) {
|
||||
curFullPath = curFullPath.split("?")[0];
|
||||
}
|
||||
const processKey = await FormProcessMappingApi.selectProcessKey( curFullPath )
|
||||
if ( processKey) {
|
||||
data.processDefinitionKey = processKey
|
||||
}
|
||||
|
||||
data.date = dateKey.value //创建后提交的时候才会更新标识
|
||||
await KqglApi.createKqgl(data)
|
||||
await updateUser() //提交的时候更新考勤数据
|
||||
// 提交的时候也是,因为草稿保存时key已经保存过了,所以草稿模式不需要再保存key,会覆盖原数据,
|
||||
// 判断 新建模式就正常保存key
|
||||
if (queryId){
|
||||
await KqglApi.createKqgl(data)
|
||||
await updateUser() //提交的时候更新考勤数据
|
||||
}else {
|
||||
data.date = dateKey.value //创建后提交的时候才会更新标识
|
||||
await KqglApi.createKqgl(data)
|
||||
await updateUser() //提交的时候更新考勤数据
|
||||
}
|
||||
message.success(t('common.createSuccess'))
|
||||
|
||||
delView(unref(currentRoute))
|
||||
@ -357,13 +378,44 @@ const submitForm = async () => {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
const draftButton = ref(false)
|
||||
const saveDraft = async () => {
|
||||
// 校验表单
|
||||
await formRef.value.validate()
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = formData.value as unknown as KqglVO
|
||||
// 这里时考勤独有的需要保存一下key
|
||||
data.date = dateKey.value //创建后提交的时候才会更新标识
|
||||
await KqglApi.saveDraft(data)
|
||||
await updateUser() //提交的时候更新考勤数据
|
||||
message.success(t('存为草稿成功!'))
|
||||
// 关闭当前 Tab
|
||||
delView(unref(currentRoute))
|
||||
await push({ name: 'Kqgl' })
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
await open()
|
||||
|
||||
const curFullPath = currentRoute.value.fullPath
|
||||
let curFullPath = currentRoute.value.fullPath
|
||||
|
||||
if (curFullPath.includes("?")) {
|
||||
// 使用 URLSearchParams 提取查询参数
|
||||
const params = new URLSearchParams(curFullPath.split("?")[1]);
|
||||
const id = params.get("id") ;
|
||||
// 获取路径部分
|
||||
curFullPath = curFullPath.split("?")[0];
|
||||
if ( id != "") {
|
||||
formData.value = await KqglApi.getKqgl(Number( id) )
|
||||
draftButton.value= true
|
||||
}
|
||||
}
|
||||
const processKey = await FormProcessMappingApi.selectProcessKey( curFullPath )
|
||||
|
||||
if ( !processKey ) {
|
||||
|
Loading…
Reference in New Issue
Block a user