mo 5 years ago
parent
commit
7ac1316973
1 changed files with 286 additions and 5 deletions
  1. 286 5
      src/views/teacherManager/teacherDetail/components/calendarList.vue

+ 286 - 5
src/views/teacherManager/teacherDetail/components/calendarList.vue

@@ -1,7 +1,6 @@
 <template>
   <div class="m-container">
     <el-calendar style="minWidth:810px">
-      <!-- 这里使用的是 2.5 slot 语法,对于新项目请使用 2.6 slot 语法-->
       <template slot="dateCell"
                 slot-scope="scope">
         <div @click="showDate(scope)">
@@ -121,18 +120,139 @@
     </div>
 
     <!-- 乐团调整 -->
+    <el-dialog title="课程调整"
+               width="400px"
+               :visible.sync="musicVisible">
+      <el-form :model="musicForm"
+               ref="musicFormref"
+               :rules="musicRules"
+               label-position="right"
+               label-width="80px;">
+        <el-form-item label="指导老师"
+                      prop="teacher">
+          <el-select v-model.trim="musicForm.teacher"
+                     style="width:220px!important"
+                     clearable
+                     filterable>
+            <el-option v-for="(item,index) in teacherList"
+                       :key="index"
+                       :value="item.id"
+                       :label="item.realName"></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="上课日期"
+                      prop="date">
+          <el-date-picker v-model.trim="musicForm.date"
+                          type="date"
+                          :picker-options="{
+                            firstDayOfWeek:1
+                          }"
+                          value-format="yyyy-MM-dd"
+                          placeholder="选择日期"></el-date-picker>
+        </el-form-item>
+        <el-form-item label="开始时间"
+                      prop="startTime">
+          <el-time-select placeholder="起始时间"
+                          v-model.trim="startCourseTime"
+                          @change="changeStartTime"
+                          :picker-options="{
+                            start: '04:30',
+                            step: '00:05',
+                            end: '23:30'
+                            }"></el-time-select>
+        </el-form-item>
+        <el-form-item label="结束时间"
+                      prop="endTime">
+          <el-time-select placeholder="结束时间"
+                          v-model.trim="endCourseTime"
+                          :picker-options="{
+                            start: '04:30',
+                            step: '00:05',
+                            end: '23:30',
+                            minTime: startCourseTime
+                          }"></el-time-select>
+        </el-form-item>
+      </el-form>
+      <div slot="footer"
+           class="dialog-footer">
+        <el-button @click="musicVisible = false">取 消</el-button>
+        <el-button type="primary"
+                   @click="submitResetClass">确 定</el-button>
+      </div>
+    </el-dialog>
+    <!-- vip调整 -->
+    <el-dialog title="课程调整"
+               width="400px"
+               :visible.sync="vipVisible">
+      <el-form :model="vipForm"
+               ref="vipForm"
+               :rules="vipRules"
+               label-position="right"
+               label-width="80px;"
+               :inline="true">
+        <el-form-item label="上课日期"
+                      prop="date">
+          <el-date-picker v-model.trim="vipForm.date"
+                          style="width:200px!important;"
+                          type="date"
+                          :picker-options="{
+                              firstDayOfWeek:1
+                            }"
+                          value-format="yyyy-MM-dd"
+                          placeholder="选择日期"></el-date-picker>
+        </el-form-item>
+        <el-form-item label="开始时间"
+                      prop="startCourseTime">
+          <el-time-select placeholder="起始时间"
+                          style="width:200px!important;"
+                          v-model.trim="startCourseTime"
+                          :picker-options="{
+                            start: '04:30',
+                            step: '00:05',
+                            end: '23:30'
+                            }"></el-time-select>
+        </el-form-item>
+        <el-form-item label="课程类型"
+                      prop="courseType">
+          <el-select clearable
+                     v-model.trim="vipForm.teachMode">
+            <el-option label="线上课"
+                       value="ONLINE"></el-option>
+            <el-option label="线下课"
+                       value="OFFLINE"></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="教学地点"
+                      v-if="vipForm.teachMode == 'OFFLINE'">
+          <el-select v-model.trim="vipForm.schoolId"
+                     filterable
+                     clearable>
+            <el-option v-for="(item,index) in schoolList"
+                       :key="index"
+                       :value="item.id"
+                       :label="item.name"></el-option>
+          </el-select>
+        </el-form-item>
+      </el-form>
+      <div slot="footer"
+           class="dialog-footer">
+        <el-button @click="vipVisible = false">取 消</el-button>
+        <el-button type="primary"
+                   @click="submitResetVipClass">确 定</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 <script>
-import { superFindCourseSchedules, getTeacher } from "@/api/buildTeam";
+import { superFindCourseSchedules, getTeacher, resetCourse } from "@/api/buildTeam";
 import { setDate, getCurrentMonthFirst, getCurrentMonthLast } from "@/utils/date"
