<template>
  <!-- Your template content here -->
  <div class="margin-5"></div>
  <div class="main-container wrap main-fullScreen">
    <el-row :gutter="20">
      <el-col :span="4" v-show="state.visible.leftShow">
        <div style="position: fixed;left: 10px">
          <el-card style="max-width: 480px">
          <template #header>
            <div class="card-header font-size-20" style="line-height: 10px;">
              <span>{{ state.scoreInfo && state.scoreInfo.professionalCategory||'' }}</span>
            </div>
          </template>
          <div class="child-link">
            <a v-for="o in state.pages" :key="o.value" class="flexWrap alink" :class="o.value===state.activePage?'alink-active':''" @click="switchPages(o.value)">
              {{ o.label }}
            </a>
          </div>
        </el-card>
        <el-card style="max-width: 480px" class="mt-15">
          <template #header>
            <div class="card-header font-size-20" style="line-height: 10px;">
              <span>我的成绩</span>
            </div>
          </template>
          <div class="score-item" v-if="state.scoreInfo && state.scoreInfo.professionalCategory">
            <p class="flexWrap">地区：{{ state.scoreInfo.province }}</p>
            <p class="flexWrap">选科：{{ state.scoreInfo.cognitioPolyclinic==='文科'?'历史组':'物理组' }}</p>
            <p class="flexWrap">文化：{{ state.scoreInfo.culturalScore }}分</p>
            <p class="flexWrap" v-show="state.scoreInfo.professionalCategory!=='音乐类'">{{ state.scoreInfo.professionalCategory==='音乐类'?'主项':'统考' }}：{{ state.scoreInfo.professionalScore }}分</p>
            <span v-if="state.scoreInfo.professionalCategory==='音乐类'">
              <p class="flexWrap" v-show="state.scoreInfo.yybysy && state.scoreInfo.yybysy!==0">声乐：{{ state.scoreInfo.yybysy }}分</p>
              <p class="flexWrap" v-show="state.scoreInfo.yybyqy && state.scoreInfo.yybyqy!==0">器乐：{{ state.scoreInfo.yybyqy }}分</p>
              <p class="flexWrap" v-show="state.scoreInfo.yyjy && state.scoreInfo.yyjy!==0">音教：{{ state.scoreInfo.yyjy }}分</p>
            </span>
            <span v-if="state.scoreInfo.professionalCategory==='表演类'">
              <p class="flexWrap" v-show="state.scoreInfo.xjysdy && state.scoreInfo.xjysdy!==0">戏导：{{ state.scoreInfo.xjysdy }}分</p>
              <p class="flexWrap" v-show="state.scoreInfo.xjysby && state.scoreInfo.xjysby!==0">戏表：{{ state.scoreInfo.xjysby }}分</p>
              <p class="flexWrap" v-show="state.scoreInfo.fzby && state.scoreInfo.fzby!==0">服装表演：{{ state.scoreInfo.fzby }}分</p>
            </span>
            <div class="flexWrap">
              <el-button class="main-container" @click="oepnEditScoreInfo" style="width: 200px;" type="primary" :icon="Edit">修改成绩</el-button>
            </div>
          </div>
        </el-card>
        </div>
      </el-col>
      <el-col :span="20">
        <!--智能推荐-->
        <div v-if="state.activePage==='zntj'">
          <!--筛选项-->
          <div class="filterTable">
            <div class="filterTitle flexWrap">
              <div class="flex-item-35">
                <div class="filterSchool">院校筛选</div>
              </div>
              <div class="flex-item-65">
                <div class="searchSchool">
                  <el-input
                    v-model="state.selectForm.schoolName"  maxlength="24" show-word-limit
                    style="max-width: 230px;height: 40px;line-height: 40px;"
                    placeholder="请输入院校或专业名称"
                    class="input-with-select"/>
                  <el-button :icon="Search" @click="reloadRecommendVolunteerList" style="border-left: none;height: 40px;line-height: 40px;" />
                </div>
              </div>
            </div>
            <div class="filterBody">
              <div class="flexWrap">
                <div class="flex-item-1">就读地域</div>
                <div class="flex-item-9 tags">
                  <span class="tag" :class="state.selectForm.addressList.length==0?'tag-active':''"
                  @click="checkboxAddress('')">不限</span>
                  <span class="tag" :class="state.selectForm.addressList.includes(item.code)?'tag-active':''"
                  v-for="(item,index) in state.addressList" :key="index"
                  @click="checkboxAddress(item.code)">
                    {{ item.name }}
                  </span>
                </div>
              </div>
              <div class="flexWrap">
                <div class="flex-item-1">科研教学</div>
                <div class="flex-item-9 tags">
                  <span class="tag" :class="state.selectForm.kyjxList.length==0?'tag-active':''"
                  @click="checkboxKyjx('')">不限</span>
                  <span class="tag" :class="state.selectForm.kyjxList.includes(item)?'tag-active':''"
                  v-for="(item,index) in state.kyjxList" :key="index"
                  @click="checkboxKyjx(item)">
                    {{ item }}
                  </span>
                </div>
              </div>
              <div class="flexWrap">
                <div class="flex-item-1">院校标签</div>
                <div class="flex-item-9 tags">
                  <span class="tag" :class="state.selectForm.tagsList.length==0?'tag-active':''"
                  @click="checkboxSchoolTags('')">不限</span>
                  <span class="tag" :class="state.selectForm.tagsList.includes(item.code)?'tag-active':''"
                  v-for="(item,index) in state.tagsList" :key="index"
                  @click="checkboxSchoolTags(item.code)">
                    {{ item.name }}
                  </span>
                </div>
              </div>
              <div class="flexWrap">
                <div class="flex-item-1">办学类型</div>
                <div class="flex-item-9 tags">
                  <span class="tag" :class="state.selectForm.schoolNatureList.length==0?'tag-active':''"
                  @click="checkboxSchoolNature('')">不限</span>
                  <span class="tag" :class="state.selectForm.schoolNatureList.includes(item.code)?'tag-active':''"
                  v-for="(item,index) in state.schoolNatureList" :key="index"
                  @click="checkboxSchoolNature(item.code)">
                    {{ item.name }}
                  </span>
                </div>
              </div>
              <div class="flexWrap">
                <div class="flex-item-1">录取方式</div>
                <div class="flex-item-9 tags">
                  <span class="tag" :class="state.selectForm.rulesEnrollProbabilityList.length==0?'tag-active':''"
                  @click="checkboxRulesEnroll('')">不限</span>
                  <span class="tag" :class="state.selectForm.rulesEnrollProbabilityList.includes(item.value)?'tag-active':''"
                  v-for="(item,index) in state.rulesEnrollProbabilityList" :key="index"
                  @click="checkboxRulesEnroll(item.value)">
                    {{ item.label }}
                  </span>
                </div>
              </div>
              <div class="border-b"></div>
              <div class="flexWrap">
                <span class="clearFilterButton" @click="clearFilter">重置已选</span>
              </div>
            </div>
          </div>
          <!--难录取/较稳妥....-->
          <div class="paneTypes1 flexWrap">
            <div class="flex-item-4">
              <div class="flexWrap">
                <div class="panetype" :class="state.selectForm.batch==='本科提前批'?'panetype-active':''" @click="switchBatch('本科提前批')">本科提前批</div>
                <div class="panetype" :class="['本科','本科批','985/211/双一流','公办本科','民办本科'].includes(state.selectForm.batch)?'panetype-active':''" @click="switchBatch('本科批')">本科批</div>
                <div class="panetype" :class="state.selectForm.batch==='高职高专'?'panetype-active':''" @click="switchBatch('高职高专')">高职批</div>
              </div>
            </div>
            <div class="flex-item-4" v-if="['本科','985/211/双一流','公办本科','民办本科'].includes(state.selectForm.batch) && state.scoreInfo.professionalCategory!=='体育类'">
              <div class="flexWrap">
                <div class="panetype" :class="state.selectForm.batch==='985/211/双一流'?'panetype-active':''" @click="switchBatch('985/211/双一流')">985/211/双一流</div>
                <div class="panetype" :class="state.selectForm.batch==='公办本科'?'panetype-active':''" @click="switchBatch('公办本科')">公办本科</div>
                <div class="panetype" :class="state.selectForm.batch==='民办本科'?'panetype-active':''" @click="switchBatch('民办本科')">民办本科</div>
              </div>
            </div>


          </div>
          <!--难录取/较稳妥....-->
          <div class="paneTypes flexWrap">
            <div class="panetype" :class="state.selectForm.paneName==='全部'?'panetype-active':''" @click="switchPane('全部')">全部&nbsp;{{ state.vipInfo.sl?state.slData.allNumber:'??' }}</div>
            <div class="panetype" v-if="state.slData.nan!==0" :class="state.selectForm.paneName==='难录取'?'panetype-active nan':''" @click="switchPane('难录取')">难录取&nbsp;{{ state.vipInfo.sl?state.slData.nan:'??' }}</div>
            <div class="panetype" v-if="state.slData.kcj!==0" :class="state.selectForm.paneName==='可冲击'?'panetype-active chong':''" @click="switchPane('可冲击')">可冲击&nbsp;{{ state.vipInfo.sl?state.slData.kcj:'??' }}</div>
            <div class="panetype" v-if="state.slData.jwt!==0" :class="state.selectForm.paneName==='较稳妥'?'panetype-active wen':''" @click="switchPane('较稳妥')">较稳妥&nbsp;{{ state.vipInfo.sl?state.slData.jwt:'??' }}</div>
            <div class="panetype" v-if="state.slData.kbd!==0" :class="state.selectForm.paneName==='可保底'?'panetype-active bao':''" @click="switchPane('可保底')">可保底&nbsp;{{ state.vipInfo.sl?state.slData.kbd:'??' }}</div>
          </div>
          <el-table v-if="state.recommendVolunteer.list && state.recommendVolunteer.list.length>0" :data="state.recommendVolunteer.list" class="elTable" style="width:100%;height: 75vh;" v-el-table-infinite-scroll="handleRecommTableScroll">
            <el-table-column label="招生院校" width="210">
              <template #default="scope">
                <div class="top-align">
                  <div class="flexWrap">
                    <span class="font-size-16 fw-6 black1 showClick" @click="openSchoolInfo(scope.row.schoolCode)">{{ scope.row.schoolName }}</span>
                  </div>
                  <div class="flexWrap mt-10">
                    <span class="font-size-14 mr-5">{{ scope.row.province }}</span>
                    <span class="font-size-14 mr-5">{{ scope.row.schoolNature }}</span>
                    <span class="font-size-14">{{ scope.row.institutionType }}</span>
                  </div>
                  <div class="flexWrap mt-10" style="line-height: 10px;">
                    <span class="font-size-14 mr-5">院校代码</span>
                    <span class="font-size-14" style="background-color:bisque;padding:1 7px;border-radius: 3px;">{{ scope.row.schoolCode }}</span>
                  </div>
                </div>

              </template>
            </el-table-column>
            <el-table-column label="录取概率" width="100" align="center">
              <template #default="scope">
                <div class="top-align flexWrap">
                    <span class="font-size-15" style="margin: 0 auto;" v-if="state.vipInfo.lqgl">{{ formatDecimal(scope.row.enrollProbability) }}</span>
                    <span class="font-size-15" style="margin: 0 auto;" v-else>???%</span>
                </div>
                <div class="flexWrap" v-if="state.vipInfo.lqgl">
                  <span style="margin: 0 auto;">
                    <img :src="returnEnrollProbabilityIcon(scope.row.enrollProbability)" class="icon32"/>
                  </span>
                </div>
                <div class="flexWrap">
                  <span style="margin: 0 auto;" v-if="scope.row.studentScore">
                    折合分：{{ scope.row.studentScore }}
                  </span>
                </div>
                <div class="flexWrap">
                  <span style="margin: 0 auto;" v-if="scope.row.scoreLineDifference">
                    线差：{{ scope.row.scoreLineDifference }}
                  </span>
                </div>
              </template>
            </el-table-column>
            <el-table-column label="招生专业" width="230" align="center">
              <template #default="scope">
                <div class="top-align">
                  <div class="flexWrap">
                    <span class="font-size-16 fw-6 black1 main-container showClick" @click="openMajor(scope.row.majorCode)">{{ scope.row.majorName }}</span>
                    <span class="showClick" @click="openMajor(scope.row.majorCode)">{{scope.row.majorDetail}}{{scope.row.tuition ? '['+scope.row.tuition+']':'' }}</span>
                  </div>
