lrf402788946 5 years ago
parent
commit
c4121f83cd

+ 1 - 0
.env

@@ -1,4 +1,5 @@
 VUE_APP_AXIOS_BASE_URL = ''
 VUE_APP_ROOT_URL=/admin/
 VUE_APP_MODULE='center'
+VUE_APP_USER_TYPE = '0'
 VUE_APP_LIMIT = 10

+ 4 - 1
src/App.vue

@@ -4,7 +4,7 @@
   </div>
 </template>
 <script>
-import { createNamespacedHelpers } from 'vuex';
+import { mapState, createNamespacedHelpers } from 'vuex';
 import _ from 'lodash';
 const { mapActions } = createNamespacedHelpers('login');
 export default {
@@ -13,6 +13,9 @@ export default {
   created() {
     this.toLogin();
   },
+  computed: {
+    ...mapState(['user']),
+  },
   methods: {
     ...mapActions(['login']),
     async toLogin() {

+ 9 - 1
src/router/index.js

@@ -262,7 +262,15 @@ const router = new VueRouter({
 router.beforeEach((to, form, next) => {
   store.commit('setUser');
   let user = store.state.user;
-  if (user) next();
+  if (user) {
+    if (user.type == process.env.VUE_APP_USER_TYPE) {
+      console.log('缓存登陆');
+      next();
+    } else {
+      console.error('非当前端用户,需要重新登陆');
+      // next('/login'); //TODO 跳转至登陆页
+    }
+  }
   //下面是没登录的情况,需要跳转页面到用户未登录页
   else next();
 });

+ 6 - 21
src/store/index.js

@@ -20,7 +20,10 @@ import lesson from '@frame/store/lesson';
 import nation from '@frame/store/nation';
 import completion from '@frame/store/question-completion';
 import termquest from '@frame/store/termquest';
+import dirPlan from '@frame/store/dir-plan';
 import login from '@frame/store/login';
+import * as ustate from '@frame/store/user/state';
+import * as umutations from '@frame/store/user/mutations';
 
 Vue.use(Vuex);
 
@@ -47,27 +50,9 @@ export default new Vuex.Store({
     completion,
     termquest,
     login,
+    dirPlan,
   },
-  state: {
-    user: {},
-  },
-  mutations: {
-    setUser(state, payload) {
-      let res = true;
-      //登陆时
-      if (payload) state.user = payload;
-      else {
-        //已经登陆,切换路由时取出用户信息放在总store中
-        let user = sessionStorage.getItem('user');
-        if (user) state.user = JSON.parse(user);
-        else {
-          res = false;
-          state.user = undefined;
-          console.warn('用户未登录');
-        }
-      }
-      return res;
-    },
-  },
+  state: { ...ustate },
+  mutations: { ...umutations },
   actions: {},
 });

+ 2 - 2
src/views/director/detail.vue

@@ -39,10 +39,10 @@ export default {
   data: () => ({
     info: {},
     fields: [
-      { label: '姓名', required: true, model: 'name' },
+      { label: '姓名', required: true, model: 'name', tip: '请输入姓名' },
       { label: '所属部门', required: true, model: 'department', type: 'select' },
       { label: '性别', required: true, model: 'gender', type: `radio` },
-      { label: '电话', required: true, model: 'phone', options: { maxlength: 11, minlength: 11 } },
+      { label: '电话', required: true, model: 'phone', options: { maxlength: 11, minlength: 11 }, tip: '请输入11位点话号码' },
       { label: '出生日期', required: true, model: 'birthday', type: 'date' },
       { label: '年龄', required: true, model: 'age' },
       { label: '礼仪课教师', required: true, model: 'is_etiquette_teacher', type: 'radio' },

+ 1 - 0
src/views/director/index.vue

@@ -37,6 +37,7 @@ export default {
         label: '删除',
         icon: 'el-icon-delete',
         method: 'delete',
+        methodZh: '注意,删除班主任信息,其账号将一并删除',
         confirm: true,
       },
     ],

+ 0 - 10
src/views/plan/index.vue

@@ -10,7 +10,6 @@
         @publish="toPublish"
         @classes="toClasses"
         @lesson="toLesson"
-        @msg="toMsg"
         @ques="toQues"
       ></data-table>
     </list-frame>
@@ -66,12 +65,6 @@ export default {
         display: i => i.status === '1',
         method: 'lesson',
       },
-      {
-        label: '发送确认通知',
-        icon: 'el-icon-message-solid',
-        display: i => i.status === '1',
-        method: 'msg',
-      },
       {
         label: '添加调查问卷',
         icon: 'el-icon-edit-outline',
@@ -124,9 +117,6 @@ export default {
     toClasses({ data }) {
       this.$router.push({ path: '/plan/classes', query: { id: data.id } });
     },
-    toMsg({ data }) {
-      this.$router.push({ path: '/plan/msg', query: { id: data.id } });
-    },
     toQues({ data }) {
       this.$router.push({ path: '/plan/question', query: { id: data.id } });
     },

+ 10 - 5
src/views/plan/lesson-plan.vue

@@ -7,11 +7,12 @@
             <span style="font-size:24px">{{ item.name }}</span>
           </template>
           <data-table style="padding:10px" ref="table" :fields="fields" :data="item.lessons" :opera="opera" @edit="toEdit"></data-table>
-          <el-form :inline="true" size="small" style="padding:0 10px" label-width="120px" @submit.native.prevent>
+          <el-form :inline="true" size="mini" label-width="120px" @submit.native.prevent>
             <el-form-item label="班主任">
               <el-select v-model="item.headteacherid" placeholder="请选择班主任">
                 <el-option-group v-for="group in directorList" :key="group.label" :label="group.label">
-                  <el-option v-for="item in group.options" :key="item._id" :label="item.name" :value="item._id"> </el-option>
+                  <el-option v-for="item in group.options" :key="item._id" :label="`${item.name}${item.status === '0' ? '(已上报)' : ''}`" :value="item._id">
+                  </el-option>
                 </el-option-group>
               </el-select>
             </el-form-item>
@@ -149,8 +150,9 @@ const { mapActions: location } = createNamespacedHelpers('location'); //地点
 const { mapActions: subject } = createNamespacedHelpers('subject'); //科目
 const { mapActions: teacher } = createNamespacedHelpers('teacher'); //教师
 const { mapActions: teaPlan } = createNamespacedHelpers('teaPlan'); //教师申请
-const { mapActions: director } = createNamespacedHelpers('director'); //教师
+const { mapActions: director } = createNamespacedHelpers('director'); //教师 //TODO 接口合并,可能不需要了
 const { mapActions: dept } = createNamespacedHelpers('dept'); //配合教师表使用的部门表
+const { mapActions: dirPlan } = createNamespacedHelpers('dirPlan'); //班主任不能上课的列表
 
 export default {
   name: 'lesson-plan',
@@ -158,6 +160,8 @@ export default {
     startDate: { type: String, required: true },
     endDate: { type: String, required: true },
     classes: { type: Array, default: () => [] },
+    trainplanid: { type: String },
+    batchid: { type: String },
   },
   components: { dataTable, timeTable, cards },
   data: () => ({
@@ -220,11 +224,12 @@ export default {
     this.getOtherList();
   },
   methods: {
+    ...dirPlan({ dirQuery: 'getDirTeacher' }),
     ...location({ getLocationList: 'query' }),
     ...subject({ getSubjectList: 'query' }),
     ...teacher({ getTeacherList: 'query' }),
     ...teaPlan({ getApplyTeacherList: 'applyQuery' }),
-    ...director({ getDirectorList: 'query' }),
+    ...director({ getDirectorList: 'query' }), //TODO 接口合并,可能不需要了
     ...dept({ getDeptList: 'query' }),
     setDateList() {
       let start = new Date(this.startDate);
@@ -329,7 +334,7 @@ export default {
       if (this.$checkRes(res)) this.$set(this, `lyTeacherList`, res.data);
       res = await this.getDeptList();
       if (this.$checkRes(res)) this.$set(this, `deptList`, res.data);
-      res = await this.getDirectorList();
+      res = await this.dirQuery({ batchid: this.batchid });
       if (this.$checkRes(res)) {
         let arr = res.data;
         arr = arr.map(i => {

+ 32 - 8
src/views/plan/lesson.vue

@@ -16,10 +16,17 @@
             <el-option v-for="(i, index) in termList" :key="index" :label="`第${i.term}期`" :value="i._id"></el-option>
           </template>
         </template>
-        <data-table ref="table" :fields="fields" :data="list" :opera="opera" @date="toDate"></data-table>
+        <data-table ref="table" :fields="fields" :data="list" :opera="opera" @date="toDate" @msg="toMsg"></data-table>
       </list-frame>
       <detail-frame v-else title="返回批次列表" :returns="returnList">
-        <lesson-plan :startDate="batch.startdate" :endDate="batch.enddate" :classes="classes" @save="handleSave"></lesson-plan>
+        <lesson-plan
+          :startDate="batch.startdate"
+          :endDate="batch.enddate"
+          :classes="classes"
+          :trainplanid="id"
+          :batchid="batchid"
+          @save="handleSave"
+        ></lesson-plan>
       </detail-frame>
     </transition>
   </div>
@@ -52,6 +59,11 @@ export default {
         icon: 'el-icon-date',
         method: 'date',
       },
+      {
+        label: '发送确认通知',
+        icon: 'el-icon-message-solid',
+        method: 'msg',
+      },
     ],
     fields: [
       { label: '', prop: 'name' },
@@ -62,12 +74,13 @@ export default {
     batch: {},
     total: 0,
     classes: [],
+    batchid: [],
   }),
   created() {
     this.search();
   },
   methods: {
-    ...trainPlan({ getTrainPlan: 'fetch' }),
+    ...trainPlan({ getTrainPlan: 'fetch', sendNotice: 'notice' }),
     ...mapClasses({ getClass: 'query', updateClass: 'update' }),
     ...lesson({ getLessonList: 'query', lessonCreate: 'create', lessonUpdate: 'update' }),
     async search({ skip = 0, limit = 10, ...info } = {}) {
@@ -84,6 +97,7 @@ export default {
     },
     async toDate({ data }) {
       let res = await this.getClass({ batchid: data._id });
+      this.$set(this, 'batchid', data._id);
       // this.view = 'lesson';
       let { startdate, enddate } = data;
       this.$set(this.batch, `startdate`, startdate);
@@ -104,9 +118,9 @@ export default {
             } else {
               //没排课,需要动手干下,整理好数据
               let object = { name, lyteacherid, yclocationid, kzjhlocationid, kbyslocationid, headteacherid, jslocationid };
-              object.class = tClass.id;
-              object.batch = tClass.batchid;
-              object.term = tClass.termid;
+              object.classid = tClass.id;
+              object.batchid = tClass.batchid;
+              object.termid = tClass.termid;
               cArr.push(object);
             }
           }
@@ -123,8 +137,8 @@ export default {
       //根据data中是否有id,判断是课表的添加还是修改
       //解构出data中class字段,是班级id,将各种地点,礼仪课老师,班主任修改好
       let classid = data.class;
-      let { lessons, term, batch, headteacherid, jslocationid, yclocationid, kzjhlocationid, kbyslocationid, lyteacherid } = data;
-      let newLessons = { lessons, term, batch, class: classid };
+      let { lessons, termid, batchid, headteacherid, jslocationid, yclocationid, kzjhlocationid, kbyslocationid, lyteacherid } = data;
+      let newLessons = { lessons, termid, batchid, classid };
       let newClass = { id: classid, headteacherid, jslocationid, yclocationid, kzjhlocationid, kbyslocationid, lyteacherid };
       let lid = _.get(data, `id`);
       let res;
@@ -148,6 +162,16 @@ export default {
         check(res, '班级信息修改成功', '班级信息修改失败');
       }
     },
+    async toMsg({ data }) {
+      let res = await this.getClass({ batchid: data._id });
+      if (this.$checkRes(res)) {
+        let arr = res.data.map(i => i.id);
+        if (arr.length > 0) {
+          const resNotice = await this.sendNotice({ classids: arr });
+          this.$checkRes(resNotice, '发送成功', '发送失败');
+        } else this.$message.warning(`该批次下未分班`);
+      }
+    },
   },
   computed: {
     mainTitle() {

+ 5 - 4
src/views/test/detail.vue

@@ -1,17 +1,18 @@
 <template>
   <div id="detail">
-    <time-table></time-table>
+    <iframe v-if="url" :src="url" frameborder="0" allow="autoplay;encrypted-media" allowfullscreen style="width:100%;height:500px;"> </iframe>
   </div>
 </template>
 
 <script>
-import timeTable from '@frame/parts/time-table';
 export default {
   metaInfo: { title: '' },
   name: 'detail',
   props: {},
-  components: { timeTable },
-  data: () => ({}),
+  components: {},
+  data: () => ({
+    url: undefined,
+  }),
   created() {},
   computed: {},
   methods: {},