element封装表格
<template>
<div>
<el-scrollbar class="table-wrap">
<el-table
v-loading="loading"
:data="tableData"
:height="height"
:stripe="stripe"
:border="border"
:max-height="maxHeight"
:header-cell-style="tabHeadStyle"
:cell-style="tabcellStyle"
:row-style="rowStyle"
style="width: 100%"
@selection-change="handleSelectionChange"
>
<!-- 多选 -->
<el-table-column
v-if="isSelection"
type="selection"
align="center"
:is-selection="selectable"
/>
<!-- 索引 -->
<el-table-column
v-if="isIndex"
:label="indexLabel"
type="index"
align="center"
width="50"
/>
<template v-for="(item, index) in tableCols">
<!-- 合并单元格 -->
<el-table-column
v-if="item.type == 'table_column'"
:key="index"
:label="item.label"
:width="item.width"
:min-width="item['min-width']"
:fixed="item.fixed"
:align="item.align"
:header-align="item['header-align'] || 'left'"
:show-overflow-tooltip="item['show-overflow-tooltip'] || true"
>
<!-- <el-table-column
v-for="(itema, index) in item.prop"
:key="index"
:label="itema.label"
:prop="itema.prop"
:width="itema.width"
:min-width="itema['min-width']"
:fixed="itema.fixed"
:align="itema.align"
:header-align="itema['header-align'] || 'left'"
:show-overflow-tooltip="itema['show-overflow-tooltip'] || true"
>
<template v-if="itema.slot" slot-scope="scope" :name="itema.slot">
<slot :name="itema.slot" :row="scope.row" />
</template>
</el-table-column> -->
<el-table-column
v-for="(itema, index) in item.prop"
:key="index"
:label="itema.label"
:prop="itema.prop"
:width="itema.width"
:min-width="itema['min-width']"
:fixed="itema.fixed"
:align="itema.align"
:header-align="itema['header-align'] || 'left'"
:show-overflow-tooltip="itema['show-overflow-tooltip'] || true"
/>
</el-table-column>
<!-- 需要插槽 -->
<el-table-column
v-if="item.slot && !item.type"
:key="index"
:label="item.label"
:prop="item.prop"
:width="item.width"
:min-width="item['min-width']"
:fixed="item.fixed"
:align="item.align"
:header-align="item['header-align'] || 'left'"
:show-overflow-tooltip="item['show-overflow-tooltip'] || true"
>
<template v-if="item.slot" slot-scope="scope" :name="item.slot">
<slot :name="item.slot" :row="scope.row" />
</template>
</el-table-column>
<!--不需要插槽-->
<el-table-column
v-if="!item.slot && !item.type"
:key="index"
:label="item.label"
:prop="item.prop"
:width="item.width"
:min-width="item['min-width']"
:fixed="item.fixed"
:align="item.align"
:header-align="item['header-align'] || 'left'"
:show-overflow-tooltip="item['show-overflow-tooltip'] || true"
/>
</template>
</el-table>
</el-scrollbar>
<el-pagination
v-if="pagInationIf"
:current-page="pagInation.pageNum"
:total="pagInation.count"
:page-size="pagInation.pageSize"
layout="prev, pager, next,total"
background
@current-change="handleCurrentChange"
/>
</div>
</template> <script type="text/ecmascript-6">
export default {
name: 'SirTable',
props: {
// 加载状态
loading: { type: Boolean, default: false },
// 表格列配置
tableCols: { type: [Array], default: () => [] },
// 表格内数据
tableData: { type: [Array], default: () => [] },
// 表格是否显示斑马线
stripe: { type: [Boolean, String], default: false },
// 表格边框
border: { type: [Boolean, String], default: false },
height: { type: [Number, String], default: null },
// 最大高度
maxHeight: { type: [Number, String], default: null },
// 是否显示表格复选框
isSelection: { type: [Boolean], default: false },
// 是否显示表格索引
isIndex: { type: Boolean, default: true },
// 索引lable
indexLabel: { type: String, default: '序号' },
// 分页数据
pagInation: { type: Object, default: () => ({ pageSize: 10, pageNo: 1, total: 0 }) },
pagInationIf: { type: [Boolean], default: true },
},
data() {
return {
// 表头样式
tabHeadStyle: {
'background-color': '#FAFAFA',
color: '#333333', 'font-weight': 'bold'
},
// 行样式
tabcellStyle: {
color: '#666'
},
rowStyle: {
height: '50px'
}
}
},
methods: {
// 据条件禁用某个列表项的选择框
selectable(row) {
if ((row.prohibit == null) || (row.prohibit == '')) {
return true
} else {
return false
}
},
// 多选事件,保存选择项到指定参数
handleSelectionChange(val) {
this.$emit('checkbox-data', val)
},
// 翻页触发
handleCurrentChange(val) {
this.pagInation.pageNum = val
this.$emit('refresh', this.pagInation) }
}
}
</script> <style lang="scss" scoped>
.el-table td {
/*min-height: 40px;*/
/*padding: 0 !important;*/
}
/deep/.el-table--enable-row-transition .el-table__body td {
min-height: 40px;
padding: 0;
}
/deep/.el-scrollbar__wrap {
height: $tableCalc;
}
/*分页*/
.el-pagination {
float: right;
margin-top: 25px;
}
/deep/.el-pagination.is-background {
.number,
.btn-prev,
.btn-next {
background-color: #fff;
border: 1px solid #ebedf0;
}
.el-pager li {
background-color: #fff;
}
}
/deep/.el-pagination.is-background .el-pager li:not(.disabled):hover {
color: #499bfc;
}
/deep/.el-pagination.is-background .el-pager li:not(.disabled).active {
background-color: #499bfc;
color: #fff;
}
</style>
element封装表格的更多相关文章
- element el-table表格的vue组件二次封装(附表格高度自适应)
基于vue的el-table表格二次封装组件方法 前言 在公司实习使用vue+element-ui框架进行前端开发,使用表格el-table较为多,有些业务逻辑比较相似,有些地方使用的重复性高,如果多 ...
- 前端枚举enum的应用(Element)封装
什么是枚举Enum 枚举 Enum是在众多语言中都有的一种数据类型,JavaScript中还没有(TypeScript有).用来表示一些特定类别的常量数据,如性别.学历.方向.账户状态等,项目开发中是 ...
- element ui 表格提交时获取所有选中的checkbox的数据
<el-table ref="multipleTable" :data="appList" @selection-change="changeF ...
- 封装一个优雅的element ui表格组件
现在做后台系统用vue + elementUI 的越来越多,那element ui的 el-table 组件肯定也离不开.虽然element ui的table组件很好.但是表格和分页是分离的.每次写表 ...
- vue2.0+Element UI 表格前端分页和后端分页
之前写过一篇博客,当时对element ui框架还不太了解,分页组件用 html + css 自己写的,比较麻烦,而且只提到了后端分页 (见 https://www.cnblogs.com/zdd20 ...
- vue + element ui 表格自定义表头,提供线上demo
前言:工作中用到 vue+element ui 的前端框架,需要使用自定义表头,需要使用 re.转载请注明出处:https://www.cnblogs.com/yuxiaole/p/9710826.h ...
- Element UI表格组件技巧:如何简洁实现跨页勾选、跨页统计功能
业务场景 在使用Element UI的Table组件时,常常面对这样的业务需求: 表格数据的每一项都要提供勾选框,当切换分页时,能够记忆所有页面勾选的数据,以实现批量提交不同页面勾选数据的功能.并且, ...
- element UI表格行高、padding等设置报错问题
element UI里面表格的行高需要自己调整高度和设置padding,直接写style是不行的,里面有 : 1.row-style (行的 style) 2.header-row-styl (表 ...
- 手把手教学~基于element封装tree树状下拉框
在日常项目开发中,树状下拉框的需求还是比较常见的,但是element并没有这种组件以供使用.在这里,小编就基于element如何封装一个树状下拉框做个详细的介绍. 通过这篇文章,你可以了解学习到一个树 ...
随机推荐
- 2020-04-09:TCP的四次挥手中为什么要有TIME_WAIT状态?
TIME_WAIT状态存在有两个原因.<1>可靠终止TCP连接.如果最后一个ACK报文因为网络原因被丢弃,此时server因为没有收到ACK而超时重传FIN报文,处于TIME_WAIT状态 ...
- 微博AnalysisQl动态数据视图元数据设计
前言 目前,AnalysisQl 数据视图的元数据(维度.指标.指标计算器)需要通过代码(API)或资源文件的形式硬编码,应用启动时,按照声明的顺序依次注册.这种模式下,数据视图是 静态 的,任何一项 ...
- 释放DT时代释放金融数据价值,驱动金融商业裂变
摘要:客户微细分模型上线华为云ModelArts,看如何以AI科技挖掘金融数据价值. 当前信息化浪潮席卷全球,新一轮的科技革命和产业革命推动金融行业发展到全新阶段.人工智能2.0时代,智慧金融方兴未艾 ...
- 每日一道 LeetCode (15):二进制求和
每天 3 分钟,走上算法的逆袭之路. 前文合集 每日一道 LeetCode 前文合集 代码仓库 GitHub: https://github.com/meteor1993/LeetCode Gitee ...
- PythonCrashCourse 第十章习题
在文本编辑器中新建一个文件,写几句话来总结一下你至此学到的Python知识,其中每一行都以"In Python you can"打头.将这个文件命名为 learning_pytho ...
- linux驱动之jiffies的理解
本文主要借鉴了http://blog.csdn.net/allen6268198/article/details/7270194,非常感谢该网友的分享. 在LINUX的时钟中断中涉及至二个全局变量一个 ...
- hbase运行流程图
hbase运行流程图
- Linux时间同步服务chrony
1.简介 Chrony是一个开源的自由软件,像CentOS 7或基于RHEL 7操作系统,已经是默认服务,默认配置文件在 /etc/chrony.conf .它能保持系统时间与时间服务器(NTP)同步 ...
- 如何加速github下载速度
第一步 魔法 第二步 git config --global http.proxy http://127.0.0.1:1080 git config --global https.proxy http ...
- Python语言中的关键字(自己做的读书笔记)
电脑配置:联想笔记本电脑 windows8系统 Python版本:2.7.8 本文章撰写时间:2015.1.1 作者:陈东陈 阅读说明: 1.本文都是先解释,后放图片: 2.文中斜体部分要么为需要输入 ...