<!--                  <div class="flexWrap mt-20" style="line-height: 10px;">-->
<!--                    <div style="color:red" class="main-container" v-show="scope.row.state == '2'">新</div>-->
<!--                  </div>-->
                  <div class="flexWrap mt-20" style="line-height: 10px;">
                    <span class="font-size-14 main-container">专业代码</span>
                    <span class="font-size-14 main-container" style="background-color:bisque;padding:1 7px;border-radius: 3px;">{{ scope.row.enrollmentCode }}</span>
                  </div>
                </div>

              </template>
            </el-table-column>
            <el-table-column label="26省内招生"  align="center">
              <template #default="scope">
                <div class="top-align flexWrap">
                  <span class="font-size-16 black1" style="margin: 0 auto;">{{ scope.row.planNum + '人' || '未公布' }}</span>
                  <!-- <span class="font-size-16 black1" style="margin: 0 auto;">未公布</span> -->
                </div>
                <div class="flexWrap mt-10">
                  <span style="margin: 0 auto;">
                    录取方式
                  </span>
                </div>
                <div class="flexWrap">
                    <span style="margin: 0 auto;" class="fw-6">
                      {{ scope.row.rulesEnrollProbability || scope.row.rulesEnrollProbabilitySx ||'未知'}}
                    </span>
                  </div>
              </template>
            </el-table-column>
            <el-table-column label="历年" width="80" align="center">
              <template #default="scope">
                <div class="flexWrap font-size-14 black1 lh-50 border-l border-b">
                  <span class="main-container">招生人数</span>
                </div>
                <div class="flexWrap font-size-14 black1 lh-50 border-l border-b">
                  <span class="main-container">最低分数</span>
                </div>
                <div class="flexWrap font-size-14 black1 lh-50 border-l border-b" v-if="state.userInfo.showLinediff==='1'">
                  <span class="main-container">历年线差</span>
                </div>
                <div class="flexWrap font-size-14 black1 lh-50 border-l">
                  <span class="main-container">录取方式</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column v-for="(item,index) in ['2025','2024','2023']" :key="index" :label="item" width="140" align="center">
              <template #default="scope">
                <div class="flexWrap font-size-14 black1 lh-50  border-l border-b border-r" style="min-height: 50px;">
                  <span class="main-container">{{ scope.row.historyMajorEnrollMap&& scope.row.historyMajorEnrollMap[item] && scope.row.historyMajorEnrollMap[item].enrollNum || '未公布' }}</span>
                </div>
                <div class="flexWrap font-size-14 black1 lh-50  border-l border-b border-r" style="min-height: 50px;">
                  <span class="main-container">{{ scope.row.historyMajorEnrollMap&& scope.row.historyMajorEnrollMap[item] && scope.row.historyMajorEnrollMap[item].admissionLine }}</span>
                </div>
                <div class="flexWrap font-size-14 black1 lh-50  border-l border-b border-r" style="min-height: 50px;" v-if="state.userInfo.showLinediff==='1'">
                  <span class="main-container">{{ scope.row.historyMajorEnrollMap&& scope.row.historyMajorEnrollMap[item] && scope.row.historyMajorEnrollMap[item].scoreLineDifference }}</span>
                </div>
                <div class="flexWrap font-size-14 black1 border-l border-r" style="min-height: 50px;">
                  <span class="main-container" v-if="scope.row.historyMajorEnrollMap&& scope.row.historyMajorEnrollMap[item]">
                    {{scope.row.historyMajorEnrollMap[item].probabilityOperator }}
                  </span>
                </div>
              </template>
            </el-table-column>
            <el-table-column fixed="right" width="115" label="操作" align="center">
              <template #default="scope">
                <div class="flexWrap font-size-14" style="height: 150px;">
                  <span class="showOtherButton" @click="handleShowOtherMajor(scope.row)" style="">
                      查看可选专业
                    </span>
                </div>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <!--我的志愿-->
        <div v-else-if="state.activePage ==='wdzy'">
          <div class="border-eb bgd-while p-20">
            <div class="flexWrap">
              <div class="flex-item-4 pl-10 pr-10" style="line-height: 30px">
                <div class="flexWrap">
                  <div class="flex-item-1">名称</div>
                  <div class="flex-item-7 pl-10"><el-input v-model="state.volunteerInfo.editVolunteerName"/></div>
                  <div class="flex-item-1">
                    <el-popconfirm
                        confirm-button-text="确定"
                        cancel-button-text="取消"
                        :icon="InfoFilled"
                        icon-color="#626AEF"
                        title="确定修改志愿表名称吗?"
                        @confirm="handlerEditVolunteerName"
                    >
                        <template #reference>
                          <el-button :disabled="state.volunteerInfo.volunteerName===state.volunteerInfo.editVolunteerName">修改</el-button>
                        </template>
                    </el-popconfirm>
                  </div>
                </div>
              </div>
              <div class="flex-item-4 pl-20 pr-10"  style="line-height: 30px;">
                <!-- <div class="flexWrap">
                  <div class="flex-item-1">优化</div>
                  <div class="flex-item-2 pl-10"><el-button @click="handlerAutoSortVolunteer">智能排序</el-button></div>
                </div> -->
              </div>
            </div>
            <div class="flexWrap mt-15">
              <div class="flex-item-4 pl-10 pr-10" style="line-height: 30px">
                <div class="flexWrap">
                  <div class="flex-item-1">功能</div>
                  <div class="flex-item-2 pl-10"><el-button @click="handlerVolunteerSwitch">切换</el-button></div>
                  <div class="flex-item-2 pl-10"><el-button @click="handlerVolunteerExport">打印</el-button></div>
                </div>
              </div>
            </div>

          </div>
          <div class="paneTypes flexWrap">
            <div class="panetype" v-if="state.scoreInfo.meBatchLevel==0" :class="state.selectForm.batchPaneName==='提前批'?'panetype-active':''" @click="switchBatchPane('提前批')">本科提前批</div>
            <div class="panetype" v-if="state.scoreInfo.meBatchLevel==0" :class="state.selectForm.batchPaneName==='本科批'?'panetype-active':''" @click="switchBatchPane('本科批')">本科批</div>
            <div class="panetype" v-if="state.scoreInfo.meBatchLevel<=3" :class="state.selectForm.batchPaneName==='高职高专'?'panetype-active':''" @click="switchBatchPane('高职高专')">高职高专</div>
          </div>
          <el-table row-draggable :data="returnVolunteerList()" height="800" style="width: 100%;">
            <el-table-column label="招生院校" width="190">
              <template #default="scope">
                <div class="top-align" v-if="scope.row.schoolName">
                  <div class="flexWrap">
                    <span class="font-size-16 fw-6 black1" @click="openSchoolInfo(scope.row.schoolCode)">{{ scope.row.schoolName }}</span>
                  </div>
                  <div class="flexWrap mt-10">
                    <span class="font-size-14 mr-5">{{ scope.row.province }}</span>
                    <span class="font-size-14 mr-5">{{ scope.row.schoolNature }}</span>
                    <span class="font-size-14">{{ scope.row.institutionType }}</span>
                  </div>
                  <div class="flexWrap mt-10" style="line-height: 10px;">
                    <span class="font-size-14 mr-5">院校代码</span>
                    <span class="font-size-14" style="background-color:bisque;padding:1 7px;border-radius: 3px;">{{ scope.row.schoolCode }}</span>
                  </div>
                </div>

              </template>
            </el-table-column>
            <el-table-column label="录取概率" align="center">
              <template #default="scope">
                <div v-if="scope.row.schoolName">
                  <div class="top-align flexWrap">
                      <span class="font-size-15" style="margin: 0 auto;" v-if="state.vipInfo.lqgl">{{  formatDecimal(scope.row.enrollProbability) }}</span>
                      <span class="font-size-15" style="margin: 0 auto;" v-else>???%</span>
                  </div>
                  <div class="flexWrap" v-if="state.vipInfo.lqgl">
                    <span style="margin: 0 auto;">
                      <img :src="returnEnrollProbabilityIcon(scope.row.enrollProbability)" class="icon32"/>
                    </span>
                  </div>
                  <div class="flexWrap">
                    <span style="margin: 0 auto;" v-if="scope.row.studentScore">
                      折合分：{{ scope.row.studentScore }}
                    </span>
                  </div>
                  <div class="flexWrap">
                    <span style="margin: 0 auto;" v-if="scope.row.scoreLineDifference">
                      线差：{{ scope.row.scoreLineDifference }}
                    </span>
                  </div>

                </div>
              </template>
            </el-table-column>
            <el-table-column label="招生专业"  align="center">
              <template #default="scope">
                <div class="top-align" v-if="scope.row.schoolName">
                  <div class="flexWrap">
                    <span class="font-size-16 fw-6 black1 main-container showClick" @click="openMajor(scope.row.majorCode)">{{ scope.row.majorName }}</span>
                    <span class="showClick" @click="openMajor(scope.row.majorCode)">{{scope.row.majorDetail}}{{scope.row.tuition ? '['+scope.row.tuition+']':'' }}</span>
                  </div>
                  <div class="flexWrap mt-20" style="line-height: 10px;">
                    <span class="font-size-14 main-container">专业代码</span>
                    <span class="font-size-14 main-container" style="background-color:bisque;padding:1 7px;border-radius: 3px;">{{ scope.row.enrollmentCode }}</span>
                  </div>
                </div>

              </template>
            </el-table-column>
            <el-table-column label="26省内招生" width="150" align="center">
              <template #default="scope">
                <div v-if="scope.row.schoolName">
                  <div class="top-align flexWrap">
                    <span class="font-size-16 black1" style="margin: 0 auto;">{{ scope.row.planNum + '人' ||'未公布' }}</span>
                    <!-- <span class="font-size-16 black1" style="margin: 0 auto;">未公布</span> -->
                  </div>
                  <div class="flexWrap mt-10">
                    <span style="margin: 0 auto;">
                      录取方式
                    </span>
                  </div>
                  <div class="flexWrap">
                      <span style="margin: 0 auto;">
                        {{ scope.row.rulesEnrollProbability ||'未知'}}
                      </span>
                  </div>
                </div>
              </template>
            </el-table-column>
            <el-table-column label="历年" width="80" align="center">
              <template #default="scope">
                <div class="flexWrap font-size-14 black1 lh-50 border-l border-b">
                  <span class="main-container">招生人数</span>
                </div>
                <div class="flexWrap font-size-14 black1 lh-50 border-l border-b">
                  <span class="main-container">最低分数</span>
                </div>
                <div class="flexWrap font-size-14 black1 lh-50 border-l">
                  <span class="main-container">录取方式</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column v-for="(item,index) in ['2025','2024','2023']" :key="index" :label="item" width="100" align="center">
              <template #default="scope">
                <div>
                  <div class="flexWrap font-size-14 black1 lh-50  border-l border-b border-r" style="min-height: 50px;">
                    <span class="main-container" v-if="scope.row.schoolName">{{ scope.row.historyMajorEnrollMap&& scope.row.historyMajorEnrollMap[item] && scope.row.historyMajorEnrollMap[item].enrollNum  || '未公布'}}</span>
                  </div>
                  <div class="flexWrap font-size-14 black1 lh-50  border-l border-b border-r" style="min-height: 50px;">
                    <span class="main-container" v-if="scope.row.schoolName">{{ scope.row.historyMajorEnrollMap&& scope.row.historyMajorEnrollMap[item] && scope.row.historyMajorEnrollMap[item].admissionLine }}</span>
                  </div>
                  <div class="flexWrap font-size-14 black1 border-l border-r" style="min-height: 50px;">
                    <span class="main-container" v-if="scope.row.historyMajorEnrollMap&& scope.row.historyMajorEnrollMap[item]">
                      {{scope.row.historyMajorEnrollMap[item].probabilityOperator }}
                    </span>
                  </div>
                </div>
              </template>
            </el-table-column>
            <el-table-column fixed="right" width="115" label="操作" align="center">
              <template #default="scope">
                <div class="flexWrap font-size-14" style="height: 150px;"  v-if="scope.row.schoolName">
                  <el-popover placement="left" :width="200" trigger="click">
                    <template #reference>
                      <span class="selectVolunteerBtn selectVolunteerBtn-active">
                        志愿&nbsp;{{scope.row.indexs}}
                      </span>
                    </template>
                    <div class="" style="height: 300px;overflow:auto;">
                      <div v-for="(item,index) in returnVolunteerList()" @click="handleSwitchVolunteer(scope.row,(index+1))" :key="index" class="switchVolunteerItemBtn"
                      :class="{'switchVolunteerItemBtnActive':item.schoolName}">
                          志愿 {{item.indexs}}
                      </div>
                    </div>
                  </el-popover>
                  <el-popconfirm
                    confirm-button-text="确定"
                    cancel-button-text="取消"
                    :icon="InfoFilled"
                    icon-color="#626AEF"
                    title="确定要删除这个志愿吗?"
                    @confirm="confirmVolunteerDeleteEvent({batch:scope.row.batch,id:scope.row.calculationMajorId})"
                  >
                    <template #reference>
                      <div style="margin:0 auto"><el-button style="min-width: 95px;" type="danger" round>移除</el-button></div>
                    </template>
                  </el-popconfirm>
                </div>
                <div class="flexWrap font-size-14" style="height: 150px;" v-else>
                  <span class="selectVolunteerBtn" @click="state.activePage='zntj'">
                      添加 {{scope.row.indexs}}
                  </span>
                </div>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </el-col>
    </el-row>
  </div>


  <!--查看其他专业-->
  <div class="showOtherMajorDialogDiv">
    <el-dialog
        v-model="state.visible.showOtherMajorDialog"
        title=" "
        width="1155px"
        :closeOnClickModal="false"
        :show-close="false"
    >
      <template #header>
        <div class="otherMajorDialogHeader">
          <div class="flex-item-2">
            <span class="schoolName" @click="openSchoolInfo(state.otherMajorInfo.schoolCode)">{{ state.otherMajorInfo.schoolName }}</span>
          </div>
          <div class="flex-item-2">
            <span class="schoolCode mr-5">院校代码</span>
            <span class="black">{{ state.otherMajorInfo.schoolCode }}</span>
          </div>
          <div class="flex-item-5">
            <el-icon style="float: right" @click="closeOtherMajorDialog" class="el-dialog__headerbtn"><Close /></el-icon>
          </div>
        </div>
      </template>
      <div style="height: 650px">
        <el-table :data="state.otherMajorInfo.list" height="630" style="width: 100%;">
          <el-table-column label="招生专业" width="250">
            <template #default="scope">
              <div class="top-align">
                <div class="flexWrap">
                  <span class="font-size-16 fw-6 black1 showClick" @click="openMajor(scope.row.majorCode)">{{ scope.row.majorName }}</span><br/>
                  <span class="showClick" @click="openMajor(scope.row.majorCode)">{{scope.row.majorDetail}}{{scope.row.tuition ? '['+scope.row.tuition+']':'' }}</span>
                </div>
                <div class="flexWrap mt-20" style="line-height: 10px;">
                  <span class="font-size-14 mr-5">专业代码</span>
                  <span class="font-size-14" style="background-color:bisque;padding:1 7px;border-radius: 3px;">{{ scope.row.enrollmentCode }}</span>
                </div>
              </div>
            </template>
          </el-table-column>
          <el-table-column label="录取概率" width="100" align="center">
            <template #default="scope">
              <div class="top-align flexWrap">
                  <span class="font-size-15" style="margin: 0 auto;" v-if="state.vipInfo.lqgl">{{  formatDecimal(scope.row.enrollProbability) }}</span>
                  <span class="font-size-15" style="margin: 0 auto;" v-else>???%</span>
              </div>
              <div class="flexWrap" v-if="state.vipInfo.lqgl">
                <span style="margin: 0 auto;">
                  <img :src="returnEnrollProbabilityIcon(scope.row.enrollProbability)" class="icon32"/>
                </span>
              </div>
              <div class="flexWrap">
                <span style="margin: 0 auto;" v-if="scope.row.studentScore">
                  折合分：{{ scope.row.studentScore }}
                </span>
              </div>
              <div class="flexWrap">
                <span style="margin: 0 auto;" v-if="scope.row.scoreLineDifference">
                  线差：{{ scope.row.scoreLineDifference }}
                </span>
              </div>
            </template>
          </el-table-column>
          <el-table-column label="26省内招生" width="150" align="center">
            <template #default="scope">
              <div class="top-align flexWrap">
                <span class="font-size-16 black1" style="margin: 0 auto;">{{ scope.row.planNum + '人' ||'未公布' }}</span>
                <!-- <span class="font-size-16 black1" style="margin: 0 auto;">未公布</span> -->
              </div>
              <div class="flexWrap mt-10">
                <span style="margin: 0 auto;">
                  录取方式
                </span>
              </div>
              <div class="flexWrap">
                  <span style="margin: 0 auto;">
                    {{ scope.row.rulesEnrollProbability ||'未知'}}
                  </span>
                </div>
            </template>
          </el-table-column>
          <el-table-column label="历年" width="80" align="center">
            <template #default="scope">
              <div class="flexWrap font-size-14 black1 lh-50 border-l border-b">
                <span class="main-container">招生人数</span>
              </div>
              <div class="flexWrap font-size-14 black1 lh-50 border-l border-b">
                <span class="main-container">最低分数</span>
              </div>
              <div class="flexWrap font-size-14 black1 lh-50 border-l border-b" v-if="state.userInfo.showLinediff==='1'">
                <span class="main-container">历年线差</span>
              </div>

              <div class="flexWrap font-size-14 black1 lh-50 border-l">
                <span class="main-container">录取方式</span>
              </div>
            </template>
          </el-table-column>
          <el-table-column v-for="(item,index) in ['2025','2024','2023']" :key="index" :label="item" width="120" align="center">
            <template #default="scope">
              <div class="flexWrap font-size-14 black1 lh-50  border-l border-b border-r" style="min-height: 50px;">
                <span class="main-container">{{ scope.row.historyMajorEnrollMap&& scope.row.historyMajorEnrollMap[item] && scope.row.historyMajorEnrollMap[item].enrollNum || '未公布' }}</span>
              </div>
              <div class="flexWrap font-size-14 black1 lh-50  border-l border-b border-r" style="min-height: 50px;">
                <span class="main-container">{{ scope.row.historyMajorEnrollMap&& scope.row.historyMajorEnrollMap[item] && scope.row.historyMajorEnrollMap[item].admissionLine }}</span>
              </div>
              <div class="flexWrap font-size-14 black1 lh-50  border-l border-b border-r" style="min-height: 50px;" v-if="state.userInfo.showLinediff==='1'">
                <span class="main-container">{{ scope.row.historyMajorEnrollMap&& scope.row.historyMajorEnrollMap[item] && scope.row.historyMajorEnrollMap[item].scoreLineDifference }}</span>
              </div>
              <div class="flexWrap font-size-14 black1 border-l border-r" style="min-height: 50px;">
                <span class="main-container" v-if="scope.row.historyMajorEnrollMap&& scope.row.historyMajorEnrollMap[item]">
                  {{scope.row.historyMajorEnrollMap[item].probabilityOperator }}
                </span>
              </div>
            </template>
          </el-table-column>
          <el-table-column label="操作" width="180" align="center">
            <template #default="scope">
              <div class="flexWrap font-size-14" style="height: 150px;" v-if="checkHasPerms(scope.row.batch)">
                <!--之前选择-->
                <el-popconfirm  v-if="returnVolunteerIndex(scope.row)"
                  confirm-button-text="确定"
                  cancel-button-text="取消"
                  :icon="InfoFilled"
                  icon-color="#626AEF"
                  title="确定要删除这个志愿吗?"
                  @confirm="confirmVolunteerDeleteEvent(scope.row)"
                >
                  <template #reference>
                    <span class="selectVolunteerBtn selectVolunteerBtn-active">
                      志愿&nbsp;{{returnVolunteerIndex(scope.row)}}
                    </span>
                  </template>
                </el-popconfirm>

                <!--临时选择-->
                <span v-else-if="returnStorgeVolunteerIndex(scope.row)" @click="cancelSelectVolunteer(scope.row)" class="selectVolunteerBtn selectVolunteerBtn-active">
                  志愿&nbsp;{{returnStorgeVolunteerIndex(scope.row)}}
                </span>
                <!--未选择-->
                <span v-else class="selectVolunteerBtn" @click="selectVolunteer(scope.row)" style="">
                  填报
                </span>
              </div>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="otherMajorButtonMenu">
        <div>
          &nbsp;
          <el-popconfirm confirm-button-text="确定" cancel-button-text="取消"
            :icon="InfoFilled"
            icon-color="#626AEF"
            title="确定要保存吗?"
            @confirm="confirmVolunteerSaveEvent()"
          >
            <template #reference>
              <el-button :disabled="state.otherMajorInfo.storgeVolunteer.size===0" style="float: right;margin: 0 5px;" type="primary">保存志愿</el-button>
            </template>
          </el-popconfirm>
          <el-button @click="state.otherMajorInfo.storgeVolunteer.clear()" :disabled="state.otherMajorInfo.storgeVolunteer.size===0" style="float: right;">重置</el-button>
        </div>
      </div>
    </el-dialog>
  </div>
  <!--切换志愿表-->
  <div class="showOtherVolunteerDialogDiv">
    <el-dialog
        v-model="state.visible.showOtherVolunteerDialog"
        title=" "
        width="1155px"
        :closeOnClickModal="false"
        :show-close="false"
    >
      <template #header>
        <div class="otherMajorDialogHeader">
          <div class="flex-item-2">
            <span class="schoolName">切换志愿表</span>
          </div>
          <div class="flex-item-2">
          </div>
          <div class="flex-item-5">
            <el-icon style="float: right" @click="closeOtherVolunteerDialog" class="el-dialog__headerbtn"><Close /></el-icon>
          </div>
        </div>
      </template>
      <div style="height: 650px">
        <VolunteerList/>
      </div>
    </el-dialog>
  </div>
  <!--切换志愿顺序-->
  <div class="showOtherVolunteerDialogDiv">
    <el-dialog
        v-model="state.visible.switchVolunteerDialog"
        title=" "
        width="555px"
        :closeOnClickModal="false"
        :show-close="false"
    >
      <template #header>
        <div class="otherMajorDialogHeader">
          <div class="flex-item-2">
            <span class="schoolName">切换志愿顺序</span>
          </div>
          <div class="flex-item-2">
          </div>
          <div class="flex-item-5">
            <el-icon style="float: right" @click="state.visible.switchVolunteerDialog=false" class="el-dialog__headerbtn"><Close /></el-icon>
          </div>
        </div>
      </template>
      <div style="height: 650px">

      </div>
    </el-dialog>
  </div>
