<template>
  <div class="modern-page-container">
    <div class="page-wrapper">
      <!-- 筛选条件 -->
      <el-card v-show="showSearch" class="search-card" shadow="never">
        <template #header>
          <div class="card-header">
            <span class="card-title">
              <el-icon class="title-icon"><Search /></el-icon>
              筛选条件
            </span>
          </div>
        </template>
        <el-form
          :model="searchForm"
          ref="searchFormRef"
          :inline="true"
          @keyup.enter="handleSearch"
          class="search-form">
          <el-form-item label="毕业年份" prop="graduYear">
            <el-select
              v-model="searchForm.graduYear"
              placeholder="请选择毕业年份"
              clearable
              filterable
              style="width: 140px">
              <el-option
                v-for="y in graduYearOptions"
                :key="y"
                :label="y + '年'"
                :value="y" />
            </el-select>
          </el-form-item>
          <el-form-item label="毕业状态" prop="status">
            <el-select
              v-model="searchForm.status"
              placeholder="请选择"
              clearable
              style="width: 140px">
              <el-option label="待确认" value="0" />
              <el-option label="确认毕业" value="1" />
              <el-option label="不可毕业" value="-1" />
            </el-select>
          </el-form-item>
          <el-form-item label="毕业类型" prop="type">
            <el-select
              v-model="searchForm.type"
              placeholder="请选择"
              clearable
              style="width: 120px">
              <el-option label="段段清" value="1" />
              <el-option label="正常毕业" value="2" />
            </el-select>
          </el-form-item>
          <el-form-item label="学号" prop="stuNo">
            <el-input
              v-model="searchForm.stuNo"
              placeholder="请输入学号"
              clearable
              style="width: 140px" />
          </el-form-item>
          <el-form-item label="姓名" prop="realName">
            <el-input
              v-model="searchForm.realName"
              placeholder="请输入姓名"
              clearable
              style="width: 120px" />
          </el-form-item>
          <el-form-item label="学院" prop="deptCode">
            <el-select
              v-model="searchForm.deptCode"
              placeholder="请选择学院"
              clearable
              filterable
              style="width: 160px">
              <el-option
                v-for="item in deptList"
                :key="item.deptCode"
                :label="item.deptName"
                :value="item.deptCode" />
            </el-select>
          </el-form-item>
          <el-form-item label="班号" prop="classNo">
            <el-input
              v-model="searchForm.classNo"
              placeholder="请输入班号"
              clearable
              style="width: 120px" />
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="Search" @click="handleSearch">查询</el-button>
            <el-button icon="Refresh" @click="handleReset">重置</el-button>
          </el-form-item>
        </el-form>
      </el-card>

      <!-- 内容卡片 -->
      <el-card class="content-card" shadow="never">
        <template #header>
          <div class="card-header">
            <span class="card-title">
              <el-icon class="title-icon"><Document /></el-icon>
              毕业学生名单
            </span>
            <div class="header-actions">
              <el-button type="primary" icon="DataAnalysis" @click="handleConfirmScore">学分确认</el-button>
              <el-button type="info" icon="Finished" plain @click="handleSolidifyScore">固化学分</el-button>
              <el-button type="success" icon="DataAnalysis" @click="handleConfirmConduct">操行确认</el-button>
              <el-button type="primary" icon="Finished" plain @click="handleSolidifyConduct">固化操行考核</el-button>
              <el-button type="warning" icon="DataAnalysis" @click="handleConfirmPunish">违纪确认</el-button>
              <el-button type="info" icon="DataAnalysis" @click="handleConfirmSkill">等级工确认</el-button>
              <right-toolbar
                v-model:showSearch="showSearch"
                class="ml10"
                @queryTable="getDataList">
                <TableColumnControl
                  ref="columnControlRef"
                  :columns="tableColumns"
                  v-model="visibleColumns"
                  trigger-type="default"
                  trigger-circle
                  @change="handleColumnChange"
                  @order-change="handleColumnOrderChange">
                  <template #trigger>
                    <el-tooltip class="item" effect="dark" content="列设置" placement="top">
                      <el-button circle style="margin-left: 0;">
                        <el-icon><Menu /></el-icon>
                      </el-button>
                    </el-tooltip>
                  </template>
                </TableColumnControl>
              </right-toolbar>
            </div>
          </div>
        </template>

        <!-- 表格 -->
        <el-table
          :data="state.dataList"
          v-loading="state.loading"
          stripe
          :cell-style="tableStyle.cellStyle"
          :header-cell-style="tableStyle.headerCellStyle"
          class="modern-table">
          <el-table-column type="index" label="序号" width="70" align="center">
            <template #header>
              <el-icon><List /></el-icon>
            </template>
            <template #default="{ $index }">
              {{ $index + 1 + ((state.pagination?.current || 1) - 1) * (state.pagination?.size || 10) }}
            </template>
          </el-table-column>
          <template v-for="col in visibleColumnsSorted" :key="col.prop || col.label">
            <el-table-column
              v-if="checkColumnVisible(col.prop || '') && col.prop !== '操作'"
              :prop="col.prop"
              :label="col.label"
              :min-width="col.minWidth"
              :width="col.width"
              show-overflow-tooltip
              align="center">
              <template #header>
                <el-icon v-if="col.icon"><component :is="col.icon" /></el-icon>
                <span :style="{ marginLeft: col.icon ? '4px' : '0' }">{{ col.label }}</span>
              </template>
              <template v-if="col.prop === 'status'" #default="scope">
                <el-tag :type="statusTagType(scope.row.status)" size="small">
                  {{ formatStatus(scope.row.status) }}
                </el-tag>
              </template>
              <template v-else-if="col.prop === 'type'" #default="scope">
                {{ scope.row.type === '1' ? '段段清' : scope.row.type === '2' ? '正常毕业' : scope.row.type || '-' }}
              </template>
            </el-table-column>
          </template>
          <!-- 操作列 -->
          <el-table-column label="操作" width="260" align="center" fixed="right">
            <template #header>
              <el-icon><Setting /></el-icon>
              <span style="margin-left: 4px">操作</span>
            </template>
            <template #default="scope">
              <el-dropdown trigger="click">
                <el-button type="primary" link size="small">
                  单项确认<el-icon class="el-icon--right"><ArrowDown /></el-icon>
                </el-button>
                <template #dropdown>
                  <el-dropdown-menu>
                    <el-dropdown-item @click="handleDetailConfirm('score', scope.row)">
                      <el-icon><Document /></el-icon>学分详情
                    </el-dropdown-item>
                    <el-dropdown-item @click="handleDetailConfirm('conduct', scope.row)">
                      <el-icon><UserFilled /></el-icon>操行详情
                    </el-dropdown-item>
                    <el-dropdown-item @click="handleDetailConfirm('punish', scope.row)">
                      <el-icon><Warning /></el-icon>违纪详情
                    </el-dropdown-item>
                    <el-dropdown-item @click="handleDetailConfirm('skill', scope.row)">
                      <el-icon><Medal /></el-icon>等级工详情
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </template>
              </el-dropdown>
            </template>
          </el-table-column>
          <template #empty>
            <el-empty description="暂无数据，请选择条件查询" :image-size="120" />
          </template>
        </el-table>

        <!-- 分页 -->
        <div class="pagination-wrapper">
          <pagination
            @size-change="sizeChangeHandle"
            @current-change="currentChangeHandle"
            v-bind="state.pagination" />
        </div>
      </el-card>
    </div>

    <!-- 确认结果对话框 -->
    <el-dialog
      v-model="confirmDialogVisible"
      :title="confirmTypeLabel"
      width="800px"
      destroy-on-close>
      <div v-loading="confirmLoading">
        <!-- 统计信息 -->
        <el-row :gutter="20" class="confirm-stats">
          <el-col :span="6">
            <el-statistic title="总人数" :value="confirmResult.totalCount || 0">
              <template #suffix>
                <span style="font-size: 12px; color: #909399;">人</span>
              </template>
            </el-statistic>
          </el-col>
          <el-col :span="6">
            <el-statistic title="合格人数" :value="confirmResult.qualifiedCount || 0">
              <template #suffix>
                <span style="font-size: 12px; color: #67c23a;">人</span>
              </template>
            </el-statistic>
          </el-col>
          <el-col :span="6">
            <el-statistic title="不合格人数" :value="confirmResult.unqualifiedCount || 0">
              <template #suffix>
                <span style="font-size: 12px; color: #f56c6c;">人</span>
              </template>
            </el-statistic>
          </el-col>
        </el-row>

        <el-divider content-position="left">不合格学生列表</el-divider>

        <!-- 不合格学生表格 -->
        <el-table
          :data="confirmResult.unqualifiedList || []"
          stripe
          max-height="350px"
          :cell-style="tableStyle.cellStyle"
          :header-cell-style="tableStyle.headerCellStyle">
          <el-table-column type="index" label="序号" width="70" align="center" />
          <el-table-column prop="stuNo" label="学号" align="center" width="120" />
          <el-table-column prop="realName" label="姓名" align="center" width="100" />
          <el-table-column prop="classNo" label="班号" align="center" width="120" />
          <el-table-column prop="reason" label="不合格原因" align="center" min-width="150" />
        </el-table>
      </div>

      <template #footer>
        <el-button @click="confirmDialogVisible = false">关闭</el-button>
      </template>
    </el-dialog>

    <!-- 单个学生确认详情对话框 -->
    <el-dialog
      v-model="detailDialogVisible"
      :title="detailTitle"
      width="700px"
      destroy-on-close>
      <div v-loading="detailLoading">
        <!-- 学生基本信息 -->
        <el-descriptions :column="3" border size="small" class="detail-desc">
          <el-descriptions-item label="学号">{{ detailData.stuNo }}</el-descriptions-item>
          <el-descriptions-item label="姓名">{{ detailData.realName }}</el-descriptions-item>
          <el-descriptions-item label="班号">{{ detailData.classNo }}</el-descriptions-item>
          <el-descriptions-item label="培养层次">{{ detailData.majorLevelName }}</el-descriptions-item>
        </el-descriptions>

        <!-- 学分详情 -->
        <template v-if="detailType === 'score' && detailData.scoreDetail">
          <el-divider content-position="left">学分情况</el-divider>
          <el-descriptions :column="3" border size="small">
            <el-descriptions-item label="是否合格">
              <el-tag :type="detailData.scoreDetail.isQualified ? 'success' : 'danger'" size="small">
                {{ detailData.scoreDetail.isQualified ? '合格' : '不合格' }}
              </el-tag>
            </el-descriptions-item>
            <el-descriptions-item label="已修学分">{{ detailData.scoreDetail.earnedCredit || 0 }} 分</el-descriptions-item>
            <el-descriptions-item label="要求学分">{{ detailData.scoreDetail.requiredCredit || 120 }} 分</el-descriptions-item>
            <el-descriptions-item label="必修学分">{{ detailData.scoreDetail.requiredCourseCredit || 0 }} 分</el-descriptions-item>
            <el-descriptions-item label="选修学分">{{ detailData.scoreDetail.electiveCredit || 0 }} 分</el-descriptions-item>
            <el-descriptions-item label="核心学分">{{ detailData.scoreDetail.coreCredit || 0 }} 分</el-descriptions-item>
          </el-descriptions>
          <el-alert v-if="detailData.scoreDetail.reason" :title="detailData.scoreDetail.reason" type="warning" :closable="false" class="detail-alert" />
        </template>

        <!-- 操行详情 -->
        <template v-if="detailType === 'conduct' && detailData.conductDetail">
          <el-divider content-position="left">操行情况</el-divider>
          <el-descriptions :column="3" border size="small">
            <el-descriptions-item label="是否合格">
              <el-tag :type="detailData.conductDetail.isQualified ? 'success' : 'danger'" size="small">
                {{ detailData.conductDetail.isQualified ? '合格' : '不合格' }}
              </el-tag>
            </el-descriptions-item>
            <el-descriptions-item label="最终得分">{{ detailData.conductDetail.finalScore || 0 }} 分</el-descriptions-item>
            <el-descriptions-item label="基础分">{{ detailData.conductDetail.baseScore || 85 }} 分</el-descriptions-item>
            <el-descriptions-item label="总加分">
              <span style="color: #67c23a">+{{ detailData.conductDetail.totalAddScore || 0 }}</span>
            </el-descriptions-item>
            <el-descriptions-item label="总扣分">
              <span style="color: #f56c6c">-{{ detailData.conductDetail.totalDeductScore || 0 }}</span>
            </el-descriptions-item>
          </el-descriptions>
          <el-alert v-if="detailData.conductDetail.reason" :title="detailData.conductDetail.reason" type="warning" :closable="false" class="detail-alert" />

          <!-- 学期明细 -->
          <template v-if="detailData.conductDetail.termScores && detailData.conductDetail.termScores.length > 0">
            <el-divider content-position="left">学期明细</el-divider>
            <el-table :data="detailData.conductDetail.termScores" size="small" border>
              <el-table-column prop="schoolYear" label="学年" align="center" />
              <el-table-column prop="schoolTerm" label="学期" align="center" />
              <el-table-column prop="score" label="得分" align="center" />
            </el-table>
          </template>
        </template>

        <!-- 违纪详情 -->
        <template v-if="detailType === 'punish' && detailData.punishDetail">
          <el-divider content-position="left">违纪情况</el-divider>
          <el-descriptions :column="1" border size="small">
            <el-descriptions-item label="是否合格">
              <el-tag :type="detailData.punishDetail.isQualified ? 'success' : 'danger'" size="small">
                {{ detailData.punishDetail.isQualified ? '合格' : '不合格' }}
              </el-tag>
            </el-descriptions-item>
          </el-descriptions>
          <el-alert v-if="detailData.punishDetail.reason" :title="detailData.punishDetail.reason" type="warning" :closable="false" class="detail-alert" />

          <!-- 违纪记录 -->
          <template v-if="detailData.punishDetail.punishRecords && detailData.punishDetail.punishRecords.length > 0">
            <el-divider content-position="left">违纪记录</el-divider>
            <el-table :data="detailData.punishDetail.punishRecords" size="small" border>
              <el-table-column prop="punishName" label="处分名称" align="center" />
              <el-table-column prop="punishDate" label="处分日期" align="center" width="120" />
              <el-table-column prop="revokeDate" label="撤销日期" align="center" width="120" />
              <el-table-column label="是否撤销" align="center" width="100">
                <template #default="scope">
                  <el-tag :type="scope.row.isRevoked ? 'success' : 'danger'" size="small">
                    {{ scope.row.isRevoked ? '已撤销' : '未撤销' }}
                  </el-tag>
                </template>
              </el-table-column>
            </el-table>
          </template>
          <el-empty v-else description="无违纪记录" :image-size="60" />
        </template>

        <!-- 等级工详情 -->
        <template v-if="detailType === 'skill' && detailData.skillDetail">
          <el-divider content-position="left">技能等级情况</el-divider>
          <el-descriptions :column="2" border size="small">
            <el-descriptions-item label="是否合格">
              <el-tag :type="detailData.skillDetail.isQualified ? 'success' : 'danger'" size="small">
                {{ detailData.skillDetail.isQualified ? '合格' : '不合格' }}
              </el-tag>
            </el-descriptions-item>
            <el-descriptions-item label="要求等级">{{ detailData.skillDetail.requiredLevelName }}</el-descriptions-item>
            <el-descriptions-item label="实际等级">{{ detailData.skillDetail.actualLevelName || '未获取' }}</el-descriptions-item>
          </el-descriptions>
          <el-alert v-if="detailData.skillDetail.reason" :title="detailData.skillDetail.reason" type="warning" :closable="false" class="detail-alert" />

          <!-- 证书列表 -->
          <template v-if="detailData.skillDetail.certificates && detailData.skillDetail.certificates.length > 0">
            <el-divider content-position="left">证书列表</el-divider>
            <el-table :data="detailData.skillDetail.certificates" size="small" border>
              <el-table-column prop="workType" label="工种" align="center" />
              <el-table-column prop="workLevelName" label="等级" align="center" width="100" />
              <el-table-column prop="cardNo" label="证书编号" align="center" />
              <el-table-column prop="certificateDate" label="发证日期" align="center" width="120" />
            </el-table>
          </template>
          <el-empty v-else description="无技能等级证书" :image-size="60" />
        </template>
      </div>

      <template #footer>
        <el-button @click="detailDialogVisible = false">关闭</el-button>
      </template>
    </el-dialog>
  </div>
