<template>

    <div class="page_item step_2_content page_search">

        <div class="container_left">
          <FormSearchGroup :searchList="searchList" @searchChange="HandleSearchChange"></FormSearchGroup>
          
          <Table 
            :hidePagination="true"
            class="teacher_table"
            :tableColumns="teacherTableColumns" 
            :tableData="teacherList"
            :tableRowClassName="tableRowClassName"
            @rowClick="HandleSelectTeacher"
            ></Table>

        </div>
        <div class="container_right">
          <div class="search_content">
            <!-- 年级切换 -->
            <div class="content_left">
              <TabSearch 
                class="grade_tab"
                tabType="box" 
                :tabList="gradeList" 
                :defaultTabKey="searchParmams.gradeId"
                @tabChange="(val)=>HandleTabChange(val,'grade')">
              </TabSearch>
            </div>
            <div class="content_right operation_btn el_button">
              <el-button type="text"  class="delete_item" plain @click="ClearTeachingRelationship">清空授课</el-button>
              <el-button class="custom_border_btn" @click="HandleExportExcel">批量导出</el-button>
              <el-upload action="#"
                :auto-upload="false"
                :show-file-list="false"
                @change="(file)=>HandleImportExcel(file)">
                  <el-button  class="custom_border_btn"> 批量导入</el-button>
              </el-upload>
              <el-button class="button_background" @click="FinishTeachingRelationship">完成</el-button>
            </div>
          </div>

          <div class="page_jg_20"></div>

          <div class="search_content">
            <div class="content_left">
              <TabSearch 
                class="class_tab"
                tabType="line" 
                :tabList="tabList" 
                :defaultTabKey="searchParmams.classType"
                @tabChange="(val)=>HandleTabChange(val,'classType')"> </TabSearch>
            </div>
             <div class="content_right">
                <span v-if="isConfigMode" class="config_switch_desc">
                  {{ selectedTeacher?.teacherId ? `当前选中的教师：${selectedTeacher.teacherName} ${selectedTeacher.userAccount}` : '暂无选中的教师' }}
                </span>
               <el-switch v-model="isConfigMode" 
               style="--el-switch-on-color: #2E64FA"
               active-text="选中教师配置任课关系" />
             </div>
          </div>

          <div class="page_solid_line"></div>
          <div class="page_jg_20"></div>

          <div class="end_item teaching_relation_table" >

            <!-- 行政班渲染表数据 -->
            <Table v-if="searchParmams.classType === 'xingzeng'"  
                :tableColumns="filterAdministrativeClassTableColumns" 
                :tableData="administrativeClassTableData" 
                :hidePagination="true">

                <template #className="{row}">
                  {{ row.className.className }}
                </template>
                <template v-for="column in filterAdministrativeClassTableColumns.slice(1)" :key="column.name"   v-slot:[column.name]="{row}"> 
                  
                  <div class="cell_container  administrative_cell_container" @click="HandleAddTeacher(row, column.name,'administrative')">
                    <template v-if="row?.[column.name] && row?.[column.name]?.length > 0">
                      <div v-for="(teacher, idx) in row?.[column.name]" :key="teacher.teacherId">
                        <el-tooltip
                          effect="dark"
                          :content="`${teacher.teacherName} ${teacher.userAccount}`"
                          placement="top-start"
                        >
                          <div v-if="isConfigMode" class="teacher_tag">
                            <span :title="teacher.teacherName">{{ teacher.teacherName }}</span>
                            <el-icon class="delete_icon" @click.stop="HandleRemoveTeacher(row, column.name, idx,'administrative')"><Close /></el-icon>
                          </div>
                          <div v-else class="disabled_teacher">
                            <span :title="teacher.teacherName">{{ teacher.teacherName }}</span>
                          </div>
                        </el-tooltip>
                      </div>
                    </template>
                    <template v-else>
                      <span v-if="isConfigMode" class="placeholder_text" >请选择教师</span>
                      <span v-else>-</span>
                    </template>
                  </div>
                </template>
            </Table>


            <!-- 教学班渲染表数据 -->
            <Table v-else-if="searchParmams.classType === 'teach'"  
                :tableColumns="filterTeachingClassTableColumns" 
                :tableData="teachingClassTableData" 
                :hidePagination="true">
                <template v-for="column in filterTeachingClassTableColumns" :key="column.name"   v-slot:[column.name]="{row}"> 

                  <div class="cell_container" @click="HandleAddTeacher(row, column.name, 'teach')">
                    <div class="tag_teacher_content">
                      <!-- 左侧：班级名称（还原 .content_title 样式） -->
                      <div class="content_title" :title="row?.[column.name]?.className?.className">
                        {{ row?.[column.name]?.className?.className }}
                      </div>

                      <!-- 右侧：教师标签列表（还原 .content_value 样式） -->
                      <div class="content_value" v-if="row?.[column.name]?.className?.className && row?.[column.name]?.teacherList?.length > 0">
                        <div 
                          v-for="(teacher, idx) in row?.[column.name]?.teacherList" 
                          :key="teacher.teacherId" 
                          class="content_teacher"
                        >
                          <el-tooltip
                            effect="dark"
                            :content="`${teacher.teacherName} ${teacher.userAccount}`"
                            placement="top"
                            :disabled="!teacher.teacherName"
                          >
                            <!-- 可配置模式：带删除按钮的蓝色标签 -->
                            <div v-if="isConfigMode" class="content_teacher_item">
                              <span :title="teacher.teacherName">{{ teacher.teacherName }}</span>
                              <el-icon 
                                class="delete_icon" 
                                @click.stop="HandleRemoveTeacher(row, column.name, idx, 'teach')"
                              >
                                <Close />
                              </el-icon>
                            </div>

                            <!-- 只读模式：灰色文本标签 -->
                            <div v-else class="content_text_item">
                              <span :title="teacher.teacherName">{{ teacher.teacherName }}</span>
                            </div>
                          </el-tooltip>
                        </div>
                      </div>

                      <!-- 空状态/占位符处理 -->
                      <div class="content_value" v-else-if="row?.[column.name]?.className?.className">
                        <!-- 可配置模式：请选择教师 -->
                        <div v-if="isConfigMode" class="content_item">请选择教师</div>
                        <!-- 只读模式：显示横杠 -->
                        <div v-else class="content_no_data">-</div>
                      </div>
                    </div>
                  </div>




                </template>
            </Table>

          </div>
        </div>
  </div>
