From 5063db47f35dc53417cf149b40ac29f5041f4370 Mon Sep 17 00:00:00 2001 From: GoldenZqqq <1361001127@qq.com> Date: Tue, 3 Dec 2024 11:13:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B0=86=E6=B5=81=E7=A8=8B=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E6=96=B0=E5=A2=9E/=E4=BF=AE=E6=94=B9/=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E6=95=B4=E5=90=88=E5=88=B0=E5=90=8C=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E4=B8=AD=EF=BC=8C=E5=88=86=E4=B8=89=E4=B8=AA?= =?UTF-8?q?=E6=AD=A5=E9=AA=A4=E8=BF=9B=E8=A1=8C=EF=BC=9B=E8=B7=B3=E8=BD=AC?= =?UTF-8?q?=E4=BC=A0=E5=8F=82=E9=80=BB=E8=BE=91=E4=B8=8E=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E7=BB=98=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/modules/remaining.ts | 12 + .../bpm/model/CategoryDraggableModel.vue | 37 +- src/views/bpm/model/CreateUpdate.vue | 582 ++++++++++++++++++ src/views/bpm/model/editor/index.vue | 36 +- src/views/bpm/model/index.vue | 7 +- src/views/bpm/simple/SimpleModelDesign.vue | 17 +- 6 files changed, 648 insertions(+), 43 deletions(-) create mode 100644 src/views/bpm/model/CreateUpdate.vue diff --git a/src/router/modules/remaining.ts b/src/router/modules/remaining.ts index f0ce322e..22a0c3e5 100644 --- a/src/router/modules/remaining.ts +++ b/src/router/modules/remaining.ts @@ -330,6 +330,18 @@ const remainingRouter: AppRouteRecordRaw[] = [ title: '查看 OA 请假', activeMenu: '/bpm/oa/leave' } + }, + { + path: 'manager/model/create-update', + component: () => import('@/views/bpm/model/CreateUpdate.vue'), + name: 'BpmModelCreateUpdate', + meta: { + noCache: true, + hidden: true, + canTo: true, + title: '创建/修改流程', + activeMenu: '/bpm/manager/model' + } } ] }, diff --git a/src/views/bpm/model/CategoryDraggableModel.vue b/src/views/bpm/model/CategoryDraggableModel.vue index 35465935..f01c7d18 100644 --- a/src/views/bpm/model/CategoryDraggableModel.vue +++ b/src/views/bpm/model/CategoryDraggableModel.vue @@ -339,21 +339,22 @@ const handleChangeState = async (row: any) => { /** 设计流程 */ const handleDesign = (row: any) => { - if (row.type == BpmModelType.BPMN) { - push({ - name: 'BpmModelEditor', - query: { - modelId: row.id - } - }) - } else { - push({ - name: 'SimpleModelDesign', - query: { - modelId: row.id - } - }) - } + // if (row.type == BpmModelType.BPMN) { + // push({ + // name: 'BpmModelEditor', + // query: { + // modelId: row.id + // } + // }) + // } else { + // push({ + // name: 'SimpleModelDesign', + // query: { + // modelId: row.id + // } + // }) + // } + push(`/bpm/manager/model/create-update?id=${row.id}`) } /** 发布流程 */ @@ -496,7 +497,11 @@ const handleDeleteCategory = async () => { /** 添加流程模型弹窗 */ const modelFormRef = ref() const openModelForm = (type: string, id?: number) => { - modelFormRef.value.open(type, id) + if (type === 'create') { + push('/bpm/manager/model/create-update') + } else { + push(`/bpm/manager/model/create-update?id=${id}`) + } } watch(() => props.categoryInfo.modelList, updateModeList, { immediate: true }) diff --git a/src/views/bpm/model/CreateUpdate.vue b/src/views/bpm/model/CreateUpdate.vue new file mode 100644 index 00000000..c412d9d0 --- /dev/null +++ b/src/views/bpm/model/CreateUpdate.vue @@ -0,0 +1,582 @@ + + + + + diff --git a/src/views/bpm/model/editor/index.vue b/src/views/bpm/model/editor/index.vue index 3e773691..232f2bff 100644 --- a/src/views/bpm/model/editor/index.vue +++ b/src/views/bpm/model/editor/index.vue @@ -34,6 +34,10 @@ import * as ModelApi from '@/api/bpm/model' defineOptions({ name: 'BpmModelEditor' }) +const props = defineProps<{ + modelId: string +}>() +const emit = defineEmits(['success']) const router = useRouter() // 路由 const { query } = useRoute() // 路由的查询 const message = useMessage() // 国际化 @@ -59,36 +63,28 @@ const initModeler = (item) => { /** 添加/修改模型 */ const save = async (bpmnXml: string) => { - const data = { - ...model.value, - bpmnXml: bpmnXml // bpmnXml 只是初始化流程图,后续修改无法通过它获得 - } as unknown as ModelApi.ModelVO - // 提交 - if (data.id) { + try { + const data = { + ...model.value, + bpmnXml: bpmnXml + } as unknown as ModelApi.ModelVO + // 提交 await ModelApi.updateModelBpmn(data) - message.success('修改成功') - } else { - await ModelApi.updateModelBpmn(data) - message.success('新增成功') + emit('success') + } catch (error) { + console.error('保存失败:', error) + message.error('保存失败') } - // 跳转回去 - close() -} - -/** 关闭按钮 */ -const close = () => { - router.push({ path: '/bpm/manager/model' }) } /** 初始化 */ onMounted(async () => { - const modelId = query.modelId as unknown as number - if (!modelId) { + if (!props.modelId) { message.error('缺少模型 modelId 编号') return } // 查询模型 - const data = await ModelApi.getModel(modelId) + const data = await ModelApi.getModel(String(props.modelId)) if (!data.bpmnXml) { // 首次创建的 Model 模型,它是没有 bpmnXml,此时需要给它一个默认的 data.bpmnXml = ` diff --git a/src/views/bpm/model/index.vue b/src/views/bpm/model/index.vue index bf43d292..d779a9f2 100644 --- a/src/views/bpm/model/index.vue +++ b/src/views/bpm/model/index.vue @@ -106,6 +106,7 @@ import CategoryDraggableModel from './CategoryDraggableModel.vue' defineOptions({ name: 'BpmModel' }) +const { push } = useRouter() const message = useMessage() // 消息弹窗 const loading = ref(true) // 列表的加载中 const isCategorySorting = ref(false) // 是否 category 正处于排序状态 @@ -124,7 +125,11 @@ const handleQuery = () => { /** 添加/修改操作 */ const formRef = ref() const openForm = (type: string, id?: number) => { - formRef.value.open(type, id) + if (type === 'create') { + push('/bpm/manager/model/create-update') + } else { + push(`/bpm/manager/model/create-update?id=${id}`) + } } /** 流程表单的详情按钮操作 */ diff --git a/src/views/bpm/simple/SimpleModelDesign.vue b/src/views/bpm/simple/SimpleModelDesign.vue index 1740e03f..5029ad0f 100644 --- a/src/views/bpm/simple/SimpleModelDesign.vue +++ b/src/views/bpm/simple/SimpleModelDesign.vue @@ -1,6 +1,6 @@