Преглед на файлове

新增知识权限多选

Zhang Li, BBF-411-2(Neusoft) преди 1 година
родител
ревизия
c52babe671
променени са 2 файла, в които са добавени 157 реда и са изтрити 61 реда
  1. 83 28
      src/views/modules/knowledge/components/orgPeople.vue
  2. 74 33
      src/views/modules/knowledge/warehouse/knowledgeAddUpdate.vue

+ 83 - 28
src/views/modules/knowledge/components/orgPeople.vue

@@ -4,10 +4,12 @@
           <rx-tree
             :treeData="orgData"
             :async="true"
+            v-model="checkedKeys"
             :loadByParent="onLoadGroupTree"
-            :multiSelect="false"
+            :multiSelect="!isOnlyOrg"
             :showTreeIcon="true"
             @select="selectGroupNode"
+            @check="check"
             :expandOnLoad="0"
             autoExpandParent="true"
             id-field="key"
@@ -22,14 +24,14 @@
             </a-select>
         </a-card> -->
         <a-card  v-if="!isOnlyOrg" title="职系" style="padding:20px;border:none;border-right: 1px solid #e8e8e8;overflow-y:auto;" :style="{width: isOnlyOrg ? '35%' : '100%'}">
-            <a-select v-model="sequencesInfo.gradeId" placeholder="请选择职系" allowClear style="width:100%;" @change="handleSequencesChange">
+            <a-select mode="multiple" v-model="gradeId" placeholder="请选择职系" style="width:100%;" @change="dropdownSequencesChange">
                 <a-select-option v-for="(item,index) in sequencesList" :key="index" :value="item.value" >
                     {{ item.label }}
                 </a-select-option>
             </a-select>
         </a-card>
         <a-card  v-if="!isOnlyOrg" title="职等" style="padding:20px;border:none;" :style="{width: isOnlyOrg ? '35%' : '100%'}">
-            <a-select v-model="gradesInfo.gradeLevelId" placeholder="请选择职等" allowClear style="width:100%;" @change="handleGradeChange">
+            <a-select mode="multiple" v-model="gradeLevelId" placeholder="请选择职等" style="width:100%;" @change="dropdownGradesChange">
                 <a-select-option v-for="(item,index) in gradesList" :key="index" :value="item">
                     {{ item }}
                 </a-select-option>
@@ -97,6 +99,10 @@
         isOnlyOrg: {
             type: Boolean,
             default: true
+        },
+        organizationIdsInfo: {
+            type: Object,
+            default: () => {}
         }
     },
     data() {
@@ -170,16 +176,25 @@
             // }
             ],
             // 组织架构
+            checkedKeys:{checked:[]},
             checkedTarget: {},
+            // 组织架构(多选)
+            checkedTargets: {
+                organizationId: [],
+                organizationName: [],
+                organizationTree: []
+            },
             // 职系
+            gradeId: [],
             sequencesInfo: {
-                gradeId: undefined,
-                gradeName: ''
+                gradeId: [],
+                gradeName: []
             },
+            gradeLevelId: [],
             // 职等
             gradesInfo: {
-                gradeLevelId: undefined,
-                gradeLevelName: ''
+                gradeLevelId: [],
+                gradeLevelName: []
             }
         }
     },
@@ -198,7 +213,6 @@
                 this.gradesList = res.data
             })
         }
-        // this.getAllUserTypeList();
     },
     methods: {
         reset() {
@@ -235,6 +249,18 @@
                 }
 
                 this.orgData = [...temp];
+                // this.getAllUserTypeList();
+                let info = this.organizationIdsInfo
+                this.checkedKeys.checked = info.organizationId || []
+                this.checkedTargets.organizationId = info.organizationId || []
+                this.checkedTargets.organizationName = info.organizationName || []
+                this.checkedTargets.organizationTree = info.organizationTree || []
+                this.gradeId = info.gradeId || []
+                this.sequencesInfo.gradeId = info.gradeId || []
+                this.sequencesInfo.gradeName = info.gradeName || []
+                this.gradeLevelId = info.gradeLevelId || []
+                this.gradesInfo.gradeLevelId = info.gradeLevelId || []
+                this.gradesInfo.gradeLevelName = info.gradeLevelName || []
             })
         },
         //加载左树下的子节点
