Browse Source

Merge branch '20200710_pc_vue_new_branch' of http://git.shengws.com/csx/Vue_New into 20200710_pc_vue_new_branch

See999 4 years ago
parent
commit
1402821c1e
1 changed files with 137 additions and 6 deletions
  1. 137 6
      src/xt_pages/medicalScheduling/class.vue

+ 137 - 6
src/xt_pages/medicalScheduling/class.vue View File

69
             >
69
             >
70
              <el-form :model="form" :rules="rules" ref="form" label-width="90px">
70
              <el-form :model="form" :rules="rules" ref="form" label-width="90px">
71
                 <el-form-item label="班种名称 : " required prop="class_name">
71
                 <el-form-item label="班种名称 : " required prop="class_name">
72
-                    <el-input v-model="form.class_name" placeholder="" ></el-input>
72
+                    <el-input v-model.trim="form.class_name" placeholder="" ></el-input>
73
                 </el-form-item>
73
                 </el-form-item>
74
                 <el-form-item label="班种属性 : " required  prop="class_attributes">
74
                 <el-form-item label="班种属性 : " required  prop="class_attributes">
75
                     <el-select v-model="form.class_attributes" placeholder="请选择">
75
                     <el-select v-model="form.class_attributes" placeholder="请选择">
102
                         </el-option>
102
                         </el-option>
103
                     </el-select>
103
                     </el-select>
104
                     <el-time-select
104
                     <el-time-select
105
+                    @change="changtimeTwo"
105
                     style="width:140px;"
106
                     style="width:140px;"
106
                     v-model="form.timeone_end"
107
                     v-model="form.timeone_end"
107
                     :picker-options="{
108
                     :picker-options="{
121
                     style="width:140px;"
122
                     style="width:140px;"
122
                     v-model="form.timetwo_start"
123
                     v-model="form.timetwo_start"
123
                     :picker-options="{
124
                     :picker-options="{
124
-                    start: '08:00',
125
+                    start: '01:00',
125
                     step: '00:15',
126
                     step: '00:15',
126
                     end: '24:00'
127
                     end: '24:00'
127
                     }"
128
                     }"
136
                         </el-option>
137
                         </el-option>
137
                     </el-select>
138
                     </el-select>
138
                     <el-time-select
139
                     <el-time-select
140
+                    @change="changtime"
139
                     style="width:140px;"
141
                     style="width:140px;"
140
                     v-model="form.timetwo_end"
142
                     v-model="form.timetwo_end"
141
                     :picker-options="{
143
                     :picker-options="{
142
-                    start: '08:00',
144
+                    start: '01:00',
143
                     step: '00:15',
145
                     step: '00:15',
144
                     end: '24:00'
146
                     end: '24:00'
145
                     }"
147
                     }"
206
                         </el-option>
208
                         </el-option>
207
                     </el-select>
209
                     </el-select>
208
                     <el-time-select
210
                     <el-time-select
211
+                    @change="changtime"
209
                     style="width:140px;"
212
                     style="width:140px;"
210
                     v-model="form.timeone_end"
213
                     v-model="form.timeone_end"
211
                     :picker-options="{
214
                     :picker-options="{
240
                         </el-option>
243
                         </el-option>
241
                     </el-select>
244
                     </el-select>
242
                     <el-time-select
245
                     <el-time-select
246
+                    @change="changtimeTwo"
243
                     style="width:140px;"
247
                     style="width:140px;"
244
                     v-model="form.timetwo_end"
248
                     v-model="form.timetwo_end"
245
                     :picker-options="{
249
                     :picker-options="{
276
 <script>
280
 <script>
277
 import {saveDoctorSchedules,getDoctorScheduleList,getScheduleDetail,UpdateSchedule,deleteScheduleById } from '@/api/doctorSchedule'
281
 import {saveDoctorSchedules,getDoctorScheduleList,getScheduleDetail,UpdateSchedule,deleteScheduleById } from '@/api/doctorSchedule'
278
 import BreadCrumb from '@/xt_pages/components/bread-crumb'
