zoukankan      html  css  js  c++  java
  • 表格行拖动,数据中状态值不同的禁止拖拽

    rowDrop () {
          const tbody = document.querySelector('.el-table__body-wrapper tbody')
          const _this = this
          let sort = Sortable.create(tbody, {
            forceFallback: false,
            onMove: (evt, originalEvent) => {
              // 出现非发布和已发布,立即还原交换
              if (_this.initTableData[evt.dragged.rowIndex].status != _this.initTableData[evt.related.rowIndex].status) {
                return false
              }
            },
            onEnd ({ newIndex, oldIndex }) {
              let newRow = _this.initTableData[newIndex]
              let oldRow = _this.initTableData[oldIndex]
              const currRow = _this.initTableData.splice(oldIndex, 1)[0]
              if (!newRow) {
                let index = _this.initTableData.length - 1
                let sort = _this.initTableData[index].sequence
                currRow.sequence = sort + 1
                _this.initTableData.splice(oldIndex, 0, currRow)
                return
              }
              let old = newRow.sequence
              let current = currRow.sequence
              currRow.sequence = old   //交换顺序
              newRow.sequence = current
              _this.initTableData.splice(newIndex, 0, currRow)
              _this.temp.push(currRow)
              _this.temp.push(newRow)
              _this.$emit('update:initTableData', _this.initTableData)
            }
          })
        },
    

      

  • 相关阅读:
    LintCode A+B问题
    LintCode 斐波纳契数列
    LintCode 删除链表中的元素
    LintCode 整数排序
    c++ lower_bound upper_bound
    259. 3Sum Smaller
    86. Partition List
    209. Minimum Size Subarray Sum
    11. Container With Most Water
    360. Sort Transformed Array
  • 原文地址:https://www.cnblogs.com/ihuangqing/p/11599186.html
Copyright © 2011-2022 走看看