guhongwei 5 年之前
父節點
當前提交
89341d3e24
共有 1 個文件被更改,包括 10 次插入3 次删除
  1. 10 3
      src/views/student/detail.vue

+ 10 - 3
src/views/student/detail.vue

@@ -19,7 +19,7 @@
           </template>
           <!-- 班级 -->
           <template v-if="item.model === 'classid'">
-            <el-option v-for="(item, index) in classList" :key="index" :label="item.name" :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: '学生信息' },
@@ -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);
@@ -207,16 +209,21 @@ export default {
       } else if (model == 'batchid') {
         let res = this.batchList.filter(fil => fil._id === data);
         if (res.length > 0) {
-          this.$set(this, `classList`, res[0].class);
           this.$set(this.info, `batchname`, res[0].batch);
+          this.searchClass(data);
         }
-      } else {
+      } 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);
         }
       }
     },
+    // 查询班级
+    async searchClass(id) {
+      const res = await this.classesQuery({ batchid: id });
+      if (this.$checkRes(res)) this.$set(this, `classList`, res.data);
+    },
     // 存id与名字
     selectChild(id) {
       console.log(id);