|
@@ -2,14 +2,19 @@
|
|
|
<div id="index">
|
|
|
<list-frame title="学生管理" @query="search" :total="total" :needFilter="false" @add="$router.push({ path: '/student/detail' })">
|
|
|
<el-form :inline="true" size="mini">
|
|
|
- <el-form-item label="选择计划">
|
|
|
- <el-select v-model="searchInfo.planid" @change="getTerm" clearable>
|
|
|
- <el-option v-for="(i, index) in planList" :key="index" :label="i.title" :value="i.id"></el-option>
|
|
|
+ <el-form-item label="期">
|
|
|
+ <el-select v-model="form.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="searchInfo.termid" clearable>
|
|
|
- <el-option v-for="(i, index) in termList" :key="index" :label="i.term" :value="i._id"></el-option>
|
|
|
+ <el-form-item label="批次">
|
|
|
+ <el-select v-model="form.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="form.classid" placeholder="请先选择批次">
|
|
|
+ <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-item>
|
|
@@ -24,8 +29,9 @@
|
|
|
<script>
|
|
|
import listFrame from '@frame/layout/admin/list-frame';
|
|
|
import dataTable from '@frame/components/data-table';
|
|
|
-import { createNamespacedHelpers } from 'vuex';
|
|
|
+import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
const { mapActions } = createNamespacedHelpers('student');
|
|
|
+const { mapActions: classes } = createNamespacedHelpers('classes');
|
|
|
const { mapActions: trainplan } = createNamespacedHelpers('trainplan');
|
|
|
|
|
|
export default {
|
|
@@ -64,23 +70,26 @@ export default {
|
|
|
{ label: '手机号', prop: 'phone' },
|
|
|
{ label: '邮箱', prop: 'email' },
|
|
|
],
|
|
|
+ form: {},
|
|
|
searchInfo: {},
|
|
|
list: [],
|
|
|
- planList: [],
|
|
|
+ classList: [],
|
|
|
+ batchList: [],
|
|
|
termList: [],
|
|
|
total: 0,
|
|
|
}),
|
|
|
created() {
|
|
|
this.getPlan();
|
|
|
},
|
|
|
- computed: {},
|
|
|
+ computed: { ...mapState(['user', 'defaultOption']) },
|
|
|
methods: {
|
|
|
- ...trainplan({ getPlanList: 'query' }),
|
|
|
+ ...trainplan({ planfetch: 'fetch' }),
|
|
|
...mapActions(['query', 'delete']),
|
|
|
+ ...classes({ classesquery: 'query' }),
|
|
|
async search({ skip = 0, limit = 10, ...info } = {}) {
|
|
|
- let data;
|
|
|
- this.searchInfo.termid && this.searchInfo.termid !== '' ? (data = { termid: this.searchInfo.termid }) : '';
|
|
|
- const res = await this.query({ skip, limit, ...data });
|
|
|
+ //let data;
|
|
|
+ // this.searchInfo.termid && this.searchInfo.termid !== '' ? (data = { termid: this.searchInfo.termid }) : '';
|
|
|
+ const res = await this.query({ skip, limit, termid: this.form.termid, classid: this.form.classid });
|
|
|
if (this.$checkRes(res)) {
|
|
|
this.$set(this, `list`, res.data);
|
|
|
this.$set(this, `total`, res.total);
|
|
@@ -95,13 +104,33 @@ export default {
|
|
|
this.search();
|
|
|
},
|
|
|
async getPlan() {
|
|
|
- let res = await this.getPlanList();
|
|
|
- if (res.errcode === 0) this.$set(this, `planList`, res.data);
|
|
|
+ const res = await this.planfetch(this.defaultOption.planid);
|
|
|
+ let terms = res.data.termnum;
|
|
|
+ this.$set(this, `termList`, terms);
|
|
|
+ if (this.defaultOption.termid) {
|
|
|
+ this.form.termid = this.defaultOption.termid;
|
|
|
+ this.getBatch(this.form.termid);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getBatch(termid) {
|
|
|
+ let batchs = this.termList.filter(f => f._id === termid);
|
|
|
+ if (batchs.length > 0) {
|
|
|
+ let { batchnum } = batchs[0];
|
|
|
+ this.$set(this, `batchList`, batchnum);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async getClasses(batchid) {
|
|
|
+ const res = await this.classesquery({ batchid });
|
|
|
+ this.$set(this, `classList`, res.data);
|
|
|
},
|
|
|
- getTerm(data) {
|
|
|
- let term = this.planList.find(f => f.id === data);
|
|
|
- if (term) this.$set(this, `termList`, term.termnum);
|
|
|
- else this.$set(this, `termList`, []);
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ defaultOption: {
|
|
|
+ handler(val) {
|
|
|
+ this.form.termid = this.defaultOption.termid;
|
|
|
+ this.getBatch(this.form.termid);
|
|
|
+ },
|
|
|
+ deep: true,
|
|
|
},
|
|
|
},
|
|
|
};
|