孔祥富
2021-03-18 2402f7902663a20fe1b66f4305abb5ba05d7016f
src/views/febs/system/user/Edit.vue
@@ -66,7 +66,6 @@
        <el-tree
          ref="deptTree"
          :data="deptTree"
          :check-strictly="false"
          :default-checked-keys="user.deptIdsArr"
          show-checkbox
          accordion
@@ -250,8 +249,23 @@
      })
    },
    setUser(val) {
      setTimeout(() => {
        this.filterDate(val)
      }, 1000)
    },
    filterDate(val) {
      var this_ = this
      this.user = { ...val }
      this.user.deptIds && (this.user.deptIdsArr = this.user.deptIds.split(','))
      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)
    },
    close() {
      this.$emit('close')
@@ -290,7 +304,7 @@
        if (valid) {
          this.buttonLoading = true
          this.user.roleId = this.user.roleId.join(',')
          this.user.deptIds = this.$refs.deptTree.getCheckedKeys()
          this.user.deptIds = this.$refs.deptTree.getCheckedKeys().concat(this.$refs.deptTree.getHalfCheckedKeys())
          if (!this.user.userId) {
            // create
            this.$post('system/user', { ...this.user }).then(() => {