Browse Source

排课完成

wolyshaw 4 years ago
parent
commit
3463c348b7

+ 146 - 0
src/views/teamDetail/components/modals/classroom-preview.vue

@@ -0,0 +1,146 @@
+<template>
+  <div>
+    <el-form inline>
+      <el-form-item label="主教老师:">{{coreTeacherName}}</el-form-item>
+      <el-form-item label="助教老师:" v-if="assistantName">{{assistantName}}</el-form-item>
+    </el-form>
+    <el-table
+      :header-cell-style="{background:'#EDEEF0',color:'#444'}"
+      :data="typelist"
+    >
+      <el-table-column
+        label="课程类型"
+        prop="name"
+      ></el-table-column>
+      <el-table-column
+        label="课时数"
+        prop="surplus"
+      ></el-table-column>
+      <el-table-column
+        label="总排课时长(分钟)"
+        prop="courseTotalMinuties"
+      ></el-table-column>
+      <el-table-column
+        label="剩余时长(分钟)"
+        prop="surplusTime"
+      ></el-table-column>
+    </el-table>
+    <div style="color: red;font-weight: bold;margin: 20px 0;">确认排课后剩余时长将被系统删除,不可排课</div>
+    <el-table
+      :header-cell-style="{background:'#EDEEF0',color:'#444'}"
+      :data="details"
+      max-height="300px"
+    >
+      <el-table-column
+        label="课程类型"
+        prop="type"
+      >
+        <span slot-scope="scope">{{courseTypeListByName[scope.row.type]}}</span>
+      </el-table-column>
+      <el-table-column
+        label="开始时间"
+        prop="startClassTime"
+      ></el-table-column>
+      <el-table-column
+        label="课程时长(分钟)"
+        key="time"
+      >
+        <span slot-scope="scope">{{getTimers(scope.row)}}</span>
+      </el-table-column>
+    </el-table>
+  </div>
+</template>
+
+<script>
+import { diffTimerFormMinute } from '@/utils/date'
+import dayjs from 'dayjs';
+export default {
+  props: {
+    types: {
+      type: Object,
+      default: {}
+    },
+    details: {
+      type: Array,
+      default: []
+    },
+    courseTypeListByName: {
+      type: Object,
+      default: {}
+    },
+    teacherList: {
+      type: Array,
+      default: []
+    },
+    cooperationList: {
+      type: Array,
+      default: []
+    },
+    coreTeacher: {
+      type: String
+    },
+    assistant: {
+      type: Array,
+      default: []
+    },
+  },
+  computed: {
+    coreTeacherName() {
+      let name = ''
+      for (const item of this.teacherList) {
+        if (this.coreTeacher == item.id) {
+          name = item.realName
+          break
+        }
+      }
+      return name
+    },
+    assistantName() {
+      let names = []
+      for (const item of this.cooperationList) {
+        if (this.assistant.includes(item.id)) {
+          names.push(item.realName)
+        }
+      }
+      return names.join(' ')
+    },
+    typelist() {
+      const list = []
+      for (const key in this.types) {
+        if (Object.hasOwnProperty.call(this.types, key)) {
+          const item = this.types[key];
+          let surplusTime = 0
+          let surplus = 0
+          for (const ke of item.cycle) {
+            surplus += parseFloat(ke.expectCourseNum)
+            surplusTime += (parseFloat(ke.expectCourseNum) * parseFloat(ke.time))
+          }
+          surplusTime = item.courseTotalMinuties - surplusTime
+          list.push({
+            name: this.courseTypeListByName[key],
+            cycles: item.cycle.length,
+            courseTotalMinuties: item.courseTotalMinuties,
+            surplus,
+            surplusTime
+          })
+        }
+      }
+      return list
+    }
+  },
+  mounted() {
+    console.log(this)
+  },
+  methods: {
+    getTimers (item) {
+      const time = diffTimerFormMinute(dayjs(item.classDate).format('YYYY-MM-DD'), dayjs(item.startClassTime).format('HH:mm'), dayjs(item.endClassTime).format('HH:mm'))
+      console.log(time, item)
+      return time
+    }
+  }
+}
+</script>
+
+<style lang="less" scoped>
+
+</style>

