Browse Source

Merge branch 'master' of http://git.cc-lotus.info/new_train/train-center

lrf402788946 5 years ago
parent
commit
5cc2385212
1 changed files with 33 additions and 16 deletions
  1. 33 16
      src/views/student/detail.vue

+ 33 - 16
src/views/student/detail.vue

@@ -1,7 +1,7 @@
 <template>
   <div id="detail">
     <detail-frame :title="mainTitle" returns="/student/index">
-      <data-form :data="info" :fields="fields" :rules="rules" @save="handleSave" :isNew="isNew">
+      <data-form :data="info" :fields="fields" :rules="rules" @save="handleSave" :isNew="isNew" @filterReturn="termChange">
         <template #options="{item}">
           <template v-if="item.model === 'school_name'">
             <el-option v-for="(item, index) in schcoolList" :key="index" :label="item.name" :value="item.name"></el-option>
@@ -15,11 +15,11 @@
           </template>
           <!-- 批次 -->
           <template v-if="item.model === 'batchid'">
-            <el-option v-for="(item, index) in batchList" :key="index" :label="item.term" :value="item._id"></el-option>
+            <el-option v-for="(item, index) in batchList" :key="index" :label="item.batch" :value="item._id"></el-option>
           </template>
           <!-- 班级 -->
           <template v-if="item.model === 'classid'">
-            <el-option v-for="(item, index) in classList" :key="index" :label="item.term" :value="item._id"></el-option>
+            <el-option v-for="(item, index) in classList" :key="index" :label="item.name" :value="item.id"></el-option>
           </template>
         </template>
         <template #radios="{item}">
@@ -49,6 +49,7 @@ const { mapActions } = createNamespacedHelpers('student');
 const { mapActions: mapNation } = createNamespacedHelpers('nation');
 const { mapActions: mapschool } = createNamespacedHelpers('school');
 const { mapActions: trainplan } = createNamespacedHelpers('trainplan');
+const { mapActions: classes } = createNamespacedHelpers('classes');
 //缺少字典表:学校表,民族表,院系表,专业表
 export default {
   metaInfo: { title: '学生信息' },
@@ -83,9 +84,9 @@ export default {
       { label: '家庭是否困难', required: true, model: 'family_is_hard', type: 'radio' },
       { label: '是否获得过助学金', required: true, model: 'have_grant', type: 'radio' },
       { label: '职务', model: 'job' },
-      { label: '期', model: 'termid', type: 'select' },
-      { label: '批次', model: 'batch' },
-      { label: '班级', model: 'class' },
+      { label: '期', model: 'termid', type: 'select', filterReturn: true },
+      { label: '批次', model: 'batchid', type: 'select', filterReturn: true },
+      { label: '班级', model: 'classid', type: 'select', filterReturn: true },
       { label: '是否优秀', model: 'is_fine', type: 'radio' },
     ],
     rules: {
@@ -155,6 +156,7 @@ export default {
     ...mapNation({ nation: 'query' }),
     ...mapschool({ zschool: 'query' }),
     ...trainplan({ trainplanQuery: 'query' }),
+    ...classes({ classesQuery: 'query' }),
     async otherList() {
       const res = await this.nation();
       if (this.$checkRes(res)) this.$set(this, `nationList`, res.data);
@@ -169,7 +171,6 @@ export default {
       let planyearid = _.get(this.defaultOption, 'planyearid');
       const res = await this.trainplanQuery({ planyearid: planyearid });
       var arr = res.data.filter(item => item.id === planid);
-      console.log(arr[0].termnum);
       if (this.$checkRes(arr)) this.$set(this, `termList`, arr[0].termnum);
     },
     async search() {
@@ -190,22 +191,38 @@ export default {
         // data.school_name = `测试学校`;
         data.planid = planid;
         data.planyearid = planyearid;
-        console.log(data);
-        // res = await this.create(data);
-        // msg = `${this.keyWord}添加成功`;
+        res = await this.create(data);
+        msg = `${this.keyWord}添加成功`;
       } else {
         res = await this.update(data);
         msg = `${this.keyWord}修改成功`;
       }
       if (this.$checkRes(res, msg)) this.$router.push({ path: '/student/index' });
     },
-    // 存id与名字
-    selectChild(id) {
-      let res = this.termList.filter(fil => fil._id === id);
-      if (res.length > 0) {
-        this.$set(this.info, `term`, res[0].name);
+    termChange({ data, model }) {
+      if (model == 'termid') {
+        let res = this.termList.filter(fil => fil._id === data);
+        if (res.length > 0) {
+          this.$set(this, `batchList`, res[0].batchnum);
+          this.$set(this.info, `termname`, res[0].term);
+        }
+      } else if (model == 'batchid') {
+        let res = this.batchList.filter(fil => fil._id === data);
+        if (res.length > 0) {
+          this.$set(this.info, `batchname`, res[0].batch);
+          this.searchClass(data);
+        }
+      } else if (model == 'classid') {
+        let res = this.classList.filter(fil => fil._id === data);
+        if (res.length > 0) {
+          this.$set(this.info, `classname`, res[0].name);
+        }
       }
-      this.$forceUpdate();
+    },
+    // 查询班级
+    async searchClass(id) {
+      const res = await this.classesQuery({ batchid: id });
+      if (this.$checkRes(res)) this.$set(this, `classList`, res.data);
     },
   },
 };