elective-generation-commands.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <div class="fx-row fx-bet-cen">
  3. <div class="fx-1">
  4. <el-button v-if="showDMAlgorithm" type="primary" @click="applyAlgorithm">智能匹配</el-button>
  5. <el-button v-if="showDMAlgorithmResults" type="primary" @click="goDetailPage">查看匹配明细</el-button>
  6. <el-button v-if="showForceAdjust" type="primary" @click="goDetailPage">查看/调剂</el-button>
  7. </div>
  8. <div>
  9. <el-button v-if="showFastPush" type="primary" @click="flushIntoDM">提前进入{{ nextStepName }}</el-button>
  10. <el-button v-if="showForceAdjustSend" type="primary" @click="jumpForceAdjust">
  11. 进入{{ generation.options.forceAdjust.title }}
  12. </el-button>
  13. <el-button v-else-if="showSend" type="primary" @click="pushGeneration">发送</el-button>
  14. <el-button v-if="showRankBalance" type="primary" @click="jumpRankBalance">排名均衡</el-button>
  15. <el-button v-if="showClassDispatch" type="primary" @click="terminateAndJumpDispatch">选科分班</el-button>
  16. <!--<el-button v-else type="primary" @click="jumpDispatch">选科分班</el-button>-->
  17. <!--<el-button type="primary" @click="jumpReport" class="ml10">选科数据</el-button>-->
  18. </div>
  19. <el-dialog v-if="pushSettingFormVisible" :visible.sync="pushSettingFormVisible"
  20. :title="nextStepName+'设置'" width="350">
  21. <elective-generation-push-setting ref="settingForm"/>
  22. <div class="fx-row fx-end-cen mt15">
  23. <el-button @click="pushSettingFormVisible=false">取消</el-button>
  24. <el-button type="primary" @click="commitPushSetting">确认</el-button>
  25. </div>
  26. </el-dialog>
  27. </div>
  28. </template>
  29. <script>
  30. import {
  31. applyElectiveDMAlgorithm,
  32. flushIntoGenerationDM, jumpGenerationForceAdjust,
  33. jumpGenerationRankBalance, pushGenerationSetting,
  34. terminateGeneration
  35. } from '@/api/webApi/elective/generation'
  36. import config from '@/common/mx-config'
  37. import ElectiveGenerationPushSetting from '@/views/elective/generation/components/elective-generation-push-setting'
  38. import transferMixin from '@/components/mx-transfer-mixin'
  39. export default {
  40. mixins: [transferMixin],
  41. name: 'elective-generation-commands',
  42. components: { ElectiveGenerationPushSetting },
  43. inject: ['refreshData'],
  44. props: ['chartBinding', 'disabled'],
  45. computed: {
  46. generation() {
  47. return this.chartBinding.generation || {}
  48. },
  49. status() {
  50. return this.generation?.status || {}
  51. },
  52. // buttons control
  53. showDMAlgorithm() {
  54. return this.status.allowDMAlgorithm
  55. },
  56. showDMAlgorithmResults() {
  57. return this.status.doneDMAlgorithm && !this.status.allowForce
  58. },
  59. showForceAdjust() {
  60. return this.status.doneDMAlgorithm && this.status.allowForce
  61. },
  62. showFastPush() {
  63. return this.status.enablePushNextDMGeneration
  64. },
  65. nextStepName() {
  66. const options = this.generation.options
  67. const next = this.generation.current + 1
  68. return Object.values(options).find(opt => opt.value == next).title
  69. },
  70. showForceAdjustSend() {
  71. return this.status.enablePushForceAdjust
  72. },
  73. showSend() {
  74. return this.status.doneDMAlgorithm && !this.status.allEnrolled
  75. },
  76. showRankBalance() {
  77. return false // TODO: not implement.
  78. const options = this.generation.options
  79. return this.status.allEnrolled && this.generation.current < options.rankBalance.value
  80. },
  81. showClassDispatch() {
  82. const options = this.generation.options
  83. // return this.status.allEnrolled && this.generation.current <= options.rankBalance.value
  84. return this.status.allEnrolled && this.generation.current >= options.forceAdjust.value
  85. }
  86. },
  87. data() {
  88. return {
  89. pushSettingFormVisible: false
  90. }
  91. },
  92. methods: {
  93. notifyRootRefresh(syncStep = false) {
  94. this.refreshData(syncStep)
  95. },
  96. applyAlgorithm() {
  97. // 暂时只支持一种算法,不排队以后会支持多种
  98. const algorithm = config.electiveDMAlgorithm.rankFirst.value
  99. applyElectiveDMAlgorithm(algorithm).finally(() => {
  100. this.notifyRootRefresh()
  101. })
  102. },
  103. goDetailPage() {
  104. // 默认跳第1个可查询项 // 外抛让table子组件处理
  105. this.$emit('jumpDetail')
  106. },
  107. flushIntoDM() {
  108. flushIntoGenerationDM().finally(() => {
  109. this.notifyRootRefresh(true)
  110. })
  111. },
  112. pushGeneration() {
  113. // show dialog form for push settings
  114. // then call push api
  115. this.pushSettingFormVisible = true
  116. },
  117. async commitPushSetting() {
  118. const setting = await this.$refs.settingForm.validate()
  119. setting.roundId = this.status.roundId
  120. pushGenerationSetting(setting).finally(() => {
  121. this.notifyRootRefresh(true)
  122. })
  123. },
  124. jumpForceAdjust() {
  125. jumpGenerationForceAdjust().finally(() => {
  126. this.notifyRootRefresh(true)
  127. })
  128. },
  129. async jumpRankBalance() {
  130. jumpGenerationRankBalance().finally(() => {
  131. this.notifyRootRefresh(true)
  132. })
  133. },
  134. async terminateAndJumpDispatch() {
  135. await this.$confirm('确认进入选科分班?该操作将锁定所有选科录取状态,且不可逆')
  136. terminateGeneration().then(res => {
  137. this.jumpDispatch()
  138. }).finally(() => this.notifyRootRefresh())
  139. },
  140. jumpDispatch() {
  141. const path = '/new-gaokao/selectCourse/elective/dispatch/index'
  142. this.transferTo(path)
  143. },
  144. jumpReport() {
  145. // 跳转选科数据
  146. // TODO: 页面还没有定义好
  147. this.msgInfo('更多选科数据,敬请期待')
  148. }
  149. }
  150. }
  151. </script>
  152. <style scoped>
  153. </style>