</template>


<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue';
import { ErrorTypes, useRoute } from 'vue-router';
import { useStore } from 'vuex';
import ExcelJS from 'exceljs';


import { Close } from '@element-plus/icons-vue';
import FormSearchGroup from '@/baseComponents/FormSearchGroup.vue';
import Table from '@/baseComponents/Table.vue';
import TabSearch from '@/baseComponents/TabSearch.vue';
import {
  getTeachingRelationshipTableDataApi,  getTeacherListDataApi,  
  saveTeachingRelationshipApi,  deleteTeachingRelationshipApi,  
  finishTeachingRelationshipApi,clearTeachingRelationshipApi, 
  importTeachingRelationshipApi
} from '@/api/teachingRelationshipComponent'

import {getEvaluationDataDetailApi} from '@/api/evaluationDataComponent'

import {administrativeClassTableColumns,teacherTableColumns,teachingClassTableColumns} from './table'
import { ElMessage } from 'element-plus';
import router from '@/router';

const route = useRoute()
const store = useStore()

// 配置模式开关
const isConfigMode = ref(true);


// 1. 查询参数 列表 配置
const tabList = ref([
  {
    label:'行政班',
    key:'xingzeng',
  },
  {
    label:'教学班',
    key:'teach',
  },
]);
// 搜索列表配置
const searchList = ref([
  {
    key: 'searchKey',
    type: 'input',
    placeholder: '教师姓名、账号',
  }
]);
// 查询参数
const searchParmams = ref({
  gradeId:'',
  classType:'teach',
  searchKey:''
})
// 年级列表
interface GradeItm {
  label:string,
  key:string
}
const gradeList = ref<GradeItm[]>([])

