孔祥富
2021-03-14 680c4f9e4e8b079593c8e57c100b92890e70960d
src/views/febs/system/user/Edit.vue
@@ -66,6 +66,7 @@
        <el-tree
          ref="deptTree"
          :data="deptTree"
          :check-strictly="false"
          :default-checked-keys="user.deptIdsArr"
          show-checkbox
          accordion
@@ -249,23 +250,8 @@
      })
    },
    setUser(val) {
      setTimeout(() => {
        this.filterDate(val)
      }, 1000)
    },
    filterDate(val) {
      var this_ = this
      this.user = { ...val }
      var deptIdArrStr = []
      this.user.deptIds.split(',').forEach(element => {
        const thisNode = this_.$refs.deptTree.getNode(element) // 获取当前节点
        if (thisNode.childNodes.length === 0) {
          deptIdArrStr.push(thisNode.data.id)
          return
        }
      })
      this.user.deptIds && (this.user.deptIdsArr = deptIdArrStr)
      this.user.deptIds && (this.user.deptIdsArr = this.user.deptIds.split(','))
    },
    close() {
      this.$emit('close')
@@ -304,7 +290,7 @@
        if (valid) {
          this.buttonLoading = true
          this.user.roleId = this.user.roleId.join(',')
          this.user.deptIds = this.$refs.deptTree.getCheckedKeys().concat(this.$refs.deptTree.getHalfCheckedKeys())
          this.user.deptIds = this.$refs.deptTree.getCheckedKeys()
          if (!this.user.userId) {
            // create
            this.$post('system/user', { ...this.user }).then(() => {