</template>

<script setup lang="ts">

document.title = '模拟报志愿|' + import.meta.env.VITE_PROGRAM_TYPE;
import {inject,onMounted,reactive} from 'vue';
import {checkLevel, isNull} from '@/utils/tool';
import {getScore,getRulesEnrollrobabilityMenuList} from '@/axios/api';
import {ScoreInfoEntity} from '@/types/index';
import {ElMessage} from 'element-plus';
import ApiConstant from '@/utils/ApiConstant';
import ImagesConstant from '@/utils/ImagesConstant';
import StaticConstant from '@/utils/StaticConstant';
import axiosInstance from '@/utils/http';
import bus from "@/store/eventBus";
import {InfoFilled,Search,Edit} from '@element-plus/icons-vue';
import { default as vElTableInfiniteScroll } from "el-table-infinite-scroll";
//接受路由参数
import { useRoute } from 'vue-router';
import VolunteerList from '../volunteer/volunteer-list.vue';
const route = useRoute();

// 定义一个变量，可以是布尔值，也可以是空值
type myBoolean= boolean | null | undefined;

const state = reactive({
  scoreInfo:{} as ScoreInfoEntity,
  addressList:[...StaticConstant.addressList] as any,//就读地域筛选项
  kyjxList:['硕士点','博士点','保研'] as Array<string>,//科研教学筛选项
  rulesEnrollProbabilityList:[] as Array<any>,//录取方式
  tagsList: StaticConstant.tagsList as Array<any>,//院校标签
  schoolNatureList: StaticConstant.schoolTypeList as Array<any>,//办学类型
  selectForm:{
    addressList:[] as Array<string>,
    kyjxList:[] as Array<string>,
    rulesEnrollProbabilityList:[] as Array<string>,//录取方式
    tagsList: [] as Array<string>,//院校标签
    schoolNatureList: [] as Array<string>,//办学类型
    schoolName:'',//查询院校名称
    current:1,//当前页
    pageSize:6,//每页大小
    paneName:'全部',//选择的概率段
    batch:'本科批',//选择的查询批次
    batchPaneName:'',//查询的批次pane
  },//查询对象
  recommendVolunteer:{
    list:[] as any,
    total:0,//总条数
    pages:0,//总页数
    hasNext:false,
  },//推荐列表
  userInfo:{
    showLinediff:'0',
  } as any,//用户信息
  vipInfo:{
    sl:false,//数量是否展示
    lqgl:false,//录取概率是否显示
    vipLevel:0,//vip等级
  },//vip信息
  slData:{
    nan:null,//难录取
    kcj:null,//可冲击
    jwt:null,//较稳妥
    kbd:null,//可保底
    allNumber:null,//全部
  },//可报数量
  activePage:'zntj',//当前打开的子页面 {label:'一键填报',value:'yjtb'},{label:'我的订单',value:'wddd'}
  pages:[{label:'智能推荐',value:'zntj'},{label:'我的志愿',value:'wdzy'},],//智能推荐，一键填报，我的志愿，我的订单
  visible:{
    showOtherMajorDialog:false,//查看其他专业弹出层判断
    showOtherVolunteerDialog:false,//切换志愿表
    switchVolunteerDialog:false,//切换志愿顺序
    leftShow:true,//左侧分数是否显示
  },
  volunteerInfo:{
    id:'',
    scoreId:'',
    volunteerName:'',//志愿表名称
    editVolunteerName:'',
    //volunteerDetailIndexMap:new Map(),
    volunteerBenIndexMap:new Map(),
    volunteerZhuanIndexMap:new Map(),
    volunteerRecordEarlyAdmissionList:[] as any,//提前批
    volunteerRecordUndergraduateAList:[] as any,//A段
    volunteerRecordUndergraduateBList:[] as any,//B段
    volunteerRecordUndergraduateList:[] as any,//体育本科
    volunteerRecordJuniorCollegeList:[] as any,//高职高专
    volunteerTiQianList:[] as any,
    volunteerBenList:[] as any,
    volunteerZhuanList:[] as any,

  },//已报志愿信息
  otherMajorInfo:{
    schoolCode:'6353',
    schoolName:'河南女子学校',
    current:1,
    total:0,//总条数
    pages:0,//总页数
    hasNext:false,
    storgeVolunteer:new Map(),
    list:[],
  },
})
const openEditScore = inject('openEditScore') as Function;
onMounted(() => {
  if(route.query.rulesEnrollProbability){
    state.selectForm.rulesEnrollProbabilityList.push(route.query.rulesEnrollProbability as any)
  }
  bus.on("closeOtherVolunteerChange"as any, (nameValue: string) => {
    closeOtherVolunteerDialog()
    console.log('触发了回调');
  });
  if(getScoreInfo()){
    let userInfo = localStorage.getItem('userInfo') as any
    if(userInfo){
      state.userInfo = JSON.parse(userInfo);
    }
    //vip判断
    let vipInfo = localStorage.getItem('vipInfo') as any
    if(vipInfo){
        vipInfo = JSON.parse(vipInfo);
        state.vipInfo.vipLevel = vipInfo.vipLevel
    }
    state.vipInfo.lqgl = checkLevel(0)
    state.vipInfo.sl = checkLevel(0)



    state.scoreInfo = JSON.parse(localStorage.getItem('scoreInfo') as string)
    //给查询批次赋默认值
    state.selectForm.batchPaneName = '本科批'
    if(state.scoreInfo.batch==='本科A段'){
    state.selectForm.batch = '公办本科'
    }else if(state.scoreInfo.batch==='本科B段'){
    state.selectForm.batch = '民办本科'
    }else{
    state.selectForm.batchPaneName = '高职高专'
    state.selectForm.batch = state.scoreInfo.batch
    }
    //将我的批次转为登记
    let mebatchLevel = state.scoreInfo.batch === '本科A段'||state.scoreInfo.batch === '本科B段'||state.scoreInfo.batch==='本科'?0:3;
    state.scoreInfo.meBatchLevel = mebatchLevel
     fetchDataAndUseResult()
    //  let rvlist = localStorage.getItem('rvlist')
    //  if(rvlist){
    //    state.recommendVolunteer.list = JSON.parse(rvlist as any)
    //  }
     getVolunteerDetail()
     getRecommendVolunteerList()
  }
});