+import { getTeachSchool } from "@/api/teacherManager";
 import pagination from "@/components/Pagination/index";
 import { permission } from "@/utils/directivePage";
 export default {
   components: { pagination },
   data () {
     return {
-
       dataList: [],
       value: new Date(),
       teacherIdList: '',
@@ -140,6 +260,8 @@ export default {
       teamList: [],
       newList: [],
       tableList: [],
+      teacherList: [],
+      schoolList: [],
       startTime: '',
       endTime: '',
       rules: {
@@ -151,8 +273,41 @@ export default {
       },
       musicVisible: false,
       vipVisible: false,
-      practiceVisible: false
+      practiceVisible: false,
+      musicForm: {
+        teacher: "",
+        assistant: "",
+        date: "",
+        id: "",
+        startTime: "",
+        endTime: "",
+        type: "",
+      },
+      musicRules: {
+        teacher: [
+          { required: true, message: "请选择主教老师名称", trigger: "blur" }
+        ],
+        date: [{ required: true, message: "请选择上课时间", trigger: "blur" }],
+      },
+      vipForm: {
+        date: "",
+        id: "",
+        address: "",
+        teachMode: ""
+      },
+      vipRules: {
+        date: [{ required: true, message: "请选择上课时间", trigger: "blur" }],
 
+      },
+      startCourseTime: '',
+      endCourseTime: '',
+      practiceForm: {},
+      pickerOptions: {
+        firstDayOfWeek: 1,
+        disabledDate (time) {
+          return time.getTime() + 86400000 <= new Date().getTime();
+        }
+      },
     }
   },
   mounted () {
@@ -162,6 +317,13 @@ export default {
         this.teacherList = res.data;
       }
     });
+    getTeachSchool({
+      userId: this.teacherIdList
+    }).then(res => {
+      if (res.code == 200) {
+        this.schoolList = res.data;
+      }
+    })
     this.$nextTick(() => {
       // 点击上个月
       let prevBtn1 = document.querySelector('.el-calendar__button-group .el-button-group>button:nth-child(1)');
@@ -232,6 +394,7 @@ export default {
     showDate (scope) {
       this.startTime = scope.data.day
       this.endTime = scope.data.day
+      this.value = scope.data.day
       this.getList()
     },
     reduceArray (array, str) {
@@ -252,12 +415,130 @@ export default {
       return permission(str, parent);
     },
     resetClass (row) {
-      console.log(row.groupType)
+      console.log(row)
+      switch (row.groupType) {
+        case 'MUSIC': {
+          this.$nextTick(() => {
+            this.musicForm.teacher = parseInt(row.actualTeacherId);
+            this.musicForm.date = row.classDate;
+            this.startCourseTime = row.startClassTime.split(' ')[1].substring(0, 5);
+            this.endCourseTime = row.endClassTime.split(' ')[1].substring(0, 5);
+            this.musicForm.id = row.id;
+            this.musicVisible = true;
+          })
+          break
+        }
+        case 'VIP': {
+          this.$nextTick(() => {
+            this.vipForm.date = row.classDate;
+            this.vipForm.id = row.id;
+            this.vipForm.teachMode = row.teachMode
+            this.vipForm.schoolId = row.schoolId
+            this.startCourseTime = row.startClassTime.split(' ')[1].substring(0, 5);
+            this.vipVisible = true;
+          })
+          break
+        }
+      }
+
+    },
+    changeStartTime () {
+      this.endTime = '';
+    },
+    submitResetClass () {
+      if (!this.startCourseTime || !this.endCourseTime) {
+        this.$message.error("请填写开始时间或结束时间");
+        return;
+      }
+      this.$refs['musicFormref'].validate(res => {
+        if (res) {
+          let obj = {
+            actualTeacherId: this.musicForm.teacher,
+            startClassTimeStr: this.startCourseTime,
+            endClassTimeStr: this.endCourseTime,
+            id: this.musicForm.id,
+            classDate: this.musicForm.date,
+          };
+          resetCourse(obj).then(res => {
+            if (res.code == 200) {
+              this.$message.success("修改成功");
+              this.setCourseList(this.value)
+              this.musicVisible = false;
+            }
+          });
+        }
+      })
+    },
+    submitResetVipClass () {
+      if (!this.startTime) {
+        this.$message.error("请填写修改时间");
+        return;
+      }
+      let classTime = this.vipForm.date
+        ? new Date(this.vipForm.date)
+        : new Date();
+      let ymd =
+        classTime.getFullYear() +
+        "-" +
+        (classTime.getMonth() + 1) +
+        "-" +
+        classTime.getDate();
+      let tempStartTime = this.startCourseTime
+      if (this.startCourseTime.length <= 5) {
+        tempStartTime = tempStartTime + ":00";
+      }
+      let obj = {
+        startClassTime: ymd + " " + tempStartTime,
+        // startClassTimeStr: this.startTime,
+        id: this.vipForm.id,
+        classDate: this.vipForm.date,
+        schoolId: this.vipForm.address || null,
+        teachMode: this.vipForm.teachMode || null
+      };
+      resetCourse(obj).then(res => {
+        if (res.code == 200) {
+          this.$message.success("修改成功");
+          this.vipVisible = false;
+          this.setCourseList(this.value)
+        } //else {
+        //   this.$message.error(res.msg)
+        // }
+      });
+    }
+  },
+  watch: {
+    musicVisible (val) {
+      if (!val) {
+        this.musicForm = {
+          teacher: "",
+          assistant: "",
+          date: "",
+          id: "",
+          type: "",
+        }
+        this.startCourseTime = ""
+        this.endCourseTime = ""
+        this.$refs['musicFormref'].resetFields()
+      }
+    },
+    vipVisible (val) {
+      if (!val) {
+        this.startCourseTime = ""
+        this.vipForm = {
+          date: "",
+          id: "",
+          schoolId: "",
+          teachMode: ""
+        }
+      }
     }
   }
 }
 </script>
 <style lang="scss" scoped>
+// /deep/.el-input__inner {
+//   width: 220px !important;
+// }
 /deep/ .el-calendar-day {
   box-sizing: border-box;
   height: 80px !important;