el-table点击⼀⾏数据,checkBox⾃动勾选Demo,table实现
⾏内编辑
效果:
代码:
<el-table ref="table"
border
:height="tableHeight"
v-loading="loading"
:data="tableDate"
@lection-change="lectItem"
@row-click="openDetails"
>
<el-table-column type="lection" width="55" :rerve-lection="fal"></el-table-column>
<el-table-column prop="name" :show-overflow-tooltip="true" align="center" label="通道名称"/>
<el-table-column prop="runDevName" :show-overflow-tooltip="true" align="center" label="通道编号"/>
<el-table-column prop="city" :show-overflow-tooltip="true" align="center" label="所属地市"/>
<el-table-column prop="maintOrg" :show-overflow-tooltip="true" align="center" label="运维单位"/>
<el-table-column prop="maintGroup" :show-overflow-tooltip="true" align="center" label="维护班组"/>
<el-table-column prop="startPosition" :show-overflow-tooltip="true" align="center" label="起点位置">
<template scope="scope">
<el-lect v-model="w.startPosition" v-show="w.show" placeholder="请选择">
<el-option
v-for="item in dydjbm"
:key="item.value"
:label="item.label"
:value="item.label">
爱情三要素理论
</el-option>
</el-lect>
<span v-show="!w.show">{{w.startPosition}}</span>
</template>
</el-table-column>
<el-table-column prop="endPosition" :show-overflow-tooltip="true" align="center" label="终点位置">
<template scope="scope">
<el-lect v-model="dPosition" v-show="w.show" placeholder="请选择">
<el-option
v-for="item in dydjbm"
:key="item.value"
:label="item.label"
:value="item.label">
</el-option>
</el-lect>
<span v-show="!w.show">{{dPosition}}</span>
</template>
</el-table-column>
<el-table-column prop="startName" :show-overflow-tooltip="true" align="center" label="起点名称">
<template scope="scope">
<el-input size="small" v-model="w.startName" v-show="w.show" placeholder="请输⼊内容"></el-input> <span v-show="!w.show">{{w.startName}}</span>
</template>
</el-table-column>
<el-table-column prop="endName" :show-overflow-tooltip="true" align="center" label="终点名称">
<template scope="scope">
<el-input size="small" v-model="dName" v-show="w.show" placeholder="请输⼊内容"></el-input> <span v-show="!w.show">{{dName}}</span>
第一诫结局
</template>
</el-table-column>
<el-table-column prop="operateDate" :show-overflow-tooltip="true" align="center" label="投运⽇期"/>
<el-table-column label="操作" width="200" :show-overflow-tooltip="true" align="center" fixed="right">
<template slot-scope="scope">
<el-button size="mini" type="primary" @click="w)">定位</el-button>
listed<el-button type="success" size="mini" @click="w)">编辑</el-button>
</template>
</el-table-column>
</el-table>
js代码:
export default {
鼓楼山
name: "index",
data() {
return {
dialogVisible: fal,
title:'⼋台⾥通道详情',
flags: 'new',
lectlist: [], // 选择的table数据
isCheckDate: true,
tableDate:[],
loading: fal,
tableHeight: "calc(100vh - 300px)",
dydjbm: [{
value: '选项1',
label: '黄⾦糕'
}, {
value: '选项2',
label: '双⽪奶'
}],
}
},
created() {
let list=[{
name: '222',
runDevName: '2834832492',
city: '张家⼝22222222222222222222222222222222', maintOrg: '运维单位',
maintGroup: 'jsidfs班组',
startPosition: '选项1',
endPosition: '选项1',
startName: '展⽰⼲的张',
endName: '展⽰⼲sss的张',
operateDate: '投运⽇期'
},{
name: '3332',
runDevName: '2834832492',
city: '张家⼝',
maintOrg: '运维单位',
maintGroup: 'jsidfs班组',
startPosition: '选项1',
endPosition: '选项1',
startName: '展⽰⼲的张',
endName: '展⽰⼲sss的张',
operateDate: '投运⽇期'
}];
// 遍历table每⼀个项,并且追加show属性
list.forEach(element => {
element["show"] = fal
});
this.tableDate = list;
},
methods:{
toMap(row){
this.$emit('gotoMap',row)
},
// 保存
save(){
this.lectlist[0].show = fal;
琴棋书画的棋指的是什么
this.$message({
type: 'success',
message: '数据保存成功!'
});
});
},
// 删除
deleteData(){
this.$confirm('确定要删除该条数据吗?', '提⽰', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$message({
type: 'success',
message: '删除成功!'
});
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
},
//添加
add(){
this.flags = 'new';
this.title='通道新增';
this.dialogVisible = true;
},
//修改
edit(){
if (this.lectlist.length !==0) {
this.flags = 'new';
this.title='通道修改';
this.dialogVisible = true;
}
},
//编辑
editLine(row){
row.show = true;
},
重庆周边古镇// 详情
getDetail(){
if (this.lectlist.length !==0) {
this.$store.dispatch('tdgj/tBmArr', this.lectlist[0]); this.flags = 'info';
this.title='通道详情';
this.dialogVisible = true;
}
},
// 当某⼀⾏被点击时会触发该事件 row, column, event
openDetails(row){
this.lectlist= [];
this.lectlist.push(row);韩国烤肉
this.$refs.table.clearSelection();
this.$leRowSelection(row);
},
//当选择项发⽣变化时会触发该事件
lectItem(rows) {
if (rows.length > 1 || rows.length == 0) {
this.isCheckDate = true;
var newRows = rows.filter((it, index) => {
this.$leRowSelection(it).show = fal; });
this.lectlist = newRows;
} el {
this.isCheckDate = fal;
this.lectlist = rows;
this.lectlist = rows; }
}
年会主持稿}
}