<template>
<div id="Cold_all">
<div class="Cold_Left">
<el-row>
<div class="font_style"> 1.输入计算基本数据</div>
<el-col :span="24"> <el-table
size="mini"
:data="master_user.data"
border
style="width: 100%;margin:auto"
highlight-current-row
>
<el-table-column type="index"></el-table-column>
<el-table-column
v-for="(item,index) in master_user.columns"
:label="item.label"
:prop="item.prop"
:width="item.width"
:key="index"
>
<template slot-scope="scope">
<span v-if="scope.row.isSet">
<el-input size="mini" placeholder="请输入内容" v-model="master_user.sel[item.prop]"></el-input>
</span>
<span v-else>{{scope.row[item.prop]}}</span>
</template>
</el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<span
class="Insert_Cold"
style="cursor: pointer;"
@click.stop="saveRow(scope.row,scope.$index)"
>保存</span>
<span
class="Edit_Cold"
style="cursor: pointer;"
@click="editRow(scope.row,scope.$index)"
>编辑</span>
<span
class="Delete_Cold"
style="cursor: pointer;"
@click="deleteRow(scope.$index,master_user.data)"
>删除</span>
</template>
</el-table-column>
</el-table>
</el-col>
<el-col :span="24">
<div class="el-table-add-row" style="width: 99.2%;" @click="add()">
<span>+ 添加</span>
</div>
</el-col>
</el-row>
</div>
</div>
</template>
<script>
export default {
name: "",
data() {
return {
master_user: {
sel: null, //选中行
columns: [ {
prop: "OutdoorTDB",
label: "室外计算温度(℃)", },
{
prop: "IndoorTDB",
label: "室内计算温度(℃)"
},
{
prop: "TdbStartTime",
label: "运行开始时间"
},
{
prop: "TdbEndTime",
label: "运行结束时间"
}
],
data: []
}
}
<script>
methods: {
//基本输入列表
add() {
for (let i of this.master_user.data) {
if (i.isSet) return this.$message.error("请先保存当前编辑项");
}
let j = {
index: "",
OutdoorTDB: "",
IndoorTDB: "",
TdbStartTime: "",
TdbEndTime: "",
isSet: true
};
this.master_user.data.push(j);
this.master_user.sel = JSON.parse(JSON.stringify(j));
},
saveRow(row, index) {
//保存
let data = JSON.parse(JSON.stringify(this.master_user.sel));
for (let k in data) {
row[k] = data[k];
}
row.isSet = false;
},
editRow(row) {
//编辑
for (let i of this.master_user.data) {
if (i.isSet) return this.$message.error("请先保存当前编辑项");
}
this.master_user.sel = row;
row.isSet = true;
},
deleteRow(index, rows) {
//删除
rows.splice(index, 1);
},
components: {}
}

element-ui 表格可编辑添加删除的更多相关文章

  1. element ui 表格提交时获取所有选中的checkbox的数据

    <el-table ref="multipleTable" :data="appList" @selection-change="changeF ...

  2. 封装一个优雅的element ui表格组件

    现在做后台系统用vue + elementUI 的越来越多,那element ui的 el-table 组件肯定也离不开.虽然element ui的table组件很好.但是表格和分页是分离的.每次写表 ...

  3. WPF下的Richtextbox中实现表格合并,添加删除行列等功能

    .Net中已有现在的方法实现这些功能,不过可能是由于未完善,未把方法公开出来.只能用反射的方法去调用它. 详细信息可以查看.Net Framework 的源代码 http://referencesou ...

  4. vue + element ui 表格自定义表头,提供线上demo

    前言:工作中用到 vue+element ui 的前端框架,需要使用自定义表头,需要使用 re.转载请注明出处:https://www.cnblogs.com/yuxiaole/p/9710826.h ...

  5. Element UI表格组件技巧:如何简洁实现跨页勾选、跨页统计功能

    业务场景 在使用Element UI的Table组件时,常常面对这样的业务需求: 表格数据的每一项都要提供勾选框,当切换分页时,能够记忆所有页面勾选的数据,以实现批量提交不同页面勾选数据的功能.并且, ...

  6. vue2.0+Element UI 表格前端分页和后端分页

    之前写过一篇博客,当时对element ui框架还不太了解,分页组件用 html + css 自己写的,比较麻烦,而且只提到了后端分页 (见 https://www.cnblogs.com/zdd20 ...

  7. element UI表格行高、padding等设置报错问题

    element UI里面表格的行高需要自己调整高度和设置padding,直接写style是不行的,里面有 : 1.row-style (行的 style) 2.header-row-styl   (表 ...

  8. element ui表格常用功能如:导出 新增 删除 多选 跨页多选 固定表头 多级表头 合并行列 等常见需求

    <template> <div class="table-cooperte"> <el-table :data="tableData&quo ...

  9. js表格上下移动添加删除

    html部分 <div onclick='fn()'>加</div> <table width="250" border="1" ...

随机推荐

  1. mybatis之动态SQL操作之删除

    /** * 持久层 */ public class StudentDao { /** * 动态SQL--删除 */ public void dynaSQLwithDelete(int... ids) ...

  2. 加载大图片的OOM异常

    * 原因:系统分配给应用程序的堆内存 < 图片的大小* 解决方案:缩放图片显示* OOM:OutOfMemoryError * 图片的宽高 * 宽 2400 * 高 3200 * 手机屏幕的宽高 ...

  3. umask 介绍

    umask码 是用户创建文件或目录的初始权限设置值 文件或目录的权限:读: r — 4写: w — 2执行: x — 1 输入umask 查看umask 码 设定umask码,umask 0033 1 ...

  4. ceph常用命令(3)

    1.查看集群配置信息 ceph daemon /var/run/ceph/ceph-mon.$(hostname -s).asok config show 2.在部署节点修改了ceph.conf文件, ...

  5. 安装python3.6并使用virtualenvwrapper管理虚环境

    1.安装python3.6.5依赖环境 注:python3.7.4需要安装:yum install libffi-devel -y yum install gcc patch libffi-devel ...

  6. —Entity Framework实例详解

    Entity Framework Code First的默认行为是使用一系列约定将POCO类映射到表.然而,有时候,不能也不想遵循这些约定,那就需要重写它们.重写默认约定有两种方式:Data Anno ...

  7. Unity Shader概述

    一.概述 在Unity中需要配合使用材质和Unity Shader才能达到需要的效果.常见的流程:(1)创建一个材质:(2)创建一个Unity Shader,并把它赋给创建的材质:(3)把材质赋给要渲 ...

  8. 使用国内镜像给ROS安装提速

    大半年没写博客了.最近有幸参与机器人导航研究,在学习ROS相关知识.在安装ROS时使用国外的官方源安装非常慢.这里把使用国内镜像的安装方式做一个记录. 笔者用的是Kinetic版本,操作系统是Ubun ...

  9. [转帖]prometheus数据采集exporter全家桶

    prometheus数据采集exporter全家桶 Rainbowhhy1人评论2731人阅读2019-04-06 15:38:32 https://blog.51cto.com/13053917/2 ...

  10. SqlException 服务器主体无法在当前安全上下文下访问数据库

    遇到一个错误如下 System.Data.SqlClient.SqlException  HResult=0x80131904  Message=服务器主体 "用户名" 无法在当前 ...