yichenxi
2022-12-12 936633659148e800a8d09322a9f1e646104010a7
src/views/personnel/role.vue
@@ -151,7 +151,8 @@
        children: 'children',
        label: 'label'
      },
      visibleDel: false
      visibleDel: false,
      parentIds: []
    }
  },
  // 计算属性 类似于data概念
@@ -269,6 +270,12 @@
        // console.log('当前组织下的菜单列表')
        // console.log(res)
        this.menuData = res.data.menus
        // 拿到所有的父id
        this.parentIds = []
        res.data.menus.map(v => {
          this.parentIds.push(v.id)
        })
        this.parentIds = JSON.parse(JSON.stringify(this.parentIds))
      }).catch(err => {
        console.log(err)
      })
@@ -287,8 +294,16 @@
      }).then(res => {
        // console.log('当前角色的菜单列表')
        // console.log(res)
        this.checkedData = res.data
        console.log(this.checkedData)
        var allIds = res.data
        // 过滤父id
        for (let i = 0; i < allIds.length; i++) {
          for (let j = 0; j < this.parentIds.length; j++) {
            if (allIds[i] === this.parentIds[j]) {
              allIds.splice(i, 1)
            }
          }
        }
        this.checkedData = allIds
      }).catch(err => {
        console.log(err)
      })
@@ -300,10 +315,10 @@
        method: 'post',
        data: {
          groupId: this.currentGroupId,
          menuIds:this.$refs.tree.getCheckedKeys()
          menuIds: this.$refs.tree.getCheckedKeys().concat(this.$refs.tree.getHalfCheckedKeys())
          // menuIds: this.$refs.tree.getCheckedKeys()
        }
      }).then(res => {
        console.log(res)
        if (res.code === 0) {
          this.$message({
            message: '保存成功',