mirror of
https://gitee.com/dapppp/ruoyi-plus-vben5.git
synced 2026-04-03 19:43:23 +08:00
refactor: 发起流程前的loading
This commit is contained in:
@@ -17,6 +17,10 @@ interface Emits {
|
|||||||
* 完成
|
* 完成
|
||||||
*/
|
*/
|
||||||
complete: [];
|
complete: [];
|
||||||
|
/**
|
||||||
|
* 取消 此时已经变成草稿状态了
|
||||||
|
*/
|
||||||
|
cancel: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const emit = defineEmits<Emits>();
|
const emit = defineEmits<Emits>();
|
||||||
@@ -31,6 +35,7 @@ const [BasicModal, modalApi] = useVbenModal({
|
|||||||
title: '流程发起',
|
title: '流程发起',
|
||||||
fullscreenButton: false,
|
fullscreenButton: false,
|
||||||
onConfirm: handleSubmit,
|
onConfirm: handleSubmit,
|
||||||
|
onCancel: () => emit('cancel'),
|
||||||
async onOpenChange(isOpen) {
|
async onOpenChange(isOpen) {
|
||||||
if (!isOpen) {
|
if (!isOpen) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -3,7 +3,12 @@ import type { LeaveVO } from '../leave/api/model';
|
|||||||
|
|
||||||
import { computed, onMounted, shallowRef } from 'vue';
|
import { computed, onMounted, shallowRef } from 'vue';
|
||||||
|
|
||||||
import { Descriptions, DescriptionsItem, Skeleton } from 'ant-design-vue';
|
import {
|
||||||
|
Alert,
|
||||||
|
Descriptions,
|
||||||
|
DescriptionsItem,
|
||||||
|
Skeleton,
|
||||||
|
} from 'ant-design-vue';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
import { leaveInfo } from './api';
|
import { leaveInfo } from './api';
|
||||||
@@ -36,6 +41,12 @@ function formatDate(date: string) {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="rounded-[6px] border p-2">
|
<div class="rounded-[6px] border p-2">
|
||||||
|
<Alert
|
||||||
|
class="mb-4"
|
||||||
|
type="success"
|
||||||
|
show-icon
|
||||||
|
message="新版已经重构为映射组件方式来显示详情 来替代原来的iframe方案 加载速度更快(该提示会在发版前去除)"
|
||||||
|
/>
|
||||||
<Descriptions v-if="data" :column="1" size="middle">
|
<Descriptions v-if="data" :column="1" size="middle">
|
||||||
<DescriptionsItem label="请假类型">
|
<DescriptionsItem label="请假类型">
|
||||||
{{ leaveType }}
|
{{ leaveType }}
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { StartWorkFlowReqData } from '#/api/workflow/task/model';
|
import type { StartWorkFlowReqData } from '#/api/workflow/task/model';
|
||||||
|
|
||||||
import { onMounted } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
|
|
||||||
import { useVbenModal } from '@vben/common-ui';
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
import { useTabs } from '@vben/hooks';
|
||||||
|
|
||||||
import { Card } from 'ant-design-vue';
|
import { Card, Spin } from 'ant-design-vue';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { cloneDeep, omit } from 'lodash-es';
|
import { cloneDeep, omit } from 'lodash-es';
|
||||||
|
|
||||||
@@ -36,13 +37,18 @@ const [BasicForm, formApi] = useVbenForm({
|
|||||||
wrapperClass: 'grid-cols-2',
|
wrapperClass: 'grid-cols-2',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const loading = ref(false);
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
// 只读 获取信息赋值
|
// 只读 获取信息赋值
|
||||||
if (id) {
|
if (id) {
|
||||||
|
loading.value = true;
|
||||||
|
|
||||||
const resp = await leaveInfo(id);
|
const resp = await leaveInfo(id);
|
||||||
await formApi.setValues(resp);
|
await formApi.setValues(resp);
|
||||||
const dateRange = [dayjs(resp.startDate), dayjs(resp.endDate)];
|
const dateRange = [dayjs(resp.startDate), dayjs(resp.endDate)];
|
||||||
await formApi.setFieldValue('dateRange', dateRange);
|
await formApi.setFieldValue('dateRange', dateRange);
|
||||||
|
|
||||||
|
loading.value = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -88,6 +94,7 @@ async function handleTempSave() {
|
|||||||
* 保存业务 & 发起流程
|
* 保存业务 & 发起流程
|
||||||
*/
|
*/
|
||||||
async function handleStartWorkFlow() {
|
async function handleStartWorkFlow() {
|
||||||
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
// 保存业务
|
// 保存业务
|
||||||
const leaveResp = await handleSaveOrUpdate();
|
const leaveResp = await handleSaveOrUpdate();
|
||||||
@@ -113,25 +120,38 @@ async function handleStartWorkFlow() {
|
|||||||
applyModalApi.open();
|
applyModalApi.open();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleComplete() {
|
const { closeCurrentTab } = useTabs();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用提交/取消回调
|
||||||
|
*
|
||||||
|
* 提交后点击取消 这时候已经变成草稿状态了
|
||||||
|
* 每次点击都会生成新记录 直接跳转回列表
|
||||||
|
*/
|
||||||
|
async function handleCompleteOrCancel() {
|
||||||
formApi.resetForm();
|
formApi.resetForm();
|
||||||
|
await closeCurrentTab();
|
||||||
router.push('/demo/leave');
|
router.push('/demo/leave');
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Card>
|
<Spin :spinning="loading">
|
||||||
<div id="leave-form">
|
<Card>
|
||||||
<!-- 使用v-if会影响生命周期 -->
|
|
||||||
<BasicForm />
|
<BasicForm />
|
||||||
<div class="flex justify-end gap-2">
|
<div class="flex justify-end gap-2">
|
||||||
<a-button @click="handleTempSave">暂存</a-button>
|
<a-button @click="handleTempSave">暂存</a-button>
|
||||||
<a-button type="primary" @click="handleStartWorkFlow">提交</a-button>
|
<a-button type="primary" @click="handleStartWorkFlow">提交</a-button>
|
||||||
</div>
|
</div>
|
||||||
<ApplyModal @complete="handleComplete" />
|
<ApplyModal
|
||||||
</div>
|
@complete="handleCompleteOrCancel"
|
||||||
</Card>
|
@cancel="handleCompleteOrCancel"
|
||||||
|
/>
|
||||||
|
</Card>
|
||||||
|
</Spin>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user