瀏覽代碼

学下计划添加实际总人数列,取消最大值限制;期课表改为普通班和特殊班多列,各自改各自的

lrf402788946 5 年之前
父節點
當前提交
b9777bcbf4

+ 10 - 6
src/router/index.js

@@ -312,12 +312,12 @@ const train = [
     meta: { title: '非常用问卷管理' },
     component: () => import('@/views/train-plan/quest.vue'),
   },
-  {
-    path: '/train/plan/lesson',
-    name: 'train_plan_lesson',
-    meta: { title: '课表管理管理' },
-    component: () => import('@/views/train-plan/lesson.vue'),
-  },
+  // {
+  //   path: '/train/plan/lesson',
+  //   name: 'train_plan_lesson',
+  //   meta: { title: '课表管理管理' },
+  //   component: () => import('@/views/train-plan/lesson.vue'),
+  // },
   {
     path: '/train/plan/term/lesson',
     name: 'train_plan_term_lesson',
@@ -469,6 +469,10 @@ const routes = [
       },
     ],
   },
+  {
+    path: '/teacher/index',
+    component: () => import('@/views/teacher/index.vue'),
+  },
   {
     path: '/yearPlan/index',
     name: 'yearPlan_index',

+ 3 - 2
src/views/new-plan/arrange/school-arrange.vue

@@ -60,11 +60,11 @@
                   v-model="form.num"
                   type="number"
                   placeholder="请输入分配给该期的名额"
-                  :max="dGetMax(form)"
                   :min="0"
                   style="width:250px"
                   @change="dComputed"
                 ></el-input-number>
+                <!-- :max="dGetMax(form)" -->
               </el-form-item>
               <el-form-item>
                 <el-row type="flex" align="middle" justify="start" :gutter="20">
@@ -188,7 +188,8 @@ export default {
             if (result) {
               let { classtype } = b;
               // 获取对应班级类型的 剩余人数
-              let schremaining = _.get(sch, this.proAffix(classtype, 'remaining'));
+              let schremaining = _.get(sch, this.proAffix(classtype, 'remaining'), 0);
+              if (schremaining <= 0) continue;
               // 学校名额>本批次剩余名额:
               if (schremaining > b.remaining) {
                 schremaining = schremaining - b.remaining; //学校剩余名额 = 学校剩余名额(原) - 本批次剩余名额

+ 19 - 2
src/views/new-plan/arrange/table/table.vue

@@ -30,6 +30,11 @@
               <el-table-column align="center" v-for="(ct, index) in classTypeList" :key="index" :label="ct.name" :prop="`${proAffix(ct.code, 'remaining')}`">
               </el-table-column>
               <el-table-column label="总人数" align="center" prop="number"> </el-table-column>
+              <el-table-column label="实际分配总人数" align="center">
+                <template v-slot="{ row }">
+                  {{ getRowTotal(row) }}
+                </template>
+              </el-table-column>
             </el-table-column>
           </el-table-column>
         </el-table-column>
@@ -118,6 +123,12 @@ export default {
         else return `该批次不需要派车`;
       } else return `分配名额: ${data[`batch_total-${batchid}`]} 人`;
     },
+    //行实际人数计算
+    getRowTotal(row) {
+      let keys = Object.keys(row).filter(f => f.includes('batch_total-'));
+      let num = keys.reduce((p, n) => p + row[n] * 1, 0);
+      return num;
+    },
     //尾行计算
     sumComputed({ columns, data }) {
       let arr = [];
@@ -129,9 +140,12 @@ export default {
           if (prop == 'number') {
             let num = this.list.reduce((prev, next) => prev + (next.number || 0) * 1, 0);
             arr.push(num);
-          } else {
+          } else if (prop) {
             let r = this.display ? this.columnComputed(prop, data) : this.carComputed(prop, data);
             arr.push(r);
+          } else {
+            let total = data.reduce((p, n) => p + this.getRowTotal(n), 0);
+            arr.push(total);
           }
         }
       });
@@ -146,7 +160,10 @@ export default {
         .flat()
         .find(f => f._id == batchid);
       if (batch) {
-        let word = batch.remaining > 0 ? `(缺少${batch.remaining}人)` : '(分配完成)';
+        let word;
+        if (batch.remaining == 0) word = '(分配完成)';
+        else if (batch.remaining < 0) word = `(多${Math.abs(batch.remaining)}人)`;
+        else word = `(缺少${batch.remaining}人)`;
         num = `${num}${word}`;
       }
       return num;

+ 0 - 205
src/views/train-plan/lesson.vue

@@ -1,205 +0,0 @@
-<template>
-  <div id="lesson">
-    <!-- 弃用 -->
-    <detail-frame :title="pageTitle" v-show="view == 'list'">
-      <el-row type="flex" align="middle" justify="end" class="btn_bar">
-        <el-col :span="2">
-          <el-button type="primary" size="mini" plain @click="toArrange">按模板排课</el-button>
-        </el-col>
-        <el-col :span="2">
-          <el-button type="primary" size="mini" @click="$router.push({ path: '/train/plan/term/lesson' })">查看本期课表</el-button>
-        </el-col>
-      </el-row>
-      <data-table :fields="fields" :data="list" :opera="opera" @edit="toEdit" :usePage="false"></data-table>
-    </detail-frame>
-    <detail-frame v-if="view == 'classView'" title="班级课表" :returns="() => (view = 'list')">
-      <class-table ref="lesson" :classInfo="classInfo" @saveResult="getRes"></class-table>
-      <el-divider></el-divider>
-      <info-class
-        ref="classes"
-        :classInfo="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 dataTable from '@frame/components/filter-page-table';
-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');
-const { mapActions: lesson } = createNamespacedHelpers('lesson');
-//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: 'lesson',
-  props: {},
-  components: { detailFrame, dataTable, classTable, infoClass },
-  data: function() {
-    return {
-      view: 'list',
-      list: [],
-      opera: [
-        {
-          label: '查看本班课表',
-          icon: 'el-icon-view',
-          method: 'edit',
-        },
-      ],
-      fields: [
-        { label: '期', prop: 'term' },
-        { label: '批', prop: 'batch' },
-        { label: '班级', prop: 'name' },
-      ],
-      options: {},
-      classInfo: {},
-      //info-class
-      lyTeacherList: [],
-      locationList: [],
-      headTeacherList: [],
-      deptList: [],
-      result: [],
-    };
-  },
-  created() {},
-  methods: {
-    ...classes(['query']),
-    ...lesson({ autoArrange: 'arrange' }),
-    //info-class
-    ...location({ getLocationList: 'query' }),
-    ...teacher({ getTeacherList: 'query' }),
-    ...dirPlan({ dirQuery: 'getDirTeacher' }),
-    ...mapDept({ getDept: 'query' }),
-    ...teaplan(['findTeacher']),
-    async search() {
-      let termid = _.get(this.defaultOption, 'termid');
-      if (!termid) return;
-      let res = await this.query({ termid });
-      if (this.$checkRes(res)) {
-        this.$set(this, `list`, res.data);
-      }
-    },
-    toEdit({ data }) {
-      this.getSettingLists(data);
-      this.$set(this, `classInfo`, data);
-      this.view = 'classView';
-    },
-    async toArrange() {
-      this.$confirm('此操作将会将默认 年度计划 下所有的班级课表重置,若您已经修改过某班的信息,请谨慎使用', '提示', {
-        confirmButtonText: '按模板排课',
-        cancelButtonText: '取消',
-        type: 'warning',
-      })
-        .then(async () => {
-          let planid = _.get(this.defaultOption, 'planid');
-          let res = await this.autoArrange(planid);
-          this.$checkRes(res, '排课成功', res.errmsg || '排课失败');
-        })
-        .catch(async () => {
-          console.log('已取消');
-        });
-    },
-    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]);
-        }
-      }
-    },
-    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`, []);
-      }
-    },
-  },
-  watch: {
-    defaultOption: {
-      immediate: true,
-      deep: true,
-      handler(val) {
-        if (!_.get(this, 'options')) {
-          this.$set(this, `options`, _.cloneDeep(val));
-          this.search();
-        } else {
-          let ntermid = _.get(val, 'termid');
-          let otermid = _.get(this.options, 'termid');
-          if (ntermid && !_.isEqual(ntermid, otermid)) {
-            this.$set(this, `options`, _.cloneDeep(val));
-            this.search();
-          }
-        }
-      },
-    },
-  },
-  computed: {
-    ...mapState(['user', 'defaultOption']),
-    pageTitle() {
-      return `${this.$route.meta.title}`;
-    },
-  },
-  metaInfo() {
-    return { title: this.$route.meta.title };
-  },
-};
-</script>
-
-<style lang="less" scoped></style>

+ 6 - 1
src/views/train-plan/parts/term-lesson-form.vue

@@ -28,7 +28,12 @@ export default {
       obj.type = subid ? '课程' : '活动';
       this.$set(this, `form`, obj);
       let keys = Object.keys(others);
-      let indexs = _.uniq(keys.map(key => key.match(/\d+(.\d+)?/g)[0]));
+      let indexs = _.uniq(
+        keys.map(key => {
+          let r = key.match(/\d+(.\d+)?/g);
+          if (r && r.length > 0) return r[0];
+        })
+      );
       let arr = indexs.map(i => {
         let gks = keys.filter(f => f.includes(i));
         gks = gks.map(gk => {

+ 3 - 2
src/views/train-plan/parts/term-lesson-table.vue

@@ -35,6 +35,7 @@ import { mapState, createNamespacedHelpers } from 'vuex';
 export default {
   name: 'term-lesson-table',
   props: {
+    type: { type: String },
     data: { type: Array, default: () => [] },
     batch: { type: [String, Array] },
   },
@@ -73,8 +74,8 @@ export default {
           let arr = this.data;
           let fr = arr.filter(f => f.type == 'lesson' && Object.keys(f).length > 0);
           obj.is_last = _.isEqualWith(_.last(fr), row, (ob, ot) => ob.date == ot.date);
-          this.$emit('lesson', obj);
-        } else this.$emit('other', obj);
+          this.$emit('lesson', obj, this.type);
+        } else this.$emit('other', obj, this.type);
       } else {
         this.$message.warning('此项不允许更改');
       }

+ 30 - 14
src/views/train-plan/term-lesson.vue

@@ -11,7 +11,12 @@
       </el-row>
       <el-row type="flex" v-loading="loading" style="min-height:500px">
         <el-col :span="8" v-for="(i, index) in list" :key="index">
-          <lesson-table :data="i" :batch="`${index + 1}`" @lesson="toLesson" @other="toOther" @toOneClass="toOneClass"></lesson-table>
+          <lesson-table type="usual" :data="i" :batch="`${index + 1}`" @lesson="toLesson" @other="toOther" @toOneClass="toOneClass"></lesson-table>
+        </el-col>
+      </el-row>
+      <el-row type="flex" v-loading="loading" style="min-height:500px" v-for="(i, index) in unusualList" :key="index">
+        <el-col :span="8">
+          <lesson-table type="unusual" :data="i" :batch="`${index + 1}`" @lesson="toLesson" @other="toOther" @toOneClass="toOneClass"></lesson-table>
         </el-col>
       </el-row>
     </detail-frame>
@@ -65,11 +70,12 @@ export default {
       lDrawer: false,
       oDrawer: false,
       form: {},
+      formType: 'usual',
       options: {},
       list: [],
+      unusualList: [],
       classList: [],
       lessonList: [],
-
       locationList: [],
       lyTeacherList: [],
       deptList: [],
@@ -122,8 +128,6 @@ export default {
         lessonList = lessons.data;
         if (lessonList.length <= 0) {
           this.toArrange(false);
-          // this.$message.warning('班级没有按模板初始化,请按模板初始化后再进入期课表');
-          // this.loading = false;
           return;
         }
         this.$set(this, `lessonList`, lessonList);
@@ -136,7 +140,15 @@ export default {
         }
         this.$set(this, `classList`, classList);
       }
-
+      let unusualList = classList.filter(f => f.type != '0');
+      let usualList = classList.filter(f => f.type == '0');
+      let usualRes = this.dealList(usualList, lessonList);
+      let unusualRes = this.dealList(unusualList, lessonList);
+      this.$set(this, `list`, usualRes);
+      this.$set(this, `unusualList`, unusualRes);
+      this.loading = false;
+    },
+    dealList(classList, lessonList) {
       let arr = classList.map(i => {
         let r = lessonList.find(f => f.classid == i._id);
         if (r) {
@@ -173,8 +185,7 @@ export default {
         a.push(last);
         return a;
       });
-      this.$set(this, `list`, arr);
-      this.loading = false;
+      return arr;
     },
     //课程数据=>页面数据形式
     changeLesson(array) {
@@ -341,36 +352,41 @@ export default {
       //   arr.push(this.modelFetch({ model: 'director', id: _.get(obj, 'jslocationid') }));
       // }
     },
-    toLesson(data) {
+    toLesson(data, type) {
       let { is_last, batch } = data;
       if (is_last) {
         let last = _.last(this.list[batch - 1]);
         let { date } = last;
         data.allday = date;
       }
+      this.formType = type;
       this.$set(this, `form`, data);
       this.lDrawer = true;
     },
-    async toOther(data) {
+    async toOther(data, type) {
       this.oDrawer = true;
       this.dloading = true;
-      let { type } = data;
-      if (type != 'jslocation') await this.getHeadTeacher(data);
+      let { type: ct } = data;
+      if (ct != 'jslocation') await this.getHeadTeacher(data);
+      this.formType = type;
       this.$set(this, `form`, data);
       this.dloading = false;
     },
     lessonSave(data) {
-      let { index, batch, is_last, allday, ...info } = data;
+      let { index, batch, is_last, allday, listtype, ...info } = data;
       if (is_last) {
         //TODO 改变半天/全天
-        this.$set(this.list[batch - 1], this.list[batch - 1].length - 1, { date: allday, type: 'allday' });
+        if (this.formType == 'usual') this.$set(this.list[batch - 1], this.list[batch - 1].length - 1, { date: allday, type: 'allday' });
+        else this.$set(this.unusualList[batch - 1], this.unusualList[batch - 1].length - 1, { date: allday, type: 'allday' });
       }
-      this.$set(this.list[batch - 1], index, { batch, ...info });
+      if (this.formType == 'usual') this.$set(this.list[batch - 1], index, { batch, ...info });
+      else this.$set(this.unusualList[batch - 1], index, { batch, ...info });
       this.toClose();
     },
     toClose() {
       this.lDrawer = false;
       this.oDrawer = false;
+      this.formType = 'usual';
       this.form = {};
     },
     async getHeadTeacher(data) {