</template>

<script setup lang="ts" name="Stugraducheck">
import { reactive, ref, computed, onMounted } from 'vue'
import { useRoute } from 'vue-router'
import { BasicTableProps, useTable } from '/@/hooks/table'
import { fetchList, confirmScore, confirmConduct, confirmPunish, confirmSkill, solidifyConduct, solidifyScore, confirmScoreByStuNo, confirmConductByStuNo, confirmPunishByStuNo, confirmSkillByStuNo } from '/@/api/stuwork/stugraducheck'
import { getDeptList } from '/@/api/basic/basicclass'
import TableColumnControl from '/@/components/TableColumnControl/index.vue'
import {
  List,
  Calendar,
  UserFilled,
  Document,
  Menu,
  Search,
  Grid,
  DataAnalysis,
  Finished,
  Setting,
  ArrowDown,
  Warning,
  Medal
} from '@element-plus/icons-vue'
import { useTableColumnControl } from '/@/hooks/tableColumn'
import { useMessage } from '/@/hooks/message'
import { ElMessageBox } from 'element-plus'

const route = useRoute()
const searchFormRef = ref()
const columnControlRef = ref<any>()
const showSearch = ref(true)
const deptList = ref<any[]>([])

// 确认对话框相关变量
const confirmDialogVisible = ref(false)
const confirmLoading = ref(false)
const confirmResult = ref<any>({
  confirmType: '',
  totalCount: 0,
  qualifiedCount: 0,
  unqualifiedCount: 0,
  unqualifiedList: []
})
const confirmTypeLabel = computed(() => {
  const map: Record<string, string> = {
    score: '学分确认',
    conduct: '操行确认',
    punish: '违纪确认',
    skill: '等级工确认'
  }
  return map[confirmResult.value.confirmType] || '确认结果'
})

