admin-vue3/src/views/bpm/oa/leave/index.vue

94 lines
2.4 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<ContentWrap>
<XTable @register="registerTable">
<template #toolbar_buttons>
<!-- 操作发起请假 -->
<XButton type="primary" preIcon="ep:plus" title="发起请假" @click="handleCreate()" />
</template>
<template #actionbtns_default="{ row }">
<!-- 操作: 取消请假 -->
<XTextButton
preIcon="ep:delete"
title="取消请假"
v-hasPermi="['bpm:oa-leave:create']"
v-if="row.result === 1"
@click="cancelLeave(row)"
/>
<!-- 操作: 详情 -->
<XTextButton preIcon="ep:view" :title="t('action.detail')" @click="handleDetail(row)" />
<!-- 操作: 审批进度 -->
<XTextButton preIcon="ep:edit-pen" title="审批进度" @click="handleProcessDetail(row)" />
</template>
</XTable>
</ContentWrap>
</template>
<script lang="ts" setup>
// 全局相关的 import
import { ElMessageBox } from 'element-plus'
// 业务相关的 import
import { allSchemas } from './leave.data'
import * as LeaveApi from '@/api/bpm/leave'
import * as ProcessInstanceApi from '@/api/bpm/processInstance'
defineOptions({ name: 'BpmOALeave' })
const { t } = useI18n() // 国际化
const message = useMessage() // 消息弹窗
const { push, router } = useRouter() // 路由
const [registerTable, { reload }] = useXTable({
allSchemas: allSchemas,
getListApi: LeaveApi.getLeavePageApi
})
// 发起请假
const handleCreate = () => {
push({
name: 'BpmOALeaveCreate'
})
}
// 取消请假
const cancelLeave = (row) => {
ElMessageBox.prompt('请输入取消原因', '取消流程', {
confirmButtonText: t('common.ok'),
cancelButtonText: t('common.cancel'),
inputPattern: /^[\s\S]*.*\S[\s\S]*$/, // 判断非空,且非空格
inputErrorMessage: '取消原因不能为空'
}).then(async ({ value }) => {
await ProcessInstanceApi.cancelProcessInstanceApi(row.id, value)
message.success('取消成功')
reload()
})
}
// 详情
const handleDetail = (row) => {
push({
name: 'BpmOALeaveDetail',
query: {
id: row.id
}
})
}
// 审批进度
const handleProcessDetail = (row) => {
push({
name: 'BpmProcessInstanceDetail',
query: {
id: row.processInstanceId
}
})
}
// fix: 列表不刷新的问题。
watch(
() => router.currentRoute.value,
() => {
reload()
}
)
</script>