elective-ai-table.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <div>
  3. <mx-table :propDefines="propDefines" :rows="rows">
  4. <template #underOver="{value}">
  5. <over-under-badge :value="value"></over-under-badge>
  6. </template>
  7. <template #subjects="{row}">
  8. <elective-major-thumbnail :group="row"></elective-major-thumbnail>
  9. </template>
  10. <template #group="{row}">
  11. <elective-table-group-tag :generation="generation" :group="row"></elective-table-group-tag>
  12. </template>
  13. <template #colleges="{row}">
  14. <elective-major-college :group="row"></elective-major-college>
  15. </template>
  16. <template #report="{row}">
  17. <el-button @click="toReport('single',row)">查看</el-button>
  18. </template>
  19. </mx-table>
  20. <elective-ai-report-dialog ref="aiReportDialog"></elective-ai-report-dialog>
  21. </div>
  22. </template>
  23. <script>
  24. import OverUnderBadge from '@/views/elective/publish/components/steps/fauclty/over-under-badge'
  25. import ElectiveAiReportDialog from '@/views/elective/select/components/elective-ai-report-dialog'
  26. import ElectiveMajorThumbnail from '@/views/elective/select/components/elective-major-thumbnail'
  27. import ElectiveMajorCollege from '@/views/elective/select/components/elective-major-college'
  28. import ElectiveTableGroupTag from '@/views/elective/select/components/elective-table-group-tag'
  29. const resolverModules = require.context('./ai-round-select-resolvers', false, /\.js$/)
  30. const resolvers = resolverModules.keys().map(key => resolverModules(key).default)
  31. export default {
  32. mixins: [...resolvers],
  33. name: 'elective-ai-table',
  34. components: {
  35. ElectiveTableGroupTag,
  36. ElectiveMajorCollege,
  37. ElectiveMajorThumbnail,
  38. ElectiveAiReportDialog,
  39. OverUnderBadge
  40. },
  41. props: {
  42. generation: Object,
  43. readonly: Boolean,
  44. optionalMajors: { type: Array, default: () => [] }
  45. },
  46. data() {
  47. return {
  48. rows: []
  49. }
  50. },
  51. created() {
  52. const optionalMajors = this.optionalMajors
  53. // 初始化rows 当前activeModels
  54. this.rows = this.generation.activeModel.models.map(row => {
  55. row.colleges = optionalMajors.map(m => ({ college: m.collegeName, major: m.majorCategoryName }))
  56. row.subjects = optionalMajors.map(m => m['majorCategoryName'])
  57. return row
  58. })
  59. },
  60. computed: {
  61. resolveTablePrefix() {
  62. return {
  63. groupName: {
  64. label: '选科组合',
  65. width: '120px',
  66. slot: 'group'
  67. },
  68. scoreSumGroup: {
  69. label: '组合成绩'
  70. }
  71. }
  72. },
  73. resolveTableSuffix() {
  74. return {
  75. subjects: {
  76. label: '自选专业',
  77. slot: 'subjects',
  78. width: '150'
  79. },
  80. colleges: {
  81. label: '院校',
  82. slot: 'colleges',
  83. width: '250'
  84. },
  85. signUp: {
  86. label: '报告',
  87. slot: 'report',
  88. width: '100',
  89. fixed: 'right',
  90. hidden: this.readonly
  91. }
  92. }
  93. },
  94. formatTable() {
  95. // if (!this.formatRows) return {}
  96. const options = this.generation.options
  97. console.log(this.generation)
  98. if (!options || !this.generation.active) return {}
  99. // const optValues = Object.values(options)
  100. const dynamicColumns = {}
  101. const resolverKey = this.generation.activeOpt.key + 'Resolver'
  102. const resolver = this[resolverKey]
  103. if (typeof resolver === 'function') {
  104. const genColumns = resolver(this.generation.active)
  105. Object.assign(dynamicColumns, genColumns)
  106. }
  107. console.log(dynamicColumns)
  108. return dynamicColumns
  109. },
  110. propDefines() {
  111. return {
  112. ...this.resolveTablePrefix,
  113. ...this.formatTable,
  114. ...this.resolveTableSuffix
  115. }
  116. }
  117. },
  118. methods: {
  119. toReport(type, row) {
  120. this.$refs.aiReportDialog.init(type, row)
  121. }
  122. }
  123. }
  124. </script>
  125. <style scoped>
  126. /deep/ .el-badge__content.is-fixed {
  127. top: 8px;
  128. right: 8px;
  129. }
  130. </style>