// 单个学生详情对话框
const detailDialogVisible = ref(false)
const detailLoading = ref(false)
const detailType = ref('')
const detailData = ref<any>({})
const detailTitle = computed(() => {
  const map: Record<string, string> = {
    score: '学分确认详情',
    conduct: '操行确认详情',
    punish: '违纪确认详情',
    skill: '等级工确认详情'
  }
  return map[detailType.value] || '详情'
})

// 毕业年份：当前年前后各 5 年
const graduYearOptions = computed(() => {
  const y = new Date().getFullYear()
  return Array.from({ length: 11 }, (_, i) => y - 5 + i)
})

// 表格列配置
const tableColumns = [
  { prop: 'stuNo', label: '学号', icon: UserFilled },
  { prop: 'realName', label: '姓名', icon: UserFilled },
  { prop: 'classNo', label: '班号', icon: Grid },
  { prop: 'majorName', label: '专业名称', icon: Document, minWidth: 140 },
  { prop: 'graduYear', label: '毕业年份', icon: Calendar },
  { prop: 'status', label: '毕业状态', icon: Document },
  { prop: 'type', label: '毕业类型', icon: Document },
  { prop: 'scoreCondition', label: '学分情况', icon: Document, minWidth: 100 },
  { prop: 'skillCondition', label: '技能情况', icon: Document, minWidth: 100 },
  { prop: 'conductCondition', label: '操行情况', icon: Document, minWidth: 100 }
]

