index.vue

<template>
<div>
<el-table ref="multipleTable" :data="tableData" border style="width: 100%" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="60"></el-table-column>
<el-table-column prop="eNumber" label="企业编号" width="180" sortable></el-table-column>
<el-table-column prop="eName" label="企业名称" show-overflow-tooltip></el-table-column>
<el-table-column prop="eIndustry" label="所属行业" width="180"></el-table-column>
<el-table-column prop="eRange" label="经营范围" width="180"></el-table-column>
<el-table-column prop="eModel" label="经营模式" width="180"></el-table-column>
<el-table-column prop="createTime" label="创建日期" width="180"></el-table-column>
<el-table-column prop="updateTime" label="更新日期" width="180"></el-table-column>
<el-table-column prop="recordStatus" label="企业状态" width="180"></el-table-column>
</el-table>
<el-pagination background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-sizes="[10, 50, 100, 200]"
:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
</el-pagination>
</div>
</template>
<script>
export default {
data() {
return {
keyword: "集团",
total: 5,
currentPage: 1,
          pageSize: 10,
tableData: [{
eNumber: 'A10001',
eName: 'YE集团',
eIndustry: '金融业',
eRange: '商业',
eModel: '国有企业',
createTime: '2017-03-27',
updateTime: '2016-03-27',
recordStatus: '1'
}],
multipleSelection: []
}
},
created: function(){
// 组件创建完后获取数据,
// 此时 data 已经被 observed 了
this.fetchData();
},
methods: {
toggleSelection(rows) {
if (rows) {
rows.forEach(function(row) {
this.$refs.multipleTable.toggleRowSelection(row);
});
} else {
this.$refs.multipleTable.clearSelection();
}
},
handleSelectionChange(val) {
this.multipleSelection = val;
},
callbackFunction(result) {
alert(result + "aaa");
},
fetchData(){ //获取数据
this.$http.jsonp("http://localhost:8080/wproject/view/enterprise!getListByParam.action",{//跨域请求数据
params: {
keywords:this.keyword//输入的关键词
},
jsonpCallback:'callbackFunction'//这里是callback
}).then(function(res) {//请求成功回调,请求来的数据赋给searchList数组
this.total = res.body.count;
this.currentPage = res.body.curr;
this.tableData = res.body.data;
console.info(res);
},function(res) {//失败显示状态码
alert("res.status:"+res.status)
})
},
            handleSizeChange(val){
              this.pageSize = val;
              this.currentPage = 1;
              this.fetchData(1, val);
              // console.log(`每页 ${val} 条`);
            },
            handleCurrentChange(val){
              this.currentPage = val;
              this.fetchData(val, this.pageSize);
              // console.log(`当前页: ${val}`);
            }
 
    }
}
</script>
<style>
.el-table th {
text-align: center;
} .el-table tbody tr td:first-child {
text-align: center;
}
</style>

附上Java后台模拟数据接口代码:

