Browse Source

tmp save for ai-table

hare8999@163.com 2 years ago
parent
commit
56202d70e4

+ 1 - 1
src/views/elective/select/components/ai-round-select-resolvers/backTracking-ai-resolver-mixins.js

@@ -1,6 +1,6 @@
 export default {
   methods: {
-    backTrackingResolver(model, activeModel, context) {
+    backTrackingAIResolver(model, activeModel, context) {
       const models = model?.models || []
       this.rows.forEach(item => {
         const currentGroup = models.find(group => group.groupId == item.groupId) || {}

+ 1 - 1
src/views/elective/select/components/ai-round-select-resolvers/finalAdjust-ai-resolver-mixins.js

@@ -1,6 +1,6 @@
 export default {
   methods: {
-    finalAdjustResolver(model, activeModel, context) {
+    finalAdjustAIResolver(model, activeModel, context) {
       const models = model?.models || []
       this.rows.forEach(item => {
         const currentGroup = models.find(group => group.groupId == item.groupId) || {}

+ 19 - 35
src/views/elective/select/components/elective-ai-table.vue

@@ -1,6 +1,6 @@
 <template>
   <div>
-    <mx-table :propDefines="propDefines" :rows="rows">
+    <mx-table :propDefines="formatCols" :rows="formatRows">
       <template #underOver="{value}">
         <over-under-badge :value="value"></over-under-badge>
       </template>
@@ -17,7 +17,7 @@
         <el-button @click="toReport('single',row)">查看</el-button>
       </template>
     </mx-table>
-    <elective-ai-report-dialog ref="aiReportDialog"></elective-ai-report-dialog>
+    <elective-ai-report-dialog v-if="false" ref="aiReportDialog"></elective-ai-report-dialog>
   </div>
 </template>
 <script>
@@ -29,10 +29,12 @@ import ElectiveTableGroupTag from '@/views/elective/select/components/elective-t
 
 const resolverModules = require.context('./ai-round-select-resolvers', false, /\.js$/)
 const resolvers = resolverModules.keys().map(key => resolverModules(key).default)
+import ElectiveTableMixin from './elective-table-mixins'
 
 export default {
-  mixins: [...resolvers],
+  mixins: [ElectiveTableMixin, ...resolvers],
   name: 'elective-ai-table',
+  props: ['generation', 'optionalMajors'],
   components: {
     ElectiveTableGroupTag,
     ElectiveMajorCollege,
@@ -40,25 +42,6 @@ export default {
     ElectiveAiReportDialog,
     OverUnderBadge
   },
-  props: {
-    generation: Object,
-    readonly: Boolean,
-    optionalMajors: { type: Array, default: () => [] }
-  },
-  data() {
-    return {
-      rows: []
-    }
-  },
-  created() {
-    const optionalMajors = this.optionalMajors
-    // 初始化rows 当前activeModels
-    this.rows = this.generation.activeModel.models.map(row => {
-      row.colleges = optionalMajors.map(m => ({ college: m.collegeName, major: m.majorCategoryName }))
-      row.subjects = optionalMajors.map(m => m['majorCategoryName'])
-      return row
-    })
-  },
   computed: {
     resolveTablePrefix() {
       return {
@@ -93,26 +76,27 @@ export default {
         }
       }
     },
-    formatTable() {
-      // if (!this.formatRows) return {}
+    resolveDynamicAITable() {
+      if (!this.formatRows?.length) return {}
       const options = this.generation.options
-      console.log(this.generation)
       if (!options || !this.generation.active) return {}
-      // const optValues = Object.values(options)
       const dynamicColumns = {}
-      const resolverKey = this.generation.activeOpt.key + 'Resolver'
-      const resolver = this[resolverKey]
-      if (typeof resolver === 'function') {
-        const genColumns = resolver(this.generation.active)
-        Object.assign(dynamicColumns, genColumns)
-      }
-      console.log(dynamicColumns)
+      this.generation.activeModels.forEach(model => {
+        if (model.generation != this.generation.active) return // 暂只执行一步
+        const resolverKey = model.option.key + 'AIResolver'
+        const resolver = this[resolverKey]
+        if (typeof resolver === 'function') {
+          const genColumns = resolver(model, this.generation.activeModel, dynamicColumns)
+          Object.assign(dynamicColumns, genColumns)
+        }
+      })
       return dynamicColumns
     },
-    propDefines() {
+    formatCols() {
       return {
         ...this.resolveTablePrefix,
-        ...this.formatTable,
+        ...this.resolveDynamicTable,
+        ...this.resolveDynamicAITable,
         ...this.resolveTableSuffix
       }
     }

+ 3 - 1
src/views/elective/select/components/elective-preference-batch.vue

@@ -33,7 +33,9 @@ export default {
       }
       await this.$confirm(`确认填报 ${this.allSelectedGroupNames}`)
       try {
-        await submitElectiveModels({ models: this.selectedList.map(g => g.groupId) })
+        await submitElectiveModels({
+          models: this.selectedList.map(g => ({ groupId: g.groupId }))
+        })
         this.$message.success('报名成功')
       } finally {
         this.refreshData()

+ 2 - 2
src/views/elective/select/components/elective-preference-command.vue

@@ -49,7 +49,7 @@ export default {
         this.group.selected = true
         this.selectedList.push(this.group)
         try {
-          await submitElectiveModels({ models: this.selectedList.map(g => g.groupId) })
+          await submitElectiveModels({ models: this.selectedList.map(g => ({ groupId: g.groupId })) })
           this.$message.success('报名成功')
         } finally {
           this.refreshData()
@@ -66,7 +66,7 @@ export default {
         this.group.selected = false
         this.selectedList.remove(this.group)
         try {
-          await submitElectiveModels({ models: this.selectedList.map(g => g.groupId) })
+          await submitElectiveModels({ models: this.selectedList.map(g => ({ groupId: g.groupId })) })
           this.$message.success('报名取消成功,您可以重新填报')
         } finally {
           this.refreshData()

+ 136 - 0
src/views/elective/select/components/elective-table-mixins.js

@@ -0,0 +1,136 @@
+import consts from '@/common/mx-const'
+import { mapGetters } from 'vuex'
+import ElectiveToolsMixin from './elective-tools-mixins'
+
+const resolverModules = require.context('./round-select-resolvers', false, /\.js$/)
+const resolvers = resolverModules.keys().map(key => resolverModules(key).default)
+
+export default {
+  mixins: [...resolvers, ElectiveToolsMixin],
+  props: ['generation', 'optionalMajors'],
+  computed: {
+    ...mapGetters(['hasPermissions']),
+    enrollStatus() {
+      const enrolledGroup = this.generation.activeModel.models?.find(this.isGroupEnrolled)
+      if (enrolledGroup) {
+        let enrolledModel = this.generation.activeModel
+        do {
+          const matched = enrolledModel.models?.find(this.isGroupEnrolled)
+          if (matched
+            && matched.groupId == enrolledGroup.groupId
+            && enrolledModel.selectedList.includes(matched)) {
+            return {
+              enrolledGroup,
+              enrolledModel
+            }
+          }
+          enrolledModel = enrolledModel.prevModel
+        }
+        while (enrolledModel)
+      }
+      return { enrolledGroup, enrolledModel: null }
+    },
+    resolveTablePrefix() {
+      return {
+        index: {
+
+          type: 'index',
+          label: '编号'
+        },
+        groupName: {
+          label: '选科组合',
+          slot: 'group',
+          width: '85px'
+        },
+        scoreSumGroup: {
+          label: '组合成绩',
+          hidden: this.hasPermissions([consts.enum.electivePermission.rankInGroup.scoreByGroup])
+        },
+        classCount: {
+          label: '开设班级数'
+        },
+        personCount: {
+          label: '人数设置'
+        }
+      }
+    },
+    resolveTableSuffix() {
+      const stepMatched = this.generation.active == this.generation.current
+      const enableApply = !this.generation.currentOpt.decisionMaking
+      const enableSignUp = stepMatched && enableApply && !this.readonly
+
+      return {
+        rankInGroup: {
+          label: '当前组合实时排名',
+          hidden: this.hasPermissions([consts.enum.electivePermission.rankInGroup])
+        },
+        rankInGrade: {
+          label: '选科全校排名',
+          hidden: this.hasPermissions([consts.enum.electivePermission.rankInGrade])
+        },
+        allowSelectTips: {
+          label: '报名状态'
+        },
+        temp: {
+          label: '选择专业',
+          width: '140',
+          slot: 'temp',
+          hidden: this.readonly
+        },
+        subjects: {
+          label: '自选专业',
+          slot: 'subjects',
+          minWidth: '150'
+        },
+        colleges: {
+          label: '院校',
+          slot: 'colleges',
+          minWidth: '250'
+        },
+        signUp: {
+          label: '操作',
+          slot: 'signUp',
+          width: '100',
+          fixed: 'right',
+          hidden: !enableSignUp
+        }
+      }
+    },
+    resolveDynamicTable() {
+      if (!this.formatRows?.length) return {}
+      const options = this.generation.options
+      if (!options || !this.generation.active) return {}
+      const dynamicColumns = {}
+      this.generation.activeModels.forEach(model => {
+        const resolverKey = model.option.key + 'Resolver'
+        const resolver = this[resolverKey]
+        if (typeof resolver === 'function') {
+          const genColumns = resolver(model, this.generation.activeModel, dynamicColumns)
+          Object.assign(dynamicColumns, genColumns)
+        }
+      })
+      return dynamicColumns
+    },
+    formatRows() {
+      if (!this.optionalMajors) return []
+      if (!this.generation.roundGroups?.length) return []
+      if (!this.generation.activeModels?.length) return []
+      const activeModel = this.generation.activeModel
+      return this.generation.roundGroups.map(rg => {
+        const row = activeModel.models?.find(item => item.groupId == rg.groupId) || {}
+        this.$set(row, 'allowSelectTips', this.combineGroupStatus(row, activeModel))
+        const matchedMajors = this.optionalMajors.filter(college => college.matchedGroupIds.includes(row.groupId))
+        this.$set(row, 'colleges', matchedMajors.map(m => ({ college: m.collegeName, major: m.majorCategoryName })))
+        this.$set(row, 'subjects', matchedMajors.map(m => m['majorCategoryName']))
+        return row
+      })
+    },
+    formatCols() {
+      return {
+        ...this.resolveTablePrefix,
+        ...this.resolveDynamicTable,
+        ...this.resolveTableSuffix
+      }
+    }
+  }
+}

+ 2 - 129
src/views/elective/select/components/elective-table.vue

@@ -42,14 +42,11 @@
   </div>
 </template>
 <script>
-import consts from '@/common/mx-const'
-import { mapGetters } from 'vuex'
 import MxSelectTranslate from '@/components/Cache/modules/mx-select-translate-mixin.js'
 import ChooseSubjectDialog from '../../../system/user/profile/components/choose-subject-dialog'
 import SelectSubjectReportDialog from '@/views/system/user/profile/components/select-subject-report-dialog'
 import OverUnderBadge from '@/views/elective/publish/components/steps/fauclty/over-under-badge'
 import ElectiveEnrollInfo from '@/views/elective/select/components/elective-enroll-info'
-import ElectiveToolsMixin from './elective-tools-mixins'
 import ElectivePreferenceInfo from '@/views/elective/select/components/elective-preference-info'
 import ElectivePreferenceReject from '@/views/elective/select/components/elective-preference-reject'
 import ElectivePreferenceCommand from '@/views/elective/select/components/elective-preference-command'
@@ -60,11 +57,10 @@ import ElectiveMajorCollege from '@/views/elective/select/components/elective-ma
 import ElectivePreferenceBatch from '@/views/elective/select/components/elective-preference-batch'
 import ElectiveTableGroupTag from '@/views/elective/select/components/elective-table-group-tag'
 
-const resolverModules = require.context('./round-select-resolvers', false, /\.js$/)
-const resolvers = resolverModules.keys().map(key => resolverModules(key).default)
+import ElectiveTableMixin from './elective-table-mixins'
 
 export default {
-  mixins: [ElectiveToolsMixin, MxSelectTranslate, ...resolvers],
+  mixins: [ElectiveTableMixin, MxSelectTranslate],
   name: 'elective-table',
   props: {
     generation: Object,
@@ -93,30 +89,9 @@ export default {
     }
   },
   computed: {
-    ...mapGetters(['hasPermissions']),
     enrollInfoVisible() {
       return this.generation.active > this.generation.options.primary.value
     },
-    enrollStatus() {
-      const enrolledGroup = this.generation.activeModel.models?.find(this.isGroupEnrolled)
-      if (enrolledGroup) {
-        let enrolledModel = this.generation.activeModel
-        do {
-          const matched = enrolledModel.models?.find(this.isGroupEnrolled)
-          if (matched
-            && matched.groupId == enrolledGroup.groupId
-            && enrolledModel.selectedList.includes(matched)) {
-            return {
-              enrolledGroup,
-              enrolledModel
-            }
-          }
-          enrolledModel = enrolledModel.prevModel
-        }
-        while (enrolledModel)
-      }
-      return { enrolledGroup, enrolledModel: null }
-    },
     stepMatched() {
       return this.generation.active == this.generation.current
     },
@@ -142,108 +117,6 @@ export default {
       return !this.generation.activeOpt.decisionMaking
         && this.generation.activeOpt != this.generation.options.primary
         && !this.readonly
-    },
-    resolveTablePrefix() {
-      return {
-        index: {
-
-          type: 'index',
-          label: '编号'
-        },
-        groupName: {
-          label: '选科组合',
-          slot: 'group',
-          width: '85px'
-        },
-        scoreSumGroup: {
-          label: '组合成绩',
-          hidden: this.hasPermissions([consts.enum.electivePermission.rankInGroup.scoreByGroup])
-        },
-        classCount: {
-          label: '开设班级数'
-        },
-        personCount: {
-          label: '人数设置'
-        }
-      }
-    },
-    resolveTableSuffix() {
-      const stepMatched = this.generation.active == this.generation.current
-      const enableApply = !this.generation.currentOpt.decisionMaking
-      const enableSignUp = stepMatched && enableApply && !this.readonly
-
-      return {
-        rankInGroup: {
-          label: '当前组合实时排名',
-          hidden: this.hasPermissions([consts.enum.electivePermission.rankInGroup])
-        },
-        rankInGrade: {
-          label: '选科全校排名',
-          hidden: this.hasPermissions([consts.enum.electivePermission.rankInGrade])
-        },
-        allowSelectTips: {
-          label: '报名状态'
-        },
-        temp: {
-          label: '选择专业',
-          width: '140',
-          slot: 'temp',
-          hidden: this.readonly
-        },
-        subjects: {
-          label: '自选专业',
-          slot: 'subjects',
-          minWidth: '150'
-        },
-        colleges: {
-          label: '院校',
-          slot: 'colleges',
-          minWidth: '250'
-        },
-        signUp: {
-          label: '操作',
-          slot: 'signUp',
-          width: '100',
-          fixed: 'right',
-          hidden: !enableSignUp
-        }
-      }
-    },
-    resolveDynamicTable() {
-      if (!Object.keys(this.formatRows).length) return {}
-      const options = this.generation.options
-      if (!options || !this.generation.active) return {}
-      const dynamicColumns = {}
-      this.generation.activeModels.forEach(model => {
-        const resolverKey = model.option.key + 'Resolver'
-        const resolver = this[resolverKey]
-        if (typeof resolver === 'function') {
-          const genColumns = resolver(model, this.generation.activeModel, dynamicColumns)
-          Object.assign(dynamicColumns, genColumns)
-        }
-      })
-      return dynamicColumns
-    },
-    formatRows() {
-      if (!this.optionalMajors) return []
-      if (!this.generation.roundGroups?.length) return []
-      if (!this.generation.activeModels?.length) return []
-      const activeModel = this.generation.activeModel
-      return this.generation.roundGroups.map(rg => {
-        const row = activeModel.models?.find(item => item.groupId == rg.groupId) || {}
-        this.$set(row, 'allowSelectTips', this.combineGroupStatus(row, activeModel))
-        const matchedMajors = this.optionalMajors.filter(college => college.matchedGroupIds.includes(row.groupId))
-        this.$set(row, 'colleges', matchedMajors.map(m => ({ college: m.collegeName, major: m.majorCategoryName })))
-        this.$set(row, 'subjects', matchedMajors.map(m => m['majorCategoryName']))
-        return row
-      })
-    },
-    formatCols() {
-      return {
-        ...this.resolveTablePrefix,
-        ...this.resolveDynamicTable,
-        ...this.resolveTableSuffix
-      }
     }
   },
   methods: {