function reloadRecommendVolunteerList(){
  clearPage()
  getRecommendVolunteerList()
}

// 在适当的地方调用异步函数并使用返回的数据
const fetchDataAndUseResult = async () => {
  try {
    // let rulesEnrollProbabilityListStr = localStorage.getItem('rulesEnrollProbabilityList')
    // if(!rulesEnrollProbabilityListStr){
    //
    // }else{
    //   state.rulesEnrollProbabilityList = JSON.parse(rulesEnrollProbabilityListStr)
    // }
    const professionalCategory = state.scoreInfo.professionalCategory; // 传递给函数的参数
    const result = await getRulesEnrollrobabilityMenuList(professionalCategory);
    localStorage.setItem('rulesEnrollProbabilityList',JSON.stringify(result));
    state.rulesEnrollProbabilityList = result
    // 在这里处理返回的数据
  } catch (error) {
    console.error('An error occurred:', error);
  }
};

//判断登录状态
function ifLogin(){
  let token = window.localStorage.getItem('X-Access-Token');
  const openLogin = inject('openLogin') as Function;
  if (!token && typeof openLogin === 'function') {
    openLogin(); // 调用提供的打开登录方法
    return false
  }
  return true
}

//打开更改成绩界面
function oepnEditScoreInfo(){
  if (typeof openEditScore === 'function') {
    openEditScore(); // 调用提供的打开更改成绩弹框
    return false
  }
  return true
}

