lilei пре 2 година
родитељ
комит
d7b0b7fc3b
2 измењених фајлова са 17 додато и 12 уклоњено
  1. 16 11
      src/views/common/dingDepartUser.js
  2. 1 1
      vue.config.js

+ 16 - 11
src/views/common/dingDepartUser.js

@@ -62,10 +62,12 @@ const DingDepartUser = {
       this.$emit('input', value);
     },
     // 格式化数据
-    formatData(data,type){
+    formatData(data){
+      console.log(data)
       const ret = []
       data.map(item => {
-        if(type == 'bm'){
+        // 部门
+        if(item.deptId){
           const node = {
             title: item.name,
             id:item.deptId,
@@ -74,19 +76,21 @@ const DingDepartUser = {
             autoAddUser: item.autoAddUser,
             createDeptGroup: item.createDeptGroup,
             disableCheckbox: true,
-            checkable: false
+            checkable: false,
+            children: []
           }
-          if(item.deptUserList){
-            node.children = this.formatData(item.deptUserList,'yg')
-          }
-          if(item.deptList){
-            node.children = this.formatData(item.deptList,'bm')
+          if(item.deptUserList && item.deptList){
+            node.children = this.formatData(item.deptList.concat(item.deptUserList?item.deptUserList:[]))
+          }else if(item.deptUserList && !item.deptList){
+            node.children = this.formatData(item.deptUserList)
+          }else if(!item.deptUserList && item.deptList){
+            node.children = this.formatData(item.deptList)
           }
           ret.push(node)
         }else{
           ret.push({
             title: item.name,
-            id: item.userid,
+            id: item.deptOrder,
             value: item.userid,
             pId: item.parentId,
             avatar: item.avatar,
@@ -98,16 +102,17 @@ const DingDepartUser = {
             isLeaf: true
           })
         }
+         
       })
       return ret
     },
     // 获取部门人员
     async genTreeNode() {
        let ret = await getDingTalkAllDeptUser().then(res => res.data)
-       console.log(ret)
        const res1 = ret.deptList||[]
        const res2 = ret.deptUserList||[]
-       this.treeData = this.treeData.concat(this.formatData(res1,'bm')).concat(this.formatData(res2,'yg'));
+       this.treeData = this.treeData = this.formatData(res1.concat(res2));
+       console.log(this.treeData,'----')
     },
     // 更新人员数据
     updateDeptUser(){

+ 1 - 1
vue.config.js

@@ -107,7 +107,7 @@ const vueConfig = {
     // If you want to turn on the proxy, please remove the mockjs /src/main.jsL11
     proxy: {
       '/api': {
-        target: 'http://192.168.16.151/ocs-admin',
+        target: 'http://192.168.0.183:8602/ocs-admin',
         // target: 'https://t.ocs.360arrow.com/ocs-admin', //  Á·Ï°
         // target: 'http://p.ocs.360arrow.com/ocs-admin', //  Ô¤·¢²¼
         ws: false,