const {
  visibleColumns,
  visibleColumnsSorted,
  checkColumnVisible,
  handleColumnChange,
  handleColumnOrderChange
} = useTableColumnControl(tableColumns, route.path)

// 搜索表单
const searchForm = reactive({
  graduYear: '',
  status: '',
  type: '',
  stuNo: '',
  realName: '',
  deptCode: '',
  classNo: ''
})

const state: BasicTableProps = reactive<BasicTableProps>({
  queryForm: searchForm,
  pageList: fetchList,
  props: {
    item: 'records',
    totalCount: 'total'
  },
  createdIsNeed: true
})

const {
  getDataList,
  currentChangeHandle,
  sizeChangeHandle,
  tableStyle
} = useTable(state)

const formatStatus = (status: string) => {
  const map: Record<string, string> = { '0': '待确认', '1': '确认毕业', '-1': '不可毕业' }
  return map[status] || status || '-'
}

const statusTagType = (status: string) => {
  const map: Record<string, string> = { '0': 'warning', '1': 'success', '-1': 'danger' }
  return map[status] || 'info'
}

const handleSearch = () => {
  getDataList()
}

const handleReset = () => {
  searchFormRef.value?.resetFields()
  searchForm.graduYear = ''
  searchForm.status = ''
  searchForm.type = ''
  searchForm.stuNo = ''
  searchForm.realName = ''
  searchForm.deptCode = ''
  searchForm.classNo = ''
  getDataList()
}