var blevel = 0
//判断是否有权限填报该专业
function checkHasPerms(batch:any){
  if(!batch){
    //该专业批次为空,不可填报
    return false
  }
  //将批次转为登记
  blevel = batch === '提前批' || batch === '本科A段'|| batch==='本科B段' || batch ==='本科'?0:3;
  return state.scoreInfo.meBatchLevel<=blevel
}

//获取成绩
function getScoreInfo(){
  //判断登录
  if(ifLogin()){
    //从浏览器数据中取出成绩信息
    let scoreInfoStr = localStorage.getItem('scoreInfo') as string
    if(isNull(scoreInfoStr)){
      //如果取出来的成绩为空，则请求一次成绩接口
      getScore()
      //如果取出来之后还是没有成绩
      scoreInfoStr = localStorage.getItem('scoreInfo') as string
      if(isNull(scoreInfoStr)){
        //提示用户更改自己的成绩
        return oepnEditScoreInfo()
      }
    }
    return true
  }
  return false
}

//回到第一页
function clearPage(){
  state.selectForm.current = 1
  state.recommendVolunteer.hasNext = true
  state.recommendVolunteer.list = []
}

//切换子页面
function switchPages(page:string){
  state.activePage = page
}

function switchBatch(batch:string){
  if(state.selectForm.batch !== batch){
    state.selectForm.paneName = '全部'
    if(batch==='本科批' && state.scoreInfo.professionalCategory!=='体育类'){
      //如果不是体育类的本科批
      if(state.scoreInfo.batch==='本科A段'){
        //如果过了A段
        state.selectForm.batch = '公办本科'
      }else{
        //没过A段
        state.selectForm.batch = '民办本科'
      }
    }else{
      state.selectForm.batch = batch;
    }
    reloadRecommendVolunteerList()
  }

}
//切换pane
function switchPane(pane:string){
  if(state.selectForm.paneName !== pane){
    state.selectForm.paneName = pane
    //刷新数据
    reloadRecommendVolunteerList()
  }
}

//切换批次Pane
function switchBatchPane(batchPane:string){
  if(batchPane && state.selectForm.batchPaneName!==batchPane){
    state.selectForm.batchPaneName=batchPane
  }
}
//清除筛选项
function clearFilter(){
  state.selectForm.schoolName = ''
  state.selectForm.addressList = []
  state.selectForm.kyjxList = []
  state.selectForm.tagsList = []
  state.selectForm.schoolNatureList = []
  state.selectForm.rulesEnrollProbabilityList = []
  reloadRecommendVolunteerList()
}