282
 import BreadCrumb from '@/xt_pages/components/bread-crumb'
283
+import { parseTime } from '@/utils'
279
 export default {
284
 export default {
280
     components:{
285
     components:{
281
         BreadCrumb
286
         BreadCrumb
331
                      this.showError = true
336
                      this.showError = true
332
                      return false
337
                      return false
333
                  }
338
                  }
339
+                 
334
                  const params = {
340
                  const params = {
335
                     class_name:this.form.class_name,
341
                     class_name:this.form.class_name,
336
                     class_attributes:this.form.class_attributes,
342
                     class_attributes:this.form.class_attributes,
343
                     work_time:this.form.work_time,
349
                     work_time:this.form.work_time,
344
                     remarks:this.form.remarks
350
                     remarks:this.form.remarks
345
                  }
351
                  }
346
-                 console.log("params",params)
347
                 saveDoctorSchedules(params).then(response=>{
352
                 saveDoctorSchedules(params).then(response=>{
348
                   if(response.data.state == 1){
353
                   if(response.data.state == 1){
349
                     var schedules = response.data.data.schedules
354
                     var schedules = response.data.data.schedules
360
                     this.form.timetwo_end=""
365
                     this.form.timetwo_end=""
361
                     this.form.work_time = ""
366
                     this.form.work_time = ""
362
                     this.form.remarks = ""
367
                     this.form.remarks = ""
368
+                  }else{
369
+                     this.$message.error("班种名称已存在")
363
                   }
370
                   }
364
                })
371
                })
365
              }
372
              }
479
                  this.$message.success("修改成功")
486
                  this.$message.success("修改成功")
480
                  this.EditNewVisible = false
487
                  this.EditNewVisible = false
481
                  this.getList()
488
                  this.getList()
482
-                 
489
+               }else{
490
+                   this.$message.error("班种名称已存在")
483
                }
491
                }
484
              })
492
              })
485
           }
493
           }
501
                 var msg = response.data.data.msg
509
                 var msg = response.data.data.msg
502
                 this.$message.success("删除成功")
510
                 this.$message.success("删除成功")
503
                 this.getList()
511
                 this.getList()
512
+              }else{
513
+                this.$message.error("该班种已存在排班,不能删除")
504
               }
514
               }
505
            }) 
515
            }) 
506
         })
516
         })
