Explorar el Código

elective master - step sync optimized

hare8999@163.com hace 2 años
padre
commit
f3ec8891ca

+ 6 - 2
src/views/elective/generation/components/elective-generation-steps.vue

@@ -120,8 +120,12 @@ export default {
       }
     },
     syncStepWithCurrent() {
-      if (this.generation.active >= this.generation.current) return
-      const currentStep = this.steps.find(s => s.value == this.generation.current)
+      let currentStep = this.steps.find(s => s.value == this.generation.current)
+      if (!currentStep) {
+        currentStep = this.generation.active >= this.generation.current
+          ? this.steps.first()
+          : this.steps.last()
+      }
       this.handleStepChange(currentStep)
     }
   }

+ 10 - 5
src/views/elective/generation/index.vue

@@ -2,7 +2,7 @@
   <div class="app-container" v-loading="loading">
     <el-card>
       <mx-condition :query-params="queryParams" :require-fields="requireFields"
-                    @query="handleQuery" @invalid="handleInvalid"></mx-condition>
+                    @query="handleQuery(true)" @invalid="handleInvalid"></mx-condition>
     </el-card>
     <el-card v-if="electiveStatus" class="mt20">
       <template #header>
@@ -110,7 +110,7 @@ export default {
       this.electiveStatus = null
       this.electiveSummary = []
     },
-    async handleQuery() {
+    async handleQuery(syncStep) {
       this.loading = true
       try {
         // TODO: remove when test completed
@@ -122,13 +122,18 @@ export default {
         const resSummary = await getElectiveSummary(this.queryParams)
         this.electiveStatus = resStatus.data
         this.electiveSummary = resSummary.data
+        // reset step
+        if (syncStep) {
+          await this.$nextTick()
+          this.$refs.step.syncStepWithCurrent()
+        }
+
       } finally {
         this.loading = false
       }
     },
-    async refreshData(syncStep) {
-      await this.handleQuery()
-      if (syncStep) this.$refs.step.syncStepWithCurrent()
+    refreshData(syncStep) {
+      this.handleQuery(syncStep)
     }
   }
 }