<!-- 班级人员管理 -->
|
<template>
|
<div class="c">
|
<div class="bg">
|
<div class="main">
|
<TitleIndex title="班级人员管理" />
|
<div class="content">
|
<!-- 班级名称 -->
|
<div style="padding-bottom:20px; border-bottom: 3px solid #409EFF;margin-bottom: 20px;">
|
<span>{{title}}</span>
|
<el-button @click="open = true" type="primary" size="small">新增学员</el-button>
|
</div>
|
<!-- 表格 -->
|
<el-table
|
:header-cell-style="getRowClass"
|
:row-style="{height:'38px'}"
|
:cell-style="{padding: '0'}"
|
:data="tableData"
|
border
|
style="width: 100%;"
|
>
|
<el-table-column
|
align="center"
|
prop="id"
|
label="学号"
|
>
|
</el-table-column>
|
<el-table-column
|
align="center"
|
prop="name"
|
label="姓名"
|
>
|
</el-table-column>
|
<el-table-column
|
align="center"
|
prop="sex"
|
label="性别"
|
>
|
</el-table-column>
|
<el-table-column
|
align="center"
|
prop="phone"
|
label="电话"
|
>
|
</el-table-column>
|
<el-table-column
|
align="center"
|
prop="condition"
|
label="上线情况"
|
>
|
</el-table-column>
|
<el-table-column
|
label="操作"
|
align="center"
|
width="300px"
|
>
|
<el-button type="warning">编辑</el-button>
|
<el-button type="danger">删除</el-button>
|
<el-button type="primary">分配角色</el-button>
|
</el-table-column>
|
</el-table>
|
<div
|
class="block"
|
style="display: flex; margin-top: 40px;"
|
>
|
<pagination v-show="total>0" :total="total" :page.sync="searchForm.pageNum" :limit.sync="searchForm.pageSize"
|
@pagination="page"/>
|
</div>
|
</div>
|
</div>
|
|
</div>
|
<PopUp
|
ref="popUp"
|
@children="parentGoods"
|
/>
|
|
<el-dialog
|
title="学员管理"
|
:visible.sync="open"
|
width="900px"
|
:before-close="handleClose">
|
<el-transfer
|
filterable
|
:filter-method="filterMethod"
|
filter-placeholder="学员姓名"
|
:titles="['学生列表', '当前学生']"
|
:button-texts="['退出班级', '加入班级']"
|
:props="{
|
key: 'id',
|
label: 'realName'
|
}"
|
v-model="classes.studentList"
|
:data="studentList">
|
</el-transfer>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="handleClose">取 消</el-button>
|
<el-button type="primary" @click="submitForm">保 存</el-button>
|
</span>
|
</el-dialog>
|
|
</div>
|
</template>
|
<script>
|
// 引入彈出窗口組件
|
import PopUp from "../../../components/PopUp/Question.vue";
|
import UserApi from "@/api/user";
|
import { updateClassesUser, getClassesUsers } from "@/api/classesUser";
|
export default {
|
// 注册
|
components: {
|
PopUp,
|
},
|
data() {
|
return {
|
total: 0,
|
studentList: [],
|
searchForm: {
|
realName: "",
|
pageSize: 10,
|
pageNum: 1,
|
classesId: null
|
},
|
classes: {
|
id: null,
|
studentList: []
|
},
|
open: false,
|
// 班级名称
|
title: "19级软件四班",
|
formLabelAlign: {
|
type: "",
|
user: "",
|
region: "",
|
},
|
tableData: [
|
{
|
id: 1,
|
name: "王五",
|
sex: "男",
|
phone: "12345678977",
|
// 是否上线
|
condition: "未上线",
|
},
|
],
|
};
|
},
|
mounted() {
|
this.classes.id = this.$route.query.classesId;
|
this.page()
|
this.getClassesCurrentUserList(this.classes.id)
|
this.getStudentList()
|
},
|
methods: {
|
getClassesCurrentUserList(classesId) {
|
let param = {
|
classesId: classesId
|
}
|
UserApi.getClassesCurrentUserList(param).then(res => {
|
this.classes.studentList = res.data
|
})
|
},
|
getStudentList() {
|
UserApi.studentList().then(res => {
|
this.studentList = res.data;
|
})
|
},
|
// 获取当前班级学员分页
|
page() {
|
this.searchForm.classesId = this.classes.id
|
getClassesUsers(this.searchForm).then(res => {
|
this.tableData = res.data.data
|
})
|
},
|
submitForm() {
|
updateClassesUser(this.classes).then(res => {
|
this.$message.success(res.data.message)
|
this.classesStudentPage();
|
})
|
},
|
handleClose() {
|
|
},
|
filterMethod(query, item) {
|
return item.realName.indexOf(query) > -1;
|
},
|
// 返回上一个页面
|
goBack() {
|
this.$router.back();
|
},
|
// 修改表单头部的颜色
|
getRowClass() {
|
return "background:#d2d3d6";
|
},
|
|
// 生成试卷
|
getCreate() {
|
// 跳转到生成页面
|
//跳转到对应的管理页面
|
this.$router.push({
|
path: "/manage/test-paper-generation",
|
});
|
},
|
|
// 点击后调用弹窗组件的方法,开启弹窗
|
getDialogFormVisible() {
|
this.$refs.popUp.showDialog();
|
},
|
// 弹窗
|
// 接收弹窗组件返回的表单值
|
parentGoods(obj) {
|
console.log(obj, "弹窗组件的表单值");
|
},
|
},
|
};
|
</script>
|
<style scoped lang="scss">
|
.flex {
|
display: flex;
|
}
|
// 内容
|
.content {
|
width: 1262px;
|
margin-bottom: 80px;
|
background-color: #fff;
|
padding: 20px 40px;
|
border-radius: 10px;
|
}
|
</style>
|