interface GradeClassType {
  gradeId:string,
  administrativeClassStatus: number|string,  // 0关闭  1开启
  teachingClassStatus: number|string       // 0关闭  1开启
}
const gradeClassTypeStatus = ref<GradeClassType[]>([])  //存储 不同年级的班级类型状态
// 获取年级列表信息
const GetGradeList = async()=>{
  let id = route.query.id
  let res = await getEvaluationDataDetailApi(id)
  if(res?.code == 200){
    gradeList.value = res?.data.map((item,index)=>{
      gradeClassTypeStatus.value[index] = {
        gradeId:item.id,
        administrativeClassStatus: item.administrativeClassStatus,
        teachingClassStatus: item.teachingClassStatus
      }
      return {
        label:item.gradeName,
        key:item.id
      }
    }) || []
    searchParmams.value.gradeId = gradeList.value[0].key
  }
}


// 2. 教师列表数据
interface TeacherItm {
  id: null | string
  teacherId: string
  teacherName: string
  userAccount: string
}
const teacherList = ref<TeacherItm[]>([]);
// 选中的教师ID
const selectedTeacher = ref()
// 获取教师列表数据
const GetTeacherTableData = async ()=>{
  let params = {
    evaluationId: route.query.id,
    evaluationGradeId: searchParmams.value.gradeId,
    teacherName: searchParmams.value.searchKey
  }
  let res = await getTeacherListDataApi(params)
  if(res?.code == 200){
    teacherList.value = res.data || []
  }
}
// 行选中 选择教师
const HandleSelectTeacher = (teacher) => {
  selectedTeacher.value = {
    teacherId:teacher.teacherId,
    teacherName:teacher.teacherName,
    userAccount:teacher.userAccount,
  };
};
// 设置表行选中 样式
const tableRowClassName = ({row,rowIndex})=>{
  if(row.teacherId == selectedTeacher.value?.teacherId){
    return 'active_row'
  }
}
// 搜索变化处理
const HandleSearchChange = async (params) => {
  console.log('搜索参数', params);
  searchParmams.value.searchKey = params.searchKey
  // 重查教师账号信息
  await GetTeacherTableData()
};



// 3. 授课关系数据 
// 行政班 表头
const filterAdministrativeClassTableColumns = ref([...administrativeClassTableColumns.value]) 
// 教学班 表头
const filterTeachingClassTableColumns = ref([...teachingClassTableColumns.value])
const administrativeClassTableData = ref([]); // 行政班授课关系数据
const teachingClassTableData = ref([])  //教学班授课关系数据
// 获取表格授课关系配置数据
const GetTeachingRelationshipData = async ()=>{
  teachingClassTableData.value = []
  administrativeClassTableData.value = []

  let res = await getTeachingRelationshipTableDataApi(searchParmams.value.gradeId)
  if(res?.code == 200){
    // 	行政班数据  行政班科目    教学班数据   教学班科目   
    const {administrativeClassData,administrativeSubjectLists, 
          teachingClassData, teachingSubjectLists,
        } = res.data
    
      // 行政班数据渲染
      let administrativeHeaderColumn = administrativeSubjectLists.map(item=>{
        return {
          name: item.subjectId,
          label: item.name,
          width: '140',
          custom: true, 
          fixed:'',
          hidden: false,
          align:'center',
        }
      })
      filterAdministrativeClassTableColumns.value = [...administrativeClassTableColumns.value,...administrativeHeaderColumn]
      administrativeClassTableData.value = administrativeClassData.map(item=>{
        let subjectOpt = {}
        item.subjectData.map(subject=>{
          subjectOpt[subject.subjectId] = subject.teacherData
        })
        return {
          className:{
            className:item.className,
            evaluationClassId:item.evaluationClassId
          },
          ...subjectOpt
        }
      })

      // 教学班数据渲染
      let teachingHeaderColumn = teachingSubjectLists.map(item=>{
        return {
          name: item.subjectId,
          label: item.name,
          width: '140',
          custom: true, 
          fixed:'',
          hidden: false,
          align:'center',
        }
      })
      filterTeachingClassTableColumns.value = [...teachingClassTableColumns.value,...teachingHeaderColumn];
      teachingClassData.map((subjectItm:any)=>{
        let subjectId = subjectItm.subjectId
        subjectItm?.classData.map((classItm,idx)=>{
          let subjectOpt = {
            className:{
              className:classItm.className,
              evaluationClassId:classItm.evaluationClassId
            },
            teacherList:classItm.teacherData
          }
          if(typeof teachingClassTableData.value[Number(idx)]  === 'object'){
            teachingClassTableData.value[Number(idx)][subjectId] = subjectOpt
          }else{
            teachingClassTableData.value[Number(idx)] = {}
            teachingClassTableData.value[Number(idx)][subjectId] = subjectOpt
          }
        });
      })
  }
}

