<template>
  <div class="page_user page_search" >
    <div class="page_jg"></div>
    <el-tabs  v-model="teachingTabType" @tab-click="HandleTabClick">
        <el-tab-pane label="授课关系" name="relation">
          <div class="content_container search_content">
            <div class="container_left content_left">
              <el-input v-model="teacherName" @input="GetTeacherTableData" placeholder="教师姓名，编号"><el-button slot="append" icon="el-icon-search"></el-button></el-input>
              <div class="right_table" style="width: 100%;margin-top: 18px;">
                <el-table :data="teacherTableData" border :highlight-current-row="true" :height="leftTableHeight"
                :row-class-name="TableRowClassName"
                  @row-click="CheckedTeacher"  width="100%" stripe >
                  <el-table-column prop="userAccount" label="账号" align="center"></el-table-column>
                  <el-table-column prop="teacherName" label="教师" align="center">
                  </el-table-column>
                </el-table>
              </div>
            </div>
            <div class="container_right">
              <div class="search_content">
                <div class="content_left">
                    <el-select v-model="schoolYearId" @change="ChangeSchoolYearId" placeholder="请选择" class="select_year" >
                      <el-option v-for="item in schoolYearIdList" :key="item.id" :label="item.schoolYearName" :value="item.id">
                      </el-option>
                    </el-select>
                    <el-select v-model="schoolYearGradeId"  @change="ChangeSchoolYearGradeId" placeholder="请选择" class="select_width">
                      <el-option v-for="item in schoolYearGradeIdList" :key="item.id" :label="item.gradeName" :value="item.id">
                      </el-option>
                    </el-select>
                </div>
                <div class="content_right el_button">
                    
        
                    <el-button :loading="exportLoading" @click="BatchExportTeacher()">批量导出</el-button>
                    <el-button  @click="BatchImportTeacher()">批量导入</el-button>
                    <el-button  @click="ClearAllTeacherCourse"   type="text" class="delete_item" plain>清空授课</el-button>
                    <!-- 未开发完成 先注释 -->
                    <!-- <el-button  @click="ExportTeacherList" type="text" plain class="editor_item">批量导出</el-button> -->
                </div>
              </div>
              <div class="page_jg"></div>
              <div class="content_table">
                <el-tabs v-model="classTabType" @tab-click="HandleClick">
                  <el-tab-pane class="xzb" label="行政班" name="0">
                    <div class="page_table" >
                      <el-table stripe :data="administrativeClassData.tableData"
                      ref="teacherTable"
                      :key="tableKey"
                      v-loading="isSetLoading"
                      element-loading-text="加载中"
            element-loading-spinner="el-icon-loading"
            element-loading-background="transparent"
     border :height="tableHeight"  style="width:100%;">
                        
                        <el-table-column fixed width="80" label="班级" align="center">
                          <template slot-scope="scope">
                            <div style="white-space: pre-line;">{{scope.row?.className=="年级组长/备课组长"?'年级组长\n备课组长':scope.row.className }}</div>
                          </template>
                        </el-table-column>
                        <el-table-column fixed label="班主任" min-width="120"  align="center">
                          <template slot-scope="scope">
                                  <div v-if="checkedTeacherToSet" class="row_content"  @click="SetHeadTeacherItem(scope.row)">
                                    <div  class="tag_content" v-if="scope.row.classMasterNames && scope.row.classMasterNames.length>0">
                                      <div class="content_teacher" v-for="(teacher, idx) in scope.row.classMasterNames"  :key="idx">
                                        <el-tooltip class="item" effect="dark" :content="`${teacher.teacherName} ${teacher.userAccount}`" placement="top" :disabled="!teacher.teacherName">
                                          <span class="content_teacher_item">
                                            <span>{{ teacher.teacherName }}</span>
                                            <img src="@/assets/icon/close_teacher.webp" @click.stop="DeleteHeadTeacherCourse(teacher)">
                                          </span>
                                        </el-tooltip>
                                        <!-- <i class="el-icon-error"  ></i> -->
                                      </div>
                                    </div>
                                    
                                    <div v-else class="content_item">请选择教师</div>
                                  </div>
                                  <div v-else class="tag_content"> 
                                    <span class="content_text" v-for="(teacher, idx) in scope.row.classMasterNames"  :key="idx">
                                      <el-tooltip class="item" effect="dark" :content="`${teacher.teacherName} ${teacher.userAccount}`" placement="top" :disabled="!teacher.teacherName">
                                        <span>{{ teacher.teacherName }}</span>
                                      </el-tooltip>
                                    </span>
                                    <span  v-if="scope.row.classMasterNames==null || scope.row.classMasterNames.length==0">-</span>
                                  </div>       
                          </template>
                        </el-table-column>
                        <el-table-column v-for="(column, columnIndex) in administrativeClassData.tableColumn" :key="columnIndex"  :prop="column.id"  :label="column.courseName" min-width="120" align="center">
                          <template slot-scope="scope">
                              <div v-if="checkedTeacherToSet" class="row_content" @click="SetTeacherItem(scope.row,column,columnIndex)">
                                <div class="tag_content" v-if="scope.row.values[columnIndex].length>0">
                                  <div class="content_teacher" v-for="(teacher, idx) in scope.row.values[columnIndex]"  :key="idx">
                                    <el-tooltip class="item" effect="dark" :content="`${teacher.teacherName} ${teacher.userAccount}`" placement="top" :disabled="!teacher.teacherName">
                                      <span class="content_teacher_item">
                                        <span>{{ teacher.teacherName }}</span>
                                        <img src="@/assets/icon/close_teacher.webp" @click.stop="DeleteTeacherCourse(teacher,column)">
                                      </span>
                                    </el-tooltip>
                                    <!-- <i class="el-icon-error"  ></i> -->
                                  </div>
                                </div>
                                <div class="content_item" v-if="scope.row.values[columnIndex].length==0" >请选择教师</div>
                              </div>
                              <div v-else class="tag_content">
                                  <span  class="content_text" v-for="(teacher, idx) in scope.row.values[columnIndex]"  :key="idx">
                                    <el-tooltip class="item" effect="dark" :content="`${teacher.teacherName} ${teacher.userAccount}`" placement="top" :disabled="!teacher.teacherName">
                                      <span>{{ teacher.teacherName }}</span>
                                    </el-tooltip>
                                  </span>
                                  <span v-if="scope.row.values[columnIndex].length==0">-</span>
                              </div>
                          </template>
                        </el-table-column>
                      </el-table>
                    </div>
                  </el-tab-pane>
                  <el-tab-pane class="jxb"  label="教学班" name="1">
                    <div class="page_table" >
                      <el-table stripe :data="teachingClassData.tableData" 
                      :key="tableKey"
                      v-loading="isSetLoading"
                      element-loading-text="加载中"
                      element-loading-spinner="el-icon-loading"
                      element-loading-background="transparent"
                      border :height="tableHeight" style="width:100%;">

                        <!-- <el-table-column fixed label="班主任"  align="center">
                          <template slot-scope="scope">
                                  <div v-if="checkedTeacherToSet"  class="tag_content" @click="SetHeadTeacherItem(scope.row)">
                                    <template v-if="scope.row.classMasterNames && scope.row.classMasterNames.length>0">
                                      <div class="content_teacher" v-for="(teacher, idx) in scope.row.classMasterNames"  :key="idx"  >
                                        <span>{{ teacher.teacherName }}</span>
                                        <i class="el-icon-error"  @click.stop="DeleteHeadTeacherCourse(teacher)"></i>
                                      </div>
                                    </template>
                                    
                                    <div v-else class="content_item">请选择教师</div>
                                  </div>
                                  <div v-else>
                                    <span v-for="(teacher, idx) in scope.row.classMasterNames"  :key="idx">
                                      {{ teacher.teacherName }}
                                    </span>
                                    <span v-if="scope.row.classMasterNames==null || scope.row.classMasterNames.length==0">-</span>
                                  </div>       
                          </template>
                        </el-table-column> -->
                        <el-table-column v-for="(column, columnIndex) in teachingClassData.tableColumn" :key="columnIndex"  :prop="column.id" min-width="185"  :label="column.courseName"  align="center">
                          <template slot-scope="scope">
                              <div v-if="checkedTeacherToSet" class="row_content"  @click="SetTeachingClassTeacher(scope.row,column,columnIndex)">
                                <div class="tag_teacher_content">

                                
                                  <div class="content_title">
                                    {{scope.row[columnIndex].className}}
                                  </div>
                                  
                                  <div  class="content_value" v-if="scope.row[columnIndex].values ==null || scope.row[columnIndex].values.length==0">
                                    <div class="content_item" v-show="scope.row[columnIndex].className">请选择教师</div>
                                  </div>
                                  <div class="content_value" v-else>
                                    <div class="content_teacher" v-for="(teacher, idx) in scope.row[columnIndex].values"  :key="idx">
                                      <el-tooltip class="item" effect="dark" :content="`${teacher.teacherName} ${teacher.userAccount}`" placement="top" :disabled="!teacher.teacherName">
                                        <span class="content_teacher_item">
                                          <span>{{ teacher.teacherName }}</span>
                                          <img src="@/assets/icon/close_teacher.webp" @click.stop="DeleteTeacherCourse(teacher,column)">
                                        </span>
                                      </el-tooltip>
                                    </div>
                                  </div>
                                </div>
                              </div>
                              <div v-else class="row_content" >
                                <div  class="tag_teacher_content">
                                  <div class="content_title">
                                    {{scope.row[columnIndex].className}}
                                  </div>
                                  <div  class="content_value" v-if="scope.row[columnIndex].values ==null || scope.row[columnIndex].values.length==0">
                                  <div class="content_no_data" v-if="scope.row[columnIndex].className">-</div> 
                                  </div>
                                  <div class="content_value" v-else>
                                    <div class="content_text" v-for="(teacher, idx) in scope.row[columnIndex].values"  :key="idx">
                                      <el-tooltip class="item" effect="dark" :content="`${teacher.teacherName} ${teacher.userAccount}`" placement="top" :disabled="!teacher.teacherName">
                                        <span>{{ teacher.teacherName }}</span>
                                      </el-tooltip>
                                      <!-- <i class="el-icon-error"  @click.stop="DeleteTeacherCourse(teacher,column)"></i> -->
                                    </div>
                                    
                                  </div>
                                  </div>
                              </div>
                          </template>
                        </el-table-column>
                      </el-table>
                    </div>
                    
                  </el-tab-pane>
                </el-tabs>
                <div class="table_switch" ref="showTeachList">
                  <div v-if="checkedTeacherToSet">
                    <span class="" v-if="selectedTeacher.teacherName">当前选中的教师：{{ selectedTeacher.teacherName }} {{ selectedTeacher.userAccount }}</span>
                    <span v-else>暂无选中的教师</span>
                  </div>
                  <el-switch
                      style="display: block"
                      
                      v-model="checkedTeacherToSet"
                      active-text="选中教师配置任课关系"
                      inactive-text=""
                    >
                  </el-switch>
                </div>
              </div>
            </div>
          </div>
        </el-tab-pane>
        <el-tab-pane label="授课列表" name="list">
          <div class="search_content">
            <div class="content_left">
              <el-select v-model="teacherCourseParam.schoolYearId" @change="ChangeParamSchoolYearId" placeholder="请选择" class="select_year">
                <el-option v-for="item in teacherCourseParam.schoolYearIdList" :key="item.id" :label="item.schoolYearName" :value="item.id">
                </el-option>
              </el-select>
              <el-select v-model="teacherCourseParam.schoolYearGradeId" @change="ChangeParamSchoolYearGradeId" placeholder="请选择" class="select_width">
                <el-option v-for="item in teacherCourseParam.schoolYearGradeIdList" :key="item.id" :label="item.gradeName" :value="item.id">
                </el-option>
              </el-select>
              <el-select v-model="teacherCourseParam.classType" @change="ChangeClassType"  placeholder="请选择" class="select_width">
                <el-option label="全部类别" value=""></el-option>
                <el-option label="行政班" value="0"></el-option>
                <el-option label="教学班" value="1"></el-option>
              </el-select>
              <el-select v-model="teacherCourseParam.classId" @change="ChangeFilterItem" placeholder="请选择" class="select_width">
                <el-option label="全部班级" value=""></el-option>
                <el-option v-for="item in classList" :key="item.id" :label="item.className" :value="item.classId">
                </el-option>
              </el-select>
              <el-select v-model="teacherCourseParam.roleId" @change="ChangeRole" placeholder="请选择" class="select_width">
                <el-option label="全部角色" value=""></el-option>
                <el-option v-for="item in roleList" :key="item.id" :label="item.roleName" :value="item.id">
                </el-option>
              </el-select>
              <el-input v-model="teacherCourseParam.teacherName" @input="ChangeFilterItem" placeholder="教师姓名，编号" class="input_width">
                
                <el-button slot="append" icon="el-icon-search"></el-button>
              </el-input>
            </div>
            <div class="content_right el_button">
              <el-button  @click="ClearAllTeacherCourse" type="text" class="delete_item" plain>清空授课</el-button>
              <!-- 未开发完成 先注释 -->
              <!-- <el-button  @click="ExportTeacherList" type="text" plain class="editor_item">批量导出</el-button> -->
            </div>
          </div>
          <div class="page_jg_20"></div>
          <div  class="page_table">
            <el-table :data="teacherCourseList" ref="teacherCourseTable" stripe  border :height="listTableHeight"  style="width:100%;">
              <el-table-column  label="序号" type="index" :index="GetIndexNumber" width="80" align="center">
              </el-table-column>
              <el-table-column  min-width="120" prop="userAccount" label="账号" align="center">
              </el-table-column>
              <!-- <el-table-column  min-width="120" prop="teacherCode" label="教师编号" align="center">
              </el-table-column> -->
              <el-table-column  min-width="100" prop="teacherName" label="教师姓名" align="center">
              </el-table-column>
              <el-table-column  min-width="100" prop="roleName" label="角色" align="center">
              </el-table-column>
              <el-table-column  min-width="100" prop="courseName" label="科目" align="center">
              </el-table-column>
              <el-table-column  min-width="100" prop="className" label="班级" align="center">
              </el-table-column>
              <el-table-column width="150" label="操作" align="center" :fit="true">
                <template slot-scope="scope">
                  <div class="table_row_option">
                      <!-- <div  class="button_editor"  @click="ResetPassWord(scope.row)">重置密码</div> -->
                      <div  class="button_delete"  @click="DeleteTeacherCourse(scope.row)">删除</div>
                  </div>
                </template>
              </el-table-column>
            </el-table>
          </div>
          <div class="page_pagination" >
              <el-pagination
                  @current-change="ChangePage"
                  background
                  layout="sizes,prev, pager, next"
                  @size-change="HandleSizeChange"
                  :page-sizes="[20,50,100]"
                  :current-page="pageInfo.pageNum"
                  :total="pageInfo.total">
              </el-pagination>
          </div>
        </el-tab-pane>
    </el-tabs>
    <div class="page_dialog">
        <!-- 重置密码 -->
        <el-dialog title="重置密码" center :visible.sync="editPassWordData.dialogShow" width="480px">
          <div class="dialog_center padding_20">
            <el-form :model="editPassWordData" label-width="110px" :rules="editPassWordDataRules" ref="editPassWordData">
              <el-form-item label="教师编号：">
                <el-input v-model="editPassWordData.teacherCode" disabled/>
              </el-form-item>
              <el-form-item label="教师姓名： ">
                <el-input v-model="editPassWordData.teacherName" disabled/>
              </el-form-item>
              <el-form-item label="新密码：" prop="newPassWord">
                <el-input v-model="editPassWordData.newPassWord"/>
              </el-form-item>
            </el-form>
          </div>
          <!-- <div style="color:#999; font-size:12px;line-height:16px;margin-top:10px;">注：多个教师编号用逗号隔开，可一一对应多个新密码用逗号隔开，如果密码不存在逗号，则所有教师的密码都为一样，如果为唯一密码，且中间存在*，则密码会把*替换成教师编号
    </div> -->
          <div slot="footer" class="dialog-footer">
            <el-button size="small" @click="editPassWordData.dialogShow = false">取 消</el-button>
            <el-button size="small" type="primary" @click="confirmPassWord">确 定</el-button>
          </div>
        </el-dialog>
        <!-- 重置密码 批量设置 -->
        <el-dialog title="重置密码" center width="450px" :visible.sync="editMultiplePassWordData.dialogShow">
          <el-form :model="editMultiplePassWordData" label-width="80px" :rules="editMultiplePassWordDataRules" ref="editMultiplePassWordData">
            <el-form-item label="教师编号:" prop="teacherIds">
              <el-input type="textarea"
                :rows="4"
                v-model="editMultiplePassWordData.teacherIds"/>
            </el-form-item>
            <el-form-item label="新密码:" prop="newPassWord">
              <el-input v-model="editMultiplePassWordData.newPassWord"/>
            </el-form-item>
          </el-form>
          <div style="color:#999; font-size:12px;line-height:16px;margin-top:10px;">注：多个教师编号用逗号隔开，可一一对应多个新密码用逗号隔开，如果密码不存在逗号，则所有教师的密码都为一样，如果为唯一密码，且中间存在*，则密码会把*替换成教师编号

      </div>
          <div slot="footer" class="dialog-footer">
            <el-button size="small" @click="editMultiplePassWordData.dialogShow = false">取 消</el-button>
            <el-button size="small" type="primary" @click="confirmMultiplePassWord">确 定</el-button>
          </div>
        </el-dialog>
        <!-- 批量导入 -->
        <el-dialog title="教师批量导入" center  :visible.sync="batchImportData.dialogShow" width="600px">
          <div class="dialog_center padding_20">
            <el-form :model="batchImportData" label-width="160px" :rules="batchImportDataRules" ref="batchImportData" >
              <el-form-item label="当前学年学期：">
                <el-input :value="batchImportData.selectSchoolYearName" disabled  style="width:300px;"/>
              </el-form-item>
             
              <el-form-item label="班级类型：" prop="schoolClassType">
                <el-radio-group v-model="batchImportData.schoolClassType">
                  
                  <el-radio label="0">行政班</el-radio>
                  <el-radio label="1">教学班</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="选择文件：">
                <div class="">
                  <el-button type="primary" size="small" @click="OpenUpload" >点击上传</el-button>
                  <span class="upload_file_name">{{batchImportData.fileName}}</span>
                  <!-- <el-input style="width:240px;" v-model="batchImportData.fileName" clearable size="mini"></el-input> -->
                  <input type="file" ref="uploadTeachers" @change="UploadChange" enctype="multipart/form-data" style="display:none;"/>
                </div>
                  
              </el-form-item>
              
            </el-form>
          </div>
          <div slot="footer" class="dialog-footer">
            <el-button size="small" @click="CancelBatchImport">取 消</el-button>
            <el-button size="small" type="primary" @click="ConfirmBatchImport" :disabled="isSubmitting"><i class="el-icon-loading" v-if="isSubmitting"></i>确 定</el-button>
          </div>
        </el-dialog>
    </div>
  </div>
