首页 > 其他 > 详细

vue自定义元素拖动

时间:2019-06-25 11:25:14      阅读:210      评论:0      收藏:0      [点我收藏+]

岗位序列拖动交换岗位

<span
            draggable="true"
            @dragstart="onDragstart($event,index,index2)"
            @dragend="onDragend($event)"
            @dragover="onDragover($event)"
            @drop="onDrop($event,index,index2)"
            slot="reference"
            @click="showPositonEdit(sequence,index)"
            :class="['el-btn-position',sequence.showNodes.length>=2?'el-btn-position-plus':'',sequence.showItem.showPosTag?'position_tag':'']"
            :style="{zIndex:sequence.showItem.highLightIndex?'6':'auto'}"
            :title="sequence.showNodes.length>=2?'':sequence.showItem.positionName"
          >
            {{sequence.showItem.positionName.substring(0,6)}}
            <span
              v-if="sequence.showNodes.length>=2 && !sequence.showItem.showPosTag"
              class="icon_num"
            >{{sequence.showNodes.length}}</span>
          </span>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// 拖动
    onDragstart (e, index, index2) {
      this.tempDragObj = {}
      this.dragObj.fromMapId = ''
      this.dragObj.toGradeId = ''
      this.dragObj.toSeriesId = ''
      const { pid } = this.queryId(index, index2)
      this.dragObj.fromMapId = pid
    },
    async onDragend (e) {
      if (this.dragFlag) {
        await movePosition(this.dragObj).catch(e => console.error(e))
        await this.getMap(this.id).catch(e => console.error(e))
        // 行为日志
        let logData = {
          method: this.METHOD.MODIFY,
          description: this.DESCRIPTION.SINGLE,
          referstr1: this.dragObj,
          logcontent: '拖拽岗位交换位置'
        }
        this.sendBehaviorLog(logData)
        // this.dragFlag = false
        this.$emit('update:dragFlag', false)
      }
    },
    onDragover (e) {
      e.preventDefault()
    },
    onDrop (e, index, index2) {
      // this.dragFlag = true
      this.$emit('update:dragFlag', true)
      const { sequenceId, gradeId } = this.queryId(index, index2)
      this.dragObj.toGradeId = gradeId
      this.dragObj.toSeriesId = sequenceId
    },

vue自定义元素拖动

原文:https://www.cnblogs.com/raind/p/11081325.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!