|
@@ -28,15 +28,27 @@
|
|
|
</el-button>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
- <data-table :fields="fields" :select="true" :selected="selected" @handleSelect="toSelect" :data="list" :opera="opera" @turn="toTurn"></data-table>
|
|
|
+ <data-table
|
|
|
+ :fields="fields"
|
|
|
+ :select="true"
|
|
|
+ :selected="selected"
|
|
|
+ @handleSelect="toSelect"
|
|
|
+ :data="list"
|
|
|
+ :opera="opera"
|
|
|
+ @turn="toTurn"
|
|
|
+ @turnBedroom="turnBed"
|
|
|
+ ></data-table>
|
|
|
</el-card>
|
|
|
</list-frame>
|
|
|
- <el-dialog :visible.sync="dialog" title="转班" @close="toClose" width="30%">
|
|
|
- <data-form :data="form" :fields="turnFields" :rules="{}" @save="turnSave">
|
|
|
+ <el-dialog :visible.sync="dialog" :title="dtitle == 0 ? '转班' : '转寝'" @close="toClose" width="30%">
|
|
|
+ <data-form :data="form" :fields="dtitle == 0 ? turnFields : turnBedRoomFields" :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 v-if="item.model == 'bedroomid'">
|
|
|
+ <el-option v-for="(i, index) in bedroomList" :key="index" :label="`${i.floor}楼-${i.code}`" :value="i._id"></el-option>
|
|
|
+ </template>
|
|
|
</template>
|
|
|
</data-form>
|
|
|
</el-dialog>
|
|
@@ -52,6 +64,7 @@ import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
const { mapActions: trainPlan } = createNamespacedHelpers('trainplan');
|
|
|
const { mapActions: classes } = createNamespacedHelpers('classes');
|
|
|
const { mapActions: student } = createNamespacedHelpers('student');
|
|
|
+const { mapActions: bedroom } = createNamespacedHelpers('bedroom');
|
|
|
export default {
|
|
|
name: 'name-list',
|
|
|
props: {},
|
|
@@ -59,17 +72,25 @@ export default {
|
|
|
data: function() {
|
|
|
return {
|
|
|
dialog: false,
|
|
|
+ dtitle: 0,
|
|
|
form: {},
|
|
|
termList: [],
|
|
|
batchList: [],
|
|
|
classList: [],
|
|
|
allTermClass: [],
|
|
|
+ bedroomList: [],
|
|
|
list: [],
|
|
|
opera: [
|
|
|
{
|
|
|
label: '转班',
|
|
|
icon: 'el-icon-refresh',
|
|
|
method: 'turn',
|
|
|
+ display: i => !i.openid,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '转寝',
|
|
|
+ icon: 'el-icon-s-home',
|
|
|
+ method: 'turnBedroom',
|
|
|
},
|
|
|
],
|
|
|
fields: [
|
|
@@ -88,6 +109,12 @@ export default {
|
|
|
{ label: '学校', model: 'school_name', type: 'text' },
|
|
|
{ label: '班级', model: 'classid', type: 'select' },
|
|
|
],
|
|
|
+ turnBedRoomFields: [
|
|
|
+ { label: '姓名', model: 'name', type: 'text' },
|
|
|
+ { label: '学校', model: 'school_name', type: 'text' },
|
|
|
+ { label: '寝室', model: 'bedroomid', type: 'select' },
|
|
|
+ { label: '原寝室', model: 'bedroom', type: 'text' },
|
|
|
+ ],
|
|
|
selectInfo: {},
|
|
|
total: 0,
|
|
|
selected: [],
|
|
@@ -97,6 +124,7 @@ export default {
|
|
|
this.search();
|
|
|
},
|
|
|
methods: {
|
|
|
+ ...bedroom({ getBedroom: 'query' }),
|
|
|
...trainPlan(['fetch']),
|
|
|
...classes({ getClassesList: 'query' }),
|
|
|
...student({ getStudentList: 'query', updateStudent: 'update', removeClass: 'removeClass' }),
|
|
@@ -121,6 +149,7 @@ export default {
|
|
|
this.$set(this, `classList`, res.data);
|
|
|
}
|
|
|
},
|
|
|
+ //查询学生列表
|
|
|
async getStudent({ skip = 0, limit = 10, ...info } = {}) {
|
|
|
let res = await this.getStudentList({ classid: this.selectInfo.classid, skip, limit, ...info });
|
|
|
if (this.$checkRes(res)) {
|
|
@@ -128,18 +157,36 @@ export default {
|
|
|
this.$set(this, `total`, res.total);
|
|
|
}
|
|
|
},
|
|
|
- async classSearch({ skip = 0, limit = 10, ...info } = {}) {},
|
|
|
+ //转班按钮
|
|
|
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.dtitle = 0;
|
|
|
this.dialog = true;
|
|
|
this.getAllTermClass();
|
|
|
},
|
|
|
+ //转寝
|
|
|
+ async turnBed({ data }) {
|
|
|
+ if (this.bedroomList.length <= 0) {
|
|
|
+ let br = await this.getBedroom();
|
|
|
+ if (this.$checkRes(br)) this.$set(this, `bedroomList`, br.data);
|
|
|
+ }
|
|
|
+ let duplicate = _.cloneDeep(data);
|
|
|
+ this.$set(this, `form`, duplicate);
|
|
|
+ this.dtitle = 1;
|
|
|
+ this.dialog = true;
|
|
|
+ },
|
|
|
+ //转班/寝保存
|
|
|
async turnSave({ data }) {
|
|
|
+ if (this.dtitle == 1) {
|
|
|
+ let br = this.bedroomList.find(f => f.bedroomid == data.bedroomid);
|
|
|
+ if (br) data.bedroom = br.code;
|
|
|
+ }
|
|
|
+ let msg = this.dtitle == 0 ? '转班' : '转寝';
|
|
|
let res = await this.updateStudent(data);
|
|
|
- if (this.$checkRes(res, '转班成功', res.errmsg || '转班失败')) {
|
|
|
+ if (this.$checkRes(res, `${msg}成功`, res.errmsg || `${msg}失败`)) {
|
|
|
this.getStudent();
|
|
|
this.toClose();
|
|
|
}
|
|
@@ -156,7 +203,10 @@ export default {
|
|
|
}).then(async () => {
|
|
|
let ids = this.selected.map(i => i._id);
|
|
|
let res = await this.removeClass(ids);
|
|
|
- if (this.$checkRes(res, '移除成功', res.errmsg || '移除失败')) this.getStudent();
|
|
|
+ if (this.$checkRes(res, '移除成功', res.errmsg || '移除失败')) {
|
|
|
+ this.selected = [];
|
|
|
+ this.getStudent();
|
|
|
+ }
|
|
|
});
|
|
|
},
|
|
|
async getAllTermClass() {
|