• vue+elemenUI实现el-table-column行的上下移动


    最后实现的效果,如图所示,第一行的向上按钮不可操作,最后一行的向下按钮为不可操作。

    其实 vue的很多操作并不是对页面数据的操作,而是对数据源的操作,数据源发生变化,实时渲染页面,这样就达到了,我们的需求。上代码:

    <el-table :key='tableKey' :data="detaillist" border fit highlight-current-row
              style=" 100%">
      <el-table-column align="center" label="序号" width="65">
        <template slot-scope="scope">
          <span>{{ scope.$index + 1 }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="股道(号码)" width="145">
        <template slot-scope="scope">
          <span>{{scope.row.bztzdGdhm}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="操作">
        <template slot-scope="scope">
          <el-button
            size="mini"
            :disabled="scope.$index===0"
            @click="moveUp(scope.$index,scope.row)"><i class="el-icon-arrow-up"></i></el-button>
          <el-button
            size="mini"
            :disabled="scope.$index===(detaillist.length-1)"
            @click="moveDown(scope.$index,scope.row)"><i class="el-icon-arrow-down"></i></el-button>
          <el-button size="small" type="danger" @click="rowchilddel(scope.$index)">
            删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    这是数据的list----------> detaillist: [],
    //向上移动
    moveUp(index, row) {
      var that = this;
      console.log('上移', index, row);
      console.log(that.detaillist[index]);
      if (index > 0) {
        let upDate = that.detaillist[index - 1];
        that.detaillist.splice(index - 1, 1);
        that.detaillist.splice(index, 0, upDate);
      } else {
        alert('已经是第一条,不可上移');
      }
    },
    //向下移动
    moveDown(index, row) {
      var that = this;
      console.log('下移', index, row);
      if ((index + 1) === that.detaillist.length) {
        alert('已经是最后一条,不可下移');
      } else {
        console.log(index);
        let downDate = that.detaillist[index + 1];
        that.detaillist.splice(index + 1, 1);
        that.detaillist.splice(index, 0, downDate);
      }
    },
  • 相关阅读:
    django + scrapy 部署
    scrapyd 爬虫部署
    爬虫部署
    使用Scrapy爬取图片入库,并保存在本地
    学习Spider 了解 Scrapy的流程
    Django 的 一些基本操作:视图函数,路由配置
    Django 了解
    sql
    嚯嚯~ module 1
    Long Way To Go 之 Python 5 (2)
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13300600.html
Copyright © 2020-2023  润新知