507
-      }
517
+      },
518
+     timeDifference(startTime,endTime){ 
519
+        var start1=startTime.split(":");
520
+        var startAll=parseInt(start1[0]*60)+parseInt(start1[1]);   
521
+        var end1=endTime.split(":");
522
+        var endAll=parseInt(end1[0]*60)+parseInt(end1[1]);
523
+         return endAll - startAll
524
+      },
525
+      timeStamp(StatusMinute){	
526
+        var day=parseInt(StatusMinute/60/24);
527
+        var hour=parseInt(StatusMinute/60%24);
528
+        var min= parseInt(StatusMinute % 60);
529
+        StatusMinute="";
530
+        if (day > 0)
531
+        {
532
+            StatusMinute= day + "天";
533
+        } 
534
+        if (hour>0)
535
+        {
536
+            StatusMinute += hour + "小时";
537
+        } 
538
+        // if(hour == 0){
539
+        //    StatusMinute += hour + "小时"
540
+        // }
541
+        if (min>0)
542
+        {
543
+            StatusMinute += parseFloat(min) + "分钟";
544
+        }
545
+            return StatusMinute;
546
+        },
547
+     changtime(){
548
+         //计算时长
549
+        console.log("timeone",this.form.timeone_start)
550
+        console.log("timeonend",this.form.timeone_end)
551
+        console.log("timeonetype",this.form.timeone_type)
552
+        var longtime = 0
553
+        var timeone = 0
554
+        var timetwo = 0
555
+        //时间选择1的时间差
556
+       if(this.form.timeone_type == 1){
557
+          var timeone = this.timeDifference(this.form.timeone_start,this.form.timeone_end)
558
+           timeone = timeone
559
+       }
560
+       if(this.form.timeone_type == 2){
561
+          var hour = this.form.timeone_end.split(":")
562
+          var hous = parseInt(hour[0]) + 24
563
+          var oneHours = hous.toString() +":"+ hour[1]
564
+          var timeone =  this.timeDifference(this.form.timeone_start,oneHours)
565
+         timeone = timeone
566
+        }
567
+       console.log("时间选择1时长",this.timeStamp(timeone))
568
+                
569
+        //时间选择2的时间差
570
+        if(this.form.timetwo_type == 1){
571
+            var timetwo = this.timeDifference(this.form.timetwo_start,this.form.timetwo_end)
572
+            timetwo = timetwo
573
+        }
574
+        if(this.form.timetwo_type == 2){
575
+            var hour = this.form.timetwo_end.split(":")
576
+            var hous = parseInt(hour[0]) + 24
577
+            var oneHours = hous.toString() +":"+ hour[1]
578
+            var timetwo =  this.timeDifference(this.form.timetwo_start,oneHours)
579
+            timetwo = timetwo
580
+        }
581
+          console.log("timetwo",timetwo)
582
+          console.log("时间选择2时长",this,this.timeStamp(timetwo))
583
+                  
584
+        longtime = timeone + timetwo
585
+        console.log("longtime",longtime)
586
+        this.form.work_time = this.timeStamp(longtime)
587
+     },
588
+     changtimeTwo(){
589
+           //计算时长
590
+        console.log("timeone",this.form.timeone_start)
591
+        console.log("timeonend",this.form.timeone_end)
592
+        console.log("timeonetype",this.form.timeone_type)
593
+        var longtime = 0
594
+        var timeone = 0
595
+        var timetwo = 0
596
+        //时间选择1的时间差
597
+       if(this.form.timeone_type == 1){
598
+          var timeone = this.timeDifference(this.form.timeone_start,this.form.timeone_end)
599
+           timeone = timeone
600
+       }
601
+       if(this.form.timeone_type == 2){
602
+          var hour = this.form.timeone_end.split(":")
603
+          var hous = parseInt(hour[0]) + 24
604
+          var oneHours = hous.toString() +":"+ hour[1]
605
+          var timeone =  this.timeDifference(this.form.timeone_start,oneHours)
606
+         timeone = timeone
607
+        }
608
+       console.log("时间选择1时长",this.timeStamp(timeone))
609
+                
610
+        //时间选择2的时间差
611
+        if(this.form.timetwo_type == 1){
612
+            var timetwo = this.timeDifference(this.form.timetwo_start,this.form.timetwo_end)
613
+            timetwo = timetwo
614
+        }
615
+        if(this.form.timetwo_type == 2){
616
+            var hour = this.form.timetwo_end.split(":")
617
+            var hous = parseInt(hour[0]) + 24
618
+            var oneHours = hous.toString() +":"+ hour[1]
619
+            var timetwo =  this.timeDifference(this.form.timetwo_start,oneHours)
620
+            timetwo = timetwo
621
+        }
622
+          console.log("timetwo",timetwo)
623
+          console.log("时间选择2时长",this,this.timeStamp(timetwo))
624
+                  
625
+        longtime = timeone + timetwo
626
+        console.log("longtime",longtime)
627
+        this.form.work_time = this.timeStamp(longtime) 
628
+     }
508
     },
629
     },
509
     created(){
630
     created(){
510
         //获取班种列表
631
         //获取班种列表
511
         this.getList()
632
         this.getList()
633
+    },
634
+    watch: {
635
+    //  监听对象数据变化
636
+    work_time: {
637
+      handler(newVal, oldVal) {
638
+        console.log(newVal)
639
+        console,log(oldVal)
640
+      },
641
+      deep: true  // 非常非常重要,这个是深度监听,默认是false。true的时候才能监听到对象的变化
512
     }
642
     }
643
+   }
513
 }
644
 }
514
 </script>
645
 </script>
515
 <style scoped>
646
 <style scoped>