vue+elementui tree 同级拖拽功能

目录树是懒加载的

上代码:

allowDrop(draggingNode, dropNode, type){
      if (draggingNode.data.level === dropNode.data.level) {
        if (draggingNode.data.aboveId === dropNode.data.aboveId) {
          return type === 'prev' || type === 'next'
        }
      } else {
        // 不同级进行处理
        return false
      }
},
sort(draggingNode,dropNode,type,event) {
      /* console.log('排序')
      console.log(dropNode)   //dropNode.parent.childNodes =[] 拖拽之后的重新组合的数组 */
      let obj = {
        aboveId:'',
        arr:[]
      }
      obj.aboveId = dropNode.data.aboveId
      for (let item of dropNode.parent.childNodes) {
        obj.arr.push(item.data.id)
      }
      this.updateOrderMe(obj)
},
updateOrderMe(obj) {
      this.$http.post('url', {aboveId:obj.aboveId,ids: obj.arr}).then(res =>{
	        if (!res.data.success) {
	          this.$message.warning(res.data.msg)
	        }
        })
}

猜你喜欢

转载自blog.csdn.net/weixin_43173924/article/details/89372926