From ee15398472acb5686be991b6445bab3db3cf229b Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期六, 30 十一月 2024 01:25:41 +0800
Subject: [PATCH] 任务分配支持选部门

---
 src/components/Process/panel/taskPanel.vue |   87 +++++++++++++++++++++++++++++++++++++------
 1 files changed, 75 insertions(+), 12 deletions(-)

diff --git a/src/components/Process/panel/taskPanel.vue b/src/components/Process/panel/taskPanel.vue
index 9bfe14a..59063a2 100644
--- a/src/components/Process/panel/taskPanel.vue
+++ b/src/components/Process/panel/taskPanel.vue
@@ -43,12 +43,26 @@
         </el-button-group>
       </el-form-item>
 
-      <el-form-item label="鍊欓�夎鑹�" v-else>
+      <el-form-item label="鍊欓�夎鑹�" v-else-if="bpmnFormData.userType === 'candidateGroups'">
         <el-input-tag v-model="bpmnFormData.candidateGroups" :value="bpmnFormData.candidateGroups"/>
         <el-button-group class="ml-4" style="margin-top: 4px">
           <!--鍊欓�夎鑹�-->
           <el-tooltip class="box-item" effect="dark" content="鍊欓�夎鑹�" placement="bottom">
             <el-button size="mini" type="primary" icon="el-icon-user"  @click="multipleRoleCheck"/>
+          </el-tooltip>
+          <!--閫夋嫨琛ㄨ揪寮�-->
+          <el-tooltip class="box-item" effect="dark" content="閫夋嫨琛ㄨ揪寮�" placement="bottom">
+            <el-button size="mini" type="warning" icon="el-icon-postcard" @click="singleExpCheck"/>
+          </el-tooltip>
+        </el-button-group>
+      </el-form-item>
+
+      <el-form-item label="鍊欓�夐儴闂�" v-else>
+        <el-input-tag v-model="bpmnFormData.candidateGroups" :value="bpmnFormData.candidateGroups"/>
+        <el-button-group class="ml-4" style="margin-top: 4px">
+          <!--鍊欓�夐儴闂�-->
+          <el-tooltip class="box-item" effect="dark" content="鍊欓�夐儴闂�" placement="bottom">
+            <el-button size="mini" type="primary" icon="el-icon-user"  @click="deptVisible = true"/>
           </el-tooltip>
           <!--閫夋嫨琛ㄨ揪寮�-->
           <el-tooltip class="box-item" effect="dark" content="閫夋嫨琛ㄨ揪寮�" placement="bottom">
@@ -95,6 +109,8 @@
       </div>
     </el-dialog>
 
+    <flow-dept :checkeds="selectData.candidateGroups" :show="deptVisible" @close="closeDept" @submit="submitDept"/>
+
     <!--閫夋嫨琛ㄨ揪寮�-->
     <el-dialog
       title="閫夋嫨琛ㄨ揪寮�"
@@ -119,6 +135,7 @@
 import FlowRole from '@/components/flow/Role'
 import FlowExp from '@/components/flow/Expression'
 import ElInputTag from '@/components/flow/ElInputTag'
+import FlowDept from '@/components/flow/Dept'
 import {StrUtil} from '@/utils/StrUtil'
 
 export default {
@@ -127,7 +144,8 @@
     FlowUser,
     FlowRole,
     FlowExp,
-    ElInputTag
+    ElInputTag,
+    FlowDept
   },
   /** 缁勪欢浼犲��  */
   props : {
@@ -141,13 +159,15 @@
       userVisible: false,
       roleVisible: false,
       expVisible: false,
+      deptVisible: false,
       isIndeterminate: true,
       checkType: 'single', // 閫夌被
       userType: '',
       userTypeOption: [
         {label: '鎸囧畾浜哄憳', value: 'assignee'},
         {label: '鍊欓�変汉鍛�', value: 'candidateUsers'},
-        {label: '鍊欓�夎鑹�', value: 'candidateGroups'}
+        {label: '鍊欓�夎鑹�', value: 'candidateGroups'},
+        {label: '鍊欓�夐儴闂�', value: 'candidateDeptGroups'},
       ],
       checkAll: false,
       bpmnFormData: {
@@ -164,7 +184,8 @@
       selectData: {
         assignee: null,
         candidateUsers: null,
-        candidateGroups: null,
+        candidateGroups: null,  // 瑙掕壊
+        candidateDeptGroups: [], // 閮ㄩ棬
         exp: null,
       },
       otherExtensionList:[],
@@ -186,6 +207,11 @@
 
   },
   methods: {
+    closeDept() {
+      this.deptVisible = false
+      this.selectData.candidateGroups = []
+    },
+
     // 鍒濆鍖栬〃鍗�
     resetTaskForm() {
       // 鍒濆鍖栬涓虹┖鍊�
@@ -210,7 +236,7 @@
         const value = this.modelerStore.element?.businessObject[key] || this.bpmnFormData[key];
         this.$set(this.bpmnFormData, key, value);
       }
-      // 浜哄憳淇℃伅鍥炴樉
+      // 浜哄憳銆佽鑹层�侀儴闂ㄤ俊鎭洖鏄�
       this.checkValuesEcho(this.bpmnFormData);
     },
 
@@ -239,6 +265,7 @@
         assignee: null,
         candidateUsers: null,
         candidateGroups: null,
+        candidateDeptGroups: null,
         exp: null,
       }
       // 鍐欏叆userType鑺傜偣淇℃伅鍒皒ml
