fix:修改添加班级的问题;

This commit is contained in:
yangws 2024-07-30 10:16:46 +08:00
parent b317471e66
commit 817ea8790e
4 changed files with 30 additions and 32 deletions

View File

@ -92,7 +92,7 @@
<el-col :span="4">未选学生:</el-col>
<el-col :span="20" class="studentContent">
<div class="aItem" v-for="(stuItem,stuIndex) in avaliableStudents" :key="stuIndex">
<el-button style="width: 100%" plain @click="chooseItem(stuItem,stuIndex)">{{stuItem.name || stuItem.studentname}}</el-button>
<el-button style="width: 100%" plain @click="chooseItem(stuItem,stuIndex)">{{stuItem.studentname || stuItem.name}}</el-button>
</div>
</el-col>
</el-row>
@ -121,7 +121,7 @@ const groupForm = reactive({
groupname: '',
orderidx: 0,
classid: Number(props.classId),
edituserid: userStore.id,
edituserid: userStore.userId,
edusubject: userStore.edusubject,
userid : 0,
studentid : 0,
@ -188,7 +188,7 @@ const getClassInfo = () => {
const chooseItem = (item,stuIndex) => {
let formdata = {}
formdata.classid = props.classId;
formdata.edituserid = userStore.id;
formdata.edituserid = userStore.userId;
formdata.userid = item.userid;
formdata.parentid = parentId.value;
formdata.studentid = item.studentid;

View File

@ -2,25 +2,19 @@
<el-card style="width: 100%;height: 100%">
<template #header>
<div style="text-align: left">
<el-button v-if="classInfo.teacher.length > 0" type="danger" @click="deleteClassRoom">删除班级</el-button>
<el-button type="danger" @click="deleteClassRoom">删除班级</el-button>
</div>
</template>
<template v-if="classInfo.teacher.length > 0">
<el-descriptions :column="1">
<el-descriptions-item label="班级名称">{{ classInfo.className }}</el-descriptions-item>
<el-descriptions-item label="教师">
<template v-if="classInfo.teacher.length > 0">
<el-tag type="primary" v-for="(item, index) in classInfo.teacher" :key="index">{{item.name}}</el-tag>
</template>
<template v-else>暂无</template>
</el-descriptions-item>
<el-descriptions-item label="学生人数">{{ classInfo.student.length }}</el-descriptions-item>
</el-descriptions>
</template>
<template v-else>
<el-empty description="暂无班级信息" style="margin: 0 auto"/>
</template>
<el-descriptions :column="1">
<el-descriptions-item label="班级名称">{{ classInfo.caption }}</el-descriptions-item>
<el-descriptions-item label="教师">
<template v-if="classInfo.teacher.length > 0">
<el-tag type="primary" v-for="(item, index) in classInfo.teacher" :key="index">{{item.name}}</el-tag>
</template>
<template v-else>{{ classInfo.teachername }}</template>
</el-descriptions-item>
<el-descriptions-item label="学生人数">{{ classInfo.classstudentcount || 0 }}</el-descriptions-item>
</el-descriptions>
</el-card>
</template>
@ -42,13 +36,14 @@
})
const isDelClass = delClassDemo()
const userStore = useUserStore().user
console.log(userStore,'userStore')
//
const deleteClassRoom = () => {
ElMessageBox.alert('确认删除该班级?', {
confirmButtonText: '确认',
type: 'warning'
}).then(() => {
leaveClass({ classid: props.classId, userid: userStore.id, inrole: 'teacher' }).then(() => {
leaveClass({ classid: props.classId, userid: userStore.userId, inrole: 'teacher' }).then(() => {
ElMessage({
message: '删除成功',
type: 'success',
@ -63,12 +58,13 @@
const getClassInfo = () => {
if(props.classId){
getClassmain(props.classId).then(response => {
classInfo.className = response.data.caption
Object.assign(classInfo,response.data)
listClassuser({classid:props.classId,pageSize:100}).then(res => {
classInfo.teacher = res.rows.filter(item => item.inrole === 'teacher')
classInfo.student = res.rows.filter(item => item.inrole === 'student')
})
})
console.log(classInfo,'classInfo')
}
}
onMounted(() => {

View File

@ -145,12 +145,14 @@
//
const getClassInfo = () => {
classList.value = []
listClassmain({ entpid: userStore.deptId, pageSize: 500, status: 'open' }).then(response => {
response.rows.forEach(item => {
if(item.classteacherids && Number(item.classteacherids) === userStore.userId){
classList.value.push(item)
}
})
listClassmain({ classuserid: userStore.userId, pageSize: 100, status: 'open' }).then(response => {
// response.rows.forEach(item => {
// if(item.teacherid && Number(item.teacherid) === userStore.userId){
// classList.value.push(item)
// }
// })
classList.value = [...response.rows]
console.log(classList.value,'classList')
if(classList.value.length > 0){
classId.value = classList.value[0].id
currentIndex.value = 0
@ -190,7 +192,7 @@
classForm.entpid = userStore.deptId;
classForm.status = 'open';
classForm.teachername = userStore.nickName;
classForm.teacherid = userStore.id;
classForm.teacherid = userStore.userId;
classForm.teacherSubject = classForm.edusubject;
addClassmain(classForm).then(response => {
if (response.code === 200) {

View File

@ -71,7 +71,7 @@
</el-form>
<template #footer>
<el-button type="warning" v-show="studentForm.id > 0" @click="delStudent(1)">移出班级</el-button>
<el-button type="danger" v-show="studentForm.id > 0 && studentForm.editoruserid == userStore.id" @click="delStudent(2)">删除学生</el-button>
<el-button type="danger" v-show="studentForm.id > 0 && studentForm.editoruserid == userStore.userId" @click="delStudent(2)">删除学生</el-button>
<el-button @click="studentVisible = false"> </el-button>
<el-button type="primary" @click="btnStudentSave"> </el-button>
</template>
@ -201,7 +201,7 @@
studentForm.classname = classInfo.value.caption;
studentForm.schoolname = classInfo.value.entpname;
studentForm.status = '';
studentForm.editoruserid = userStore.id;
studentForm.editoruserid = userStore.userId;
addStudentmain(studentForm).then((response) => {
if (response.code === 200) {
ElMessage({
@ -422,7 +422,7 @@
formdata.classname = classInfo.value.caption;
formdata.schoolname = classInfo.value.entpname;
formdata.status = '';
formdata.editoruserid = userStore.id;
formdata.editoruserid = userStore.userId;
addStudentmainByNameArray(formdata).then(res => {
if(res.code == 200){