Browse Source

student elective table - 容错性

hare8999@163.com 2 years ago
parent
commit
003b19e524
1 changed files with 28 additions and 30 deletions
  1. 28 30
      src/views/system/user/profile/round-select.vue

+ 28 - 30
src/views/system/user/profile/round-select.vue

@@ -27,10 +27,9 @@
         <elective-generation-steps v-if="selectObj" v-model="activeStep" :generation="generation"
                                    disable-hidden-feature></elective-generation-steps>
       </template>
-      <report-table v-if="generation.active <= generation.current" :generation="generation"
-                    :optional-majors="optionalMajors">
+      <report-table v-if="activeModel&&activeModel.models" :generation="generation" :optional-majors="optionalMajors">
         <template #header-prefix>
-          <el-button circle icon="el-icon-refresh" @click="refresh" class="mr30"></el-button>
+          <el-button circle icon="el-icon-refresh" @click="refreshData" class="mr30"></el-button>
         </template>
       </report-table>
       <evaluation-empty v-else :shadow="false" :title="emptyTitle"></evaluation-empty>
@@ -97,6 +96,9 @@ export default {
   computed: {
     emptyTitle() {
       if (!this.activeOpt) return
+      if (this.activeModel && !this.activeModel.models && this.activeOpt.decisionMaking) {
+        return this.activeOpt.title + '正在进行...'
+      }
       return this.activeOpt.title + '还未开启'
     },
     currentOpt() {
@@ -112,14 +114,15 @@ export default {
       /// 当前选中的进程代,可能没有值
       return this.generationModels.filter(gm => gm.generation <= this.activeOpt.value)
     },
+    activeModel() {
+      if (!this.activeStep || !this.selectObj) return null
+      return this.generationModels.find(gm => gm.generation == this.activeOpt.value)
+    },
     roundGroups() {
       if (!this.selectObj?.groupIds) return []
       if (!this.generationModels.length) return []
-      const currentModels = this.generationModels.last().models
-      return this.selectObj.groupList?.map(g => {
-        const matched = currentModels.find(m => m.groupId == g.groupId) || {}
+      return this.selectObj['groupList']?.map(g => {
         return ({
-          ...matched,
           ...g,
           groupName: g.name
         })
@@ -141,20 +144,26 @@ export default {
           roundName: this.selectObj.name || ''
         },
         models: this.generationModels,
-        activeModels: this.activeModels
+        activeModels: this.activeModels,
+        activeModel: this.activeModel
       }
     }
   },
   mounted() {
-    this.loadStudentSelected()
-    this.getStudentElectiveModels()
-    this.getOptionalMajors()
-    this.getRecommendMajor()
+    try {
+      this.loading = true
+      this.loadStudentSelected()
+      this.getStudentElectiveModels()
+      this.getOptionalMajors()
+      this.getRecommendMajor()
+    } finally {
+      this.loading = false
+    }
   },
   methods: {
     refreshData() {
-      this.loading = true
       try {
+        this.loading = true
         this.loadStudentSelected()
         this.getStudentElectiveModels()
       } finally {
@@ -162,27 +171,16 @@ export default {
       }
     },
     getStudentElectiveModels() {
-      this.loading = true
       getStudentElectiveModels().then(res => {
-        this.generationModels = res.data.map(item => {
-          item.selectedList = item.models.filter(model => {
-            return model.selected
-          }).sort((prev, cur) => {
-            return prev.selectedRank - cur.selectedRank
-          })
-          return item
+        // create local selected list
+        res.data.forEach(gen => {
+          const localSelected = gen.models?.filter(m => m.selected)
+          localSelected?.sort((l, r) => l.selectedRank - r.selectedRank)
+          gen.selectedList = localSelected || []
         })
-      }).finally(_ => {
-        this.loading = false
+        this.generationModels = res.data
       })
     },
-    refresh() {
-      // 刷新
-      this.loadStudentSelected()
-      this.getStudentElectiveModels()
-      this.getOptionalMajors()
-      this.getRecommendMajor()
-    },
     getRecommendMajor() {
       getRecommendMajor().then(res => {
         this.evaluationMajors = res.data