363 lines
10 KiB
Vue
363 lines
10 KiB
Vue
<template>
|
||
<div class="outer-wrap">
|
||
<!-- 顶部栏:Tab + 班级名称 + 返回 -->
|
||
<div class="header-bar">
|
||
<Tabs v-model="activeTab" type="line">
|
||
<TabPane label="任教信息" name="teacher"></TabPane>
|
||
<TabPane label="学生列表" name="student"></TabPane>
|
||
</Tabs>
|
||
<div class="class-title-box">
|
||
<span class="class-name">{{ $route.query.gradeclassName }}</span>
|
||
<Button text @click="backPage">
|
||
<Icon type="ios-arrow-back"></Icon>
|
||
</Button>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 任教信息页面 -->
|
||
<div v-if="activeTab === 'teacher'" class="teacher-wrap">
|
||
<div class="subject-container">
|
||
<div
|
||
v-for="(item, idx) in subjectList"
|
||
:key="idx"
|
||
class="subject-card"
|
||
@click="openSetTeacher(idx)"
|
||
>
|
||
<div class="subject-name">{{ item.subName }}</div>
|
||
<div class="teacher-name-wrap">
|
||
<span class="teacher-name">{{ item.teacherName || '点击设置老师' }}</span>
|
||
<span
|
||
v-if="item.teacherId"
|
||
class="close-btn"
|
||
@click.stop="clearTeacher(idx)"
|
||
>×</span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 学生列表页面 -->
|
||
<div v-if="activeTab === 'student'" class="student-wrap">
|
||
<div class="table-scroll-box">
|
||
<Table
|
||
border
|
||
stripe
|
||
:columns="studentColumns"
|
||
:data="studentData"
|
||
:height="useTableHeight()+82"
|
||
class="student-table"
|
||
></Table>
|
||
</div>
|
||
<!-- <div class="pagination-bottom">
|
||
<span class="total-text">共 {{ total }} 条</span>
|
||
<Page
|
||
:current.sync="pageNum"
|
||
:total="total"
|
||
:page-size="pageSize"
|
||
:page-size-opts="[10,20,50]"
|
||
show-sizer
|
||
@on-change="pageChange"
|
||
@on-page-size-change="sizeChange"
|
||
></Page>
|
||
</div> -->
|
||
</div>
|
||
|
||
<!-- 设置教师弹窗 -->
|
||
<Modal v-model="modalVisible" title="选择教师" width="400">
|
||
<Form ref="form" :model="formData" :rules="formRules" label-width="90">
|
||
<FormItem label="科室">
|
||
<Select v-model="formData.dept" placeholder="按科室过滤" style="width:100%" @on-change="getteacherSelect" clearable transfer>
|
||
<Option v-for="d in groupteacherSelectlist" :key="d.id" :value="d.id">{{ d.name }}</Option>
|
||
</Select>
|
||
</FormItem>
|
||
<FormItem label="教师">
|
||
<Select v-model="formData.teacher" placeholder="请选择" style="width:100%" filterable transfer>
|
||
<Option v-for="t in teacherSelectlist" :key="t.id" :value="t.id">{{ t.name }}</Option>
|
||
</Select>
|
||
</FormItem>
|
||
</Form>
|
||
<div slot="footer" align="right">
|
||
<Button @click="modalVisible = false" style="margin-right:10px">取消</Button>
|
||
<Button type="primary" @click="submitSelectTeacher">提交</Button>
|
||
</div>
|
||
</Modal>
|
||
</div>
|
||
</template>
|
||
|
||
<script>
|
||
import { self_viewport } from "@/mixins/self_viewport";
|
||
export default {
|
||
name: 'ChristianityDetail',
|
||
data() {
|
||
return {
|
||
activeTab: 'teacher',
|
||
// 当前编辑科目下标
|
||
currentEditIndex: null,
|
||
|
||
// 科目列表
|
||
subjectList: [],
|
||
|
||
// 科室、教师数据源
|
||
groupteacherSelectlist: [],
|
||
teacherSelectlist: [],
|
||
|
||
modalVisible: false,
|
||
formData: { dept: '', teacher: '' },
|
||
formRules: {
|
||
dept: [{ required: true, message: '请选择科室', trigger: 'change' }],
|
||
teacher: [{ required: true, message: '请选择教师', trigger: 'change' }]
|
||
},
|
||
|
||
// 学生列表分页
|
||
pageNum: 1,
|
||
pageSize: 10,
|
||
total: 0,
|
||
studentColumns: [
|
||
{ title: '序号', type: 'index', align: 'center', width: 70 },
|
||
{ title: '姓名', key: 'name', align: 'center' },
|
||
{
|
||
title: '性别',
|
||
key: 'gender',
|
||
align: 'center',
|
||
width: 70,
|
||
render: (h, params) => {
|
||
return h('div', [
|
||
params.row.gender==0?'女':params.row.gender==1?'男':''
|
||
]);
|
||
},
|
||
},
|
||
{ title: '年级', key: 'gradeName', align: 'center' },
|
||
{ title: '班级', key: 'className', align: 'center' },
|
||
{ title: '身份证', key: 'idCard', align: 'center' }
|
||
],
|
||
studentData: []
|
||
}
|
||
},
|
||
watch: {
|
||
// 切换标签页重新初始化拖拽
|
||
activeTab(val) {
|
||
if (val === 'teacher') {
|
||
this.getSchClassTeach();
|
||
} else{
|
||
this.searchSchClassStudent();
|
||
}
|
||
}
|
||
},
|
||
mixins: [self_viewport],
|
||
created(){
|
||
this.getSchClassTeach();
|
||
this.getgroupteacherSelect();
|
||
this.getteacherSelect();
|
||
},
|
||
methods: {
|
||
// 返回上一页
|
||
backPage() {
|
||
this.$router.back()
|
||
},
|
||
//通过班级ID获取任教
|
||
getSchClassTeach(){
|
||
const _this = this;
|
||
var item={
|
||
gradeId:_this.$route.query.gradeId,
|
||
classId:_this.$route.query.classId
|
||
};
|
||
_this.$api.get(APIConfig.BschClassSystem.getSchClassTeach, item, resp => {
|
||
if(resp.code==0)
|
||
{
|
||
_this.subjectList = resp.data;
|
||
}else{
|
||
_this.subjectList=[];
|
||
}
|
||
});
|
||
},
|
||
//通过班级ID获取学生
|
||
searchSchClassStudent(){
|
||
const _this = this;
|
||
var item={
|
||
gradeId:_this.$route.query.gradeId,
|
||
classId:_this.$route.query.classId
|
||
};
|
||
_this.$api.get(APIConfig.BschClassSystem.searchSchClassStudent, item, resp => {
|
||
if(resp.code==0)
|
||
{
|
||
_this.studentData = resp.data;
|
||
}else{
|
||
_this.studentData=[];
|
||
}
|
||
});
|
||
},
|
||
// 教师组下拉
|
||
getgroupteacherSelect() {
|
||
const _this = this;
|
||
_this.$api.get(APIConfig.BschClassSystem.getgroupteacherSelect, {}, resp => {
|
||
if (resp.code == 0) {
|
||
_this.groupteacherSelectlist = resp.data;
|
||
} else {
|
||
_this.groupteacherSelectlist = [];
|
||
}
|
||
});
|
||
},
|
||
// 教师下拉
|
||
getteacherSelect() {
|
||
const _this = this;
|
||
const item = { groupId: _this.selectDept };
|
||
_this.$api.get(APIConfig.BschClassSystem.getteacherSelect, item, resp => {
|
||
if (resp.code == 0) {
|
||
_this.teacherSelectlist = resp.data;
|
||
if (_this.oldTeacherId) {
|
||
const findT = _this.teacherSelectlist.find(t => t.id === _this.oldTeacherId);
|
||
if (findT) {
|
||
_this.selectTeacher = findT.id;
|
||
}
|
||
}
|
||
} else {
|
||
_this.teacherSelectlist = [];
|
||
}
|
||
});
|
||
},
|
||
// 打开设置教师弹窗
|
||
openSetTeacher(index) {
|
||
this.currentEditIndex = index
|
||
this.modalVisible = true
|
||
this.formData = { dept: '', teacher:this.subjectList[index].teacherId?this.subjectList[index].teacherId:'' }
|
||
},
|
||
|
||
// 移除当前科目教师
|
||
clearTeacher(index) {
|
||
this.$Modal.confirm({
|
||
title: '提示',
|
||
content: '确定移除该任课教师?',
|
||
onOk: () => {
|
||
this.$api.post(APIConfig.BschClassSystem.teachsdelete+this.subjectList[index].id, {}, res => {
|
||
if (res.code === 0) {
|
||
this.$Message.success('移除教师成功');
|
||
this.getSchClassTeach();
|
||
}
|
||
});
|
||
}
|
||
})
|
||
},
|
||
// 弹窗提交分配教师
|
||
submitSelectTeacher() {
|
||
if (!this.formData.teacher) {
|
||
this.$Message.warning('请选择教师');
|
||
return;
|
||
}
|
||
const row = this.subjectList[this.currentEditIndex];
|
||
const params = {
|
||
id: row.id,
|
||
gradeId:this.$route.query.gradeId,
|
||
classId:this.$route.query.classId,
|
||
subId: row.subId,
|
||
teaId: this.formData.teacher
|
||
};
|
||
this.$api.post(APIConfig.BschClassSystem.teachssave, JSON.stringify(params), res => {
|
||
if (res.code === 0) {
|
||
this.$Message.success('分配教师成功');
|
||
this.modalVisible = false;
|
||
this.getSchClassTeach();
|
||
}
|
||
});
|
||
},
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style scoped>
|
||
.outer-wrap {
|
||
border: 1px solid #e5e7eb;
|
||
border-radius: 4px;
|
||
padding: 16px;
|
||
width: 100%;
|
||
height: 100%;
|
||
box-sizing: border-box;
|
||
background: #fff;
|
||
display: flex;
|
||
flex-direction: column;
|
||
overflow-y: auto;
|
||
}
|
||
|
||
.header-bar {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
margin-bottom: 20px;
|
||
}
|
||
.class-title-box {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 8px;
|
||
}
|
||
.class-name {
|
||
font-size: 18px;
|
||
font-weight: 500;
|
||
}
|
||
|
||
/* 任教信息卡片布局 */
|
||
.teacher-wrap {
|
||
flex: 1;
|
||
}
|
||
.subject-container {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
gap: 12px;
|
||
row-gap: 16px;
|
||
}
|
||
.subject-card {
|
||
width: 180px;
|
||
border: 1px solid #cad6f0;
|
||
border-radius: 4px;
|
||
padding: 12px 14px;
|
||
cursor: pointer;
|
||
}
|
||
.subject-name {
|
||
font-size: 14px;
|
||
color: #333;
|
||
margin-bottom: 6px;
|
||
}
|
||
.teacher-name-wrap {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
}
|
||
.teacher-name {
|
||
font-size: 14px;
|
||
color: #4080ff;
|
||
}
|
||
.close-btn {
|
||
width: 18px;
|
||
height: 18px;
|
||
line-height: 18px;
|
||
text-align: center;
|
||
border-radius: 50%;
|
||
background: #eee;
|
||
font-size: 14px;
|
||
color: #666;
|
||
}
|
||
|
||
/* 学生列表布局 */
|
||
.student-wrap {
|
||
flex: 1;
|
||
display: flex;
|
||
flex-direction: column;
|
||
min-height: 0;
|
||
}
|
||
.table-scroll-box {
|
||
flex: 1;
|
||
overflow-y: auto;
|
||
}
|
||
.student-table {
|
||
width: 100%;
|
||
}
|
||
.pagination-bottom {
|
||
margin-top: 16px;
|
||
display: flex;
|
||
justify-content: flex-end;
|
||
align-items: center;
|
||
gap: 12px;
|
||
}
|
||
.total-text {
|
||
font-size: 14px;
|
||
color: #666;
|
||
}
|
||
</style> |