统一表格分页样式

This commit is contained in:
q4speed 2020-04-10 16:23:38 +08:00
parent 026a03c21d
commit a116bfe8ab
3 changed files with 78 additions and 47 deletions

View File

@ -7,11 +7,11 @@
<el-row type="flex" justify="space-between" align="middle"> <el-row type="flex" justify="space-between" align="middle">
<span class="title">{{$t('commons.test')}}</span> <span class="title">{{$t('commons.test')}}</span>
<span class="search"> <span class="search">
<el-input type="text" size="small" :placeholder="$t('load_test.search_by_name')" <el-input type="text" size="small" :placeholder="$t('load_test.search_by_name')"
prefix-icon="el-icon-search" prefix-icon="el-icon-search"
maxlength="60" maxlength="60"
v-model="condition" @change="search" clearable/> v-model="condition" @change="search" clearable/>
</span> </span>
</el-row> </el-row>
</div> </div>
</template> </template>
@ -56,34 +56,21 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<div> <ms-table-pagination :change="search" :current-page.sync="currentPage" :page-size.sync="pageSize"
<el-row> :total="total"/>
<el-col :span="22" :offset="1">
<div class="table-page">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page.sync="currentPage"
:page-sizes="[5, 10, 20, 50, 100]"
:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
</el-pagination>
</div>
</el-col>
</el-row>
</div>
</el-card> </el-card>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import MsTablePagination from "../../common/pagination/TablePagination";
export default { export default {
components: {MsTablePagination},
data() { data() {
return { return {
result: {}, result: {},
queryPath: "/api/list",
deletePath: "/api/delete", deletePath: "/api/delete",
condition: "", condition: "",
projectId: null, projectId: null,
@ -99,15 +86,15 @@
watch: { watch: {
'$route'(to) { '$route'(to) {
this.projectId = to.params.projectId; this.projectId = to.params.projectId;
this.initTableData(); this.search();
} }
}, },
created: function () { created: function () {
this.projectId = this.$route.params.projectId; this.projectId = this.$route.params.projectId;
this.initTableData(); this.search();
}, },
methods: { methods: {
initTableData() { search() {
let param = { let param = {
name: this.condition, name: this.condition,
}; };
@ -116,26 +103,13 @@
param.projectId = this.projectId; param.projectId = this.projectId;
} }
this.result = this.$post(this.buildPagePath(this.queryPath), param, response => { let url = "/api/list/" + this.currentPage + "/" + this.pageSize
this.result = this.$post(url, param, response => {
let data = response.data; let data = response.data;
this.total = data.itemCount; this.total = data.itemCount;
this.tableData = data.listObject; this.tableData = data.listObject;
}); });
}, },
search() {
this.initTableData();
},
buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize;
},
handleSizeChange(size) {
this.pageSize = size;
this.initTableData();
},
handleCurrentChange(current) {
this.currentPage = current;
this.initTableData();
},
handleSelectionChange(val) { handleSelectionChange(val) {
this.multipleSelection = val; this.multipleSelection = val;
}, },
@ -176,9 +150,5 @@
width: 100%; width: 100%;
} }
.table-page {
padding-top: 20px;
margin-right: -9px;
float: right;
}
</style> </style>

View File

@ -40,7 +40,9 @@
}, },
getRouter: function () { getRouter: function () {
return function (item) { return function (item) {
return this.options.router(item); if (this.options.router) {
return this.options.router(item);
}
} }
} }
} }

View File

@ -0,0 +1,59 @@
<template>
<el-row type="flex" justify="end">
<div class="table-page">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-sizes="pageSizes"
:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
</el-pagination>
</div>
</el-row>
</template>
<script>
export default {
name: "MsTablePagination",
props: {
page: Object,
currentPage: {
type: Number,
default: 1
},
pageSize: {
type: Number,
default: 5
},
pageSizes: {
type: Array,
default: function () {
return [5, 10, 20, 50, 100]
}
},
total: {
type: Number,
default: 0
},
change: Function
},
methods: {
handleSizeChange: function (size) {
this.$emit('update:pageSize', size)
this.change();
},
handleCurrentChange(current) {
this.$emit('update:currentPage', current)
this.change();
}
}
}
</script>
<style scoped>
.table-page {
padding-top: 20px;
}
</style>