<template> <div slot="header" class="clearfix"> <el-button :loading="false" icon="el-icon-edit" @click="saveTableData()" plain> 修改保存 </el-button> <el-button :loading="false" icon="el-icon-refresh" @click="reflush()" > 刷新 </el-button> <el-button :loading="false" icon="el-icon-success" @click="selectAll('Y')" > 全选 </el-button> <el-button :loading="false" icon="el-icon-error" @click="selectAll('N')" > 全不选 </el-button> <div class="currentPage"> <c-table :list="tableData" :border="true" height="calc(100vh - 350px)" ref="refTable"> <el-table-column label="机构号" prop="accbch"> <template slot-scope="scope">{{scope.row.accbch}}</template> </el-table-column> <el-table-column label="机构名称" prop="bchname"> <template slot-scope="scope">{{scope.row.bchname}}</template> </el-table-column> <el-table-column label="试点机构" prop="ispilot"> <template slot-scope="scope"> <el-checkbox v-model="scope.row.ispilot" true-label="Y" false-label="N" ></el-checkbox> </template> </el-table-column> </c-table> </div> <!-- <span>共{{this.tableData.length}}条</span> --> </div> </template> <script> import PilotbchModel from "./PilotbchModel.js"; import Utils from "~/utils"; import { queryList, updateBatch } from "~/service/manage/pilotbch.js"; import commonFunctions from "~/mixin/commonFunctions.js"; export default { mixins: [commonFunctions], props:{ }, data(){ return{ tableData:null, } }, mounted(){ this.searchTable() }, methods:{ // 列表查询 searchTable(){ const loading = this.loading(); queryList() .then((res)=>{ this.tableData = res.data; loading.close(); }) .catch((err)=>{ this.$notify.error("查询失败!"); loading.close(); }); }, reflush(){ this.searchTable() }, selectAll(a){ for(let i = 0; i < this.tableData.length; i++){ this.tableData[i].ispilot = a } }, // 批量更新 saveTableData(){ const loading = this.loading(); updateBatch(this.tableData) .then((res)=>{ this.$notify.success("更新成功!"); this.searchTable(); loading.close(); }) .catch((err)=>{ this.$notify.error("更新失败!"); loading.close(); }); }, } } </script> <style lang="less" scoped> .currentPage{ .el-table--enable-row-hover { .el-table__body { tr:hover>td { background-color: #c694dc !important; } } } ::v-deep .el-checkbox { float: none; } } </style>