shilipojs 3 éve
szülő
commit
3038f7934d

+ 63 - 0
src/api/webApi/elective/dispatch.js

@@ -1,5 +1,68 @@
 import request from '@/utils/request'
 
+// 查询 ROUND
+export function getRound(params) {
+  return request({
+    url: '/front/elective/classes/round',
+    method: 'get',
+    params
+  })
+}
+
+// 查询分班配置
+export function getSettings(params) {
+  return request({
+    url: '/front/elective/classes/settings',
+    method: 'get',
+    params
+  })
+}
+
+// 保存分班配置
+export function saveSettings(params) {
+  return request({
+    url: '/front/elective/classes/settings',
+    method: 'post',
+    data: params
+  })
+}
+
+// 应用分班配置
+export function applySettings(params) {
+  return request({
+    url: '/front/elective/classes/settings/apply',
+    method: 'post',
+    params
+  })
+}
+
+// 分派名单查询
+export function classesResult(params) {
+  return request({
+    url: '/front/elective/classes/result',
+    method: 'get',
+    params
+  })
+}
+
+// 分派转移
+export function resultDispatch(params) {
+  return request({
+    url: '/front/elective/classes/result/dispatch',
+    method: 'post',
+    params
+  })
+}
+
+// 锁定分班
+export function lockDispatch(params) {
+  return request({
+    url: '/front/elective/classes',
+    method: 'post',
+    params
+  })
+}
+
 export function getCurrentRound(params) {
   return request({
     url: '/mock/front/report/getCurrentRound',

+ 23 - 11
src/views/elective/dispatch/components/choose-class.vue

@@ -1,6 +1,6 @@
 <template>
   <el-dialog
-    :title="`选择班级(${roundGroup.groupName})`"
+    :title="`选择班级(${roundGroup.groupName || ''})`"
     :visible.sync="show"
     :close-on-click-modal="false"
     width="50%"
@@ -49,6 +49,12 @@ import * as busiClass from '@/api/webApi/busi-classes.js'
 import { add } from '@/api/webApi/busi-classes.js'
 export default {
   name: 'choose-class',
+  props: {
+    year:{
+      type: Number ,
+      default: 0
+    }
+  },
   mixins: [MxClassTreeTranslateMixin],
   data() {
     return {
@@ -60,9 +66,9 @@ export default {
       form: {
         name: '',
         type: 1, // 默认为行政班
-        year: '2021', // 学年
-        gradeId: 500, // 年级
-        subjectId: "2,3,4,5,9,8,7,6,1" // 默认为全科目
+        year: '', // 学年
+        gradeId: '', // 年级
+        subjectId: "1,2,3,4,5,6,7,8,9" // 默认为全科目
       },
       rules: {
         name: [
@@ -75,7 +81,12 @@ export default {
   computed: {
     classList() {
       if (!this.classTree?.length) return []
-      return this.classTree[0].classList.map(item => {
+      if (!this.year) return []
+      // 获取该年份下的年级
+      const classTree= this.classTree[this.classTree.findIndex(i => i.year = this.year)]
+      this.form.grade = classTree.gradeId
+      this.form.year = classTree.year
+      return this.classTree[this.classTree.findIndex(i => i.year = this.year)].classList.map(item => {
         item['disabled'] = this.settingContainer.some(c => c.classId == item.classId && c.groupId !== this.roundGroup.groupId)
         return item
       })
@@ -100,12 +111,13 @@ export default {
       // int classId; // 班级
       const mergeClasses = this.tmpClassIds.map(id => {
         return this.tmpClasses.find(c => c.classId == id) || {
-          classId: id,
-          groupId: this.roundGroup.groupId,
-          expectedCount: 0,
-          actualCount: 0,
-          actualCountInMale: 0,
-          actualCountInFemale: 0
+          classId: id, // 班级Id
+          roundId: this.roundGroup.roundId, // 轮次Id
+          groupId: this.roundGroup.groupId, // 组合Id
+          actualCount: 0, // 应用才产生 实际人数
+          expectedCount: 0, // 期望人数
+          actualCountInMale: 0, // 应用才产生 实际男生
+          actualCountInFemale: 0 // 应用才产生 实际女生
         }
       })
       console.log(mergeClasses)

+ 53 - 48
src/views/elective/dispatch/components/dispatch-table.vue

@@ -2,7 +2,9 @@
   <el-row>
     <mx-table :propDefines="propDefines" :rows="displayRows">
       <template #classCount="{row,$index}">
-        <el-input-number  size="small" v-model="row.classCount" @change="classCountChange(row,$index)" :min="0" :disabled="row.classCount != 0" label="label"></el-input-number>
+        <el-input-number size="small" v-model="row.classCount" @change="classCountChange(row,$index)" :min="0"
+                         :disabled="row.classCount != 0" label="label"
+        ></el-input-number>
       </template>
       <!-- 人数设定 -->
       <template #countSet="{row}">
@@ -11,7 +13,7 @@
           plain
           icon="el-icon-edit"
           size="mini"
-          @click="countEdit(row)"
+          @click="editCount(row)"
         >设定
         </el-button>
       </template>
@@ -22,7 +24,7 @@
           plain
           icon="el-icon-edit"
           size="mini"
-          @click="edit(row)"
+          @click="editClass(row)"
         >编辑
         </el-button>
       </template>
@@ -38,7 +40,7 @@
         </el-button>
       </template>
     </mx-table>
-    <choose-class ref="editClassDialog"></choose-class>
+    <choose-class  :year="round.year" :roundId="round.roundId"  ref="editClassDialog"></choose-class>
     <set-classcount ref="setClassDialog"></set-classcount>
     <class-adjust ref="adjustDialog"></class-adjust>
   </el-row>
@@ -46,34 +48,37 @@
 <script>
 import MxClassTreeTranslateMixin from '@/components/Cache/modules/mx-classTree-translate-mixin.js'
 import MxSelectTranslateMixin from '@/components/Cache/modules/mx-select-translate-mixin.js'
-import * as gradeAxios from '@/api/webApi/grade'
-import { getCurrentRound } from '@/api/webApi/elective/dispatch'
 import ChooseClass from './choose-class'
 import ClassAdjust from './class-adjust'
 import SetClasscount from './set-classcount'
+
 export default {
   components: {
     ChooseClass,
     SetClasscount,
-    ClassAdjust
+    ClassAdjust,
   },
   mixins: [MxClassTreeTranslateMixin, MxSelectTranslateMixin],
   props: {
-    // round: {
-    //   type: Object,
-    //   default: {},
-    // }
+    round: {
+      type: Object,
+      default: {},
+    },
+    settings: {
+      type: Array,
+      default: [],
+    }
   },
   data() {
     return {
-      round: null,
       settingList: [],
+      dataList: [],
       propDefines: {
         groupName: {
           label: '组合'
         },
         number: {
-          label: '组合人数'
+          label: '录取人数'
         },
         classCount: {
           label: '班级数',
@@ -84,78 +89,78 @@ export default {
           slot: 'edit'
         },
         groupClass: {
-          label: '班级名称',
+          label: '班级名称'
         },
         countSet: {
           label: '人数设定',
-          slot:  'countSet'
+          slot: 'countSet'
         },
-        actualCount: {
-          label: '人数',
+        expectedCount: {
+          label: '人数'
         },
         adjust: {
           label: '操作',
-          slot:'adjust'
-        },
+          slot: 'adjust'
+        }
       }
     }
   },
   computed: {
-    allowDispatch() {
-      return this.round.allowDispatch
-    },
     displayRows() {
       if (!this.classTree.length) return []
       if (!this.listGroupsOptions.length) return []
-      // if (!this.settingList.length) return []
-      if (!this.round) return []
-
-      //
-      const rows = this.round.roundGroups.map(rg => ({
+      // if (!this.settings.length) return []
+      if (!this.round.groupList) return []
+      const rows = this.round.groupList.map(rg => ({
         groupId: rg.groupId,
-        groupName: this.translateGroup(rg.groupId),
-        number: this.round.enrollGroupCount[rg.groupId],
-        classCount: rg.classCount,
-        actualCount: this.settingList.filter(item => item.groupId == rg.groupId).map(item => item.actualCount).toString(),
-        groupClass: this.settingList
+        roundId: this.round.roundId,
+        groupName: rg.name,
+        number: this.round.enrollGroupCount[rg.groupId] || 200, // 录取人数
+        classCount: rg.classCount || 5, // 班级数
+        expectedCount: this.settings.filter(item => item.groupId == rg.groupId).map(item => item.expectedCount).toString(),
+        groupClass: this.settings
           .filter(item => item.groupId == rg.groupId)
-          .map(item => this.getClassName(item.classId)).toString(),
+          .map(item => this.getClassName(item.classId)).toString()
       }))
       console.log('displayRows computed:', rows)
       return rows
     }
   },
   created() {
-    this.loadRoundStatus()
+
   },
   methods: {
     adjust() {
       this.$refs.adjustDialog.open()
     },
-    countEdit(row) {
-      // 设定人数
-      const filter = this.settingList.filter(item => item.groupId == row.groupId)
+    editCount(row) {
+      // 设定分配人数
+      const filter = this.settings.filter(item => item.groupId == row.groupId)
       if (filter.length == 0) {
         this.$message.warning('班级未编辑')
         return
       }
-      this.$refs.setClassDialog.open(row,this.settingList)
-    },
-    async loadRoundStatus() {
-      const res = await getCurrentRound()
-      this.round = res.data
+      // if(){
+      //   this.$message.warning('需要选择')
+      // }
+      this.$refs.setClassDialog.open(row, this.settings)
     },
-    classCountChange(newVal,index) {
-      console.log(newVal)
-      console.log(index)
-      this.round.roundGroups[index] = newVal
+    classCountChange(newVal, index) {
+      this.round.groupList[index] = newVal
     },
-    edit(row) {
+    editClass(row) {
+      // 分配班级
       if (!row.classCount) {
         this.$message.warning('班级数为0时不可分班')
         return
       }
-      this.$refs.editClassDialog.open(row,this.settingList)
+      // 获取分班配置
+      // getSettings({
+      //   roundId: row.roundId
+      // }).then(res => {
+      //   this.$refs.editClassDialog.open(row, res.data)
+      // })
+      this.$refs.editClassDialog.open(row, this.settings)
     }
   }
 }

+ 15 - 15
src/views/elective/dispatch/components/set-classcount.vue

@@ -12,7 +12,6 @@
         style="width: 100%"
       >
         <el-table-column
-          prop="className"
           label="组合"
           width="180"
         >
@@ -27,11 +26,10 @@
         >
         </el-table-column>
         <el-table-column
-          prop="date"
           label="人数"
         >
           <template slot-scope="scope">
-            <el-input-number :min="0" :max="roundGroup.number?setPubMax(scope.$index):Infinity" v-model="scope.row.actualCount" @change="countEdit(scope.row,scope.$index)" ></el-input-number>
+            <el-input-number :min="0" :max="roundGroup.number?setPubMax(scope.$index):Infinity" v-model="scope.row.expectedCount" @change="countEdit(scope.row,scope.$index)" ></el-input-number>
           </template>
         </el-table-column>
         <el-table-column
@@ -59,13 +57,14 @@
     </div>
     <span slot="footer" class="dialog-footer">
     <el-button @click="setShow = false">取 消</el-button>
-    <el-button type="primary" @click="setShow = false">确 定</el-button>
+    <el-button type="primary" @click="confirm()">确 定</el-button>
   </span>
   </el-dialog>
 </template>
 
 <script>
 import MxClassTreeTranslateMixin from '@/components/Cache/modules/mx-classTree-translate-mixin.js'
+import { saveSettings } from '@/api/webApi/elective/dispatch'
 export default {
   name: 'set-classcount',
   mixins: [MxClassTreeTranslateMixin],
@@ -84,7 +83,7 @@ export default {
         let maxQuantit = this.roundGroup.number
         this.settingContainer.forEach((item, index) => {
           if (index !== data) {
-            allSelect += item.actualCount
+            allSelect += item.expectedCount
           }
         })
         return maxQuantit-allSelect
@@ -93,7 +92,7 @@ export default {
     formatSetting() {
       return this.settingContainer.map(item => {
         return {
-          actualCount: item.actualCount,
+          expectedCount: item.expectedCount,
           classId: item.classId,
           className: this.getClassName(item.classId),
         }
@@ -102,22 +101,23 @@ export default {
   },
   methods: {
     open(roundGroup, settingContainer) {
-      console.log(roundGroup)
-      console.log(settingContainer)
       this.setShow = true
       this.roundGroup = roundGroup
+      this.roundId = roundGroup.roundId
       this.settingContainer = settingContainer.filter(item => item.groupId == roundGroup.groupId)
     },
     countEdit(newVal,index){
-      console.log(newVal)
-      console.log(index)
-      this.settingContainer[index].actualCount = newVal.actualCount
+      this.settingContainer[index].expectedCount = newVal.expectedCount
     },
     confirm() {
-      this.show = false
-      // int groupId; // 组合ID
-      // int classId; // 班级
-    },
+      // 保存settings
+      console.log(this.settingContainer)
+      saveSettings({
+        roundId: this.roundId,
+        settings: this.settingContainer }).then(res => {
+        console.log(res)
+      })
+    }
   }
 }
 </script>

+ 48 - 7
src/views/elective/dispatch/index.vue

@@ -1,24 +1,65 @@
 <template>
   <div class="app-container">
-    <dispatch-table></dispatch-table>
+    <el-card class="box-card" style="margin-bottom: 10px;">
+      <mx-condition ref="condition" :query-params="queryParams" :require-fields="requireFields" @query="handleQuery"
+                    @invalid="handleInvalidQuery"
+      ></mx-condition>
+    </el-card>
+    <dispatch-table :round="round" :settings="settings"></dispatch-table>
   </div>
 </template>
 <script>
 import DispatchTable from "./components/dispatch-table.vue";
+import { getRound,getSettings } from '@/api/webApi/elective/dispatch'
+import MxCondition from '@/components/MxCondition/mx-condition'
+
 export default {
   components: {
     DispatchTable,
-  },
-  created() {
-  },
-  methods: {},
-  computed: {
+    MxCondition
   },
   data() {
     return {
-
+      requireFields: ['year', 'roundId'],
+      queryParams: {
+        year: '',
+        roundId: ''
+      },
+      settings: [],
+      round: { },
     };
   },
+  created() {
+  },
+  methods: {
+    handleQuery() {
+      this.getRound()
+      this.getSettings()
+    },
+    // 获取批次的setting
+    getSettings() {
+      getSettings({
+        roundId:this.queryParams.roundId,
+      }).then(res => {
+        console.log(res)
+        this.settings = res.data
+      })
+    },
+    // 获取批次的组合
+    getRound() {
+      getRound({
+        year:this.queryParams.year,
+        round:this.queryParams.roundId,
+      }).then(res => {
+        this.round = res.data
+        console.log(res)
+      })
+    },
+    handleInvalidQuery() {
+      console.log('query取消')
+      this.round = {}
+    },
+  },
 };
 </script>
 <style scoped>