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

Merged
yangws merged 1 commits from yangws into main 2024-07-30 10:17:27 +08:00
4 changed files with 30 additions and 32 deletions

View File

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

View File

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

View File

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

View File

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