第一部分, 列表(表格)页面内容
包含功能
代码部分
<template>
<div class="page">
<el-form :inline="true" :model="search" class="searchForm">
<el-form-item>
<el-input v-model="search.keyword1" placeholder="请输入关键字"></el-input>
</el-form-item>
<el-form-item label="关键字">
<el-input v-model="search.keyword2" placeholder="请输入关键字2"></el-input>
</el-form-item>
<el-form-item label="状态">
<el-select v-model="search.state" placeholder="请选择">
<el-option label="状态一" value="1"></el-option>
<el-option label="状态二" value="2"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" size="mini" @click="onSubmitSearch">查询</el-button>
</el-form-item>
</el-form>
<el-table :data="tableData" stripe style="width: 100%">
<template v-for="(val, key) in tableColumn">
<el-table-column :key="key" :prop="val.prop" :label="val.label" :width="val.width" :align="val.align"></el-table-column>
</template>
<el-table-column fixed="right" label="操作" width="100" align="center">
<template slot-scope="scope">
<el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
<el-button type="text" size="small">编辑</el-button>
</template>
</el-table-column>
</el-table>
<div class="pagination">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="page.currentPage"
:page-sizes="[10, 20, 50, 100]"
:page-size="page.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="page.total"
>
</el-pagination>
</div>
</div>
</template>
<script>
export default {
name: "tableBase",
data() {
return {
search: {
keyword1: "",
keyword2: "",
state: undefined,
},
page: {
currentPage: 1,
pageSize: 10,
total: 3,
},
tableData: [
{ id: 1, name: "用户名1", sex: 1, time: "2021-10-20 20:00:00" },
{ id: 2, name: "用户名2", sex: 2, time: "2021-10-20 20:00:00" },
{ id: 3, name: "用户名3", sex: 1, time: "2021-10-20 20:00:00" },
],
tableColumn: [
{ label: "编号", prop: "id", width: "80px", align: "left" },
{ label: "用户名", prop: "name", width: "100px" },
{ label: "性别", prop: "sex", width: "100px" },
{ label: "创建时间", prop: "time" },
],
};
},
created() {
},
mounted() {
this.$nextTick(() => {
this.getTableData();
});
},
methods: {
onSubmitSearch() {
this.getTableData();
},
getTableData() {
let params = {};
params = Object.assign(params, this.page);
if (this.search.keyword1) {
params["keyword1"] = this.search.keyword1;
}
},
handleSizeChange(val) {
this.page.pageSize = val;
this.getTableData();
},
handleCurrentChange(val) {
this.page.currentPage = val;
this.getTableData();
},
},
};
</script>
<style lang="scss" scoped>
.page {
padding: 10px;
.pagination {
padding-top: 10px;
display: flex;
justify-content: flex-end;
align-items: center;
}
}
</style>
结尾
还有具体行操作方法页面 看得人多或者点赞多的话后面会写出来 代码中还有不足的地方, 可以在评论中指出来, 博主有空的话会更正的
|