From b4b0eba2284d24a82732f01eab6bedb370cc4342 Mon Sep 17 00:00:00 2001
From: gssong <1742057357@qq.com>
Date: 星期六, 06 四月 2024 21:06:59 +0800
Subject: [PATCH] update 调整流程定义配置逻辑

---
 src/components/Process/submitVerify.vue |  228 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 208 insertions(+), 20 deletions(-)

diff --git a/src/components/Process/submitVerify.vue b/src/components/Process/submitVerify.vue
index da30ed7..d71b855 100644
--- a/src/components/Process/submitVerify.vue
+++ b/src/components/Process/submitVerify.vue
@@ -1,5 +1,5 @@
 <template>
-  <el-dialog v-model="dialog.visible" :title="dialog.title" width="50%" draggable :before-close="cancel" :close-on-click-modal="false">
+  <el-dialog v-model="dialog.visible" :title="dialog.title" width="50%" draggable :before-close="cancel" center :close-on-click-modal="false">
     <el-form v-loading="loading" :model="form" label-width="120px">
       <el-form-item label="娑堟伅鎻愰啋">
         <el-checkbox-group v-model="form.messageType">
@@ -8,7 +8,7 @@
           <el-checkbox label="3" name="type">鐭俊</el-checkbox>
         </el-checkbox-group>
       </el-form-item>
-      <el-form-item label="闄勪欢">
+      <el-form-item label="闄勪欢" v-if="task.businessStatus === 'waiting'">
         <fileUpload v-model="form.fileId" :fileType="['doc', 'xls', 'ppt', 'txt', 'pdf', 'xlsx', 'docx', 'zip']" :fileSize="'20'"/>
       </el-form-item>
       <el-form-item label="鎶勯��">
@@ -17,18 +17,63 @@
             {{ user.userName }}
           </el-tag>
       </el-form-item>
-      <el-form-item label="瀹℃壒鎰忚" v-if="businessStatus === 'waiting'">
+      <el-form-item label="瀹℃壒鎰忚" v-if="task.businessStatus === 'waiting'">
         <el-input v-model="form.message" type="textarea" resize="none" />
       </el-form-item>
     </el-form>
     <template #footer>
       <span class="dialog-footer">
-        <el-button v-loading="buttonLoading" @click="cancel">鍙栨秷</el-button>
         <el-button v-loading="buttonLoading" type="primary" @click="handleCompleteTask"> 鎻愪氦 </el-button>
-        <el-button v-if="businessStatus === 'waiting'" v-loading="buttonLoading" type="danger" @click="handleBackProcess"> 閫�鍥� </el-button>
+        <el-button v-if="task.businessStatus === 'waiting'" v-loading="buttonLoading" type="primary" @click="openDelegateTask"> 濮旀墭 </el-button>
+        <el-button v-if="task.businessStatus === 'waiting'" v-loading="buttonLoading" type="primary" @click="openTransferTask"> 杞姙 </el-button>
+        <el-button v-if="task.businessStatus === 'waiting' && task.multiInstance" v-loading="buttonLoading" type="primary" @click="addMultiInstanceUser"> 鍔犵 </el-button>
+        <el-button v-if="task.businessStatus === 'waiting' && task.multiInstance" v-loading="buttonLoading" type="primary" @click="deleteMultiInstanceUser"> 鍑忕 </el-button>
+        <el-button v-if="task.businessStatus === 'waiting'" v-loading="buttonLoading" type="danger" @click="handleTerminationTask"> 缁堟 </el-button>
+        <el-button v-if="task.businessStatus === 'waiting'" v-loading="buttonLoading" type="danger" @click="handleBackProcessOpen"> 閫�鍥� </el-button>
+        <el-button v-loading="buttonLoading" @click="cancel">鍙栨秷</el-button>
       </span>
     </template>
