在table數(shù)據(jù)中加一個disabled屬性的值
async getData() {
let vm = this;
vm.loading = true;
let list = await vm.$fetch(vm.$path+'received/BatchCodeWithdrawalInfo/', {
page: vm.cur_page,
size: vm.pageSize,
search: vm.select_word,
});
vm.loading = false;
if( list){
let table = list.dataInfo.listData;
// vm.tableData.newParam ='vVisible';
if(table){
for(let i=0; i<table.length; i++){
table[i]["vVisible"] = true;
}
}
vm.tableData = table;
vm.totalcount = list.dataInfo.pageInfo.total_size;
}
}, // 獲取table數(shù)據(jù)
將disabled屬性動態(tài)綁定至對象中對應的vVisible中
<el-table-column
align="center"
prop=""
label="樣品信息"
width="120">
<template slot-scope="scope">
<el-input v-model="scope.row.sample_info" :disabled='scope.row.vVisible'>
</el-input>
</template>
</el-table-column>
點擊事件傳遞index參數(shù)
<el-button
@click="handleEdit(scope.$index, scope.row)" size="small" type="primary" round>編輯
</el-button>
改變點擊行的disabled屬性
handleEdit(index,row){
if(this.tableData[index].vVisible == false){
this.tableData[index].vVisible=true;
}else{
this.tableData[index].vVisible = false;
}
}, // 退倉信息是否可編輯