html代码

 <el-table  :data="prodata">
	<el-table-column align="center" label="操作">
	   <template slot-scope="scope">
	     <el-button  @click="upLayer(scope.$index,scope.row)">上移</el-button>
	     <el-button  @click="downLayer(scope.$index,scope.row)" >下移 </el-button>
	   </template>
	 </el-table-column>
 </el-table>

js代码

upLayer(index, row) {
     var that = this;
     if (index == 0) {
       that.$message({
         message: "处于顶端,不能继续上移",
         type: "warning"
       });
     } else {
       let upDate = that.prodata[index - 1];
       that.prodata.splice(index - 1, 1);
       that.prodata.splice(index, 0, upDate);
     }
   },
   downLayer(index, row) {
     var that = this;
     if (index + 1 === that.prodata.length) {
       that.$message({
         message: "处于末端端,不能继续下移",
         type: "warning"
       });
     } else {
       let downDate = that.prodata[index + 1];
       that.prodata.splice(index + 1, 1);
       that.prodata.splice(index, 0, downDate);
     }
   }
Logo

前往低代码交流专区

更多推荐