feat:【antd】【bpm】oa 相关代码优化
This commit is contained in:
@@ -6,6 +6,7 @@ import { computed, onMounted, ref, watch } from 'vue';
|
||||
|
||||
import { confirm, Page, useVbenForm } from '@vben/common-ui';
|
||||
import { BpmCandidateStrategyEnum, BpmNodeIdEnum } from '@vben/constants';
|
||||
import { useTabs } from '@vben/hooks';
|
||||
import { IconifyIcon } from '@vben/icons';
|
||||
|
||||
import { Button, Card, message, Space } from 'ant-design-vue';
|
||||
@@ -20,6 +21,8 @@ import ProcessInstanceTimeline from '#/views/bpm/processInstance/detail/modules/
|
||||
|
||||
import { useFormSchema } from './data';
|
||||
|
||||
const { closeCurrentTab } = useTabs();
|
||||
|
||||
const formLoading = ref(false); // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
|
||||
const processDefineKey = 'oa_leave'; // 流程定义 Key
|
||||
@@ -51,11 +54,11 @@ const [Form, formApi] = useVbenForm({
|
||||
|
||||
/** 提交申请 */
|
||||
async function onSubmit() {
|
||||
// 1.1 表单校验
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 1.2 审批相关:校验指定审批人
|
||||
if (startUserSelectTasks.value?.length > 0) {
|
||||
for (const userTask of startUserSelectTasks.value) {
|
||||
@@ -70,19 +73,16 @@ async function onSubmit() {
|
||||
|
||||
// 提交表单
|
||||
const data = (await formApi.getValues()) as BpmOALeaveApi.Leave;
|
||||
|
||||
// 审批相关:设置指定审批人
|
||||
if (startUserSelectTasks.value?.length > 0) {
|
||||
data.startUserSelectAssignees = startUserSelectAssignees.value;
|
||||
}
|
||||
|
||||
// 格式化开始时间和结束时间的值
|
||||
const submitData: BpmOALeaveApi.Leave = {
|
||||
...data,
|
||||
startTime: Number(data.startTime),
|
||||
endTime: Number(data.endTime),
|
||||
};
|
||||
|
||||
try {
|
||||
formLoading.value = true;
|
||||
await (formData.value?.id
|
||||
@@ -93,12 +93,9 @@ async function onSubmit() {
|
||||
content: $t('ui.actionMessage.operationSuccess'),
|
||||
key: 'action_process_msg',
|
||||
});
|
||||
|
||||
await router.push({
|
||||
name: 'BpmOALeave',
|
||||
});
|
||||
} catch (error: any) {
|
||||
message.error(error.message);
|
||||
} finally {
|
||||
formLoading.value = false;
|
||||
}
|
||||
@@ -111,8 +108,7 @@ function onBack() {
|
||||
icon: 'warning',
|
||||
beforeClose({ isConfirm }) {
|
||||
if (isConfirm) {
|
||||
// TODO @ziye、@jason:是不是要关闭当前标签哈。
|
||||
router.back();
|
||||
closeCurrentTab();
|
||||
}
|
||||
return Promise.resolve(true);
|
||||
},
|
||||
@@ -132,7 +128,6 @@ async function getApprovalDetail() {
|
||||
),
|
||||
}), // 解决 GET 无法传递对象的问题,后端 String 再转 JSON
|
||||
});
|
||||
|
||||
if (!data) {
|
||||
message.error('查询不到审批详情信息!');
|
||||
return;
|
||||
@@ -182,21 +177,20 @@ watch(
|
||||
},
|
||||
);
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
const processDefinitionDetail: any = await getProcessDefinition(
|
||||
undefined,
|
||||
processDefineKey,
|
||||
);
|
||||
|
||||
if (!processDefinitionDetail) {
|
||||
message.error('OA 请假的流程模型未配置,请检查!');
|
||||
return;
|
||||
}
|
||||
|
||||
processDefinitionId.value = processDefinitionDetail.id;
|
||||
startUserSelectTasks.value = processDefinitionDetail.startUserSelectTasks;
|
||||
|
||||
getApprovalDetail();
|
||||
await getApprovalDetail();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -220,7 +214,6 @@ onMounted(async () => {
|
||||
:show-status-icon="false"
|
||||
@select-user-confirm="selectUserConfirm"
|
||||
/>
|
||||
|
||||
<template #actions>
|
||||
<Space warp :size="12" class="w-full px-6">
|
||||
<Button type="primary" @click="onSubmit"> 提交 </Button>
|
||||
|
||||
@@ -82,7 +82,6 @@ async function submitForm() {
|
||||
}
|
||||
// 流程表单校验
|
||||
await fApi.value.validate();
|
||||
|
||||
// 校验指定审批人
|
||||
if (startUserSelectTasks.value?.length > 0) {
|
||||
for (const userTask of startUserSelectTasks.value) {
|
||||
|
||||
Reference in New Issue
Block a user