lrf402788946 5 år sedan
förälder
incheckning
c744fdc052

+ 5 - 5
components/calendar.vue

@@ -39,8 +39,8 @@
 <script>
 <script>
 import FullCalendar from '@fullcalendar/vue';
 import FullCalendar from '@fullcalendar/vue';
 import dayGridPlugin from '@fullcalendar/daygrid';
 import dayGridPlugin from '@fullcalendar/daygrid';
-import listPlugin from '@fullcalendar/list';
-import timeGridPlugin from '@fullcalendar/timegrid';
+// import listPlugin from '@fullcalendar/list';
+// import timeGridPlugin from '@fullcalendar/timegrid';
 import interactionPlugin from '@fullcalendar/interaction';
 import interactionPlugin from '@fullcalendar/interaction';
 var moment = require('moment');
 var moment = require('moment');
 import _ from 'lodash';
 import _ from 'lodash';
@@ -66,8 +66,8 @@ export default {
       calendarPlugins: [
       calendarPlugins: [
         // plugins must be defined in the JS
         // plugins must be defined in the JS
         dayGridPlugin,
         dayGridPlugin,
-        listPlugin,
-        timeGridPlugin,
+        // listPlugin,
+        // timeGridPlugin,
         interactionPlugin, // needed for dateClick
         interactionPlugin, // needed for dateClick
       ],
       ],
       planList: [],
       planList: [],
@@ -121,7 +121,7 @@ export default {
   },
   },
   computed: {
   computed: {
     defaultDate() {
     defaultDate() {
-      return `${this.year}-01-01`;
+      return moment().format('YYYY-MM-DD');
     },
     },
     rangeStart() {
     rangeStart() {
       return `${this.year}-01-01`;
       return `${this.year}-01-01`;

+ 1 - 1
config/menu-config.js

@@ -103,7 +103,7 @@ export const center = [
         module: 'center',
         module: 'center',
       },
       },
       {
       {
-        path: '/newPlan/classes/index',
+        path: '/newPlan/school/time',
         name: '学校参培时间',
         name: '学校参培时间',
         module: 'center',
         module: 'center',
       },
       },

+ 37 - 16
layout/admin/navBar/default-select.vue

@@ -1,7 +1,7 @@
 <template>
 <template>
   <div id="default-select">
   <div id="default-select">
-    <el-row type="flex" align="middle" justify="start" class="user-menu">
-      <el-col :span="12">
+    <el-row type="flex" align="middle" justify="start" class="user-menu" v-loading="loading">
+      <el-col :span="12" v-if="options">
         当前默认:
         当前默认:
         <span>
         <span>
           <el-tooltip :disabled="this.user.type != 0" content="点击更改默认批次" effect="dark" placement="bottom">
           <el-tooltip :disabled="this.user.type != 0" content="点击更改默认批次" effect="dark" placement="bottom">
@@ -18,14 +18,16 @@
         </span>
         </span>
         <span>
         <span>
           <el-tooltip :disabled="this.user.type != 0" content="点击更改默认年度计划" effect="dark" placement="bottom">
           <el-tooltip :disabled="this.user.type != 0" content="点击更改默认年度计划" effect="dark" placement="bottom">
-            <el-select v-model="options.planid" :disabled="this.user.type != 0" placeholder="未设置年度计划" size="mini">
+            <el-select v-model="options.planid" :disabled="this.user.type != 0" placeholder="未设置年度计划" size="mini" @change="getTermList">
               <el-option v-for="(i, index) in planList" :key="index" :label="i.title" :value="i._id"></el-option>
               <el-option v-for="(i, index) in planList" :key="index" :label="i.title" :value="i._id"></el-option>
             </el-select>
             </el-select>
           </el-tooltip>
           </el-tooltip>
         </span>
         </span>
         <span>
         <span>
           <el-tooltip content="点击更改默认期" effect="dark" placement="bottom">
           <el-tooltip content="点击更改默认期" effect="dark" placement="bottom">
-            <el-select v-model="options.termid" placeholder="未设置默认期" size="mini"></el-select>
+            <el-select v-model="options.termid" placeholder="未设置默认期" size="mini">
+              <el-option v-for="(i, index) in termList" :key="index" :label="`第${i.term}期`" :value="i._id"></el-option>
+            </el-select>
           </el-tooltip>
           </el-tooltip>
         </span>
         </span>
         <span>
         <span>
@@ -48,15 +50,18 @@ export default {
   components: {},
   components: {},
   data: function() {
   data: function() {
     return {
     return {
-      options: {},
+      loading: true,
+      options: undefined,
       planYearList: [],
       planYearList: [],
       planList: [],
       planList: [],
       termList: [],
       termList: [],
     };
     };
   },
   },
-  created() {
-    this.$set(this, `options`, _.cloneDeep(this.defaultOption));
+  async created() {
+    // this.$set(this, `options`, _.cloneDeep(this.defaultOption));
+    this.search({ type: 'planYear' });
     this.checkOption();
     this.checkOption();
+    this.loading = false;
   },
   },
   methods: {
   methods: {
     ...mapMutations(['deleteUser', 'changeOpt']),
     ...mapMutations(['deleteUser', 'changeOpt']),
@@ -68,28 +73,32 @@ export default {
       if (this.$checkRes(res)) {
       if (this.$checkRes(res)) {
         this.$set(this, `${type}List`, res.data);
         this.$set(this, `${type}List`, res.data);
         if (type == 'plan') {
         if (type == 'plan') {
-          let term = _.get(res.data, 'termnum', []);
-          this.$set(this, `termList`, term);
+          let planid = _.get(this.options, 'planid');
+          this.getTermList(planid);
         }
         }
       }
       }
     },
     },
     checkOption() {
     checkOption() {
-      if (_.get(this.options, 'planyearid')) {
-        this.search({ type: 'planYear' });
-        if (_.get(this.options, 'planid')) {
-          this.search({ type: 'plan', planyearid: _.get(this.options, 'planyearid') });
-        }
+      if (_.get(this.options, 'planid')) {
+        this.search({ type: 'plan', planyearid: _.get(this.options, 'planyearid') });
       }
       }
     },
     },
     async changeList(type, data) {
     async changeList(type, data) {
       let obj = { type };
       let obj = { type };
       let res;
       let res;
+      this.toClear();
+      this.setVuexOpt();
       if (type == 'plan') {
       if (type == 'plan') {
         obj[`planyearid`] = data;
         obj[`planyearid`] = data;
         await this.search(obj);
         await this.search(obj);
       }
       }
-      this.toClear();
-      this.setVuexOpt();
+    },
+    getTermList(planid) {
+      let r = this.planList.find(f => f.id == planid);
+      if (r) {
+        let term = _.get(r, 'termnum', []);
+        this.$set(this, `termList`, term);
+      }
     },
     },
     setVuexOpt() {
     setVuexOpt() {
       this.changeOpt(this.options);
       this.changeOpt(this.options);
@@ -111,6 +120,18 @@ export default {
       this.$checkRes(res, '设置成功', res.errmsg);
       this.$checkRes(res, '设置成功', res.errmsg);
     },
     },
   },
   },
+  watch: {
+    defaultOption: {
+      handler(val) {
+        if (val) {
+          let opt = _.get(this, `options`);
+          if (!opt) this.$set(this, `options`, _.cloneDeep(val));
+        }
+      },
+      immediate: true,
+      deep: true,
+    },
+  },
   computed: {
   computed: {
     ...mapState(['user', 'defaultOption']),
     ...mapState(['user', 'defaultOption']),
     pageTitle() {
     pageTitle() {

+ 7 - 0
store/setting.js

@@ -24,8 +24,15 @@ const actions = {
       }
       }
     }
     }
   },
   },
+  async checkCache({ commit }) {
+    let res = commit('setDefOpt', null, { root: true });
+    console.log(res);
+  },
   async update({ commit }, { id, ...data }) {
   async update({ commit }, { id, ...data }) {
     const res = await this.$axios.$post(`${api.update(id)}`, data);
     const res = await this.$axios.$post(`${api.update(id)}`, data);
+    if (res.errcode == '0') {
+      commit('setDefOpt', res.data.data, { root: true });
+    }
     return res;
     return res;
   },
   },
 };
 };

+ 4 - 3
store/setting/mutations.js

@@ -1,14 +1,15 @@
 import _ from 'lodash';
 import _ from 'lodash';
 export const setDefOpt = (state, payload) => {
 export const setDefOpt = (state, payload) => {
-  let res = true;
-  //登陆时
+  let res;
+
   if (payload) {
   if (payload) {
     sessionStorage.setItem('defaultOption', JSON.stringify(payload));
     sessionStorage.setItem('defaultOption', JSON.stringify(payload));
     state.defaultOption = payload;
     state.defaultOption = payload;
+    res = 'set';
   } else {
   } else {
-    //已经登陆,切换路由时取出用户信息放在总store中
     let defaultOption = sessionStorage.getItem('defaultOption');
     let defaultOption = sessionStorage.getItem('defaultOption');
     if (defaultOption) state.defaultOption = JSON.parse(defaultOption);
     if (defaultOption) state.defaultOption = JSON.parse(defaultOption);
+    res = 'cache';
   }
   }
   return res;
   return res;
 };
 };