// 添加教师
const HandleAddTeacher = async (row, cell,type) => {
  if (!isConfigMode.value) return;
  if (!selectedTeacher.value) return;

  let teacherMsg = { 
    teacherId: selectedTeacher.value?.teacherId, 
    teacherName: selectedTeacher.value?.teacherName,
    userAccount:selectedTeacher.value?.userAccount 
  }


  switch(type){
    case 'administrative':{
      // 行政班
      if (!row[cell]) {
        row[cell] = [];
      }
      let res = await saveTeachingRelationshipApi({
        ...teacherMsg,
        evaluationId:route.query.id,
        evaluationGradeId:searchParmams.value.gradeId,
        evaluationSubjectId:cell,
        evaluationClassId:row.className.evaluationClassId,
        classType:searchParmams.value.classType == 'teach' ? 1 : 0  //班级类型，0-行政班，1-教学班
      })
      if(res?.code == 200){
        ElMessage.success(res?.msg)
        row[cell].push({...teacherMsg,id:res?.data});
      }
      break
    }
    case 'teach':{
      if (row?.[cell]?.className?.className && !row?.[cell]?.teacherList) {
        row[cell] = {
          name:row?.[cell]?.className,
          teacherList:[]
        }
      }
      
      let res = await saveTeachingRelationshipApi({
        ...teacherMsg,
        evaluationId:route.query.id,
        evaluationGradeId:searchParmams.value.gradeId,
        evaluationSubjectId:cell,
        evaluationClassId:row[cell].className.evaluationClassId,
        classType:searchParmams.value.classType == 'teach' ? 1 : 0  //班级类型，0-行政班，1-教学班
      })
      if(res?.code == 200){
        ElMessage.success(res?.msg)
        row[cell].teacherList.push({...teacherMsg,id:res?.data});
      }
      break
    }
  }
};

// 移除教师
const HandleRemoveTeacher = async (row, cell, index,type) => {
  if (!isConfigMode.value) return;
  let id = null
  let res = undefined
  switch(type){
    case 'teach':{
      id = row[cell].teacherList[index].id
      res = await deleteTeachingRelationshipApi(id)
      if(res?.code == 200){
        ElMessage.success(res?.msg)
        row[cell].teacherList.splice(index, 1);
      }
      break
    }
    case 'administrative':{
      id = row[cell][index].id
      res = await deleteTeachingRelationshipApi(id)
      if(res?.code == 200){
        ElMessage.success(res?.msg)
        row[cell].splice(index, 1);
      }
      break
    }
  }
};




// 4 综合. 
// 标签切换处理   年级/班级类型
const HandleTabChange = async (val,type) => {
  console.log('当前选中的tab',val,type)
  switch(type){
    case 'grade':{
      let aimClassTypeStatus =  gradeClassTypeStatus.value.find(item=>{
        return item.gradeId == val
      })
      tabList.value = []
      if(aimClassTypeStatus.administrativeClassStatus === 1){
        searchParmams.value.classType = 'xingzeng'
        tabList.value.push(
          {
            label:'行政班',
            key:'xingzeng',
          },
        )
      }
      if(aimClassTypeStatus.teachingClassStatus === 1){
        if(aimClassTypeStatus.administrativeClassStatus !== 1){
          searchParmams.value.classType = 'teach'
        }
        tabList.value.push(
          {
            label:'教学班',
            key:'teach',
          },
        )
      }
      searchParmams.value.gradeId = val
      await reloadData()
      break
    }
    case 'classType':{
      searchParmams.value.classType = val
        break
    }
  }
};