//选择地区
function checkboxAddress(addressCode:string){
  if(!addressCode){
    state.selectForm.addressList = []
  }else if(state.selectForm.addressList.includes(addressCode)){
    state.selectForm.addressList =state.selectForm.addressList.filter(element => element !== addressCode)
  }else{
    state.selectForm.addressList.push(addressCode)
  }
  reloadRecommendVolunteerList()
}
//选择科研教学
function checkboxKyjx(kyjx:string){
  if(!kyjx){
    state.selectForm.kyjxList = []
  }else if(state.selectForm.kyjxList.includes(kyjx)){
    state.selectForm.kyjxList =state.selectForm.kyjxList.filter(element => element !== kyjx)
  }else{
    state.selectForm.kyjxList.push(kyjx)
  }
  reloadRecommendVolunteerList()
}
//选择院校标签
function checkboxSchoolTags(schoolTag:string){
  if(!schoolTag){
    state.selectForm.tagsList = []
  }else if(state.selectForm.tagsList.includes(schoolTag)){
    state.selectForm.tagsList =state.selectForm.tagsList.filter(element => element !== schoolTag)
  }else{
    state.selectForm.tagsList.push(schoolTag)
  }
  reloadRecommendVolunteerList()
}

//选择办学类型
function checkboxSchoolNature(schoolNature:string){
  if(!schoolNature){
    state.selectForm.schoolNatureList = []
  }else if(state.selectForm.schoolNatureList.includes(schoolNature)){
    state.selectForm.schoolNatureList =state.selectForm.schoolNatureList.filter(element => element !== schoolNature)
  }else{
    state.selectForm.schoolNatureList.push(schoolNature)
  }
  reloadRecommendVolunteerList()
}
//选择录取方式
function checkboxRulesEnroll(rulesEnroll:string){
  if(!rulesEnroll){
    state.selectForm.rulesEnrollProbabilityList = []
  }else if(state.selectForm.rulesEnrollProbabilityList.includes(rulesEnroll)){
    state.selectForm.rulesEnrollProbabilityList =state.selectForm.rulesEnrollProbabilityList.filter(element => element !== rulesEnroll)
  }else{
    state.selectForm.rulesEnrollProbabilityList.push(rulesEnroll)
  }
  reloadRecommendVolunteerList()
}

//获取已报志愿表信息
function getVolunteerDetail(){
  axiosInstance({
    url: ApiConstant.Volunteer.volunteerDetail,
    method: 'get',
    params:{},
    showLoading: false,//是否显示加载图标
  }).then((response) => {
    return response.data
  }).then((data) => {
    if(!data.success){
      ElMessage.error(data.message);
      return false
    }
    if(data.result){
      let allList=[] as any
      //将明细组合到一起
      // if(data.result.volunteerRecordEarlyAdmissionList){
      //   allList = allList.concat(data.result.volunteerRecordEarlyAdmissionList)
      // }
      // if(data.result.volunteerRecordUndergraduateAList){
      //   allList = allList.concat(data.result.volunteerRecordUndergraduateAList)
      // }
      // if(data.result.volunteerRecordUndergraduateBList){
      //   allList = allList.concat(data.result.volunteerRecordUndergraduateBList)
      // }
      //本科批
      if(data.result.volunteerRecordUndergraduateList){
        allList = allList.concat(data.result.volunteerRecordUndergraduateList)
      }
      //高职高专
      if(data.result.volunteerRecordJuniorCollegeList){
        allList = allList.concat(data.result.volunteerRecordJuniorCollegeList)
      }
      //将已报志愿信息组装成map
      let volunteerDetailIndexMap = new Map()
      let volunteerTqpIndexMap = new Map()//提前批
      let volunteerBenIndexMap = new Map()//本科
      let volunteerZhuanIndexMap = new Map()//专科

      //专科Map,indexs:value
      let volunteeZhuanOfIndexsMap = new Map()
      let volunteerBenOfIndexsMap = new Map()
      let a = {}
      allList.forEach((element: any) => {
        a = {id:element.id,indexs:element.indexs}
        //key = element.schoolCode+a+element.batch+a+element.majorCode+a+element.majorName+a+element.enrollmentCode
        if(element.batch === '提前批'||element.batch.includes('本科')){
          volunteerBenIndexMap.set(element.calculationMajorId,a)
          volunteerBenOfIndexsMap.set(element.indexs,element)
        }else{
          volunteerZhuanIndexMap.set(element.calculationMajorId,a)
          volunteeZhuanOfIndexsMap.set(element.indexs,element)
        }
      });
      //可报志愿数量
      state.volunteerInfo.id = data.result.id
      state.volunteerInfo.scoreId = data.result.scoreId
      state.volunteerInfo.volunteerName = data.result.volunteerName
      state.volunteerInfo.editVolunteerName = data.result.volunteerName
      state.volunteerInfo.volunteerBenIndexMap = volunteerBenIndexMap
      state.volunteerInfo.volunteerZhuanIndexMap = volunteerZhuanIndexMap
      //组合志愿表页面列表数据

      //高职高专
      let volunteerZhuanList=[] as any
      let e = null
      for(let i=1;i<=64;i++){
         e = volunteeZhuanOfIndexsMap.get(i)
         if(!e){
          volunteerZhuanList.push({indexs:i})
         }else{
          volunteerZhuanList.push(e)
         }
      }
      state.volunteerInfo.volunteerZhuanList = volunteerZhuanList

      //本科
      let volunteerBenList=[] as any
      for(let i=1;i<=64;i++){
         e = volunteerBenOfIndexsMap.get(i)
         if(!e){
          volunteerBenList.push({indexs:i})
         }else{
          volunteerBenList.push(e)
         }
      }
      state.volunteerInfo.volunteerBenList = volunteerBenList

    }
  }).catch((error: any) => {
    console.log(error);
  }).finally(() => {
  });
}

function returnVolunteerIndex(majorInfo:any){
  let key = majorInfo.id
  let info = null
  if(majorInfo.batch === '提前批'|| majorInfo.batch.includes('本科')){
    info = state.volunteerInfo.volunteerBenIndexMap.get(key);
  }else{
    info = state.volunteerInfo.volunteerZhuanIndexMap.get(key);
  }
  if(info===undefined || info===null){
    return null
  }
  return info.indexs
}

//从临时数据中获取选择志愿索引
function returnStorgeVolunteerIndex(majorInfo:any){
  let key = majorInfo.id
  let r = state.otherMajorInfo.storgeVolunteer.get(key)
  return r
}
//选择该专业
function selectVolunteer(majorInfo:any){
  console.log('aa')
  let a = '-'
  let key = majorInfo.id
  //majorInfo.schoolCode+a+majorInfo.batch+a+majorInfo.majorCode+a+majorInfo.majorName+a+majorInfo.enrollmentCode
  let valuesArray = []
  if(majorInfo.batch === '提前批'|| majorInfo.batch.includes('本科')){
    valuesArray = Array.from(state.volunteerInfo.volunteerBenIndexMap.values()).map((value) => value.indexs)

  }else{
    valuesArray = Array.from(state.volunteerInfo.volunteerZhuanIndexMap.values()).map((value) => value.indexs)
  }
  valuesArray = valuesArray.concat(Array.from(state.otherMajorInfo.storgeVolunteer.values()))
  let closestNextValue = null;
  // 对值数组进行升序排序
  if (valuesArray && valuesArray.length>0) {
    valuesArray.sort((a, b) => a - b);

    // 找到缺失的数字或者接近的下一个值
    for (let i = 0; i < valuesArray.length; i++) {
        if (valuesArray[i] !== i + 1) {
            closestNextValue = i + 1;
            break;
        }
    }
    if (closestNextValue === null) {
        closestNextValue = valuesArray[valuesArray.length - 1] + 1;
    }
  } else {
    closestNextValue = 1;
  }
  state.otherMajorInfo.storgeVolunteer.set(key,closestNextValue);
}

//确定保存志愿
function confirmVolunteerSaveEvent(){
  //拼接志愿表明细参数
  let k = ''
  let saveList=[] as any
  state.otherMajorInfo.storgeVolunteer.forEach((value,key)=>{
    let ss= {calculationMajorId:key,indexs:value}
    saveList.push(ss)
  })
  axiosInstance({
    url: ApiConstant.Volunteer.volunteerSaveBatch,
    method: 'post',
    data:{
      list:saveList
    },
    /*showLoading: false,//是否显示加载图标*/
  }).then((response) => {
    return response.data
  }).then((data) => {
    if(!data.success){
      ElMessage.error(data.message);
      return false
    }else{
      ElMessage.success('保存成功');
      //请求接口更新志愿信息
      getVolunteerDetail()
      //关闭弹框
      closeOtherMajorDialog()
    }
  }).catch((error: any) => {
    console.log(error);
  }).finally(() => {
  });
}

