From 6e6754e44ad407b6f6b3ceba9b29c0dab83cbd5c Mon Sep 17 00:00:00 2001 From: GoldenZqqq <1361001127@qq.com> Date: Mon, 16 Dec 2024 17:23:27 +0800 Subject: [PATCH 1/7] =?UTF-8?q?feat:=20=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=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2-=E4=BC=98=E5=8C=96=E8=B7=AF=E7=94=B1=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E3=80=81=E6=96=B0=E5=A2=9E=E4=BF=AE=E6=94=B9=E5=88=86?= =?UTF-8?q?=E4=B8=BA=E4=B8=A4=E4=B8=AA=E5=B9=B6=E5=85=A8=E9=83=A8=E4=BD=BF?= =?UTF-8?q?=E7=94=A8name=E8=BF=9B=E8=A1=8C=E8=B7=B3=E8=BD=AC=EF=BC=8C?= =?UTF-8?q?=E6=AF=8F=E4=B8=AA=E6=AD=A5=E9=AA=A4=E6=8B=86=E5=88=86=E5=87=BA?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E5=AD=90=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/modules/remaining.ts | 20 +- .../bpm/model/CategoryDraggableModel.vue | 14 +- src/views/bpm/model/form/BasicInfo.vue | 305 ++++++++++++++++++ src/views/bpm/model/form/FormDesign.vue | 111 +++++++ src/views/bpm/model/form/ProcessDesign.vue | 74 +++++ src/views/bpm/model/form/index.vue | 251 ++++++++++++++ src/views/bpm/model/index.vue | 7 +- 7 files changed, 771 insertions(+), 11 deletions(-) create mode 100644 src/views/bpm/model/form/BasicInfo.vue create mode 100644 src/views/bpm/model/form/FormDesign.vue create mode 100644 src/views/bpm/model/form/ProcessDesign.vue create mode 100644 src/views/bpm/model/form/index.vue diff --git a/src/router/modules/remaining.ts b/src/router/modules/remaining.ts index 3537a59c..806f954d 100644 --- a/src/router/modules/remaining.ts +++ b/src/router/modules/remaining.ts @@ -332,14 +332,26 @@ const remainingRouter: AppRouteRecordRaw[] = [ } }, { - path: 'manager/model/create-update', // TODO @goldenzqqq:是不是拆分成两个,一个 create 创建流程;一个 update 修改流程? - component: () => import('@/views/bpm/model/CreateUpdate.vue'), // TODO @goldenzqqq:是不是放到 '@/views/bpm/model/form/index.vue'。然后,原本的 editor/index.vue 是不是可以清理了呀? - name: 'BpmModelCreateUpdate', + path: 'manager/model/create', + component: () => import('@/views/bpm/model/form/index.vue'), + name: 'BpmModelCreate', meta: { noCache: true, hidden: true, canTo: true, - title: '创建/修改流程', + title: '创建流程', + activeMenu: '/bpm/manager/model' + } + }, + { + path: 'manager/model/update/:id', + component: () => import('@/views/bpm/model/form/index.vue'), + name: 'BpmModelUpdate', + 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 8009e693..37045568 100644 --- a/src/views/bpm/model/CategoryDraggableModel.vue +++ b/src/views/bpm/model/CategoryDraggableModel.vue @@ -339,8 +339,10 @@ const handleChangeState = async (row: any) => { /** 设计流程 */ const handleDesign = (row: any) => { - // TODO @goldenzqqq:最好使用 name 哈 - push(`/bpm/manager/model/create-update?id=${row.id}`) + push({ + name: 'BpmModelUpdate', + params: { id: row.id } + }) } /** 发布流程 */ @@ -483,11 +485,13 @@ const handleDeleteCategory = async () => { /** 添加流程模型弹窗 */ const modelFormRef = ref() const openModelForm = (type: string, id?: number) => { - // TODO @goldenzqqq:最好使用 name 哈 if (type === 'create') { - push('/bpm/manager/model/create-update') + push({ name: 'BpmModelCreate' }) } else { - push(`/bpm/manager/model/create-update?id=${id}`) + push({ + name: 'BpmModelUpdate', + params: { id } + }) } } diff --git a/src/views/bpm/model/form/BasicInfo.vue b/src/views/bpm/model/form/BasicInfo.vue new file mode 100644 index 00000000..088a8cac --- /dev/null +++ b/src/views/bpm/model/form/BasicInfo.vue @@ -0,0 +1,305 @@ + + + + + diff --git a/src/views/bpm/model/form/FormDesign.vue b/src/views/bpm/model/form/FormDesign.vue new file mode 100644 index 00000000..c0c06189 --- /dev/null +++ b/src/views/bpm/model/form/FormDesign.vue @@ -0,0 +1,111 @@ + + + \ No newline at end of file diff --git a/src/views/bpm/model/form/ProcessDesign.vue b/src/views/bpm/model/form/ProcessDesign.vue new file mode 100644 index 00000000..934de5a8 --- /dev/null +++ b/src/views/bpm/model/form/ProcessDesign.vue @@ -0,0 +1,74 @@ + + + diff --git a/src/views/bpm/model/form/index.vue b/src/views/bpm/model/form/index.vue new file mode 100644 index 00000000..1b9e4f50 --- /dev/null +++ b/src/views/bpm/model/form/index.vue @@ -0,0 +1,251 @@ + + + + + diff --git a/src/views/bpm/model/index.vue b/src/views/bpm/model/index.vue index d779a9f2..c7d94170 100644 --- a/src/views/bpm/model/index.vue +++ b/src/views/bpm/model/index.vue @@ -126,9 +126,12 @@ const handleQuery = () => { const formRef = ref() const openForm = (type: string, id?: number) => { if (type === 'create') { - push('/bpm/manager/model/create-update') + push({ name: 'BpmModelCreate' }) } else { - push(`/bpm/manager/model/create-update?id=${id}`) + push({ + name: 'BpmModelUpdate', + params: { id } + }) } } From a6461da0f867e126f2108fac48376ef77b66ce79 Mon Sep 17 00:00:00 2001 From: GoldenZqqq <1361001127@qq.com> Date: Tue, 17 Dec 2024 09:19:04 +0800 Subject: [PATCH 2/7] =?UTF-8?q?feat:=20=E6=B5=81=E7=A8=8B=E6=96=B0?= =?UTF-8?q?=E5=A2=9E/=E4=BF=AE=E6=94=B9=E9=A1=B5=E9=9D=A2=E4=B8=AD-?= =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E6=AD=A5=E9=AA=A4=E4=B8=AD=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E9=A2=84=E8=A7=88=E5=8A=9F=E8=83=BD=E5=A2=9E=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/bpm/model/form/BasicInfo.vue | 1 - src/views/bpm/model/form/FormDesign.vue | 76 +++++++++++++++++-------- src/views/bpm/model/form/index.vue | 69 ++++++++++++++-------- 3 files changed, 96 insertions(+), 50 deletions(-) diff --git a/src/views/bpm/model/form/BasicInfo.vue b/src/views/bpm/model/form/BasicInfo.vue index 088a8cac..b063921d 100644 --- a/src/views/bpm/model/form/BasicInfo.vue +++ b/src/views/bpm/model/form/BasicInfo.vue @@ -144,7 +144,6 @@ \ No newline at end of file + diff --git a/src/views/bpm/model/form/index.vue b/src/views/bpm/model/form/index.vue index 1b9e4f50..f0178447 100644 --- a/src/views/bpm/model/form/index.vue +++ b/src/views/bpm/model/form/index.vue @@ -1,8 +1,10 @@ @@ -17,6 +18,7 @@ :model-id="modelData.id" :model-key="modelData.key" :model-name="modelData.name" + :value="modelData.bpmnXml" @success="handleDesignSuccess" /> @@ -44,6 +46,13 @@ const modelData = computed({ set: (val) => emit('update:modelValue', val) }) +// 监听modelValue变化,确保XML数据同步 +watch(() => props.modelValue, (newVal) => { + if (newVal.bpmnXml) { + xmlString.value = newVal.bpmnXml + } +}, { immediate: true, deep: true }) + /** 处理设计器保存成功 */ const handleDesignSuccess = (bpmnXml?: string) => { if (bpmnXml) { @@ -52,8 +61,8 @@ const handleDesignSuccess = (bpmnXml?: string) => { ...modelData.value, bpmnXml }) + emit('success', bpmnXml) } - emit('success', bpmnXml) } /** 表单校验 */ @@ -61,14 +70,16 @@ const validate = async () => { if (!xmlString.value) { throw new Error('请设计流程') } + return true } /** 是否显示设计器 */ const showDesigner = computed(() => { - return Boolean(modelData.value.id || (modelData.value.key && modelData.value.name)) + return Boolean(modelData.value.key && modelData.value.name) }) defineExpose({ - validate + validate, + getXmlString: () => xmlString.value }) diff --git a/src/views/bpm/model/form/index.vue b/src/views/bpm/model/form/index.vue index 7c152a6b..3f105d67 100644 --- a/src/views/bpm/model/form/index.vue +++ b/src/views/bpm/model/form/index.vue @@ -173,6 +173,19 @@ const initData = async () => { /** 保存操作 */ const handleSave = async () => { try { + // 保存前确保当前步骤的数据已经验证通过 + if (typeof steps[currentStep.value].validator === 'function') { + await steps[currentStep.value].validator() + } + + // 如果是第三步,需要先获取最新的流程设计数据 + if (currentStep.value === 2) { + const bpmnXml = processDesignRef.value?.getXmlString() + if (bpmnXml) { + formData.value.bpmnXml = bpmnXml + } + } + if (formData.value.id) { await ModelApi.updateModel(formData.value) message.success('修改成功') @@ -183,6 +196,7 @@ const handleSave = async () => { } } catch (error) { console.error('保存失败:', error) + message.error(error.message || '保存失败') } } @@ -196,6 +210,13 @@ const handleDeploy = async () => { await step.validator() } } + // 如果是第三步,需要先获取最新的流程设计数据 + if (currentStep.value === 2) { + const bpmnXml = processDesignRef.value?.getXmlString() + if (bpmnXml) { + formData.value.bpmnXml = bpmnXml + } + } await handleSave() await ModelApi.deployModel(formData.value.id) message.success('发布成功') @@ -250,8 +271,6 @@ const handleDesignSuccess = (bpmnXml?: string) => { if (bpmnXml) { formData.value.bpmnXml = bpmnXml } - handleSave() // 自动保存 - message.success('保存成功') } /** 初始化 */ From f86bd0df0b4375665d568ce2107d99582997880f Mon Sep 17 00:00:00 2001 From: GoldenZqqq <1361001127@qq.com> Date: Wed, 25 Dec 2024 09:52:19 +0800 Subject: [PATCH 5/7] =?UTF-8?q?fix:=20=E7=AC=AC=E4=B8=80=E6=AD=A5=E9=AA=A4?= =?UTF-8?q?=E4=B8=ADtooltip=20icon=E6=9C=AA=E5=B1=95=E7=A4=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BF=AE=E5=A4=8D=E4=B8=8E=E6=A0=B7=E5=BC=8F=E7=BB=86?= =?UTF-8?q?=E8=8A=82=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/bpm/model/form/BasicInfo.vue | 31 ++++++++++++++------------ src/views/bpm/model/form/index.vue | 8 ++----- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/views/bpm/model/form/BasicInfo.vue b/src/views/bpm/model/form/BasicInfo.vue index b063921d..532ec786 100644 --- a/src/views/bpm/model/form/BasicInfo.vue +++ b/src/views/bpm/model/form/BasicInfo.vue @@ -7,19 +7,22 @@ class="mt-20px w-600px" > - - - - - - - +
+ + + + +
-
- +
+
From a82862be475daa6ea8fa7822dc7c4f5d48873ad5 Mon Sep 17 00:00:00 2001 From: GoldenZqqq <1361001127@qq.com> Date: Wed, 25 Dec 2024 14:10:16 +0800 Subject: [PATCH 6/7] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=BA=86=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E4=BF=9D=E5=AD=98=E4=B8=8D=E7=94=9F=E6=95=88?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/bpm/model/form/ProcessDesign.vue | 31 ++++++++++++++++------ src/views/bpm/model/form/index.vue | 4 +-- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/views/bpm/model/form/ProcessDesign.vue b/src/views/bpm/model/form/ProcessDesign.vue index 4cbd40c2..7ee58092 100644 --- a/src/views/bpm/model/form/ProcessDesign.vue +++ b/src/views/bpm/model/form/ProcessDesign.vue @@ -47,11 +47,15 @@ const modelData = computed({ }) // 监听modelValue变化,确保XML数据同步 -watch(() => props.modelValue, (newVal) => { - if (newVal.bpmnXml) { - xmlString.value = newVal.bpmnXml - } -}, { immediate: true, deep: true }) +watch( + () => props.modelValue, + (newVal) => { + if (newVal.bpmnXml) { + xmlString.value = newVal.bpmnXml + } + }, + { immediate: true, deep: true } +) /** 处理设计器保存成功 */ const handleDesignSuccess = (bpmnXml?: string) => { @@ -67,6 +71,11 @@ const handleDesignSuccess = (bpmnXml?: string) => { /** 表单校验 */ const validate = async () => { + // 修改场景下,如果已有 modelData.bpmnXml 则不需要重新校验 + if (modelData.value.id && modelData.value.bpmnXml) { + return true + } + // 新增场景或无 bpmnXml 时才校验 if (!xmlString.value) { throw new Error('请设计流程') } @@ -75,11 +84,17 @@ const validate = async () => { /** 是否显示设计器 */ const showDesigner = computed(() => { - return Boolean(modelData.value.key && modelData.value.name) + return Boolean(modelData.value?.key && modelData.value?.name) }) +/** 获取当前XML字符串 */ +const getXmlString = () => { + // 优先返回最新的 xmlString + return xmlString.value || modelData.value?.bpmnXml +} + defineExpose({ validate, - getXmlString: () => xmlString.value + getXmlString }) - + diff --git a/src/views/bpm/model/form/index.vue b/src/views/bpm/model/form/index.vue index 59279842..47016ac3 100644 --- a/src/views/bpm/model/form/index.vue +++ b/src/views/bpm/model/form/index.vue @@ -52,7 +52,7 @@
-
+
-
+
From 36157a8f24502d84e31696a5a258da33580a3bba Mon Sep 17 00:00:00 2001 From: GoldenZqqq <1361001127@qq.com> Date: Wed, 25 Dec 2024 14:33:21 +0800 Subject: [PATCH 7/7] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E6=97=B6=E6=97=A0=E6=B3=95=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E7=AC=AC=E4=B8=89=E6=AD=A5=E7=9A=84bpm=E5=BF=85=E5=A1=AB?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/bpm/model/form/ProcessDesign.vue | 22 ++++++----- src/views/bpm/model/form/index.vue | 46 +++++++++++----------- 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/src/views/bpm/model/form/ProcessDesign.vue b/src/views/bpm/model/form/ProcessDesign.vue index 7ee58092..2e8f94c9 100644 --- a/src/views/bpm/model/form/ProcessDesign.vue +++ b/src/views/bpm/model/form/ProcessDesign.vue @@ -50,7 +50,7 @@ const modelData = computed({ watch( () => props.modelValue, (newVal) => { - if (newVal.bpmnXml) { + if (newVal?.bpmnXml) { xmlString.value = newVal.bpmnXml } }, @@ -61,24 +61,29 @@ watch( const handleDesignSuccess = (bpmnXml?: string) => { if (bpmnXml) { xmlString.value = bpmnXml - emit('update:modelValue', { + modelData.value = { ...modelData.value, bpmnXml - }) + } emit('success', bpmnXml) } } /** 表单校验 */ const validate = async () => { - // 修改场景下,如果已有 modelData.bpmnXml 则不需要重新校验 - if (modelData.value.id && modelData.value.bpmnXml) { + // 获取最新的XML数据 + const currentXml = xmlString.value || modelData.value?.bpmnXml + + // 如果是修改场景且有XML数据(无论是新的还是原有的) + if (modelData.value.id && currentXml) { return true } - // 新增场景或无 bpmnXml 时才校验 - if (!xmlString.value) { + + // 新增场景必须有XML数据 + if (!currentXml) { throw new Error('请设计流程') } + return true } @@ -89,8 +94,7 @@ const showDesigner = computed(() => { /** 获取当前XML字符串 */ const getXmlString = () => { - // 优先返回最新的 xmlString - return xmlString.value || modelData.value?.bpmnXml + return xmlString.value || modelData.value?.bpmnXml || '' } defineExpose({ diff --git a/src/views/bpm/model/form/index.vue b/src/views/bpm/model/form/index.vue index 47016ac3..f6c2ef2a 100644 --- a/src/views/bpm/model/form/index.vue +++ b/src/views/bpm/model/form/index.vue @@ -169,19 +169,24 @@ const initData = async () => { /** 保存操作 */ const handleSave = async () => { try { - // 保存前确保当前步骤的数据已经验证通过 - if (typeof steps[currentStep.value].validator === 'function') { - await steps[currentStep.value].validator() - } - - // 如果是第三步,需要先获取最新的流程设计数据 - if (currentStep.value === 2) { - const bpmnXml = processDesignRef.value?.getXmlString() - if (bpmnXml) { - formData.value.bpmnXml = bpmnXml + // 保存前确保所有步骤的数据都已经验证通过 + for (const step of steps) { + if (step.validator) { + await step.validator() } } - + + // 如果是在第三步,需要先获取最新的流程设计数据 + if (currentStep.value === 2) { + await nextTick() + const bpmnXml = processDesignRef.value?.getXmlString() + // 确保有XML数据 + if (!bpmnXml) { + throw new Error('请设计流程') + } + formData.value.bpmnXml = bpmnXml + } + if (formData.value.id) { await ModelApi.updateModel(formData.value) message.success('修改成功') @@ -193,6 +198,7 @@ const handleSave = async () => { } catch (error) { console.error('保存失败:', error) message.error(error.message || '保存失败') + throw error } } @@ -200,24 +206,14 @@ const handleSave = async () => { const handleDeploy = async () => { try { await message.confirm('是否确认发布该流程?') - // 发布时才进行全部校验 - for (const step of steps) { - if (step.validator) { - await step.validator() - } - } - // 如果是第三步,需要先获取最新的流程设计数据 - if (currentStep.value === 2) { - const bpmnXml = processDesignRef.value?.getXmlString() - if (bpmnXml) { - formData.value.bpmnXml = bpmnXml - } - } + // 先保存所有数据 await handleSave() + // 发布 await ModelApi.deployModel(formData.value.id) message.success('发布成功') router.push({ name: 'BpmModel' }) } catch (error) { + console.error('发布失败:', error) if (error instanceof Error) { // 校验失败时,跳转到对应步骤 const failedStep = steps.findIndex((step) => { @@ -231,6 +227,8 @@ const handleDeploy = async () => { if (failedStep !== -1) { currentStep.value = failedStep message.warning('请完善必填信息') + } else { + message.error(error.message || '发布失败') } } }