-    <UserSelect ref="userSelectCopyRef" :data="selectCopyUserIds" @confirm-call-back="userSelectCopyCallBack"></UserSelect>
+    <!-- 鎶勯�� -->
+    <UserSelect ref="userSelectCopyRef" :multiple="true" :data="selectCopyUserIds" @confirm-call-back="userSelectCopyCallBack"></UserSelect>
+    <!-- 杞姙 -->
+    <UserSelect ref="transferTaskRef" :multiple="false" @confirm-call-back="handleTransferTask"></UserSelect>
+    <!-- 濮旀墭 -->
+    <UserSelect ref="delegateTaskRef" :multiple="false" @confirm-call-back="handleDelegateTask"></UserSelect>
+    <!-- 鍔犵缁勪欢 -->
+    <multiInstanceUser ref="multiInstanceUserRef" :title="title" @submit-callback='closeDialog' />
+
+    <!-- 椹冲洖寮�濮� -->
+    <el-dialog v-model="backVisible" draggable title="椹冲洖" width="40%" :close-on-click-modal="false">
+      <el-form v-loading="backLoading" :model="backForm" label-width="120px" v-if="task.businessStatus === 'waiting'">
+        <el-form-item label="椹冲洖鑺傜偣">
+          <el-select clearable placeholder="璇烽�夋嫨" v-model="backForm.targetActivityId" style="width: 300px">
+            <el-option
+              v-for="item in taskNodeList"
+              :key="item.nodeId"
+              :label="item.nodeName"
+              :value="item.nodeId"
+            />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="娑堟伅鎻愰啋">
+          <el-checkbox-group v-model="backForm.messageType">
+            <el-checkbox label="1" name="type" disabled>绔欏唴淇�</el-checkbox>
+            <el-checkbox label="2" name="type">閭欢</el-checkbox>
+            <el-checkbox label="3" name="type">鐭俊</el-checkbox>
+          </el-checkbox-group>
+        </el-form-item>
+        <el-form-item label="瀹℃壒鎰忚">
+          <el-input v-model="backForm.message" type="textarea" resize="none" />
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <div class="dialog-footer" style="float: right;padding-bottom: 20px;">
+          <el-button type="primary" v-loading="backLoading" @click="handleBackProcess">纭</el-button>
+          <el-button v-loading="backLoading" @click="backVisible = false">鍙栨秷</el-button>
+        </div>
+      </template>
+    </el-dialog>
+    <!-- 椹冲洖缁撴潫 -->
   </el-dialog>
 </template>
 
@@ -36,11 +81,18 @@
 import { ref } from 'vue';
 import { ComponentInternalInstance } from 'vue';
 import { ElForm } from 'element-plus';
-import { completeTask, backProcess, getBusinessStatus } from '@/api/workflow/task';
+import { completeTask, backProcess, getTaskById,transferTask,terminationTask,getTaskNodeList,delegateTask } from '@/api/workflow/task';
 import UserSelect from '@/components/UserSelect';
+import MultiInstanceUser from '@/components/Process/multiInstanceUser.vue';
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 import { UserVO } from '@/api/system/user/types';
+import { TaskVO } from '@/api/workflow/task/types';
 const userSelectCopyRef = ref<InstanceType<typeof UserSelect>>();
