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