Compare commits

...

2 Commits

Author SHA1 Message Date
yangws 8ec738de46 Merge pull request 'add:新增加入班级;' (#185) from yangws into main
Reviewed-on: #185
2024-09-10 16:50:30 +08:00
yangws 076a510109 add:新增加入班级; 2024-09-10 16:49:11 +08:00
5 changed files with 200 additions and 84 deletions

View File

@ -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"
} }

View File

@ -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'
}
})
}

View File

@ -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>

View File

@ -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 label="任选学科" style="margin-right: 10px;">-->
<!-- <el-radio-group v-model="classForm.edusubject" class="ml-4">-->
<!-- <template v-for="(item, index) in courseList" :key="index">-->
<!-- <el-radio v-if="item.edustage == userStore.edustage" :value="item.itemtitle">{{ item.itemtitle }}</el-radio>-->
<!-- </template>-->
<!-- </el-radio-group>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="年级" style="margin-right: 10px;" prop="agekey">-->
<!-- <el-radio-group v-model="classForm.edudegree">-->
<!-- <template v-for="(item,index) in gradeList" :key="index">-->
<!-- <el-radio v-if="item.edustage == userStore.edustage" :value="item.value">{{ item.label }}</el-radio>-->
<!-- </template>-->
<!-- </el-radio-group>-->
<!-- </el-form-item>-->
<!-- <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}}
</el-text>
</el-form-item> </el-form-item>
<el-form-item label="任选学科" style="margin-right: 10px;"> <el-form-item label="班级">
<el-radio-group v-model="classForm.edusubject" class="ml-4"> <el-tree-select
<template v-for="(item, index) in courseList" :key="index"> v-model="classids"
<el-radio v-if="item.edustage == userStore.edustage" :value="item.itemtitle">{{ item.itemtitle }}</el-radio> :data="gradeTree"
</template> multiple
</el-radio-group> :render-after-expand="false"
</el-form-item> style="width: 240px"
<el-form-item label="年级" style="margin-right: 10px;" prop="agekey"> />
<el-radio-group v-model="classForm.edudegree">
<template v-for="(item,index) in gradeList" :key="index">
<el-radio v-if="item.edustage == userStore.edustage" :value="item.value">{{ item.label }}</el-radio>
</template>
</el-radio-group>
</el-form-item>
<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>
</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) {

View File

@ -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>--> <!--&lt;!&ndash; <div>&ndash;&gt;-->
<!-- <el-button type="primary" @click="addStudent(0)">新增学生</el-button>--> <!--&lt;!&ndash; <el-button type="primary" @click="addStudent(0)">新增学生</el-button>&ndash;&gt;-->
<!-- <el-button type="primary" @click="importStudent()">导入学生</el-button>--> <!--&lt;!&ndash; <el-button type="primary" @click="importStudent()">导入学生</el-button>&ndash;&gt;-->
<!--&lt;!&ndash; </div>&ndash;&gt;-->
<!--&lt;!&ndash; <el-text class="mx-1">点击学生头像查看学生信息</el-text>&ndash;&gt;-->
<!-- </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">