+const transferTaskRef = ref<InstanceType<typeof UserSelect>>();
+const delegateTaskRef = ref<InstanceType<typeof UserSelect>>();
+
+  //鍔犵缁勪欢
+const multiInstanceUserRef = ref<InstanceType<typeof MultiInstanceUser>>();
 
 const props = defineProps({
   taskVariables: {
@@ -52,16 +104,48 @@
 const loading = ref(true);
 //鎸夐挳
 const buttonLoading = ref(true);
-//娴佺▼鐘舵��
-const businessStatus = ref<string>('');
 //浠诲姟id
 const taskId = ref<string>('');
 //鎶勯�佷汉
 const selectCopyUserList = ref<UserVO[]>([]);
 //鎶勯�佷汉id
 const selectCopyUserIds = ref<string>(undefined);
-  
-
+// 椹冲洖鏄惁鏄剧ず
+const backVisible = ref(false);
+const backLoading = ref(true);
+// 鍙┏鍥炲緱浠诲姟鑺傜偣
+const taskNodeList = ref([]);
+//浠诲姟
+const task = ref<TaskVO>({
+  id: undefined,
+  name: undefined,
+  description: undefined,
+  priority: undefined,
+  owner: undefined,
+  assignee: undefined,
+  assigneeName: undefined,
+  processInstanceId: undefined,
+  executionId: undefined,
+  taskDefinitionId: undefined,
+  processDefinitionId: undefined,
+  endTime: undefined,
+  taskDefinitionKey: undefined,
+  dueDate: undefined,
+  category: undefined,
+  parentTaskId: undefined,
+  tenantId: undefined,
+  claimTime: undefined,
+  businessStatus: undefined,
+  businessStatusName: undefined,
+  processDefinitionName: undefined,
+  processDefinitionKey: undefined,
+  participantVo: undefined,
+  multiInstance: undefined,
+  businessKey: undefined,
+  wfNodeConfigVo: undefined
+});
+//鍔犵 鍑忕鏍囬
+const title = ref('');
 const dialog = reactive<DialogOption>({
   visible: false,
   title: '鎻愮ず'
@@ -74,6 +158,16 @@
   messageType: ['1'],
   wfCopyList: []
 });
+const backForm = ref<Record<string, any>>({
+  taskId: undefined,
+  targetActivityId: undefined,
+  message: undefined,
+  variables: {},
+  messageType: ['1']
+});
+const closeDialog = () => {
+  dialog.visible = false
+}
 //鎵撳紑寮圭獥
 const openDialog = (id?: string) => {
   selectCopyUserIds.value = undefined
@@ -85,8 +179,8 @@
   loading.value = true;
   buttonLoading.value = true;
   nextTick(() => {
-    getBusinessStatus(taskId.value).then((response) => {
-      businessStatus.value = response.data;
+    getTaskById(taskId.value).then((response) => {
+      task.value = response.data;
       loading.value = false;
       buttonLoading.value = false;
     });
@@ -114,20 +208,37 @@
   await proxy?.$modal.confirm('鏄惁纭鎻愪氦锛�');
   loading.value = true;
   buttonLoading.value = true;
-  await completeTask(form.value).finally(() => (loading.value = false));
-  dialog.visible = false;
-  emits('submitCallback');
-  proxy?.$modal.msgSuccess('鎿嶄綔鎴愬姛');
+  try {
+    await completeTask(form.value);
+    dialog.visible = false;
+    emits('submitCallback');
+    proxy?.$modal.msgSuccess('鎿嶄綔鎴愬姛');
+  } finally {
+    loading.value = false
+    buttonLoading.value = false
+  }
 };
 
+/** 椹冲洖寮圭獥鎵撳紑 */
+const handleBackProcessOpen = async () => {
+  backForm.value = {}
+  backForm.value.messageType = ['1']
+  backVisible.value = true
+  backLoading.value = true
+  let data = await getTaskNodeList(task.value.processInstanceId)
+  taskNodeList.value = data.data
+  backLoading.value = false
+  backForm.value.targetActivityId = taskNodeList.value[0].nodeId
+}
 /** 椹冲洖娴佺▼ */
 const handleBackProcess = async () => {
-  form.value.taskId = taskId.value;
+  backForm.value.taskId = taskId.value;
   await proxy?.$modal.confirm('鏄惁纭椹冲洖鍒扮敵璇蜂汉锛�');
   loading.value = true;
-  buttonLoading.value = true;
-  await backProcess(form.value).finally(() => (loading.value = false));
+  backLoading.value = true;
+  await backProcess(backForm.value).finally(() => (loading.value = false));
   dialog.visible = false;
+  backLoading.value = false
   emits('submitCallback');
   proxy?.$modal.msgSuccess('鎿嶄綔鎴愬姛');
 };
@@ -156,6 +267,83 @@
   selectCopyUserList.value.splice(index, 1);
   selectCopyUserIds.value = selectCopyUserList.value.map((item) => item.userId).join(',');
 };
+//鍔犵
+const addMultiInstanceUser = () => {
+  if (multiInstanceUserRef.value) {
+    title.value = '鍔犵浜哄憳';
+    multiInstanceUserRef.value.getAddMultiInstanceList(taskId.value, []);
+  }
+};
+//鍑忕
+const deleteMultiInstanceUser = () => {
+  if (multiInstanceUserRef.value) {
+    title.value = '鍑忕浜哄憳';
+    multiInstanceUserRef.value.getDeleteMultiInstanceList(taskId.value);
+  }
+};
+//鎵撳紑杞姙
+const openTransferTask = () => {
+  transferTaskRef.value.open();
+};
+//杞姙
+const handleTransferTask  = async (data) => {
+  if(data && data.length > 0){
+    let params = {
+      taskId: taskId.value,
+      userId: data[0].userId,
+      comment: form.value.message
+    }
+    await proxy?.$modal.confirm('鏄惁纭鎻愪氦锛�');
+    loading.value = true;
+    buttonLoading.value = true;
+    await transferTask(params).finally(() => (loading.value = false));
+    dialog.visible = false;
+    emits('submitCallback');
+    proxy?.$modal.msgSuccess('鎿嶄綔鎴愬姛');
+  }else{
+    proxy?.$modal.msgWarning('璇烽�夋嫨鐢ㄦ埛锛�');
+  }
+}
+
+//鎵撳紑濮旀墭
+const openDelegateTask = () => {
+  delegateTaskRef.value.open();
+};
+//濮旀墭
+const handleDelegateTask  = async (data) => {
+  if(data && data.length > 0){
+    let params = {
+      taskId: taskId.value,
+      userId: data[0].userId,
+      nickName: data[0].nickName
+    }
+    await proxy?.$modal.confirm('鏄惁纭鎻愪氦锛�');
+    loading.value = true;
+    buttonLoading.value = true;
+    await delegateTask(params).finally(() => (loading.value = false));
+    dialog.visible = false;
+    emits('submitCallback');
+    proxy?.$modal.msgSuccess('鎿嶄綔鎴愬姛');
+  }else{
+    proxy?.$modal.msgWarning('璇烽�夋嫨鐢ㄦ埛锛�');
+  }
+}
+//缁堟浠诲姟
+const handleTerminationTask  = async (data) => {
+    let params = {
+      taskId: taskId.value,
+      comment: form.value.message
+    }
+    await proxy?.$modal.confirm('鏄惁纭缁堟锛�');
+    loading.value = true;
+    buttonLoading.value = true;
+    await terminationTask(params).finally(() => (loading.value = false));
+    dialog.visible = false;
+    emits('submitCallback');
+    proxy?.$modal.msgSuccess('鎿嶄綔鎴愬姛');
+  
+}
+
 /**
  * 瀵瑰鏆撮湶瀛愮粍浠舵柟娉�
  */

--
Gitblit v1.9.3