解决vue + elementui el-table中input 赋值问题以及批量赋值问题
问题贴出来调整代码:<el-table-column label="实结点位" align="center" width="140"><template slot-scope="scope"><div class="display"><el-input v-model="scope.row.chargesPercentage" clearable size
·
问题贴出来
调整代码:
<el-table-column label="实结点位" align="center" width="140">
<template slot-scope="scope">
<div class="display">
<el-input v-model="scope.row.chargesPercentage" clearable size="small"
@blur="onExchangeChange(scope.$index)" @input="change(scope.$index)"/>
<span>%</span>
</div>
</template>
</el-table-column>
<div class="table-bottom">
<div class="left">批量调整</div>
<div class="right">
<el-input v-model="policyNototal" clearable size="small"
@blur="batchChange($event)" />
<span>%</span>
</div>
</div>
</div>
method:
this.statementChangeList.forEach(item => {
item.chargesPercentage = item.policyChargesPercentage ;
});
/**批量调整点位 */
batchChange() {
this.statementChangeList.forEach((item,index) => {
item.chargesPercentage = this.policyNototal;
this.onExchangeChange(index);
this.change(index) ;
});
},
/**特殊方法处理 */
/** 更改el-table input 批量赋值显示问题 */
onExchangeChange: function (index) {
let tmpObj = this.statementChangeList[index];
this.$set(this.statementChangeList, index, tmpObj);
},
change: function (index) {
// 重新赋值
let tmpObj = this.statementChangeList[index];
this.$set(this.statementChangeList, index, tmpObj);
}
更多推荐
已为社区贡献2条内容
所有评论(0)