elective-ai-table.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <div>
  3. <mx-table :propDefines="formatCols" :rows="formatRows">
  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. </mx-table>
  17. <elective-ai-report-dialog v-if="true" ref="aiReportDialog" :generation="generation"></elective-ai-report-dialog>
  18. </div>
  19. </template>
  20. <script>
  21. import OverUnderBadge from '@/views/elective/publish/components/steps/fauclty/over-under-badge'
  22. import ElectiveAiReportDialog from '@/views/elective/select/components/elective-ai-report-dialog'
  23. import ElectiveMajorThumbnail from '@/views/elective/select/components/elective-major-thumbnail'
  24. import ElectiveMajorCollege from '@/views/elective/select/components/elective-major-college'
  25. import ElectiveTableGroupTag from '@/views/elective/select/components/elective-table-group-tag'
  26. const resolverModules = require.context('./ai-round-select-resolvers', false, /\.js$/)
  27. const resolvers = resolverModules.keys().map(key => resolverModules(key).default)
  28. import ElectiveTableMixin from './elective-table-mixins'
  29. export default {
  30. mixins: [ElectiveTableMixin, ...resolvers],
  31. name: 'elective-ai-table',
  32. components: {
  33. ElectiveTableGroupTag,
  34. ElectiveMajorCollege,
  35. ElectiveMajorThumbnail,
  36. ElectiveAiReportDialog,
  37. OverUnderBadge
  38. },
  39. computed: {
  40. resolveTablePrefix() {
  41. return {
  42. groupName: {
  43. label: '选科组合',
  44. width: '120px',
  45. slot: 'group'
  46. },
  47. scoreSumGroup: {
  48. label: '组合成绩'
  49. }
  50. }
  51. },
  52. resolveTableSuffix() {
  53. return {
  54. subjects: {
  55. label: '自选专业',
  56. slot: 'subjects',
  57. width: '150'
  58. },
  59. colleges: {
  60. label: '院校',
  61. slot: 'colleges',
  62. width: '250'
  63. },
  64. // signUp: {
  65. // label: '报告',
  66. // slot: 'report',
  67. // width: '100',
  68. // fixed: 'right',
  69. // hidden: this.readonly
  70. // }
  71. }
  72. },
  73. resolveDynamicAITable() {
  74. if (!this.formatRows?.length) return {}
  75. const options = this.generation.options
  76. if (!options || !this.generation.active) return {}
  77. const dynamicColumns = {}
  78. const model = this.generation.activeModel
  79. const resolverKey = model.option.key + 'AIResolver'
  80. const resolver = this[resolverKey]
  81. if (typeof resolver === 'function') {
  82. const genColumns = resolver(model, model, dynamicColumns)
  83. Object.assign(dynamicColumns, genColumns)
  84. }
  85. return dynamicColumns
  86. },
  87. formatCols() {
  88. const _ = this.resolveDynamicTable // Note: force execute!
  89. return {
  90. ...this.resolveTablePrefix,
  91. ...this.resolveDynamicAITable,
  92. ...this.resolveTableSuffix
  93. }
  94. }
  95. },
  96. methods: {
  97. toReport() {
  98. this.$refs.aiReportDialog.init()
  99. }
  100. }
  101. }
  102. </script>
  103. <style scoped>
  104. /deep/ .el-badge__content.is-fixed {
  105. top: 8px;
  106. right: 8px;
  107. }
  108. </style>