yumeng 1 månad sedan
förälder
incheckning
1d3b3ba284
1 ändrade filer med 79 tillägg och 78 borttagningar
  1. 79 78
      src/views/modules/material/accountCheckBytedance.vue

+ 79 - 78
src/views/modules/material/accountCheckBytedance.vue

@@ -250,54 +250,62 @@ export default {
       if(!this.isMultiagent){
         var dataArr = data.map(item=>{
           return {
-            accountId:item.id.split('@')[0],
-            userName:item.id.split('@')[2],
-            userId:item.id.split('@')[1],
+            accountId:item.key.split('@')[0],
+            userName:item.key.split('@')[2],
+            userId:item.key.split('@')[1],
           }
         })
         this.showEdit = false
         this.$emit('synchro', {treeData:dataArr,shieldBackwardSwitch:this.shieldBackwardSwitch,isMultiagent:this.isMultiagent})
       }else{
+        // 勾选快手ID即默认同步其下全部账户:已加载的直接取子节点,未加载的调接口展开
         var dataArr = []
-        if(this.productId == 8640280){
-          for (let i = 0; i < data.length; i++) {
-            getAction('/ctop/userAllocation/getAccountIdListByUserId', {
-              userId: data[i].id.split('@')[1],
-            }).then((res) => {
-              dataArr.push(...res.result.map((item) => {
-                return {
-                  accountId:item.accountId,
-                  userId:data[i].id.split('@')[1],
+        var tasks = []
+        var coveredUserIds = []
+        data.forEach((item) => {
+          if (item.level !== 1) return
+          var userId = item.key.split('@')[1]
+          coveredUserIds.push(userId)
+          if (item.childNodes && item.childNodes.length > 0) {
+            item.childNodes.forEach((c) => {
+              dataArr.push({
+                accountId: c.key.split('@')[0],
+                userId: userId,
+              })
+            })
+          } else {
+            tasks.push(
+              getAction('/ctop/userAllocation/getAccountIdListByUserId', {
+                userId: userId,
+              }).then((res) => {
+                if (res.code == 0 && res.result) {
+                  res.result.forEach((r) => {
+                    dataArr.push({
+                      accountId: r.accountId,
+                      userId: userId,
+                    })
+                  })
                 }
-              }))
-
-               
+              })
+            )
+          }
+        })
+        // 未按快手ID全选、直接勾选的单个账户也一并带上
+        data.forEach((item) => {
+          if (item.level === 1) return
+          var userId = item.key.split('@')[1]
+          if (coveredUserIds.indexOf(userId) === -1) {
+            dataArr.push({
+              accountId: item.key.split('@')[0],
+              userId: userId,
             })
-            
           }
-          setTimeout(()=>{
-            this.showEdit = false
-            this.$emit('synchro', {treeData:dataArr,shieldBackwardSwitch:this.shieldBackwardSwitch,isMultiagent:this.isMultiagent})
-          },data.length*600)
-        }else{
-          dataArr = data.map(item=>{
-          
-              return {
-                accountId:item.id.split('@')[0],
-                userId:item.id.split('@')[1],
-              }
-
-          })
+        })
+        Promise.all(tasks).then(() => {
           this.showEdit = false
           this.$emit('synchro', {treeData:dataArr,shieldBackwardSwitch:this.shieldBackwardSwitch,isMultiagent:this.isMultiagent})
-        }
-         
-
+        })
       }
-      
-      // console.log(dataArr)
-     
-      
     },
     close() {
       // this.$refs.tree.setCheckedKeys([])
@@ -307,48 +315,42 @@ export default {
     },
     ...mapGetters(['nickname', 'avatar', 'userInfo']),
     update(node, id) {
-
-      
-      this.$nextTick(()=>{
-          // if(node.children.length>0){
-
-          // }else{
-            // getAction('/ctop/userAllocation/getAccountIdListByUserId', {
-            //   userId: node.id.split('@')[1],
-            // }).then((res) => {
-            //   console.log(res)
-            //   if (res.code == 0) {
-            //       if (res.result.length > 0&&node.children.length == 0) {
-            //         node.children = res.result.map((item) => {
-            //           return {
-            //             id: item.accountId,
-            //             label:
-            //               (item.userName.length == 2
-            //                 ? item.userName + '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0'
-            //                 : item.userName.length == 3
-            //                 ? item.userName + '\xa0\xa0\xa0\xa0'
-            //                 : item.userName) +
-            //               '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0' +
-            //               item.accountId +
-            //               '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0' +
-            //               item.authName,
-            //             disabled: this.isMultiagent,
-            //             children:null
-            //           }
-            //         })
-
-            //       } else {
-            //         node.children = null
-            //       }
-            //     } else {
-            //     }
-            // })
-          // }
-
-
+      // 开启"同步全部账户"后,勾选快手ID时自动加载并全选其下全部账户
+      if (!this.isMultiagent || node.level !== 1 || !node.checked) {
+        return
+      }
+      var userId = node.key.split('@')[1]
+      var tree = this.$refs.tree
+      if (node.childNodes && node.childNodes.length > 0) {
+        tree.setChecked(node.childNodes.map((c) => c.key), true)
+        return
+      }
+      getAction('/ctop/userAllocation/getAccountIdListByUserId', {
+        userId: userId,
+      }).then((res) => {
+        if (res.code == 0 && res.result && res.result.length > 0) {
+          var children = res.result.map((item) => {
+            return {
+              id: item.accountId + '@' + userId,
+              label:
+                (item.userName.length == 2
+                  ? item.userName + '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0'
+                  : item.userName.length == 3
+                  ? item.userName + '\xa0\xa0\xa0\xa0'
+                  : item.userName) +
+                '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0' +
+                item.accountId +
+                '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0' +
+                item.authName,
+              disabled: false,
+            }
+          })
+          tree.updateKeyChildren(node.key, children)
+          this.$nextTick(() => {
+            tree.setChecked(children.map((c) => c.id), true)
+          })
+        }
       })
-      
-
     },
     emitValue() {
       // this.$emit('update:appId', this.value)
@@ -414,7 +416,6 @@ export default {
               id: item.accountId+'@'+item.userId+'@'+item.userName,
               label: item.userId+'-'+item.projectName,
               children: [],
-              disabled:this.isMultiagent&&this.productId!=8640280
             }
           })
         } else {