<template> <div class="currentPage"> <el-card shadow="always"> <div slot="header" class="clearfix"> <el-button :loading="false" v-if="isShowBtn" icon="el-icon-edit" @click="saveTableData()" plain> 修改保存 </el-button> </div> <c-table :list="tableData" :border="true" 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="hdlath"> <template slot-scope="scope"> <el-checkbox v-model="scope.row.hdlath" true-label="1" false-label="0" :disabled="!isShowBtn"></el-checkbox> </template> </el-table-column> </c-table> </el-card> </div> </template> <script> import UsrModel from "./UsrModel.js"; import { queryList, updateBatch } from "~/service/manage/usrorg.js"; import Utils from "~/utils"; import commonFunctions from "~/mixin/commonFunctions.js"; export default { mixins: [commonFunctions], props:{ btnType:String }, watch:{ // 会出现父组件传真,子组件更新不及时的情况 btnType:{ handler:function(newValue,oldValue){ if(newValue == "info"){ this.isShowBtn = false; } }, // 强制立即执行回调 immediate:true } }, data(){ return{ model:new UsrModel().data.relatedOrg, tableData:null, currentUserId: '', isShowBtn:true, } }, methods:{ // 列表查询 searchTable(userId){ const loading = this.loading(); this.currentUserId = userId; this.model.userdetailsid = userId; queryList(this.model) .then((res)=>{ this.tableData = res.data; loading.close(); }) .catch((err)=>{ this.$notify.error("查询失败!"); loading.close(); }); }, // 批量更新 saveTableData(){ updateBatch(this.tableData) .then((res)=>{ this.$notify.success("更新成功!"); this.searchTable(this.currentUserId); }) .catch((err)=>{ this.$notify.error("更新失败!"); }); }, } } </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>