Compare commits
2 Commits
32ab4dbbfb
...
da1390a0df
Author | SHA1 | Date |
---|---|---|
yangws | da1390a0df | |
小杨 | 1c463ed58b |
|
@ -0,0 +1,232 @@
|
|||
<template>
|
||||
<div>
|
||||
<el-dialog v-model="dialogVisible" title="创建班级" width="50%" append-to-body>
|
||||
<el-form
|
||||
style="width: 100%"
|
||||
label-width="auto"
|
||||
:model="classForm"
|
||||
:rules="rules"
|
||||
ref="myForm"
|
||||
>
|
||||
<el-form-item label="班级名称" style="margin-right: 10px;width: 100%" prop="caption">
|
||||
<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" :label="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.agekey">
|
||||
<template v-for="(item, index) in gradeList" :key="index">
|
||||
<el-radio v-if="item.edustage == userStore.edustage" :label="item.agekey">{{ 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>
|
||||
<template #footer>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="btnSave">确 定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, reactive, watch, defineEmits, defineExpose } from 'vue'
|
||||
import { listClassmain, addClassmain, listEvaluation } from '@/api/classManage/index'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import delClassDemo from '@/store/modules/delClass'
|
||||
|
||||
const userStore = useUserStore().user
|
||||
const emit = defineEmits(['refreshList'])
|
||||
const isDel = delClassDemo()
|
||||
|
||||
// 获取班级信息
|
||||
const classList = ref([])
|
||||
// 创建班级基本信息
|
||||
const classForm = reactive({
|
||||
caption: '',
|
||||
classdesc: '',
|
||||
teacherid: '',
|
||||
agekey: '',
|
||||
edusubject: userStore.edusubject,
|
||||
edudegree: userStore.edustage
|
||||
})
|
||||
// 学科列表
|
||||
const courseList = ref([])
|
||||
// 班级id
|
||||
const classId = ref('')
|
||||
// 当前页面
|
||||
const currentIndex = ref(0)
|
||||
// 年级
|
||||
const gradeList = ref([
|
||||
{ label: '一年级', value: '1年级', checked: false, edustage: '小学', agekey: 1 },
|
||||
{ label: '二年级', value: '2年级', checked: false, edustage: '小学', agekey: 2 },
|
||||
{ label: '三年级', value: '3年级', checked: false, edustage: '小学', agekey: 3 },
|
||||
{ label: '四年级', value: '4年级', checked: false, edustage: '小学', agekey: 4 },
|
||||
{ label: '五年级', value: '5年级', checked: false, edustage: '小学', agekey: 5 },
|
||||
{ label: '六年级', value: '6年级', checked: false, edustage: '小学', agekey: 6 },
|
||||
{ label: '初一', value: '初一', checked: false, edustage: '初中', agekey: 7 },
|
||||
{ label: '初二', value: '初二', checked: false, edustage: '初中', agekey: 8 },
|
||||
{ label: '初三', value: '初三', checked: false, edustage: '初中', agekey: 9 },
|
||||
{ label: '高一', value: '高一', checked: false, edustage: '高中', agekey: 10 },
|
||||
{ label: '高二', value: '高二', checked: false, edustage: '高中', agekey: 11 },
|
||||
{ label: '高三', value: '高三', checked: false, edustage: '高中', agekey: 12 },
|
||||
])
|
||||
// 打开班级
|
||||
const dialogVisible = ref(false)
|
||||
// 校验表单
|
||||
const myForm = ref(null)
|
||||
const rules = reactive({
|
||||
caption: [
|
||||
{ required: true, message: '请输入班级名称', trigger: 'blur' },
|
||||
{ min: 1, max: 10, message: '班级名称必须是 1-10 位 的字符', trigger: 'blur' }
|
||||
],
|
||||
agekey: [
|
||||
{ required: true, message: '请选择年级', trigger: 'change' }
|
||||
],
|
||||
})
|
||||
|
||||
// 获取班级信息
|
||||
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?.id) {
|
||||
classList.value.push(item)
|
||||
}
|
||||
})
|
||||
if (classList.value.length > 0) {
|
||||
classId.value = classList.value[0].id
|
||||
currentIndex.value = 0
|
||||
}
|
||||
});
|
||||
}
|
||||
// 获取所有学科
|
||||
const getCourseList = () => {
|
||||
// 获取基础的学科
|
||||
listEvaluation({ itemkey: "subject", pageSize: 500 }).then((res) => {
|
||||
courseList.value = [...res.rows];
|
||||
});
|
||||
}
|
||||
// 新增班级
|
||||
const addClass = () => {
|
||||
dialogVisible.value = true
|
||||
getCourseList()
|
||||
getClassInfo()
|
||||
}
|
||||
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.agekey;
|
||||
const index = gradeList.value.findIndex(item => item.agekey === age);
|
||||
classForm.edudegree = gradeList.value[index].value
|
||||
classForm.entpid = userStore.deptId;
|
||||
classForm.status = 'open';
|
||||
classForm.teachername = userStore.nickName;
|
||||
classForm.teacherid = userStore.userId;
|
||||
classForm.teacherSubject = classForm.edusubject;
|
||||
classForm.action = 'new';
|
||||
classForm.teachtype = 'standard';
|
||||
classForm.isSaving = true;
|
||||
addClassmain(classForm).then(response => {
|
||||
if (response.code === 200) {
|
||||
dialogVisible.value = false
|
||||
ElMessage({
|
||||
message: '新增成功',
|
||||
type: 'success',
|
||||
})
|
||||
emit('refreshList')
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ElMessage({
|
||||
message: '班级名称重复',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
// 文本计算
|
||||
const textSimilar = (s, t, f) => {
|
||||
if (!s || !t) {
|
||||
return 0
|
||||
}
|
||||
if (s === t) {
|
||||
return 100;
|
||||
}
|
||||
var l = s.length > t.length ? s.length : t.length
|
||||
var n = s.length
|
||||
var m = t.length
|
||||
var d = []
|
||||
f = f || 2
|
||||
var min = function (a, b, c) {
|
||||
return a < b ? (a < c ? a : c) : (b < c ? b : c)
|
||||
}
|
||||
var i, j, si, tj, cost
|
||||
if (n === 0) return m
|
||||
if (m === 0) return n
|
||||
for (i = 0; i <= n; i++) {
|
||||
d[i] = []
|
||||
d[i][0] = i
|
||||
}
|
||||
for (j = 0; j <= m; j++) {
|
||||
d[0][j] = j
|
||||
}
|
||||
for (i = 1; i <= n; i++) {
|
||||
si = s.charAt(i - 1)
|
||||
for (j = 1; j <= m; j++) {
|
||||
tj = t.charAt(j - 1)
|
||||
if (si === tj) {
|
||||
cost = 0
|
||||
} else {
|
||||
cost = 1
|
||||
}
|
||||
d[i][j] = min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost)
|
||||
}
|
||||
}
|
||||
let res = (1 - d[n][m] / l) * 100
|
||||
return res.toFixed(f)
|
||||
}
|
||||
watch(() => isDel.idDelete, () => {
|
||||
// 判断是否更改了班级
|
||||
getClassInfo()
|
||||
isDel.idDelete = false
|
||||
})
|
||||
defineExpose({
|
||||
addClass
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.el-card-demo {
|
||||
width: 200px;
|
||||
overflow-y: auto;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
flex-direction: column;
|
||||
}
|
||||
</style>
|
|
@ -1,14 +1,15 @@
|
|||
<template>
|
||||
<div class="common-layout">
|
||||
<el-container>
|
||||
<el-aside style="width: 200px;">
|
||||
<el-card style="width: 200px" class="el-card-demo">
|
||||
<el-aside style="width: 230px;">
|
||||
<el-card style="width: 230px" class="el-card-demo">
|
||||
<div >
|
||||
<Aside :menuItems="menuItems" :classList="classList" @handleSelect="handleSelect"></Aside>
|
||||
</div>
|
||||
<template #footer>
|
||||
<div>
|
||||
<el-button @click="addClass" type="primary" :icon="Plus" >加入班级</el-button>
|
||||
<div style="display: flex;">
|
||||
<el-button @click="addClass" type="primary">加入班级</el-button>
|
||||
<el-button @click="addNewClass" type="primary">创建班级</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-card>
|
||||
|
@ -23,11 +24,11 @@
|
|||
<!-- 分组情况-->
|
||||
<BasicGroup v-else-if="currentIndex==2" :classId="classId"></BasicGroup>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- 创建班级 -->
|
||||
<NewClass ref="newClassRef" @refreshList="refreshList"/>
|
||||
</el-container>
|
||||
</div>
|
||||
<el-dialog v-model="dialogVisible" title="新增班级" width="50%" append-to-body>
|
||||
<el-dialog v-model="dialogVisible" title="加入班级" width="50%" append-to-body>
|
||||
<el-form
|
||||
style="width: 100%"
|
||||
label-width="auto"
|
||||
|
@ -69,11 +70,14 @@
|
|||
import BasicGroup from './basicGroup.vue'
|
||||
import ClassInfo from './classInfo.vue'
|
||||
import Aside from './aside.vue'
|
||||
import NewClass from './components/newClass.vue'
|
||||
|
||||
const userStore = useUserStore().user
|
||||
const isDel = delClassDemo()
|
||||
//获取班级信息
|
||||
const classList = ref([])
|
||||
// 创建新班级
|
||||
const newClassRef = ref()
|
||||
const menuItems = [
|
||||
{
|
||||
index: '1-1',
|
||||
|
@ -108,21 +112,6 @@
|
|||
const classId = ref(0)
|
||||
//当前页面
|
||||
const currentIndex = ref(0)
|
||||
//年级
|
||||
const gradeList = ref([
|
||||
{ label: '一年级', value: '1年级', checked: false, edustage: '小学', agekey: 1 },
|
||||
{ label: '二年级', value: '2年级', checked: false, edustage: '小学', agekey: 2 },
|
||||
{ label: '三年级', value: '3年级', checked: false, edustage: '小学', agekey: 3 },
|
||||
{ label: '四年级', value: '4年级', checked: false, edustage: '小学', agekey: 4 },
|
||||
{ label: '五年级', value: '5年级', checked: false, edustage: '小学', agekey: 5},
|
||||
{ label: '六年级', value: '6年级', checked: false, edustage: '小学', agekey: 6 },
|
||||
{ label: '初一', value: '初一', checked: false, edustage: '初中', agekey: 7 },
|
||||
{ label: '初二', value: '初二', checked: false, edustage: '初中', agekey: 8 },
|
||||
{ label: '初三', value: '初三', checked: false, edustage: '初中', agekey: 9 },
|
||||
{ label: '高一', value: '高一', checked: false, edustage: '高中', agekey: 10 },
|
||||
{ label: '高二', value: '高二', checked: false, edustage: '高中', agekey: 11 },
|
||||
{ label: '高三', value: '高三', checked: false, edustage: '高中', agekey: 12 },
|
||||
])
|
||||
//打开班级
|
||||
const dialogVisible = ref(false)
|
||||
//班级列表
|
||||
|
@ -287,6 +276,14 @@
|
|||
classId.value = obj.id
|
||||
currentIndex.value = obj.index
|
||||
}
|
||||
// 创建班级
|
||||
const addNewClass = () => {
|
||||
newClassRef.value.addClass()
|
||||
}
|
||||
// 刷新列表
|
||||
const refreshList = () => {
|
||||
getClassInfo()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getClassInfo()
|
||||
|
|
|
@ -66,7 +66,6 @@ onMounted(() => {
|
|||
}
|
||||
.text-center {
|
||||
margin-bottom: 15px;
|
||||
border-bottom: 1px solid #dddddd;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
.info{
|
||||
|
|
Loading…
Reference in New Issue