elective-generation-master.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <div class="fx-column">
  3. <evaluation-empty v-if="isUnPassedStep" :shadow="false" :title="emptyTitle"></evaluation-empty>
  4. <template v-else>
  5. <div class="fx-row fx-bet-cen mb15">
  6. <div>
  7. <slot name="header-prefix"></slot>
  8. </div>
  9. <div class="fx-1">
  10. <slot :name="activeKey+'-header'" v-bind="chartBinding">
  11. <elective-generation-commands v-if="!stepDisabled" :chart-binding="chartBinding"
  12. @jumpDetail="handleJumpDetail"/>
  13. </slot>
  14. </div>
  15. <div>
  16. <slot name="header-suffix">
  17. <el-button type="primary" @click="jumpReport" class="ml10">选科数据</el-button>
  18. </slot>
  19. </div>
  20. </div>
  21. <slot :name="activeKey" v-bind="chartBinding">
  22. <elective-generation-table :chart-binding="chartBinding" ref="gTable"></elective-generation-table>
  23. </slot>
  24. <slot name="footer-prefix"></slot>
  25. <slot :name="activeKey+'-footer'" v-bind="chartBinding">
  26. <elective-generation-charts :chart-binding="chartBinding" class="mt40"></elective-generation-charts>
  27. </slot>
  28. <slot name="footer-suffix"></slot>
  29. </template>
  30. </div>
  31. </template>
  32. <script>
  33. import ElectiveGenerationTable from '@/views/elective/generation/components/elective-generation-table'
  34. import ElectiveGenerationCharts from '@/views/elective/generation/components/elective-generation-charts'
  35. import ElectiveGenerationCommands from '@/views/elective/generation/components/elective-generation-commands'
  36. import transferMixin from '@/components/mx-transfer-mixin'
  37. export default {
  38. mixins: [transferMixin],
  39. name: 'elective-generation-master',
  40. components: { ElectiveGenerationCommands, ElectiveGenerationCharts, ElectiveGenerationTable },
  41. props: {
  42. generation: {
  43. type: Object
  44. }
  45. },
  46. data() {
  47. return {
  48. emptyTitle: ''
  49. }
  50. },
  51. computed: {
  52. activeKey() {
  53. return this.generation.activeOpt?.key || ''
  54. },
  55. stepDisabled() {
  56. return this.generation.active !== this.generation.current
  57. },
  58. isUnPassedStep() {
  59. if (!this.generation.activeOpt) return false
  60. this.emptyTitle = this.generation.currentOpt == this.generation.options.init
  61. ? '选科还未开启'
  62. : `正在进行${this.generation.currentOpt.title || '{未知进程}'}, 还未进行至${this.generation.activeOpt.title}`
  63. return this.generation.active > this.generation.current
  64. },
  65. categories() {
  66. // summary - categories for display in table
  67. return this.generation.summary.filter(item => item.generation <= this.generation.active)
  68. },
  69. accumulates() {
  70. // summary - accumulate for display in charts
  71. let options = this.generation.options
  72. let generation = this.generation.active
  73. let generationData = this.generation.summary.find(item => item.generation == generation && item.accumulates?.length)
  74. if (!generationData) {
  75. generation = generation - 1
  76. generationData = this.generation.summary.find(item => item.generation == generation)
  77. }
  78. return generationData?.accumulates?.length ? {
  79. generation: generation, // 图表激活的进程代,除初选报名外,一般为决策代数据
  80. accumulates: generationData.accumulates
  81. } : null
  82. },
  83. chartBinding() {
  84. return {
  85. generation: this.generation,
  86. tableData: this.categories,
  87. chartData: this.accumulates
  88. }
  89. }
  90. },
  91. methods: {
  92. jumpReport() {
  93. // 跳转选科数据
  94. // TODO: 页面还没有定义好
  95. },
  96. handleJumpDetail() {
  97. // 跳列表,模拟点击第一列
  98. this.$refs.gTable.simulateGoDetails()
  99. }
  100. }
  101. }
  102. </script>
  103. <style scoped>
  104. </style>