优化 OA 请假,create 和 detail 使用独立路由,可接入工作流
This commit is contained in:
parent
de5b1216cd
commit
4dabb710c5
@ -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'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -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) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||||
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>
|
||||||
|
@ -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>
|
||||||
|
@ -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
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 取消请假操作 */
|
/** 取消请假操作 */
|
||||||
|
Loading…
Reference in New Issue
Block a user