<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. springmvc快速入门(XML版本)

    1)springmvc快速入门(传统版) 步一:创建springmvc-day01这么一个web应用 步二:导入springioc,springweb , springmvc相关的jar包 步三:在/ ...

  2. BrowserUtils

    import android.content.Context; import android.content.Intent; import android.net.Uri; public class ...

  3. java序列化与反序列化操作redis

     笔者在使用SSM框架项目部分功能进行测试需要使用到对象的序列化与反序列化 第一种方式:jackson Demo package com.dznfit.service; import com.dznf ...

  4. idea使用generatorconfig生成

    在maven工程中的resource中创建generatorConfigxml配置generatorConfigxml的配置pomxml生成对象的两种方式方式一使用idea的maven插件直接快速生成 ...

  5. harber私有镜像仓库(4)

    一.部署准备: 准备harbor软件包 在部署节点上: #mv harbor-offline-installer-v1.4.0.tgz /opt/ && cd /opt #tar zx ...

  6. es6 实现双链表

    const util = require('util'); /** * 链表节点类 */ class Node { constructor (ele) { this.ele = ele; this.n ...

  7. Js 使用Map

    function Map() { this.elements = new Array(); this.size = function() { return this.elements.length; ...

  8. Python3 循环_break和continue语句及循环中的else子句

    break和continue语句及循环中的else子句break语句可以跳出for和while的循环体.如果你从for或while循环中终止,任何对应的循环else块将不执行. continue语句被 ...

  9. SpringBoot: 8.整合freemarker(转)

    1.创建maven项目,添加pom依赖 <!--springboot项目依赖的父项目--> <parent> <groupId>org.springframewor ...

  10. 【Zookeeper】本地模式安装

    安装步骤 上传gz包 通过rz命令,将zookeeper-3.4.10.tar.gz安装包上传到/opt/soft/文件夹下. [root@bigdata111 soft]# rz [root@big ...