elective-table.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <div>
  3. <div class="mb10 fx-row fx-bet-cen">
  4. <div class="fx-row fx-end-cen">
  5. <el-button circle icon="el-icon-refresh" @click="refreshData" class="mr30"></el-button>
  6. <elective-enroll-info v-if="enrollInfoVisible" :generation="generation"
  7. :enroll-status="enrollStatus"></elective-enroll-info>
  8. </div>
  9. <el-button v-if="enableAIFeature" type="primary" @click="toAiAnalysis">AI分析</el-button>
  10. </div>
  11. <mx-table :propDefines="formatCols" :rows="formatRows">
  12. <template #underOver="{value}">
  13. <over-under-badge :value="value"></over-under-badge>
  14. </template>
  15. <template #group="{row}">
  16. <elective-table-group-tag :generation="generation" :group="row"></elective-table-group-tag>
  17. </template>
  18. <template #temp="{row}">
  19. <span class="btn-blue mr5" @click="toSelectSub(row)">选择</span>
  20. <span class="btn-green" @click="toReport">查看记录</span>
  21. </template>
  22. <template #signUp="{row}">
  23. <elective-preference-command :generation="generation" :group="row"></elective-preference-command>
  24. </template>
  25. <template #subjects="{row}">
  26. <elective-major-thumbnail :group="row"></elective-major-thumbnail>
  27. </template>
  28. <template #colleges="{row}">
  29. <elective-major-college :group="row"></elective-major-college>
  30. </template>
  31. </mx-table>
  32. <elective-preference-info :generation="generation"></elective-preference-info>
  33. <elective-preference-batch v-if="enableMultipleDrag" :generation="generation"
  34. :disabled="!enableSelect"></elective-preference-batch>
  35. <elective-preference-reject v-if="enableReject" :generation="generation"></elective-preference-reject>
  36. <elective-esign-dialog ref="esignDialog"></elective-esign-dialog>
  37. <choose-subject-dialog ref="chooseDialog"></choose-subject-dialog>
  38. <select-subject-report-dialog ref="reportDialog"></select-subject-report-dialog>
  39. <elective-ai-analysis-dialog ref="aiDialog" :optionalMajors="optionalMajors"
  40. :generation="generation"></elective-ai-analysis-dialog>
  41. </div>
  42. </template>
  43. <script>
  44. import MxSelectTranslate from '@/components/Cache/modules/mx-select-translate-mixin.js'
  45. import ChooseSubjectDialog from '../../../system/user/profile/components/choose-subject-dialog'
  46. import SelectSubjectReportDialog from '@/views/system/user/profile/components/select-subject-report-dialog'
  47. import OverUnderBadge from '@/views/elective/publish/components/steps/fauclty/over-under-badge'
  48. import ElectiveEnrollInfo from '@/views/elective/select/components/elective-enroll-info'
  49. import ElectivePreferenceInfo from '@/views/elective/select/components/elective-preference-info'
  50. import ElectivePreferenceReject from '@/views/elective/select/components/elective-preference-reject'
  51. import ElectivePreferenceCommand from '@/views/elective/select/components/elective-preference-command'
  52. import ElectiveAiAnalysisDialog from '@/views/elective/select/components/elective-ai-analysis-dialog'
  53. import ElectiveEsignDialog from '@/views/elective/select/components/elective-esign-dialog'
  54. import ElectiveMajorThumbnail from '@/views/elective/select/components/elective-major-thumbnail'
  55. import ElectiveMajorCollege from '@/views/elective/select/components/elective-major-college'
  56. import ElectivePreferenceBatch from '@/views/elective/select/components/elective-preference-batch'
  57. import ElectiveTableGroupTag from '@/views/elective/select/components/elective-table-group-tag'
  58. import ElectiveTableMixin from './elective-table-mixins'
  59. export default {
  60. mixins: [ElectiveTableMixin, MxSelectTranslate],
  61. name: 'elective-table',
  62. props: {
  63. generation: Object,
  64. readonly: Boolean, // 校长端不允许操作
  65. optionalMajors: { type: Array, default: () => [] }
  66. },
  67. components: {
  68. ElectiveTableGroupTag,
  69. ElectivePreferenceBatch,
  70. ElectiveMajorCollege,
  71. ElectiveMajorThumbnail,
  72. ElectiveEsignDialog,
  73. ElectiveAiAnalysisDialog,
  74. ElectivePreferenceCommand,
  75. ElectivePreferenceReject,
  76. ElectivePreferenceInfo,
  77. ElectiveEnrollInfo,
  78. OverUnderBadge,
  79. SelectSubjectReportDialog,
  80. ChooseSubjectDialog
  81. },
  82. inject: {
  83. refreshData: {
  84. default: function() {
  85. }
  86. }
  87. },
  88. computed: {
  89. enrollInfoVisible() {
  90. return this.generation.active > this.generation.options.primary.value
  91. },
  92. stepMatched() {
  93. return this.generation.active == this.generation.current
  94. },
  95. selectStep() {
  96. return !this.generation.activeOpt.decisionMaking
  97. },
  98. enableSelect() {
  99. return this.stepMatched && this.selectStep && !!!this.enrollStatus.enrolledGroup && !this.readonly
  100. },
  101. selectedList() {
  102. return this.generation.activeModel.selectedList
  103. },
  104. multipleSelect() {
  105. return this.generation.activeModel.preferenceCount > 1
  106. },
  107. enableMultipleDrag() {
  108. return this.selectStep && this.multipleSelect
  109. },
  110. enableReject() {
  111. return this.enableSelect && this.generation.active > this.generation.options.primary.value
  112. },
  113. enableAIFeature() {
  114. return !this.generation.activeOpt.decisionMaking
  115. && this.generation.activeOpt != this.generation.options.primary
  116. && !this.readonly
  117. }
  118. },
  119. methods: {
  120. preventSelectedListChanged() {
  121. if (!this.enableSelect) return Promise.resolve(true)
  122. const from = this.generation.activeModel.selectedList
  123. const to = this.generation.activeModel.selectedListSnapshot
  124. let changedMsg = '请先提交更改过的志愿', changed = false
  125. if (from.length != to.length) {
  126. changed = true
  127. } else if (from.length) {
  128. const elementCheckFields = ['selected', 'rejected', 'groupId']
  129. from.forEach((eleFrom, idx) => {
  130. const eleTo = to[idx]
  131. const eleChanged = elementCheckFields.some(f => eleFrom[f] != eleTo[f])
  132. if (eleChanged) changed = true
  133. })
  134. }
  135. if (changed) this.$message.warning(changedMsg)
  136. return changed ? Promise.reject(changedMsg) : Promise.resolve(true)
  137. },
  138. async toReport() {
  139. await this.preventSelectedListChanged()
  140. this.$refs.reportDialog.open()
  141. },
  142. async toSelectSub(row) {
  143. await this.preventSelectedListChanged()
  144. // 打开选科弹窗
  145. const course0 = this.translateCourse0(row.groupId)
  146. const course1 = this.translateCourse1(row.groupId)
  147. this.$refs.chooseDialog.open(course0, course1)
  148. },
  149. toAiAnalysis() {
  150. // AI 分析 跳转
  151. this.$refs.aiDialog.open(this.formatRows)
  152. }
  153. }
  154. }
  155. </script>
  156. <style scoped>
  157. </style>