const loadDeptList = async () => {
  try {
    const res = await getDeptList()
    deptList.value = Array.isArray(res.data) ? res.data : []
  } catch (err) {
    deptList.value = []
  }
}

// 学分确认
const handleConfirmScore = async () => {
  if (!searchForm.graduYear) {
    useMessage().warning('请先选择毕业年份')
    return
  }
  confirmLoading.value = true
  confirmDialogVisible.value = true
  try {
    const res = await confirmScore(searchForm.graduYear)
    if (res.data) {
      confirmResult.value = res.data
    }
  } catch (err: any) {
    useMessage().error(err.msg || '学分确认失败')
  } finally {
    confirmLoading.value = false
  }
}

// 操行确认
const handleConfirmConduct = async () => {
  if (!searchForm.graduYear) {
    useMessage().warning('请先选择毕业年份')
    return
  }
  confirmLoading.value = true
  confirmDialogVisible.value = true
  try {
    const res = await confirmConduct(searchForm.graduYear)
    if (res.data) {
      confirmResult.value = res.data
    }
  } catch (err: any) {
    useMessage().error(err.msg || '操行确认失败')
  } finally {
    confirmLoading.value = false
  }
}

// 违纪确认
const handleConfirmPunish = async () => {
  if (!searchForm.graduYear) {
    useMessage().warning('请先选择毕业年份')
    return
  }
  confirmLoading.value = true
  confirmDialogVisible.value = true
  try {
    const res = await confirmPunish(searchForm.graduYear)
    if (res.data) {
      confirmResult.value = res.data
    }
  } catch (err: any) {
    useMessage().error(err.msg || '违纪确认失败')
  } finally {
    confirmLoading.value = false
  }
}

