|
@@ -1,212 +0,0 @@
|
|
-<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-col :span="2">
|
|
|
|
- <el-button type="success" size="mini" @click="toSave">保存班主任计划</el-button>
|
|
|
|
- </el-col>
|
|
|
|
- <el-col :span="2">
|
|
|
|
- <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>
|
|
|
|
- </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>
|
|
|
|
-
|
|
|
|
-<script>
|
|
|
|
-import _ from 'lodash';
|
|
|
|
-import detailFrame from '@frame/layout/admin/detail-frame';
|
|
|
|
-import dataTable from '@frame/components/data-table';
|
|
|
|
-import dataForm from '@frame/components/form';
|
|
|
|
-import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
|
-const { mapActions } = createNamespacedHelpers('teaPlan');
|
|
|
|
-const { mapActions: classes } = createNamespacedHelpers('classes');
|
|
|
|
-const { mapActions: mapDept } = createNamespacedHelpers('dept');
|
|
|
|
-const { mapActions: director } = createNamespacedHelpers('director');
|
|
|
|
-export default {
|
|
|
|
- name: 'director-arrange',
|
|
|
|
- props: {
|
|
|
|
- // events: { type: Array, default: () => [] },
|
|
|
|
- },
|
|
|
|
- components: { dataForm, 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: [
|
|
|
|
- {
|
|
|
|
- label: '选择班主任',
|
|
|
|
- icon: 'el-icon-edit',
|
|
|
|
- method: 'edit',
|
|
|
|
- },
|
|
|
|
- ],
|
|
|
|
- };
|
|
|
|
- },
|
|
|
|
- async created() {
|
|
|
|
- await this.getOtherList();
|
|
|
|
- this.search();
|
|
|
|
- },
|
|
|
|
- methods: {
|
|
|
|
- ...director({ getDirList: 'query' }),
|
|
|
|
- ...mapDept({ getDept: 'query' }),
|
|
|
|
- ...mapActions(['divide', 'findTeacher']),
|
|
|
|
- ...classes(['query', 'upHeadTea']),
|
|
|
|
- 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;
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- 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;
|
|
|
|
- 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;
|
|
|
|
- });
|
|
|
|
- this.$set(this, `htList`, arr);
|
|
|
|
- }
|
|
|
|
- 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,
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- computed: {
|
|
|
|
- ...mapState(['user', 'defaultOption']),
|
|
|
|
- pageTitle() {
|
|
|
|
- return `${this.$route.meta.title}`;
|
|
|
|
- },
|
|
|
|
- id() {
|
|
|
|
- return this.$route.query.id;
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- metaInfo() {
|
|
|
|
- return { title: this.$route.meta.title };
|
|
|
|
- },
|
|
|
|
-};
|
|
|
|
-</script>
|
|
|
|
-
|
|
|
|
-<style lang="less" scoped></style>
|
|
|