优化 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,
canTo: true,
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,5 +1,4 @@
<template>
<Dialog title="发起 OA 请假流程" v-model="dialogVisible">
<el-form
ref="formRef"
:model="formData"
@ -38,19 +37,19 @@
<el-form-item label="原因" prop="reason">
<el-input v-model="formData.reason" type="textarea" placeholder="请输请假原因" />
</el-form-item>
</el-form>
<template #footer>
<el-form-item>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</el-form-item>
</el-form>
</template>
<script setup lang="ts">
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import * as LeaveApi from '@/api/bpm/leave'
import { useTagsViewStore } from '@/store/modules/tagsView'
const message = useMessage() //
const { delView } = useTagsViewStore() //
const { currentRoute } = useRouter() //
const dialogVisible = ref(false) //
const formLoading = ref(false) // 12
const formData = ref({
type: undefined,
@ -66,15 +65,7 @@ const formRules = reactive({
})
const formRef = ref() // Ref
/** 打开弹窗 */
const open = async () => {
dialogVisible.value = true
resetForm()
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
if (!formRef) return
@ -85,23 +76,11 @@ const submitForm = async () => {
try {
const data = formData.value as unknown as LeaveApi.LeaveVO
await LeaveApi.createLeave(data)
message.success('新增成功')
dialogVisible.value = false
//
emit('success')
message.success('发起成功')
// Tab
delView(unref(currentRoute))
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
type: undefined,
reason: undefined,
startTime: undefined,
endTime: undefined
}
formRef.value?.resetFields()
}
</script>

View File

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

View File

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