2023-03-07 15:29:08 +08:00
|
|
|
<template>
|
2023-03-07 15:34:43 +08:00
|
|
|
<!-- <ListViewWithHead :table-configs="tableConfigs" :head-config="headFormConfigs" :dialog-configs="dialogConfigs" /> -->
|
|
|
|
<div style="padding: 16px; background: #fff; border-radius: 8px">
|
|
|
|
<el-table :data="dataList">
|
|
|
|
<el-table-column key="id" prop="id" label="ID"></el-table-column>
|
|
|
|
<el-table-column key="name" prop="name" label="名字"></el-table-column>
|
|
|
|
<el-table-column key="age" prop="age" label="年龄"></el-table-column>
|
|
|
|
<el-table-column key="opt" label="操作">
|
|
|
|
<template slot-scope="scope">
|
|
|
|
<el-button @click.native.prevent="handleUp(scope)">up</el-button>
|
|
|
|
<el-button @click.native.prevent="handleDown(scope)">down</el-button>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
</el-table>
|
|
|
|
</div>
|
2023-03-07 15:29:08 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-03-07 15:34:43 +08:00
|
|
|
import initConfig from "./config";
|
|
|
|
// import ListViewWithHead from "./components/ListViewWithHead.vue";
|
2023-03-07 15:29:08 +08:00
|
|
|
|
|
|
|
export default {
|
2023-03-07 15:34:43 +08:00
|
|
|
name: "OrderView",
|
|
|
|
// components: { ListViewWithHead },
|
|
|
|
provide() {
|
|
|
|
return {
|
|
|
|
urls: this.allUrls,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
// const { tableConfigs, headFormConfigs, urls, dialogConfigs } = initConfig.call(this);
|
|
|
|
// return {
|
|
|
|
// tableConfigs,
|
|
|
|
// headFormConfigs,
|
|
|
|
// allUrls: urls,
|
|
|
|
// dialogConfigs,
|
|
|
|
// };
|
|
|
|
return {
|
|
|
|
dataList: [
|
|
|
|
{ id: 1, name: "张三", age: 12 },
|
|
|
|
{ id: 2, name: "李四", age: 13 },
|
|
|
|
{ id: 3, name: "王五", age: 14 },
|
|
|
|
{ id: 4, name: "陈鼻", age: 15 },
|
|
|
|
{ id: 5, name: "肖上唇", age: 16 },
|
|
|
|
],
|
|
|
|
limit: 20
|
|
|
|
};
|
|
|
|
},
|
|
|
|
created() {},
|
|
|
|
mounted() {},
|
|
|
|
methods: {
|
|
|
|
handleUp({ $index, row }) {
|
|
|
|
console.log("row: ", $index, row);
|
|
|
|
// const { id } = row;
|
|
|
|
// const index = this.dataList.findIndex((o) => o.id === id);
|
|
|
|
// console.log("index: ", index);
|
|
|
|
if ($index === 0) return;
|
|
|
|
const [item] = this.dataList.splice($index, 1);
|
|
|
|
console.log("item: ", item);
|
|
|
|
this.dataList.splice($index - 1, 0, item);
|
|
|
|
console.log("dataList: ", this.dataList);
|
|
|
|
// this.dataList
|
|
|
|
},
|
|
|
|
handleDown({ $index, row }) {
|
|
|
|
// const { id } = row;
|
|
|
|
if ($index === this.limit) return;
|
|
|
|
const [item] = this.dataList.splice($index, 1);
|
|
|
|
this.dataList.splice($index + 1, 0, item);
|
|
|
|
},
|
|
|
|
},
|
2023-03-07 15:29:08 +08:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped></style>
|