Browse Source

修改网管课详情 调整优化

lex-xin 4 years ago
parent
commit
8ee86bf6de
1 changed files with 57 additions and 36 deletions
  1. 57 36
      src/views/accompanyManager/accompanys.vue

+ 57 - 36
src/views/accompanyManager/accompanys.vue

@@ -206,14 +206,15 @@
                           type="date"
                           value-format="yyyy-MM-dd"
                           :picker-options="{
-        firstDayOfWeek: 1
-    }"
+                            firstDayOfWeek: 1
+                            }"
                           placeholder="选择日期"></el-date-picker>
         </el-form-item>
         <el-form-item label="开始时间"
-                      prop="startTime">
+                      prop="startTime"
+                      :rules="[{ required: true, message: '请选择开始时间', trigger: 'change' }]">
           <el-time-picker placeholder="起始时间"
-                          v-model="startTime"
+                          v-model="maskForm.startTime"
                           @change="changeStartTime"
                           format='HH:mm'
                           value-format='HH:mm'
@@ -249,7 +250,7 @@
       </el-form>
       <div slot="footer"
            class="dialog-footer">
-        <el-button @click="courseVisible = false">取 消</el-button>
+        <el-button @click="handleClose">取 消</el-button>
         <el-button type="primary"
                    @click="submitResetClass">确 定</el-button>
       </div>
@@ -819,14 +820,15 @@ export default {
       this.teacherVisible = false;
     },
     handleClose () {
-      this.courseVisible = false;
-      this.startTime = "";
-      this.maskForm = {
-        date: "",
-        startTime: "",
-        id: ""
-      };
+      console.log(true)
       this.$refs["maskForm"].resetFields();
+      this.courseVisible = false;
+      // this.startTime = "";
+      // this.maskForm = {
+      //   date: "",
+      //   startTime: "",
+      //   id: ""
+      // };
     },
     expireClose () {
       this.expireVisible = false;
@@ -835,36 +837,55 @@ export default {
     },
     submitResetClass () {
       //   endClassTimeStr: this.maskForm.endTime,
-      if (!this.startTime) {
-        this.$message.error("请填写修改时间");
-        return;
-      }
-      let obj = {
-        startClassTime: dayjs(this.maskForm.date + ' ' + this.startTime).format('YYYY-MM-DD HH:mm:ss'),
-        id: this.maskForm.id,
-        classDate: this.maskForm.date,
-        groupType: 'PRACTICE'
-      };
-      resetCourse(obj).then(res => {
-        if (res.code == 200) {
-          this.$message.success("修改成功");
-          this.courseVisible = false;
-          this.getList();
-        } //else {
-        //     this.$message.error(res.msg)
-        //   }
-      });
+      this.$refs.maskForm.validate(valid => {
+        if(valid) {
+          let obj = {
+            startClassTime: dayjs(this.maskForm.date + ' ' + this.startTime).format('YYYY-MM-DD HH:mm:ss'),
+            id: this.maskForm.id,
+            classDate: this.maskForm.date,
+            groupType: 'PRACTICE'
+          };
+          resetCourse(obj).then(res => {
+            if (res.code == 200) {
+              this.$message.success("修改成功");
+              this.courseVisible = false;
+              this.getList();
+            }
+          });
+        }
+      })
+      // if (!this.startTime) {
+      //   this.$message.error("请填写修改时间");
+      //   return;
+      // }
+      // let obj = {
+      //   startClassTime: dayjs(this.maskForm.date + ' ' + this.startTime).format('YYYY-MM-DD HH:mm:ss'),
+      //   id: this.maskForm.id,
+      //   classDate: this.maskForm.date,
+      //   groupType: 'PRACTICE'
+      // };
+      // resetCourse(obj).then(res => {
+      //   if (res.code == 200) {
+      //     this.$message.success("修改成功");
+      //     this.courseVisible = false;
+      //     this.getList();
+      //   }
+      // });
     },
     resetClass (row) {
       /**
        * maskForm.startTime
        *
        */
-
-      this.maskForm.date = dayjs(row.classDate).format('YYYY-MM-DD');
-      this.startTime = row.startClassTimeStr.substring(0, 5);
-      this.maskForm.endTime = row.endClassTimeStr.substring(0, 5);
-      this.maskForm.id = row.id;
+      this.$nextTick(() => {
+        this.maskForm = {
+          date: dayjs(row.classDate).format('YYYY-MM-DD'),
+          startTime: row.startClassTimeStr.substring(0, 5),
+          endTime: row.endClassTimeStr.substring(0, 5),
+          id: row.id
+        }
+        // this.startTime = row.startClassTimeStr.substring(0, 5);
+      })
       this.coursesExpireDate = row.coursesExpireDate;
       // 修改课时
       this.courseVisible = true;