SPA项目开发之动态树+分页数据表格

目录

1.Element UI动态树

2.数据表格 

3.分页与条件查询


1.Element UI动态树

向后台发送请求,获取数据,然后渲染到页面中

<template>
	<el-menu router :default-active="$route.path"  default-active="2" class="el-menu-vertical-demo" background-color="#334157" text-color="#fff"
	 active-text-color="#ffd04b" :collapse="collapsed">
		<!-- <el-menu default-active="2" :collapse="collapsed" collapse-transition router :default-active="$route.path" unique-opened class="el-menu-vertical-demo" background-color="#334157" text-color="#fff" active-text-color="#ffd04b"> -->
		<div class="logobox">
			<img class="logoimg" src="" alt="">
		</div>
		<el-submenu :index="m.treeNodeId" v-for="m in tree">
			<template slot="title">
				<i :class="m.icon"></i>
				<span>{{m.treeNodeName}}</span>
			</template>
			<el-menu-item :key="m1.treeNodeId" :index="m1.url" v-for="m1 in m.children">
				<i :class="m1.icon"></i>
				<span>{{m1.treeNodeName}}</span>
			</el-menu-item>
		</el-submenu>
	</el-menu>
</template>
<script>
	export default {
		data() {
			return {
				collapsed: false,
				tree: []

			}
		},
		created() {
			/* 向后台发送请求 */
			let url = this.axios.urls.SYSTEM_MENU_TREE;
			this.axios.post(url, {}).then((resp) => {
			/* 	将后台返回的数据给数组然后遍历 */
				this.tree = resp.data.result
			}).catch(function(error) {
				console.log(error);
			});
			this.$root.bus.$on("collapsed-aside", (v) => {
				this.collapsed = v;
			});
		}
	}
</script>
<style>
	.el-menu-vertical-demo:not(.el-menu--collapse) {
		width: 240px;
		min-height: 400px;
	}

	.el-menu-vertical-demo:not(.el-menu--collapse) {
		border: none;
		text-align: left;
	}

	.el-menu-item-group__title {
		padding: 0px;
	}

	.el-menu-bg {
		background-color: #1f2d3d !important;
	}

	.el-menu {
		border: none;
	}

	.logobox {
		height: 40px;
		line-height: 40px;
		color: #9d9d9d;
		font-size: 20px;
		text-align: center;
		padding: 20px 0px;
	}

	.logoimg {
		height: 40px;
	}
</style>

在Element UI中 index为跳转路径  key相当于唯一标识列 

表数据

 后台数据层级结构使用的是hibernat懒加载

页面显示

2.数据表格 

2,1表格组件

<el-form :inline="true" :model="formInline" class="user-search">
			<el-form-item label="搜索:">
				<el-input size="small" v-model="formInline.title" placeholder="输入文章标题"></el-input>
			</el-form-item>
			<el-form-item>
				<el-button size="small" type="primary" icon="el-icon-search" @click="search">搜索</el-button>
			</el-form-item>
		</el-form>
		<el-table :data="result" style="width: 100%;" :border="true" max-height="550">
			<el-table-column prop="id" label="ID" min-width="10" align="center"></el-table-column>
			<el-table-column prop="title" label="标题" min-width="20"></el-table-column>
			<el-table-column prop="body" label="内容" min-width="70"></el-table-column>
		</el-table>

 2.2数据加载

dosearch(param) {
				let url = this.axios.urls.SYSTEM_ARTICLE_LIST;
				this.axios.post(url, param).then((resp) => {
					console.log(resp);
					this.result = resp.data.result;
					this.formInline.total = resp.data.pageBean.total;
				}).catch(function(error) {
					console.log(error);
				});
			}
		},
		created() {
			this.dosearch({});

		}

页面效果

 

3.分页与条件查询

Element UI分页条

<el-pagination style="margin-top: 20px;" @size-change="handleSizeChange" @current-change="handleCurrentChange"
		 :current-page="formInline.page" :page-sizes="[10, 20, 30, 50]" :page-size="100" layout="total, sizes, prev, pager, next, jumper"
		 :total="formInline.total">
		</el-pagination>

 定义初始值与方法

data() {
			return {
				result: [],
				formInline: {
					page: 1,
					total: 0,
					rows: 10,
					title: '',
				}
			}
		},
		methods: {
			/* 每页条数方法 */
			handleSizeChange(rows) {
				this.formInline.page = 1;
				this.formInline.rows = rows;
				this.search();
			},
			/* 当前页数方法 */
			handleCurrentChange(page) {
				this.formInline.page = page;
				this.search();
			},
			/* 当点击上一页,下一页,更换每页条数时将所有参数带上调用方法, */
			search() {
				this.dosearch(this.formInline);
			},

 结果

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值