</template>
<script>
import { throttle,debounce } from '@/utils/common';

import base from '@/http/common/base';


export default {
  data() {
    return {
      teachingTabType: "relation", //relation授课关系 list授课列表
      uploadUrl:base.baseUrl + `/api/v1/teach/schoolTeacherInfo/importTeacherInfo`,
      selGradeYear: {
        value: "",
        arr: []
      },
      selTermList: {
        value: "",
        arr: []
      },
      teacherTreeList: [],
      classData: [],
      defaultPropsClass: {
        children: 'teacherList',
        label: 'username',
        labelId: 'id'
      },
      checkedTeacherToSet:false,//是否选中教师配置任课关系
      colShowTeacher:false,
      selectedTeacher:{},
      administrativeClassData:{
        tableData:[],
        tableColumn:[],
      },//行政班数据
      teachingClassData:{
        tableData:[],
        tableColumn:[],
      },//教学班数据

      teacherName:'',//教师姓名 搜索
      teacherTableData:[],//教师表格数据


      colShowTeacherClassList:[],//教师任课详情
      teacherCourseList:[],//教师授课列表
      
      classTabType:0, //0 行政班  1 教学班 
      classTableHeader1:[
        // {
        //     "id":"classManagerList",
        //     "titleName":"班主任"
        // },
       
    ],
      classTableHeader2:[],
      mergedHeader: [],
      
      // [
      //   {
      //     prop: "physicalClassData",
      //     label: ""
      //   },
      //   {
      //     prop: "physicalClassTeacher",
      //     label: "物理"
      //   },
      //   {
      //     prop: "geographyClassData",
      //     label: ""
      //   },
      //   {
      //     prop: "geographyClassTeacher",
      //     label: "地理"
      //   },
      // ],
      editTeacherData:{   //教师数据 编辑添加
        dialogShow:false,
        teacherCode:"",
        username:"",
        teacherDepartmentCode:"",
        teacherDepartmentName:"",
        teacherDuty:""
      },
      editTeacherDataRules:{
        teacherCode:[
            { required: true, message: '请输入教师编号', trigger: 'blur' },
          ],
          username:[
            { required: true, message: '请输入教师名称', trigger: 'blur' },
        ],
      },
      editPassWordData:{
        dialogShow:false,
        newPassWord:"",
        teacherName:"",
        userInfoId:"",
        teacherCode:""
      },
      editPassWordDataRules:{
        newPassWord:[
          { required: true, message: '请输入新密码', trigger: 'blur' },
        ],
      },
      editMultiplePassWordData:{
        dialogShow:false,
        teacherIds:"",
        newPassWord:""
      },
      editMultiplePassWordDataRules:{
        teacherIds:[
          { required: true, message: '请输入老师编号', trigger: 'blur' }
        ],
        newPassWord:[
          { required: true, message: '请输入新密码', trigger: 'blur' },
        ],
      },
      teacherDetails:[{
        teacherId:"1",
        teacherName:"11",
        classLeader:"22",
        courseName:"3",            
        classNumber:"4",
        className:"5",
      }],
      gradeClassArr:[
        {
          label:"授课关系",
          value:false
        },
        {
          label:"授课列表",
          value:true
        }
      ],
      loading: true,
      activeTab: 'admin',
      mainHeight:0,

      schoolYearId:'',//学年ID
      schoolYearName:'',//学年名称
      schoolYearIdList:[],//学年ID列表
      schoolYearGradeId:'',//年级id
      schoolYearGradeName:'',//年级名称
      schoolYearGradeIdList:[],//年级ID列表
      

      isSubmitting:false,//批量导入是否正在提交
      batchImportData:{
        dialogShow:false,
        selectSchoolYearId:'',//当前的学年
        selectSchoolYearName:'',//当前的学年名称
        selectSchoolYearGradeId:'',//当前的年级id
        selectSchoolYearGradeCode:'',//当前的年级code
        selectSchoolYearGradeName:'',//当前的年级名称
        schoolClassType:'0',//0-行政班 1-教学班  默认行政班
        checkCourseList:[],//选择的课程
        isOverGrade:true, //是否覆盖
        excelUrl:"",
        fileName:"",//文件名
      },
      batchImportDataRules:{
        excelUrl:[
          {required: true, message: '请上传文件', trigger: 'blur'}
        ]
      },

      //授课列表相关参数
      teacherCourseParam:{
        schoolYearId:'',//学年ID
        schoolYearIdList:[],//学年ID列表
        schoolYearGradeId:'',//年级id
        schoolYearGradeIdList:[],//年级ID列表
        classType:'',//0 行政班 1 教学班
        classId:'',//班级id
        roleId:'',//角色Id
        roleCode:'',//角色code
        teacherName:'',//教师名称 编号
      },//授课列表参数
      roleList: [],//角色列表
      allClassList:[],//所有班级列表
      classList:[],//班级列表
      pageInfo:{
        pageNum:1,
        pageSize:20,
        total:0
      },
      tableHeight:0,
      listTableHeight:0,
      leftTableHeight:0,
      isSetLoading:false,//设置教师加载动画状态
      tableKey:0,
      scrollTopCache:0,//当前滚动条位置缓存

      exportLoading: false // 导出按钮loading

    }
  },
  mounted() {
    // this.initData();
    this.GetTeachingRelationship();//获取授课关系列表数据
    this.GetTeacherTableData();//获取所有教师列表表格数据
    // this.GetTeacherCourseList();//获取授课列表表格数据
    this.SetTableHeight(); //设置表格高度
    window.addEventListener("resize", this.HandleResize); //监听窗口大小变化
  },
  beforeDestroy() {
     window.removeEventListener('resize', this.HandleResize);
  },
  methods: {

    // 定义行类名方法
    TableRowClassName({ row }) {
      // console.log("row",row);
      if (this.selectedTeacher.teacherId === row.teacherId) {
        return 'selected_row';
      }
      return '';
    },
    //选择教师数据
    CheckedTeacher(e) 
    {
      console.log("打印选择的教师数据",e);
      this.selectedTeacher = {
        teacherId: e.teacherId,
        identityCode:e.identity,
        teacherName: e.teacherName,
        userAccount:e.userAccount,
        identityName:e.identityName,
      };
    },
    //获取序号
    GetIndexNumber(index) 
    {
      
        let indexCount=(this.pageInfo.pageNum - 1) * this.pageInfo.pageSize + index +1 ;
        return indexCount   
        
    },
    // 监听窗口大小变化，重新计算表格高度 使用节流防止频繁改变窗口大小导致计算量过大而页面卡顿
    HandleResize: throttle(function () {
        this.SetTableHeight();
    }, 500), // 节流 500 毫秒内最多执行一次
    //设置表格高度
    SetTableHeight() 
    {
        let windowViewHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
        
        this.$nextTick(() => {
            this.leftTableHeight = windowViewHeight - 268;
            this.tableHeight=windowViewHeight - 318;
            this.listTableHeight=windowViewHeight - 318;
        });
    },

    //获取任课教师授课关系列表
    GetTeachingRelationship(isUpdateTable=true)
    {
      let param={
        classType:this.classTabType,//0  行政班 1 教学班
        schoolYearGradeId:this.schoolYearGradeId,//年级ID
        schoolYearId:this.schoolYearId//学年ID
      };
      

      this.$api.user.getTeachingRelationship(param).then(res=>{
        console.log("打印任课教师授课关系列表",res);
        if(res.code==200 && res.data!=null)
        {
          if(this.classTabType==0)
          {
            //行政班
            this.administrativeClassData.tableColumn=res.data.tableData?.headData || [];
            this.administrativeClassData.tableData=res.data.tableData?.rowData || [];
          }
          else 
          {
            //教学班
            this.teachingClassData.tableColumn=res.data.tableData?.headData;
            this.teachingClassData.tableData=res.data.tableData?.rowTeachData;
            console.log("打印教学班数据",this.teachingClassData);
          }
          
          //筛选条件数据
          if(res.data.pcSchoolYearVOS)
          {
            this.schoolYearIdList=res.data.pcSchoolYearVOS || [];
            this.schoolYearId=res.data.schoolYearId || '';
            
            this.schoolYearGradeId=res.data.schoolYearGradeId || '';
            const selectedSchoolYear= this.schoolYearIdList.find(year => year.id === this.schoolYearId);
            this.schoolYearName=selectedSchoolYear.schoolYearName || '';
            this.schoolYearGradeIdList = selectedSchoolYear.schoolYearGradeVOS || [];
            this.schoolYearGradeName = selectedSchoolYear.schoolYearGradeVOS[0].gradeName || '';//默认第一个
          }
          
          // this.tableKey+=1;//解决串行问题
          //恢复滚动条位置
          if(isUpdateTable)
          {
            
            this.tableKey+=1;//解决串行问题
          }
          else
          {
            //不更新表格
          }
            
           
        }
        
       
      })
    },


    //保存当前滚动条位置
    SaveCurrentScrollPosition()
    {
      const tableEl = this.$refs.teacherTable?.$el;
      const scrollBody = tableEl?.querySelector('.el-table__body-wrapper');
      if (scrollBody) {
        this.scrollTopCache = scrollBody.scrollTop; // 缓存滚动位置
        console.log("保存滚动位置：", this.scrollTopCache);
      }
    },
    //设置滚动条的位置
    RestoreScrollPosition()
    {
      
      this.$nextTick(() => {
            
            const tableEl = this.$refs.teacherTable?.$el;
            const scrollBody = tableEl?.querySelector('.el-table__body-wrapper');
            if (scrollBody && this.scrollTopCache !== undefined) {
              scrollBody.scrollTop = this.scrollTopCache;
              console.log("恢复滚动位置：", this.scrollTopCache);
            }
            
        });
    },

    //获取任课教师 所有教师账号表格列表数据
    GetTeacherTableData()
    {
      let param={
        accountName:this.teacherName,//查询教师姓名
      };
      this.$api.user.getTeacherTableData(param).then(res=>{
        console.log("打印任课教师列表",res);
        if(res.code==200)
        {
          this.teacherTableData=res.data || [];
          
        }

      })
    },

    //获取任课教师授课列表数据
    GetTeacherCourseList()
    {
      let param={

        accountName:this.teacherCourseParam.teacherName,//姓名 账号
        classId:this.teacherCourseParam.classId,//班级ID
        courseCode:'',//科目code
        roleId:this.teacherCourseParam.roleId,//角色ID
        roleCode:this.teacherCourseParam.roleCode,//角色code
        classType:this.teacherCourseParam.classType,//0-行政班 1-教学班
        schoolYearGradeId:this.teacherCourseParam.schoolYearGradeId,//年级ID
        schoolYearId:this.teacherCourseParam.schoolYearId,//学年ID
        pageNum:this.pageInfo.pageNum,//页码
        pageSize:this.pageInfo.pageSize,//每页条数
      };
      console.log("打印任课教师授课列表参数",param);
      this.$api.user.getTeacherCourseList(param).then(res=>{
        console.log("打印任课教师授课列表",res);
        if(res.code==200 && res.data!=null)
        {
          this.teacherCourseList=res.data.pcTeacherTblVOS.records || [];
          this.pageInfo.total = parseInt(res.data.pcTeacherTblVOS.total);
          

          //学年 年级筛选条件数据
          if(res.data.pcSchoolYearVOS)
          {
            this.teacherCourseParam.schoolYearIdList=res.data.pcSchoolYearVOS || [];
            this.teacherCourseParam.schoolYearId=res.data.schoolYearId || '';
            this.teacherCourseParam.schoolYearGradeId=res.data.schoolYearGradeId || '';
            const selectedSchoolYear= this.teacherCourseParam.schoolYearIdList.find(year => year.id === this.teacherCourseParam.schoolYearId);
            this.teacherCourseParam.schoolYearGradeIdList = selectedSchoolYear.schoolYearGradeVOS || [];
            const selectedSchoolYearGrade= this.teacherCourseParam.schoolYearGradeIdList.find(grade => grade.id === this.teacherCourseParam.schoolYearGradeId);
            this.allClassList=selectedSchoolYearGrade.pcClassTblVOS || [];
            this.classList=selectedSchoolYearGrade.pcClassTblVOS || [];
            console.log("打印所有班级列表",this.allClassList);
          }

          //角色 筛选数据
          if(res.data.roleBOS)
          {
            this.roleList=res.data.roleBOS || [];
            console.log("打印所有角色列表",this.roleList);
          }
        }
      })
    },

    //切换行政班教学班事件
    HandleClick()
    {
      console.log("打印行政班教学班",this.classTabType);
      this.GetTeachingRelationship();//获取授课关系列表数据
    },
    //设置班主任或者年级组长
    SetHeadTeacherItem:debounce(function(item,header)
    {
      console.log("打印item",item);
      console.log("打印header",header);
      console.log("打印选中的教师",this.selectedTeacher);
     
      
      //教师code  班主任     CLASS_MASTER
      // 备课组长   PREPARE_COURSE_LEADER
      // 科目组长   COURSE_LEADER
      // 年级组长   GRADE_LEADER
      // 任课教师   NORMAL_TEACHER
      // 校长       SCHOOL_MASTER
      // 学校管理员 SCHOOL_MANAGER
      // 学生       SCHOOL_STUDENT
      //第一行的班主任是 是年级组长  后面的科目是备课组长
      //第二行的班主任是 班主任 后面的科目是任课教师
      //设置保存任课教师授课信息
      let roleCode='';//角色code
      let classId='';//班级id
      
      if(item.className=='年级组长/备课组长')
      {
        roleCode='GRADE_LEADER';//年级组长
        classId="";//保存年级组长和科目组长的时候不用传
      }
      else
      {
        roleCode='CLASS_MASTER';//班主任
        classId=item.classId;
      }
      if(!this.selectedTeacher.teacherId)
      {
        this.$message.error("请选择一个教师");
        return
      }
      else
      {
        //判断是否重复
        let list=item.classMasterNames || [];
        if(list.some(item => item.teacherId === this.selectedTeacher.teacherId))
        {
          this.$message.error("该教师已经添加了!");
          return 
        }
      }
      
      let param={

        "classId":classId,//班级ID,保存年级组长和科目组长的时候不用传
        "courseCode": '',//科目CODE，保存班主任，年级组长的时候不用传
        "courseName": "",//科目名称，保存班主任，年级组长的时候不用传
        "classType": this.classTabType,//班级类型 0-行政班 1-教学班
        "roleCode": roleCode,//角色code
        "schoolYearGardeId": this.schoolYearGradeId,//学年年级ID 来自下拉列表
        "schoolYearId": this.schoolYearId,//学年ID 来自下拉列表
        "teacherId": this.selectedTeacher.teacherId//教师ID
      };
      this.isSetLoading=true;
      this.$api.user.saveTeacherCourseInfo(param).then(res=>{
        console.log("打印保存教师的结果",res);
        this.isSetLoading=false;
        if(res.code==200)
        {
          this.$message.success("保存成功!");
          this.GetTeachingRelationship(false);//获取授课关系列表数据  false 不强制回滚滚动条位置
        }
      })
    },1000),//500毫米内只执行一次
    //设置教师
    SetTeacherItem:debounce(function(item,header,headerIndex)
    {
      console.log("打印item",item);
      console.log("打印header",header);
     
      
      //教师code  班主任     CLASS_MASTER
      // 备课组长   PREPARE_COURSE_LEADER
      // 科目组长   COURSE_LEADER
      // 年级组长   GRADE_LEADER
      // 任课教师   NORMAL_TEACHER
      // 校长       SCHOOL_MASTER
      // 学校管理员 SCHOOL_MANAGER
      // 学生       SCHOOL_STUDENT
      //第一行的班主任是 是年级组长  后面的科目是备课组长
      //第二行的班主任是 班主任 后面的科目是任课教师
      //设置保存任课教师授课信息
      let roleCode='';//角色code
      let classId='';//班级id
      let courseCode="";//科目code
      let courseName="";//科目name
      
      if(item.className=='年级组长/备课组长')
      {
        roleCode='PREPARE_COURSE_LEADER';//备课组长
        classId="";//保存年级组长和备课组长的时候不用传

         courseCode=header.courseCode || null;
        courseName=header.courseName || null;
      }
      else
      {
        roleCode='NORMAL_TEACHER';//班主任
        classId=item.classId;
        courseCode=header.courseCode;
        courseName=header.courseName;
      }
      if(!this.selectedTeacher.teacherId)
      {
        this.$message.error("请选择一个教师");
        return
      }
      else
      {
        //判断是否重复
        let list=item.values[headerIndex];
        if(list.some(item => item.teacherId === this.selectedTeacher.teacherId))
        {
          this.$message.error("该教师已经添加了!");
          return 
        }
      }
      let param={
        "classId": classId,//班级ID,保存年级组长和备课组长的时候不用传
        "classType": this.classTabType,//班级类型 0-行政班 1-教学班
        "courseCode": courseCode,//科目CODE，保存班主任，年级组长的时候不用传
        "courseName": courseName,//科目名称，保存班主任，年级组长的时候不用传
        "roleCode": roleCode,//角色code
        "schoolYearGardeId": this.schoolYearGradeId,//学年年级ID 来自下拉列表
        "schoolYearId": this.schoolYearId,//学年ID 来自下拉列表
        "teacherId": this.selectedTeacher.teacherId//教师ID
      };
      this.isSetLoading=true;
      this.$api.user.saveTeacherCourseInfo(param).then(res=>{
        console.log("打印保存教师的结果",res);
        this.isSetLoading=false;
        if(res.code==200)
        {
          this.$message.success("保存成功!");
          this.GetTeachingRelationship(false);//获取授课关系列表数据
        }
      })
    },500),//500毫秒内只执行一次
    //设置教学班教师
    SetTeachingClassTeacher:debounce(function(row,header,headerIndex)
    {
      console.log("打印row",row);
      console.log("打印header",header);
      console.log("打印headerIndex",headerIndex);
      console.log("打印this.isSetLoading",this.isSetLoading);
     
      
      //教师code  班主任     CLASS_MASTER
      // 备课组长   PREPARE_COURSE_LEADER
      // 科目组长   COURSE_LEADER
      // 年级组长   GRADE_LEADER
      // 任课教师   NORMAL_TEACHER
      // 校长       SCHOOL_MASTER
      // 学校管理员 SCHOOL_MANAGER
      // 学生       SCHOOL_STUDENT
      //第一行的班主任是 是年级组长  后面的科目是备课组长
      //第二行的班主任是 班主任 后面的科目是任课教师
      //设置保存任课教师授课信息
      let item=row[headerIndex];
      console.log("item",item);
      if(item.className==null)
      {
        return;
      }
      let roleCode='';//角色code
      let classId='';//班级id
      let courseCode="";//科目code
      let courseName="";//科目name
      if(item.className=='备课组长')
      {
        roleCode='PREPARE_COURSE_LEADER';//备课组长
        classId="";//保存年级组长和备课组长的时候不用传

        courseCode=header.courseCode || null;
        courseName=header.courseName || null;
      }
      else
      {
        roleCode='NORMAL_TEACHER';//任课教师
        classId=item.classId;
        courseCode=header.courseCode;
        courseName=header.courseName;
      }
      if(!this.selectedTeacher.teacherId)
      {
        this.$message.error("请选择一个教师");
        return
      }
      else
      {
        //判断是否重复
        let list=item.values || [];
        if(list.some(item => item.teacherId === this.selectedTeacher.teacherId))
        {
          this.$message.error("该教师已经添加了!");
          return 
        }
      }

      let param={
        "classId": classId,//班级ID,保存年级组长和备课组长的时候不用传
        "classType": this.classTabType,//班级类型 0-行政班 1-教学班
        "courseCode": courseCode,//科目CODE，保存班主任，年级组长的时候不用传
        "courseName": courseName,//科目名称，保存班主任，年级组长的时候不用传
        "roleCode": roleCode,//角色code
        "schoolYearGardeId": this.schoolYearGradeId,//学年年级ID 来自下拉列表
        "schoolYearId": this.schoolYearId,//学年ID 来自下拉列表
        "teacherId": this.selectedTeacher.teacherId//教师ID
      };
      this.isSetLoading=true;
      this.$api.user.saveTeacherCourseInfo(param).then(res=>{
        console.log("打印保存教师的结果",res);
        this.isSetLoading=false;
        if(res.code==200)
        {
          this.$message.success("保存成功!");
          this.GetTeachingRelationship(false);//获取授课关系列表数据
        }
      })
    },500),//500毫秒内只执行一次


    //删除班主任
    DeleteHeadTeacherCourse(item)
    {
      console.log("item",item);

      this.$confirm(`确定要删除   ${item.roleName}(${item.teacherName})吗?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
          customClass:'page_dialog',
      }).then(() => {
          let param={
            id:item.tchCourseId,
          };
          this.$api.user.deleteTeacherCourseInfo(param).then(res=>{
            console.log("打印删除任课教师结果",res);
            if(res.code==200)
            {
              this.$message.success("删除成功!");
              this.GetTeachingRelationship(false);//获取授课关系列表数据
            }

          })
          
      })
      
      
    },

    //删除任课教师
    DeleteTeacherCourse(item,header)
    {
      console.log("item",item);
      console.log("header",header);

      this.$confirm(`确定要删除   ${item.courseName}${item.roleName}(${item.teacherName})吗?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
          customClass:'page_dialog',
      }).then(() => {
          let param={
            id:item.tchCourseId,
          };
          this.$api.user.deleteTeacherCourseInfo(param).then(res=>{
            console.log("打印删除任课教师结果",res);
            if(res.code==200)
            {
              this.$message.success("删除成功!");
              if(this.teachingTabType=='relation')
              {
                this.GetTeachingRelationship(false);//获取授课关系列表数据
              }
              else
              {
                this.ChangeFilterItem();//重置分页并获取授课教师列表数据
                // this.GetTeacherCourseList();//获取授课教师列表数据
              }
              
              
            }

          })
          
      })
      
      
    },

    //清空所有任课教师course
    ClearAllTeacherCourse()
    {

      this.$confirm(`确定要清空当前年级下的授课信息吗?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
          customClass:'page_dialog',
      }).then(() => {

        let param={
          "classType": this.classTabType,//班级类型 0-行政班 1-教学班
          "schoolYearGradeId": this.schoolYearGradeId,//学年年级ID 来自下拉列表
        };
        this.$api.user.clearAllTeacherCourse(param).then(res=>{
          console.log("打印清空所有任课教师信息",res);
          if(res.code==200)
          {
            this.$message.success("清除成功!");
            this.GetTeachingRelationship();//获取授课关系列表数据
            this.GetTeacherCourseList();//获取授课列表数据
          }

        })
          
      })
      
    },
    // 批量导出教师名单
    BatchExportTeacher() {
      let params = {
        classType:this.classTabType,//0  行政班 1 教学班
        schoolYearGradeId:this.schoolYearGradeId,//年级ID
        schoolYearId:this.schoolYearId//学年ID
      }
      this.exportLoading = true;
      this.$api.user.exportTeachersList(params).then(res => {
        if(res.status == 200) {
          let blob = new Blob([res.data], {
            type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
          });
          let a = document.createElement("a");
          a.href = URL.createObjectURL(blob);
          a.download = decodeURIComponent(res.headers["content-disposition"].split("filename=")[1]);
          a.click();
          URL.revokeObjectURL(a.href);
          a.remove();
        } else {
          this.$message.error('导出失败！')
        }
      }).finally(() => {
        this.exportLoading = false;
      });
    },
    //批量导入教师名单
    BatchImportTeacher()
    {
      // this.$refs.uploadTeachers.value = null;
      // this.$refs.uploadTeachers.click();

      this.batchImportData.fileName="";
      this.batchImportData.dialogShow = true;

      this.batchImportData.selectSchoolYearId=this.schoolYearId;
      this.batchImportData.selectSchoolYearName=this.schoolYearName +'     '+ this.schoolYearGradeName;
      // this.batchImportData.selectSchoolYearGradeId=this.selectSchoolYearGradeId;//当前的年级id
      // this.batchImportData.selectSchoolYearGradeCode=this.selectSchoolYearGradeCode;//当前的年级code
      // this.batchImportData.selectSchoolYearGradeName=this.selectSchoolYearGradeName;//当前的年级名称

      //清空之前的选择
      this.batchImportData.schoolClassType=this.classTabType;//默认行政班
    },

    //取消批量导入
    CancelBatchImport()
    {
      this.batchImportData.dialogShow = false;
    },

    //确定批量导入
    ConfirmBatchImport()
    {
      if (this.isSubmitting) return;
      this.isSubmitting = true;
      let formdata = new FormData();
      formdata.append("file",this.$refs.uploadTeachers.files[0]);
      formdata.append("schoolYearId",this.schoolYearId);
      formdata.append("schoolYearGradeId",this.schoolYearGradeId);
      formdata.append("classType",this.batchImportData.schoolClassType);

     
      
      try {
          this.$api.user.importClassTeacherList(formdata).then((res)=>{
            console.log("打印导入结果",res);
            this.isSubmitting = false;
          if(res.code == 200)
          {
            this.batchImportData.dialogShow = false;
            this.$message.success("导入成功!");

            //导入成功 清空选择的节点信息
          
            this.batchImportData.fileName="";
            this.GetTeachingRelationship();//获取授课关系列表数据
          }
          else if(res.code==500)
          {
            this.$message.warning("系统异常,导入失败!");
            
          }
          else
          {
            let msg=res.msg;
            if(msg.length>50)
            {
              msg=msg.substring(0,50)+"...";
            }
            this.$message.warning(msg);
          }
        })
      } catch (error) {
        
      }finally {
        // 请求完成后重新启用按钮
        // this.isSubmitting = false;
      }
    },
    //上传文件
    OpenUpload(){
      this.$refs.uploadTeachers.value = null;
      this.$refs.uploadTeachers.click();
    },
    //上传excel
    UploadChange()
    {
      this.batchImportData.fileName = this.$refs.uploadTeachers.files[0].name;
      console.log("打印上传文件",this.$refs.uploadTeachers.files[0]);

    },
    //授课关系学年切换
    ChangeSchoolYearId()
    {
      
      const selectedSchoolYear= this.schoolYearIdList.find(year => year.id === this.schoolYearId);
      this.schoolYearName = selectedSchoolYear.schoolYearName;
      console.log("打印选择的学年",selectedSchoolYear);
      this.schoolYearGradeId = selectedSchoolYear.schoolYearGradeVOS[0].id || '';//默认第一个
      this.schoolYearGradeName = selectedSchoolYear.schoolYearGradeVOS[0].gradeName || '';//默认第一个
      this.schoolYearGradeIdList = selectedSchoolYear.schoolYearGradeVOS || [];
     
      this.GetTeachingRelationship();
    },

    //授课关系年级切换
    ChangeSchoolYearGradeId()
    {
      const gradeItem= this.schoolYearGradeIdList.find(grade => grade.id === this.schoolYearGradeId);
   
      this.schoolYearGradeName = gradeItem.gradeName || '';//默认第一个

     
      this.GetTeachingRelationship();
    },
    //授课列表学年切换
    ChangeParamSchoolYearId()
    {
      const selectedSchoolYear= this.teacherCourseParam.schoolYearIdList.find(year => year.id === this.teacherCourseParam.schoolYearId);
      this.teacherCourseParam.schoolYearGradeId = selectedSchoolYear.schoolYearGradeVOS[0].id || '';//默认第一个
      this.teacherCourseParam.schoolYearGradeIdList = selectedSchoolYear.schoolYearGradeVOS || [];
     
      this.GetTeacherCourseList();//获取授课列表数据
    },

    //授课列表年级切换
    ChangeParamSchoolYearGradeId()
    {
      const selectedSchoolYearGrade= this.teacherCourseParam.schoolYearGradeIdList.find(grade => grade.id === this.teacherCourseParam.schoolYearGradeId);
      this.allClassList=selectedSchoolYearGrade?.pcClassTblVOS || [];//所有班级
      this.classList=selectedSchoolYearGrade?.pcClassTblVOS || [];//班级列表
      this.teacherCourseParam.classType="";//清空班级类型
      this.teacherCourseParam.classId="";//清空选择的班级
    
     
      this.GetTeacherCourseList();//获取授课列表数据
    },

    //班级类型切换
    ChangeClassType()
    {
      //根据不同的班级类型过滤对应的班级
      this.classList=this.allClassList.filter(item=>item.classType==this.teacherCourseParam.classType);
      this.teacherCourseParam.classId="";
      this.GetTeacherCourseList();//获取授课列表数据
    },

    //切换角色
    ChangeRole()
    {
      console.log("切换角色",this.teacherCourseParam.roleId);
      
      const roleItem=this.roleList.find(item=>item.id==this.teacherCourseParam.roleId);
      console.log("切换角色",roleItem);
      if(roleItem)
      {
        this.teacherCourseParam.roleCode=roleItem.roleCode;
      }
      else
      {
        this.teacherCourseParam.roleCode="";
      }
      this.ChangeFilterItem();
    },
    //切换筛选条件通用调用数据
    ChangeFilterItem()
    {
      this.pageInfo={
        pageNum:1,
        pageSize:20,
        total:0,
      };
      this.GetTeacherCourseList();//获取授课列表数据
    },

    //分页组件
    ChangePage(val)
    {
      this.pageInfo.pageNum=val;
      this.GetTeacherCourseList();//获取授课列表数据
      this.TableScrollTop();
    },
    //页面分页切换改变
    HandleSizeChange(val)
    {
        this.pageInfo.pageSize = val;
        this.GetTeacherCourseList();
        this.TableScrollTop();
    },

    //重置表格滚动条
    TableScrollTop()
    {

      this.$nextTick(() => {
        if (this.$refs.teacherCourseTable) {
          const tableBody = this.$refs.teacherCourseTable.$el.querySelector('.el-table__body-wrapper');
          if (tableBody) {
            tableBody.scrollTop = 0;
          }
        } 
      });
    },
    //授课关系  授课列表 切换
    HandleTabClick(tab) {

      // console.log("HandleTabClick",this.teachingTabType);
      // this.schoolYearId="";
      // this.schoolYearGradeId="";
      if(this.teachingTabType == 'relation')
      {
        this.GetTeachingRelationship();//获取授课关系列表数据
      }
      else
      {
        this.GetTeacherCourseList();//获取授课列表数据
      }
    },
   



    confirmPassWord(){
      if(!this.editPassWordData.newPassWord){
        this.$message.warning("请输入新密码");
        return;
      }
      let param = {
        userId:this.editPassWordData.userInfoId,
        randomPassword:this.editPassWordData.newPassWord,
        type:1
      }
      this.$api.school.resetPassword(param).then((res)=>{
        if(res.code == 200){
          this.$message.success("密码修改成功");
          this.editPassWordData.dialogShow = false;
        }
      })
    },
    deleteChooseTeacherId(data){
      this.$confirm('您确定删除当前信息吗？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
          customClass:'page_dialog',
        }).then(() => {
          this.$api.school.deleteTeacherBindRole({ids:[data.id]}).then((res)=>{
            if(res.code == 200){
              this.getTeacherInfo();
              this.teacherClassDetailsList();
              // this.$message.success("删除成功");
            }
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });          
        });
    },
    deleteChooseTeacher(){
      if(!this.selectedTeacher.teacherId){
        this.$message('请先选择一个老师....');
        return;
      }
      this.$confirm(`您是否要删除${this.selectedTeacher.teacherName}老师？`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
          customClass:'page_dialog',
        }).then(() => {
          let param = {
            ids:[this.selectedTeacher.teacherId]
          }
          this.$api.school.deleteTeacher(param).then((res)=>{
            if(res.code == 200){
              this.$message.success("删除成功");
              this.getTeacherList();
              this.getAdminClass();
              this.getSectionClassCourseData();
            }
          })
          
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });          
        });
      
      
    },


    //删除
    DeleteTeacher()
    {

    },

    //重置密码
    ResetPassWord(type,data){
      // if(!this.selectedTeacher.teacherId){
      //   this.$message('请先选择一个老师....');
      //   return;
      // }
      if(type=="only"){
        this.editPassWordData.teacherName = data.teacherName;
        this.editPassWordData.userInfoId = data.userInfoId;
        this.editPassWordData.teacherCode = data.teacherCode;
      }
      this.editPassWordData.dialogShow = true;

    },
    //批量导入
    batchImport(){

    },
    //批量导出
    batchExport(){

    },
    //多老师重置密码
    resetMultiplePW(){
      this.editMultiplePassWordData.dialogShow = true;
    },
    confirmMultiplePassWord(){
      let param = {
            userId:this.editMultiplePassWordData.teacherIds,
            randomPassword:this.editMultiplePassWordData.newPassWord,
            type:1
        }
        this.$api.school.resetPassword(param).then((res)=>{
            if(res.code ==200){
                this.$message.success("重置成功");
                this.editMultiplePassWordData.dialogShow = false;
            }

        }).catch((err)=>{})
                  
      console.log(this.editMultiplePassWordData)
    },


    //导出教师列表
    ExportTeacherList(){
      if(!this.schoolYearId){
          this.$message.warning('未选择学年！');
          return;
      }
      this.$api.school.exportTeacherInfos({schoolSemesterId:this.selTermList.value}).then((res)=>{
        const blob = new Blob([res.data], {
              type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
          });
          const a = document.createElement("a");
          a.href = URL.createObjectURL(blob);
          a.download = decodeURIComponent(res.headers["content-disposition"].split("filename=")[1]);
          a.click();
          URL.revokeObjectURL(a.href);
          a.remove();
      })
    },
  },
}
</script>
<style lang="scss" scoped>
.content_container
{
  width: 100%;
  height: calc(100% - 56px);
  display: flex;
  justify-content: space-between;
  align-items: start;
  .container_left
  {
    width: 200px;
    height: auto;
  }

  .container_right
  {
    width: calc(100% - 220px);
    height: auto;
  }
}
.content_table
{
  position: relative;
}
.table_switch
{
  width: 500px;
  height: 40px;
  position: absolute;
  right: 0;
  top:0px;
  text-align: right;
  line-height: 40px;
  display: flex;
  justify-content: flex-end;
  align-items: center;

  gap: 10px;
}
.jxb .page_table .row_content {
  justify-content: flex-start !important;
}

</style>