|
@@ -1,7 +1,7 @@
|
|
<template>
|
|
<template>
|
|
<div id="director-arrange">
|
|
<div id="director-arrange">
|
|
<detail-frame :title="pageTitle">
|
|
<detail-frame :title="pageTitle">
|
|
- <el-row type="flex" align="middle" justify="end" style="padding-bottom:10px">
|
|
|
|
|
|
+ <el-row type="flex" align="middle" justify="end" style="padding-bottom:10px" v-if="!loading">
|
|
<el-col :span="2">
|
|
<el-col :span="2">
|
|
<el-button type="success" size="mini" @click="toSave">保存班主任计划</el-button>
|
|
<el-button type="success" size="mini" @click="toSave">保存班主任计划</el-button>
|
|
</el-col>
|
|
</el-col>
|
|
@@ -9,10 +9,33 @@
|
|
<el-button type="primary" size="mini" @click="toArrange">一键分配</el-button>
|
|
<el-button type="primary" size="mini" @click="toArrange">一键分配</el-button>
|
|
</el-col>
|
|
</el-col>
|
|
</el-row>
|
|
</el-row>
|
|
- <data-table v-loading="loading" :fields="fields" :data="classList" :opera="opera" @edit="toEdit" :toFormat="toFormat"></data-table>
|
|
|
|
|
|
+ <!-- <data-table v-loading="loading" :fields="fields" :data="classList" :opera="opera" @edit="toEdit" :toFormat="toFormat"></data-table> -->
|
|
|
|
+ <el-table :data="classList" border stripe v-loading="loading">
|
|
|
|
+ <el-table-column align="center" type="expand">
|
|
|
|
+ <template v-slot="{ row }">
|
|
|
|
+ <el-table :data="row.data" border stripe>
|
|
|
|
+ <el-table-column align="center" type="expand">
|
|
|
|
+ <template v-slot="{ row: batRow }">
|
|
|
|
+ <el-table :data="batRow.data" border stripe>
|
|
|
|
+ <el-table-column align="center" label="班级" prop="name"></el-table-column>
|
|
|
|
+ <el-table-column align="center" label="班主任" prop="headteacherid" :formatter="toFormat"></el-table-column>
|
|
|
|
+ <el-table-column align="center" label="操作">
|
|
|
|
+ <template v-slot="{ row: claRow }">
|
|
|
|
+ <el-button type="text" size="mini" icon="el-icon-edit" @click="toEdit(claRow)"></el-button>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ </el-table>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column align="center" label="批" prop="batch"></el-table-column>
|
|
|
|
+ </el-table>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column align="center" label="期" prop="term"></el-table-column>
|
|
|
|
+ </el-table>
|
|
</detail-frame>
|
|
</detail-frame>
|
|
<el-dialog title="选择班主任" :visible.sync="dialog" width="20%">
|
|
<el-dialog title="选择班主任" :visible.sync="dialog" width="20%">
|
|
- <data-form :data="form" :fields="fields" :rules="{}" @save="handleSave">
|
|
|
|
|
|
+ <data-form :data="form" :fields="fields" :rules="{}" @save="handleSave" :reset="false">
|
|
<template #options="{item,form}">
|
|
<template #options="{item,form}">
|
|
<template v-if="item.model == 'headteacherid'">
|
|
<template v-if="item.model == 'headteacherid'">
|
|
<el-option-group v-for="(dept, index) in htList" :label="dept.name" :key="index">
|
|
<el-option-group v-for="(dept, index) in htList" :label="dept.name" :key="index">
|
|
@@ -40,7 +63,7 @@ export default {
|
|
props: {
|
|
props: {
|
|
// events: { type: Array, default: () => [] },
|
|
// events: { type: Array, default: () => [] },
|
|
},
|
|
},
|
|
- components: { dataTable, dataForm, detailFrame },
|
|
|
|
|
|
+ components: { dataForm, detailFrame }, //dataTable
|
|
data: function() {
|
|
data: function() {
|
|
return {
|
|
return {
|
|
loading: true,
|
|
loading: true,
|
|
@@ -79,34 +102,31 @@ export default {
|
|
if (!planid) return;
|
|
if (!planid) return;
|
|
let res = await this.query({ planid });
|
|
let res = await this.query({ planid });
|
|
if (this.$checkRes(res)) {
|
|
if (this.$checkRes(res)) {
|
|
- //现在应该不需要过滤班的batch和term了,返回应该有
|
|
|
|
- // let arr = res.data.map(i => {
|
|
|
|
- // let e = this.events.find(f => f.termid == i.termid && f._id == i.batchid);
|
|
|
|
- // if (e) {
|
|
|
|
- // i.term = _.get(e, `term`);
|
|
|
|
- // i.batch = _.get(e, `batch`);
|
|
|
|
- // }
|
|
|
|
- // return i;
|
|
|
|
- // });
|
|
|
|
- // arr = _.reverse(arr.sort((a, b) => a.term - b.term && a.batch - b.batch));
|
|
|
|
- // this.$set(this, `classList`, arr);
|
|
|
|
|
|
+ let arr = this.resetList(res.data);
|
|
|
|
+ this.$set(this, `classList`, arr);
|
|
this.loading = false;
|
|
this.loading = false;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
async toArrange() {
|
|
async toArrange() {
|
|
|
|
+ let msg = this.$message({ message: '正在分配班主任,请稍后', duration: 0 });
|
|
this.loading = true;
|
|
this.loading = true;
|
|
- let res = await this.divide({ trainplanid: this.id });
|
|
|
|
|
|
+ let duplicate = this.returnList();
|
|
|
|
+ let planid = _.get(this.defaultOption, `planid`);
|
|
|
|
+ let res = await this.divide({ trainplanid: planid });
|
|
if (this.$checkRes(res)) {
|
|
if (this.$checkRes(res)) {
|
|
- let arr = this.classList.map(i => {
|
|
|
|
|
|
+ let arr = duplicate.map(i => {
|
|
let r = res.data.find(f => f.classid == i._id);
|
|
let r = res.data.find(f => f.classid == i._id);
|
|
if (r) i.headteacherid = r.headteacherid;
|
|
if (r) i.headteacherid = r.headteacherid;
|
|
return i;
|
|
return i;
|
|
});
|
|
});
|
|
|
|
+ arr = this.resetList(arr);
|
|
this.$set(this, `classList`, arr);
|
|
this.$set(this, `classList`, arr);
|
|
}
|
|
}
|
|
this.loading = false;
|
|
this.loading = false;
|
|
|
|
+ msg.close();
|
|
|
|
+ this.$checkRes(res, '分配完成', res.errmsg);
|
|
},
|
|
},
|
|
- async toEdit({ data, index }) {
|
|
|
|
|
|
+ async toEdit(data) {
|
|
let res = await this.findTeacher({ planid: data.planid, termid: data.termid, batchid: data.batchid });
|
|
let res = await this.findTeacher({ planid: data.planid, termid: data.termid, batchid: data.batchid });
|
|
if (this.$checkRes(res)) {
|
|
if (this.$checkRes(res)) {
|
|
let group = _.groupBy(res.data, 'department');
|
|
let group = _.groupBy(res.data, 'department');
|
|
@@ -123,15 +143,15 @@ export default {
|
|
this.$set(this, `htList`, arr);
|
|
this.$set(this, `htList`, arr);
|
|
}
|
|
}
|
|
this.dialog = true;
|
|
this.dialog = true;
|
|
- this.$set(this, `form`, { ...JSON.parse(JSON.stringify(data)), index });
|
|
|
|
|
|
+ this.$set(this, `form`, data);
|
|
},
|
|
},
|
|
handleSave({ data }) {
|
|
handleSave({ data }) {
|
|
- let { index, ...info } = data;
|
|
|
|
- this.$set(this.classList, index, info);
|
|
|
|
|
|
+ // let { index, ...info } = data;
|
|
|
|
+ // this.$set(this.classList, index, info);
|
|
this.dialog = false;
|
|
this.dialog = false;
|
|
},
|
|
},
|
|
async toSave() {
|
|
async toSave() {
|
|
- let data = JSON.parse(JSON.stringify(this.classList));
|
|
|
|
|
|
+ let data = JSON.parse(JSON.stringify(this.returnList()));
|
|
let res = await this.upHeadTea(data);
|
|
let res = await this.upHeadTea(data);
|
|
this.$checkRes(res, '保存成功', res.errmsg || '保存失败');
|
|
this.$checkRes(res, '保存成功', res.errmsg || '保存失败');
|
|
},
|
|
},
|
|
@@ -141,12 +161,30 @@ export default {
|
|
res = await this.getDirList();
|
|
res = await this.getDirList();
|
|
if (this.$checkRes(res)) this.$set(this, `dirList`, res.data);
|
|
if (this.$checkRes(res)) this.$set(this, `dirList`, res.data);
|
|
},
|
|
},
|
|
- toFormat({ model, value }) {
|
|
|
|
|
|
+ toFormat(row, column, cellValue) {
|
|
|
|
+ let model = _.get(column, 'property');
|
|
if (model == 'headteacherid') {
|
|
if (model == 'headteacherid') {
|
|
- let r = this.dirList.find(f => f._id == value);
|
|
|
|
|
|
+ let r = this.dirList.find(f => f._id == cellValue);
|
|
if (r) return r.name;
|
|
if (r) return r.name;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ resetList(data, prop = 'term') {
|
|
|
|
+ let duplicate = _.groupBy(_.cloneDeep(data), prop);
|
|
|
|
+ let keys = Object.keys(duplicate);
|
|
|
|
+ let arr = keys.map(key => {
|
|
|
|
+ let obj = {};
|
|
|
|
+ obj[prop] = key;
|
|
|
|
+ if (prop == 'term') obj.data = this.resetList(duplicate[key], 'batch');
|
|
|
|
+ else obj.data = duplicate[key];
|
|
|
|
+ return obj;
|
|
|
|
+ });
|
|
|
|
+ return arr;
|
|
|
|
+ },
|
|
|
|
+ returnList() {
|
|
|
|
+ let duplicate = _.cloneDeep(this.classList);
|
|
|
|
+ let arr = _.flattenDeep(duplicate.map(i => i.data.map(i => i.data)));
|
|
|
|
+ return arr;
|
|
|
|
+ },
|
|
},
|
|
},
|
|
watch: {
|
|
watch: {
|
|
defaultOption: {
|
|
defaultOption: {
|