Bladeren bron

学生、班主任分班发布

shilipojs 2 jaren geleden
bovenliggende
commit
33d894ca26

+ 18 - 5
src/components/MxDialog/DispatchMaster.vue

@@ -1,12 +1,13 @@
 <template>
   <el-dialog
-    title="提示"
+    title="班主任分班"
     :visible.sync="show"
     width="30%"
   >
     <div class="block">
+      <p class="mb10">请设置班主任分配的生效日期</p>
       <el-date-picker
-        v-model="value"
+        v-model="settings.activeDate"
         type="date"
         placeholder="选择日期">
       </el-date-picker>
@@ -18,11 +19,14 @@
   </el-dialog>
 </template>
 <script>
+  import { lockPublishTeachers } from '@/api/webApi/elective/dispatch'
+
   export default {
     data(){
       return {
         show:false,
-        value: ''
+        value: '',
+        settings: {}
       }
     },
     methods: {
@@ -30,8 +34,17 @@
         console.log('dialog---init', this)
       },
       onConfirm() {
-        this.show = false
-        this.success(this.value)
+        this.lock()
+      },
+      lock() {
+        lockPublishTeachers({
+          ...this.settings
+        }).then(res => {
+          this.show = false
+          this.success()
+        }).finally(_ => {
+          this.show = false
+        })
       }
     }
   }

+ 52 - 0
src/components/MxDialog/DispatchStudent.vue

@@ -0,0 +1,52 @@
+<template>
+  <el-dialog
+    title="学生分班"
+    :visible.sync="show"
+    width="30%"
+  >
+    <div class="block">
+      <p class="mb10">请设置学生分班的生效日期</p>
+      <el-date-picker
+        v-model="settings.activeDate"
+        type="date"
+        placeholder="选择日期">
+      </el-date-picker>
+    </div>
+    <span slot="footer" class="dialog-footer">
+       <el-button @click="show = false">取 消</el-button>
+       <el-button type="primary" @click="onConfirm">确 定</el-button>
+     </span>
+  </el-dialog>
+</template>
+<script>
+import { lockPublish } from '@/api/webApi/elective/dispatch'
+
+export default {
+  data(){
+    return {
+      show:false,
+      settings: {}
+    }
+  },
+  methods: {
+    init() {
+      console.log('dialog---init', this)
+    },
+    onConfirm() {
+      this.lock()
+    },
+    lock() {
+      lockPublish({
+        ...this.settings
+      }).then(res => {
+        this.success()
+      }).finally(_ => {
+        this.show = false
+      })
+    }
+  }
+}
+</script>
+<style>
+
+</style>

+ 10 - 2
src/components/MxDialog/index.js

@@ -1,17 +1,24 @@
 import Vue from 'vue';
-import DispatchMaster from './DispatchMaster';  // 引入组件
+import DispatchMaster from './DispatchMaster';  // 班主任分班
+import DispatchStudent from './DispatchStudent';  // 学生分班
 
 const DispatchMasterController = Vue.extend(DispatchMaster);  // 发送班主任分班
+const DispatchStudentController = Vue.extend(DispatchStudent);  // 发送学生分班
 
 let instance;
 
 function initInstance(type) {
   switch (type) {
-    case 'Test':
+    case 'DispatchMaster':
       instance = new DispatchMasterController({
         el: document.createElement('div'),
       })
       break
+    case 'DispatchStudent':
+      instance = new DispatchStudentController({
+        el: document.createElement('div'),
+      })
+      break
   }
   // 标识已被挂载过一次
   instance.constrctType = type
@@ -23,6 +30,7 @@ export default (type,options,callback) => {
     console.log('挂载')
     initInstance(type); // 挂载
   }
+  console.log(1111111)
   Object.assign(instance, options);
   // 实例化后newInstance就是一个对象了,所以data内的数据会
   // 挂载到this下,传入一个对象与之合并

+ 6 - 10
src/views/elective/dispatch/index.vue

@@ -30,7 +30,7 @@ export default {
       loading: false,
       settings: [],
       round: { },
-      publish: {}
+      publishSettings: {}
     };
   },
   computed: {
@@ -55,7 +55,7 @@ export default {
       getPublish({
         roundId: this.queryParams.roundId
       }).then(res => {
-        this.publish = res.data
+        this.publishSettings = res.data
         console.log(res)
       })
     },
@@ -70,14 +70,10 @@ export default {
         return
       }
       // 分班锁定
-      await this.$confirm(`确定要发布分班?`)
-      this.toLockPublish()
-    },
-    toLockPublish() {
-      lockPublish({
-        setting:this.publish
-      }).then(res=> {
-        console.log(res)
+      this.$Dialog('DispatchStudent',{
+        settings: this.publishSettings
+      },(val) => {
+        this.handleQuery()
       })
     },
     // 获取批次的setting

+ 14 - 6
src/views/elective/master/index.vue

@@ -90,6 +90,7 @@ export default {
         year: '',
         roundId: ''
       },
+      settings: {}, // 分班时间配置
       headteacherSettings: null
     }
   },
@@ -108,6 +109,9 @@ export default {
           copy.newHeadteacherCode = setting ? setting.customerCode : ''    // 新班主任code
           return copy
         }) || []
+    },
+    classList() {
+      return this.classTree.find(item => item.year == this.queryParams.year).classList
     }
   },
   methods: {
@@ -115,6 +119,7 @@ export default {
       getPublish({
         roundId: this.queryParams.roundId
       }).then(res => {
+        this.settings = res.data
         console.log(res)
       })
     },
@@ -144,12 +149,15 @@ export default {
       })
     },
     send() {
-      // if (true) {
-      //   this.$message.warning('还有班级未分配新班主任和新班级号')
-      //   return
-      // }
-      this.$Dialog('Test',{},(val) => {
-        console.log('success', val)
+      const headteacherSettings = Object.values(this.headteacherSettings)
+      if (headteacherSettings.length < this.classList.length) {
+        this.$message.warning('还有班级未分配新班主任和新班级号')
+        return
+      }
+      this.$Dialog('DispatchMaster',{
+        settings: this.settings
+      },(val) => {
+        this.handleQuery()
       })
     },
     async cancel(row) {