vue+Element ui 可编辑表格

news/2024/7/10 3:01:55 标签: vue, em

 

1.利用css属性绑定,事件触发<span>与<el-input>和<el-select>的展示与否,将表格列模板中写出两种展现格式,通过控制css实现

<el-table :data="dataList" class="tb-edit" style="width: 100%" max-height="260" highlight-current-row @row-dblclick="handleCurrentChange">
    <el-table-column label="参数类型" width="180" :show-overflow-tooltip="true" header-align="center" align="center" >
        <template scope="scope">
            <el-select size="small" v-model="scope.row.paramType" placeholder="请输入内容" @change="handleEdit(scope.$index, scope.row)">
                <el-option v-for="item in paramTypeList" :label="item.paramKey"  :value="item.paramValue" ></el-option>
            </el-select>
                <span>{{scope.row.paramType}}</span>
        </template>
    </el-table-column>
    <el-table-column prop="paramName" label="参数名称" :show-overflow-tooltip="true" header-align="center" align="center" width="180">
        <template scope="scope">
            <el-select size="small" v-model="scope.row.paramName" placeholder="请输入内容" @change="handleEdit(scope.$index, scope.row)">
                <el-option v-for="item in paramNameList" :label="item.paramKey"  :value="item.paramValue" ></el-option>
            </el-select> <span>{{scope.row.paramName}}</span>
        </template>
    </el-table-column>
    <el-table-column prop="paramCode" header-align="center" :show-overflow-tooltip="true" align="center" label="参数编码">
        <template scope="scope">
            <el-select size="small" v-model="scope.row.paramCode" placeholder="请输入内容" @change="handleEdit(scope.$index, scope.row)">
                <el-option v-for="item in paramCodeList" :label="item.paramKey"  :value="item.paramValue" ></el-option>
            </el-select>  <span>{{scope.row.paramCode}}</span>
        </template>
    </el-table-column>
    <el-table-column prop="param" header-align="center" :show-overflow-tooltip="true" align="center" label="参数值">
        <template scope="scope">
            <el-input size="small" v-model="scope.row.param" placeholder="请输入内容" @change="handleEdit(scope.$index, scope.row)">
            </el-input>  <span>{{scope.row.param}}</span>
        </template>
    </el-table-column>
    <el-table-column  header-align="center" align="center" label="操作">
        <template scope="scope">
            <el-button size="small" @click="updateHandle(scope.$index, scope.row)">保存</el-button>
            <el-button size="small" type="danger" @click="deleteHandle(scope.row.id)">删除</el-button>
        </template>
    </el-table-column>
</el-table>


<style>
    * {
        margin: 0;
        padding: 0
    }
    body {
        font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, SimSun, sans-serif;
        overflow: auto;
        font-weight: 400;
        -webkit-font-smoothing: antialiased;
    }
    .tb-edit .el-select  {
        display: none
    }
    .tb-edit .el-input  {
        display: none
    }
    .tb-edit .current-row .el-select {
        display: block
    }
    .tb-edit .current-row .el-input{
        display: block
    }
    .tb-edit .current-row .el-select+span {
        display: none
    }
    .tb-edit .current-row .el-input+span {
        display: none
    }
</style>


handleCurrentChange(row, event, column) {
    console.log(row, event, column, event.currentTarget)
},
updateHandle(index, row) {
    vm.loadingText = '正在提交数据...'
    vm.dataListLoading = true
    http.post('/task/param/editUpdate' ,{
        'id': row.id || undefined,
        'taskTemplateId':vm.dataForm.id,
        'paramCode':row.paramCode,
        'paramName': row.paramName,
        'paramType': row.paramType,
        'param': row.param,
    }).then(function (data) {
        vm.dataListLoading = false
        vm.$message({
            type: 'success',
            message: '操作成功'
        })
        vm.requestParameter()
        // window.parent.layerEmit("success", saveOrUpdateStr);
    }).catch(function () {
        vm.dataListLoading = false
    })

},




 


http://www.niftyadmin.cn/n/764591.html

相关文章

c++输出lpbyte类型_C语言拓展第六期:格式化输出

前边我们学习了不同种类的数据类型&#xff0c;为了将这些数据输出到终端我们学习了printf函数。但前边的学习更多的是简单的套用&#xff0c;并没有理解printf语句里每个部分的含义。于是我们有了今天的学习内容——C语言的格式化输出。在学习了本节内容后&#xff0c;你就可以…

JS导出excel 纯前端

exportExcel: function () {//要导出的json数据const jsonData vm.dataListfor (let j 0; j < jsonData.length; j) {console.log(jsonData[j])delete jsonData[j].iddelete jsonData[j].beforeSixCountdelete jsonData[j].beforeOneCount}//列标题//列标题&#xff0c;逗…

apache http可以访问https没权限_Linux网络服务Apache

这边建议点击右上角“”找到调整字体为最小的那个&#xff0c;可舒服观看一、Web的基础概念&#xff1f; 讲Apache之前我们先了解一下Web的基础概念&#xff1a;HTML语言&#xff1a;超文本标记语言&#xff0c;使用html语言编写的文本叫超文本&#xff0c;“超文本”就是指页面…

Vue +ElementUI 实现表格的动态展示

Vue 动态表格控制表格中每一列的显示与否实现步骤1.vueElement UI写控制组件2. 为表格每一列绑定v-if值3. 值监听函数控制表格中每一列的显示与否 效果图&#xff1a; 实现思想&#xff1a; 首先利用element Ui写好组件&#xff0c;然后通过选择组件状态触发监听函数改变v-if…

springboot+vue 解析txt csv excel 文件并存入数据库

1、VueElement UI上传组件上传文件 <el-uploaddragref"upload"class"upload-demo":action"uploadDatasetUrl"//后端响应地址:on-successupLoadSuccess//成功后的回调函数:file-list"fileList"><i class"el-icon-upload…

python 歌曲相似度 音乐推荐_python爬虫如何下载QQ音乐付费歌曲2020最新版

最近想写一个QQ音乐的API接口&#xff0c;为了省事先到网上查了资料&#xff0c;发现很多都是不能用的&#xff0c;估计官方进行了升级&#xff0c;算了&#xff0c;还是自己来吧。1. 如何下载付费歌曲打开QQ音乐&#xff0c;任意搜索一首歌曲&#xff0c;发现歌曲需要收费&…

封装es查询

封装es查询 快速实现es的各种查询的功能包括关系型数据库中的and、between、in、like、sortField、sortDirect 分页和高亮显示等 快速开始&#xff01;只需构造对应的参数调用方法即可 1.首先创建es客户端实例&#xff0c;连接es &#xff08;双重校验锁实现单例&#xff0c;…

matlab svm预测_Python机器学习笔记:证明SVM(3)FlyAI

上一节我学习了SVM的核函数内容&#xff0c;下面继续对SVM进行证明&#xff0c;具体的参考链接都在第一篇文章中。话休絮烦&#xff0c;要证明一个东西先要弄清楚它的根基在哪里&#xff0c;即构成它的基础是哪些理论。OK&#xff0c;以下内容基本上都是上文没有学习到的一些定…