|
@@ -1,29 +1,45 @@
|
|
<template>
|
|
<template>
|
|
<div id="name-list">
|
|
<div id="name-list">
|
|
- <list-frame :title="pageTitle" @query="classSearch" :total="total" :needAdd="false" :needFilter="false" returns="./index">
|
|
|
|
|
|
+ <list-frame :title="pageTitle" @query="getStudent" :total="total" :needAdd="false" :needFilter="false" returns="./index">
|
|
<el-card style="padding:10px">
|
|
<el-card style="padding:10px">
|
|
<el-row>
|
|
<el-row>
|
|
- <el-form :inline="true" size="mini">
|
|
|
|
- <el-form-item label="期">
|
|
|
|
- <el-select v-model="selectInfo.termid" placeholder="请选择期数" @change="getBatch">
|
|
|
|
- <el-option v-for="(i, index) in termList" :key="index" :label="`第${i.term}期`" :value="i._id"></el-option>
|
|
|
|
- </el-select>
|
|
|
|
- </el-form-item>
|
|
|
|
- <el-form-item label="批次">
|
|
|
|
- <el-select v-model="selectInfo.batchid" placeholder="请先选择期数" @change="getClasses">
|
|
|
|
- <el-option v-for="(i, index) in batchList" :key="index" :label="i.name" :value="i._id"></el-option>
|
|
|
|
- </el-select>
|
|
|
|
- </el-form-item>
|
|
|
|
- <el-form-item label="班级">
|
|
|
|
- <el-select v-model="selectInfo.classname" placeholder="请先选择批次" @change="getStudent">
|
|
|
|
- <el-option v-for="(i, index) in classList" :key="index" :label="i.name" :value="i._id"></el-option>
|
|
|
|
- </el-select>
|
|
|
|
- </el-form-item>
|
|
|
|
- </el-form>
|
|
|
|
|
|
+ <el-col :span="20">
|
|
|
|
+ <el-form :inline="true" size="mini">
|
|
|
|
+ <el-form-item label="期">
|
|
|
|
+ <el-select v-model="selectInfo.termid" placeholder="请选择期数" @change="getBatch">
|
|
|
|
+ <el-option v-for="(i, index) in termList" :key="index" :label="`第${i.term}期`" :value="i._id"></el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="批次">
|
|
|
|
+ <el-select v-model="selectInfo.batchid" placeholder="请先选择期数" @change="getClasses">
|
|
|
|
+ <el-option v-for="(i, index) in batchList" :key="index" :label="i.name" :value="i._id"></el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="班级">
|
|
|
|
+ <el-select v-model="selectInfo.classid" placeholder="请先选择批次" @change="getStudent()">
|
|
|
|
+ <el-option v-for="(i, index) in classList" :key="index" :label="i.name" :value="i._id"></el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-form>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="2">
|
|
|
|
+ <el-button type="danger" plain @click="toDelete" size="mini" v-if="list.length > 0" :disabled="selected.length <= 0">
|
|
|
|
+ {{ selected.length > 0 ? `将选中的 ${selected.length}名学生 从班级移除` : '请选择要从班级移除的学生' }}
|
|
|
|
+ </el-button>
|
|
|
|
+ </el-col>
|
|
</el-row>
|
|
</el-row>
|
|
- <data-table :fields="fields" :data="list" :opera="opera" @turn="toTurn" @delete="toDelete"></data-table>
|
|
|
|
|
|
+ <data-table :fields="fields" :select="true" :selected="selected" @handleSelect="toSelect" :data="list" :opera="opera" @turn="toTurn"></data-table>
|
|
</el-card>
|
|
</el-card>
|
|
</list-frame>
|
|
</list-frame>
|
|
|
|
+ <el-dialog :visible.sync="dialog" title="转班" @close="toClose" width="30%">
|
|
|
|
+ <data-form :data="form" :fields="turnFields" :rules="{}" @save="turnSave">
|
|
|
|
+ <template #options="{item,form}">
|
|
|
|
+ <template v-if="item.model == 'classid'">
|
|
|
|
+ <el-option v-for="(i, index) in allTermClass" :key="index" :label="`第${i.batch}批-${i.name}`" :value="i._id"></el-option>
|
|
|
|
+ </template>
|
|
|
|
+ </template>
|
|
|
|
+ </data-form>
|
|
|
|
+ </el-dialog>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
@@ -31,6 +47,7 @@
|
|
import _ from 'lodash';
|
|
import _ from 'lodash';
|
|
import listFrame from '@frame/layout/admin/list-frame';
|
|
import listFrame from '@frame/layout/admin/list-frame';
|
|
import dataTable from '@frame/components/data-table';
|
|
import dataTable from '@frame/components/data-table';
|
|
|
|
+import dataForm from '@frame/components/form';
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
const { mapActions: trainPlan } = createNamespacedHelpers('trainplan');
|
|
const { mapActions: trainPlan } = createNamespacedHelpers('trainplan');
|
|
const { mapActions: classes } = createNamespacedHelpers('classes');
|
|
const { mapActions: classes } = createNamespacedHelpers('classes');
|
|
@@ -38,12 +55,15 @@ const { mapActions: student } = createNamespacedHelpers('student');
|
|
export default {
|
|
export default {
|
|
name: 'name-list',
|
|
name: 'name-list',
|
|
props: {},
|
|
props: {},
|
|
- components: { listFrame, dataTable },
|
|
|
|
|
|
+ components: { listFrame, dataTable, dataForm },
|
|
data: function() {
|
|
data: function() {
|
|
return {
|
|
return {
|
|
|
|
+ dialog: false,
|
|
|
|
+ form: {},
|
|
termList: [],
|
|
termList: [],
|
|
batchList: [],
|
|
batchList: [],
|
|
classList: [],
|
|
classList: [],
|
|
|
|
+ allTermClass: [],
|
|
list: [],
|
|
list: [],
|
|
opera: [
|
|
opera: [
|
|
{
|
|
{
|
|
@@ -51,29 +71,26 @@ export default {
|
|
icon: 'el-icon-refresh',
|
|
icon: 'el-icon-refresh',
|
|
method: 'turn',
|
|
method: 'turn',
|
|
},
|
|
},
|
|
- {
|
|
|
|
- label: '移除该班',
|
|
|
|
- icon: 'el-icon-delete',
|
|
|
|
- method: 'delete',
|
|
|
|
- confirm: true,
|
|
|
|
- },
|
|
|
|
],
|
|
],
|
|
fields: [
|
|
fields: [
|
|
{ label: '姓名', prop: 'name' },
|
|
{ label: '姓名', prop: 'name' },
|
|
{ label: '性别', prop: 'gender' },
|
|
{ label: '性别', prop: 'gender' },
|
|
{ label: '民族', prop: 'nation' },
|
|
{ label: '民族', prop: 'nation' },
|
|
{ label: '身份证号', prop: 'id_number' },
|
|
{ label: '身份证号', prop: 'id_number' },
|
|
- { label: '期', prop: 'term' },
|
|
|
|
- { label: '批次', prop: 'batch' },
|
|
|
|
- { label: '班级', prop: 'class' },
|
|
|
|
{ label: '学校', prop: 'school_name' },
|
|
{ label: '学校', prop: 'school_name' },
|
|
{ label: '院系', prop: 'faculty' },
|
|
{ label: '院系', prop: 'faculty' },
|
|
{ label: '专业', prop: 'major' },
|
|
{ label: '专业', prop: 'major' },
|
|
{ label: '手机号', prop: 'phone' },
|
|
{ label: '手机号', prop: 'phone' },
|
|
{ label: '邮箱', prop: 'email' },
|
|
{ label: '邮箱', prop: 'email' },
|
|
],
|
|
],
|
|
|
|
+ turnFields: [
|
|
|
|
+ { label: '姓名', model: 'name', type: 'text' },
|
|
|
|
+ { label: '学校', model: 'school_name', type: 'text' },
|
|
|
|
+ { label: '班级', model: 'classid', type: 'select' },
|
|
|
|
+ ],
|
|
selectInfo: {},
|
|
selectInfo: {},
|
|
total: 0,
|
|
total: 0,
|
|
|
|
+ selected: [],
|
|
};
|
|
};
|
|
},
|
|
},
|
|
created() {
|
|
created() {
|
|
@@ -82,7 +99,7 @@ export default {
|
|
methods: {
|
|
methods: {
|
|
...trainPlan(['fetch']),
|
|
...trainPlan(['fetch']),
|
|
...classes({ getClassesList: 'query' }),
|
|
...classes({ getClassesList: 'query' }),
|
|
- ...student({ getStudentList: 'query' }),
|
|
|
|
|
|
+ ...student({ getStudentList: 'query', updateStudent: 'update', removeClass: 'removeClass' }),
|
|
async search({ skip = 0, limit = 10, ...info } = {}) {
|
|
async search({ skip = 0, limit = 10, ...info } = {}) {
|
|
const res = await this.fetch(this.id);
|
|
const res = await this.fetch(this.id);
|
|
if (this.$checkRes(res)) {
|
|
if (this.$checkRes(res)) {
|
|
@@ -104,12 +121,63 @@ export default {
|
|
this.$set(this, `classList`, res.data);
|
|
this.$set(this, `classList`, res.data);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- async getStudent(batchid) {
|
|
|
|
- let res = await this.getStudentList({ batchid });
|
|
|
|
|
|
+ async getStudent({ skip = 0, limit = 10, ...info } = {}) {
|
|
|
|
+ let res = await this.getStudentList({ classid: this.selectInfo.classid, skip, limit, ...info });
|
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
|
+ this.$set(this, `list`, res.data);
|
|
|
|
+ this.$set(this, `total`, res.total);
|
|
|
|
+ }
|
|
},
|
|
},
|
|
async classSearch({ skip = 0, limit = 10, ...info } = {}) {},
|
|
async classSearch({ skip = 0, limit = 10, ...info } = {}) {},
|
|
- toTurn({ data }) {},
|
|
|
|
- toDelete({ data }) {},
|
|
|
|
|
|
+ toTurn({ data }) {
|
|
|
|
+ let duplicate = _.cloneDeep(data);
|
|
|
|
+ let batch = this.batchList.find(f => f._id == data.batchid);
|
|
|
|
+ if (batch) duplicate.batch = batch.batch;
|
|
|
|
+ this.$set(this, `form`, duplicate);
|
|
|
|
+ this.dialog = true;
|
|
|
|
+ this.getAllTermClass();
|
|
|
|
+ },
|
|
|
|
+ async turnSave({ data }) {
|
|
|
|
+ let res = await this.updateStudent(data);
|
|
|
|
+ if (this.$checkRes(res, '转班成功', res.errmsg || '转班失败')) {
|
|
|
|
+ this.getStudent();
|
|
|
|
+ this.toClose();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ async toDelete() {
|
|
|
|
+ if (this.selected.length <= 0) {
|
|
|
|
+ this.$message.warning('您没有选择要移出该班的学生');
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ this.$confirm('您确定要从该班移除这些学生吗?', '移出班级', {
|
|
|
|
+ confirmButtonText: '确定',
|
|
|
|
+ cancelButtonText: '取消',
|
|
|
|
+ type: 'warning',
|
|
|
|
+ }).then(async () => {
|
|
|
|
+ let ids = this.selected.map(i => i._id);
|
|
|
|
+ let res = await this.removeClass(ids);
|
|
|
|
+ if (this.$checkRes(res, '移除成功', res.errmsg || '移除失败')) this.getStudent();
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ async getAllTermClass() {
|
|
|
|
+ let res = await this.getClassesList({ termid: this.selectInfo.termid });
|
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
|
+ let duplicate = _.cloneDeep(res.data);
|
|
|
|
+ duplicate = duplicate.map(i => {
|
|
|
|
+ let r = this.batchList.find(bf => bf._id == i.batchid);
|
|
|
|
+ if (r) i.batch = r.batch;
|
|
|
|
+ return i;
|
|
|
|
+ });
|
|
|
|
+ this.$set(this, `allTermClass`, duplicate);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ toClose() {
|
|
|
|
+ this.dialog = false;
|
|
|
|
+ this.form = {};
|
|
|
|
+ },
|
|
|
|
+ toSelect(selecteds) {
|
|
|
|
+ this.$set(this, `selected`, selecteds);
|
|
|
|
+ },
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
...mapState(['user']),
|
|
...mapState(['user']),
|