/*jsonp调用接口方法*/
public void getListByParam() {
try {
System.out.println("调用getListByParam方法");
String callbackFunName = request.getParameter("callback");
String keywords = request.getParameter("keywords");
int curPage = Integer.parseInt(request.getParameter("curr"));
int pageSize = Integer.parseInt(request.getParameter("pageSize"));
List<Enterprise> enterList = enterpriseService.findAllByParam(keywords, curPage, pageSize);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//创建JSONObject对象
JSONObject result = new JSONObject();
//创建JSONArray实例
JSONArray jsonArray = new JSONArray();
//for each循环取出每个User对象
for(int i=0; i<enterList.size(); i++) {
Enterprise etpr = enterList.get(i);
//JSONObject是一个{}包裹起来的一个对象(Object),
//JSONArray则是[]包裹起来的一个数组(Array)
//此处为对象,所以用得到JSONObject
JSONObject jo = new JSONObject();
jo.put("eId", etpr.geteId());
jo.put("eNumber", etpr.getEnterpriseNumber());
jo.put("eName", etpr.getEnterpriseName());
if(etpr.getEnterpriseIndustry().equals("1")){
jo.put("eIndustry", "金融业");
} else if(etpr.getEnterpriseIndustry().equals("2")){
jo.put("eIndustry", "IT业");
} else if(etpr.getEnterpriseIndustry().equals("3")){
jo.put("eIndustry", "工业");
} else if(etpr.getEnterpriseIndustry().equals("4")){
jo.put("eIndustry", "农林牧渔业");
} else {
jo.put("eIndustry", "");
}
jo.put("eRange", etpr.getEnterpriseRange());
jo.put("eModel", etpr.getEnterpriseModel());
jo.put("createTime", formatter.format(etpr.getCreateTime()));
jo.put("updateTime", formatter.format(etpr.getUpdateTime()));
jo.put("recordStatus", etpr.getRecordStatus());
jsonArray.add(jo);
}
result.put("code", "0");
result.put("msg", "");
result.put("count", enterList.size());
result.put("curr", curPage);
result.put("limit", pageSize);
result.put("data", jsonArray);
System.out.println("enterList.size(): " + enterList.size());
System.out.println("curPage: " + curPage);
System.out.println("pageSize: " + pageSize);
//设置字符集
response.setCharacterEncoding("UTF-8");
//页面输出
PrintWriter out = response.getWriter();
out.write(callbackFunName + "(" + result.toString() + ")");
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}

elementUI动态数据表格(带分页)的更多相关文章

  1. SPA项目开发之动态树以及数据表格和分页

    首先我们来看下数据库 t_vue_user t_vue_tree_node t_vue_articles 2. 动态生成NavMenu导航菜单(只支持2级菜单) <el-menu key=&qu ...

  2. SPA项目开发动态树、数据表格、分页功能

    SPA项目开发 1.修改左侧动态树 LeftNav.vue <template> <el-menu router :" class="el-menu-vertic ...

  3. layui动态数据表格-分页

    数据结构 $list = [ [,'], [,] ]; $json[; $json['; $json[; $json['data'] = $list; return json($json); 代码: ...

  4. ExtJS4.2学习(20)动态数据表格之前几章总结篇1(转)

    鸣谢:http://www.shuyangyang.com.cn/jishuliangongfang/qianduanjishu/2014-02-18/196.html --------------- ...

  5. vue+mock.js+element-ui模拟数据搞定分页

    效果如图: 前提是搭好vue前端框架,npm install mockjs引入mock.js 当前页全部代码如下,其他有关element-ui的引入未提到,仅作参考用 <!-- 用户管理 --& ...

  6. layui数据表格及分页

    一.前端部分 html只需要放一个有id的div就行了,方便js获取渲染区域 <div id="data_grid" lay-filter="demo" ...

  7. easyui combogrid下拉表格的分页/按键/动态搜索

    作者:xfl4629712  <  easyui combogrid下拉表格的分页/按键/动态搜索  > 需求: 1.下拉框下拉时出现表格: 2.表格带分页功能: 3.可以使用向上键.向下 ...

  8. layui 数据表格+分页+搜索+checkbox+缓存选中项数据

    在做数据表格的时候遇到了很多坑, 今天整理一下方便以后使用. 主要功能是使用数据表格, 做分页,做搜索,  还有checkbox,  支持全选. 当选中一些数据的时候, 数据切换页面数据在切换回来后, ...

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

    SPA项目开发之动态树+数据表格+分页 动态生成NavMenu导航菜单(只支持2级菜单) <el-menu key="" index=""> < ...

随机推荐

  1. leetcode 62. Unique Paths 、63. Unique Paths II

    62. Unique Paths class Solution { public: int uniquePaths(int m, int n) { || n <= ) ; vector<v ...

  2. LeetCode_35. Search Insert Position

    35. Search Insert Position Easy Given a sorted array and a target value, return the index if the tar ...

  3. LeetCode_26. Remove Duplicates from Sorted Array

    26. Remove Duplicates from Sorted Array Easy Given a sorted array nums, remove the duplicates in-pla ...

  4. (二)UML之类图、接口、包

    一.概念 类图(Class Diagram): 类图是面向对象系统建模中最常用和最重要的图,是定义其它图的基础.类图主要是用来显示系统中的类.接口以及它们之间的静态结构和关系的一种静态模型. 类图的3 ...

  5. c# 如何给 dataGridView里添加一个自增长列(列名为序号)

    System.Data.DataTable table = new DataTable();                System.Data.DataColumn column = new Da ...

  6. vue中添加less配置,用于计算div高度

    需求:左边垂直的菜单栏高度设置为 100% - 导航栏的高度(3.6rem) 首先,从vue-cli脚手架里的安装的webpack模板中并没有less的依赖配置,得自己手动添加安装 安装命令::npm ...

  7. 学习JavaScript之this,call,apply(转)

    转自: http://www.h5cn.com/js/jishu/2016/0128/17884.html 在之前的JavaScript学习中,this,call,apply总是让我感到迷惑,但是他们 ...

  8. python map函数(23)

    截至到目前为止,其实我们已经接触了不少的python内置函数,而map函数也是其中之一,map函数是根据指定函数对指定序列做映射,在开发中使用map函数也是有效提高程序运行效率的办法之一. 一.语法定 ...

  9. 【转】Entity Framework简介

    Entity Framework Core 可基于现有数据库创建模型,也可基于模型创建数据库. 以下文字来源于:http://www.entityframeworktutorial.net/what- ...

  10. 如何查看USB是不是3.0版本

    打开设备管理器 找到>便携设备 对应U盘,打开属性>查看详细信息>如果设备描述为Data Traveler 3.0 那么这就是3.0的U盘