vue+elementUI table篇
1.table内容展示
<el-table stripe :key='tableKey' header-cell-class-name="bindonce" :data="tableList" v-loading="listLoading" element-loading-text="列表正在加载中" border fit highlight-current-row
style="width: 100%;" @selection-change="selectionChange">
<el-table-column align="center" type="selection" width="55px"></el-table-column> <el-table-column align="center" :label="'会员卡名称'" width="150" sortable prop="scope.row.name">
<template slot-scope="scope">
<span v-text="scope.row.name"></span>
</template>
</el-table-column> <el-table-column align="center" :label="'会员卡类型'" width="120" prop="scope.row.type"
:filters="[{text: '全部', value: 0},{text: '时效卡', value: 1}, {text: '次卡', value: 2}]"
:filter-method="filterType" filter-placement="bottom-end" :filter-multiple="false">
<template slot-scope="scope">
<span>{{scope.row.type === 1 ? '时效卡' : '次卡'}}</span>
</template>
</el-table-column> <el-table-column align="center" :label="'总时间/次数'" width="150" sortable prop="scope.row.times">
<template slot-scope="scope">
<span>{{ scope.row.type===1 ? scope.row.times + '天' : scope.row.times + '次'}}</span>
</template>
</el-table-column> <el-table-column align="center" :label="'价格(元)'" width="150" sortable prop="scope.row.price">
<template slot-scope="scope">
<span>{{scope.row.price}}</span>
</template>
</el-table-column> <el-table-column align="center" :label="'底价(元)'" width="150" sortable prop="scope.row.floor_price">
<template slot-scope="scope">
<span>{{scope.row.floor_price}}</span>
</template>
</el-table-column> <el-table-column align="center" :label="'APP状态'" width="150" sortable prop="scope.row.app_status">
<template slot-scope="scope">
<span>{{scope.row.app_status === 1? '下架':'上架'}}</span>
</template>
</el-table-column> <el-table-column align="center" :label="'SAAS状态'" width="150" sortable prop="scope.row.saas_status">
<template slot-scope="scope">
<span>{{scope.row.saas_status === 1? '下架' : '上架'}}</span>
</template>
</el-table-column> <el-table-column width="150px" align="center" :label="'会员卡图标'">
<template slot-scope="scope">
<span><img :src="scope.row.photo" @click="common.bigImg($event)" alt="icon" width="30" height="30" style="margin-left:50px;display: list-item;border-radius:50%;"></span>
</template>
</el-table-column> <el-table-column width="200px" align="center" label="创建时间<i class='el-icon-date'></i>" sortable prop="scope.row.created_at">
<template slot-scope="scope">
<span>{{scope.row.created_at}}</span>
</template>
</el-table-column> <el-table-column align="center" fixed="right" :label="$t('table.actions')" min-width="230" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="primary" plain
@click="handleEdit(scope.$index, scope.row)">编辑</el-button>
<el-dropdown trigger="click">
<el-button size="mini" type="danger" plain>删除</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item @click.native="handleDelete(scope.$index, tableList)">确定</el-dropdown-item>
<el-dropdown-item>取消</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
2.编辑
handleEdit(index, row) {
this.subStatus = 'edit_' + index
this.formData = Object.assign({}, row)
this.DialogVisible = true
this.add_edit = true
this.$nextTick(() => {
this.$refs.imgbox.setImg(row.photo)
})
},
editsubmit() {
let self = this
this.$refs.formbox.validate(valid => {
if (valid) {
self.loading = true
editVipCard(self.formData).then(response => {
self.loading = false
self.DialogVisible = false
let index = self.subStatus.split('_')[1]
self.$set(self.tableList, index, response.data)
// this.getList()
})
} else {
console.log('error submit!!')
return false
}
})
},
3.删除
handleDelete(index, rows) {
deleteVipCard(rows[index].id).then(res => {
rows.splice(index, 1)
}).catch(() => {
this.common.Message('error', '删除失败!')
})
}
4.table中使用checkbox,判断选中状态
在table中加入@selection-change="selectionChange"
// 点击checkbox获得对应id
selectionChange(selection) {
this.groupOprate.ids = []
for (let i = 0; i < selection.length; i++) {
this.groupOprate.ids.push(selection[i].id)
}
console.log(this.groupOprate.ids)
},
vue+elementUI table篇的更多相关文章
- 关于【vue + element-ui Table的数据多选,多页选择数据回显,分页记录保存选中的数据】的优化
之前写的[vue + element-ui Table的数据多选,多页选择数据回显,分页记录保存选中的数据]这篇博客.功能虽然实现了相对应的功能.但是用起来很不爽.所以进行了优化. 备注:最近可能没时 ...
- Vue Element-ui table只展开一行
直接上代码了哈~ <template> <div class="app-content"> <div class="table_expand ...
- vue + element-ui Table的数据多选,多页选择数据回显,分页记录保存选中的数据。
业务的需要:我要对与会人员勾选,记录所选的与会人员,并且点击到别的页面上时也要记录所勾选的.第一次尝试,每次点击下一页数据都会清空.然后我就去element ui官网查看了api.实现如下: 在tab ...
- vue element-ui Table数据解除自动响应方法
在对列表Table进行数据编辑时,会存在table的增删改操作后,列表view也自动响应发生了变化,原因是赋值的数据是一个引用类型共享一个内存区域的.所以我们就不能直接连等复制,需要重新克隆一份新的数 ...
- vue elementui table 双击单元格实现编辑,聚焦,失去焦点,显示隐藏input和span
<el-table :data="tableData" class="tb-edit" style="width: 100%" ref ...
- vue elementui table 内按钮跳转页面
vue : <el-table-column label="操作" v-if="isColumOperate"> <template slot ...
- vue elementui table组件内容换行
解决方案 tableData = [ { "name": "domain111", "metric": [ "平均耗时" ...
- Vue + Element-ui实现后台管理系统(5)---封装一个Form表单组件和Table表格组件
封装一个Form表单组件和Table组件 有关后台管理系统之前写过四遍博客,看这篇之前最好先看下这四篇博客.另外这里只展示关键部分代码,项目代码放在github上: mall-manage-syste ...
- SpringBoot + Vue + ElementUI 实现后台管理系统模板 -- 后端篇(五): 数据表设计、使用 jwt、redis、sms 工具类完善注册登录逻辑
(1) 相关博文地址: SpringBoot + Vue + ElementUI 实现后台管理系统模板 -- 前端篇(一):搭建基本环境:https://www.cnblogs.com/l-y-h/p ...
随机推荐
- 莫(meng)比(bi)乌斯反演--BZOJ2301: [HAOI2011]Problem b
n<=50000个询问,每次问a<=x<=b,c<=y<=d中有多少gcd(x,y)=K的(x,y).a,b,c,d,K<=50000. 这大概是入门题辣..这里记 ...
- [HDU5709]Claris Loves Painting(动态开点线段树+合并)
题意:有n(<=1e5)个点的树,每个点都有颜色(颜色可能重复),有m(<=1e5)个询问,每次询问(x,d)问在x的子树中,与x的距离不超过d的节点有多少种不同的颜色.强制要求在线. 分 ...
- delphi调用oracle存储过程(ODAC)
CREATE OR REPLACE PACKAGE p_lee01ISTYPE cur_lee01 IS REF CURSOR;END; CREATE OR REPLACE PROCEDURE pro ...
- Linux命令输出头(标题)、输出结果排序技巧
原文:http://blog.csdn.net/hongweigg/article/details/65446007 ----------------------------------------- ...
- 搭建wamp php环境
点击下载wamp,wamp是一个集成环境,在安装过程中,我们要选择默认的浏览器以及默认的文本编辑器,安装步骤如下: 第一步,选择默认的浏览器(填写默认的浏览器可执行路径就行) 第二步,选择默认的文本编 ...
- 七夕节 看到很多停止更新的blog 莫名有点淡淡的忧桑
又是一年七夕.又是一年单身.看到很多停止更新的blog, 仿佛看到了一茬一茬的程序猿 进入it 圈 又离开it圈,就有莫名的忧桑
- OCP-1Z0-051-题目解析-第21题
21. Examine the description of the EMP_DETAILS table given below: name NULL ...
- python 简单连接mysql数据库
1. 安装pymysql 库 pip install pymysql 2.实例本地连接mysql库 #!/usr/bin/python # encoding: utf-8 ""&q ...
- 通过java类文件识别JDK编译版本号
类文件里第5,6.7,8四个字节是jDK版本信息.当中5,6为小版本:7,8为大版本. 大版本号号相应JDK版本号例如以下: JDK版本 7,8字节 JDK8 52(0x34) JDK7 51(0x3 ...
- java poi excel导入模板设置下拉框
import org.apache.poi.hssf.usermodel.DVConstraint; import org.apache.poi.hssf.usermodel.HSSFCell; im ...