elective-generation-commands.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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="showSend" type="primary" @click="pushGeneration">发送</el-button>
  11. <el-button v-if="showRankBalance" type="primary" @click="jumpRankBalance">排名均衡</el-button>
  12. <el-button v-if="showClassDispatch" type="primary" @click="terminateAndJumpDispatch">选科分班</el-button>
  13. <el-button v-else type="primary" @click="jumpDispatch">选科分班</el-button>
  14. </div>
  15. <el-dialog v-if="pushSettingFormVisible" :visible.sync="pushSettingFormVisible"
  16. :title="nextStepName+'设置'" width="350">
  17. <elective-generation-push-setting ref="settingForm"/>
  18. <div class="fx-row fx-end-cen mt15">
  19. <el-button @click="pushSettingFormVisible=false">取消</el-button>
  20. <el-button type="primary" @click="commitPushSetting">确认</el-button>
  21. </div>
  22. </el-dialog>
  23. </div>
  24. </template>
  25. <script>
  26. import {
  27. applyElectiveDMAlgorithm,
  28. flushIntoGenerationDM,
  29. jumpGenerationRankBalance, pushGenerationSetting,
  30. terminateGeneration
  31. } from '@/api/webApi/elective/generation'
  32. import config from '@/common/mx-config'
  33. import ElectiveGenerationPushSetting from '@/views/elective/generation/components/elective-generation-push-setting'
  34. import transferMixin from '@/components/mx-transfer-mixin'
  35. export default {
  36. mixins: [transferMixin],
  37. name: 'elective-generation-commands',
  38. components: { ElectiveGenerationPushSetting },
  39. inject: ['refreshData'],
  40. props: ['chartBinding', 'disabled'],
  41. computed: {
  42. generation() {
  43. return this.chartBinding.generation || {}
  44. },
  45. status() {
  46. return this.generation?.status || {}
  47. },
  48. // buttons control
  49. showDMAlgorithm() {
  50. return this.status.allowDMAlgorithm
  51. },
  52. showDMAlgorithmResults() {
  53. return this.status.doneDMAlgorithm && !this.status.allowForce
  54. },
  55. showForceAdjust() {
  56. return this.status.doneDMAlgorithm && this.status.allowForce
  57. },
  58. showFastPush() {
  59. return this.status.enablePushNextDMGeneration
  60. },
  61. nextStepName() {
  62. const options = this.generation.options
  63. const next = this.generation.current + 1
  64. return Object.values(options).find(opt => opt.value == next).title
  65. },
  66. showSend() {
  67. return this.status.doneDMAlgorithm && !this.status.allMatched
  68. },
  69. showRankBalance() {
  70. const options = this.generation.options
  71. return this.status.allMatched && this.generation.current < options.rankBalance.value
  72. },
  73. showClassDispatch() {
  74. const options = this.generation.options
  75. return this.status.allMatched && this.generation.current <= options.rankBalance.value
  76. }
  77. },
  78. data() {
  79. return {
  80. pushSettingFormVisible: false
  81. }
  82. },
  83. methods: {
  84. notifyRootRefresh() {
  85. this.refreshData()
  86. },
  87. applyAlgorithm() {
  88. // 暂时只支持一种算法,不排队以后会支持多种
  89. const algorithm = config.electiveDMAlgorithm.rankFirst.value
  90. applyElectiveDMAlgorithm(algorithm).finally(() => {
  91. this.notifyRootRefresh()
  92. })
  93. },
  94. goDetailPage() {
  95. // 默认跳第1个可查询项 // 外抛让table子组件处理
  96. this.$emit('jumpDetail')
  97. },
  98. flushIntoDM() {
  99. flushIntoGenerationDM().finally(() => {
  100. this.notifyRootRefresh()
  101. })
  102. },
  103. pushGeneration() {
  104. // show dialog form for push settings
  105. // then call push api
  106. this.pushSettingFormVisible = true
  107. },
  108. async commitPushSetting() {
  109. const setting = await this.$refs.settingForm.validate()
  110. setting.roundId = this.status.roundId
  111. pushGenerationSetting(setting).finally(() => {
  112. this.notifyRootRefresh()
  113. })
  114. },
  115. jumpRankBalance() {
  116. jumpGenerationRankBalance().finally(() => {
  117. this.notifyRootRefresh()
  118. })
  119. },
  120. terminateAndJumpDispatch() {
  121. terminateGeneration().then(res => {
  122. // this.refreshData()
  123. this.jumpDispatch()
  124. }).catch(_ => this.notifyRootRefresh())
  125. },
  126. jumpDispatch() {
  127. const path = '/evaluating/master-manage/permission/elective/dispatch/index'
  128. this.transferTo(path)
  129. }
  130. }
  131. }
  132. </script>
  133. <style scoped>
  134. </style>