lrf402788946 5 anos atrás
pai
commit
fed77894b5

+ 18 - 5
components/calendar.vue

@@ -13,13 +13,16 @@
       :header="headers"
       :button-text="{
         today: '今天',
+        dayGridMonth: '月视图',
+        dayGridWeek: '周视图',
+        listMonth: '月列表',
       }"
       :valid-range="{
         start: rangeStart,
         end: rangeEnd,
       }"
       :slot-event-overlap="false"
-      defaultView="dayGridMonth"
+      :defaultView="view"
       :plugins="calendarPlugins"
       :selectable="useDraft"
       :events="event"
@@ -29,7 +32,6 @@
       :views="views"
       :displayEventEnd="true"
       :displayEventTime="true"
-      :allday="true"
     />
   </div>
 </template>
@@ -37,6 +39,8 @@
 <script>
 import FullCalendar from '@fullcalendar/vue';
 import dayGridPlugin from '@fullcalendar/daygrid';
+import listPlugin from '@fullcalendar/list';
+import timeGridPlugin from '@fullcalendar/timegrid';
 import interactionPlugin from '@fullcalendar/interaction';
 var moment = require('moment');
 import _ from 'lodash';
@@ -54,13 +58,16 @@ export default {
     FullCalendar, // make the <FullCalendar> tag available
   },
   data: function() {
+    var that = this;
     return {
+      view: 'dayGridMonth',
       form: { isAllDay: true },
       dialog: false,
       calendarPlugins: [
         // plugins must be defined in the JS
         dayGridPlugin,
-        // timeGridPlugin,
+        listPlugin,
+        timeGridPlugin,
         interactionPlugin, // needed for dateClick
       ],
       planList: [],
@@ -68,13 +75,19 @@ export default {
       headers: {
         left: 'prev',
         center: 'title',
-        right: 'today ,next',
+        right: 'dayGridMonth,dayGridWeek, today ,next',
       },
       btn: {},
       views: {
         dayGridMonth: {
           eventLimit: _.clone(this.eventLimit),
         },
+        dayGridWeek: {
+          duration: { day: 7 },
+        },
+        listMonth: {
+          eventLimit: _.clone(this.eventLimit),
+        },
       },
     };
   },
@@ -101,7 +114,7 @@ export default {
         let { position, ...info } = selfBtn[key];
         selfBtn[key] = { ...info };
         if (position === 'left') this.headers.left = `${this.headers.left}, ${key}`;
-        else this.headers.right = `${this.headers.right}, ${key}`;
+        else this.headers.right = `${key}, ${this.headers.right} `;
       }
       this.$set(this, `btn`, selfBtn);
     },

+ 4 - 3
components/filter-page-table.vue

@@ -83,7 +83,7 @@
       <el-col :span="24" style="text-align:right;">
         <el-pagination
           background
-          layout="sizes, total, prev, pager, next"
+          layout="total, prev, pager, next"
           :page-sizes="[10, 15, 20, 50, 100]"
           :total="total"
           :page-size="limit"
@@ -92,6 +92,7 @@
           @size-change="sizeChange"
         >
         </el-pagination>
+        <!-- sizes -->
       </el-col>
     </el-row>
   </div>
