当前位置: 首页 > news >正文

vue+elementUI实现指定列的单元格可编辑

template中的代码如下:

<div v-if="(item.label === '高压侧' || item.label === '低压侧')&&coloumnHeader.label === '单柱片数'"><div class="editableCell"><div v-if="item.label === '高压侧'" @dblclick="changeValue(scope.$index, scope.row,'high')"><span v-if="!scope.row.highEdit">{{scope.row[item.prop]}}</span><el-input v-model="scope.row[item.prop]" v-else="scope.row.highEdit" size="mini" @blur.native.capture="valueBlur(scope.$index, scope.row, 'high')" v-focus></el-input></div><div v-else @dblclick="changeValue(scope.$index, scope.row,'low')"><span v-if="!scope.row.lowEdit">{{scope.row[item.prop]}}</span><el-input v-model="scope.row[item.prop]" v-else="scope.row.lowEdit" size="mini" @blur.native.capture="valueBlur(scope.$index, scope.row, 'low')"v-focus></el-input></div>			</div></div>

js代码如下:

		/*** 高压侧低压侧列双击可输入值* @param {Number} index 行索引* @param {Object} rowData 行数据* @param {String} type 高低压侧类型*/changeValue(index,rowData, type){if(type === 'high'){// 数据更新,视图更新if(Object.keys(this.updateTableData[index]).indexOf("highEdit") === -1){// 还没编辑过的添加编辑属性this.$set(this.updateTableData, index,{highEdit:true,...this.updateTableData[index]});}else{// 已经编辑过的,更改编辑属性this.$set(this.updateTableData[index], "highEdit", true);}				}else if(type === 'low'){if(Object.keys(this.updateTableData[index]).indexOf("lowEdit") === -1){this.$set(this.updateTableData, index,{lowEdit:true,...this.updateTableData[index]});}else{this.$set(this.updateTableData[index], "lowEdit", true);}}},/*** 输入框失去焦点时触发* @param {Number} index 行索引* @param {Object} rowData 行数据* @param {String} type 高低压侧类型*/valueBlur(index,rowData, type){// 数据更新,视图更新if(type === "high"){this.$set(this.updateTableData[index], "highEdit", false);}else{this.$set(this.updateTableData[index], "lowEdit", false);}console.log(this.updateTableData)},
http://www.lryc.cn/news/321762.html

相关文章:

  • RK3568平台开发系列讲解(基础篇)内核是如何发送事件到用户空间
  • 力扣---打家劫舍---动态规划
  • mac安装rust环境
  • 1058:求一元二次方程
  • GraphQL入门之一对多关联查询
  • MATLAB和Python数值和符号计算可视化物理学气体动能和粒子速度
  • 阿里云-零基础入门NLP【基于机器学习的文本分类】
  • 蓝桥杯模块综合——高质量讲解AT24C02,BS18B20,BS1302,AD/DA(PCF8591),超声波模块
  • 前端跨平台开发框架:简化多端开发的利器
  • cesium.js加载模型后,重新设置旋转角度属性值
  • ②免费AI软件开发工具测评:通义灵码 VS 码上飞
  • 幻兽帕鲁游戏搭建(docker)
  • unity报错出现Asset database transaction committed twice!
  • 去除项目git的控制 端口号的关闭
  • 交叉注意力融合时域、频域特征的FFT + CNN -BiLSTM-CrossAttention电能质量扰动识别模型
  • 简单的Charles抓包教程
  • 如何构建Docker自定义镜像
  • 一起学数据分析_2
  • 请解释Redis是什么?它有哪些主要应用场景?Redis支持哪些数据类型?并描述每种数据类型的特性和使用场景。
  • 在centos8中部署Tomcat和Jenkins
  • 机器学习模型—K means
  • QT UI设计
  • 前端小白的学习之路(CSS3 一)
  • 春暖花开,一起来看看2024年品牌春分海报吧!
  • golang面试题总结
  • BUGKU-WEB shell
  • 系统重构后,对项目定制开发的兼容性问题
  • Linux---基本操作命令之用户管理命令
  • excel 破解 保护工作簿及保护工作表
  • django-comment-migrate 模型注释的使用