美文网首页
element ui 中table实现默认勾选(主要用在编辑中)

element ui 中table实现默认勾选(主要用在编辑中)

作者: alive02 | 来源:发表于2018-07-26 18:41 被阅读0次

    template

      <div class="dial-header">
                <el-dialog title="选择批次" :visible.sync="Index.BatchEdit">
                    <el-table ref="multipleTable" :data="tableDataEdit" tooltip-effect="dark" style="width:100%" @selection-change="handleSelectionChangeEdit">
                        <el-table-column type="selection" prop="id"></el-table-column>
                        <el-table-column prop="id" label="批次ID"></el-table-column>
                        <el-table-column prop="batch_name" label="批次名称"></el-table-column>
                        <el-table-column prop="create_time" label="创建时间"></el-table-column>
                        <el-table-column prop="remain_count" label="剩余条数"></el-table-column>
                    </el-table>
                    <div slot="footer" class="dialog-footer">
                        <el-button type="primary" @click="saveChangeEdit">确定</el-button>
                    </div>
                    <div class="pagination">
                            <div class="block"> 
                                <el-pagination
                                    @current-change="handleCurrentChangeEdit"
                                    :current-page="pag.currentPage"
                                    :page-sizes="[10]"
                                    :total="pag.total"
                                    layout="total, sizes, prev, pager, next, jumper">
                                </el-pagination>
                            </div>
                        </div>
                    <el-dialog>
            </div>
           //下面是根据后台返回的数组中的asrcall_id 字段是否为0判断的(主要是setTimeout)
          <script>
              this.tableDataEdit.forEach((row,index)=>{
                if(row.asrcall_id != 0){
                     setTimeout(()=>{  
                         this.batchIds.push(row.id)
                         this.$refs.multipleTable.toggleRowSelection(this.tableDataEdit[index])
                          },1)
                      }
                })
    </script>
    

    相关文章

      网友评论

          本文标题:element ui 中table实现默认勾选(主要用在编辑中)

          本文链接:https://www.haomeiwen.com/subject/msfimftx.html