diff --git a/apps/web-antd/src/api/bpm/model/index.ts b/apps/web-antd/src/api/bpm/model/index.ts index 90a815be5..9cce9be8e 100644 --- a/apps/web-antd/src/api/bpm/model/index.ts +++ b/apps/web-antd/src/api/bpm/model/index.ts @@ -107,6 +107,11 @@ export async function importModel(file: File, key?: string, name?: string) { }); } +/** 导出流程模型 */ +export async function exportModel(id: number) { + return requestClient.get(`/bpm/model/export?id=${id}`); +} + /** 删除流程模型 */ export async function deleteModel(id: number) { return requestClient.delete(`/bpm/model/delete?id=${id}`); diff --git a/apps/web-antd/src/views/bpm/model/modules/category-draggable-model.vue b/apps/web-antd/src/views/bpm/model/modules/category-draggable-model.vue index b93cf3458..8f0926d26 100644 --- a/apps/web-antd/src/views/bpm/model/modules/category-draggable-model.vue +++ b/apps/web-antd/src/views/bpm/model/modules/category-draggable-model.vue @@ -31,6 +31,7 @@ import { cleanModel, deleteModel, deployModel, + exportModel, updateModelSortBatch, updateModelState, } from '#/api/bpm/model'; @@ -315,6 +316,10 @@ function handleModelCommand(command: string, row: any) { handleDelete(row); break; } + case 'handleExport': { + handleExportModel(row); + break; + } case 'handleReport': { handleReport(row); break; @@ -325,6 +330,26 @@ function handleModelCommand(command: string, row: any) { } } +/** 导出模型 */ +async function handleExportModel(row: any) { + const hideLoading = message.loading({ content: '正在导出...', duration: 0 }); + try { + const data = await exportModel(row.id); + const blob = new Blob([JSON.stringify(data, null, 2)], { + type: 'application/json', + }); + const url = URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = url; + a.download = `${row.key || row.name || 'model'}.json`; + a.click(); + URL.revokeObjectURL(url); + message.success('导出成功'); + } finally { + hideLoading(); + } +} + /** 更新状态操作 */ async function handleChangeState(row: any) { const state = row.processDefinition.suspensionState; @@ -691,6 +716,7 @@ function handleRenameSuccess() { @click="(e) => handleModelCommand(e.key as string, row)" > 复制 + 导出 历史