优化 OA 请假,create 和 detail 使用独立路由,可接入工作流

This commit is contained in:
YunaiV 2023-04-15 16:03:12 +08:00
parent de5b1216cd
commit 4dabb710c5
4 changed files with 88 additions and 93 deletions

View File

@ -313,7 +313,19 @@ const remainingRouter: AppRouteRecordRaw[] = [
hidden: true, hidden: true,
canTo: true, canTo: true,
title: '发起 OA 请假', title: '发起 OA 请假',
activeMenu: 'bpm/oa/leave/create' activeMenu: '/bpm/oa/leave'
}
},
{
path: '/bpm/oa/leave/detail',
component: () => import('@/views/bpm/oa/leave/detail.vue'),
name: 'OALeaveDetail',
meta: {
noCache: true,
hidden: true,
canTo: true,
title: '查看 OA 请假',
activeMenu: '/bpm/oa/leave'
} }
} }
] ]

View File

@ -1,56 +1,55 @@
<template> <template>
<Dialog title="发起 OA 请假流程" v-model="dialogVisible"> <el-form
<el-form ref="formRef"
ref="formRef" :model="formData"
:model="formData" :rules="formRules"
:rules="formRules" label-width="80px"
label-width="80px" v-loading="formLoading"
v-loading="formLoading" >
> <el-form-item label="请假类型" prop="type">
<el-form-item label="请假类型" prop="type"> <el-select v-model="formData.type" placeholder="请选择请假类型" clearable>
<el-select v-model="formData.type" placeholder="请选择请假类型" clearable> <el-option
<el-option v-for="dict in getIntDictOptions(DICT_TYPE.BPM_OA_LEAVE_TYPE)"
v-for="dict in getIntDictOptions(DICT_TYPE.BPM_OA_LEAVE_TYPE)" :key="dict.value"
:key="dict.value" :label="dict.label"
:label="dict.label" :value="dict.value"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="开始时间" prop="startTime">
<el-date-picker
clearable
v-model="formData.startTime"
type="datetime"
value-format="x"
placeholder="请选择开始时间"
/> />
</el-form-item> </el-select>
<el-form-item label="结束时间" prop="endTime"> </el-form-item>
<el-date-picker <el-form-item label="开始时间" prop="startTime">
clearable <el-date-picker
v-model="formData.endTime" clearable
type="datetime" v-model="formData.startTime"
value-format="x" type="datetime"
placeholder="请选择结束时间" value-format="x"
/> placeholder="请选择开始时间"
</el-form-item> />
<el-form-item label="原因" prop="reason"> </el-form-item>
<el-input v-model="formData.reason" type="textarea" placeholder="请输请假原因" /> <el-form-item label="结束时间" prop="endTime">
</el-form-item> <el-date-picker
</el-form> clearable
<template #footer> v-model="formData.endTime"
type="datetime"
value-format="x"
placeholder="请选择结束时间"
/>
</el-form-item>
<el-form-item label="原因" prop="reason">
<el-input v-model="formData.reason" type="textarea" placeholder="请输请假原因" />
</el-form-item>
<el-form-item>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button> <el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button> </el-form-item>
</template> </el-form>
</Dialog>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import * as LeaveApi from '@/api/bpm/leave' import * as LeaveApi from '@/api/bpm/leave'
import { useTagsViewStore } from '@/store/modules/tagsView'
const message = useMessage() // const message = useMessage() //
const { delView } = useTagsViewStore() //
const { currentRoute } = useRouter() //
const dialogVisible = ref(false) //
const formLoading = ref(false) // 12 const formLoading = ref(false) // 12
const formData = ref({ const formData = ref({
type: undefined, type: undefined,
@ -66,15 +65,7 @@ const formRules = reactive({
}) })
const formRef = ref() // Ref const formRef = ref() // Ref
/** 打开弹窗 */
const open = async () => {
dialogVisible.value = true
resetForm()
}
defineExpose({ open }) // open
/** 提交表单 */ /** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => { const submitForm = async () => {
// //
if (!formRef) return if (!formRef) return
@ -85,23 +76,11 @@ const submitForm = async () => {
try { try {
const data = formData.value as unknown as LeaveApi.LeaveVO const data = formData.value as unknown as LeaveApi.LeaveVO
await LeaveApi.createLeave(data) await LeaveApi.createLeave(data)
message.success('新增成功') message.success('发起成功')
dialogVisible.value = false // Tab
// delView(unref(currentRoute))
emit('success')
} finally { } finally {
formLoading.value = false formLoading.value = false
} }
} }
/** 重置表单 */
const resetForm = () => {
formData.value = {
type: undefined,
reason: undefined,
startTime: undefined,
endTime: undefined
}
formRef.value?.resetFields()
}
</script> </script>

View File

@ -1,40 +1,48 @@
<template> <template>
<Dialog title="详情" v-model="dialogVisible" :scroll="true" :max-height="200"> <ContentWrap>
<el-descriptions border :column="1"> <el-descriptions border :column="1">
<el-descriptions-item label="请假类型"> <el-descriptions-item label="请假类型">
<dict-tag :type="DICT_TYPE.BPM_OA_LEAVE_TYPE" :value="detailData.type" /> <dict-tag :type="DICT_TYPE.BPM_OA_LEAVE_TYPE" :value="detailData.type" />
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="开始时间"> <el-descriptions-item label="开始时间">
{{ formatDate(detailData.startTime) }} {{ formatDate(detailData.startTime, 'YYYY-MM-DD') }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="结束时间"> <el-descriptions-item label="结束时间">
{{ formatDate(detailData.endTime) }} {{ formatDate(detailData.endTime, 'YYYY-MM-DD') }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="原因"> <el-descriptions-item label="原因">
{{ detailData.reason }} {{ detailData.reason }}
</el-descriptions-item> </el-descriptions-item>
</el-descriptions> </el-descriptions>
</Dialog> </ContentWrap>
</template> </template>
<script setup lang="ts"> <script setup lang="ts" name="OALeaveCreate">
import { DICT_TYPE } from '@/utils/dict' import { DICT_TYPE } from '@/utils/dict'
import { formatDate } from '@/utils/formatTime' import { formatDate } from '@/utils/formatTime'
import { propTypes } from '@/utils/propTypes'
import * as LeaveApi from '@/api/bpm/leave' import * as LeaveApi from '@/api/bpm/leave'
const { query } = useRoute() //
const dialogVisible = ref(false) // const props = defineProps({
id: propTypes.number.def(undefined)
})
const detailLoading = ref(false) // const detailLoading = ref(false) //
const detailData = ref() // const detailData = ref({}) //
const queryId = query.id as unknown as number // URL id
/** 打开弹窗 */ /** 获得数据 */
const open = async (data: LeaveApi.LeaveVO) => { const getInfo = async () => {
dialogVisible.value = true
//
detailLoading.value = true detailLoading.value = true
try { try {
detailData.value = data detailData.value = await LeaveApi.getLeave(queryId || props.id)
} finally { } finally {
detailLoading.value = false detailLoading.value = false
} }
} }
defineExpose({ open }) // open defineExpose({ open: getInfo }) // open
/** 初始化 **/
onMounted(() => {
getInfo()
})
</script> </script>

View File

@ -137,19 +137,12 @@
@pagination="getList" @pagination="getList"
/> />
</ContentWrap> </ContentWrap>
<!-- 表单弹窗详情 -->
<LeaveDetail ref="detailRef" />
<!-- 表单弹窗添加 -->
<LeaveForm ref="formRef" @success="getList" />
</template> </template>
<script setup lang="ts" name="BpmOALeave"> <script setup lang="ts" name="BpmOALeave">
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
import * as LeaveApi from '@/api/bpm/leave' import * as LeaveApi from '@/api/bpm/leave'
import * as ProcessInstanceApi from '@/api/bpm/processInstance' import * as ProcessInstanceApi from '@/api/bpm/processInstance'
import LeaveDetail from './detail.vue'
import LeaveForm from './create.vue'
const message = useMessage() // const message = useMessage() //
const router = useRouter() // const router = useRouter() //
const { t } = useI18n() // const { t } = useI18n() //
@ -192,15 +185,18 @@ const resetQuery = () => {
} }
/** 添加操作 */ /** 添加操作 */
const formRef = ref()
const handleCreate = () => { const handleCreate = () => {
formRef.value.open() router.push({ name: 'OALeaveCreate' })
} }
/** 详情操作 */ /** 详情操作 */
const detailRef = ref() const handleDetail = (row: LeaveApi.LeaveVO) => {
const handleDetail = (data: LeaveApi.LeaveVO) => { router.push({
detailRef.value.open(data) name: 'OALeaveDetail',
query: {
id: row.id
}
})
} }
/** 取消请假操作 */ /** 取消请假操作 */