@@ -242,7 +268,7 @@
             if (treeNode.dataRef.children) {
                 return;
             }
-            console.log(treeNode)
+            // console.log(treeNode)
             return OsGroupApi.getParentGroup(treeNode.dataRef.groupId).then(data => {
                 let treeData = []
                 for (let i = 0; i < data.length; i++) {
@@ -253,8 +279,8 @@
                 var orgData = this.getGroupTree(this.orgData, treeNode.dataRef.groupId, treeData);
 
                 this.orgData = [...orgData];
-                console.info("onLoadGroupTree")
-                console.info(this.orgData)
+                // console.info("onLoadGroupTree")
+                // console.info(this.orgData)
             })
         },
         getGroupTree(orgData, groupId, treeData) {
@@ -278,13 +304,14 @@
                 this.checkedTarget['approverId'] = node.groupId
                 this.checkedTarget['approverName'] = node.title
                 this.$emit('transCheckedTarget',this.checkedTarget)
-            } else {
-                let organizationTree = getParentNode(e.node)
-                this.checkedTarget['organizationId'] = node.groupId
-                this.checkedTarget['organizationName'] = node.title
-                this.checkedTarget['organizationTree'] = organizationTree
-                this.$emit('transCheckedTarget',this.checkedTarget)
-            }   
+            } 
+            // else {
+            //     let organizationTree = getParentNode(e.node)
+            //     this.checkedTarget['organizationId'] = node.groupId
+            //     this.checkedTarget['organizationName'] = node.title
+            //     this.checkedTarget['organizationTree'] = organizationTree
+            //     this.$emit('transCheckedTarget',this.checkedTarget)
+            // }   
             if(this.isOnlyOrg) {
                 //this.selectGroupId=node.groupId;
                 //查询左树用户
@@ -296,10 +323,22 @@
                 this.$refs.table.loadData()
             }
         },
+        // 多选节点
+        check(selKeys, e) {
+            //  organizationId: [],
+            //     organizationName: [],
+            //     organizationTree: []
+            this.checkedTargets = Object.assign({},this.$options.data().checkedTargets)
+            this.checkedTargets.organizationId = selKeys
+            for(let i of e.checkedNodes) {
+                 this.checkedTargets.organizationName.push(i.data.props.title)
+                 this.checkedTargets.organizationTree.push(i.data.props.title)
+            }
+            this.$emit('transCheckedTargets',this.checkedTargets)
+        },
         onSelectChange(keys,rows) {
             this.checkedTarget['approverId'] = rows[0].userNo
             this.checkedTarget['approverName'] = rows[0].fullName
-            console.log(this.checkedTarget)
             this.$emit('transCheckedTarget',this.checkedTarget)
         },
         // 选择职系
@@ -311,6 +350,18 @@
             }
             this.$emit('returnSequencesInfo',this.sequencesInfo)
         },
+        // 选择职系(多选)
+        dropdownSequencesChange(open) {
+            // if(open == false) {
+                this.sequencesInfo = Object.assign({},this.$options.data().sequencesInfo)
+                let that = this
+                this.gradeId.forEach(function(item){
+                    that.sequencesInfo.gradeId.push(item)
+                    that.sequencesInfo.gradeName.push(that.sequencesList.find(item0 => item0.value == item).label)
+                })
+                this.$emit('returnSequencesInfo',this.sequencesInfo)
+            // }
+        },
         // 选择职级
         handleGradeChange(arg) {
             if(arg) {
@@ -319,22 +370,26 @@
                 this.gradesInfo = {}
             }
             this.$emit('returnGradeInfo',this.gradesInfo)
+        },
+        // 选择职级(多选)
+        dropdownGradesChange(open) {
+            // if(open == false) {
+                this.gradesInfo = Object.assign({},this.$options.data().gradesInfo)
+                let that = this
+                this.gradeLevelId.forEach(function(item){
+                    that.gradesInfo.gradeLevelId.push(item)
+                    that.gradesInfo.gradeLevelName.push(item)
+                })
+                this.$emit('returnGradeInfo',this.gradesInfo)
+            // }
         }
     },
     beforeDestroy() {
         this.checkedTarget = Object.assign({},this.$options.data().checkedTarget)
+        this.checkedTargets = Object.assign({},this.$options.data().checkedTargets)
         this.sequencesInfo = Object.assign({},this.$options.data().sequencesInfo)
         this.gradesInfo = Object.assign({},this.$options.data().gradesInfo)
     }
