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: "處于頂端叠纷,不能繼續(xù)上移",
? ? ? ? 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: "處于末端端尽爆,不能繼續(xù)下移",
? ? ? ? type: "warning"
? ? ? });
? ? } else {
? ? ? let downDate = that.prodata[index + 1];
? ? ? that.prodata.splice(index + 1, 1);
? ? ? that.prodata.splice(index, 0, downDate);
? ? }
? }