+ 15 - 14
src/views/teamDetail/components/modals/classroom-setting-item.vue

@@ -211,7 +211,7 @@
       <el-table-column prop="date" width="50px">
         <template slot-scope="scope">
           <i
-            @click="remove(scope.$index)"
+            @click="remove(scope.$index, scope)"
             v-if="form.cycle.length > 1"
             class="close-icon el-icon-circle-close"
           ></i>
@@ -277,8 +277,15 @@ export default {
     },
   },
   methods: {
+    updateUseTime() {
+      let time = 0
+        for (const item of this.form.cycle) {
+          time += (item.time || 0) * (item.expectCourseNum || 0)
+        }
+
+        this.$emit('setUserTime', time, this.type)
+    },
     create() {
-      console.log(this.surplustime,this.useTime)
       if(this.surplustime<=this.useTime){
         this.$message.error('已排课时长使用完毕,请修改预计课时数')
         return
@@ -288,15 +295,14 @@ export default {
         initVal.time = this.selectPrice;
       }
       this.form.cycle.push(initVal);
+      this.updateUseTime()
     },
 
     remove(index) {
       this.form.cycle.splice(index, 1);
+      this.updateUseTime()
     },
     startTimeChange(item, val) {
-      if(item.$index == 0){
-        this.useTime = 0
-      }
       if (item.row.time && item.row.startClassTime) {
         let str = dayjs(new Date()).format("YYYY-MM-DD");
         this.$set(
@@ -308,11 +314,6 @@ export default {
         this.$set(item.row, "endClassTime", "");
       }
       if (val) {
-        console.log(
-          this.surplustime,
-          this.useTime,
-          parseInt((this.surplustime - this.useTime) / val)
-        );
         this.$set(
           item.row,
           "expectCourseNum",
@@ -335,9 +336,9 @@ export default {
       } else {
         this.$set(item, "endClassTime", "");
       }
+      this.updateUseTime()
     },
     getUseTime(row) {
-      console.log(row)
       if(row){
           this.$set(
           row,
@@ -356,10 +357,10 @@ export default {
           (item.expectCourseNum ? parseInt(item.expectCourseNum) : 0) *
           parseInt(item.time);
       });
-     this.$emit('setUserTime',this.useTime,this.type)
+      this.updateUseTime()
+    //  this.$emit('setUserTime', this.useTime, this.type)
     },
     changeStartDate(val, row) {
-      console.log(val, row);
       if (row.dayOfWeek && val&&row.expectCourseNum) {
         let num;
         let dayjs = this.$helpers.dayjs
@@ -379,7 +380,7 @@ this.$set(
          ''
         );
       }
-
+      this.updateUseTime()
     },
   },
 };

+ 66 - 26
src/views/teamDetail/components/modals/classroom-setting.vue

@@ -116,6 +116,28 @@
         >确 定</el-button
       >
     </div>
+    <el-dialog
+      title="班级预览"
+      :visible.sync="previewVisible"
+      append-to-body
+      width="650px"
+    >
+      <classrome-preview
+        :types="form.classs"
+        :details="previewList"
+        :courseTypeListByName="courseTypeListByName"
+        :teacherList="teacherList"
+        :cooperationList="cooperationList"
+        :coreTeacher="form.coreTeacher"
+        :assistant="form.assistant"
+      />
+      <div slot="footer" class="dialog-footer" v-if="classType != 5">
+        <el-button @click="previewVisible = false">取 消</el-button>
+        <el-button type="primary" @click="submit('confirmGenerate')"
+          >确 定</el-button
+        >
+      </div>
+    </el-dialog>
   </div>
 </template>
 <script>
@@ -132,6 +154,7 @@ import { classTimeList } from "@/utils/searchArray";
 import MusicStore from "@/views/resetTeaming/store";
 import { queryByOrganIdAndCourseType } from "@/views/resetTeaming/api";
 import { isEmpty } from "lodash";
+import classromePreview from './classroom-preview'
 
 const classTimeListByType = {};
 for (const item of classTimeList) {
@@ -177,6 +200,7 @@ export default {
   ],
   components: {
     courseItem,
+    'classrome-preview': classromePreview
   },
   data() {
     return {
@@ -193,6 +217,8 @@ export default {
       classTimeListByType,
       musicCourseSettings: {},
       musicSurplus: {},
+      previewVisible: false,
+      previewList: [],
     };
   },
   watch: {
@@ -318,14 +344,20 @@ export default {
       }
       this.$set(this.form, "classs", clas);
     },
-    submit() {
+    submit(type) {
+      // for (const key in this.musicCourseSettings) {
+      //   if (Object.hasOwnProperty.call(this.musicCourseSettings, key)) {
+      //     const item = this.musicCourseSettings[key];
+
+      //   }
+      // }
       this.$refs.form.validate(async (valid) => {
         if (valid) {
           const list = [];
           for (const key in this.form.classs) {
             if (this.form.classs.hasOwnProperty(key)) {
               const item = this.form.classs[key];
-              list.push({
+              const data = {
                 type: this.detail ? undefined : this.activeType,
                 courseType: key,
                 classGroupName:
@@ -352,30 +384,33 @@ export default {
                   endDate:_.endDate,
                   expectCourseNum:_.expectCourseNum
                 })),
-              });
+              }
+              if (type && typeof type === 'string') {
+                data[type] = true
+              }
+              list.push(data);
             }
           }
           try {
             if (this.detail) {
               let result = await classGroupUpdate(list);
-              if (result.code == 206) {
-                this.$confirm(`当前课程课酬预计为0,是否继续`, "提示", {
-                  confirmButtonText: "确定",
-                  cancelButtonText: "取消",
+              this.previewVisible = false
+              if (result.code == 207) {
+                await this.$confirm((result.msg || `当前课程课酬预计为0,是否继续`), "提示", {
                   type: "warning",
                 })
-                  .then(async () => {
-                    // obj.allowZeroSalary = true;
-                    list.forEach((item) => {
-                      item.allowZeroSalary = true;
-                    });
-                    await classGroupUpdate(list);
-                    this.$listeners.submited();
-                    this.$listeners.close();
-                  })
-                  .catch(() => {
-                    return;
-                  });
+                // obj.allowZeroSalary = true;
+                list.forEach((item) => {
+                  item.allowZeroSalary = true;
+                });
+                await classGroupUpdate(list);
+                this.$listeners.submited();
+                this.$listeners.close();
+                return;
+              }
+              if (result.code == 206) {
+                this.previewVisible = true
+                this.previewList = result.data
                 return;
               }
               this.$message.success("排课修改成功");
@@ -422,9 +457,13 @@ export default {
       this.collapses = val;
     },
     changecoreTeacher(val) {},
+    updateMusicSurplus() {
+
+    },
     setUserTime(time, type) {
-      this.$set(this.musicSurplus,type,time)
-       console.log(this.musicSurplus[type],1)
+      console.log(time, type)
+      this.$set(this.musicSurplus, type, (time || 0))
+      console.log(this.musicSurplus)
        this.$forceUpdate()
       // this.$nextTick(res=>{
       //   this.musicSurplus[type] = time;
@@ -432,11 +471,12 @@ export default {
       // })
 
     },
-  },watch:{
-    musicSurplus(){
-      deep
-    }
-  }
+  },
+  // watch:{
+  //   musicSurplus(){
+  //     deep
+  //   }
+  // }
 };
 </script>
 <style lang="less" scoped>