// 5. 完成授课关系
const FinishTeachingRelationship = async ()=>{
  let params = gradeList.value.map(grade=>{
    return grade.key
  })
  let res = await finishTeachingRelationshipApi(params)
  if(res?.code == 200){
    // 更新全局状态 并 跳转到下一步 
    await store.dispatch('updateEvaluationManageStepData',route.query.id)
    // 线上匿名  线下答卷 
    // store.state.evaluationManageStepData.evaluationType   // 评价方式  0-线上匿名，1-线下答卷，2-线上导入，3-线上实名
    if(store.state.evaluationManageStepData.evaluationType === 0){
      store.commit('updateEvaluationManageStepData',{currentActiveStepName:'questionnaireTemplate'})  //更新全局活跃路由
      router.push(`questionnaireTemplate?id=${route.query.id}`)
    
    }else if(store.state.evaluationManageStepData.evaluationType === 1){
      store.commit('updateEvaluationManageStepData',{currentActiveStepName:'numberMapping'})  //更新全局活跃路由
      router.push(`numberMapping?id=${route.query.id}`)
    }
  }
}

// 6. 清空授课关系
const ClearTeachingRelationship = async ()=>{
  let id = searchParmams.value.gradeId
  let classType = searchParmams.value.classType == 'teach' ? 1 : 0  //班级类型，0-行政班，1-教学班
  let res = await clearTeachingRelationshipApi(id,classType)
  if(res?.code == 200){
    ElMessage.success(res?.msg)
    // 重查页面
    await GetTeachingRelationshipData()
  }
}

// 批量导入/导出


const LoopAddSheet=(finalTableColumn, finalTableData,workbook,sheetName )=>{
  // 1. 提取表头
  let headers = []               // 表头数据

  // 2.创建工作表
  const worksheet = workbook.addWorksheet(sheetName);

  // 3. 添加表头行
  let headerRow
  if(sheetName == '行政班'){
    headers = finalTableColumn.map(column => column.label || column.name)
  }else if(sheetName == '教学班'){
    finalTableColumn.forEach(column => {
      headers.push(`${column.label || column.name}班级`)
      headers.push(`${column.label || column.name}教师`)
    })
  }
  // 添加表头
  headerRow = worksheet.addRow(headers)
  // 定义表头样式
  headerRow.eachCell((cell) => {
    cell.style = {
      font: { name: 'Microsoft YaHei', size: 12, color: { argb: 'FF333333' } },
      border: {
        top: { style: 'thin', color: { argb: 'FFD9D9D9' } },
        left: { style: 'thin', color: { argb: 'FFD9D9D9' } },
        bottom: { style: 'thin', color: { argb: 'FFD9D9D9' } },
        right: { style: 'thin', color: { argb: 'FFD9D9D9' } },
      },
      alignment: { vertical: 'middle', horizontal: 'center', wrapText: true },
    }
  })

  // 4. 添加数据行
  // 行政班  和 教学班 不一样
  finalTableData.forEach(row => {
    const rowData = finalTableColumn.map(column => {
      if (column.name === 'className') {
        return row?.className?.className || '';
      }
      const cellValue = row[column.name];
      if(sheetName == '行政班'){
        return cellValue?.map((item: any) => item.teacherName || '').join(',');
      }else if(sheetName == '教学班'){
        let className = cellValue?.className?.className
        let teacherList = cellValue?.teacherList || []
        let teacherName = teacherList?.map((item: any) => item.teacherName || '').join(',');
        return [className,teacherName]
      }
    }).flat();

    const excelRow = worksheet.addRow(rowData);

    // 6. 定义数据行样式
    excelRow.eachCell({ includeEmpty: true }, (cell) => {
      cell.style = {
        font: { name: 'Microsoft YaHei', size: 12, color: { argb: 'FF333333' } },
        border: {
          top: { style: 'thin', color: { argb: 'FFD9D9D9' } },
          left: { style: 'thin', color: { argb: 'FFD9D9D9' } },
          bottom: { style: 'thin', color: { argb: 'FFD9D9D9' } },
          right: { style: 'thin', color: { argb: 'FFD9D9D9' } },
        },
        alignment: { vertical: 'middle', horizontal: 'center', wrapText: true },
      
      };
    });
  });

  // 5. 设置列宽并固定表头行
  worksheet.columns = headers.map(() => ({ width: 25 }));
  // 设置表头的第一行固定
  worksheet.views = [{ state: 'frozen', ySplit: 1 }];
}

