Procházet zdrojové kódy

elective - auto step move

hare8999@163.com před 3 roky
rodič
revize
9fe6704011

+ 9 - 7
src/views/elective/generation/components/elective-generation-commands.vue

@@ -7,7 +7,9 @@
     </div>
     <div>
       <el-button v-if="showFastPush" type="primary" @click="flushIntoDM">提前进入{{ nextStepName }}</el-button>
-      <el-button v-if="showForceAdjustSend" type="primary" @click="jumpForceAdjust">进入{{ generation.options.forceAdjust.title }}</el-button>
+      <el-button v-if="showForceAdjustSend" type="primary" @click="jumpForceAdjust">
+        进入{{ generation.options.forceAdjust.title }}
+      </el-button>
       <el-button v-else-if="showSend" type="primary" @click="pushGeneration">发送</el-button>
       <el-button v-if="showRankBalance" type="primary" @click="jumpRankBalance">排名均衡</el-button>
       <el-button v-if="showClassDispatch" type="primary" @click="terminateAndJumpDispatch">选科分班</el-button>
@@ -89,8 +91,8 @@ export default {
     }
   },
   methods: {
-    notifyRootRefresh() {
-      this.refreshData()
+    notifyRootRefresh(syncStep = false) {
+      this.refreshData(syncStep)
     },
     applyAlgorithm() {
       // 暂时只支持一种算法,不排队以后会支持多种
@@ -105,7 +107,7 @@ export default {
     },
     flushIntoDM() {
       flushIntoGenerationDM().finally(() => {
-        this.notifyRootRefresh()
+        this.notifyRootRefresh(true)
       })
     },
     pushGeneration() {
@@ -117,17 +119,17 @@ export default {
       const setting = await this.$refs.settingForm.validate()
       setting.roundId = this.status.roundId
       pushGenerationSetting(setting).finally(() => {
-        this.notifyRootRefresh()
+        this.notifyRootRefresh(true)
       })
     },
     jumpForceAdjust() {
       jumpGenerationForceAdjust().finally(() => {
-        this.notifyRootRefresh()
+        this.notifyRootRefresh(true)
       })
     },
     async jumpRankBalance() {
       jumpGenerationRankBalance().finally(() => {
-        this.notifyRootRefresh()
+        this.notifyRootRefresh(true)
       })
     },
     async terminateAndJumpDispatch() {

+ 5 - 1
src/views/elective/generation/components/elective-generation-steps.vue

@@ -95,7 +95,6 @@ export default {
       }
 
       if (!this.modelValue) {
-        console.log(this.steps.findIndex(item => item.value == defaultOpt.value) + 1)
         this.activeStep = this.steps.findIndex(item => item.value == defaultOpt.value) + 1
         this.$emit('change', defaultOpt.key)
       }
@@ -119,6 +118,11 @@ export default {
       } else {
         this.generation.hiddenGenerations.remove(step.value)
       }
+    },
+    syncStepWithCurrent() {
+      if (this.generation.active >= this.generation.current) return
+      const currentStep = this.steps.find(s => s.value == this.generation.current)
+      this.handleStepChange(currentStep)
     }
   }
 }

+ 6 - 2
src/views/elective/generation/index.vue

@@ -6,7 +6,7 @@
     </el-card>
     <el-card v-if="electiveStatus" class="mt20">
       <template #header>
-        <elective-generation-steps v-model="activeStep" :generation="generation"></elective-generation-steps>
+        <elective-generation-steps ref="step" v-model="activeStep" :generation="generation"></elective-generation-steps>
       </template>
       <elective-generation-master :generation="generation">
         <template #header-prefix>
@@ -91,7 +91,7 @@ export default {
   },
   provide() {
     return {
-      refreshData: this.handleQuery
+      refreshData: this.refreshData
     }
   },
   methods: {
@@ -115,6 +115,10 @@ export default {
       } finally {
         this.loading = false
       }
+    },
+    async refreshData(syncStep) {
+      await this.handleQuery()
+      if (syncStep) this.$refs.step.syncStepWithCurrent()
     }
   }
 }