lrf402788946 пре 5 година
родитељ
комит
685be49d39

+ 20 - 20
src/router/index.js

@@ -197,86 +197,80 @@ const system = [
 const newPlan = [
   //缺少:当前计划日历;班主任全年安排;学校总人数设置;学校发参培时间;培训计划详表
   {
-    path: '/newPlan/index',
+    path: '/plan/index',
     name: 'newPlan_index',
     meta: { title: '年度计划管理' },
     component: () => import('@/views/new-plan/index.vue'),
   },
   {
-    path: '/newPlan/template',
+    path: '/plan/template',
     name: 'newPlan_template',
     meta: { title: '计划模板' },
     component: () => import('@/views/new-plan/template.vue'),
   },
   {
-    path: '/newPlan/arrange',
+    path: '/plan/arrange',
     name: 'newPlan_arrange',
     meta: { title: '培训计划安排' },
     component: () => import('@/views/new-plan/arrange/arrange.vue'),
   },
   {
-    path: '/newPlan/director',
+    path: '/plan/director',
     name: 'newPlan_director',
     meta: { title: '班主任计划安排' },
     component: () => import('@/views/new-plan/arrange/director-arrange.vue'),
   },
   {
-    path: '/newPlan/school/num',
+    path: '/plan/school/num',
     name: 'newPlan_school_num',
     meta: { title: '学校人数安排' },
     component: () => import('@/views/new-plan/arrange/school-num.vue'),
   },
   {
-    path: '/newPlan/school/time',
+    path: '/plan/school/time',
     name: 'newPlan_school_time',
     meta: { title: '学校参培时间' },
     component: () => import('@/views/new-plan/arrange/school-time.vue'),
   },
   {
-    path: '/newPlan/school',
+    path: '/plan/school',
     name: 'newPlan_school',
     meta: { title: '学校计划安排' },
     component: () => import('@/views/new-plan/arrange/school-arrange.vue'),
   },
   {
-    path: '/newPlan/classes/index',
-    name: 'newPlan_classes_index',
-    meta: { title: '班级管理' },
-    component: () => import('@/views/new-plan/class/index-class.vue'),
-  },
-  {
-    path: '/newPlan/classes/detail',
+    path: '/plan/classes/detail',
     name: 'newPlan_classes_detail',
     meta: { title: '班级安排' },
     component: () => import('@/views/new-plan/class/classes.vue'),
   },
   {
-    path: '/newPlan/classes/lesson',
+    path: '/plan/classes/lesson',
     name: 'newPlan_classes_lesson',
     meta: { title: '排课管理' },
     component: () => import('@/views/new-plan/class/lesson.vue'),
   },
   {
-    path: '/newPlan/classes/setting',
+    path: '/plan/classes/setting',
     name: 'newPlan_classes_setting',
     meta: { title: '班级设置' },
     component: () => import('@/views/new-plan/class/setting.vue'),
   },
   {
-    path: '/newPlan/classes/bedroom',
+    path: '/plan/classes/bedroom',
     name: 'newPlan_classes_bedroom',
     meta: { title: '分寝' },
     component: () => import('@/views/new-plan/class/bedroom.vue'),
   },
   {
-    path: '/newPlan/classes/namelist',
+    path: '/plan/classes/namelist',
     name: 'newPlan_classes_namelist',
     meta: { title: '班级人员' },
     component: () => import('@/views/new-plan/class/name-list.vue'),
   },
   {
-    path: '/newPlan/classes/quest',
-    name: 'newPlan_classes_quest',
+    path: '/classes/quest',
+    name: 'classes_quest',
     meta: { title: '非常用问卷管理' },
     component: () => import('@/views/new-plan/class/quest.vue'),
   },
@@ -284,6 +278,12 @@ const newPlan = [
 
 const train = [
   //班级设置需要处理,课表管理(按魏老师给的图片做), 通知,学生管理(拿出来,加上searchBar)缺少考勤,学生成绩
+  {
+    path: '/classes/index',
+    name: 'classes_index',
+    meta: { title: '班级管理' },
+    component: () => import('@/views/new-plan/class/index-class.vue'),
+  },
   {
     path: '/student/index',
     name: 'student_index',

+ 72 - 27
src/views/new-plan/arrange/school-arrange.vue

@@ -1,7 +1,7 @@
 <template>
   <div id="school-arrange">
     <detail-frame :title="pageTitle">
-      <el-row type="flex" align="middle" justify="end" style="padding-bottom:10px">
+      <el-row type="flex" align="middle" justify="end" style="padding-bottom:10px" v-if="already">
         <el-col :span="2">
           <el-button type="success" size="mini" @click="toSave">保存计划</el-button>
         </el-col>
@@ -145,16 +145,12 @@ var moment = require('moment');
 import detailFrame from '@frame/layout/admin/detail-frame';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: trainPlan } = createNamespacedHelpers('trainplan');
-const { mapActions: trainTemplate } = createNamespacedHelpers('trainTemplate');
+const { mapActions: util } = createNamespacedHelpers('util');
 const { mapActions: school } = createNamespacedHelpers('school');
 const { mapActions: schPlan } = createNamespacedHelpers('schPlan');
 export default {
   name: 'school-arrange',
-  props: {
-    events: { type: Array, default: () => [] },
-    year: { type: String, default: `${new Date().getFullYear()}` },
-    template: { type: Object, default: () => {} },
-  },
+  props: {},
   components: { detailFrame },
   data: () => {
     return {
@@ -163,27 +159,32 @@ export default {
       termList: [],
       totalList: [],
       carList: [],
+      template: {},
       dialog: false,
       drawer: false,
       form: {},
       activeName: '1',
       already: false,
+      options: undefined,
     };
   },
   async created() {
     await this.toGetTrainPlan();
+    await this.toGetTrainTemplate();
     await this.getSchool();
   },
   methods: {
+    ...util({ modelFetch: 'fetch' }),
     ...trainPlan({ getTrainPlan: 'fetch' }),
     ...school(['query']),
-    ...schPlan({ schPlanQuery: 'query', createSchPlan: 'create', updateSchPlan: 'update' }),
+    ...schPlan({ schPlanQuery: 'query', createSchPlan: 'create', updateSchPlan: 'update', setSchPlan: 'schArrange' }),
     //请求,处理学校列表
     async getSchool() {
       const res = await this.query();
       if (this.$checkRes(res)) {
-        let school = res.data.map(i => {
-          i = _.omit(i, ['meta', 'id', '_id', 'logourl']);
+        let nd = res.data.map(i => (i = _.omit(i, ['meta', 'id', '_id', 'logourl', 'number'])));
+        nd = this.setSchoolNumber(nd);
+        let school = nd.map(i => {
           if (i.number) i.remaining = JSON.parse(JSON.stringify(i.number));
           else i.remaining = 0;
           return i;
@@ -240,7 +241,7 @@ export default {
       this.getCarTotal();
     },
     //保存整体计划
-    toSave() {
+    async toSave() {
       //修改学校上报计划,整理数据
       let schPlan = this.list.map(i => {
         let plan = _.cloneDeep(i.plan);
@@ -264,7 +265,8 @@ export default {
         i.term = _.uniqBy(this.checkTerm(i.term), '_id');
         return i;
       });
-      this.$emit('toSave', schPlan);
+      const res = await this.setSchPlan(schPlan);
+      this.$checkRes(res, '保存成功', res.errmsg);
     },
     //手动更改
     cellClick(row, column) {
@@ -300,7 +302,6 @@ export default {
     },
     //将学校上报的月份数组[String]=>[{start,end}]方法
     changeRange(data) {
-      //TODO 时间不对,跨月份之后接不上了
       let duplicate = JSON.parse(JSON.stringify(data));
       if (_.isArray(duplicate)) {
         duplicate = duplicate.map(i => {
@@ -315,29 +316,33 @@ export default {
       return duplicate;
     },
     groupTime(data) {
+      let res;
       let len = _.get(data, 'length');
       if (len && len == 1) {
         let dr = data.map(mon => {
           let r = this.stringDateRange(mon, mon);
           return r;
         });
-        return dr;
+        res = dr;
       } else if (len && len > 1) {
         //TODO 长度大于1也就是说明最少上报了2个月份
         //先排序,然后按照连续性分组
         let afterSort = data.sort((a, b) => a * 1 - b * 1);
         let newRange = this.getConRange(afterSort);
-      }
+        let r = newRange.map(arr => this.stringDateRange(_.head(arr), _.last(arr)));
+        res = r;
+      } else res = data;
+      return res;
     },
     stringDateRange(data, num) {
       if (_.isObject(data)) return data;
       let start = moment()
-        .year(this.year)
+        .year(this.plan.year)
         .month(data * 1 - 1)
         .date('1')
         .format('YYYY-MM-DD');
       let end = moment()
-        .year(this.year)
+        .year(this.plan.year)
         .month(num * 1)
         .date('1')
         .subtract(1, 'days')
@@ -345,9 +350,7 @@ export default {
       return { start, end };
     },
     getConRange(array) {
-      array = ['1', '2', '3', '5', '6', '10', '11'];
       let res = [];
-      console.log(array);
       let limit = _.get(array, 'length') - 1;
       for (let i = 0; i <= limit; i++) {
         if (i == 0) res.push([array[i]]);
@@ -356,16 +359,14 @@ export default {
           let l_num = _.last(_.last(res));
           let r = _.subtract(t_num * 1, l_num * 1);
           if (r == 1) {
-            //当前和一期是连续的
+            //当前和一期是连续的
             let last = _.last(res);
             last.push(t_num);
             res[res.length - 1] = last;
-          } else {
-            res.push([array[i]]);
-          }
+          } else res.push([array[i]]);
         }
       }
-      console.log(res);
+      return res;
     },
     //学校匹配学校计划
     async getSchoolPlan() {
@@ -465,6 +466,7 @@ export default {
           sch.carTerm.push({ term, num });
         }
       });
+      school = school.filter(f => _.get(f, 'carTerm.length', 0) > 0);
       this.$set(this, `carList`, school);
     },
     //计算车辆
@@ -575,7 +577,6 @@ export default {
       row = this.changeRange(row);
       let { result } = this.$tqInRange(term.start, term.end, row.daterange);
       if (!result) {
-        console.log(term, row);
         return disabled;
       } else return '';
     },
@@ -595,7 +596,6 @@ export default {
       this.toSave();
       this.$emit(`toDirector`);
     },
-
     //获取计划
     async toGetTrainPlan() {
       let planid = _.get(this.defaultOption, 'planid');
@@ -605,6 +605,34 @@ export default {
         this.getTermList();
       }
     },
+    //获取计划模板
+    async toGetTrainTemplate() {
+      let planyearid = _.get(this.defaultOption, 'planyearid');
+      let planid = _.get(this.defaultOption, 'planid');
+      let res = await this.modelFetch({ model: 'trainmodel', planyearid, planid });
+      if (this.$checkRes(res)) {
+        this.$set(this, `template`, res.data ? res.data : {});
+      }
+    },
+    //本计划各个学校分配人数匹配
+    setSchoolNumber(data) {
+      let planSchool = _.get(this.plan, `school`, []);
+      if (planSchool.length <= 0) return data;
+      let nl = data.map(i => {
+        let r = planSchool.find(f => f.code == i.code);
+        if (r) i.number = r.num;
+        return i;
+      });
+      nl = nl.sort((a, b) => a.code * 1 - b.code * 1);
+      return nl;
+    },
+    //默认值改变查询
+    async reSearch() {
+      this.already = false;
+      await this.toGetTrainPlan();
+      await this.toGetTrainTemplate();
+      await this.getSchool();
+    },
   },
   filters: {
     getProp(data, prop) {
@@ -620,7 +648,24 @@ export default {
       return `${this.$route.meta.title}`;
     },
   },
-  watch: {},
+  watch: {
+    defaultOption: {
+      immediate: true,
+      deep: true,
+      handler(val) {
+        if (!_.get(this, 'options')) {
+          this.$set(this, `options`, _.cloneDeep(val));
+        } else {
+          let nplanid = _.get(val, 'planid');
+          let oplanid = _.get(this.options, 'planid');
+          if (nplanid && !_.isEqual(nplanid, oplanid)) {
+            this.$set(this, `options`, _.cloneDeep(val));
+            this.reSearch();
+          }
+        }
+      },
+    },
+  },
   metaInfo() {
     return { title: this.$route.meta.title };
   },

+ 4 - 4
src/views/new-plan/arrange/school-time.vue

@@ -76,12 +76,12 @@ export default {
       rules: {},
       list: [],
       total: 0,
-      options: {},
+      options: undefined,
     };
   },
   async created() {
     await this.otherList();
-    // this.search();
+    this.search();
   },
   methods: {
     ...school({ getSchool: 'query' }),
@@ -145,9 +145,9 @@ export default {
     defaultOption: {
       handler(val, oval) {
         //1,进入页面,val有,oval没有=>都查
-        if (val && !oval) {
+        if (!_.get(this, 'options')) {
           this.$set(this, `options`, _.cloneDeep(val));
-          this.search();
+          // this.search();
         } else {
           let nplanid = _.get(val, 'planid');
           let oplanid = _.get(this.options, 'planid');

+ 0 - 3
src/views/new-plan/class/index-class.vue

@@ -1,7 +1,6 @@
 <template>
   <div id="index">
     <list-frame :title="pageTitle" @query="search" :total="total" :needFilter="false" :needAdd="false">
-      <searchBar :allow="['planBatch', 'plan', 'term', 'batch', 'classes']"></searchBar>
       <data-table
         :fields="fields"
         :data="list"
@@ -22,7 +21,6 @@
 var moment = require('moment');
 import _ from 'lodash';
 import Vue from 'vue';
-import searchBar from '@frame/components/search-bar';
 import listFrame from '@frame/layout/admin/list-frame';
 import dataTable from '@frame/components/data-table';
 import { mapState, createNamespacedHelpers } from 'vuex';
@@ -34,7 +32,6 @@ export default {
   components: {
     listFrame,
     dataTable,
-    searchBar,
   },
   data: () => {
     return {

+ 47 - 34
src/views/new-plan/class/quest.vue

@@ -2,24 +2,27 @@
   <div id="quest">
     <list-frame title="非常用问卷管理" @query="search" :needPag="false" :needFilter="false" :needAdd="false">
       <el-card style="padding:10px">
-        <data-table :fields="listFields" :data="termList" :opera="opera" @edit="toOpen"></data-table>
+        <!-- <data-table :fields="listFields" :data="termList" :opera="opera" @edit="toOpen"></data-table> -->
+        <el-row type="flex" align="middle" justify="center" style="margin-bottom:2rem">
+          <el-col :span="8">
+            <el-alert title="请为本期设置非常用问卷" :closable="false" center></el-alert>
+          </el-col>
+        </el-row>
+        <el-form :model="form" size="mini" label-width="80px">
+          <!-- <el-form-item label="期">
+            <el-select v-model="form.termid" placeholder="请选择期数">
+              <el-option v-for="(i, index) in termList" :key="index" :label="`第${i.term}期`" :value="i._id"></el-option>
+            </el-select>
+          </el-form-item> -->
+          <el-form-item label="问卷列表">
+            <data-table :fields="fields" :data="questList" :select="true" :selected="selected" @handleSelect="handleSelect"></data-table>
+          </el-form-item>
+          <el-form-item label="">
+            <el-button type="primary" @click="handleSave">保存</el-button>
+          </el-form-item>
+        </el-form>
       </el-card>
     </list-frame>
-    <el-dialog title="分配问卷" :visible.sync="dialog" @close="toClose">
-      <el-form :model="form" size="mini" label-width="80px">
-        <el-form-item label="期">
-          <el-select v-model="form.termid" placeholder="请选择期数">
-            <el-option v-for="(i, index) in termList" :key="index" :label="`第${i.term}期`" :value="i._id"></el-option>
-          </el-select>
-        </el-form-item>
-        <el-form-item label="问卷列表">
-          <data-table :fields="fields" :data="questList" :select="true" :selected="selected" @handleSelect="handleSelect"></data-table>
-        </el-form-item>
-        <el-form-item label="">
-          <el-button type="primary" @click="handleSave">保存</el-button>
-        </el-form-item>
-      </el-form>
-    </el-dialog>
   </div>
 </template>
 
@@ -57,39 +60,33 @@ export default {
       list: [],
       form: {},
       selected: [],
+      options: undefined,
     };
   },
-  created() {
-    this.search();
-  },
+  created() {},
   methods: {
     ...util({ modelFetch: 'fetch' }),
     ...trainplan(['fetch']),
     ...termquest({ getList: 'fetch', createList: 'create', updateList: 'update' }),
     ...questionnaire(['query', 'delete', 'mergeRequest']),
-    async search({ skip = 0, limit = 10, ...info } = {}) {
-      const res = await this.fetch(this.id);
-      if (this.$checkRes(res)) {
-        let { termnum } = res.data;
-        this.$set(this, `termList`, termnum);
-      }
-    },
-    async toOpen({ data } = {}) {
-      let res = await this.modelFetch({ model: 'termquest', termid: data._id });
+    async search() {
+      let termid = _.get(this.defaultOption, 'termid');
+      if (!termid) return;
+      let res = await this.modelFetch({ model: 'termquest', termid });
       let tsl = await this.query({ type: 1 });
       if (this.$checkRes(tsl)) {
         this.$set(this, `questList`, tsl.data);
       }
       if (this.$checkRes(res)) {
         let ids = _.get(res.data, `questionnaireid`);
-        this.$set(this.form, `termid`, data._id);
+        console.log(ids);
+        this.$set(this.form, `termid`, termid);
         this.$set(this.form, `id`, _.get(res.data, `_id`));
         if (ids) {
           let questList = await this.mergeRequest({ method: 'fetch', data: ids });
           this.$set(this, `selected`, questList);
-        }
+        } else this.$set(this, 'selected', []);
       }
-      this.dialog = true;
     },
     async handleSave() {
       let duplicate = _.cloneDeep(this.form);
@@ -117,12 +114,28 @@ export default {
     },
   },
   computed: {
-    ...mapState(['user']),
+    ...mapState(['user', 'defaultOption']),
     pageTitle() {
       return `${this.$route.meta.title}`;
     },
-    id() {
-      return this.$route.query.id;
+  },
+  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();
+          }
+        }
+      },
     },
   },
   metaInfo() {

+ 1 - 1
src/views/train-batch/index.vue

@@ -102,7 +102,7 @@ export default {
       if (this.$checkRes(res, `删除成功`, res.errmsg)) this.search();
     },
     toPlan({ data }) {
-      this.$router.push({ path: '/newPlan/index', query: { id: data.id } });
+      this.$router.push({ path: '/plan/index', query: { id: data.id } });
     },
   },
   computed: {