//前端 导出 Excel
const HandleExportExcel = async () => {
  // 1. 初始化表数据
  let tableColumn = []
  let tableData = []
  let sheetName = ''
  // 班级名称
  let gradeName = gradeList.value.find(item=>item.key == searchParmams.value.gradeId)?.label
  // 教学班
  if(searchParmams.value.classType == 'teach'){
    tableColumn = filterTeachingClassTableColumns.value,
    tableData = teachingClassTableData.value,
    sheetName = '教学班'
  // 行政班
  }else if(searchParmams.value.classType == 'xingzeng'){
    tableColumn = filterAdministrativeClassTableColumns.value,
    tableData = administrativeClassTableData.value,
    sheetName = '行政班'
  }

  // 2. 创建工作簿
  const workbook = new ExcelJS.Workbook();

  // 3. 添加sheet表
  LoopAddSheet(tableColumn,tableData,workbook,sheetName)


  // 4. 导出文件
  const buffer = await workbook.xlsx.writeBuffer();
  const blob = new Blob([buffer], { 
    type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' 
  });
  
  const url = URL.createObjectURL(blob);
  const link = document.createElement('a');
  link.href = url;
  link.download = `${gradeName}_${sheetName}授课关系表.xlsx`;
  link.style.visibility = 'hidden';
  document.body.appendChild(link);
  link.click();
  document.body.removeChild(link);
  URL.revokeObjectURL(url);
};

// 导入Excel
const HandleImportExcel = async(file)=>{
  console.log('file----------',file)
  if(file.name.split('.').pop() !== 'xlsx' && file.name.split('.').pop() !== 'xls' ){
    ElMessage.warning('请上传以.xlsx、.xls结尾的文件')
    return
  }
  const fomData = new FormData()
  fomData.append('file',file.raw)
  let params = {
    evaluationId:route.query.id,
    evaluationGradeId:searchParmams.value.gradeId,
    classType:searchParmams.value.classType=== 'teach' ? 1 : 0 ,  // 0-行政班，1-教学班
  }
  let res =   await importTeachingRelationshipApi(fomData,params)
  if(res?.code == 200){
    // 查询查询数据
    ElMessage.success(res.msg)
     await reloadData()
  }
}

// 重新加载页面数据
const reloadData =async ()=>{
   await GetTeacherTableData()
   await GetTeachingRelationshipData()

}

onMounted( async ()=>{
  await GetGradeList()
  HandleTabChange(searchParmams.value.gradeId,'grade')
})

</script>



<style lang="scss" scoped>

