Browse Source

分班模拟,设定人数

shilipojs 3 years ago
parent
commit
eb35138115

+ 4 - 5
src/views/elective/dispatch/components/choose-class.vue

@@ -2,6 +2,7 @@
   <el-dialog
     :title="`选择班级(${roundGroup.groupName})`"
     :visible.sync="show"
+    :close-on-click-modal="false"
     width="50%"
   >
     <div>
@@ -27,12 +28,9 @@
             >
             </el-input>
           </el-tooltip>
-
-
           <div class="size-icon" @click="handleInputConfirm">
             <i class="icon el-icon-circle-close" ></i>
           </div>
-
         </el-form-item>
       </el-form>
 
@@ -76,7 +74,6 @@ export default {
   computed: {
     classList() {
       if (!this.classTree?.length) return []
-
       return this.classTree[0].classList.map(item => {
         item['disabled'] = this.settingContainer.some(c => c.classId == item.classId && c.groupId !== this.roundGroup.groupId)
         return item
@@ -110,6 +107,7 @@ export default {
           actualCountInFemale: 0
         }
       })
+      console.log(mergeClasses)
       this.tmpClasses.forEach(c => this.settingContainer.remove(c))
       mergeClasses.forEach(c => this.settingContainer.push(c))
       this.handleInputConfirm()
@@ -142,7 +140,8 @@ export default {
       saveClass(this.form).then(res => {
         this.form.name = ''
         this.msgSuccess('保存成功')
-        this.$store.dispatch('GetInfo') // 借机清除了用户缓存
+        this.getClassTreeByCache(false)
+        // this.$store.dispatch('GetInfo') // 借机清除了用户缓存
       }).finally()
     },
     refreshClassTree() {

+ 47 - 16
src/views/elective/dispatch/components/dispatch-table.vue

@@ -1,6 +1,20 @@
 <template>
   <el-row>
     <mx-table :propDefines="propDefines" :rows="displayRows">
+      <template #classCount="{row,$index}">
+        <el-input-number v-model="row.classCount" @change="classCountChange(row,$index)" :min="0" :disabled="row.classCount != 0" label="label"></el-input-number>
+      </template>
+      <!-- 人数设定 -->
+      <template #countEdit="{row}">
+        <el-button
+          type="success"
+          plain
+          icon="el-icon-edit"
+          size="mini"
+          @click="countEdit(row)"
+        >设定
+        </el-button>
+      </template>
       <template #edit="{row}">
         <el-button
           type="success"
@@ -12,17 +26,21 @@
         </el-button>
       </template>
     </mx-table>
-    <choose-class ref="dialog"></choose-class>
+    <choose-class ref="editClassDialog"></choose-class>
+    <set-classcount ref="setClassDialog"></set-classcount>
   </el-row>
 </template>
 <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 SetClasscount from './set-classcount'
 export default {
   components: {
-    ChooseClass
+    ChooseClass,
+    SetClasscount
   },
   mixins: [MxClassTreeTranslateMixin, MxSelectTranslateMixin],
   props: {
@@ -40,10 +58,11 @@ export default {
           label: '组合'
         },
         number: {
-          label: '人数'
+          label: '组合人数'
         },
         classCount: {
-          label: '班级数'
+          label: '班级数',
+          slot: 'classCount'
         },
         edit: {
           label: '分班编辑',
@@ -51,7 +70,14 @@ export default {
         },
         groupClass: {
           label: '班级名称',
-        }
+        },
+        countEdit: {
+          label: '人数设定',
+          slot:  'countEdit'
+        },
+        actualCount: {
+          label: '人数',
+        },
       }
     }
   },
@@ -71,6 +97,7 @@ export default {
         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
           .filter(item => item.groupId == rg.groupId)
           .map(item => this.getClassName(item.classId)).toString(),
@@ -83,26 +110,30 @@ export default {
     this.loadRoundStatus()
   },
   methods: {
+    countEdit(row) {
+      // 设定人数
+      const filter = this.settingList.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
     },
+    classCountChange(newVal,index) {
+      console.log(newVal)
+      console.log(index)
+      this.round.roundGroups[index] = newVal
+    },
     edit(row) {
       if (!row.classCount) {
         this.$message.warning('班级数为0时不可分班')
         return
       }
-      this.$refs.dialog.open(row,this.settingList)
-    },
-
-    confirm(list) {
-      this.round.roundGroups.filter(item => {
-        if(list.groupId == item.groupId) {
-           item.groupClass = list.groupClass
-        }
-      })
-      console.log(this.displayRows)
-      console.log(list)
+      this.$refs.editClassDialog.open(row,this.settingList)
     }
   }
 }

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

@@ -0,0 +1,120 @@
+<template>
+  <el-dialog
+    title="设定人数"
+    :visible.sync="setShow"
+    :close-on-click-modal="false"
+    width="50%"
+  >
+    <div>
+      <p style="margin-bottom: 10px;">组合人数为:{{roundGroup.number}}</p>
+      <el-table
+        :data="formatSetting"
+        style="width: 100%"
+      >
+        <el-table-column
+          prop="className"
+          label="组合"
+          width="180"
+        >
+          <template>
+            {{roundGroup.groupName}}
+          </template>
+        </el-table-column>
+        <el-table-column
+          prop="className"
+          label="班级名称"
+          width="180"
+        >
+        </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>
+          </template>
+        </el-table-column>
+        <el-table-column
+          label="操作"
+        >
+          <template slot-scope="scope">
+            <el-switch
+              v-model="scope.row.active"
+              active-color=""
+              active-text="按排名"
+              inactive-text="随机"
+              inactive-color="#ff4949"
+            >
+            </el-switch>
+          </template>
+        </el-table-column>
+      </el-table>
+    </div>
+    <span slot="footer" class="dialog-footer">
+    <el-button @click="setShow = false">取 消</el-button>
+    <el-button type="primary" @click="setShow = false">确 定</el-button>
+  </span>
+  </el-dialog>
+</template>
+
+<script>
+import MxClassTreeTranslateMixin from '@/components/Cache/modules/mx-classTree-translate-mixin.js'
+export default {
+  name: 'set-classcount',
+  mixins: [MxClassTreeTranslateMixin],
+  data() {
+    return {
+      setShow: false,
+      settingContainer: [],
+      roundGroup: {}
+    }
+  },
+  computed: {
+    // input-number设置公用max
+    setPubMax() {
+      return (data) => {
+        let allSelect = 0
+        let maxQuantit = this.roundGroup.number
+        this.settingContainer.forEach((item, index) => {
+          if (index !== data) {
+            allSelect += item.actualCount
+          }
+        })
+        return maxQuantit-allSelect
+      }
+    },
+    formatSetting() {
+      return this.settingContainer.map(item => {
+        return {
+          actualCount: item.actualCount,
+          classId: item.classId,
+          className: this.getClassName(item.classId),
+        }
+      })
+    },
+  },
+  methods: {
+    open(roundGroup, settingContainer) {
+      console.log(roundGroup)
+      console.log(settingContainer)
+      this.setShow = true
+      this.roundGroup = roundGroup
+      this.settingContainer = settingContainer.filter(item => item.groupId == roundGroup.groupId)
+    },
+    countEdit(newVal,index){
+      console.log(newVal)
+      console.log(index)
+      this.settingContainer[index].actualCount = newVal.actualCount
+    },
+    confirm() {
+      this.show = false
+      // int groupId; // 组合ID
+      // int classId; // 班级
+    },
+  }
+}
+</script>
+
+<style scoped>
+
+</style>