feat: [BPM 工作流] Simple 模型 - 流程设计校验
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
import type { Ref } from 'vue';
|
||||
|
||||
import { computed, inject, nextTick } from 'vue';
|
||||
import { computed, inject, nextTick, ref } from 'vue';
|
||||
|
||||
import { BpmModelType } from '#/utils';
|
||||
|
||||
@@ -13,12 +13,21 @@ const modelData = defineModel<any>();
|
||||
|
||||
const processData = inject('processData') as Ref;
|
||||
|
||||
const simpleDesign = ref();
|
||||
|
||||
/** 表单校验 */
|
||||
const validate = async () => {
|
||||
// 获取最新的流程数据
|
||||
if (!processData.value) {
|
||||
throw new Error('请设计流程');
|
||||
}
|
||||
if (modelData.value.type === BpmModelType.SIMPLE) {
|
||||
// 简易设计器校验
|
||||
const validateResult = await simpleDesign.value?.validateConfig();
|
||||
if (!validateResult) {
|
||||
throw new Error('请完善设计配置');
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
/** 处理设计器保存成功 */
|
||||
@@ -41,9 +50,7 @@ const handleDesignSuccess = async (data?: any) => {
|
||||
const showDesigner = computed(() => {
|
||||
return Boolean(modelData.value?.key && modelData.value?.name);
|
||||
});
|
||||
defineExpose({
|
||||
validate,
|
||||
});
|
||||
defineExpose({ validate });
|
||||
</script>
|
||||
<template>
|
||||
<div class="h-full">
|
||||
@@ -61,6 +68,7 @@ defineExpose({
|
||||
:start-user-ids="modelData.startUserIds"
|
||||
:start-dept-ids="modelData.startDeptIds"
|
||||
@success="handleDesignSuccess"
|
||||
ref="simpleDesign"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
@@ -17,12 +17,17 @@ defineProps<{
|
||||
const emit = defineEmits(['success']);
|
||||
const designerRef = ref();
|
||||
|
||||
// 修改成功回调
|
||||
/** 保存成功回调 */
|
||||
const handleSuccess = (data?: any) => {
|
||||
if (data) {
|
||||
emit('success', data);
|
||||
}
|
||||
};
|
||||
/** 设计器配置校验 */
|
||||
const validateConfig = async () => {
|
||||
return await designerRef.value.validate();
|
||||
};
|
||||
defineExpose({ validateConfig });
|
||||
</script>
|
||||
<template>
|
||||
<ContentWrap :body-style="{ padding: '20px 16px' }">
|
||||
|
||||
Reference in New Issue
Block a user