表格:
<el-table ref="tablestu" v-bind:data="tablestu.items" size="mini" fit stripe border
v-on:selection-change="selstuchange"
style="margin:1px;" :height="tablestu.height">
<el-table-column type="selection" align="center"></el-table-column>
<el-table-column label="" prop="rowid" width="50" align="center"></el-table-column>
<el-table-column label="学期" prop="term" width="100" align="center"></el-table-column>
<el-table-column label="开课单位" prop="dptname" width="200" header-align="center"></el-table-column>
<el-table-column label="课程代码" prop="courseid" width="100" align="center"></el-table-column>
<el-table-column label="课程序号" prop="courseno" width="120" align="center"></el-table-column>
<el-table-column label="课程名称" prop="cname" width="300" header-align="center" show-overflow-tooltip></el-table-column>
<el-table-column label="任课教师" prop="name" width="100" align="center"></el-table-column>
<el-table-column label="学号" prop="stid" width="120" align="center"></el-table-column>
<el-table-column label="姓名" prop="stname" width="100" align="center"></el-table-column>
<el-table-column label="分数" prop="score" width="80" align="center"></el-table-column>
<el-table-column label="成绩类别" prop="stype" width="110" align="center">
<template slot-scope="scope">
<div v-if="!scope.row.iseditstype">
<a href="#" v-on:click="scope.row.iseditstype=true;selstu.currentid=scope.row.id">{{scope.row.stype}}</a>
</div>
<div v-else>
<el-select v-model="scope.row.stype" size="mini" placeholder="请选择" style="width:100px;"
v-on:change="stustypechange"
v-on:visible-change="closestustype">
<el-option v-for="item in sstype"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</div>
</template>
</el-table-column>
<el-table-column label="考试类别" prop="ttype" width="80" align="center"></el-table-column>
</el-table>
data中:
  selstu: {
                    stus: [],
                    stype: '',
                    ttype: '',
                    currentid: ''
                }相关方法:
 srh: function () {
                var that = this;
                var p = this.formsrh;
                p.rows = this.tablestu.rows;
                p.page = this.tablestu.page;
                $.post('/admin_areas/examination/ListBuKaoStu', p, function (res) {
                    accecpResult(res, function () {
                        res.data.rows.forEach(item => {
                            item.iseditstype = false;
                            item.iseditttype = false;
                        })
                        that.tablestu.items = res.data.rows;
                        that.tablestu.total = res.data.total;
                    })
                })
            },
stustypechange: function (val) {
                var p = {
                    id: this.selstu.currentid,
                    stype: val
                }
                var that = this;
                $.post('/admin_areas/examination/editbkstype', p, function (res) {
                    accecpResult(res, function () {
                        that.tablestu.items.forEach(item => {
                            if (item.id == that.selstu.currentid) {
                                item.iseditstype = false;
                            }
                        })
                    }, function () {
                        that.$message.error(res.data);
                    })
                })
            },
            closestustype: function (val) {
                if (val == false) {
                    this.tablestu.items.forEach(item => {
                        if (item.id == this.selstu.currentid) {
                            item.iseditstype = false;
                        }
                    })
                }
            },思路说明:
 1、srh方法获取数据中,将各行数据增加属性iseditstype ,以此属性来切换正常显示与下拉框显示。
 2、正常显示时,显示一个链接,点击后修改该行的iseditstype值,并记录下该行id,代码: {{scope.row.stype}} 3、下拉框显示时,处理两个事件:visible-change和change,前者是下拉面板显示状态,后者是值发送改变
 下拉面板隐藏时,修改该行的iseditstype值为false,改为正常显示。
 值改变时,向后端发送修改请求,响应成功后修改isedittype的值。
 通过selstu.currentid来确定当前操作的行id
                