-    // watch: {
-    //     checkedTarget: {
-    //         handler(news,olds) {
-    //             console.log(news,olds)
-    //             this.$emit('transCheckedTarget',this.checkedTarget)
-    //         },
-    //         deep: true
-    //     }
-    // }
 }
 </script>
 <style scoped>

+ 74 - 33
src/views/modules/knowledge/warehouse/knowledgeAddUpdate.vue

@@ -87,7 +87,7 @@
         </a-form-model-item>
         <a-form-model-item class="knowledgeAddUpdateLabel oneline" v-if="knowledgeForm.type==1" prop="actualApproverName">
           <span slot="label">&emsp;&emsp;权限</span>
-          <div @click="showAuditFlag = true">
+          <div @click="handleAuthClickshow">
             <a-select class="addItemBox" v-model="authName" :showArrow="false" :open="false" placeholder="请选择您建议的权限范围"></a-select>
           </div>
         </a-form-model-item>
@@ -118,8 +118,10 @@
           okText="保存"
           @ok="handleSaveOk">
       <org-people :isOnlyOrg="false" 
+                  :organizationIdsInfo="organizationIdsInfo"
                   style="width:800px;height:65vh;" 
                   @transCheckedTarget="transCheckedTarget"
+                  @transCheckedTargets="transCheckedTargets"
                   @returnSequencesInfo="handleSequencesChange"
                   @returnGradeInfo="handleGradeChange" />
     </a-modal>  
