|
@@ -0,0 +1,143 @@
|
|
|
+<template>
|
|
|
+ <div id="class-lesson">
|
|
|
+ <detail-frame title="班级课表" returns="/train/plan/term/lesson">
|
|
|
+ <class-table ref="lesson" :classInfo="classInfo" @saveResult="getRes"></class-table>
|
|
|
+ <el-divider></el-divider>
|
|
|
+ <info-class
|
|
|
+ ref="classes"
|
|
|
+ :classInfo.sync="classInfo"
|
|
|
+ :locationList="locationList"
|
|
|
+ :lyTeacherList="lyTeacherList"
|
|
|
+ :headTeacherList="headTeacherList"
|
|
|
+ @saveResult="getRes"
|
|
|
+ ></info-class>
|
|
|
+ <el-row type="flex" align="middle" justify="center" class="btn_bar">
|
|
|
+ <el-col :span="2">
|
|
|
+ <el-button type="primary" @click="classSave">保存</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </detail-frame>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import _ from 'lodash';
|
|
|
+import detailFrame from '@frame/layout/admin/detail-frame';
|
|
|
+import classTable from './parts/class-table';
|
|
|
+import infoClass from './parts/class-info';
|
|
|
+import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
+const { mapActions: classes } = createNamespacedHelpers('classes');
|
|
|
+//info-class
|
|
|
+const { mapActions: location } = createNamespacedHelpers('location'); //地点
|
|
|
+const { mapActions: teacher } = createNamespacedHelpers('teacher'); //教师
|
|
|
+const { mapActions: dirPlan } = createNamespacedHelpers('dirPlan'); //班主任不能上课的列表
|
|
|
+const { mapActions: teaplan } = createNamespacedHelpers('teaPlan');
|
|
|
+const { mapActions: mapDept } = createNamespacedHelpers('dept'); //配合教师表使用的部门表
|
|
|
+export default {
|
|
|
+ name: 'class-lesson',
|
|
|
+ props: {},
|
|
|
+ components: { detailFrame, classTable, infoClass },
|
|
|
+ data: function() {
|
|
|
+ return {
|
|
|
+ classInfo: {},
|
|
|
+ locationList: [],
|
|
|
+ lyTeacherList: [],
|
|
|
+ headTeacherList: [],
|
|
|
+ deptList: [],
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {},
|
|
|
+ methods: {
|
|
|
+ ...classes(['fetch']),
|
|
|
+ ...location({ getLocationList: 'query' }),
|
|
|
+ ...teacher({ getTeacherList: 'query' }),
|
|
|
+ ...dirPlan({ dirQuery: 'getDirTeacher' }),
|
|
|
+ ...mapDept({ getDept: 'query' }),
|
|
|
+ ...teaplan(['findTeacher']),
|
|
|
+ async getClassInfo() {
|
|
|
+ let res = await this.fetch(this.classid);
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$set(this, `classInfo`, res.data);
|
|
|
+ this.getSettingLists(this.classInfo);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ classSave() {
|
|
|
+ this.$refs.lesson.toSave();
|
|
|
+ this.$refs.classes.toSave();
|
|
|
+ },
|
|
|
+ getRes({ from, result }) {
|
|
|
+ let r = this.result.find(f => f.from == from);
|
|
|
+ if (r) {
|
|
|
+ console.log(`已有${from}的保存结果,未清除`);
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ this.result.push({ from, result });
|
|
|
+ }
|
|
|
+ if (this.result.length == 2) {
|
|
|
+ let resR = this.result.every(e => e.result == true);
|
|
|
+ if (resR) this.$message.success('保存成功');
|
|
|
+ this.$set(this, `result`, []);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async getSettingLists(data) {
|
|
|
+ let res;
|
|
|
+ if (this.locationList.length <= 0) {
|
|
|
+ res = await this.getLocationList();
|
|
|
+ if (this.$checkRes(res)) this.$set(this, `locationList`, res.data);
|
|
|
+ }
|
|
|
+ if (this.lyTeacherList.length <= 0) {
|
|
|
+ res = await this.getTeacherList({ islyteacher: '1', status: '4' });
|
|
|
+ if (this.$checkRes(res)) this.$set(this, `lyTeacherList`, res.data);
|
|
|
+ }
|
|
|
+ if (this.headTeacherList.length <= 0) {
|
|
|
+ res = await this.findTeacher({ planid: data.planid, termid: data.termid, batchid: data.batchid });
|
|
|
+ let duplicate = _.cloneDeep(res.data);
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ if (this.deptList.length <= 0) {
|
|
|
+ let dept = await this.getDept();
|
|
|
+ if (this.$checkRes(res)) this.$set(this, `deptList`, dept.data);
|
|
|
+ }
|
|
|
+ //班主任按部门分组
|
|
|
+ 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, `headTeacherList`, arr);
|
|
|
+ //班主任筛选可以当礼仪老师列表,和 礼仪教师列表合并
|
|
|
+ duplicate = duplicate.filter(f => f.islyteacher == '1');
|
|
|
+ this.$set(this, `lyTeacherList`, [...this.lyTeacherList, ...duplicate]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ classid: {
|
|
|
+ immediate: true,
|
|
|
+ handler(val) {
|
|
|
+ if (val) this.getClassInfo();
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapState(['user']),
|
|
|
+ pageTitle() {
|
|
|
+ return `${this.$route.meta.title}`;
|
|
|
+ },
|
|
|
+ classid() {
|
|
|
+ return this.$route.query.classid;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ metaInfo() {
|
|
|
+ return { title: this.$route.meta.title };
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped></style>
|