add:新增加入班级; #185
|
@ -69,5 +69,6 @@
|
||||||
"vite-plugin-windicss": "^1.9.3",
|
"vite-plugin-windicss": "^1.9.3",
|
||||||
"vue": "^3.4.30",
|
"vue": "^3.4.30",
|
||||||
"windicss": "^3.5.6"
|
"windicss": "^3.5.6"
|
||||||
}
|
},
|
||||||
|
"packageManager": "pnpm@9.9.0+sha512.60c18acd138bff695d339be6ad13f7e936eea6745660d4cc4a776d5247c540d0edee1a563695c183a66eb917ef88f2b4feb1fc25f32a7adcadc7aaf3438e99c1"
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,3 +187,14 @@ export function getClassInfo(id) {
|
||||||
params: {id}
|
params: {id}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
//加入班级
|
||||||
|
export function addClasses(data) {
|
||||||
|
return request({
|
||||||
|
url: '/smarttalk/audit/applyAddClass',
|
||||||
|
method: 'post',
|
||||||
|
data: data,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<template v-for="(item,index) in classList" :key="index">
|
<template v-for="(item,index) in classList" :key="index">
|
||||||
<el-sub-menu :index="`${index}`">
|
<el-sub-menu :index="`${index}`">
|
||||||
<template #title>
|
<template #title>
|
||||||
<span style="overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">{{item.caption}}</span>
|
<span style="overflow: hidden;white-space: nowrap;text-overflow: ellipsis;" @click="menuClick(item,index)">{{item.caption}}</span>
|
||||||
</template>
|
</template>
|
||||||
<el-menu-item-group>
|
<el-menu-item-group>
|
||||||
<el-menu-item v-for="(items,routerIndex) in menuItems" :key="`${routerIndex}`" :index="`${items.index}-${item.id}`">{{items.title}}</el-menu-item>
|
<el-menu-item v-for="(items,routerIndex) in menuItems" :key="`${routerIndex}`" :index="`${items.index}-${item.id}`">{{items.title}}</el-menu-item>
|
||||||
|
@ -33,6 +33,7 @@ const emits = defineEmits(['handleSelect'])
|
||||||
|
|
||||||
//点击跳转路由
|
//点击跳转路由
|
||||||
const handleSelect = (itemDom,pathKey) => {
|
const handleSelect = (itemDom,pathKey) => {
|
||||||
|
console.log(itemDom,pathKey)
|
||||||
const parts = pathKey[1].split("-")
|
const parts = pathKey[1].split("-")
|
||||||
const result = parts.slice(0, 2).join("-")
|
const result = parts.slice(0, 2).join("-")
|
||||||
const index = props.menuItems.findIndex(item=>item.index===result)
|
const index = props.menuItems.findIndex(item=>item.index===result)
|
||||||
|
@ -43,6 +44,18 @@ const handleSelect = (itemDom,pathKey) => {
|
||||||
// })
|
// })
|
||||||
emits('handleSelect',{index,id})
|
emits('handleSelect',{index,id})
|
||||||
}
|
}
|
||||||
|
const menuClick = (item,index) => {
|
||||||
|
// 获取当前点击的 el-sub-menu 元素
|
||||||
|
const currentSubMenu = document.getElementsByClassName('el-sub-menu');
|
||||||
|
|
||||||
|
// 检查是否有 is-open 类
|
||||||
|
if (!currentSubMenu[index].classList.contains('is-opened')) {
|
||||||
|
//点击以及菜单初始化跳转当前班级
|
||||||
|
const str = `1-1-${item.id}`
|
||||||
|
const arr = [String(index),str]
|
||||||
|
handleSelect(str,arr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,11 @@
|
||||||
<!-- <el-button @click="addClass" type="primary" :icon="Plus" >新增班级</el-button>-->
|
<!-- <el-button @click="addClass" type="primary" :icon="Plus" >新增班级</el-button>-->
|
||||||
<!-- </div>-->
|
<!-- </div>-->
|
||||||
<!-- </template>-->
|
<!-- </template>-->
|
||||||
|
<template #footer>
|
||||||
|
<div>
|
||||||
|
<el-button @click="addClass" type="primary" :icon="Plus" >加入班级</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-aside>
|
</el-aside>
|
||||||
<el-main :style="{'min-height': (viewportHeight - 160) + 'px'}">
|
<el-main :style="{'min-height': (viewportHeight - 160) + 'px'}">
|
||||||
|
@ -28,7 +33,7 @@
|
||||||
</el-main>
|
</el-main>
|
||||||
</el-container>
|
</el-container>
|
||||||
</div>
|
</div>
|
||||||
<el-dialog v-model="dialogVisible" title="新增班级" width="50%">
|
<el-dialog v-model="dialogVisible" title="新增班级" width="50%" append-to-body>
|
||||||
<el-form
|
<el-form
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
label-width="auto"
|
label-width="auto"
|
||||||
|
@ -36,30 +41,45 @@
|
||||||
:rules="rules"
|
:rules="rules"
|
||||||
ref="myForm"
|
ref="myForm"
|
||||||
>
|
>
|
||||||
<el-form-item label="班级名称" style="margin-right: 10px;width: 50%" prop="caption">
|
<!-- <el-form-item label="班级名称" style="margin-right: 10px;width: 50%" prop="caption">-->
|
||||||
<el-input v-model="classForm.caption" placeholder="请输入班级名称"></el-input>
|
<!-- <el-input v-model="classForm.caption" placeholder="请输入班级名称"></el-input>-->
|
||||||
</el-form-item>
|
<!-- </el-form-item>-->
|
||||||
<el-form-item label="任选学科" style="margin-right: 10px;">
|
<!-- <el-form-item label="任选学科" style="margin-right: 10px;">-->
|
||||||
<el-radio-group v-model="classForm.edusubject" class="ml-4">
|
<!-- <el-radio-group v-model="classForm.edusubject" class="ml-4">-->
|
||||||
<template v-for="(item, index) in courseList" :key="index">
|
<!-- <template v-for="(item, index) in courseList" :key="index">-->
|
||||||
<el-radio v-if="item.edustage == userStore.edustage" :value="item.itemtitle">{{ item.itemtitle }}</el-radio>
|
<!-- <el-radio v-if="item.edustage == userStore.edustage" :value="item.itemtitle">{{ item.itemtitle }}</el-radio>-->
|
||||||
</template>
|
<!-- </template>-->
|
||||||
</el-radio-group>
|
<!-- </el-radio-group>-->
|
||||||
</el-form-item>
|
<!-- </el-form-item>-->
|
||||||
<el-form-item label="年级" style="margin-right: 10px;" prop="agekey">
|
<!-- <el-form-item label="年级" style="margin-right: 10px;" prop="agekey">-->
|
||||||
<el-radio-group v-model="classForm.edudegree">
|
<!-- <el-radio-group v-model="classForm.edudegree">-->
|
||||||
<template v-for="(item,index) in gradeList" :key="index">
|
<!-- <template v-for="(item,index) in gradeList" :key="index">-->
|
||||||
<el-radio v-if="item.edustage == userStore.edustage" :value="item.value">{{ item.label }}</el-radio>
|
<!-- <el-radio v-if="item.edustage == userStore.edustage" :value="item.value">{{ item.label }}</el-radio>-->
|
||||||
</template>
|
<!-- </template>-->
|
||||||
</el-radio-group>
|
<!-- </el-radio-group>-->
|
||||||
</el-form-item>
|
<!-- </el-form-item>-->
|
||||||
<el-form-item label="老师" prop="teacherid">
|
<!-- <el-form-item label="老师" prop="teacherid">-->
|
||||||
|
<!-- {{ userStore.nickName }}-->
|
||||||
|
<!-- </el-form-item>-->
|
||||||
|
<!-- <el-form-item label="简要说明" style="margin-right: 10px;" prop="classdesc">-->
|
||||||
|
<!-- <el-input v-model="classForm.classdesc" placeholder="请输入简要说明"></el-input>-->
|
||||||
|
<!-- </el-form-item>-->
|
||||||
|
<el-form-item label="老师" style="margin-right: 10px;width: 50%">
|
||||||
|
<el-text>
|
||||||
{{userStore.nickName}}
|
{{userStore.nickName}}
|
||||||
|
</el-text>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="简要说明" style="margin-right: 10px;" prop="classdesc">
|
<el-form-item label="班级">
|
||||||
<el-input v-model="classForm.classdesc" placeholder="请输入简要说明"></el-input>
|
<el-tree-select
|
||||||
|
v-model="classids"
|
||||||
|
:data="gradeTree"
|
||||||
|
multiple
|
||||||
|
:render-after-expand="false"
|
||||||
|
style="width: 240px"
|
||||||
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||||
<el-button type="primary" @click="btnSave">确 定</el-button>
|
<el-button type="primary" @click="btnSave">确 定</el-button>
|
||||||
|
@ -69,7 +89,7 @@
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {ref, onMounted, reactive,watch,nextTick} from 'vue'
|
import {ref, onMounted, reactive,watch,nextTick} from 'vue'
|
||||||
import {listClassmain, addClassmain, listEvaluation} from '@/api/classManage/index'
|
import {listClassmain, addClassmain, listEvaluation,addClasses} from '@/api/classManage/index'
|
||||||
import { Plus } from '@element-plus/icons-vue'
|
import { Plus } from '@element-plus/icons-vue'
|
||||||
import useUserStore from '@/store/modules/user'
|
import useUserStore from '@/store/modules/user'
|
||||||
import {ElMessage} from "element-plus";
|
import {ElMessage} from "element-plus";
|
||||||
|
@ -134,6 +154,8 @@
|
||||||
])
|
])
|
||||||
//打开班级
|
//打开班级
|
||||||
const dialogVisible = ref(false)
|
const dialogVisible = ref(false)
|
||||||
|
//班级列表
|
||||||
|
const gradeTree = ref([])
|
||||||
//校验表单
|
//校验表单
|
||||||
const myForm = ref(null)
|
const myForm = ref(null)
|
||||||
const rules = reactive({
|
const rules = reactive({
|
||||||
|
@ -142,78 +164,147 @@
|
||||||
{ min: 1, max: 10, message: '班级名称必须是 1-10 位 的字符', trigger: 'blur' }
|
{ min: 1, max: 10, message: '班级名称必须是 1-10 位 的字符', trigger: 'blur' }
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
const newGradeList = reactive([
|
||||||
|
[
|
||||||
|
{ label: '一年级', agekey: 1, checked: false, current: 1 },
|
||||||
|
{ label: '二年级', agekey: 2, checked: false, current: 1 },
|
||||||
|
{ label: '三年级', agekey: 3, checked: false, current: 1 },
|
||||||
|
{ label: '四年级', agekey: 4, checked: false, current: 1 },
|
||||||
|
{ label: '五年级', agekey: 5, checked: false, current: 1 },
|
||||||
|
{ label: '六年级', agekey: 6, checked: false, current: 1 },
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{ label: '初一', agekey: 7, checked: false, current: 2 },
|
||||||
|
{ label: '初二', agekey: 8, checked: false, current: 2 },
|
||||||
|
{ label: '初三', agekey: 9, checked: false, current: 2 },
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{ label: '高一', agekey: 10, checked: false, current: 3 },
|
||||||
|
{ label: '高二', agekey: 11, checked: false, current: 3 },
|
||||||
|
{ label: '高三', agekey: 12, checked: false, current: 3 },
|
||||||
|
],
|
||||||
|
])
|
||||||
|
//选择的班级
|
||||||
|
const classids = ref('')
|
||||||
|
|
||||||
// 获取班级信息
|
// 获取班级信息
|
||||||
const getClassInfo = () => {
|
const getClassInfo = () => {
|
||||||
classList.value = []
|
classList.value = []
|
||||||
listClassmain({ classuserid: userStore.userId, pageSize: 100, status: 'open' }).then(response => {
|
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]
|
classList.value = [...response.rows]
|
||||||
|
//这里获取组装所有班级
|
||||||
|
gradeTree.value = groupByCondition(response.rows, item => item.agekey);
|
||||||
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
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//获取所有学科
|
//将所有班级筛选成二级的数组
|
||||||
const getCourseList = () => {
|
function groupByCondition(arr, condition) {
|
||||||
// 获取基础的学科
|
// 分组结果存储为对象
|
||||||
listEvaluation({ itemkey: "subject", pageSize: 500 }).then((res) => {
|
const groups = arr.reduce((groups, item) => {
|
||||||
courseList.value = [...res.rows];
|
const groupKey = condition(item);
|
||||||
});
|
item.label = item.caption
|
||||||
|
item.value = item.id
|
||||||
|
groups[groupKey] = groups[groupKey] || [];
|
||||||
|
groups[groupKey].push(item);
|
||||||
|
return groups;
|
||||||
|
}, {});
|
||||||
|
// 构建新的数据结构
|
||||||
|
const formattedGroups = Object.keys(groups).map(key => ({
|
||||||
|
label: gradeName(key),
|
||||||
|
value:key,
|
||||||
|
children: groups[key]
|
||||||
|
}));
|
||||||
|
return formattedGroups;
|
||||||
}
|
}
|
||||||
|
//key对应学段年级
|
||||||
|
function gradeName(key){
|
||||||
|
//先把二级数组转化为一级数组,用于筛选
|
||||||
|
const flatGradeDataList = newGradeList.flat();
|
||||||
|
const currentIndex = flatGradeDataList.findIndex(item => item.agekey === Number(key));
|
||||||
|
if(currentIndex !== -1){
|
||||||
|
return flatGradeDataList[currentIndex].label;
|
||||||
|
}else{
|
||||||
|
//社团的处理
|
||||||
|
const defaultLabel = '社团';
|
||||||
|
flatGradeDataList[currentIndex] = { ...flatGradeDataList[currentIndex], label: defaultLabel };
|
||||||
|
return defaultLabel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//获取所有学科
|
||||||
|
// const getCourseList = () => {
|
||||||
|
// // 获取基础的学科
|
||||||
|
// listEvaluation({ itemkey: "subject", pageSize: 500 }).then((res) => {
|
||||||
|
// courseList.value = [...res.rows];
|
||||||
|
// });
|
||||||
|
// }
|
||||||
// 新增班级
|
// 新增班级
|
||||||
const addClass = () => {
|
const addClass = () => {
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
getCourseList()
|
// getCourseList()
|
||||||
}
|
}
|
||||||
|
// const btnSave = () => {
|
||||||
|
// myForm.value.validate((valid) => {
|
||||||
|
// if (valid) {
|
||||||
|
// //查看班级是否重名
|
||||||
|
// listClassmain({ entpid: userStore.deptId, status: 'open', pageSize: 500 }).then(response => {
|
||||||
|
// const data = [...response.rows]
|
||||||
|
// const existList = [];
|
||||||
|
// data.forEach(item => {
|
||||||
|
// if (parseInt(textSimilar(item.caption, classForm.caption, 2)) > 80) {
|
||||||
|
// existList.push(item);
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
//
|
||||||
|
// if (existList.length == 0) {
|
||||||
|
// const age = classForm.edudegree;
|
||||||
|
// const index = gradeList.value.findIndex(item => item.label === age);
|
||||||
|
// classForm.agekey = gradeList.value[index].agekey
|
||||||
|
// classForm.edudegree = `${gradeList.value[index].agekey}年级`
|
||||||
|
// classForm.entpid = userStore.deptId;
|
||||||
|
// classForm.status = 'open';
|
||||||
|
// classForm.teachername = userStore.nickName;
|
||||||
|
// classForm.teacherid = userStore.userId;
|
||||||
|
// classForm.teacherSubject = classForm.edusubject;
|
||||||
|
// addClassmain(classForm).then(response => {
|
||||||
|
// if (response.code === 200) {
|
||||||
|
// dialogVisible.value = false
|
||||||
|
// ElMessage({
|
||||||
|
// message: '新增成功',
|
||||||
|
// type: 'success',
|
||||||
|
// })
|
||||||
|
// getClassInfo()
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }else{
|
||||||
|
// ElMessage({
|
||||||
|
// message: '班级名称重复',
|
||||||
|
// type: 'warning',
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
//新增班级
|
||||||
const btnSave = () => {
|
const btnSave = () => {
|
||||||
myForm.value.validate((valid) => {
|
addClasses({classIds:classids.value.join(','),regId:userStore.userId}).then(res => {
|
||||||
if (valid) {
|
if (res.code === 200) {
|
||||||
//查看班级是否重名
|
|
||||||
listClassmain({ entpid: userStore.deptId, status: 'open', pageSize: 500 }).then(response => {
|
|
||||||
const data = [...response.rows]
|
|
||||||
const existList = [];
|
|
||||||
data.forEach(item => {
|
|
||||||
if (parseInt(textSimilar(item.caption, classForm.caption, 2)) > 80) {
|
|
||||||
existList.push(item);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
if (existList.length == 0) {
|
|
||||||
const age = classForm.edudegree;
|
|
||||||
const index = gradeList.value.findIndex(item => item.label === age);
|
|
||||||
classForm.agekey = gradeList.value[index].agekey
|
|
||||||
classForm.edudegree = `${gradeList.value[index].agekey}年级`
|
|
||||||
classForm.entpid = userStore.deptId;
|
|
||||||
classForm.status = 'open';
|
|
||||||
classForm.teachername = userStore.nickName;
|
|
||||||
classForm.teacherid = userStore.userId;
|
|
||||||
classForm.teacherSubject = classForm.edusubject;
|
|
||||||
addClassmain(classForm).then(response => {
|
|
||||||
if (response.code === 200) {
|
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: '新增成功',
|
message: res.msg,
|
||||||
type: 'success',
|
type: 'success',
|
||||||
})
|
})
|
||||||
getClassInfo()
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}else{
|
}else{
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: '班级名称重复',
|
message: res.msg,
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
|
||||||
//文本计算
|
//文本计算
|
||||||
const textSimilar = (s, t, f) => {
|
const textSimilar = (s, t, f) => {
|
||||||
if (!s || !t) {
|
if (!s || !t) {
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
<template>
|
<template>
|
||||||
<div style="height: 100%">
|
<div style="height: 100%">
|
||||||
<el-card style="width: 100%;height: 100%;overflow-y: auto">
|
<el-card style="width: 100%;height: 100%;overflow-y: auto">
|
||||||
<template #header>
|
<!-- <template #header>-->
|
||||||
<div style="text-align: left;display: flex;justify-content: space-between">
|
<!-- <div style="text-align: left;display: flex;justify-content: space-between">-->
|
||||||
<!-- <div>-->
|
<!--<!– <div>–>-->
|
||||||
<!-- <el-button type="primary" @click="addStudent(0)">新增学生</el-button>-->
|
<!--<!– <el-button type="primary" @click="addStudent(0)">新增学生</el-button>–>-->
|
||||||
<!-- <el-button type="primary" @click="importStudent()">导入学生</el-button>-->
|
<!--<!– <el-button type="primary" @click="importStudent()">导入学生</el-button>–>-->
|
||||||
|
<!--<!– </div>–>-->
|
||||||
|
<!--<!– <el-text class="mx-1">点击学生头像查看学生信息</el-text>–>-->
|
||||||
<!-- </div>-->
|
<!-- </div>-->
|
||||||
<el-text class="mx-1">点击学生头像查看学生信息</el-text>
|
<!-- </template>-->
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<div>
|
<div>
|
||||||
<div class="studentContent">
|
<div class="studentContent">
|
||||||
<template v-if="studentList.length > 0">
|
<template v-if="studentList.length > 0">
|
||||||
|
|
Loading…
Reference in New Issue