瀏覽代碼

自动分配班级人数

shilipojs 3 年之前
父節點
當前提交
7a937ada39

+ 1 - 1
src/views/elective/dispatch/components/dispatch-table.vue

@@ -101,7 +101,7 @@ export default {
         roundId: this.round.roundId,
         groupName: rg.name,
         number: this.round.enrollGroupCount[rg.groupId] || 200, // 录取人数
-        classCount: rg.classCount || 5, // 班级数
+        classCount: rg.classCount || 4, // 班级数
         expectedCount: this.settings.filter(item => item.groupId == rg.groupId).map(item => item.expectedCount).toString(),
         groupClass: this.settings
           .filter(item => item.groupId == rg.groupId)

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

@@ -1,6 +1,6 @@
 <template>
     <div>
-      <p style="margin-bottom: 10px;">该组合录取人数为:{{roundGroup.number}}</p>
+      <p style="margin-bottom: 10px;">该组合录取人数为{{roundGroup.number}}</p>
       <el-table
         :data="formatSetting"
         style="width: 100%"
@@ -105,7 +105,19 @@ export default {
       this.roundGroup = roundGroup
       this.settingContainer = settingContainer
       this.roundId = roundGroup.roundId
-      this.settingContainer = settingContainer.filter(item => item.groupId == roundGroup.groupId)
+      const remainder = roundGroup.number % roundGroup.classCount // 余数
+      const divide = Math.floor(roundGroup.number / roundGroup.classCount) // 向下取整的除数
+      this.settingContainer = settingContainer.filter(item => item.groupId == roundGroup.groupId).map((item,index)  => {
+        if (index + 1 <= remainder) {
+          // 余数平分给前面
+          item.expectedCount = divide + 1
+        }else {
+          // 余数分完
+          item.expectedCount = divide
+        }
+        return item
+        console.log(item)
+      })
     },
     valid() {
       // 验证