From deefea6a184d3473732250fdb1b102b616475d34 Mon Sep 17 00:00:00 2001 From: jason <2667446@qq.com> Date: Sun, 25 May 2025 08:46:09 +0800 Subject: [PATCH 1/2] =?UTF-8?q?perf:=20review=20todo=20=E7=9A=84=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/bpm/model/form/index.vue | 19 +------------------ apps/web-antd/src/views/bpm/model/index.vue | 2 +- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/apps/web-antd/src/views/bpm/model/form/index.vue b/apps/web-antd/src/views/bpm/model/form/index.vue index 0ea84ac7..2c2f61fb 100644 --- a/apps/web-antd/src/views/bpm/model/form/index.vue +++ b/apps/web-antd/src/views/bpm/model/form/index.vue @@ -26,6 +26,7 @@ import { } from '#/api/bpm/model'; import { getSimpleDeptList } from '#/api/system/dept'; import { getSimpleUserList } from '#/api/system/user'; +import { BpmAutoApproveType, BpmModelFormType, BpmModelType } from '#/utils'; import BasicInfo from './modules/basic-info.vue'; import FormDesign from './modules/form-design.vue'; @@ -33,24 +34,6 @@ import ProcessDesign from './modules/process-design.vue'; defineOptions({ name: 'BpmModelCreate' }); -// TODO 这个常量是不是所有 apps 都可以使用, 放 @utils/constant.ts 不能共享, @芋艿 这些常量放哪里合适! -// TODO @jason:/Users/yunai/Java/yudao-ui-admin-vben-v5/apps/web-antd/src/utils/constants.ts;先不多个 apps 共享哈; -const BpmModelType = { - BPMN: 10, // BPMN 设计器 - SIMPLE: 20, // 简易设计器 -}; - -const BpmModelFormType = { - NORMAL: 10, // 流程表单 - CUSTOM: 20, // 业务表单 -}; - -const BpmAutoApproveType = { - NONE: 0, // 不自动通过 - APPROVE_ALL: 1, // 仅审批一次,后续重复的审批节点均自动通过 - APPROVE_SEQUENT: 2, // 仅针对连续审批的节点自动通过 -}; - // 流程定义类型 type BpmProcessDefinitionType = Omit< BpmProcessDefinitionApi.ProcessDefinitionVO, diff --git a/apps/web-antd/src/views/bpm/model/index.vue b/apps/web-antd/src/views/bpm/model/index.vue index 64ef6646..32028843 100644 --- a/apps/web-antd/src/views/bpm/model/index.vue +++ b/apps/web-antd/src/views/bpm/model/index.vue @@ -162,7 +162,7 @@ const handleCategorySortSubmit = async () => { diff --git a/apps/web-antd/src/components/simple-process-design/components/simple-process-designer.vue b/apps/web-antd/src/components/simple-process-design/components/simple-process-designer.vue index f817963c..7f2762ca 100644 --- a/apps/web-antd/src/components/simple-process-design/components/simple-process-designer.vue +++ b/apps/web-antd/src/components/simple-process-design/components/simple-process-designer.vue @@ -3,21 +3,19 @@ import type { Ref } from 'vue'; import type { SimpleFlowNode } from '../consts'; -import type { BpmFormApi } from '#/api/bpm/form'; import type { BpmUserGroupApi } from '#/api/bpm/userGroup'; import type { SystemDeptApi } from '#/api/system/dept'; import type { SystemPostApi } from '#/api/system/post'; import type { SystemRoleApi } from '#/api/system/role'; import type { SystemUserApi } from '#/api/system/user'; -import { inject, onMounted, provide, ref } from 'vue'; +import { inject, onMounted, provide, ref, watch } from 'vue'; import { handleTree } from '@vben/utils'; import { Button, Modal } from 'ant-design-vue'; import { getFormDetail } from '#/api/bpm/form'; -import { getModel } from '#/api/bpm/model'; import { getUserGroupSimpleList } from '#/api/bpm/userGroup'; import { getSimpleDeptList } from '#/api/system/dept'; import { getSimplePostList } from '#/api/system/post'; @@ -33,21 +31,23 @@ defineOptions({ }); const props = defineProps({ - modelId: { - type: String, - required: false, - default: undefined, - }, - modelKey: { - type: String, - required: false, - default: undefined, - }, modelName: { type: String, required: false, default: undefined, }, + // 流程表单 ID + modelFormId: { + type: Number, + required: false, + default: undefined, + }, + // 表单类型 + modelFormType: { + type: Number, + required: false, + default: BpmModelFormType.NORMAL, + }, // 可发起流程的人员编号 startUserIds: { type: Array, @@ -66,7 +66,31 @@ const emits = defineEmits(['success']); const processData = inject('processData') as Ref; const loading = ref(false); const formFields = ref([]); -const formType = ref(20); +const formType = ref(props.modelFormType); + +// 监听 modelFormType 变化 +watch( + () => props.modelFormType, + (newVal) => { + formType.value = newVal; + }, +); + +// 监听 modelFormId 变化 +watch( + () => props.modelFormId, + async (newVal) => { + if (newVal) { + const form = await getFormDetail(newVal); + formFields.value = form?.fields; + } else { + // 如果 modelFormId 为空,清空表单字段 + formFields.value = []; + } + }, + { immediate: true }, +); + const roleOptions = ref([]); // 角色列表 const postOptions = ref([]); // 岗位列表 const userOptions = ref([]); // 用户列表 @@ -172,19 +196,6 @@ const validateNode = ( onMounted(async () => { try { loading.value = true; - // 获取表单字段 - if (props.modelId) { - const bpmnModel = await getModel(props.modelId); - if (bpmnModel) { - formType.value = bpmnModel.formType; - if (formType.value === BpmModelFormType.NORMAL && bpmnModel.formId) { - const bpmnForm = (await getFormDetail( - bpmnModel.formId, - )) as unknown as BpmFormApi.FormVO; - formFields.value = bpmnForm?.fields; - } - } - } // 获得角色列表 roleOptions.value = await getSimpleRoleList(); // 获得岗位列表 diff --git a/apps/web-antd/src/components/simple-process-design/components/simple-process-model.vue b/apps/web-antd/src/components/simple-process-design/components/simple-process-model.vue index 2495a68f..cfd2e6a8 100644 --- a/apps/web-antd/src/components/simple-process-design/components/simple-process-model.vue +++ b/apps/web-antd/src/components/simple-process-design/components/simple-process-model.vue @@ -198,8 +198,8 @@ onMounted(() => { }); - + diff --git a/apps/web-antd/src/components/simple-process-design/styles/simple-process-designer.scss b/apps/web-antd/src/components/simple-process-design/styles/simple-process-designer.scss index 817e7a76..dbda6573 100644 --- a/apps/web-antd/src/components/simple-process-design/styles/simple-process-designer.scss +++ b/apps/web-antd/src/components/simple-process-design/styles/simple-process-designer.scss @@ -209,8 +209,8 @@ .simple-process-model-container { width: 100%; height: 100%; + padding-top: 32px; overflow-x: auto; - background: url('./svg/simple-process-bg.svg') 0 0 repeat; background-color: #fafafa; .simple-process-model { @@ -219,6 +219,7 @@ align-items: center; justify-content: center; min-width: fit-content; + background: url('./svg/simple-process-bg.svg') 0 0 repeat; transform: scale(1); transform-origin: 50% 0 0; transition: transform 0.3s cubic-bezier(0.645, 0.045, 0.355, 1); diff --git a/apps/web-antd/src/views/bpm/model/form/modules/process-design.vue b/apps/web-antd/src/views/bpm/model/form/modules/process-design.vue index 10f99f8d..f9fb0754 100644 --- a/apps/web-antd/src/views/bpm/model/form/modules/process-design.vue +++ b/apps/web-antd/src/views/bpm/model/form/modules/process-design.vue @@ -55,9 +55,9 @@ defineExpose({