@@ -119,7 +120,7 @@ export default {
   data: () => ({
     pageSelected: [],
     currentPage: 1,
-    limit: _.get(this, `$limit`, undefined) !== undefined ? this.$limit : process.env.VUE_APP_LIMIT * 1,
+    limit: _.get(this, `$limit`, undefined) !== undefined ? this.$limit : process.env.VUE_APP_LIMIT * 1 || 10,
     searchInfo: {},
     useFilter: true,
     filterList: [],
@@ -216,7 +217,7 @@ export default {
       }
     },
     //
-    changePage(page) {
+    changePage(page = this.currentPage) {
       this.$emit('query', { skip: (page - 1) * this.limit, limit: this.limit, ...this.searchInfo });
     },
     sizeChange(limit) {

+ 3 - 0
components/form.vue

@@ -39,6 +39,9 @@
                     >
                     </el-date-picker>
                   </template>
+                  <template v-else-if="item.type === 'time'">
+                    <el-time-picker v-model="form[item.model]" placeholder="请选择时间" format="HH:mm" value-format="HH:mm"></el-time-picker>
+                  </template>
                   <template v-else-if="item.type === 'radio'">
                     <el-radio-group v-model="form[item.model]" size="mini" v-bind="item.options">
                       <slot name="radios" v-bind="{ item, form, fieldChange }"></slot>

+ 4 - 4
config/menu-config.js

@@ -84,21 +84,21 @@ export const center = [
   },
   {
     path: '',
-    name: '计划管理',
+    name: '计划管理',
     module: 'center',
     children: [
       {
-        path: '/newPlan/classes/index',
+        path: '/newPlan/arrange',
         name: '当前计划日历',
         module: 'center',
       },
       {
-        path: '/newPlan/classes/index',
+        path: '/newPlan/director',
         name: '班主任全年安排',
         module: 'center',
       },
       {
-        path: '/newPlan/classes/index',
+        path: '/newPlan/school/num',
         name: '学校总人数设置',
         module: 'center',
       },

+ 4 - 25
layout/admin/navBar.vue

@@ -31,20 +31,7 @@
         </div>
       </div>
       <div>
-        <el-row type="flex" align="middle" justify="start" class="user-menu">
-          <el-col :span="10">
-            当前默认:
-            <el-tooltip :disabled="this.user.type != 0" content="点击更改默认批次" effect="dark" placement="bottom">
-              <el-button type="text" :disabled="this.user.type != 0">1批次</el-button>
-            </el-tooltip>
-            <el-tooltip :disabled="this.user.type != 0" content="点击更改默认年度计划" effect="dark" placement="bottom">
-              <el-button type="text" :disabled="this.user.type != 0">2020年度计划</el-button>
-            </el-tooltip>
-            <el-tooltip content="点击更改默认期" effect="dark" placement="bottom">
-              <el-button type="text">第n期</el-button>
-            </el-tooltip>
-          </el-col>
-        </el-row>
+        <def-sel></def-sel>
       </div>
     </el-menu>
     <el-dialog title="修改密码" :visible.sync="dialog" center @close="toClose" :destroy-on-close="true">
@@ -62,6 +49,7 @@
 
 <script>
 import Vue from 'vue';
+import defSel from '@frame/layout/admin/navBar/default-select.vue';
 import '@frame/plugins/setting';
 import qrcode from '@frame/components/qrcode.vue';
 import dataForm from '@frame/components/form';
@@ -71,7 +59,7 @@ const { mapActions } = createNamespacedHelpers('login');
 export default {
   name: 'navBar',
   props: {},
-  components: { dataForm, qrcode },
+  components: { dataForm, qrcode, defSel },
   data: () => ({
     weixin: require('@frame/assets/wechat.png'),
     dataUrl: '',
@@ -94,7 +82,7 @@ export default {
     ...mapState(['user']),
   },
   methods: {
-    ...mapMutations(['deleteUser']),
+    ...mapMutations(['deleteUser', 'changeOption']),
     ...mapActions(['login', 'update', 'getQrcode']),
     async toLogout() {
       this.deleteUser();
@@ -195,14 +183,5 @@ export default {
       font-size: 0.75rem;
     }
   }
-  .user-menu {
-    height: 4rem;
-    .el-col {
-      margin-left: 1rem;
-      .el-button {
-        font-size: 16px;
-      }
-    }
-  }
 }
 </style>

+ 136 - 0
layout/admin/navBar/default-select.vue

@@ -0,0 +1,136 @@
+<template>
+  <div id="default-select">
+    <el-row type="flex" align="middle" justify="start" class="user-menu">
+      <el-col :span="12">
+        当前默认:
+        <span>
+          <el-tooltip :disabled="this.user.type != 0" content="点击更改默认批次" effect="dark" placement="bottom">
+            <el-select
+              v-model="options.planyearid"
+              :disabled="this.user.type != 0"
+              placeholder="未设置培训批次"
+              size="mini"
+              @change="data => changeList('plan', data)"
+            >
+              <el-option v-for="(i, index) in planYearList" :key="index" :label="i.title" :value="i._id"></el-option>
+            </el-select>
+          </el-tooltip>
+        </span>
+        <span>
+          <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-option v-for="(i, index) in planList" :key="index" :label="i.title" :value="i._id"></el-option>
+            </el-select>
+          </el-tooltip>
+        </span>
+        <span>
+          <el-tooltip content="点击更改默认期" effect="dark" placement="bottom">
+            <el-select v-model="options.termid" placeholder="未设置默认期" size="mini"></el-select>
+          </el-tooltip>
+        </span>
+        <span>
+          <el-button type="text" size="mini" @click="settingSave">保存默认值</el-button>
+        </span>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import _ from 'lodash';
+import { mapState, mapMutations, createNamespacedHelpers } from 'vuex';
+const { mapActions: trainBatch } = createNamespacedHelpers('trainBatch');
+const { mapActions: trainplan } = createNamespacedHelpers('trainplan');
+const { mapActions: setting } = createNamespacedHelpers('setting');
+export default {
+  name: 'default-select',
+  props: {},
+  components: {},
+  data: function() {
+    return {
+      options: {},
+      planYearList: [],
+      planList: [],
+      termList: [],
+    };
+  },
+  created() {
+    this.$set(this, `options`, _.cloneDeep(this.defaultOption));
+    this.checkOption();
+  },
+  methods: {
+    ...mapMutations(['deleteUser', 'changeOpt']),
+    ...trainBatch({ getplanYear: 'query' }),
+    ...trainplan({ getplan: 'query' }),
+    ...setting({ sFetch: 'fetch', sUpdate: 'update' }),
+    async search({ type, ...info }) {
+      let res = await _.get(this, `get${type}`)({ ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `${type}List`, res.data);
+        if (type == 'plan') {
+          let term = _.get(res.data, 'termnum', []);
+          this.$set(this, `termList`, term);
+        }
+      }
+    },
+    checkOption() {
+      if (_.get(this.options, 'planyearid')) {
+        this.search({ type: 'planYear' });
+        if (_.get(this.options, 'planid')) {
+          this.search({ type: 'plan', planyearid: _.get(this.options, 'planyearid') });
+        }
+      }
+    },
+    async changeList(type, data) {
+      let obj = { type };
+      let res;
+      if (type == 'plan') {
+        obj[`planyearid`] = data;
+        await this.search(obj);
+      }
+      this.toClear();
+      this.setVuexOpt();
+    },
+    setVuexOpt() {
+      this.changeOpt(this.options);
+    },
+    toClear() {
+      let planid = _.get(this.options, 'planid');
+      if (planid) {
+        let res = this.planList.find(f => f.id == planid);
+        if (!res) this.$set(this.options, 'planid', undefined);
+      }
+      let termid = _.get(this.options, 'termid');
+      if (termid) {
+        let res = this.planList.find(f => f.id == planid);
+        if (!res) this.$set(this.options, 'termid', undefined);
+      }
+    },
+    async settingSave() {
+      let res = await this.sUpdate(this.options);
+      this.$checkRes(res, '设置成功', res.errmsg);
+    },
+  },
+  computed: {
+    ...mapState(['user', 'defaultOption']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.user-menu {
+  height: 4rem;
+  .el-col {
+    margin-left: 10px;
+    span {
+      margin-left: 10px;
+    }
+  }
+}
+</style>

+ 37 - 0
store/setting.js

@@ -0,0 +1,37 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+import axios from 'axios';
+Vue.use(Vuex);
+const api = {
+  interface: `/api/train/setting/findone`,
+  update: id => `/api/train/setting/update/${id}`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.interface}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await axios.get(api.interface);
+    if (res.status == 200) {
+      if (res.data && res.data.errcode == 0) {
+        commit('setDefOpt', res.data.data, { root: true });
+        return res.data;
+      }
+    }
+  },
+  async update({ commit }, { id, ...data }) {
+    const res = await this.$axios.$post(`${api.update(id)}`, data);
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 22 - 0
store/setting/mutations.js

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

+ 1 - 0
store/setting/state.js

@@ -0,0 +1 @@
+export const defaultOption = undefined;

+ 64 - 0
store/train-plan-year.js

@@ -0,0 +1,64 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+import axios from 'axios';
+Vue.use(Vuex);
+const api = {
+  interface: `/api/train/trainplanyear`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.interface}`, { skip, limit, ...info });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.interface}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.interface}/${payload}`);
+    return res;
+  },
+  async update({ commit }, { id, ...data }) {
+    const res = await this.$axios.$post(`${api.interface}/update/${id}`, data);
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.interface}/${payload}`);
+    return res;
+  },
+  async mergeRequest({ commit, dispatch }, { method, data }) {
+    let toRequest = () => {
+      let res = [];
+      for (const i of data) {
+        res.push(dispatch(method, i));
+      }
+      return res;
+    };
+    let result = await axios.all(toRequest());
+    let newFilter = data => {
+      let res = data.map(i => {
+        let type = _.isArray(i);
+        if (!type) {
+          //fetch的多个请求 是object 将errcode为0的data取出来
+          return _.get(i, `data`, i);
+        } else {
+          //query的多个请求 array 将此数据再次走这个方法
+          return newFilter(i);
+        }
+      });
+      return res;
+    };
+    let returns = _.flattenDeep(newFilter(result));
+    return returns;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};