|
|
|
|
@ -11,7 +11,9 @@
|
|
|
|
|
<!-- 页面头部 -->
|
|
|
|
|
<div class="page-header">
|
|
|
|
|
<div class="header-icon">
|
|
|
|
|
<el-icon><User /></el-icon>
|
|
|
|
|
<el-icon>
|
|
|
|
|
<User />
|
|
|
|
|
</el-icon>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="header-content">
|
|
|
|
|
<h1>学生管理</h1>
|
|
|
|
|
@ -23,7 +25,8 @@
|
|
|
|
|
<div class="query-item">
|
|
|
|
|
<span class="query-label">班级:</span>
|
|
|
|
|
<el-select v-model="paramsquery.schoolClassId" placeholder="" style="width: 14rem" clearable>
|
|
|
|
|
<el-option v-for="school in studentClassOptions" :key="school.schoolClassId" :label="school.className" :value="school.schoolClassId" />
|
|
|
|
|
<el-option v-for="school in studentClassOptions" :key="school.schoolClassId"
|
|
|
|
|
:label="school.className" :value="school.schoolClassId" />
|
|
|
|
|
</el-select>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="query-item">
|
|
|
|
|
@ -34,47 +37,54 @@
|
|
|
|
|
<span class="query-label">学生学号:</span>
|
|
|
|
|
<el-input style="width: 14rem" v-model="paramsquery.userName" placeholder="请输入"></el-input>
|
|
|
|
|
<el-button @click="getList" type="primary" class="ml10">
|
|
|
|
|
<el-icon><Search /></el-icon>
|
|
|
|
|
<el-icon>
|
|
|
|
|
<Search />
|
|
|
|
|
</el-icon>
|
|
|
|
|
搜索
|
|
|
|
|
</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="btn-group">
|
|
|
|
|
<el-button type="primary" @click="addschool">
|
|
|
|
|
<el-icon><Plus /></el-icon>
|
|
|
|
|
<el-icon>
|
|
|
|
|
<Plus />
|
|
|
|
|
</el-icon>
|
|
|
|
|
新增
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-upload action="/api/user/importTeacherStudents" :show-file-list="false" :before-upload="beforeImportStudents" :http-request="uploadStudents">
|
|
|
|
|
<el-upload action="/api/user/importTeacherStudents" :show-file-list="false"
|
|
|
|
|
:before-upload="beforeImportStudents" :http-request="uploadStudents">
|
|
|
|
|
<el-button type="primary">
|
|
|
|
|
<el-icon><Upload /></el-icon>
|
|
|
|
|
<el-icon>
|
|
|
|
|
<Upload />
|
|
|
|
|
</el-icon>
|
|
|
|
|
导入
|
|
|
|
|
</el-button>
|
|
|
|
|
</el-upload>
|
|
|
|
|
<el-button type="warning" @click="exportTeacher">
|
|
|
|
|
<el-icon><Download /></el-icon>
|
|
|
|
|
<el-icon>
|
|
|
|
|
<Download />
|
|
|
|
|
</el-icon>
|
|
|
|
|
导出
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button type="warning" @click="downloadTemplate">
|
|
|
|
|
<el-icon><Download /></el-icon>
|
|
|
|
|
<el-icon>
|
|
|
|
|
<Download />
|
|
|
|
|
</el-icon>
|
|
|
|
|
模板下载
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button type="primary" @click="refresh">
|
|
|
|
|
<el-icon><Refresh /></el-icon>
|
|
|
|
|
<el-icon>
|
|
|
|
|
<Refresh />
|
|
|
|
|
</el-icon>
|
|
|
|
|
刷新
|
|
|
|
|
</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<el-table
|
|
|
|
|
:data="tableData"
|
|
|
|
|
border
|
|
|
|
|
v-loading="loading"
|
|
|
|
|
style="width: 100%"
|
|
|
|
|
:header-cell-style="{
|
|
|
|
|
<el-table :data="tableData" border v-loading="loading" style="width: 100%" :header-cell-style="{
|
|
|
|
|
color: '#fff',
|
|
|
|
|
fontSize: '14px',
|
|
|
|
|
fontWeight: '600',
|
|
|
|
|
background: 'linear-gradient(135deg, #0099cc 0%, #006699 100%)',
|
|
|
|
|
}"
|
|
|
|
|
>
|
|
|
|
|
}">
|
|
|
|
|
<el-table-column label="所属班级" prop="className" align="center"></el-table-column>
|
|
|
|
|
<el-table-column label="学生姓名" prop="name" align="center"></el-table-column>
|
|
|
|
|
<el-table-column label="学号" prop="username" align="center"></el-table-column>
|
|
|
|
|
@ -88,51 +98,71 @@
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
<div class="action-group">
|
|
|
|
|
<el-button type="primary" @click="editSchool(row)">
|
|
|
|
|
<el-icon><Edit /></el-icon>
|
|
|
|
|
<el-icon>
|
|
|
|
|
<Edit />
|
|
|
|
|
</el-icon>
|
|
|
|
|
编辑
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button type="danger" @click="delSchool(row)">
|
|
|
|
|
<el-icon><Delete /></el-icon>
|
|
|
|
|
<el-icon>
|
|
|
|
|
<Delete />
|
|
|
|
|
</el-icon>
|
|
|
|
|
删除
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button type="success" @click="initPassword(row, 0)">
|
|
|
|
|
<el-icon><Lock /></el-icon>
|
|
|
|
|
<el-icon>
|
|
|
|
|
<Lock />
|
|
|
|
|
</el-icon>
|
|
|
|
|
密码初始化
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button type="warning" @click="initPassword(row, 1)">
|
|
|
|
|
<el-icon><Refresh /></el-icon>
|
|
|
|
|
<el-icon>
|
|
|
|
|
<Refresh />
|
|
|
|
|
</el-icon>
|
|
|
|
|
数据初始化
|
|
|
|
|
</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
<pagination v-show="schoolTotal > 0" :total="schoolTotal" v-model:page="paramsquery.index" v-model:limit="paramsquery.size" @pagination="getList" />
|
|
|
|
|
<el-dialog v-model="dialogVisible" width="560px" :title="status ? '新增学生' : '编辑学生'" class="teacher-dialog" @close="onClose">
|
|
|
|
|
<el-form :model="formInline" class="demo-form-inline" ref="formInlineref" label-width="100px" style="width: 80%" :rules="studentFormRules">
|
|
|
|
|
<pagination v-show="schoolTotal > 0" :total="schoolTotal" v-model:page="paramsquery.index"
|
|
|
|
|
v-model:limit="paramsquery.size" @pagination="getList" />
|
|
|
|
|
<el-dialog v-model="dialogVisible" width="560px" :title="status ? '新增学生' : '编辑学生'" class="teacher-dialog"
|
|
|
|
|
@close="onClose">
|
|
|
|
|
<el-form :model="formInline" class="demo-form-inline" ref="formInlineref" label-width="100px"
|
|
|
|
|
style="width: 80%" :rules="studentFormRules">
|
|
|
|
|
<template v-if="!isTeacherRosterMode">
|
|
|
|
|
<el-form-item label="所属院系:" prop="schoolFacultyId">
|
|
|
|
|
<el-select v-model="formInline.schoolFacultyId" placeholder="" clearable @change="getMajorList" style="width: 20rem" v-if="status">
|
|
|
|
|
<el-option v-for="school in facultyList" :key="school.schoolId" :label="school.schoolFacultyName" :value="school.schoolFacultyId" />
|
|
|
|
|
<el-select v-model="formInline.schoolFacultyId" placeholder="" clearable @change="getMajorList"
|
|
|
|
|
style="width: 20rem" v-if="status">
|
|
|
|
|
<el-option v-for="school in facultyList" :key="school.schoolId"
|
|
|
|
|
:label="school.schoolFacultyName" :value="school.schoolFacultyId" />
|
|
|
|
|
</el-select>
|
|
|
|
|
<el-input v-else v-model="classInfo.name" style="width: 20rem" disabled></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="所属专业:" prop="schoolMajorId">
|
|
|
|
|
<el-select v-model="formInline.schoolMajorId" placeholder="" clearable style="width: 20rem" v-if="status" @change="getClassByMajor">
|
|
|
|
|
<el-option v-for="major in majorList" :key="major.schoolMajorId" :label="major.schoolMajorName" :value="major.schoolMajorId" />
|
|
|
|
|
<el-select v-model="formInline.schoolMajorId" placeholder="" clearable style="width: 20rem"
|
|
|
|
|
v-if="status" @change="getClassByMajor">
|
|
|
|
|
<el-option v-for="major in majorList" :key="major.schoolMajorId"
|
|
|
|
|
:label="major.schoolMajorName" :value="major.schoolMajorId" />
|
|
|
|
|
</el-select>
|
|
|
|
|
<el-input v-else v-model="classInfo.value" placeholder="请输入所属专业:" style="width: 20rem" disabled></el-input>
|
|
|
|
|
<el-input v-else v-model="classInfo.value" placeholder="请输入所属专业:" style="width: 20rem"
|
|
|
|
|
disabled></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="所属班级:" prop="schoolClassId">
|
|
|
|
|
<el-select v-model="formInline.schoolClassId" placeholder="" clearable style="width: 20rem" v-if="status">
|
|
|
|
|
<el-option v-for="major in classList1" :key="major.schoolClassId" :label="major.className" :value="major.schoolClassId" />
|
|
|
|
|
<el-select v-model="formInline.schoolClassId" placeholder="" clearable style="width: 20rem"
|
|
|
|
|
v-if="status">
|
|
|
|
|
<el-option v-for="major in classList1" :key="major.schoolClassId" :label="major.className"
|
|
|
|
|
:value="major.schoolClassId" />
|
|
|
|
|
</el-select>
|
|
|
|
|
<el-input v-else v-model="classInfo.className" placeholder="请输入所属班级:" style="width: 20rem" disabled></el-input>
|
|
|
|
|
<el-input v-else v-model="classInfo.className" placeholder="请输入所属班级:" style="width: 20rem"
|
|
|
|
|
disabled></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</template>
|
|
|
|
|
<el-form-item v-if="isTeacherRosterMode" label="所属教学班:" prop="teachingClassId">
|
|
|
|
|
<el-select v-model="formInline.teachingClassId" placeholder="请选择教学班" clearable style="width: 20rem">
|
|
|
|
|
<el-option v-for="schoolClass in teachingClassOptions" :key="schoolClass.schoolClassId" :label="schoolClass.className" :value="schoolClass.schoolClassId" />
|
|
|
|
|
<el-option v-for="schoolClass in teachingClassOptions" :key="schoolClass.schoolClassId"
|
|
|
|
|
:label="schoolClass.className" :value="schoolClass.schoolClassId" />
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="学生姓名:" prop="name">
|
|
|
|
|
@ -152,19 +182,19 @@
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script setup>
|
|
|
|
|
import { Search, Plus, Refresh, Edit, Delete, Lock } from "@element-plus/icons-vue";
|
|
|
|
|
import { formatDate } from "@/utils/index";
|
|
|
|
|
import { ElMessageBox } from "element-plus";
|
|
|
|
|
const { proxy } = getCurrentInstance();
|
|
|
|
|
import useUserStore from "@/store/modules/user";
|
|
|
|
|
const userStore = useUserStore();
|
|
|
|
|
const currentUserId = computed(() => userStore.userInfo.userId);
|
|
|
|
|
const currentSchoolId = computed(() => userStore.userInfo.schoolId);
|
|
|
|
|
const isTeacherRosterMode = computed(() => userStore.schoolProductConfig?.studentRosterOwner === "TEACHER");
|
|
|
|
|
const isManagerTeacher = computed(() => userStore.userInfo.teacherAdmin === true);
|
|
|
|
|
import * as indexApi from "@/api/teacher";
|
|
|
|
|
const dialogVisible = ref(false);
|
|
|
|
|
const loading = ref(false);
|
|
|
|
|
import { Search, Plus, Refresh, Edit, Delete, Lock } from "@element-plus/icons-vue"
|
|
|
|
|
import { formatDate } from "@/utils/index"
|
|
|
|
|
import { ElMessageBox } from "element-plus"
|
|
|
|
|
const { proxy } = getCurrentInstance()
|
|
|
|
|
import useUserStore from "@/store/modules/user"
|
|
|
|
|
const userStore = useUserStore()
|
|
|
|
|
const currentUserId = computed(() => userStore.userInfo.userId)
|
|
|
|
|
const currentSchoolId = computed(() => userStore.userInfo.schoolId)
|
|
|
|
|
const isTeacherRosterMode = computed(() => userStore.schoolProductConfig?.studentRosterOwner === "TEACHER")
|
|
|
|
|
const isManagerTeacher = computed(() => userStore.userInfo.teacherAdmin === true)
|
|
|
|
|
import * as indexApi from "@/api/teacher"
|
|
|
|
|
const dialogVisible = ref(false)
|
|
|
|
|
const loading = ref(false)
|
|
|
|
|
const formInline = ref({
|
|
|
|
|
schoolFacultyId: "",
|
|
|
|
|
schoolId: userStore.userInfo.schoolId,
|
|
|
|
|
@ -174,7 +204,7 @@ const formInline = ref({
|
|
|
|
|
teachingClassId: "",
|
|
|
|
|
schoolName: "",
|
|
|
|
|
userName: "",
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
const createEmptyForm = () => ({
|
|
|
|
|
schoolFacultyId: "",
|
|
|
|
|
schoolId: currentSchoolId.value,
|
|
|
|
|
@ -185,189 +215,189 @@ const createEmptyForm = () => ({
|
|
|
|
|
schoolName: "",
|
|
|
|
|
userName: "",
|
|
|
|
|
name: "",
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
const organizationRules = {
|
|
|
|
|
schoolFacultyId: [{ required: true, message: "请选择所属院系", trigger: "change" }],
|
|
|
|
|
schoolMajorId: [{ required: true, message: "请选择所属专业", trigger: "change" }],
|
|
|
|
|
schoolClassId: [{ required: true, message: "请选择所属班级", trigger: "change" }],
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
const studentIdentityRules = {
|
|
|
|
|
name: [{ required: true, message: "请输入学生姓名", trigger: "blur" }],
|
|
|
|
|
userName: [{ required: true, message: "请输入学号", trigger: "blur" }],
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
const teacherRosterRules = {
|
|
|
|
|
...studentIdentityRules,
|
|
|
|
|
teachingClassId: [{ required: true, message: "请选择所属教学班", trigger: "change" }],
|
|
|
|
|
};
|
|
|
|
|
const studentFormRules = computed(() => (isTeacherRosterMode.value ? teacherRosterRules : { ...organizationRules, ...studentIdentityRules }));
|
|
|
|
|
}
|
|
|
|
|
const studentFormRules = computed(() => (isTeacherRosterMode.value ? teacherRosterRules : { ...organizationRules, ...studentIdentityRules }))
|
|
|
|
|
const paramsquery = ref({
|
|
|
|
|
index: 1,
|
|
|
|
|
size: 10,
|
|
|
|
|
schoolId: userStore.userInfo.schoolId,
|
|
|
|
|
});
|
|
|
|
|
const classInfo = ref({});
|
|
|
|
|
const schoolTotal = ref(0);
|
|
|
|
|
})
|
|
|
|
|
const classInfo = ref({})
|
|
|
|
|
const schoolTotal = ref(0)
|
|
|
|
|
function buildStudentImportFormData(file) {
|
|
|
|
|
const formData = new FormData();
|
|
|
|
|
formData.append("file", file);
|
|
|
|
|
formData.append("operatorId", currentUserId.value);
|
|
|
|
|
return formData;
|
|
|
|
|
const formData = new FormData()
|
|
|
|
|
formData.append("file", file)
|
|
|
|
|
formData.append("operatorId", currentUserId.value)
|
|
|
|
|
return formData
|
|
|
|
|
}
|
|
|
|
|
// 新增编辑状态
|
|
|
|
|
const status = ref(false);
|
|
|
|
|
const status = ref(false)
|
|
|
|
|
// 院校list
|
|
|
|
|
const tableData = ref([]);
|
|
|
|
|
const tableData = ref([])
|
|
|
|
|
// 获取院校列表
|
|
|
|
|
const getList = () => {
|
|
|
|
|
indexApi.getStudentList({ ...paramsquery.value, operatorId: currentUserId.value }).then((res) => {
|
|
|
|
|
tableData.value = res.data.list;
|
|
|
|
|
schoolTotal.value = res.data.total;
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
tableData.value = res.data.list
|
|
|
|
|
schoolTotal.value = res.data.total
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// 删除院校
|
|
|
|
|
const delSchool = (id) => {
|
|
|
|
|
indexApi.deleteStudent({ userId: id.userId, operatorId: currentUserId.value, teachingClassId: resolveRowTeachingClassId(id) }).then((res) => {
|
|
|
|
|
proxy.$message.success("删除成功");
|
|
|
|
|
getList();
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
proxy.$message.success("删除成功")
|
|
|
|
|
getList()
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// 新增院校
|
|
|
|
|
const addschool = () => {
|
|
|
|
|
formInline.value = createEmptyForm();
|
|
|
|
|
classInfo.value = {};
|
|
|
|
|
classList1.value = [];
|
|
|
|
|
dialogVisible.value = true;
|
|
|
|
|
status.value = true;
|
|
|
|
|
};
|
|
|
|
|
formInline.value = createEmptyForm()
|
|
|
|
|
classInfo.value = {}
|
|
|
|
|
classList1.value = []
|
|
|
|
|
dialogVisible.value = true
|
|
|
|
|
status.value = true
|
|
|
|
|
}
|
|
|
|
|
const editSchool = (row) => {
|
|
|
|
|
console.log(row);
|
|
|
|
|
let data = { ...row };
|
|
|
|
|
formInline.value = data;
|
|
|
|
|
formInline.value.userName = row.username;
|
|
|
|
|
formInline.value.teachingClassId = isTeacherRosterMode.value ? row.teachingClassId || currentTeachingClassId() : "";
|
|
|
|
|
console.log(row)
|
|
|
|
|
let data = { ...row }
|
|
|
|
|
formInline.value = data
|
|
|
|
|
formInline.value.userName = row.username
|
|
|
|
|
formInline.value.teachingClassId = isTeacherRosterMode.value ? row.teachingClassId || currentTeachingClassId() : ""
|
|
|
|
|
classInfo.value = {
|
|
|
|
|
className: row.className || row.schoolClassName || "",
|
|
|
|
|
};
|
|
|
|
|
dialogVisible.value = true;
|
|
|
|
|
status.value = false;
|
|
|
|
|
}
|
|
|
|
|
dialogVisible.value = true
|
|
|
|
|
status.value = false
|
|
|
|
|
if (!isTeacherRosterMode.value && row.schoolMajorId) {
|
|
|
|
|
indexApi.getFacultyAndMajorName({ schoolMajorId: row.schoolMajorId }).then((res) => {
|
|
|
|
|
classInfo.value.name = Object.keys(res.data)[0];
|
|
|
|
|
classInfo.value.value = Object.values(res.data)[0];
|
|
|
|
|
});
|
|
|
|
|
classInfo.value.name = Object.keys(res.data)[0]
|
|
|
|
|
classInfo.value.value = Object.values(res.data)[0]
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
const add = () => {
|
|
|
|
|
formInline.value.schoolId = currentSchoolId.value;
|
|
|
|
|
formInline.value.operatorId = currentUserId.value;
|
|
|
|
|
formInline.value.schoolId = currentSchoolId.value
|
|
|
|
|
formInline.value.operatorId = currentUserId.value
|
|
|
|
|
if (isTeacherRosterMode.value) {
|
|
|
|
|
indexApi.addTeacherRosterStudent(formInline.value).then((res) => {
|
|
|
|
|
proxy.$message.success("添加成功");
|
|
|
|
|
dialogVisible.value = false;
|
|
|
|
|
getList();
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
formInline.value.schoolMajorName = majorList.value?.filter((item) => item.schoolMajorId == formInline.value.schoolMajorId)[0].schoolMajorName;
|
|
|
|
|
formInline.value.schoolClassName = classList1.value?.filter((item) => item.schoolClassId == formInline.value.schoolClassId)[0].className;
|
|
|
|
|
formInline.value.userId = currentUserId.value;
|
|
|
|
|
proxy.$message.success("添加成功")
|
|
|
|
|
dialogVisible.value = false
|
|
|
|
|
getList()
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
formInline.value.schoolMajorName = majorList.value?.filter((item) => item.schoolMajorId == formInline.value.schoolMajorId)[0].schoolMajorName
|
|
|
|
|
formInline.value.schoolClassName = classList1.value?.filter((item) => item.schoolClassId == formInline.value.schoolClassId)[0].className
|
|
|
|
|
formInline.value.userId = currentUserId.value
|
|
|
|
|
indexApi.addStudent(formInline.value).then((res) => {
|
|
|
|
|
proxy.$message.success("添加成功");
|
|
|
|
|
dialogVisible.value = false;
|
|
|
|
|
getList();
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
proxy.$message.success("添加成功")
|
|
|
|
|
dialogVisible.value = false
|
|
|
|
|
getList()
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
const edit = () => {
|
|
|
|
|
formInline.value.status = true;
|
|
|
|
|
formInline.value.operatorId = currentUserId.value;
|
|
|
|
|
formInline.value.status = true
|
|
|
|
|
formInline.value.operatorId = currentUserId.value
|
|
|
|
|
if (isTeacherRosterMode.value) {
|
|
|
|
|
indexApi.updateTeacherRosterStudent(formInline.value).then((res) => {
|
|
|
|
|
proxy.$message.success("编辑成功");
|
|
|
|
|
dialogVisible.value = false;
|
|
|
|
|
getList();
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
proxy.$message.success("编辑成功")
|
|
|
|
|
dialogVisible.value = false
|
|
|
|
|
getList()
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
formInline.value.teachingClassId = currentTeachingClassId();
|
|
|
|
|
formInline.value.teachingClassId = currentTeachingClassId()
|
|
|
|
|
indexApi.updateStudent(formInline.value).then((res) => {
|
|
|
|
|
proxy.$message.success("编辑成功");
|
|
|
|
|
dialogVisible.value = false;
|
|
|
|
|
getList();
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
proxy.$message.success("编辑成功")
|
|
|
|
|
dialogVisible.value = false
|
|
|
|
|
getList()
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// 提交
|
|
|
|
|
const submitForm = () => {
|
|
|
|
|
proxy.$refs.formInlineref.validate((valid) => {
|
|
|
|
|
if (valid) {
|
|
|
|
|
status.value ? add() : edit();
|
|
|
|
|
status.value ? add() : edit()
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
const onClose = () => {
|
|
|
|
|
formInline.value = createEmptyForm();
|
|
|
|
|
classInfo.value = {};
|
|
|
|
|
classList1.value = [];
|
|
|
|
|
dialogVisible.value = false;
|
|
|
|
|
};
|
|
|
|
|
formInline.value = createEmptyForm()
|
|
|
|
|
classInfo.value = {}
|
|
|
|
|
classList1.value = []
|
|
|
|
|
dialogVisible.value = false
|
|
|
|
|
}
|
|
|
|
|
// 刷新
|
|
|
|
|
const refresh = () => {
|
|
|
|
|
loading.value = true;
|
|
|
|
|
loading.value = true
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
loading.value = false;
|
|
|
|
|
getList();
|
|
|
|
|
}, 2000);
|
|
|
|
|
};
|
|
|
|
|
loading.value = false
|
|
|
|
|
getList()
|
|
|
|
|
}, 2000)
|
|
|
|
|
}
|
|
|
|
|
// 查询院系下拉列表
|
|
|
|
|
const facultyList = ref([]);
|
|
|
|
|
const facultyList = ref([])
|
|
|
|
|
const getFacultyList = () => {
|
|
|
|
|
indexApi.seleteSchoolFacultyList({ schoolId: userStore.userInfo.schoolId }).then((res) => {
|
|
|
|
|
facultyList.value = res.data;
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
facultyList.value = res.data
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// 专业下拉框
|
|
|
|
|
const majorList = ref([]);
|
|
|
|
|
const majorList = ref([])
|
|
|
|
|
const getMajorList = () => {
|
|
|
|
|
if (!formInline.value.schoolFacultyId) return;
|
|
|
|
|
paramsquery.value.schoolMajorId = "";
|
|
|
|
|
if (!formInline.value.schoolFacultyId) return
|
|
|
|
|
paramsquery.value.schoolMajorId = ""
|
|
|
|
|
indexApi.getMajorListBySchoolId({ schoolFacultyId: formInline.value.schoolFacultyId }).then((res) => {
|
|
|
|
|
majorList.value = res.data;
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
majorList.value = res.data
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
const uploadStudents = (options) => {
|
|
|
|
|
if (isTeacherRosterMode.value) {
|
|
|
|
|
const formData = new FormData();
|
|
|
|
|
formData.append("file", options.file);
|
|
|
|
|
const formData = new FormData()
|
|
|
|
|
formData.append("file", options.file)
|
|
|
|
|
return indexApi.importTeacherRosterStudents(formData).then((res) => {
|
|
|
|
|
handleSuccess(res);
|
|
|
|
|
});
|
|
|
|
|
handleSuccess(res)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
const formData = buildStudentImportFormData(options.file);
|
|
|
|
|
const formData = buildStudentImportFormData(options.file)
|
|
|
|
|
return indexApi.importTeacherStudents(formData).then((res) => {
|
|
|
|
|
handleSuccess(res);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
handleSuccess(res)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
const handleSuccess = (res, file) => {
|
|
|
|
|
if (res?.statusCode && res.statusCode !== "OK" && res.statusCode !== 200) {
|
|
|
|
|
proxy.$message.error(res?.message || "导入失败");
|
|
|
|
|
return;
|
|
|
|
|
proxy.$message.error(res?.message || "导入失败")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
getList();
|
|
|
|
|
proxy.$modal.msgSuccess("导入成功");
|
|
|
|
|
};
|
|
|
|
|
getList()
|
|
|
|
|
proxy.$modal.msgSuccess("导入成功")
|
|
|
|
|
}
|
|
|
|
|
// 导出教师账号
|
|
|
|
|
const exportTeacher = () => {
|
|
|
|
|
indexApi.exportStudentList({ schoolId: userStore.userInfo.schoolId, operatorId: currentUserId.value, schoolClassId: currentTeachingClassId() }).then((res) => {
|
|
|
|
|
const blob = new Blob([res], { type: "application/vnd.ms-excel" });
|
|
|
|
|
const url = URL.createObjectURL(blob);
|
|
|
|
|
const link = document.createElement("a");
|
|
|
|
|
link.href = url;
|
|
|
|
|
link.setAttribute("download", "学生信息表格.xlsx");
|
|
|
|
|
link.click();
|
|
|
|
|
URL.revokeObjectURL(url);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
const blob = new Blob([res], { type: "application/vnd.ms-excel" })
|
|
|
|
|
const url = URL.createObjectURL(blob)
|
|
|
|
|
const link = document.createElement("a")
|
|
|
|
|
link.href = url
|
|
|
|
|
link.setAttribute("download", "学生信息表格.xlsx")
|
|
|
|
|
link.click()
|
|
|
|
|
URL.revokeObjectURL(url)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// 导入模版下载
|
|
|
|
|
const buildOwnedAdminClassRows = async () => {
|
|
|
|
|
const majorGroups = await Promise.all(
|
|
|
|
|
@ -377,90 +407,90 @@ const buildOwnedAdminClassRows = async () => {
|
|
|
|
|
.then((res) => (res.data || []).map((major) => ({ ...major, schoolFacultyName: faculty.schoolFacultyName })))
|
|
|
|
|
.catch(() => []),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
const allMajors = majorGroups.flat();
|
|
|
|
|
)
|
|
|
|
|
const allMajors = majorGroups.flat()
|
|
|
|
|
return classList.value
|
|
|
|
|
.filter((item) => canUseAdminClassForStudent(item))
|
|
|
|
|
.map((item) => {
|
|
|
|
|
const major = allMajors.find((majorItem) => majorItem.schoolMajorId === item.schoolMajorId) || majorList.value.find((majorItem) => majorItem.schoolMajorId === item.schoolMajorId);
|
|
|
|
|
const faculty = facultyList.value.find((facultyItem) => facultyItem.schoolFacultyId === (major?.schoolFacultyId || item.schoolFacultyId));
|
|
|
|
|
return [faculty?.schoolFacultyName || item.schoolFacultyName || "", major?.schoolMajorName || item.schoolMajorName || "", item.className || ""];
|
|
|
|
|
const major = allMajors.find((majorItem) => majorItem.schoolMajorId === item.schoolMajorId) || majorList.value.find((majorItem) => majorItem.schoolMajorId === item.schoolMajorId)
|
|
|
|
|
const faculty = facultyList.value.find((facultyItem) => facultyItem.schoolFacultyId === (major?.schoolFacultyId || item.schoolFacultyId))
|
|
|
|
|
return [faculty?.schoolFacultyName || item.schoolFacultyName || "", major?.schoolMajorName || item.schoolMajorName || "", item.className || ""]
|
|
|
|
|
})
|
|
|
|
|
.filter((row) => row.every(Boolean));
|
|
|
|
|
};
|
|
|
|
|
.filter((row) => row.every(Boolean))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const downloadTemplate = async () => {
|
|
|
|
|
const XLSX = await import("xlsx");
|
|
|
|
|
const XLSX = await import("xlsx")
|
|
|
|
|
if (isTeacherRosterMode.value) {
|
|
|
|
|
const exampleClassName = teachingClassOptions.value[0]?.className || "教学一班";
|
|
|
|
|
const exampleClassName = teachingClassOptions.value[0]?.className || "教学一班"
|
|
|
|
|
const templateSheet = XLSX.utils.aoa_to_sheet([
|
|
|
|
|
["学生姓名", "学号", "班级"],
|
|
|
|
|
["张三", "20260001", exampleClassName],
|
|
|
|
|
]);
|
|
|
|
|
templateSheet["!cols"] = [{ wch: 16 }, { wch: 18 }, { wch: 20 }];
|
|
|
|
|
const workbook = XLSX.utils.book_new();
|
|
|
|
|
XLSX.utils.book_append_sheet(workbook, templateSheet, "学生导入模板");
|
|
|
|
|
XLSX.writeFile(workbook, "学生账号导入模板.xlsx");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const adminClassRows = await buildOwnedAdminClassRows();
|
|
|
|
|
const firstAdminClass = adminClassRows[0] || ["电子商务学院", "电子商务", "行政一班"];
|
|
|
|
|
])
|
|
|
|
|
templateSheet["!cols"] = [{ wch: 16 }, { wch: 18 }, { wch: 20 }]
|
|
|
|
|
const workbook = XLSX.utils.book_new()
|
|
|
|
|
XLSX.utils.book_append_sheet(workbook, templateSheet, "学生导入模板")
|
|
|
|
|
XLSX.writeFile(workbook, "学生账号导入模板.xlsx")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
const adminClassRows = await buildOwnedAdminClassRows()
|
|
|
|
|
const firstAdminClass = adminClassRows[0] || ["电子商务学院", "电子商务", "行政一班"]
|
|
|
|
|
const templateSheet = XLSX.utils.aoa_to_sheet([
|
|
|
|
|
["姓名", "学号", "性别", "所属院系", "所属专业", "所属班级"],
|
|
|
|
|
["张三", "20260001", "男", firstAdminClass[0], firstAdminClass[1], firstAdminClass[2]],
|
|
|
|
|
]);
|
|
|
|
|
templateSheet["!cols"] = [{ wch: 14 }, { wch: 18 }, { wch: 10 }, { wch: 24 }, { wch: 24 }, { wch: 20 }];
|
|
|
|
|
const dataRows = adminClassRows.length ? adminClassRows : [["暂无可导入行政班", "请先维护专业", "请先创建行政班"]];
|
|
|
|
|
const dataSheet = XLSX.utils.aoa_to_sheet([["所属院系", "所属专业", "所属班级"], ...dataRows]);
|
|
|
|
|
dataSheet["!cols"] = [{ wch: 28 }, { wch: 28 }, { wch: 24 }];
|
|
|
|
|
const guideSheet = XLSX.utils.aoa_to_sheet([["填写说明"], ["1. 本模板用于学生账号导入,不要填写任何数据ID。"], ["2. 所属院系、所属专业、所属班级请使用基础数据页中的名称。"], ["3. 只能导入本校行政班,不能导入教学班或其他学校的班级。"], ["4. 性别可填写男、女,也可留空。"], ["5. 任意一行校验失败时,整批导入失败并返回失败原因。"]]);
|
|
|
|
|
guideSheet["!cols"] = [{ wch: 76 }];
|
|
|
|
|
const workbook = XLSX.utils.book_new();
|
|
|
|
|
XLSX.utils.book_append_sheet(workbook, templateSheet, "学生导入模板");
|
|
|
|
|
XLSX.utils.book_append_sheet(workbook, dataSheet, "基础数据");
|
|
|
|
|
XLSX.utils.book_append_sheet(workbook, guideSheet, "填写说明");
|
|
|
|
|
XLSX.writeFile(workbook, "学生账号导入模板.xlsx");
|
|
|
|
|
};
|
|
|
|
|
])
|
|
|
|
|
templateSheet["!cols"] = [{ wch: 14 }, { wch: 18 }, { wch: 10 }, { wch: 24 }, { wch: 24 }, { wch: 20 }]
|
|
|
|
|
const dataRows = adminClassRows.length ? adminClassRows : [["暂无可导入行政班", "请先维护专业", "请先创建行政班"]]
|
|
|
|
|
const dataSheet = XLSX.utils.aoa_to_sheet([["所属院系", "所属专业", "所属班级"], ...dataRows])
|
|
|
|
|
dataSheet["!cols"] = [{ wch: 28 }, { wch: 28 }, { wch: 24 }]
|
|
|
|
|
const guideSheet = XLSX.utils.aoa_to_sheet([["填写说明"], ["1. 本模板用于学生账号导入,不要填写任何数据ID。"], ["2. 所属院系、所属专业、所属班级请使用基础数据页中的名称。"], ["3. 只能导入本校行政班,不能导入教学班或其他学校的班级。"], ["4. 性别可填写男、女,也可留空。"], ["5. 任意一行校验失败时,整批导入失败并返回失败原因。"]])
|
|
|
|
|
guideSheet["!cols"] = [{ wch: 76 }]
|
|
|
|
|
const workbook = XLSX.utils.book_new()
|
|
|
|
|
XLSX.utils.book_append_sheet(workbook, templateSheet, "学生导入模板")
|
|
|
|
|
XLSX.utils.book_append_sheet(workbook, dataSheet, "基础数据")
|
|
|
|
|
XLSX.utils.book_append_sheet(workbook, guideSheet, "填写说明")
|
|
|
|
|
XLSX.writeFile(workbook, "学生账号导入模板.xlsx")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const classList = ref([]);
|
|
|
|
|
const classList = ref([])
|
|
|
|
|
const normalizeClassType = (schoolClass) => {
|
|
|
|
|
if (schoolClass?.classType) return schoolClass.classType;
|
|
|
|
|
return schoolClass?.createdBy ? "TEACHING" : "ADMIN";
|
|
|
|
|
};
|
|
|
|
|
const sameValue = (left, right) => String(left || "") === String(right || "");
|
|
|
|
|
if (schoolClass?.classType) return schoolClass.classType
|
|
|
|
|
return schoolClass?.createdBy ? "TEACHING" : "ADMIN"
|
|
|
|
|
}
|
|
|
|
|
const sameValue = (left, right) => String(left || "") === String(right || "")
|
|
|
|
|
const canUseAdminClassForStudent = (schoolClass) => {
|
|
|
|
|
if (normalizeClassType(schoolClass) !== "ADMIN") return false;
|
|
|
|
|
return !schoolClass?.schoolId || sameValue(schoolClass.schoolId, currentSchoolId.value);
|
|
|
|
|
};
|
|
|
|
|
const classMap = computed(() => new Map(classList.value.map((item) => [item.schoolClassId, item])));
|
|
|
|
|
const teachingClassOptions = computed(() => classList.value.filter((schoolClass) => normalizeClassType(schoolClass) === "TEACHING" && sameValue(schoolClass.schoolId, currentSchoolId.value) && (isManagerTeacher.value || sameValue(schoolClass.createdBy, currentUserId.value))));
|
|
|
|
|
const studentClassOptions = computed(() => teachingClassOptions.value);
|
|
|
|
|
if (normalizeClassType(schoolClass) !== "ADMIN") return false
|
|
|
|
|
return !schoolClass?.schoolId || sameValue(schoolClass.schoolId, currentSchoolId.value)
|
|
|
|
|
}
|
|
|
|
|
const classMap = computed(() => new Map(classList.value.map((item) => [item.schoolClassId, item])))
|
|
|
|
|
const teachingClassOptions = computed(() => classList.value.filter((schoolClass) => normalizeClassType(schoolClass) === "TEACHING" && sameValue(schoolClass.schoolId, currentSchoolId.value) && (isManagerTeacher.value || sameValue(schoolClass.createdBy, currentUserId.value))))
|
|
|
|
|
const studentClassOptions = computed(() => teachingClassOptions.value)
|
|
|
|
|
const currentTeachingClassId = () => {
|
|
|
|
|
const selectedClass = classMap.value.get(paramsquery.value.schoolClassId);
|
|
|
|
|
return selectedClass && normalizeClassType(selectedClass) === "TEACHING" ? selectedClass.schoolClassId : "";
|
|
|
|
|
};
|
|
|
|
|
const resolveRowTeachingClassId = (row) => currentTeachingClassId() || row?.teachingClassId || "";
|
|
|
|
|
const selectedClass = classMap.value.get(paramsquery.value.schoolClassId)
|
|
|
|
|
return selectedClass && normalizeClassType(selectedClass) === "TEACHING" ? selectedClass.schoolClassId : ""
|
|
|
|
|
}
|
|
|
|
|
const resolveRowTeachingClassId = (row) => currentTeachingClassId() || row?.teachingClassId || ""
|
|
|
|
|
const beforeImportStudents = (file) => {
|
|
|
|
|
if (!/\.(xls|xlsx)$/i.test(file.name)) {
|
|
|
|
|
proxy.$message.warning("请选择xls或xlsx格式文件");
|
|
|
|
|
return false;
|
|
|
|
|
proxy.$message.warning("请选择xls或xlsx格式文件")
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
const getClassList = () => {
|
|
|
|
|
indexApi.getClassListBySchoolId({ schoolId: userStore.userInfo.schoolId }).then((res) => {
|
|
|
|
|
classList.value = res.data;
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
const classList1 = ref([]);
|
|
|
|
|
classList.value = res.data
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
const classList1 = ref([])
|
|
|
|
|
// 根据专业查班级
|
|
|
|
|
const getClassByMajor = () => {
|
|
|
|
|
if (!formInline.value.schoolMajorId) return;
|
|
|
|
|
formInline.value.schoolClassId = "";
|
|
|
|
|
if (!formInline.value.schoolMajorId) return
|
|
|
|
|
formInline.value.schoolClassId = ""
|
|
|
|
|
indexApi.getClassListByMajorId({ schoolMajorId: formInline.value.schoolMajorId }).then((res) => {
|
|
|
|
|
classList1.value = (res.data || []).filter((item) => canUseAdminClassForStudent(item));
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
classList1.value = (res.data || []).filter((item) => canUseAdminClassForStudent(item))
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
//初始化密码
|
|
|
|
|
const initPassword = (row, status) => {
|
|
|
|
|
if (status == 0) {
|
|
|
|
|
@ -471,11 +501,11 @@ const initPassword = (row, status) => {
|
|
|
|
|
})
|
|
|
|
|
.then(() => {
|
|
|
|
|
indexApi.initStudentPassword({ userId: row.userId, operatorId: currentUserId.value, teachingClassId: resolveRowTeachingClassId(row) }).then((res) => {
|
|
|
|
|
proxy.$message.success("密码初始化成功");
|
|
|
|
|
getList();
|
|
|
|
|
});
|
|
|
|
|
proxy.$message.success("密码初始化成功")
|
|
|
|
|
getList()
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {});
|
|
|
|
|
.catch(() => { })
|
|
|
|
|
} else {
|
|
|
|
|
ElMessageBox.confirm("确定初始化当前学生数据吗?", "提示", {
|
|
|
|
|
confirmButtonText: "确定",
|
|
|
|
|
@ -483,10 +513,10 @@ const initPassword = (row, status) => {
|
|
|
|
|
type: "warning",
|
|
|
|
|
})
|
|
|
|
|
.then(() => {
|
|
|
|
|
const teachingClassId = resolveRowTeachingClassId(row);
|
|
|
|
|
const teachingClassId = resolveRowTeachingClassId(row)
|
|
|
|
|
if (!teachingClassId) {
|
|
|
|
|
proxy.$message.warning("请先选择教学班");
|
|
|
|
|
return;
|
|
|
|
|
proxy.$message.warning("请先选择教学班")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
indexApi
|
|
|
|
|
.initializeTeachingClassStudentTrainingData({
|
|
|
|
|
@ -495,25 +525,24 @@ const initPassword = (row, status) => {
|
|
|
|
|
operatorId: currentUserId.value,
|
|
|
|
|
})
|
|
|
|
|
.then((res) => {
|
|
|
|
|
proxy.$message.success("初始化成功");
|
|
|
|
|
getList();
|
|
|
|
|
});
|
|
|
|
|
proxy.$message.success("初始化成功")
|
|
|
|
|
getList()
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {});
|
|
|
|
|
.catch(() => { })
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
await userStore.ensureSchoolProductConfig().catch(() => null);
|
|
|
|
|
getList();
|
|
|
|
|
getClassList();
|
|
|
|
|
await userStore.ensureSchoolProductConfig().catch(() => null)
|
|
|
|
|
getList()
|
|
|
|
|
getClassList()
|
|
|
|
|
if (!isTeacherRosterMode.value) {
|
|
|
|
|
getFacultyList();
|
|
|
|
|
getFacultyList()
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.student-page {
|
|
|
|
|
padding: 20px;
|
|
|
|
|
min-height: calc(100vh - 70px);
|
|
|
|
|
|
|
|
|
|
// 页面头部卡片
|
|
|
|
|
@ -552,6 +581,7 @@ onMounted(async () => {
|
|
|
|
|
letter-spacing: 2px;
|
|
|
|
|
text-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
p {
|
|
|
|
|
margin: 0;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
@ -614,7 +644,7 @@ onMounted(async () => {
|
|
|
|
|
background: transparent;
|
|
|
|
|
transition: all 0.3s ease;
|
|
|
|
|
|
|
|
|
|
&:hover > td {
|
|
|
|
|
&:hover>td {
|
|
|
|
|
background: rgba(0, 212, 255, 0.08) !important;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|