yijiusmile
2021-03-31 0d2a48248d27a5b17743865bb9529bbf31543209
src/views/febs/system/role/Index.vue
@@ -175,8 +175,18 @@
    edit(row) {
      this.$refs.form.clearValidate()
      this.role = { ...row }
      var this_ = this
      if (this.role.menuIds) {
        this.$refs.permsTree.setCheckedKeys(this.role.menuIds.split(','))
        var deptIdArrStr = []
        this.role.menuIds.split(',').forEach(element => {
          const thisNode = this_.$refs.permsTree.getNode(element) // 获取当前节点
          if (thisNode.childNodes.length === 0) {
            deptIdArrStr.push(thisNode.data.id)
            return
          }
        })
        this.$refs.permsTree.setCheckedKeys(deptIdArrStr)
        // this.$refs.permsTree.setCheckedKeys(this.role.menuIds.split(','))
      } else {
        this.$refs.permsTree.setCheckedKeys([])
      }
@@ -222,7 +232,7 @@
        if (valid) {
          this.buttonLoading = true
          if (this.role.roleId) {
            this.role.menuIds = this.$refs.permsTree.getCheckedKeys().join(',')
            this.role.menuIds = this.$refs.permsTree.getCheckedKeys().concat(this.$refs.permsTree.getHalfCheckedKeys()).join(',')
            this.role.createTime = this.role.modifyTime = null
            this.$put('system/role', { ...this.role }).then(() => {
              this.buttonLoading = false
@@ -233,7 +243,7 @@
              this.reset()
            })
          } else {
            this.role.menuIds = this.$refs.permsTree.getCheckedKeys().join(',')
            this.role.menuIds = this.$refs.permsTree.getCheckedKeys().concat(this.$refs.permsTree.getHalfCheckedKeys()).join(',')
            this.$post('system/role', { ...this.role }).then(() => {
              this.buttonLoading = false
              this.$message({
@@ -313,4 +323,3 @@
    }
  }
</style>