//取消曾经选择的志愿
function confirmVolunteerDeleteEvent(majorInfo:any){
  let a = null
  let key = majorInfo.id
  let flag = false
  if(majorInfo.batch === '提前批'|| majorInfo.batch.includes('本科')){
    flag = true
    a = state.volunteerInfo.volunteerBenIndexMap.get(key)
  }else{
    a = state.volunteerInfo.volunteerZhuanIndexMap.get(key)
  }
  axiosInstance({
    url: ApiConstant.Volunteer.volunteerDeleteBatch,
    method: 'post',
    data:{
      list:[a.id]
    },
    /*showLoading: false,//是否显示加载图标*/
  }).then((response) => {
    return response.data
  }).then((data) => {
    if(!data.success){
      ElMessage.error(data.message);
      return false
    }else{
      ElMessage.success('删除成功');
      //删除这个志愿明细key信息
      deleteVolunteerMapByKey(flag,key)
      //刷新志愿明细
      getVolunteerDetail()
      //关闭弹框
      //closeOtherMajorDialog()
    }
  }).catch((error: any) => {
    console.log(error);
  }).finally(() => {
  });
}

//判断是storge/本科/专科 的志愿表map里删除
function deleteVolunteerMapByKey(type:myBoolean,key:string){
  if(type===undefined || type===null){
    //storge的
    state.otherMajorInfo.storgeVolunteer.delete(key)
  }else if(type){
    state.volunteerInfo.volunteerBenIndexMap.delete(key)
  }else{
    //专科的
    state.volunteerInfo.volunteerZhuanIndexMap.delete(key)
  }
}

//取消临时选择的志愿
function cancelSelectVolunteer(majorInfo:any){
  let key = majorInfo.id
  deleteVolunteerMapByKey(null,key)
}
//模拟志愿列表
function getRecommendVolunteerList(){
  //处理真正要查询的批次
  let selectBatch = ''
  let selectKslx = '统考'
  if(state.selectForm.batch){
    if(state.selectForm.batch === '985/211/双一流'){
      selectBatch = '提前批'
    }else if(state.selectForm.batch === '公办本科'){
      selectBatch = '本科A段'
    }else if(state.selectForm.batch === '民办本科'){
      selectBatch = '本科B段'
    }else if(state.selectForm.batch === '本科提前批'){
      selectBatch = ''
      selectKslx = '校考'
    }else{
      selectBatch = state.selectForm.batch.replace('批','')
    }
  }
  //录取方式
  let params = {
    schoolName: state.selectForm.schoolName,//学校名称
    pageNum: state.selectForm.current,
    pageSize: (state.vipInfo && state.vipInfo.vipLevel >= 2) ? state.selectForm.pageSize : 6,
    paneName: state.selectForm.paneName,
    batch: selectBatch,
    province: state.selectForm.addressList?state.selectForm.addressList.join(','):'',
    rulesEnrollProbability: state.selectForm.rulesEnrollProbabilityList?state.selectForm.rulesEnrollProbabilityList.join(','):'',
    tagsStrs: state.selectForm.tagsList?state.selectForm.tagsList.join(','):'',
    schoolNatureStrs: state.selectForm.schoolNatureList?state.selectForm.schoolNatureList.join(','):'',
    kyjxStrs: state.selectForm.kyjxList?state.selectForm.kyjxList.join(','):'',
    scoreId: '',
    kslx:selectKslx
  }
  axiosInstance({
    url: ApiConstant.Volunteer.recommendMajorPage,
    method: 'get',
    params:params,
    /*showLoading: false,//是否显示加载图标*/
  }).then((response) => {
    return response.data
  }).then((data) => {
    if(!data.success){
      ElMessage.error(data.message);
      return false
    }
    if(data.result){
      // let haveMajorList = data.result.haveMajorList;//可报志愿数量
      // if(haveMajorList.includes('提前批')){
      //   state.selectForm.batch = '985/211/双一流'
      // }else if(haveMajorList.includes('本科A段')){
      //   state.selectForm.batch = '公办本科'
      // }else if(haveMajorList.includes('本科B段')){
      //   state.selectForm.batch = '民办本科'
      // }else if(haveMajorList.includes('本科批')){
      //   state.selectForm.batch = '本科批'
      // }else if(haveMajorList.includes('高职高专')){
      //   state.selectForm.batch = '高职高专'
      // }
      state.slData.nan= data.result.nan
      state.slData.kcj= data.result.kcj
      state.slData.jwt= data.result.jwt
      state.slData.kbd= data.result.kbd
      state.slData.allNumber= data.result.allNumber
      //列表数据
      if(data.result.pageList){
        if(data.result.pageList.current >=data.result.pageList.total){
          state.recommendVolunteer.hasNext = false
        }else{
          state.recommendVolunteer.hasNext = true
        }
        state.recommendVolunteer.total = data.result.pageList.total
        state.recommendVolunteer.pages = data.result.pageList.pages
        if (state.recommendVolunteer.list && data.result.pageList.records) {
            state.recommendVolunteer.list = state.recommendVolunteer.list.concat(data.result.pageList.records);
            //localStorage.setItem('rvlist',JSON.stringify(state.recommendVolunteer.list))
        }
      }else{
        state.recommendVolunteer.hasNext = false
      }
    }

    //有数据情况下
    setTimeout(function(){}, 1000);
  }).catch((error: any) => {
    console.log(error);
  }).finally(() => {
  });
}

//其他专业
function otherRecommendVolunteerList(){
  //处理真正要查询的批次
  let selectBatch = ''
  let selectKslx = '统考'
  if(state.selectForm.batch){
    if(state.selectForm.batch === '985/211/双一流'){
      selectBatch = '提前批'
    }else if(state.selectForm.batch === '公办本科'){
      selectBatch = '本科A段'
    }else if(state.selectForm.batch === '民办本科'){
      selectBatch = '本科B段'
    }else if(state.selectForm.batch === '本科提前批'){
      selectBatch = ''
      selectKslx = '校考'
    }else{
      selectBatch = state.selectForm.batch
    }
  }
  //录取方式
  let params = {
    schoolName: state.otherMajorInfo.schoolCode,//学校名称
    pageNum: state.otherMajorInfo.current,
    pageSize: (state.vipInfo && state.vipInfo.vipLevel >= 2) ? 20 : 3,
    paneName: state.selectForm.paneName,
    batch: selectBatch,
    province: '',
    rulesEnrollProbability:'',
    tagsStrs: '',
    schoolNatureStrs: '',
    kyjxStrs: '',
    scoreId: '',
    kslx:selectKslx
  }
  axiosInstance({
    url: ApiConstant.Volunteer.recommendMajorPage,
    method: 'get',
    params:params,
    /*showLoading: false,//是否显示加载图标*/
  }).then((response) => {
    return response.data
  }).then((data) => {
    if(!data.success){
      ElMessage.error(data.message);
      return false
    }
    if(data.result){
      //可报志愿数量
      //列表数据
      if(data.result.pageList){
        if(data.result.pageList.current >=data.result.pageList.total){
          state.otherMajorInfo.hasNext = false
        }else{
          state.otherMajorInfo.hasNext = true
        }
        state.otherMajorInfo.total = data.result.pageList.total
        state.otherMajorInfo.pages = data.result.pageList.pages
        state.otherMajorInfo.list = state.otherMajorInfo.list.concat(data.result.pageList.records);
      }else{
        state.otherMajorInfo.hasNext = false
      }
    }
  }).catch((error: any) => {
    console.log(error);
  }).finally(() => {
  });
}

//根据录取概率 返回class
function returnEnrollProbabilityIcon(e:number){
  if (e >= 93) {
    return ImagesConstant.enrollProbability.kbd;
  } else if (e < 93 && e >= 74) {
    return ImagesConstant.enrollProbability.jwt;
  } else if (e < 74 && e >= 60) {
    return ImagesConstant.enrollProbability.kcj;
  }
  return ImagesConstant.enrollProbability.nan;
}

//格式化录取概率
function formatDecimal(value:any) {
  try {
    if(value == 0){
      return '无概率'
    }
    return parseFloat(value).toFixed(2) + '%';
  } catch (error) {
    return '??';
  }
}

//推荐志愿表格翻滚事件
function handleRecommTableScroll(){
  console.log(state.recommendVolunteer.hasNext)

  if(!(state.vipInfo && state.vipInfo.vipLevel >= 2) && state.selectForm.current>=2){
    //如果当前不是vip，且已经翻了2页，则不继续翻页
    return false;
  }
  //如果还有下一页
  if (state.recommendVolunteer.hasNext) {
    //if ((state.selectForm.current - 1) * state.selectForm.pageSize < state.recommendVolunteer.total) {
      // 如果当前不是最后一页，获取下一页数据
      state.selectForm.current++;
      getRecommendVolunteerList();
    //}
  }
}

//查看其他专业
function handleShowOtherMajor(majorInfo:any){
  state.otherMajorInfo.list = []
  state.otherMajorInfo.current = 1
  state.otherMajorInfo.schoolCode = majorInfo.schoolCode
  state.otherMajorInfo.schoolName = majorInfo.schoolName
  state.visible.showOtherMajorDialog = true
  otherRecommendVolunteerList()
}