// 等级工确认
const handleConfirmSkill = async () => {
  if (!searchForm.graduYear) {
    useMessage().warning('请先选择毕业年份')
    return
  }
  confirmLoading.value = true
  confirmDialogVisible.value = true
  try {
    const res = await confirmSkill(searchForm.graduYear)
    if (res.data) {
      confirmResult.value = res.data
    }
  } catch (err: any) {
    useMessage().error(err.msg || '等级工确认失败')
  } finally {
    confirmLoading.value = false
  }
}

// 固化操行考核数据
const solidifyLoading = ref(false)
const handleSolidifyConduct = async () => {
  if (!searchForm.graduYear) {
    useMessage().warning('请先选择毕业年份')
    return
  }
  try {
    await ElMessageBox.confirm(
      `确定要固化 ${searchForm.graduYear} 年毕业学生的操行考核数据吗？`,
      '固化操行考核',
      { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }
    )
    solidifyLoading.value = true
    const res = await solidifyConduct(searchForm.graduYear)
    useMessage().success(res.msg || `成功固化 ${res.data} 名学生的操行考核数据`)
    getDataList()
  } catch (err: any) {
    if (err !== 'cancel') {
      useMessage().error(err.msg || '固化管理失败')
    }
  } finally {
    solidifyLoading.value = false
  }
}

// 固化学分数据
const handleSolidifyScore = async () => {
  if (!searchForm.graduYear) {
    useMessage().warning('请先选择毕业年份')
    return
  }
  try {
    await ElMessageBox.confirm(
      `确定要固化 ${searchForm.graduYear} 年毕业学生的学分数据吗？`,
      '固化学分',
      { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }
    )
    solidifyLoading.value = true
    const res = await solidifyScore(searchForm.graduYear)
    useMessage().success(res.msg || `成功固化 ${res.data} 名学生的学分数据`)
    getDataList()
  } catch (err: any) {
    if (err !== 'cancel') {
      useMessage().error(err.msg || '固化学分失败')
    }
  } finally {
    solidifyLoading.value = false
  }
}

// 单个学生确认详情
const handleDetailConfirm = async (type: string, row: any) => {
  detailType.value = type
  detailDialogVisible.value = true
  detailLoading.value = true
  detailData.value = { stuNo: row.stuNo, realName: row.realName, classNo: row.classNo }

  try {
    let res: any
    switch (type) {
      case 'score':
        res = await confirmScoreByStuNo(row.stuNo, row.graduYear)
        break
      case 'conduct':
        res = await confirmConductByStuNo(row.stuNo, row.graduYear)
        break
      case 'punish':
        res = await confirmPunishByStuNo(row.stuNo, row.graduYear)
        break
      case 'skill':
        res = await confirmSkillByStuNo(row.stuNo, row.graduYear)
        break
    }
    if (res.data) {
      detailData.value = res.data
    }
  } catch (err: any) {
    useMessage().error(err.msg || '查询失败')
  } finally {
    detailLoading.value = false
  }
}

onMounted(() => {
  loadDeptList()
})
</script>

<style scoped lang="scss">
@import '/@/assets/styles/modern-page.scss';

.detail-desc {
  margin-bottom: 16px;
}

.detail-alert {
  margin-top: 16px;
}

.confirm-stats {
  margin-bottom: 20px;
}
</style>