lrf402788946 před 5 roky
rodič
revize
667b16b2e7

+ 6 - 0
src/router/index.js

@@ -250,6 +250,12 @@ const routes = [
         meta: { title: '安排', sub: '课程' },
         component: () => import('@/views/plan/lesson.vue'),
       },
+      {
+        path: '/plan/msg',
+        name: 'plan_msg',
+        meta: { title: '发送', sub: '通知' },
+        component: () => import('@/views/plan/msg.vue'),
+      },
     ],
   },
   {

+ 2 - 0
src/store/index.js

@@ -18,6 +18,7 @@ import schPlan from '@frame/store/sch-plan';
 import teaPlan from '@frame/store/tea-plan';
 import lesson from '@frame/store/lesson';
 import nation from '@frame/store/nation';
+import completion from '@frame/store/question-completion';
 
 Vue.use(Vuex);
 
@@ -41,6 +42,7 @@ export default new Vuex.Store({
     teaPlan,
     lesson,
     nation,
+    completion,
   },
   state: {},
   mutations: {},

+ 4 - 4
src/views/Itembank/detail.vue

@@ -24,7 +24,7 @@
             <el-col :span="24">
               <el-table :data="info.option" border stripe size="mini">
                 <el-table-column align="center" label="序号" prop="number"></el-table-column>
-                <el-table-column align="center" label="内容" prop="option_name"></el-table-column>
+                <el-table-column align="center" label="内容" prop="opname"></el-table-column>
                 <el-table-column align="center" label="操作">
                   <template v-slot="{ row, $index }">
                     <el-tooltip effect="dark" content="编辑" placement="bottom">
@@ -105,11 +105,11 @@ export default {
     ],
     oFields: [
       { label: '序号', required: true, model: 'number' },
-      { label: '内容', required: true, model: 'option_name' },
+      { label: '内容', required: true, model: 'opname' },
     ],
     oRules: {
       number: [{ required: true, message: '请输入序号' }],
-      option_name: [{ required: true, message: '请输入内容' }],
+      opname: [{ required: true, message: '请输入内容' }],
     },
     rules: {
       type: [{ required: true, message: '请选择类型', trigger: 'blur' }],
@@ -169,7 +169,7 @@ export default {
       let msg;
       let newData = {};
       let { type, option, answer, ...other } = this.info;
-      if (type === 0 || type === 1) newData = this.info;
+      if (type === '0' || type === '1') newData = this.info;
       else newData = { type, ...other };
       if (this.isNew) {
         res = await this.create(newData);

+ 12 - 2
src/views/plan/index.vue

@@ -10,6 +10,7 @@
         @publish="toPublish"
         @classes="toClasses"
         @lesson="toLesson"
+        @msg="toMsg"
       ></data-table>
     </list-frame>
   </div>
@@ -19,7 +20,7 @@
 import listFrame from '@frame/layout/admin/list-frame';
 import dataTable from '@frame/components/data-table';
 import { createNamespacedHelpers } from 'vuex';
-const { mapActions } = createNamespacedHelpers('trainplan');
+const { mapActions: trainPlan } = createNamespacedHelpers('trainplan');
 
 export default {
   metaInfo: { title: '计划管理' },
@@ -64,6 +65,12 @@ export default {
         display: i => i.status === '1',
         method: 'lesson',
       },
+      {
+        label: '发送确认通知',
+        icon: 'el-icon-message-solid',
+        display: i => i.status === '1',
+        method: 'msg',
+      },
     ],
     fields: [
       { label: '计划标题', prop: 'title' },
@@ -83,7 +90,7 @@ export default {
     this.search();
   },
   methods: {
-    ...mapActions(['query', 'delete', 'update']),
+    ...trainPlan(['query', 'delete', 'update']),
     async search({ skip = 0, limit = 10, ...info } = {}) {
       const res = await this.query({ skip, limit, ...info });
       if (this.$checkRes(res)) {
@@ -110,6 +117,9 @@ 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 } });
+    },
   },
   computed: {
     mainTitle() {

+ 55 - 70
src/views/plan/lesson-plan.vue

@@ -1,56 +1,61 @@
 <template>
   <div id="lesson-plan">
     <el-collapse v-model="activeName" accordion>
-      <el-collapse-item v-for="(item, index) in classList" :key="`coli${index}`" :name="`${index}`">
-        <template slot="title">
-          <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-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-group>
-            </el-select>
-          </el-form-item>
+      <template v-if="classList.length > 0">
+        <el-collapse-item v-for="(item, index) in classList" :key="`coli${index}`" :name="`${index}`">
+          <template slot="title">
+            <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-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-group>
+              </el-select>
+            </el-form-item>
 
-          <el-form-item label="礼仪课教师">
-            <el-select v-model="item.lyteacherid" placeholder="请选择礼仪课教师">
-              <el-option v-for="(tea, index) in lyTeacherList" :key="`lytea${index}`" :label="tea.name" :value="tea.id"></el-option>
-            </el-select>
-          </el-form-item>
+            <el-form-item label="礼仪课教师">
+              <el-select v-model="item.lyteacherid" placeholder="请选择礼仪课教师">
+                <el-option v-for="(tea, index) in lyTeacherList" :key="`lytea${index}`" :label="tea.name" :value="tea.id"></el-option>
+              </el-select>
+            </el-form-item>
 
-          <el-form-item label="教室地点">
-            <el-select v-model="item.jslocationid" placeholder="请选择教室地点">
-              <el-option v-for="(place, index) in locationList" :key="`lytea${index}`" :label="place.name" :value="place.id"></el-option>
-            </el-select>
-          </el-form-item>
+            <el-form-item label="教室地点">
+              <el-select v-model="item.jslocationid" placeholder="请选择教室地点">
+                <el-option v-for="(place, index) in locationList" :key="`lytea${index}`" :label="place.name" :value="place.id"></el-option>
+              </el-select>
+            </el-form-item>
 
-          <el-form-item label="开班地点">
-            <el-select v-model="item.kbyslocationid" placeholder="请选择开班地点">
-              <el-option v-for="(place, index) in locationList" :key="`lytea${index}`" :label="place.name" :value="place.id"></el-option>
-            </el-select>
-          </el-form-item>
+            <el-form-item label="开班地点">
+              <el-select v-model="item.kbyslocationid" placeholder="请选择开班地点">
+                <el-option v-for="(place, index) in locationList" :key="`lytea${index}`" :label="place.name" :value="place.id"></el-option>
+              </el-select>
+            </el-form-item>
 
-          <el-form-item label="拓展训练地点">
-            <el-select v-model="item.kzjhlocationid" placeholder="请选择拓展训练地点">
-              <el-option v-for="(place, index) in locationList" :key="`lytea${index}`" :label="place.name" :value="place.id"></el-option>
-            </el-select>
-          </el-form-item>
+            <el-form-item label="拓展训练地点">
+              <el-select v-model="item.kzjhlocationid" placeholder="请选择拓展训练地点">
+                <el-option v-for="(place, index) in locationList" :key="`lytea${index}`" :label="place.name" :value="place.id"></el-option>
+              </el-select>
+            </el-form-item>
 
-          <el-form-item label="用餐地点">
-            <el-select v-model="item.yclocationid" placeholder="请选择用餐地点">
-              <el-option v-for="(place, index) in locationList" :key="`lytea${index}`" :label="place.name" :value="place.id"></el-option>
-            </el-select>
-          </el-form-item>
-          <el-row type="flex" justify="center" align="middle">
-            <el-col :span="5">
-              <el-button type="primary" @click="saveLessson(item.class)" size="mini">保存班级课程</el-button>
-            </el-col>
-          </el-row>
-        </el-form>
-      </el-collapse-item>
+            <el-form-item label="用餐地点">
+              <el-select v-model="item.yclocationid" placeholder="请选择用餐地点">
+                <el-option v-for="(place, index) in locationList" :key="`lytea${index}`" :label="place.name" :value="place.id"></el-option>
+              </el-select>
+            </el-form-item>
+            <el-row type="flex" justify="center" align="middle">
+              <el-col :span="5">
+                <el-button type="primary" @click="saveLessson(item.class)" size="mini">保存班级课程</el-button>
+              </el-col>
+            </el-row>
+          </el-form>
+        </el-collapse-item>
+      </template>
+      <template v-else>
+        <el-collapse-item title="该批次未分班,无法继续排课!" name="none"></el-collapse-item>
+      </template>
     </el-collapse>
     <el-drawer :with-header="false" :visible.sync="drawer" direction="rtl" @close="drawerClose">
       <el-tabs>
@@ -97,19 +102,6 @@
             </el-form-item>
           </el-form>
           <data-table style="padding:10px" :fields="teaFields" :data="applyTeacherList" :opera="teaOpera" @seletTea="setTea" :height="300"></data-table>
-          <el-row type="flex" align="middle" justify="end">
-            <el-col :span="24" style="text-align:right;">
-              <el-pagination
-                background
-                layout="total, prev, pager, next"
-                :total="applyTeacherListPag.total"
-                :page-size="5"
-                :current-page.sync="applyTeacherListPag.currentPage"
-                @current-change="cur => changePage(cur, 'apply')"
-              >
-              </el-pagination>
-            </el-col>
-          </el-row>
         </el-tab-pane>
         <el-tab-pane style="padding:10px" label="可授课教师" name="list">
           <el-form :model="teacherListPag" :inline="true">
@@ -208,10 +200,7 @@ export default {
       total: 0,
       cur: 1,
     },
-    applyTeacherListPag: {
-      total: 0,
-      cur: 1,
-    },
+    applyTeacherListPag: {},
   }),
   created() {
     this.setDateList();
@@ -222,7 +211,7 @@ export default {
     ...location({ getLocationList: 'query' }),
     ...subject({ getSubjectList: 'query' }),
     ...teacher({ getTeacherList: 'query' }),
-    ...teaPlan({ getApplyTeacherList: 'query' }),
+    ...teaPlan({ getApplyTeacherList: 'applyQuery' }),
     ...director({ getDirectorList: 'query' }),
     ...dept({ getDeptList: 'query' }),
     setDateList() {
@@ -267,10 +256,9 @@ export default {
       this.drawer = true;
     },
     toChooseTeacher() {
-      //TODO 根据科目id,查询教师和申请授课教师两个列表
       if (this.form.subid) {
         this.dialog = true;
-        this.toGetTeacherList({ query: { subid: this.form.subid } });
+        this.toGetTeacherList({ query: { subid: this.form.subid, termid: this.form.term } });
       } else this.$message.warning('请选择所授科目');
     },
     setTea({ data }) {
@@ -346,8 +334,7 @@ export default {
       let setApply = async query => {
         let res = await this.getApplyTeacherList(query);
         if (this.$checkRes(res)) {
-          this.$set(this, `applyTeacherList`, res.data);
-          this.$set(this.applyTeacherListPag, `total`, res.total);
+          this.$set(this, `applyTeacherList`, res.data ? res.data : []);
         }
       };
       if (!type) {
@@ -373,10 +360,8 @@ export default {
     },
     saveLessson(id) {
       let tcc = this.classList.find(f => f.class === id);
-      console.log(tcc);
-      // let object = { class: tcc.id, term: tcc.termid, batch: tcc.batchid, lessons: tcc.lessons };
       // // 礼仪课,开班地点,教师地点,拓展训练地点修改班级表
-      // this.$emit(`save`, tcc);
+      this.$emit(`save`, tcc);
     },
   },
   computed: {

+ 1 - 7
src/views/plan/lesson.vue

@@ -74,7 +74,6 @@ export default {
       this.$set(this, `list`, _.sortBy(res.batchnum, ['batch']));
     },
     async toDate({ data }) {
-      // TODO 根据批id查班级
       let res = await this.getClass({ batchid: data._id });
       // this.view = 'lesson';
       let { startdate, enddate } = data;
@@ -93,11 +92,6 @@ export default {
               let ldata = JSON.parse(JSON.stringify(lesson.data[0]));
               ldata = { ...ldata, name, lyteacherid, yclocationid, kzjhlocationid, kbyslocationid, headteacherid, jslocationid };
               cArr.push(ldata);
-              let object = { name, lyteacherid, yclocationid, kzjhlocationid, kbyslocationid, headteacherid, jslocationid };
-              object.class = tClass.id;
-              object.batch = tClass.batchid;
-              object.term = tClass.termid;
-              cArr.push(object);
             } else {
               //没排课,需要动手干下,整理好数据
               let object = { name, lyteacherid, yclocationid, kzjhlocationid, kbyslocationid, headteacherid, jslocationid };
@@ -125,7 +119,7 @@ export default {
       let newClass = { id: classid, headteacherid, jslocationid, yclocationid, kzjhlocationid, kbyslocationid, lyteacherid };
       let lid = _.get(data, `id`);
       let res;
-      if (lid) {
+      if (!lid) {
         res = await this.lessonCreate(newLessons);
       } else {
         newLessons.id = lid;

+ 85 - 0
src/views/plan/msg.vue

@@ -0,0 +1,85 @@
+<template>
+  <div id="msg">
+    <list-frame v-if="view === 'list'" :title="mainTitle" @query="search" :needFilter="false" :needAdd="false" :needPag="false">
+      <data-table ref="table" :fields="fields" :data="list" :opera="opera" @msg="toMsg"></data-table>
+    </list-frame>
+  </div>
+</template>
+
+<script>
+import listFrame from '@frame/layout/admin/list-frame';
+import dataTable from '@frame/components/data-table';
+import _ from 'lodash';
+import { createNamespacedHelpers } from 'vuex';
+const { mapActions: trainPlan } = createNamespacedHelpers('trainplan');
+
+//教师表,地点表,课程表
+export default {
+  metaInfo: { title: '发送通知' },
+  name: 'msg',
+  props: {},
+  components: { listFrame, dataTable },
+  data: () => ({
+    view: 'list',
+    opera: [
+      {
+        label: '发送通知',
+        icon: 'el-icon-message',
+        method: 'msg',
+      },
+    ],
+    fields: [{ label: '期数', prop: 'term' }],
+    list: [],
+    total: 0,
+  }),
+  created() {
+    this.search();
+  },
+  methods: {
+    ...trainPlan({ getTrainPlan: 'fetch' }),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      let res = await this.getTrainPlan(this.id);
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data.termnum);
+      }
+    },
+    async toMsg({ data }) {
+      let notify = this.$notify({
+        title: '发送中',
+        message: '正在发送通知,请稍后',
+        duration: 0,
+        showClose: false,
+      });
+      notify.close();
+      this.$notify({
+        title: '发送成功',
+        duration: 2000,
+        type: 'success',
+      });
+      this.$notify({
+        title: '发送失败',
+        duration: 2000,
+        type: 'error',
+      });
+    },
+  },
+  computed: {
+    mainTitle() {
+      let meta = this.$route.meta;
+      let main = meta.title || '';
+      let sub = meta.sub || '';
+      return `${main}${sub}`;
+    },
+    keyWord() {
+      let meta = this.$route.meta;
+      let main = meta.title || '';
+      return main;
+    },
+    id() {
+      return this.$route.query.id;
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 150 - 97
src/views/questionstate/index.vue

@@ -1,16 +1,26 @@
 <template>
   <div id="index">
-    <list-frame title="问卷状态页" :total="total" :filter="filFields" @add="$router.push({ path: '/questionnaire/detail' })">
-      <template #options="{item}">
-        <template v-if="item.model == 'class'">
-          <el-option v-for="(item, index) in list" :key="index" :value="item.label"></el-option>
-        </template>
-        <template v-if="item.model == 'batch'">
-          <el-option v-for="(item, index) in lists" :key="index" :value="item.label"></el-option>
-        </template>
-      </template>
-
-      <data-table :fields="fields" :data="index" :opera="opera"></data-table>
+    <list-frame title="问卷完成度查询" :total="total" :needFilter="false" :needAdd="false" :needPag="views === 'plan'">
+      <transition name="el-fade-in-linear">
+        <self-cards :title="planTitle" v-if="views === `plan`">
+          <data-table :fields="fields" :data="list" :opera="opera" @view="data => toView(data, 'term')"></data-table>
+        </self-cards>
+        <self-cards :title="termTitle" v-if="views === `term`" :returns="toReturns">
+          <data-table :fields="termFields" :data="termList" :opera="opera" @view="data => toView(data, 'batch')"></data-table>
+        </self-cards>
+        <self-cards :title="batchTitle" v-if="views === `batch`" :returns="toReturns">
+          <el-alert :title="`进度:${batch.answertotal || 0}/${batch.alltotal || 0}`" :closable="false"></el-alert>
+          <data-table :fields="batchFields" :data="batch.list" :opera="opera" @view="data => toView(data, 'class')"></data-table>
+        </self-cards>
+        <self-cards :title="classTitle" v-if="views === `class`" :returns="toReturns">
+          <el-alert :title="`进度:${classes.answertotal || 0}/${classes.alltotal || 0}`" :closable="false"></el-alert>
+          <data-table :fields="classFields" :data="classes.list" :opera="opera" @view="data => toView(data, 'student')"></data-table>
+        </self-cards>
+        <self-cards :title="studentTitle" v-if="views === `student`" :returns="toReturns">
+          <el-alert :title="`进度:${student.answertotal || 0}/${student.alltotal || 0}`" :closable="false"></el-alert>
+          <data-table :fields="studFields" :data="student.list" :opera="[]"></data-table>
+        </self-cards>
+      </transition>
     </list-frame>
   </div>
 </template>
@@ -18,113 +28,156 @@
 <script>
 import listFrame from '@frame/layout/admin/list-frame';
 import dataTable from '@frame/components/data-table';
-// import { createNamespacedHelpers } from 'vuex';
-// const { mapActions } = createNamespacedHelpers('questionnaire');
-
+import selfCards from './parts/cards';
+import { createNamespacedHelpers } from 'vuex';
+const { mapActions: trainPlan } = createNamespacedHelpers('trainplan');
+const { mapActions: classes } = createNamespacedHelpers('classes');
+const { mapActions: student } = createNamespacedHelpers('student');
+const { mapActions: completion } = createNamespacedHelpers('completion');
 export default {
   name: 'index',
+  metaInfo: { title: '问卷完成度查询' },
   props: {},
   components: {
     listFrame,
     dataTable,
+    selfCards,
   },
   data: () => ({
-    lists: [
-      { label: '第一批次', value: 0 },
-      { label: '第二批次', value: 1 },
-      { label: '第三批次', value: 2 },
-      { label: '特殊批次', value: 2 },
-    ],
-    list: [
-      { label: '一班', value: 0 },
-      { label: '二班', value: 1 },
-      { label: '三班', value: 2 },
-      { label: '四班', value: 3 },
-      { label: '五班', value: 4 },
-      { label: '六班', value: 5 },
-      { label: '七班', value: 6 },
-    ],
+    views: 'plan', // term, batch, class
+    planTitle: '全年计划',
+    termTitle: '',
+    batchTitle: '',
+    classTitle: '',
+    studentTitle: '',
+    planid: undefined,
     opera: [
-      // {
-      //   label: '编辑',
-      //   icon: 'el-icon-edit',
-      //   method: 'edit',
-      // },
-      // {
-      //   label: '删除',
-      //   icon: 'el-icon-delete',
-      //   method: 'delete',
-      // },
-    ],
-    fields: [
-      { label: '期数', prop: 'term' },
       {
-        label: '批次',
-        prop: 'batch',
-        format: item => {
-          return item === '0' ? '第一批次' : item === '1' ? '第二批次' : item === '2' ? '第三批次' : item === '3' ? '特殊批次' : '其他';
-        },
+        label: '查看',
+        icon: 'el-icon-view',
+        method: 'view',
       },
+    ],
+    fields: [
+      { label: '计划标题', prop: 'title' },
+      { label: '年度', prop: 'year' },
       {
-        label: '班级',
-        prop: 'class',
-        format: item => {
-          return item === '0'
-            ? '一班'
-            : item === '1'
-            ? '二班'
-            : item === '2'
-            ? '三班'
-            : item === '3'
-            ? '四班'
-            : item === '4'
-            ? '五班'
-            : item === '5'
-            ? '六班'
-            : item === '6'
-            ? '七班'
-            : '其他';
+        label: '状态',
+        prop: 'status',
+        format: i => {
+          return i === '0' ? '筹备中' : i === '1' ? '发布中' : '已结束';
         },
       },
-      { label: '问卷进度', prop: 'id' },
     ],
-    filFields: [
-      { label: '期数', model: 'term' },
-
-      {
-        label: '批次',
-        model: 'batch',
-        type: 'select',
-      },
-      {
-        label: '班级',
-        model: 'class',
-        type: 'select',
-      },
+    list: [],
+    termFields: [{ label: '期数', prop: 'term' }],
+    termList: [],
+    batchFields: [
+      { label: '批次', prop: 'name' },
+      { label: '进度', prop: 'completion' },
+    ],
+    batch: {
+      list: [],
+    },
+    classFields: [
+      { label: '班级', prop: 'name' },
+      { label: '进度', prop: 'completion' },
     ],
-    index: [],
+    classes: {
+      list: [],
+    },
     total: 0,
+    studFields: [
+      { label: '姓名', prop: 'name' },
+      { label: '进度', prop: 'completion' },
+    ],
+    student: {
+      list: [],
+    },
+    studFilter: [
+      { label: '姓名', model: 'name' },
+      { label: '进度', prop: 'completion' },
+    ],
+    classid: '',
+    studTotal: 0,
   }),
 
-  created() {},
+  created() {
+    this.search();
+  },
   computed: {},
   methods: {
-    // ...mapActions(['query', 'delete']),
-    // async search({ skip = 0, limit = 10, ...info } = {}) {
-    //   const res = await this.query({ skip, limit, ...info });
-    //   if (this.$checkRes(res)) {
-    //     this.$set(this, `list`, res.data);
-    //     this.$set(this, `total`, res.total);
-    //   }
-    // },
-    // toEdit({ data }) {
-    //   this.$router.push({ path: '/questionnaire/detail', query: { id: data.id } });
-    // },
-    // async toDelete({ data }) {
-    //   const res = await this.delete(data.id);
-    //   this.$checkRes(res, '删除成功', '删除失败');
-    //   this.search();
-    //},
+    ...trainPlan(['query', 'delete', 'update']),
+    ...completion({ getCompletion: 'query' }),
+    ...classes({ getClassesList: 'query' }),
+    ...student({ getStudentList: 'query' }),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      const res = await this.query({ skip, limit, status: '1', ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      }
+    },
+    async toView({ data }, type) {
+      this.views = type;
+      if (type === 'term') {
+        let planid = data._id;
+        this.planid = planid;
+        this.$set(this, `termTitle`, data.title);
+        this.$set(this, `termList`, data.termnum);
+      }
+      if (type === 'batch') {
+        let termid = data._id;
+        let res = await this.getCompletion({ type: '0', typeid: termid, trainplanid: this.planid });
+        if (this.$checkRes(res)) {
+          let { data: completion, answertotal, alltotal, completiontotal } = res;
+          completion = completion.map(i => {
+            i.completion.includes('NaN') ? (i.completion = '-') : '';
+            return i;
+          });
+          this.$set(this, `batch`, { list: completion, answertotal, alltotal, completiontotal });
+        }
+        this.$set(this, `batchTitle`, `第${data.term}期`);
+      }
+      if (type === 'class') {
+        let batch = data.id;
+        let res = await this.getCompletion({ type: '1', typeid: batch });
+        if (this.$checkRes(res)) {
+          let { data: completion, answertotal, alltotal, completiontotal } = res;
+          completion = completion.map(i => {
+            i.completion.includes('NaN') ? (i.completion = '-') : '';
+            return i;
+          });
+          this.$set(this, `classes`, { list: completion, answertotal, alltotal, completiontotal });
+        }
+        this.$set(this, `classTitle`, `${data.name}`);
+      }
+      if (type === 'student') {
+        let res = await this.getCompletion({ type: '2', typeid: data.id });
+        if (this.$checkRes(res)) {
+          let { data: completion, answertotal, alltotal, completiontotal } = res;
+          completion = completion.map(i => {
+            i.completion.includes('NaN') ? (i.completion = '-') : '';
+            return i;
+          });
+          this.$set(this, `student`, { list: completion, answertotal, alltotal, completiontotal });
+        }
+        this.$set(this, `studentTitle`, `${data.name}`);
+      }
+    },
+    toReturns() {
+      if (this.views === 'term') this.views = 'plan';
+      else if (this.views === 'batch') this.views = 'term';
+      else if (this.views === 'class') this.views = 'batch';
+      else if (this.views === 'student') this.views = 'class';
+    },
+  },
+  watch: {
+    views: {
+      handler(val) {
+        if (val === 'plan') this.planid = undefined;
+      },
+    },
   },
 };
 </script>

+ 42 - 0
src/views/questionstate/parts/cards.vue

@@ -0,0 +1,42 @@
+<template>
+  <div id="cards">
+    <el-card>
+      <template #header>
+        <el-row type="flex">
+          <el-col :span="22">{{ title }}</el-col>
+          <el-col :span="2" style="float:right;text-align:right" v-if="returns">
+            <el-button type="text" @click="toReturns">{{ text }}</el-button>
+          </el-col>
+        </el-row>
+      </template>
+      <slot></slot>
+    </el-card>
+  </div>
+</template>
+
+<script>
+import _ from 'lodash';
+export default {
+  name: 'cards',
+  props: {
+    title: { type: String, required: true },
+    returns: null,
+    text: { type: String, default: `返回上一级` },
+  },
+  components: {},
+  data: () => ({}),
+  created() {},
+  computed: {},
+  methods: {
+    toReturns() {
+      if (_.isString(this.returns)) this.$router.push({ path: this.returns });
+      else if (_.isFunction(this.returns)) {
+        let fun = _.get(this, `returns`);
+        fun();
+      }
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 25 - 26
src/views/teacher/detail.vue

@@ -9,7 +9,7 @@
           <template v-if="item.model === 'subid'">
             <el-option v-for="(i, index) in subjectList" :key="index" :label="i.name" :value="i._id"></el-option>
           </template>
-          <template v-if="item.model === 'school_code'">
+          <template v-if="item.model === 'schid'">
             <el-option v-for="(i, index) in schoolList" :key="index" :label="i.name" :value="i.code"></el-option>
           </template>
           <template v-if="item.model === 'tltype'">
@@ -23,7 +23,7 @@
             <el-radio label="男">男</el-radio>
             <el-radio label="女">女</el-radio>
           </template>
-          <template v-if="item.model === 'is_etiquette_teacher'">
+          <template v-if="item.model === 'islyteacher'">
             <el-radio label="1">是</el-radio>
             <el-radio label="0">否</el-radio>
           </template>
@@ -51,42 +51,42 @@ export default {
     dataForm,
   },
   data: () => ({
-    // info: { status: '1', is_etiquette_teacher: '0' },
+    // info: { status: '1', islyteacher: '0' },
     info: {
       status: '1',
-      is_etiquette_teacher: '0',
+      islyteacher: '0',
       name: '测试教师',
       gender: '男',
       phone: '18946597931',
-      id_number: '222222222222222222',
-      profession_number: '1111111111111212',
-      school_code: '10183',
+      idnumber: '222222222222222222',
+      zynumber: '1111111111111212',
+      schid: '10183',
       email: '2938260457@qq.com',
       age: '29',
       birthday: '1991-02-04',
-      entry_time: '2015-02-04',
+      entrydate: '2015-02-04',
       job: '教师',
       major: '化学',
       subid: '5e4369a4275c2f5514ec2593',
-      school_name: '吉林大学',
+      schname: '吉林大学',
     },
     fields: [
       { label: '教师姓名', required: true, model: 'name' },
       // { label: '状态', required: true, model: 'status', custom: true },
       { label: '性别', model: 'gender', type: `radio` },
       { label: '手机号', required: true, model: 'phone', options: { maxLength: 11, minLength: 11 } },
-      { label: '身份证号', required: true, model: 'id_number', options: { maxLength: 18, minLength: 18 } },
-      { label: '教师资格证号', required: true, model: 'profession_number' },
-      // { label: '教师资格证', required: true, model: 'profession_number_file' },
-      { label: '学校', required: true, model: 'school_code', type: 'select' },
+      { label: '身份证号', required: true, model: 'idnumber', options: { maxLength: 18, minLength: 18 } },
+      { label: '教师资格证号', required: true, model: 'zynumber' },
+      // { label: '教师资格证', required: true, model: 'zynumberfile' },
+      { label: '学校', required: true, model: 'schid', type: 'select' },
       { label: '邮箱', required: true, model: 'email' },
       { label: '年龄', required: true, model: 'age' },
       { label: '出生日期', required: true, model: 'birthday', type: 'date' },
-      { label: '入职时间', required: true, model: 'entry_time', type: 'date' },
+      { label: '入职时间', required: true, model: 'entrydate', type: 'date' },
       { label: '职务', required: true, model: 'job' },
       { label: '专业', required: true, model: 'major' },
       { label: '科目', required: true, model: 'subid', type: 'select' },
-      { label: '是/否是礼仪老师', model: 'is_etiquette_teacher', type: `radio` },
+      { label: '是/否是礼仪老师', model: 'islyteacher', type: `radio` },
 
       // { label: '资料评分', required: true, model: 'zlgrade' },
       // { label: '面试评分', required: true, model: 'msgrade' },
@@ -103,16 +103,16 @@ export default {
         { required: true, message: '请输入手机号' },
         { min: 11, max: 11, message: '请输入11位手机号 ', trigger: 'blur' },
       ],
-      id_number: [
+      idnumber: [
         { required: true, message: '请输入身份证号' },
         { min: 18, max: 18, message: '请输入18位身份证号 ', trigger: 'blur' },
       ],
-      profession_number: [{ required: true, message: '请输入教师资格证号' }],
-      school_code: [{ required: true, message: '请选择学校' }],
+      zynumber: [{ required: true, message: '请输入教师资格证号' }],
+      schid: [{ required: true, message: '请选择学校' }],
       email: [{ required: true, message: '请输入邮箱' }],
       age: [{ required: true, message: '请输入年龄' }],
       birthday: [{ required: true, message: '请选择出生日期' }],
-      entry_time: [{ required: true, message: '请选择入职时间' }],
+      entrydate: [{ required: true, message: '请选择入职时间' }],
       job: [{ required: true, message: '请输入职务' }],
       major: [{ required: true, message: '请输入专业' }],
       subid: [{ required: true, message: '请选择科目' }],
@@ -123,8 +123,8 @@ export default {
       // zlname: [{ required: true, message: '请输入资料名称' }],
       // openid: [{ required: true, message: '请输入openid' }],
       // password: [{ required: true, message: '请输入职业资格证文件' }],
-      // school_name: [{ required: true, message: '请输入学校名称' }],
-      // profession_number_file: [
+      // schname: [{ required: true, message: '请输入学校名称' }],
+      // zynumberfile: [
       //   { required: true, message: '请输入教师资格证号' },
       //   { min: 17, max: 17, message: '请输入17位教师资格证号', trigger: 'blur' },
       // ],
@@ -179,17 +179,16 @@ export default {
     async handleSave({ isNew, data }) {
       let res;
       let msg;
-      data.school_name = this.schoolList.find(f => f.code === data.school_code).name;
+      data.schname = this.schoolList.find(f => f.code === data.schid).name;
       if (isNew) {
-        res = this.create(data);
+        res = await this.create(data);
         data.password = '123456';
         msg = `${this.keyWord}添加成功`;
       } else {
-        // console.log(data);
-        res = this.update(data);
-        console.log(res);
+        res = await this.update(data);
         msg = `${this.keyWord}修改成功`;
       }
+      this.$checkRes(res, msg);
       // if (this.$checkRes(res, msg)) this.$router.push({ path: '/teacher/index' });
     },