解决所有bug 优化table内容

This commit is contained in:
2026-01-21 18:43:39 +08:00
parent 9984200814
commit 7f0280ec8a
80 changed files with 5202 additions and 744 deletions

View File

@@ -215,45 +215,157 @@
@sort-change="sortChangeHandle"
@selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column type="index" label="序号" align="center" />
<el-table-column prop="deptName" label="学院" show-overflow-tooltip />
<el-table-column prop="majorName" label="专业" show-overflow-tooltip />
<el-table-column prop="className" label="班级" show-overflow-tooltip />
<el-table-column prop="stuNo" label="学号" show-overflow-tooltip />
<el-table-column prop="realName" label="姓名" show-overflow-tooltip />
<el-table-column type="index" label="序号" align="center">
<template #header>
<el-icon><List /></el-icon>
<span style="margin-left: 4px;">序号</span>
</template>
</el-table-column>
<el-table-column prop="deptName" label="学院" show-overflow-tooltip>
<template #header>
<el-icon><OfficeBuilding /></el-icon>
<span style="margin-left: 4px;">学院</span>
</template>
</el-table-column>
<el-table-column prop="majorName" label="专业" show-overflow-tooltip>
<template #header>
<el-icon><Briefcase /></el-icon>
<span style="margin-left: 4px;">专业</span>
</template>
</el-table-column>
<el-table-column prop="className" label="班级" show-overflow-tooltip>
<template #header>
<el-icon><Grid /></el-icon>
<span style="margin-left: 4px;">班级</span>
</template>
</el-table-column>
<el-table-column prop="stuNo" label="学号" show-overflow-tooltip>
<template #header>
<el-icon><Document /></el-icon>
<span style="margin-left: 4px;">学号</span>
</template>
</el-table-column>
<el-table-column prop="realName" label="姓名" show-overflow-tooltip>
<template #header>
<el-icon><UserFilled /></el-icon>
<span style="margin-left: 4px;">姓名</span>
</template>
</el-table-column>
<el-table-column prop="gender" label="性别" width="80" align="center">
<template #header>
<el-icon><User /></el-icon>
<span style="margin-left: 4px;">性别</span>
</template>
<template #default="scope">
<span>{{ scope.row.gender === '1' || scope.row.gender === 1 ? '男' : scope.row.gender === '0' || scope.row.gender === 0 ? '女' : '-' }}</span>
<GenderTag :gender="scope.row.gender" />
</template>
</el-table-column>
<el-table-column prop="idCard" label="身份证号" show-overflow-tooltip>
<template #header>
<el-icon><CreditCard /></el-icon>
<span style="margin-left: 4px;">身份证号</span>
</template>
</el-table-column>
<el-table-column prop="teacherNo" label="班主任" show-overflow-tooltip>
<template #header>
<el-icon><UserFilled /></el-icon>
<span style="margin-left: 4px;">班主任</span>
</template>
</el-table-column>
<el-table-column prop="idCard" label="身份证号" show-overflow-tooltip />
<el-table-column prop="teacherNo" label="班主任" show-overflow-tooltip />
<el-table-column prop="isDorm" label="住宿" width="80" align="center">
<template #header>
<el-icon><HomeFilled /></el-icon>
<span style="margin-left: 4px;">住宿</span>
</template>
<template #default="scope">
<span>{{ scope.row.isDorm === 1 || scope.row.isDorm === '1' ? '是' : scope.row.isDorm === 0 || scope.row.isDorm === '0' ? '否' : '-' }}</span>
<el-tag v-if="scope.row.isDorm === 1 || scope.row.isDorm === '1'" size="small" type="success" effect="plain"></el-tag>
<el-tag v-else-if="scope.row.isDorm === 0 || scope.row.isDorm === '0'" size="small" type="info" effect="plain"></el-tag>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column prop="education" label="文化程度" show-overflow-tooltip />
<el-table-column prop="enrollStatus" label="学籍状态" show-overflow-tooltip />
<el-table-column prop="phone" label="个人电话" show-overflow-tooltip />
<el-table-column prop="householdAddress" label="户籍所在地" show-overflow-tooltip />
<el-table-column prop="stuStatus" label="学生状态" show-overflow-tooltip />
<el-table-column prop="isClassLeader" label="是否班干部" width="100" align="center">
<el-table-column prop="education" label="文化程度" show-overflow-tooltip>
<template #header>
<el-icon><School /></el-icon>
<span style="margin-left: 4px;">文化程度</span>
</template>
</el-table-column>
<el-table-column prop="enrollStatus" label="学籍状态" show-overflow-tooltip>
<template #header>
<el-icon><CircleCheck /></el-icon>
<span style="margin-left: 4px;">学籍状态</span>
</template>
<template #default="scope">
<span>{{ scope.row.isClassLeader == 1 || scope.row.isClassLeader === '1' ? '是' : scope.row.isClassLeader == 0 || scope.row.isClassLeader === '0' ? '否' : '-' }}</span>
<el-tag v-if="scope.row.enrollStatus" size="small" type="info" effect="plain">{{ scope.row.enrollStatus }}</el-tag>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column prop="phone" label="个人电话" show-overflow-tooltip>
<template #header>
<el-icon><Phone /></el-icon>
<span style="margin-left: 4px;">个人电话</span>
</template>
</el-table-column>
<el-table-column prop="householdAddress" label="户籍所在地" show-overflow-tooltip>
<template #header>
<el-icon><Location /></el-icon>
<span style="margin-left: 4px;">户籍所在地</span>
</template>
</el-table-column>
<el-table-column prop="stuStatus" label="学生状态" show-overflow-tooltip>
<template #header>
<el-icon><Tickets /></el-icon>
<span style="margin-left: 4px;">学生状态</span>
</template>
<template #default="scope">
<el-tag
v-if="getStuStatusLabel(scope.row.stuStatus)"
size="small"
:type="getStuStatusType(scope.row.stuStatus)"
effect="plain">
{{ getStuStatusLabel(scope.row.stuStatus) }}
</el-tag>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column prop="isClassLeader" label="是否班干部" width="100" align="center">
<template #header>
<el-icon><Medal /></el-icon>
<span style="margin-left: 4px;">是否班干部</span>
</template>
<template #default="scope">
<el-tag v-if="scope.row.isClassLeader == 1 || scope.row.isClassLeader === '1'" size="small" type="success" effect="plain"></el-tag>
<el-tag v-else-if="scope.row.isClassLeader == 0 || scope.row.isClassLeader === '0'" size="small" type="info" effect="plain"></el-tag>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column prop="isInout" label="是否允许进出" width="120" align="center">
<template #header>
<el-icon><Lock /></el-icon>
<span style="margin-left: 4px;">是否允许进出</span>
</template>
<template #default="scope">
<span>{{ scope.row.isInout === 1 || scope.row.isInout === '1' ? '是' : scope.row.isInout === 0 || scope.row.isInout === '0' ? '否' : '-' }}</span>
<el-tag v-if="scope.row.isInout === 1 || scope.row.isInout === '1'" size="small" type="success" effect="plain"></el-tag>
<el-tag v-else-if="scope.row.isInout === 0 || scope.row.isInout === '0'" size="small" type="danger" effect="plain"></el-tag>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column prop="completeRate" label="资料完成度" width="120" align="center">
<template #header>
<el-icon><DataAnalysis /></el-icon>
<span style="margin-left: 4px;">资料完成度</span>
</template>
<template #default="scope">
<span>{{ scope.row.completeRate || '-' }}</span>
<el-tag v-if="scope.row.completeRate !== undefined && scope.row.completeRate !== null" size="small" type="primary" effect="plain">
{{ scope.row.completeRate }}%
</el-tag>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" fixed="right" width="300">
<template #header>
<el-icon><Setting /></el-icon>
<span style="margin-left: 4px;">操作</span>
</template>
<template #default="scope">
<el-button
icon="Edit"
@@ -360,6 +472,7 @@
<script setup lang="ts" name="BasicStudent">
import { ref, reactive, defineAsyncComponent, computed, onMounted } from 'vue'
import { List, OfficeBuilding, Briefcase, Grid, Document, UserFilled, User, CreditCard, HomeFilled, School, CircleCheck, Phone, Location, Tickets, Medal, Lock, DataAnalysis, Setting } from '@element-plus/icons-vue'
import { BasicTableProps, useTable } from "/@/hooks/table";
import { fetchList } from "/@/api/basic/basicstudentinfo";
import {
@@ -379,10 +492,11 @@ import {
prePrint
} from "/@/api/basic/basicstudent";
import { getDeptList, getClassListByRole } from "/@/api/basic/basicclass";
import { queryDictByTypeList } from "/@/api/admin/dict";
import { getDicts } from "/@/api/admin/dict";
import { useMessage, useMessageBox } from "/@/hooks/message";
import { downBlobFile, adaptationUrl } from "/@/utils/other";
import { Session } from "/@/utils/storage";
import GenderTag from '/@/components/GenderTag/index.vue'
// 引入组件
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
@@ -628,67 +742,39 @@ const getStatusListData = async () => {
// 获取学生状态列表
const getStuStatusListData = async () => {
try {
// 先尝试使用批量字典接口
const res = await queryDictByTypeList(['student_status'])
// 尝试多种可能的数据结构
let dictData = null
const res = await getDicts('student_status')
if (res.data) {
// 可能是 res.data.student_status
if (res.data.student_status) {
dictData = res.data.student_status
}
// 可能是 res.data['student_status']
else if (res.data['student_status']) {
dictData = res.data['student_status']
}
// 可能是直接返回数组
else if (Array.isArray(res.data)) {
dictData = res.data
}
// 可能是对象,键为 student_status
else if (typeof res.data === 'object') {
const keys = Object.keys(res.data)
if (keys.length > 0) {
dictData = res.data[keys[0]]
}
}
}
if (dictData && Array.isArray(dictData) && dictData.length > 0) {
const parseDictList = (dictData: any) => {
return dictData.map((item: any) => ({
if (Array.isArray(res.data)) {
// 确保数据格式统一为 {label, value, type}
stuStatusList.value = res.data.map((item: any) => ({
label: item.label || item.name || item.dictLabel || item.text || '',
value: item.value || item.code || item.dictValue || item.id || ''
})).filter((item: any) => item.label && item.value !== undefined && item.value !== null && item.value !== '')
}
stuStatusList.value = parseDictList(dictData)
return
}
} catch (err) {
console.error('批量字典接口获取学生状态失败', err)
}
// 如果批量字典接口失败或返回数据格式不对,使用原来的单个字典接口
try {
const fallbackRes = await getStuStatus()
if (fallbackRes.data) {
if (Array.isArray(fallbackRes.data)) {
// 确保数据格式统一为 {label, value}
stuStatusList.value = fallbackRes.data.map((item: any) => ({
label: item.label || item.name || item.dictLabel || item.text || '',
value: item.value || item.code || item.dictValue || item.id || ''
value: String(item.value || item.code || item.dictValue || item.id || ''),
type: item.type || 'info'
})).filter((item: any) => item.label && item.value !== undefined && item.value !== null && item.value !== '')
} else {
stuStatusList.value = []
}
}
} catch (fallbackErr) {
console.error('获取学生状态列表失败', fallbackErr)
} catch (err) {
console.error('获取学生状态列表失败', err)
stuStatusList.value = []
}
}
// 根据学生状态值获取标签
const getStuStatusLabel = (value: any) => {
if (value === undefined || value === null || value === '') return ''
const status = stuStatusList.value.find(item => String(item.value) === String(value))
return status ? status.label : ''
}
// 根据学生状态值获取标签类型
const getStuStatusType = (value: any) => {
if (value === undefined || value === null || value === '') return 'info'
const status = stuStatusList.value.find(item => String(item.value) === String(value))
return status ? (status.type || 'info') : 'info'
}
// 初始化
onMounted(() => {
getDeptListData()