lrf402788946 4 rokov pred
rodič
commit
2e874c482a

+ 6 - 0
src/router/index.js

@@ -242,6 +242,12 @@ const newPlan = [
     meta: { title: '学校参培时间' },
     component: () => import('@/views/new-plan/arrange/school-time.vue'),
   },
+  {
+    path: '/plan/school/name/list',
+    name: 'newPlan_school_name_list',
+    meta: { title: '学校上报名单管理' },
+    component: () => import('@/views/new-plan/deal-list.vue'),
+  },
   {
     path: '/plan/school',
     name: 'newPlan_school',

+ 5 - 0
src/views/classes/type.vue

@@ -19,6 +19,10 @@
                 <el-radio label="0">学生签到</el-radio>
                 <el-radio label="1">教师代签</el-radio>
               </template>
+              <template v-if="item.model == 'hascar'">
+                <el-radio label="0">否</el-radio>
+                <el-radio label="1">是</el-radio>
+              </template>
             </template>
           </data-form>
         </el-tab-pane>
@@ -66,6 +70,7 @@ export default {
         { label: '类型代码', model: 'code' },
         { label: '分寝方式', model: 'bedroom', type: 'radio' },
         { label: '签到类型', model: 'sign', type: 'radio' },
+        { label: '是否派车', model: 'hascar', type: 'radio' },
       ],
       list: [],
       total: 0,

+ 0 - 1
src/views/dept/detail.vue

@@ -60,7 +60,6 @@ export default {
     ...mapClass(['fetch', 'create', 'update']),
     async search() {
       const res = await this.fetch(this.id);
-      console.log(res);
       if (this.$checkRes(res)) this.$set(this, `info`, res.data);
       this.loading = false;
     },

+ 60 - 18
src/views/new-plan/arrange/school-arrange.vue

@@ -209,8 +209,7 @@ export default {
                 schremaining = 0; //学校剩余名额 = 0
                 sch[this.proAffix(classtype, 'remaining')] = schremaining;
                 sch = this.computedSchRemaining(sch);
-                //这个地方需要检查下所有 类型的 remaining
-                console.log(sch, b);
+                //让循环自然结束就好了
                 continue;
               }
             }
@@ -300,6 +299,7 @@ export default {
       sch[this.proAffix(b.termid, 'term')] = b.term; //记录该期 term-${termid} = term
       sch[this.proAffix(b._id, 'batch')] = b.batch; //记录该批次 batch-${batchid} = batch
       sch[this.proAffix(b._id, 'batch_total')] = number; //学校哪一批次有多少人,表格上显示的
+      // sch[this.proAffix(b._id, 'batch_type')] = b.classtype; //学校哪一批次有多少人,表格上显示的
       return sch;
     },
     //将学校上报的月份数组[String]=>[{start,end}]方法
@@ -378,9 +378,7 @@ export default {
       if (this.$checkRes(res)) {
         let duplicate = _.cloneDeep(res.data);
         let list = this.list.map((i, index) => {
-          // console.log(i);
           let plan = duplicate.find(f => f.schid == i.code);
-          // console.log(plan);
           if (plan) {
             let { arrange, daterange } = plan;
             i.daterange = daterange;
@@ -459,12 +457,34 @@ export default {
     getCarTotal() {
       let carpnum = this.template.carpnum * 1 || 53;
       let list = this.list.map(i => {
-        let keys = Object.keys(i).filter(f => f.includes('batch_total'));
-        keys.map(key => {
-          let { value: batchid } = this.proAffix(key);
-          let carnum = Math.ceil(i[key] / carpnum);
-          i[this.proAffix(batchid, 'car_total')] = carnum;
-        });
+        //先排除学校就不需要车的
+        if (i.hascar == '1') {
+          //过滤出所有已分配批次的人数的 key
+          let keys = Object.keys(i).filter(f => f.includes('batch_total'));
+          keys.map(key => {
+            //将key 拆开 词缀固定不需要, 获得value=>batchid
+            let { value: batchid } = this.proAffix(key);
+            // 从 termList 找到该批次,找到批次中的 classtype 然后去查询classTypeList,看看这个类型的班级需不要派车
+            let ct;
+            for (const term of this.termList) {
+              let r = term.batchnum.find(f => f._id == batchid);
+              if (r) {
+                ct = _.get(r, `classtype`);
+                break;
+              }
+            }
+            if (ct) {
+              let r = this.classTypeList.find(f => f.code == ct);
+              if (r) {
+                let hascar = _.get(r, 'hascar');
+                if (hascar == '1') {
+                  let carnum = Math.ceil(i[key] / carpnum);
+                  i[this.proAffix(batchid, 'car_total')] = carnum;
+                }
+              }
+            }
+          });
+        }
         return i;
       });
       this.$set(this, `list`, list);
@@ -478,31 +498,53 @@ export default {
       let sr = _.get(this.form.sch, 'remaining');
       let pr = _.get(this.form.info, 'remaining');
       let remainder = cv - ov;
-      // console.log(cv, ov, remainder, sr, pr);
       this.$set(this.form.sch, `remaining`, sr - remainder);
       this.$set(this.form.info, `remaining`, pr - remainder);
     },
     //计算抽屉最大值
     dGetMax(data) {
       if (!this.drawer) return 0;
-      // console.log(data);
       let { num = 0, info, sch } = data;
-      let { remaining: pl, bpt, _id: batchid } = info; //批次限制,批次总限制,批次id
+      let { remaining: pl, bpt, _id: batchid, classtype } = info; //批次限制,批次总限制,批次id
       let { remaining: sl, number: spt, code } = sch; ////学校限制
-      // console.log(pl, sl);
       let res = 0;
       //如果学校没有名额了,那么数字框内的最大值就是当前的值
       if (sl == 0) {
-        console.log('学校名额没了');
+        console.warn('学校名额没了');
         res = num;
       }
-      //根据这个表来看,2算法
+      //根据这个表来看,2算法
       // 1) 纵向计算(按批次算) 批次总限制 - 这批次  除了这个学校外  所有学校分配的人数之和
       // 2) 横向计算(按学校算) 学校总限制 - 这个学校 除了当前批次外 所有批次的分配的人数之和
       //如果批次限制 大于 学校限制:那么最大值 = 横向计算结果
       if (pl > sl) {
-        let keys = Object.keys(sch).filter(f => f.includes('batch_total') && f != this.proAffix(batchid, 'batch_total'));
-        let obj = _.pick(sch, keys);
+        //需要过滤出这个在符合当前批次的班级类型的所有学生的key=>所有批次列表
+        let keys = Object.keys(sch)
+          .filter(f => f.includes('batch_total-'))
+          .map(i => {
+            let { value } = this.proAffix(i);
+            return value;
+          });
+        // 接着过滤,过滤出classtype符合条件的批次
+        let r = keys.filter(f => {
+          if (batchid == f) return false;
+          let midr = false;
+          for (const term of this.termList) {
+            //找到该期
+            let batch = term.batchnum.find(bf => bf._id == f);
+            if (batch) {
+              //判断该期的类型与现在要编辑的期的类型是不是一致的
+              if (batch.classtype == classtype) {
+                midr = true;
+                break;
+              }
+            }
+          }
+          return midr;
+        });
+        // 过滤后的批次都是和这次编辑相同班级类型的班级
+        r = r.map(i => this.proAffix(i, 'batch_total'));
+        let obj = _.pick(sch, r);
         let ot = Object.values(obj).reduce((prev, next) => prev + next * 1, 0);
         res = spt * 1 - ot || 0;
       }

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

@@ -112,8 +112,11 @@ export default {
       else return data[`car_total-${batchid}`];
     },
     getContent(data, batchid) {
-      if (this.display) return `需求车辆: ${data[`car_total-${batchid}`]} 辆`;
-      else return `分配名额: ${data[`batch_total-${batchid}`]} 人`;
+      if (this.display) {
+        let num = data[`car_total-${batchid}`];
+        if (num) return `需求车辆: ${num} 辆`;
+        else return `该批次不需要派车`;
+      } else return `分配名额: ${data[`batch_total-${batchid}`]} 人`;
     },
     //尾行计算
     sumComputed({ columns, data }) {

+ 103 - 0
src/views/new-plan/deal-list.vue

@@ -0,0 +1,103 @@
+<template>
+  <div id="deal-list">
+    <detail-frame :title="pageTitle">
+      <data-table :fields="fields" :data="list" :total="total" :opera="opera" @edit="toEdit" @download="toDownLoad"></data-table>
+      <!-- @edit="toEdit" @delete="toDelete" -->
+    </detail-frame>
+    <el-dialog title="学校上传人数与规定不符" width="30%" :visible.sync="dialog" @close="toClose">
+      <el-row>
+        <el-col :span="24">学校:{{ form.name }}</el-col>
+        <el-col :span="24">原因:{{ form.reason }}</el-col>
+      </el-row>
+      <template #footer>
+        <el-row type="flex" align="middle" justify="center">
+          <el-col :span="4"><el-button type="primary" plain size="mini">同意入库</el-button></el-col>
+          <el-col :span="4"><el-button type="danger" plain size="mini">拒绝入库</el-button></el-col>
+        </el-row>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import detailFrame from '@frame/layout/admin/detail-frame';
+import _ from 'lodash';
+import dataTable from '@frame/components/filter-page-table';
+import { mapState, createNamespacedHelpers } from 'vuex';
+export default {
+  name: 'deal-list',
+  props: {},
+  components: { detailFrame, dataTable },
+  data: function() {
+    return {
+      dialog: false,
+      opera: [
+        {
+          label: '处理',
+          icon: 'el-icon-s-check',
+          method: 'edit',
+        },
+        {
+          label: '下载名单',
+          icon: 'el-icon-download',
+          method: 'download',
+        },
+      ],
+      fields: [
+        { label: '学校', prop: 'name' },
+        { label: '期数', prop: 'term' },
+        { label: '未入库原因', prop: 'reason' },
+      ],
+      list: [{ name: '吉林大学', term: 336, reason: '上报人数超过范围' }],
+      form: {},
+      total: 0,
+      options: {},
+    };
+  },
+  created() {},
+  methods: {
+    toEdit({ data }) {
+      // TODO处理有问题的名单,是保留,还是删除,保留就直接导入数据库
+      this.$set(this, `form`, data);
+      this.dialog = true;
+    },
+    toDownLoad({ data }) {
+      // TODO下载学校上传的名单
+    },
+    toClose() {
+      this.dialog = false;
+      this.form = {};
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+  },
+  watch: {
+    defaultOption: {
+      immediate: true,
+      deep: true,
+      handler(val) {
+        if (!_.get(this, 'options')) {
+          this.$set(this, `options`, _.cloneDeep(val));
+          this.search();
+        } else {
+          let nplanid = _.get(val, 'planid');
+          let oplanid = _.get(this.options, 'planid');
+          if (nplanid && !_.isEqual(nplanid, oplanid)) {
+            this.$set(this, `options`, _.cloneDeep(val));
+            this.search();
+          }
+        }
+      },
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

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

@@ -100,7 +100,7 @@ export default {
     );
   },
   methods: {
-    ...lesson({ getLesson: 'query', plupdate: 'pluralUpdate' }),
+    ...lesson({ getLesson: 'query', plupdate: 'pluralUpdate', autoArrange: 'arrange' }),
     ...classes({ getClass: 'query', pcupdate: 'pluralUpdate' }),
 
     ...subject({ getSubject: 'query' }),