@@ -250,8 +277,9 @@
       if (StrUtil.isNotBlank(formData.expId)) {
         this.getExpList(formData.expId, formData.userType);
       } else {
-        if ("candidateGroups" === formData.userType) {
-          this.getRoleList(formData[formData.userType], formData.userType);
+        console.log("鎴戝幓", formData.userType)
+        if ("candidateGroups" === formData.userType || "candidateDeptGroups" === formData.userType) {
+          this.getRoleList(formData["candidateGroups"], "candidateGroups");
         } else {
           this.getUserList(formData[formData.userType], formData.userType);
         }
@@ -282,13 +310,33 @@
     // 鑾峰彇瑙掕壊淇℃伅
     getRoleList(val, key) {
       if (StrUtil.isNotBlank(val)) {
-        const newArr = this.modelerStore.roleList?.filter(i => val.split(',').includes(i.roleId.toString()))
-        this.bpmnFormData[key] = newArr.map(item => item.roleName).join(',');
-        if ('assignee' === key) {
-          this.selectData[key] = newArr.find(item => item.roleId.toString() === val).roleId;
+
+        // 鏍规嵁id绛涢�夊嚭鏄鑹茶繕鏄儴闂�
+        const roleAndDeptIds = val.split(",");
+        const deptIds = roleAndDeptIds.filter(item => item.includes("dept"));
+        const roleIds = roleAndDeptIds.filter(item => !item.includes("dept"));
+        // 璋佹湁鍊煎氨鏄皝
+        if (roleIds && roleIds.length > 0) {
+          console.log("鎴戝幓1", roleIds)
+          const newArr = this.modelerStore.roleList?.filter(i => roleIds.includes(i.roleId.toString()))
+          this.bpmnFormData[key] = newArr.map(item => item.roleName).join(',');
+          if ('assignee' === key) {
+            this.selectData[key] = newArr.find(item => item.roleId.toString() === val).roleId;
+          } else {
+            this.selectData[key] = newArr.map(item => item.roleId);
+          }
         } else {
-          this.selectData[key] = newArr.map(item => item.roleId);
+          console.log("鎴戝幓2", deptIds)
+          const newArr = this.modelerStore.deptList?.filter(i => deptIds.includes(i.id))
+          this.bpmnFormData[key] = newArr.map(item => item.label).join(',');
+          if ('assignee' === key) {
+            this.selectData[key] = newArr.find(item => item.id === val).id;
+          } else {
+            this.selectData[key] = newArr.map(item => item.id);
+          }
         }
+
+
       }
     },
 
@@ -367,6 +415,21 @@
       }
     },
 
+    // 閮ㄩ棬閫変腑鏁版嵁
+    submitDept(checkList, names) {
+      this.deptVisible = false
+      // this.selectData.candidateDeptGroups = checkList
+      if (checkList && names) {
+        this.deleteFlowAttar();
+        this.bpmnFormData["candidateGroups"] = names;
+        this.updateCustomElement('dataType', 'fixed');
+        // userType = candidateGroups
+        // 杩欓噷鍙兘鍐欐涓猴細candidateGroups锛屽洜涓篺lowable鐢ㄦ埛缁勭殑鍏抽敭瀛楀氨鏄畠
+        this.updateCustomElement("candidateGroups", checkList);
+        this.handleSelectData("candidateGroups", checkList);
+      }
+    },
+
     // 澶勭悊浜哄憳鍥炴樉
     handleSelectData(key, value) {
       for (let oldKey in this.selectData) {

--
Gitblit v1.8.0