.step_2_content {
  height: calc(100%);
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: stretch;
  gap:20px;
  overflow: auto;

  .container_left {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow: auto;
    
    width: 200px;
    height: 100%;
    .teacher_table{
      margin-top: 16px;
    
      :deep(.el-table .cell) {
        padding: 0 !important;
      }

      :deep(.el-table__body){
        tr.active_row td
        {
          background-color: rgba(46, 100, 250,0.1) !important;
          border:none;
          color: #2e64fa;
        }
      }
    }
  }

  .container_right {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: auto;

    .config_switch_desc{
      font-size: 14px;

    }
    .end_item{
      overflow-y: auto;
    }

    .grade_tab{
      gap:10px;
      :deep(> span){
        border: 1px solid  #dcdfe6 !important; 
        border-radius: 6px;
      }
    }
    .operation_btn{
      flex-wrap: wrap;
      height: auto;
    }

        
    .cell_container {
      width: 100%;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
    }


    // 行政班单元格样式渲染
    .administrative_cell_container {
      text-align: center;
      flex-wrap: wrap;
      padding: 8px;
      gap: 8px;

      .placeholder_text,
      .disabled_teacher{
        width: 90px;
        height: 34px;
        font-weight: 400;
        font-size: 14px;
        text-align: center;
        line-height: 34px;
        background-color: #f3f3f3;
        border-radius: 4px;
        cursor: pointer;
      }
      .placeholder_text {
        color: #CCCCCC;
      }
      .disabled_teacher {
        color: #666666;
      }

      // 教师标签样式
      .teacher_tag {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0 8px;

        min-width: 90px;
        height: 34px;
        font-weight: 400;
        font-size: 14px;
        color: #2E64FA;
        text-align: center;
        line-height: 34px;
        background: rgba(46, 100, 250, 0.1);
        border-radius: 4px;

        // 删除图标样式 (对应原 img 标签样式)
        .delete_icon {
          width: 12px;
          height: 12px;
          cursor: pointer;
          font-size: 12px;
          margin-left: 10px; /* 保留原代码中 i 标签的 margin-left 习惯 */
        }
      }
    }


    // 教学班单元格样式渲染
    .tag_teacher_content {
      display: flex;
      justify-content: space-between;
      align-items: center;
      width: 100%;
      height: 100%;

      // 左侧班级名称
      .content_title {
        width: 80px;
        padding-left: 5px;
        display: flex;
        align-items: center;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 14px;
        color: #333; // 可根据实际业务补充颜色
      }

      // 右侧内容区域
      .content_value {
        width: calc(100% - 80px);
        display: flex;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 5px;
        padding: 5px;
        box-sizing: border-box;

        // 教师标签容器 (对应原始 .content_teacher)
        .content_teacher {
          min-width: 90px;
          max-width: 100px;
          height: 34px;
          font-weight: 400;
          font-size: 14px;
          color: #2E64FA;
          text-align: center;
          line-height: 34px;
          background: rgba(46, 100, 250, 0.1);
          border-radius: 4px;

          // 可编辑状态内部布局
          .content_teacher_item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 8px;
            height: 100%;

            span {
              overflow: hidden;
              text-overflow: ellipsis;
              white-space: nowrap;
            }

            .delete_icon {
              width: 12px;
              height: 12px;
              cursor: pointer;
              margin-left: 10px;
              flex-shrink: 0;
            }
          }

          // 只读状态内部布局
          .content_text_item {
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100%;
            padding: 0 8px;
            color: #666666;
            background-color: #f3f3f3;
            border-radius: 4px;
            
            span {
              overflow: hidden;
              text-overflow: ellipsis;
              white-space: nowrap;
            }
          }
        }

        // 占位符样式 (对应原始 .content_item)
        .content_item {
          width: 90px;
          height: 34px;
          font-weight: 400;
          font-size: 14px;
          color: #CCCCCC;
          text-align: center;
          line-height: 34px;
          background-color: #f3f3f3;
          border-radius: 4px;
          cursor: pointer;
        }

        // 无数据样式 (对应原始 .content_no_data)
        .content_no_data {
          width: 90px;
          height: 34px;
          font-weight: 400;
          font-size: 14px;
          text-align: center;
          line-height: 34px;
          border-radius: 4px;
          color: #999; // 补充默认颜色以防不可见
        }
      }
    }

    
  }

  .class_tab{
      gap:40px;
      :deep(> span){
        font-size: 16px !important;
        font-weight: 600;
      }
  }

  .teacher_table,
  .teaching_relation_table{
      :deep(.el-table){
        tr th.el-table__cell {
          font-size: 16px !important;
        }
      }
    }
    .teaching_relation_table{
      :deep(.el-table){
        .el-table__body tr:hover > td {
            background-color: #EAF0FF !important;
        }
      }
    }
}
.el_button{
    .custom_border_btn:hover{
      color: #666666 !important;
      border-color: rgb(192.3, 208.5, 253.5) !important;
      background-color: rgb(234.1, 239.5, 254.5) !important;
    }
}
</style>
