From 58e6fdef78e4e8a8cb3bd7090ef900e9032cf714 Mon Sep 17 00:00:00 2001
From: gssong <1742057357@qq.com>
Date: 星期五, 31 五月 2024 22:11:25 +0800
Subject: [PATCH] update 优化流程实例接口全部按照业务id操作

---
 src/components/BpmnView/index.vue            |    4 +-
 src/views/workflow/processInstance/index.vue |   13 ++++--
 src/views/workflow/leave/index.vue           |    2 
 src/views/workflow/leave/leaveEdit.vue       |    2 
 src/api/workflow/processInstance/index.ts    |   36 +++++++++---------
 src/components/Process/approvalRecord.vue    |    6 +-
 6 files changed, 33 insertions(+), 30 deletions(-)

diff --git a/src/api/workflow/processInstance/index.ts b/src/api/workflow/processInstance/index.ts
index 80f122f..b949b51 100644
--- a/src/api/workflow/processInstance/index.ts
+++ b/src/api/workflow/processInstance/index.ts
@@ -29,33 +29,33 @@
 };
 
 /**
- * 閫氳繃娴佺▼瀹炰緥id鑾峰彇鍘嗗彶娴佺▼鍥�
+ * 閫氳繃涓氬姟id鑾峰彇鍘嗗彶娴佺▼鍥�
  */
