Просмотр исходного кода

feat(采购计划管理): 采购计划审批添加多选采购员

liujt 6 месяцев назад
Родитель
Сommit
aa7aff787b

+ 9 - 0
src/api/bpm/processInstance.js

@@ -39,3 +39,12 @@ export async function getProcessInstance(id) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+// 审批
+export function processInstanceValueJsonChange(data) {
+  return request({
+    url: `/bpm/process-instance/processInstanceValueJsonChange/${processInstanceId}`,
+    method: 'PATCH',
+    data: data
+  })
+}

+ 35 - 8
src/views/bpm/handleTask/components/purchasePlanManage/submit.vue

@@ -25,10 +25,12 @@
         }"
       >
         <el-select
-          v-model="form.userId"
+          v-model="selectId"
           clearable
+          multiple
           style="width: 100%"
           :filterable="true"
+          @change="handleUserChange"
         >
           <el-option
             v-for="item in userOptions"
@@ -155,10 +157,13 @@
       return {
         form: {
           userId: '',
+          userName: '',
           reason: '',
-          useDeptId: ''
+          useDeptId: '',
+          assignList: []
         },
         userOptions: [],
+        selectId: [],
         isSaveLoading:false
       };
     },
@@ -169,6 +174,26 @@
       });
     },
     methods: {
+      handleUserChange(val, option){        
+        console.log(val, option, 'val');                   
+        // 通过选中的采购员Id数组,获取对应的name数组        
+        if (val && val.length > 0) {         
+          const userNameArray = val.map(userId => {            
+            const user = this.userOptions.find(item => item.id === userId);            
+            return user ? {userId: user.id, userName: user.name} : '';          
+          }).filter(name => name);          
+          // assignList数组
+          this.form.assignList = [...userNameArray];     
+          this.form.userId = this.form.assignList[0]?.userId || '';    
+          this.form.userName = this.form.assignList[0]?.userName || ''; 
+        } else {          
+          this.form.userId = '';
+          this.form.userName = '';
+          this.form.assignList = [];        
+        }        
+
+        console.log('assignList数组:', this.form.assignList);
+      },
       /** 处理转办审批人 */
       handleUpdateAssignee() {
         this.$emit('handleUpdateAssignee');
@@ -217,9 +242,10 @@
         }
       },
       async handleAudit(status) {
-        let userInfo = this.userOptions.find(
-          (item) => item.id == this.form.userId
-        );
+        // let userInfo = this.userOptions.find(
+        //   (item) => item.id == this.form.userId
+        // );
+        console.log(this.form)
         //主管指派采购员
         if (this.taskDefinitionKey === 'deptLeaderAssign') {
           if (!this.form.userId) {
@@ -227,8 +253,9 @@
             return;
           }
           await assign({
-            userId: userInfo.id,
-            userName: userInfo.name,
+            userId: this.form.userId,
+            userName: this.form.userName,
+            assignList: this.form.assignList,
             id: this.taskId,
             reason: this.form.reason,
             businessId: this.businessId
@@ -247,7 +274,7 @@
           id: this.taskId,
           reason: this.form.reason,
           variables: {
-            userId: userInfo?.id,
+            userId: this.form.userId,
             pass: !!status
           }
         });