解决所有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

@@ -74,8 +74,8 @@
<el-form-item label="班号" prop="classNo">
<el-input
v-model="form.classNo"
placeholder="请输入班号"
clearable />
placeholder="自动填充班号"
:disabled="true" />
</el-form-item>
</el-col>
@@ -92,8 +92,8 @@
<el-form-item label="班级规范名称" prop="classProName">
<el-input
v-model="form.classProName"
placeholder="请输入班级规范名称"
clearable />
placeholder="自动拼接班级规范名称"
:disabled="true" />
</el-form-item>
</el-col>
@@ -101,8 +101,8 @@
<el-form-item label="入学年份" prop="grade">
<el-input
v-model="form.grade"
placeholder="请输入入学年份"
clearable />
placeholder="自动填充入学年份"
:disabled="true" />
</el-form-item>
</el-col>
@@ -159,9 +159,9 @@
</template>
<script setup lang="ts" name="BasicClassDialog">
import { ref, reactive, nextTick, onMounted } from 'vue'
import { ref, reactive, nextTick, onMounted, watch, computed } from 'vue'
import { useMessage } from "/@/hooks/message";
import { getObj, addObj, putObj, getMajorNameList, getDeptList } from '/@/api/basic/basicclass'
import { getDetail, addObj, putObj, getMajorNameList, getDeptList } from '/@/api/basic/basicclass'
import { getTeacherBaseList } from '/@/api/professional/professionaluser/teacherbase'
const emit = defineEmits(['refresh']);
@@ -173,6 +173,8 @@ const loading = ref(false)
const majorList = ref<any[]>([])
const deptList = ref<any[]>([])
const teacherList = ref<any[]>([])
const yearLast = ref('') // 年份后两位
const majorName = ref('') // 专业名称
// 提交表单数据
const form = reactive({
@@ -243,6 +245,10 @@ const openDialog = (id?: string) => {
preStuNum: 0,
remark: ''
})
// 重置辅助变量
yearLast.value = ''
majorName.value = ''
// 清除表单验证状态,不触发验证
nextTick(() => {
@@ -269,11 +275,17 @@ const onSubmit = async () => {
try {
loading.value = true;
// 构建提交数据,将班主任工号放到 teacherNo 字段
const submitData = {
...form,
teacherNo: form.teacherNos // 将 teacherNos 的值赋值给 teacherNo
};
if (form.id) {
await putObj(form);
await putObj(submitData);
useMessage().success('编辑成功');
} else {
await addObj(form);
await addObj(submitData);
useMessage().success('新增成功');
}
visible.value = false;
@@ -286,9 +298,10 @@ const onSubmit = async () => {
};
// 获取详情
const getBasicClassData = (id: string) => {
const getBasicClassData = async (id: string) => {
loading.value = true
getObj(id).then((res: any) => {
try {
const res = await getDetail(id)
if (res.data) {
Object.assign(form, {
id: res.data.id || '',
@@ -304,17 +317,29 @@ const getBasicClassData = (id: string) => {
preStuNum: res.data.preStuNum || 0,
remark: res.data.remark || ''
})
// 设置辅助变量(编辑时不自动填充,保持原有数据)
if (res.data.enterDate && res.data.enterDate.length >= 4) {
yearLast.value = res.data.enterDate.substring(2, 4)
}
// 确保专业列表已加载后再设置专业名称
if (res.data.majorCode && majorList.value.length > 0) {
const major = majorList.value.find(item => item.majorCode === res.data.majorCode)
if (major) {
majorName.value = major.majorName || ''
}
}
}
}).catch((err: any) => {
} catch (err: any) {
console.error('获取详情失败', err)
useMessage().error('获取详情失败')
}).finally(() => {
} finally {
loading.value = false
// 数据加载完成后,清除验证状态,避免触发验证
nextTick(() => {
dataFormRef.value?.clearValidate();
});
})
}
}
// 获取专业列表
@@ -356,6 +381,59 @@ const getTeacherListData = async () => {
}
}
// 拼接班级规范名称
const montageClassProName = () => {
// 只在新增模式下自动填充,编辑模式下不覆盖已有数据
if (!form.id && yearLast.value && majorName.value) {
form.classProName = yearLast.value + majorName.value
if (form.classNo) {
form.classProName = yearLast.value + majorName.value + '(' + form.classNo + ')'
}
console.log('classProName', form.classProName)
}
}
// 监听入学日期,取年份后两位
watch(() => form.enterDate, (newVal) => {
if (newVal && newVal.length >= 4) {
console.log('newdate:', newVal)
yearLast.value = newVal.substring(2, 4)
// 只在新增模式下自动填充入学年份
if (!form.id) {
form.grade = newVal.substring(0, 4)
}
montageClassProName()
}
})
// 监听班级代码,取后四位为班号
watch(() => form.classCode, (newVal) => {
if (newVal) {
const length = newVal.length
if (length > 4) {
// 只在新增模式下自动填充班号,编辑模式下如果班号为空才填充
if (!form.id || !form.classNo) {
form.classNo = newVal.substring(length - 4, length)
montageClassProName()
}
}
}
})
// 监听专业代码变化,获取专业名称
watch(() => form.majorCode, (newVal) => {
if (newVal) {
const major = majorList.value.find(item => item.majorCode === newVal)
if (major) {
majorName.value = major.majorName || ''
montageClassProName()
}
} else {
majorName.value = ''
montageClassProName()
}
})
// 初始化
onMounted(() => {
getMajorListData()

View File

@@ -122,27 +122,84 @@
border
:cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle"
row-key="id"
@selection-change="handleSelectionChange"
@sort-change="sortChangeHandle">
<el-table-column type="index" label="序号" align="center" />
<el-table-column prop="deptName" label="学院" show-overflow-tooltip />
<el-table-column prop="classNo" label="班号" show-overflow-tooltip />
<el-table-column prop="classProName" label="班级规范名称" show-overflow-tooltip />
<el-table-column prop="teacherRealName" label="班主任" show-overflow-tooltip />
<el-table-column prop="teacherTel" label="班主任电话号码" show-overflow-tooltip />
<el-table-column label="班级人数/原始人数" show-overflow-tooltip>
<template #default="scope">
{{ scope.row.stuNum || 0 }}/{{ scope.row.preStuNum || 0 }}
<el-table-column type="selection" width="55" align="center" />
<el-table-column type="index" label="序号" align="center">
<template #header>
<el-icon><List /></el-icon>
</template>
</el-table-column>
<el-table-column prop="ruleName" label="门禁规则" show-overflow-tooltip />
<el-table-column prop="classStatus" label="班级状态" show-overflow-tooltip>
<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="classNo" 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="classProName" 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="teacherRealName" 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="teacherTel" label="班主任电话号码" show-overflow-tooltip>
<template #header>
<el-icon><Phone /></el-icon>
<span style="margin-left: 4px">班主任电话</span>
</template>
</el-table-column>
<el-table-column label="班级人数/原始人数" show-overflow-tooltip>
<template #header>
<el-icon><User /></el-icon>
<span style="margin-left: 4px">班级人数/原始人数</span>
</template>
<template #default="scope">
<span>{{ scope.row.classStatus === '0' ? '正常' : scope.row.classStatus === '1' ? '离校' : '-' }}</span>
<el-tag size="small" type="primary" effect="plain">
{{ scope.row.stuNum || 0 }}/{{ scope.row.preStuNum || 0 }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="ruleName" label="门禁规则" show-overflow-tooltip>
<template #header>
<el-icon><Lock /></el-icon>
<span style="margin-left: 4px">门禁规则</span>
</template>
</el-table-column>
<el-table-column prop="classStatus" label="班级状态" show-overflow-tooltip>
<template #header>
<el-icon><CircleCheck /></el-icon>
<span style="margin-left: 4px">班级状态</span>
</template>
<template #default="scope">
<StatusTag
:value="scope.row.classStatus"
:options="[{ label: '正常', value: '0' }, { label: '离校', value: '1' }]"
:type-map="{ '0': { type: 'success', effect: 'light' }, '1': { type: 'warning', effect: 'light' } }"
/>
</template>
</el-table-column>
<el-table-column prop="stuLoseRate" label="流失率" show-overflow-tooltip>
<template #header>
<el-icon><TrendCharts /></el-icon>
<span style="margin-left: 4px">流失率</span>
</template>
<template #default="scope">
<span>{{ scope.row.stuLoseRate ? `${scope.row.stuLoseRate}%` : '-' }}</span>
<el-tag size="small" type="danger" effect="plain">
{{ scope.row.stuLoseRate ? `${scope.row.stuLoseRate}%` : '0%' }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" align="center" fixed="right" width="200">
@@ -193,22 +250,6 @@
draggable
width="600px">
<el-form :model="linkRuleForm" label-width="120px">
<el-form-item label="选择班级">
<el-select
v-model="linkRuleForm.classCodes"
placeholder="请选择班级"
clearable
filterable
multiple
style="width: 100%">
<el-option
v-for="item in classList"
:key="item.classCode"
:label="item.classNo"
:value="item.classCode">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="选择规则">
<el-select
v-model="linkRuleForm.ruleId"
@@ -242,6 +283,9 @@ import { fetchList, delObj, putObjs, classExportData, getDeptList, getClassListB
import { useMessage, useMessageBox } from "/@/hooks/message";
import { fetchList as getRuleList } from "/@/api/stuwork/entrancerule";
import { downBlobFile, adaptationUrl } from "/@/utils/other";
import { List, OfficeBuilding, Grid, Document, UserFilled, Phone, User, Lock, CircleCheck, TrendCharts, Setting } from '@element-plus/icons-vue'
import { defineAsyncComponent as defineStatusTag } from 'vue'
const StatusTag = defineStatusTag(() => import('/@/components/StatusTag/index.vue'))
// 引入组件
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
@@ -258,6 +302,7 @@ const classList = ref<any[]>([])
const ruleList = ref<any[]>([])
const linkRuleDialogVisible = ref(false)
const linkRuleLoading = ref(false)
const selectedClassCodes = ref<string[]>([])
// 搜索表单
const searchForm = reactive({
@@ -272,7 +317,6 @@ const searchForm = reactive({
// 关联门禁规则表单
const linkRuleForm = reactive({
classCodes: [] as string[],
ruleId: ''
})
@@ -296,6 +340,13 @@ const {
tableStyle
} = useTable(state)
// 表格多选
const handleSelectionChange = (rows: any[]) => {
selectedClassCodes.value = (rows || [])
.map((item) => item.classCode)
.filter((item) => !!item)
}
// 学院选择变化
const handleDeptChange = () => {
// 可以根据需要清空班号选择
@@ -352,8 +403,11 @@ const handleViewDetail = (row: any) => {
// 关联门禁规则
const handleLinkRule = () => {
if (!selectedClassCodes.value.length) {
useMessage().warning('请先勾选要关联的班级')
return
}
linkRuleDialogVisible.value = true
linkRuleForm.classCodes = []
linkRuleForm.ruleId = ''
// 加载规则列表
getRuleListData()
@@ -361,12 +415,12 @@ const handleLinkRule = () => {
// 确认关联门禁规则
const confirmLinkRule = async () => {
if (!linkRuleForm.ruleId) {
useMessage().warning('请选择门禁规则')
if (!selectedClassCodes.value.length) {
useMessage().warning('请先勾选要关联的班级')
return
}
if (!linkRuleForm.classCodes || linkRuleForm.classCodes.length === 0) {
useMessage().warning('请选择班级')
if (!linkRuleForm.ruleId) {
useMessage().warning('请选择门禁规则')
return
}
@@ -374,7 +428,7 @@ const confirmLinkRule = async () => {
linkRuleLoading.value = true
await putObjs({
ruleId: linkRuleForm.ruleId,
classCodes: linkRuleForm.classCodes
classCodes: selectedClassCodes.value
})
useMessage().success('关联成功')
linkRuleDialogVisible.value = false
@@ -396,10 +450,9 @@ const handleExport = async () => {
}
}
// 生成考核班级
// 生成考核班级(占位,待确认接口)
const handleGenerateAssessment = () => {
// TODO: 需要确认接口地址
useMessage().warning('生成考核班级功能待实现,请确认接口地址')
useMessage().warning('生成考核班级功能待确认接口后启用')
}
// 获取学院列表

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()

View File

@@ -0,0 +1,246 @@
<template>
<div class="app-container">
<!-- 搜索 -->
<el-card shadow="never" class="mb12">
<el-form :inline="true" :model="searchForm" ref="searchFormRef" label-width="90px">
<el-form-item label="学号" prop="stuNo">
<el-input v-model="searchForm.stuNo" placeholder="请输入学号" clearable />
</el-form-item>
<el-form-item label="姓名" prop="stuName">
<el-input v-model="searchForm.stuName" placeholder="请输入姓名" clearable />
</el-form-item>
<el-form-item label="身份证" prop="idCard">
<el-input v-model="searchForm.idCard" placeholder="请输入身份证" clearable />
</el-form-item>
<el-form-item label="电话" prop="phone">
<el-input v-model="searchForm.phone" placeholder="请输入电话" clearable />
</el-form-item>
<el-form-item label="家长电话" prop="parentPhone">
<el-input v-model="searchForm.parentPhone" placeholder="请输入家长电话" clearable />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleSearch">
<el-icon><Search /></el-icon>
查询
</el-button>
<el-button @click="handleReset">
<el-icon><Refresh /></el-icon>
重置
</el-button>
</el-form-item>
</el-form>
</el-card>
<!-- 表格 -->
<el-card shadow="never">
<el-table
:data="state.dataList"
v-loading="state.loading"
border
:cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle"
@sort-change="sortChangeHandle"
style="width: 100%;">
<el-table-column type="index" label="序号" width="70" 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 width="130">
<template #header>
<el-icon><Document /></el-icon>
<span style="margin-left: 4px;">学号</span>
</template>
</el-table-column>
<el-table-column prop="stuName" 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 width="180">
<template #header>
<el-icon><CreditCard /></el-icon>
<span style="margin-left: 4px;">身份证</span>
</template>
</el-table-column>
<el-table-column prop="phone" label="电话" show-overflow-tooltip width="130">
<template #header>
<el-icon><Phone /></el-icon>
<span style="margin-left: 4px;">电话</span>
</template>
</el-table-column>
<el-table-column prop="parentPhone" label="家长电话" show-overflow-tooltip width="140">
<template #header>
<el-icon><Phone /></el-icon>
<span style="margin-left: 4px;">家长电话</span>
</template>
</el-table-column>
<el-table-column prop="gender" label="性别" width="90" align="center">
<template #header>
<el-icon><User /></el-icon>
<span style="margin-left: 4px;">性别</span>
</template>
<template #default="scope">
<GenderTag :gender="scope.row.gender" />
</template>
</el-table-column>
<el-table-column prop="dormNo" label="宿舍号" show-overflow-tooltip width="120">
<template #header>
<el-icon><HomeFilled /></el-icon>
<span style="margin-left: 4px;">宿舍号</span>
</template>
</el-table-column>
<el-table-column prop="teacherName" 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="teacherPhone" label="班主任电话" show-overflow-tooltip width="140">
<template #header>
<el-icon><Phone /></el-icon>
<span style="margin-left: 4px;">班主任电话</span>
</template>
</el-table-column>
<el-table-column prop="schoolRollStatus" label="学籍状态" show-overflow-tooltip width="110" align="center">
<template #header>
<el-icon><CircleCheck /></el-icon>
<span style="margin-left: 4px;">学籍状态</span>
</template>
<template #default="scope">
<StatusTag :status="scope.row.schoolRollStatus" :options="rollStatusOptions" />
</template>
</el-table-column>
<el-table-column prop="stuStatus" label="学生状态" show-overflow-tooltip width="110" align="center">
<template #header>
<el-icon><Tickets /></el-icon>
<span style="margin-left: 4px;">学生状态</span>
</template>
<template #default="scope">
<StatusTag :status="scope.row.stuStatus" :options="stuStatusOptions" />
</template>
</el-table-column>
<el-table-column prop="avatarUrl" label="头像" width="120" align="center">
<template #header>
<el-icon><Picture /></el-icon>
<span style="margin-left: 4px;">头像</span>
</template>
<template #default="scope">
<el-image
v-if="scope.row.avatarUrl"
:src="scope.row.avatarUrl"
:preview-src-list="[scope.row.avatarUrl]"
fit="cover"
style="width: 60px; height: 60px; border-radius: 6px;" />
<el-tag v-else type="info" effect="plain"></el-tag>
</template>
</el-table-column>
<el-table-column label="操作" width="120" fixed="right" align="center">
<template #header>
<el-icon><Setting /></el-icon>
<span style="margin-left: 4px;">操作</span>
</template>
<template #default>
<span style="color: #999;"></span>
</template>
</el-table-column>
</el-table>
<pagination
v-show="state.total > 0"
:total="state.total"
v-model:page="state.page"
v-model:limit="state.limit"
@pagination="getDataList" />
</el-card>
</div>
</template>
<script setup lang="ts" name="QueryStuindex">
import { ref, reactive } from 'vue'
import { Search, Refresh, List, OfficeBuilding, Grid, Document, UserFilled, CreditCard, Phone, User, HomeFilled, CircleCheck, Tickets, Setting, Picture, Briefcase } from '@element-plus/icons-vue'
import { BasicTableProps, useTable } from '/@/hooks/table'
import { queryStuindex } from '/@/api/basic/basicstudent'
import GenderTag from '/@/components/GenderTag/index.vue'
import StatusTag from '/@/components/StatusTag/index.vue'
// 搜索表单
const searchFormRef = ref()
const searchForm = reactive({
stuNo: '',
stuName: '',
idCard: '',
phone: '',
parentPhone: ''
})
// 状态映射(可根据实际字典调整)
const rollStatusOptions = [
{ value: '0', label: '在籍', type: 'success' },
{ value: '1', label: '离校', type: 'warning' },
{ value: '2', label: '休学', type: 'info' }
]
const stuStatusOptions = [
{ value: '0', label: '正常', type: 'success' },
{ value: '1', label: '预警', type: 'warning' },
{ value: '2', label: '异常', type: 'danger' }
]
// 表格配置
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: searchForm,
pageList: queryStuindex,
props: {
item: 'records',
totalCount: 'total'
},
createdIsNeed: true
})
const {
getDataList,
sortChangeHandle,
tableStyle
} = useTable(state)
const handleSearch = () => {
state.page = 1
getDataList()
}
const handleReset = () => {
searchFormRef.value?.resetFields()
state.page = 1
getDataList()
}
</script>
<style scoped>
.app-container {
padding: 16px;
}
.mb12 {
margin-bottom: 12px;
}
</style>

View File

@@ -46,10 +46,30 @@
:cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle"
@sort-change="sortChangeHandle">
<el-table-column type="index" label="序号" width="60" align="center" />
<el-table-column prop="stuNo" label="学号" show-overflow-tooltip />
<el-table-column prop="realName" label="姓名" show-overflow-tooltip />
<el-table-column prop="className" label="班级" show-overflow-tooltip />
<el-table-column type="index" label="序号" width="60" align="center">
<template #header>
<el-icon><List /></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="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="headImg" label="头像" width="120" align="center">
<template #default="scope">
<el-image
@@ -84,7 +104,7 @@ import { ref, reactive, onMounted } from 'vue'
import { BasicTableProps, useTable } from "/@/hooks/table";
import { fetchList } from "/@/api/basic/basicstudentavatar";
import { getClassListByRole } from "/@/api/basic/basicclass";
import { Picture } from '@element-plus/icons-vue'
import { Picture, List, Document, UserFilled, Grid } from '@element-plus/icons-vue'
// 定义变量内容
const searchFormRef = ref()