-export const getHistoryImage = (processInstanceId: string) => {
+export const getHistoryImage = (businessKey: string) => {
   return request({
-    url: `/workflow/processInstance/getHistoryImage/${processInstanceId}` + '?t' + Math.random(),
+    url: `/workflow/processInstance/getHistoryImage/${businessKey}` + '?t' + Math.random(),
     method: 'get'
   });
 };
 
 /**
- * 閫氳繃娴佺▼瀹炰緥id鑾峰彇鍘嗗彶娴佺▼鍥捐繍琛屼腑锛屽巻鍙茬瓑鑺傜偣
+ * 閫氳繃涓氬姟id鑾峰彇鍘嗗彶娴佺▼鍥捐繍琛屼腑锛屽巻鍙茬瓑鑺傜偣
  */
-export const getHistoryList = (instanceId: string): AxiosPromise<Record<string, any>> => {
+export const getHistoryList = (businessKey: string): AxiosPromise<Record<string, any>> => {
   return request({
-    url: `/workflow/processInstance/getHistoryList/${instanceId}` + '?t' + Math.random(),
+    url: `/workflow/processInstance/getHistoryList/${businessKey}` + '?t' + Math.random(),
     method: 'get'
   });
 };
 
 /**
  * 鑾峰彇瀹℃壒璁板綍
- * @param processInstanceId 娴佺▼瀹炰緥id
+ * @param businessKey 涓氬姟id
  * @returns
  */
-export const getHistoryRecord = (processInstanceId: string) => {
+export const getHistoryRecord = (businessKey: string) => {
   return request({
-    url: `/workflow/processInstance/getHistoryRecord/${processInstanceId}`,
+    url: `/workflow/processInstance/getHistoryRecord/${businessKey}`,
     method: 'get'
   });
 };
@@ -75,24 +75,24 @@
 
 /**
  * 杩愯涓殑瀹炰緥 鍒犻櫎绋嬪疄渚嬶紝鍒犻櫎鍘嗗彶璁板綍锛屽垹闄や笟鍔′笌娴佺▼鍏宠仈淇℃伅
- * @param processInstanceId 娴佺▼瀹炰緥id
+ * @param businessKey 涓氬姟id
  * @returns
  */
-export const deleteRunAndHisInstance = (processInstanceId: string | string[]) => {
+export const deleteRunAndHisInstance = (businessKey: string | string[]) => {
   return request({
-    url: `/workflow/processInstance/deleteRunAndHisInstance/${processInstanceId}`,
+    url: `/workflow/processInstance/deleteRunAndHisInstance/${businessKey}`,
     method: 'delete'
   });
 };
 
 /**
  * 宸插畬鎴愮殑瀹炰緥 鍒犻櫎绋嬪疄渚嬶紝鍒犻櫎鍘嗗彶璁板綍锛屽垹闄や笟鍔′笌娴佺▼鍏宠仈淇℃伅
- * @param processInstanceId 娴佺▼瀹炰緥id
+ * @param businessKey 涓氬姟id
  * @returns
  */
-export const deleteFinishAndHisInstance = (processInstanceId: string | string[]) => {
+export const deleteFinishAndHisInstance = (businessKey: string | string[]) => {
   return request({
-    url: `/workflow/processInstance/deleteFinishAndHisInstance/${processInstanceId}`,
+    url: `/workflow/processInstance/deleteFinishAndHisInstance/${businessKey}`,
     method: 'delete'
   });
 };
@@ -112,12 +112,12 @@
 
 /**
  * 鎾ら攢娴佺▼
- * @param processInstanceId 娴佺▼瀹炰緥id
+ * @param businessKey 涓氬姟id
  * @returns
  */
-export const cancelProcessApply = (processInstanceId: string) => {
+export const cancelProcessApply = (businessKey: string) => {
   return request({
-    url: `/workflow/processInstance/cancelProcessApply/${processInstanceId}`,
+    url: `/workflow/processInstance/cancelProcessApply/${businessKey}`,
     method: 'post'
   });
 };
diff --git a/src/components/BpmnView/index.vue b/src/components/BpmnView/index.vue
index f07bc21..3d04246 100644
--- a/src/components/BpmnView/index.vue
+++ b/src/components/BpmnView/index.vue
@@ -51,7 +51,7 @@
 const bpmnVisible = ref(true);
 const historyList = ref([]);
 
-const init = (instanceId) => {
+const init = (businessKey) => {
   loading.value = true;
   bpmnVisible.value = true;
   nextTick(async () => {
@@ -67,7 +67,7 @@
         MoveCanvasModule
       ] as ModuleDeclaration[]
     });
-    const resp = await processApi.getHistoryList(instanceId);
+    const resp = await processApi.getHistoryList(businessKey);
     xml.value = resp.data.xml;
     taskList.value = resp.data.taskList;
     historyList.value = resp.data.historyList;
diff --git a/src/components/Process/approvalRecord.vue b/src/components/Process/approvalRecord.vue
index cbce87a..37667ca 100644
--- a/src/components/Process/approvalRecord.vue
+++ b/src/components/Process/approvalRecord.vue
@@ -67,17 +67,17 @@
 const bpmnViewRef = ref<BpmnView>();
 
 //鍒濆鍖栨煡璇㈠鎵硅褰�
-const init = async (instanceId: string) => {
+const init = async (businessKey: string) => {
   visible.value = true;
   loading.value = true;
   tabActiveName.value = 'bpmn';
   historyList.value = [];
-  processApi.getHistoryRecord(instanceId).then((resp) => {
+  processApi.getHistoryRecord(businessKey).then((resp) => {
     historyList.value = resp.data;
     loading.value = false;
   });
   await nextTick(() => {
-    bpmnViewRef.value.init(instanceId);
+    bpmnViewRef.value.init(businessKey);
   });
 };
 
diff --git a/src/views/workflow/leave/index.vue b/src/views/workflow/leave/index.vue
index 23d5442..e47768d 100644
--- a/src/views/workflow/leave/index.vue
+++ b/src/views/workflow/leave/index.vue
@@ -93,7 +93,7 @@
               size="small"
               type="primary"
               icon="Notification"
-              @click="handleCancelProcessApply(scope.row.processInstanceVo.id)"
+              @click="handleCancelProcessApply(scope.row.id)"
               >鎾ら攢</el-button
             >
           </template>
diff --git a/src/views/workflow/leave/leaveEdit.vue b/src/views/workflow/leave/leaveEdit.vue
index e978ad8..b8742f7 100644
--- a/src/views/workflow/leave/leaveEdit.vue
+++ b/src/views/workflow/leave/leaveEdit.vue
@@ -243,7 +243,7 @@
 };
 //瀹℃壒璁板綍
 const handleApprovalRecord = () => {
-  approvalRecordRef.value.init(processInstanceId.value);
+  approvalRecordRef.value.init(form.value.id);
 };
 //鎻愪氦鍥炶皟
 const submitCallback = async () => {
diff --git a/src/views/workflow/processInstance/index.vue b/src/views/workflow/processInstance/index.vue
index 4f994af..7c60880 100644
--- a/src/views/workflow/processInstance/index.vue
+++ b/src/views/workflow/processInstance/index.vue
@@ -167,6 +167,8 @@
 const loading = ref(true);
 // 閫変腑鏁扮粍
 const ids = ref<Array<any>>([]);
+// 閫変腑涓氬姟id鏁扮粍
+const businessKeys = ref<Array<any>>([]);
 // 闈炲崟涓鐢�
 const single = ref(true);
 // 闈炲涓鐢�
@@ -257,6 +259,7 @@
 // 澶氶�夋閫変腑鏁版嵁
 const handleSelectionChange = (selection: ProcessInstanceVO[]) => {
   ids.value = selection.map((item: any) => item.id);
+  businessKeys.value = selection.map((item: any) => item.businessKey);
   single.value = selection.length !== 1;
   multiple.value = !selection.length;
 };
@@ -281,14 +284,14 @@
 
 /** 鍒犻櫎鎸夐挳鎿嶄綔 */
 const handleDelete = async (row: any) => {
-  const id = row.id || ids.value;
-  await proxy?.$modal.confirm('鏄惁纭鍒犻櫎id涓恒��' + id + '銆戠殑鏁版嵁椤癸紵');
+  const businessKey = row.businessKey || businessKeys.value;
+  await proxy?.$modal.confirm('鏄惁纭鍒犻櫎涓氬姟id涓恒��' + businessKey + '銆戠殑鏁版嵁椤癸紵');
   loading.value = true;
   if ('running' === tab.value) {
-    await deleteRunAndHisInstance(id).finally(() => (loading.value = false));
+    await deleteRunAndHisInstance(businessKey).finally(() => (loading.value = false));
     getProcessInstanceRunningList();
   } else {
-    await deleteFinishAndHisInstance(id).finally(() => (loading.value = false));
+    await deleteFinishAndHisInstance(businessKey).finally(() => (loading.value = false));
     getProcessInstanceFinishList();
   }
   proxy?.$modal.msgSuccess('鍒犻櫎鎴愬姛');
@@ -308,7 +311,7 @@
   loading.value = true;
   if ('running' === tab.value) {
     let param = {
-      processInstanceId: row.id,
+      businessKey: row.businessKey,
       deleteReason: deleteReason.value
     };
     await deleteRunInstance(param).finally(() => (loading.value = false));

--
Gitblit v1.9.3