//其他专业表格翻滚事件
function handleOtherRecommTableScroll(){
  //如果还有下一页
  if (state.otherMajorInfo.hasNext) {
    // 如果当前不是最后一页，获取下一页数据
    state.otherMajorInfo.current++;
    otherRecommendVolunteerList();
  }
}

//关闭查看其他专业弹出层
function closeOtherMajorDialog(){
  state.otherMajorInfo.schoolCode = ''
  state.otherMajorInfo.schoolName = ''
  state.otherMajorInfo.storgeVolunteer.clear()
  state.visible.showOtherMajorDialog = false
}

//打开其他志愿表弹出层
function handlerVolunteerSwitch(){
  if(getScoreInfo()){
    state.visible.showOtherVolunteerDialog=true
  }
}
//关闭其他志愿表弹出层
function closeOtherVolunteerDialog(){
  state.visible.showOtherVolunteerDialog = false
}
//导出志愿信息
function handlerVolunteerExport(){
  if(getScoreInfo() && state.volunteerInfo.id){
    window.open('https://www.yitisheng.vip/volunteer/preview?id='+state.volunteerInfo.id+"&type=2")
  }
}
// 切换志愿顺序
function handleSwitchVolunteer(now:any,endIndexs:any){
  //state.switchVolunteerIndex
  axiosInstance({
    url: ApiConstant.Volunteer.exchangeIndexs,
    method: 'post',
    data:{
      id: now.id,
      batch:now.batch,
      volunteerId:state.volunteerInfo.id,
      indexs:endIndexs
    },
    /*showLoading: false,//是否显示加载图标*/
  }).then((response) => {
    return response.data
  }).then((data) => {
    if(!data.success){
      ElMessage.error(data.message);
      return false
    }else{
      // 刷新志愿列表
      getVolunteerDetail()
    }
  }).catch((error: any) => {
    console.log(error);
  }).finally(() => {
  });

}


//修改志愿表名称
function handlerEditVolunteerName(){
  axiosInstance({
        url: ApiConstant.Volunteer.editNowVolunteerName,
        method: 'post',
        data: {volunteerName:state.volunteerInfo.editVolunteerName},
        showLoading: false,//是否显示加载图标
    }).then((response) => {
        return response.data
    }).then((data) => {
        if (!data.success) {
            ElMessage.error(data.message);
            return false
        }
        state.volunteerInfo.volunteerName = state.volunteerInfo.editVolunteerName
        //切换成功，刷新成绩
        ElMessage.success("操作成功");
    }).catch((error: any) => {
        console.log(error);
    }).finally(() => {
    });
}
function openMajor(majorCode:any){
  window.open('/major/'+majorCode, '_self')
}

function openSchoolInfo(schoolCode:any){
  if(schoolCode){
    state.otherMajorInfo.schoolCode = schoolCode
  }
  window.open('/school/'+state.otherMajorInfo.schoolCode, '_self')
}

function returnVolunteerList(){
  return state.selectForm.batchPaneName==='提前批'?state.volunteerInfo.volunteerTiQianList:
          state.selectForm.batchPaneName==='本科批'?state.volunteerInfo.volunteerBenList:
          state.volunteerInfo.volunteerZhuanList;
}
</script>

<style scoped lang="scss">
.wrap{
  width: 95%;
}

// @media screen and (min-height: 596px) {
//   .elTable{
//     width: 100%;
//     height: 550px;
//   }
// }


/* 左侧选择子页面菜单 start */
:deep(.el-card__body){
  padding: 10px 20px;
}
.child-link{
  .alink{
    cursor: pointer;
    color:$color-black-60;
    line-height: 40px;
  }
  .alink-active{
      cursor: pointer;
      font-weight: bold;
      color: $color-blue-60;
  }
  .alink:hover{
      color: $color-blue-60;
  }
}
:deep(.el-card.is-always-shadow){
  box-shadow: none;
}
/* 左侧选择子页面菜单 end */

/* 右侧表格 start */

//录取概率情况筛选
.paneTypes1{
  .panetype{
    cursor: pointer;
    border: 0px 1px 1px 1px solid #ebeef5;
    border-radius: 0 0 5px 5px;
    padding: 5px 15px;
    margin-right: 10px;
    background-color: white;
    color:$color-blue-60;
    transition: all 0.3s;
  }
  .panetype-active{
    background-color: $color-blue-60;
    color:white;
  }
}

.paneTypes{
  margin-top: 15px;
  .panetype{
    cursor: pointer;
    border: 1px solid #ebeef5;
    border-radius: 5px 5px 0 0;
    padding: 5px 15px;
    margin-right: 10px;
    background-color: white;
    color:$color-blue-60;
    transition: all 0.3s;
  }
  .panetype-active{
    background-color: $color-blue-60;
    color:white;
  }
  .nan{
    background-color:rgb(216, 9, 9) !important;
  }
  .chong{
    background-color:orange!important;
  }
  .wen{
    background-color:#5c71fb !important;
  }
  .bao{
    background-color:green !important;
  }
}
//筛选表格
.filterTable{
  border: 1px 1px 0 1px solid #ebeef5;
  border-radius: 5px 5px 5px 0px;
  .filterTitle{
    //筛选表格-标题行
    .filterSchool{
      padding: 0 30px;
      width: 65px;
      line-height: 47px;
      border-radius: 5px 0 0 0;
      background-color: $color-blue-60;
      color:white;
    }
    //搜索框
    .searchSchool{
      float: right;
      margin: 3px 10px 3px 0;
    }
  }
  //筛选表格中心部分
  .filterBody{
    background-color: white;
    border-radius: 0 0 5px 0;
    padding: 15px 15px 0 15px;
    color:$color-black-60;
    border-bottom: 1px solid #ebeef5;
    .tags{
      display: flex;
      flex-direction: row;
      flex-wrap: wrap;
      .tag{
        cursor: pointer;
        margin-bottom: 10px;
        margin-right: 15px;
        color: black;
        font-size: 14px;
        padding:0 7px;
        border-radius: 4px;
        border: 1px solid white;
      }
      .tag-active{
        color:$color-blue-60;
        border: 1px solid $color-blue-60;
        position: relative;
      }
    }
    .clearFilterButton{
      cursor: pointer;
      line-height: 50px;
      color: $color-blue-60;
    }
  }
}

:deep(.cell){
  padding:10px 15px;
}
:deep(.el-table__body){
  .cell{
    min-height: 150px;
    padding: 0;
  }

  .el-table__cell{
    padding: 0;
  }
}
:deep(.el-table){
  thead{
    color:black;
    tr{
    }
    th{
      font-weight: 500;
    }
  }
  th.el-table__cell{
    background-color: #edeff7;
  }
}
.top-align {
  padding: 10px 15px;
  vertical-align: top; /* 设置内容顶部对齐 */
}

//查看其他专业按钮
.showOtherButton{
  cursor: pointer;
  border: 1px solid #409eff;color:#409eff;border-radius:20px;margin: auto auto;padding: 0 5px;line-height: 30px;
}
/* 右侧表格 end */

/* 其他专业弹出层 start */
.showOtherMajorDialogDiv{
  .otherMajorDialogHeader{
    display: flex;
    justify-content: space-between;
    align-items: center;
    .schoolName{
      margin: 0;
      color:$color-blue-60;
      font-weight: 600;
      cursor: pointer;
    }
    .schoolCode{
      color:$color-black-60;
    }
    padding-bottom: 10px;
    border-bottom: 1px solid #ebeef5;
  }
  //地下按钮组
  .otherMajorButtonMenu{
    line-height: 30px;
    border-top: 1px solid #ebeef5;
    padding: 15px 0 0 0;
  }
}

// 切换志愿顺序按钮
.switchVolunteerBtn{
  cursor: pointer;
  min-width: 85px;
  border: 1px solid #f2891b;
  background-color: #f2891b;
  color:white;
  border-radius:20px;
  margin: auto auto;
  padding: 0 5px;
  line-height: 30px;
}

//选择专业按钮
.selectVolunteerBtn{
    cursor: pointer;
    min-width: 85px;
    border: 1px solid #409eff;
    color:#409eff;
    border-radius:20px;
    margin: auto auto;
    padding: 0 5px;
    line-height: 30px;
  }
  .selectVolunteerBtn-active{
    cursor: pointer;
    min-width: 85px;
    border: 1px solid #409eff;
    background-color: #409eff;
    color:white !important;
    border-radius:20px;
    margin: auto auto;
    padding: 0 5px;
    line-height: 30px;
  }

/* 其他专业弹出层 end */



.switchVolunteerItemBtn{
  text-align:center;
  line-height:50px;
  width:100%;
  cursor: pointer;
  border-bottom: 1px solid #eeeeee;
}

.switchVolunteerItemBtn:hover{
  background-color: #a3c9ef;
}

.switchVolunteerItemBtnActive{
  text-align:center;
  line-height:50px;
  width:100%;
  cursor: pointer;
  color:#409eff;
  font-weight: 600;
  border-bottom: 1px solid #eeeeee;
}
</style>
