|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<div id="director-arrange">
|
|
|
<detail-frame :title="pageTitle">
|
|
|
- <el-row type="flex" align="middle" justify="end" style="padding-bottom:10px" v-if="!loading">
|
|
|
+ <el-row type="flex" align="middle" justify="end" style="padding-bottom:10px" v-if="loading">
|
|
|
<el-col :span="2">
|
|
|
<el-button type="success" size="mini" @click="toSave">保存班主任计划</el-button>
|
|
|
</el-col>
|
|
@@ -9,42 +9,28 @@
|
|
|
<el-button type="primary" size="mini" @click="toArrange">一键分配</el-button>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
- <!-- <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>
|
|
|
+ <el-row>
|
|
|
+ <el-table :data="list" border :span-method="objectSpanMethod">
|
|
|
+ <el-table-column label="期数" prop="term1" align="center"> </el-table-column>
|
|
|
+ <el-table-column label="班级数" prop="class" align="center"> </el-table-column>
|
|
|
+ <el-table-column label="时间" prop="date" align="center"> </el-table-column>
|
|
|
+ <el-table-column v-for="info in rightHeader" :prop="info.id" :key="info.id" :label="info.name" align="center">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ {{ scope.row[scope.row.id] }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="督导值班" prop="term7" align="center">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-input v-model="scope.row.term7" placeholder="请输入"></el-input>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="月份" prop="month" align="center"> </el-table-column>
|
|
|
+ <el-table-column label="班级总数" prop="num" align="center">
|
|
|
+ <template v-slot="{ row }">{{ classNum(row.date) }}</template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </el-row>
|
|
|
</detail-frame>
|
|
|
- <el-dialog title="选择班主任" :visible.sync="dialog" width="20%">
|
|
|
- <data-form :data="form" :fields="fields" :rules="{}" @save="handleSave" :reset="false">
|
|
|
- <template #options="{item,form}">
|
|
|
- <template v-if="item.model == 'headteacherid'">
|
|
|
- <el-option-group v-for="(dept, index) in htList" :label="dept.name" :key="index">
|
|
|
- <el-option v-for="(i, tIndex) in dept.list" :key="`${index}-${tIndex}`" :label="i.name" :value="i._id"></el-option>
|
|
|
- </el-option-group>
|
|
|
- </template>
|
|
|
- </template>
|
|
|
- </data-form>
|
|
|
- </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -58,32 +44,206 @@ const { mapActions } = createNamespacedHelpers('teaPlan');
|
|
|
const { mapActions: classes } = createNamespacedHelpers('classes');
|
|
|
const { mapActions: mapDept } = createNamespacedHelpers('dept');
|
|
|
const { mapActions: director } = createNamespacedHelpers('director');
|
|
|
+var moment = require('moment');
|
|
|
export default {
|
|
|
name: 'director-arrange',
|
|
|
props: {
|
|
|
// events: { type: Array, default: () => [] },
|
|
|
},
|
|
|
- components: { dataForm, detailFrame }, //dataTable
|
|
|
+ components: { detailFrame }, //dataTable
|
|
|
data: function() {
|
|
|
return {
|
|
|
loading: true,
|
|
|
- dialog: false,
|
|
|
- form: {},
|
|
|
- classList: [],
|
|
|
- htList: [],
|
|
|
- dirList: [],
|
|
|
- deptList: [],
|
|
|
- fields: [
|
|
|
- { label: '期', prop: 'term', model: 'term', type: 'text' },
|
|
|
- { label: '批', prop: 'batch', model: 'batch', type: 'text' },
|
|
|
- { label: '班级', prop: 'name', model: 'name', type: 'text' },
|
|
|
- { label: '班主任', prop: 'headteacherid', model: 'headteacherid', type: 'select', format: true }, //
|
|
|
- ],
|
|
|
- opera: [
|
|
|
+ rightHeader: [],
|
|
|
+ list: [
|
|
|
+ {
|
|
|
+ term1: '310',
|
|
|
+ class: '2',
|
|
|
+ date: '3.11-3.16',
|
|
|
+ metting: '',
|
|
|
+ term2: '',
|
|
|
+ term3: '',
|
|
|
+ term4: '',
|
|
|
+ term5: '',
|
|
|
+ term6: '',
|
|
|
+ term7: '',
|
|
|
+ month: '3',
|
|
|
+ num: '',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ term1: '310',
|
|
|
+ class: '2',
|
|
|
+ date: '3.12-3.17',
|
|
|
+ metting: '',
|
|
|
+ term2: '',
|
|
|
+ term3: '',
|
|
|
+ term4: '',
|
|
|
+ term5: '',
|
|
|
+ term6: '',
|
|
|
+ term7: '',
|
|
|
+ month: '3',
|
|
|
+ num: '',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ term1: '310',
|
|
|
+ class: '3',
|
|
|
+ date: '3.13-3.18',
|
|
|
+ metting: '',
|
|
|
+ term2: '',
|
|
|
+ term3: '',
|
|
|
+ term4: '',
|
|
|
+ term5: '',
|
|
|
+ term6: '',
|
|
|
+ term7: '',
|
|
|
+ month: '3',
|
|
|
+ num: '',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ term1: '311',
|
|
|
+ class: '2',
|
|
|
+ date: '3.17-3.22',
|
|
|
+ metting: '',
|
|
|
+ term2: '',
|
|
|
+ term3: '',
|
|
|
+ term4: '',
|
|
|
+ term5: '',
|
|
|
+ term6: '',
|
|
|
+ term7: '',
|
|
|
+ month: '3',
|
|
|
+ num: '',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ term1: '311',
|
|
|
+ class: '2',
|
|
|
+ date: '3.18-3.23',
|
|
|
+ metting: '',
|
|
|
+ term2: '',
|
|
|
+ term3: '',
|
|
|
+ term4: '',
|
|
|
+ term5: '',
|
|
|
+ term6: '',
|
|
|
+ term7: '',
|
|
|
+ month: '3',
|
|
|
+ num: '',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ term1: '311',
|
|
|
+ class: '3',
|
|
|
+ date: '3.19-3.24',
|
|
|
+ metting: '',
|
|
|
+ term2: '',
|
|
|
+ term3: '',
|
|
|
+ term4: '',
|
|
|
+ term5: '',
|
|
|
+ term6: '',
|
|
|
+ term7: '',
|
|
|
+ month: '3',
|
|
|
+ num: '',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ term: '3',
|
|
|
+ term1: '312',
|
|
|
+ class: '2',
|
|
|
+ date: '3.23-3.28',
|
|
|
+ metting: '',
|
|
|
+ term2: '',
|
|
|
+ term3: '',
|
|
|
+ term4: '',
|
|
|
+ term5: '',
|
|
|
+ term6: '',
|
|
|
+ term7: '',
|
|
|
+ month: '3',
|
|
|
+ num: '',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ term: '3',
|
|
|
+ term1: '312',
|
|
|
+ class: '2',
|
|
|
+ date: '3.24-3.29',
|
|
|
+ metting: '',
|
|
|
+ term2: '',
|
|
|
+ term3: '',
|
|
|
+ term4: '',
|
|
|
+ term5: '',
|
|
|
+ term6: '',
|
|
|
+ term7: '',
|
|
|
+ month: '3',
|
|
|
+ num: '',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ term: '3',
|
|
|
+ term1: '312',
|
|
|
+ class: '3',
|
|
|
+ date: '3.25-3.30',
|
|
|
+ metting: '',
|
|
|
+ term2: '',
|
|
|
+ term3: '',
|
|
|
+ term4: '',
|
|
|
+ term5: '',
|
|
|
+ term6: '',
|
|
|
+ term7: '',
|
|
|
+ month: '3',
|
|
|
+ num: '',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ term: '4',
|
|
|
+ term1: '313',
|
|
|
+ class: '2',
|
|
|
+ date: '3.29-4.3',
|
|
|
+ metting: '',
|
|
|
+ term2: '',
|
|
|
+ term3: '',
|
|
|
+ term4: '',
|
|
|
+ term5: '',
|
|
|
+ term6: '',
|
|
|
+ term7: '',
|
|
|
+ month: '3',
|
|
|
+ num: '',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ term: '4',
|
|
|
+ term1: '313',
|
|
|
+ class: '2',
|
|
|
+ date: '3.30-4.4',
|
|
|
+ metting: '',
|
|
|
+ term2: '',
|
|
|
+ term3: '',
|
|
|
+ term4: '',
|
|
|
+ term5: '',
|
|
|
+ term6: '',
|
|
|
+ term7: '',
|
|
|
+ month: '3',
|
|
|
+ num: '',
|
|
|
+ },
|
|
|
{
|
|
|
- label: '选择班主任',
|
|
|
- icon: 'el-icon-edit',
|
|
|
- method: 'edit',
|
|
|
+ term: '5',
|
|
|
+ term1: '314',
|
|
|
+ class: '2',
|
|
|
+ date: '4.1-4.6',
|
|
|
+ metting: '',
|
|
|
+ term2: '',
|
|
|
+ term3: '',
|
|
|
+ term4: '',
|
|
|
+ term5: '',
|
|
|
+ term6: '',
|
|
|
+ term7: '',
|
|
|
+ month: '4',
|
|
|
+ num: '',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ term: '5',
|
|
|
+ term1: '314',
|
|
|
+ class: '2',
|
|
|
+ date: '4.2-4.7',
|
|
|
+ metting: '',
|
|
|
+ term2: '',
|
|
|
+ term3: '',
|
|
|
+ term4: '',
|
|
|
+ term5: '',
|
|
|
+ term6: '',
|
|
|
+ term7: '',
|
|
|
+ month: '4',
|
|
|
+ num: '',
|
|
|
},
|
|
|
],
|
|
|
};
|
|
@@ -97,102 +257,95 @@ export default {
|
|
|
...mapDept({ getDept: 'query' }),
|
|
|
...mapActions(['divide', 'findTeacher']),
|
|
|
...classes(['query', 'upHeadTea']),
|
|
|
+ // 查询部门加班主任
|
|
|
+ async getOtherList() {
|
|
|
+ let res = await this.getDept();
|
|
|
+ if (this.$checkRes(res)) this.$set(this, `rightHeader`, res.data);
|
|
|
+ // res = await this.getDirList();
|
|
|
+ // if (this.$checkRes(res)) this.$set(this, `dirList`, res.data);
|
|
|
+ },
|
|
|
async search() {
|
|
|
let planid = _.get(this.defaultOption, 'planid');
|
|
|
if (!planid) return;
|
|
|
let res = await this.query({ planid });
|
|
|
- if (this.$checkRes(res)) {
|
|
|
- let arr = this.resetList(res.data);
|
|
|
- this.$set(this, `classList`, arr);
|
|
|
- this.loading = false;
|
|
|
- }
|
|
|
+ console.log(res);
|
|
|
},
|
|
|
- async toArrange() {
|
|
|
- let msg = this.$message({ message: '正在分配班主任,请稍后', duration: 0 });
|
|
|
- this.loading = true;
|
|
|
- let duplicate = this.returnList();
|
|
|
- let planid = _.get(this.defaultOption, `planid`);
|
|
|
- let res = await this.divide({ trainplanid: planid });
|
|
|
- if (this.$checkRes(res)) {
|
|
|
- let arr = duplicate.map(i => {
|
|
|
- let r = res.data.find(f => f.classid == i._id);
|
|
|
- if (r) i.headteacherid = r.headteacherid;
|
|
|
+ // 转换
|
|
|
+ ptc(date) {
|
|
|
+ return moment(date).format('YYYY-MM-DD');
|
|
|
+ },
|
|
|
+ // 计算班级数
|
|
|
+ classNum(month) {
|
|
|
+ month = moment(this.ptc(month.split('-')[0])).month() + 1;
|
|
|
+ let newMonth = this.list.map(i => {
|
|
|
+ i.month = moment(this.ptc(i.date.split('-')[0])).month() + 1;
|
|
|
+ return i;
|
|
|
+ });
|
|
|
+ let data = _.groupBy(newMonth, 'month');
|
|
|
+ let newData = data[month];
|
|
|
+ let num = newData.reduce((p, n) => p + n.class * 1, 0);
|
|
|
+ return num;
|
|
|
+ },
|
|
|
+ objectSpanMethod({ row, column, rowIndex, columnIndex }) {
|
|
|
+ // loadsh
|
|
|
+ // flatten:减维
|
|
|
+ // toPairs:把object转换成数组
|
|
|
+ // groupBy:创建对象,根据条件,Math.floor,length,字段
|
|
|
+ // filter:过滤数组
|
|
|
+ // find:查找
|
|
|
+ // every:每一项
|
|
|
+ let prop = _.get(column, 'property');
|
|
|
+ if (prop === 'term1' || prop === 'term7') {
|
|
|
+ // groupBy创建对象并根据条件过滤出来object,并用toPairs转换成数组,并降维,filter过滤出是数组的数据
|
|
|
+ let data = _.flatten(_.toPairs(_.groupBy(this.list, 'term1'))).filter(_.isArray);
|
|
|
+ // 根据数组找出跟当前数组一致的数组
|
|
|
+ let num = data.find(i => i.every(e => e.term1 === row.term1));
|
|
|
+ // 时间转换
|
|
|
+ let newNum = num.map(i => {
|
|
|
+ i.newDate = this.ptc(i.date.split('-')[0]);
|
|
|
return i;
|
|
|
});
|
|
|
- arr = this.resetList(arr);
|
|
|
- this.$set(this, `classList`, arr);
|
|
|
- }
|
|
|
- this.loading = false;
|
|
|
- msg.close();
|
|
|
- this.$checkRes(res, '分配完成', res.errmsg);
|
|
|
- },
|
|
|
- async toEdit(data) {
|
|
|
- let res = await this.findTeacher({ planid: data.planid, termid: data.termid, batchid: data.batchid });
|
|
|
- if (this.$checkRes(res)) {
|
|
|
- let group = _.groupBy(res.data, 'department');
|
|
|
- let keys = Object.keys(group);
|
|
|
- let arr = keys.map(key => {
|
|
|
- let r = this.deptList.find(f => f.id == key);
|
|
|
- let obj = {};
|
|
|
- if (r) {
|
|
|
- obj.name = r.name;
|
|
|
- obj.list = group[key];
|
|
|
- }
|
|
|
- return obj;
|
|
|
+ // 根据标准时间进行正序排序
|
|
|
+ let newOder = _.orderBy(newNum, ['newDate'], ['asc']);
|
|
|
+ // 找到数组里面的下标,根据时间
|
|
|
+ let rowi = newOder.findIndex(i => i.newDate == this.ptc(row.date.split('-')[0]));
|
|
|
+ if (rowi === 0) {
|
|
|
+ return {
|
|
|
+ rowspan: num.length,
|
|
|
+ colspan: 1,
|
|
|
+ };
|
|
|
+ } else {
|
|
|
+ return {
|
|
|
+ rowspan: 0,
|
|
|
+ colspan: 0,
|
|
|
+ };
|
|
|
+ }
|
|
|
+ } else if (prop === 'month' || prop === 'num') {
|
|
|
+ let newMonth = this.list.map(i => {
|
|
|
+ i.month = moment(this.ptc(i.date.split('-')[0])).month() + 1;
|
|
|
+ return i;
|
|
|
});
|
|
|
- this.$set(this, `htList`, arr);
|
|
|
+ let data = _.flatten(_.toPairs(_.groupBy(newMonth, 'month'))).filter(_.isArray);
|
|
|
+ let mon = data.find(i => i.every(e => e.month === row.month));
|
|
|
+ let newOder = _.orderBy(mon, ['month'], ['asc']);
|
|
|
+ let rowi = newOder.findIndex(i => i.month == row.month);
|
|
|
+ if (rowi === 0) {
|
|
|
+ return {
|
|
|
+ rowspan: mon.length,
|
|
|
+ colspan: 1,
|
|
|
+ };
|
|
|
+ } else {
|
|
|
+ return {
|
|
|
+ rowspan: 0,
|
|
|
+ colspan: 0,
|
|
|
+ };
|
|
|
+ }
|
|
|
}
|
|
|
- this.dialog = true;
|
|
|
- this.$set(this, `form`, data);
|
|
|
- },
|
|
|
- handleSave({ data }) {
|
|
|
- // let { index, ...info } = data;
|
|
|
- // this.$set(this.classList, index, info);
|
|
|
- this.dialog = false;
|
|
|
- },
|
|
|
- async toSave() {
|
|
|
- let data = JSON.parse(JSON.stringify(this.returnList()));
|
|
|
- let res = await this.upHeadTea(data);
|
|
|
- this.$checkRes(res, '保存成功', res.errmsg || '保存失败');
|
|
|
- },
|
|
|
- async getOtherList() {
|
|
|
- let res = await this.getDept();
|
|
|
- if (this.$checkRes(res)) this.$set(this, `deptList`, res.data);
|
|
|
- res = await this.getDirList();
|
|
|
- if (this.$checkRes(res)) this.$set(this, `dirList`, res.data);
|
|
|
- },
|
|
|
- toFormat(row, column, cellValue) {
|
|
|
- let model = _.get(column, 'property');
|
|
|
- if (model == 'headteacherid') {
|
|
|
- let r = this.dirList.find(f => f._id == cellValue);
|
|
|
- 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: {
|
|
|
- defaultOption: {
|
|
|
- handler(val) {
|
|
|
- this.search();
|
|
|
- },
|
|
|
- deep: true,
|
|
|
},
|
|
|
+ // 保存班主任计划
|
|
|
+ toSave() {},
|
|
|
+ // 一键分配
|
|
|
+ toArrange() {},
|
|
|
},
|
|
|
computed: {
|
|
|
...mapState(['user', 'defaultOption']),
|