@@ -166,7 +168,7 @@ export default {
         attachmentName: '',
         createBy: '',
         author: '',
-        organizationId:''
+        organizationIds: {}
       },
       options: [
         {
@@ -264,14 +266,15 @@ export default {
       },
       headers: {},
       isSubmit:false,
-      innerWidth: 800,
+      widthVar: 800,
       authName: undefined,
-      // 组织架构
       checkedTarget: {},
+      checkedTargets: {},
       // 职系
       sequencesInfo: {},
       // 职等
       gradesInfo: {},
+      organizationIdsInfo: {}
     }
   },
   created() {
@@ -294,27 +297,52 @@ export default {
         this.knowledgeForm.content = res.data.content
         this.knowledgeForm.attachment = res.data.attachment
         this.knowledgeForm.attachmentName = res.data.attachmentName
+        this.knowledgeForm.organizationIds = res.data.organizationIds
         this.approverData = res.data.approvals
         this.knowledgeForm.createBy = res.data.createBy
         this.knowledgeForm.author = res.data.author
         //res.data.organizationId='[{\"organizationId\":\"C0000\",\"organizationName\":\"惠科集团\",\"organizationTree\":[\"惠科集团\"]},{\"gradeId\":\"O/F\",\"gradeName\":\"制造职系\"},{\"gradeLevelId\":\"1\",\"gradeLevelName\":\"1\"}]'
-        console.log(res.data.organizationId)
-        let organizationIdArr = JSON.parse(res.data.organizationId)
-        if(organizationIdArr!=null){
+        if(res.data.organizationIds) {
+          let organizationInfo = res.data.organizationIds
           let info = []
-          organizationIdArr.forEach(element => {
-            if(element.organizationTree){
-              info.push(`${element.organizationTree.join('-')}`)
-            }
-            if(element.gradeName){
-              info.push(`职系-${element.gradeName}`)
-            }
-            if(element.gradeLevelName){
-              info.push(`职等-${element.gradeLevelName}`)
-            }
-          })
+          if(organizationInfo.organizationId) {
+            info.push(`组织:[${organizationInfo.organizationTree}]`)
+          }
+          if(organizationInfo.gradeId) {
+            info.push(`职系:[${organizationInfo.gradeName}]`)
+          }
+          if(organizationInfo.gradeLevelId) {
+            info.push(`职等:[${organizationInfo.gradeLevelName}]`)
+          }
+          this.checkedTargets.organizationId = organizationInfo.organizationId
+          this.checkedTargets.organizationName = organizationInfo.organizationName
+          this.checkedTargets.organizationTree = organizationInfo.organizationTree
+          this.sequencesInfo.gradeId = organizationInfo.gradeId
+          this.sequencesInfo.gradeName = organizationInfo.gradeName
+          this.gradesInfo.gradeLevelId = organizationInfo.gradeLevelId
+          this.gradesInfo.gradeLevelName = organizationInfo.gradeLevelName
+          // console.log(this.checkedTargets)
+          // console.log(this.sequencesInfo)
+          // console.log(this.gradeLevelId)
+          this.accessAuthority = info.join('/')
           this.authName = info.join('/')
         }
+        // let organizationIdArr = JSON.parse(res.data.organizationId)
+        // if(organizationIdArr!=null){
+        //   let info = []
+        //   organizationIdArr.forEach(element => {
+        //     if(element.organizationTree){
+        //       info.push(`${element.organizationTree.join('-')}`)
+        //     }
+        //     if(element.gradeName){
+        //       info.push(`职系-${element.gradeName}`)
+        //     }
+        //     if(element.gradeLevelName){
+        //       info.push(`职等-${element.gradeLevelName}`)
+        //     }
+        //   })
+        //   this.authName = info.join('/')
+        // }
         this.titlesChange()
         this.summaryChange()
       })
@@ -353,6 +381,10 @@ export default {
    
   },
   methods: {
+    handleAuthClickshow() {
+      this.organizationIdsInfo = this.knowledgeForm.organizationIds
+      this.showAuditFlag = true      
+    },
     //分类修改数据
     popupVisibleChange(value) {
       if(value==false){
@@ -368,6 +400,9 @@ export default {
     transCheckedTarget(arg) {
       this.checkedTarget = arg
     },
+    transCheckedTargets(arg) {
+      this.checkedTargets = arg
+    },
     handleSequencesChange(arg) {
       this.sequencesInfo = arg
     },
@@ -377,30 +412,32 @@ export default {
     handleSaveOk() {
       if(this.isShowOrg) {
         let info = []
-        let res = []
-        if(this.checkedTarget.organizationId) {
-          info.push(`${this.checkedTarget.organizationTree.join('-')}`)
-          res.push(this.checkedTarget)
+        let res = {}
+        if(this.checkedTargets && this.checkedTargets.organizationId) {
+          info.push(`组织:[${this.checkedTargets.organizationTree}]`)
+          res['organizationId'] = this.checkedTargets.organizationId
+          res['organizationName'] = this.checkedTargets.organizationName
+          res['organizationTree'] = this.checkedTargets.organizationTree
         }
-        if(this.sequencesInfo.gradeId) {
-          info.push(`职系-${this.sequencesInfo.gradeName}`)
-          res.push(this.sequencesInfo)
+        if(this.sequencesInfo && this.sequencesInfo.gradeId) {
+          info.push(`职系:[${this.sequencesInfo.gradeName}]`)
+          res['gradeId'] = this.sequencesInfo.gradeId
+          res['gradeName'] = this.sequencesInfo.gradeName
         }
-        if(this.gradesInfo.gradeLevelId) {
-          info.push(`职等-${this.gradesInfo.gradeLevelName}`)
-          res.push(this.gradesInfo)
+        if(this.gradesInfo && this.gradesInfo.gradeLevelId) {
+          info.push(`职等:[${this.gradesInfo.gradeLevelName}]`)
+          res['gradeLevelId'] = this.gradesInfo.gradeLevelId
+          res['gradeLevelName'] = this.gradesInfo.gradeLevelName
         }
-        console.log(info)
         if(info.length) {
           this.authName = info.join('/')
         }
-        if(res.length) {
-          this.knowledgeForm.organizationId = JSON.stringify([...res])
+        if(Object.keys(res).length) {
+          this.knowledgeForm.organizationIds = res
         } else {
-          this.knowledgeForm.organizationId = ""
+          this.knowledgeForm.organizationIds = {}
         }
       }
-      console.log(this.knowledgeForm.organizationId)
       this.showAuditFlag = false
     },
     //  title修改限制数量
@@ -789,6 +826,10 @@ export default {
 .ant-cascader-picker-label{
   height: 30px;
 }
+.ant-select-selection__placeholder {
+  height: 22px;
+  line-height: 22px;
+}
 </style>
 <style scoped>
 /deep/ .ant-cascader-menus {