浏览代码

预约建单时间的选择时间进行优化

seimin 3 年之前
父节点
当前提交
645a551cc7

+ 12 - 12
src/app/views/hushijiandan/hushijiandan.component.html

@@ -732,7 +732,7 @@
732 732
           </nz-form-item>
733 733
           <!-- 检查 -->
734 734
           <nz-form-item *ngIf="checkedShowMsg.status==200">
735
-            <nz-form-label [nzSm]="6" [nzXs]="24" nzFor="linkCheck">关联的检查</nz-form-label>
735
+            <nz-form-label [nzSm]="24" [nzXs]="24" nzFor="linkCheck">关联的检查</nz-form-label>
736 736
             <nz-form-control class="datesGroup" *ngIf="linkCheckLis.length">
737 737
               <nz-checkbox-group class="linkCheckCheck" formControlName="linkCheck" [(ngModel)]="linkCheckLis"
738 738
                 (ngModelChange)="linkCheckLisChange()">
@@ -740,16 +740,16 @@
740 740
             </nz-form-control>
741 741
             <div *ngIf="!linkCheckLis.length">暂无关联的检查</div>
742 742
           </nz-form-item>
743
-          <!-- 预约时间-患者其他服务 -->
743
+          <!-- 预约建单时间-患者其他服务 -->
744 744
           <nz-form-item class="yyTime" [ngClass]="{yyTimeError:!yyTimeZy&&clickYYZyFlag}"
745 745
             *ngIf="appointmentZyBuildFlag === '1'&&allowUrgent==0">
746 746
             <nz-form-label [nzSm]="24" [nzXs]="24">预约建单时间</nz-form-label>
747 747
             <nz-form-control [nzSm]="24" [nzXs]="24">
748
-              <nz-date-picker [nzShowToday]="false" nzFormat="yyyy-MM-dd HH:mm"
749
-                (nzOnOpenChange)="openYYTime($event,'parent-zy')" [nzDisabledDate]="disabledYYDate"
750
-                [nzDisabledTime]="disabledYYTime" [nzShowTime]="{nzDefaultOpenValue: timeDefaultValue}"
751
-                [ngModel]="yyTimeZy" (ngModelChange)="yyTimeZyChange($event)" [ngModelOptions]="{standalone: true}">
752
-              </nz-date-picker>
748
+              <nz-time-picker nzFormat="HH:mm" [nzMinuteStep]="30" [nzSecondStep]="60" [(ngModel)]="yyTimeZy"
749
+                (ngModelChange)="yyTimeZyChange($event)" [ngModelOptions]="{standalone: true}"
750
+                [nzDisabledHours]="disabledHours" [nzDisabledMinutes]="disabledMinutes"></nz-time-picker>
751
+              <label nz-checkbox [(ngModel)]="nextDayZy" (ngModelChange)="nextDayZyChange($event)" class="ml8"
752
+                [ngModelOptions]="{standalone: true}">次日</label>
753 753
             </nz-form-control>
754 754
             <div class="red w100" *ngIf="!yyTimeZy&&clickYYZyFlag">请填写预约建单时间!</div>
755 755
             <div class="red">请您在预约建单时至少在预约检查时间的基础上提前30分钟,以免错过检查!</div>
@@ -759,11 +759,11 @@
759 759
             *ngIf="linkCheckLis.length&&linkCheckLisTrue&&hasTime&&lessTime&&appointmentBuildFlag === '1'&&allowUrgent==0">
760 760
             <nz-form-label [nzSm]="24" [nzXs]="24">预约建单时间</nz-form-label>
761 761
             <nz-form-control [nzSm]="24" [nzXs]="24">
762
-              <nz-date-picker [nzShowToday]="false" nzFormat="yyyy-MM-dd HH:mm"
763
-                (nzOnOpenChange)="openYYTime($event,'parent')" [nzDisabledDate]="disabledYYDate"
764
-                [nzDisabledTime]="disabledYYTime" [nzShowTime]="{nzDefaultOpenValue: timeDefaultValue}"
765
-                [ngModel]="yyTime" (ngModelChange)="yyTimeChange($event)" [ngModelOptions]="{standalone: true}">
766
-              </nz-date-picker>
762
+              <nz-time-picker nzFormat="HH:mm" [nzMinuteStep]="30" [nzSecondStep]="60" [(ngModel)]="yyTime"
763
+                (ngModelChange)="yyTimeChange($event)" [ngModelOptions]="{standalone: true}"
764
+                [nzDisabledHours]="disabledHours" [nzDisabledMinutes]="disabledMinutes"></nz-time-picker>
765
+              <label nz-checkbox [(ngModel)]="nextDay" (ngModelChange)="nextDayChange($event)" class="ml8"
766
+                [ngModelOptions]="{standalone: true}">次日</label>
767 767
             </nz-form-control>
768 768
             <div class="red w100" *ngIf="!yyTime&&clickYYFlag">请填写预约建单时间!</div>
769 769
             <div class="red">请您在预约建单时至少在预约检查时间的基础上提前30分钟,以免错过检查!</div>

+ 1 - 1
src/app/views/hushijiandan/hushijiandan.component.less

@@ -9,7 +9,7 @@
9 9
     flex-direction: column;
10 10
   }
11 11
   .yyTimeError {
12
-    ::ng-deep .ant-calendar-picker-input {
12
+    ::ng-deep .ant-time-picker-input {
13 13
       border: 1px solid red !important;
14 14
     }
15 15
   }

+ 67 - 106
src/app/views/hushijiandan/hushijiandan.component.ts

@@ -23,8 +23,15 @@ import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
23 23
 import { ToolService } from "../../services/tool.service";
24 24
 import { Subject } from "rxjs";
25 25
 import { debounceTime } from "rxjs/operators";
26
-import { differenceInCalendarDays, format, setSeconds } from "date-fns";
27
-
26
+import { format, getMinutes, setMinutes, setSeconds, addDays } from "date-fns";
27
+// 日期禁用
28
+function range(start: number, end: number): number[] {
29
+  const result: number[] = [];
30
+  for (let i = start; i < end; i++) {
31
+    result.push(i);
32
+  }
33
+  return result;
34
+}
28 35
 @Component({
29 36
   selector: "app-hushijiandan",
30 37
   templateUrl: "./hushijiandan.component.html",
@@ -655,12 +662,9 @@ export class HushijiandanComponent implements OnInit {
655 662
   confirmInfo: string = "";
656 663
   btnLoading3 = false;
657 664
   confirm() {
658
-    this.btnLoading3 = true;
659 665
     if (this.confirmYuyue) {
660
-      this.confirmPostData.workOrder.yyTime = format(
661
-        new Date(this.yyTime),
662
-        "yyyy-MM-dd HH:mm:ss"
663
-      );
666
+      this.confirmPostData.workOrder.yyTime =
667
+        format(new Date(this.yyTime), "yyyy-MM-dd HH:mm") + ":00";
664 668
     }
665 669
     //是否需要医护陪同检查
666 670
     if (this.patientMsg.careLevel && this.currentTasktype.isAccompany == 1) {
@@ -687,6 +691,7 @@ export class HushijiandanComponent implements OnInit {
687 691
         return;
688 692
       }
689 693
     }
694
+    this.btnLoading3 = true;
690 695
     this.confirmPostData.workOrder.isAccompany = 0; //是否需要医护陪同检查
691 696
     this.mainService
692 697
       .postCustom(
@@ -805,30 +810,44 @@ export class HushijiandanComponent implements OnInit {
805 810
       });
806 811
   }
807 812
   yyTimeChange(e) {
808
-    if (e) {
809
-      this.yyTime = format(e, "yyyy-MM-dd HH:mm") + ":00";
810
-      this.timeOperate(this.yyTime);
811
-    } else {
812
-      this.yyTime = null;
813
+    if (this.yyTime) {
814
+      if (getMinutes(this.yyTime) != 30) {
815
+        this.yyTime = setMinutes(this.yyTime, 0);
816
+      }
813 817
     }
814 818
     this.clickYYFlag = false;
815
-    this.openYYTime(true, "parent");
816 819
   }
817 820
   yyTimeZyChange(e) {
818
-    if (e) {
819
-      this.yyTimeZy = format(e, "yyyy-MM-dd HH:mm") + ":00";
820
-      this.timeOperate(this.yyTimeZy);
821
-    } else {
822
-      this.yyTimeZy = null;
821
+    if (this.yyTimeZy) {
822
+      if (getMinutes(this.yyTimeZy) != 30) {
823
+        this.yyTimeZy = setMinutes(this.yyTimeZy, 0);
824
+      }
823 825
     }
824 826
     this.clickYYZyFlag = false;
825
-    this.openYYTime(true, "parent-zy");
826 827
   }
827 828
   hidePatientOrder() {
828 829
     this.patientModal = false;
829 830
     this.clickYYFlag = false;
830 831
     this.clickYYZyFlag = false;
831 832
   }
833
+  // 次日-陪检
834
+  nextDay = false;
835
+  nextDayChange(e) {
836
+    if (e) {
837
+      this.yyTime = addDays(this.yyTime, 1);
838
+    } else {
839
+      this.yyTime = addDays(this.yyTime, -1);
840
+    }
841
+  }
842
+  // 次日-陪检
843
+  nextDayZy = false;
844
+  nextDayZyChange(e) {
845
+    if (e) {
846
+      this.yyTimeZy = addDays(this.yyTimeZy, 1);
847
+    } else {
848
+      this.yyTimeZy = addDays(this.yyTimeZy, -1);
849
+    }
850
+  }
832 851
   // 预约建单
833 852
   btnLoading1 = false;
834 853
   confirmPatient1(type) {
@@ -958,10 +977,8 @@ export class HushijiandanComponent implements OnInit {
958 977
         delete postData.workOrder["checkList"];
959 978
         // 添加预约时间
960 979
         if (yuyue) {
961
-          postData.workOrder.yyTime = format(
962
-            new Date(this.yyTimeZy),
963
-            "yyyy-MM-dd HH:mm:ss"
964
-          );
980
+          postData.workOrder.yyTime =
981
+            format(new Date(this.yyTimeZy), "yyyy-MM-dd HH:mm") + ":00";
965 982
         }
966 983
       }
967 984
       if (that.checkedShowMsg.status != 200) {
@@ -1139,6 +1156,8 @@ export class HushijiandanComponent implements OnInit {
1139 1156
   changeCheckedType() {
1140 1157
     this.clickYYFlag = false;
1141 1158
     this.clickYYZyFlag = false;
1159
+    this.nextDay = false;
1160
+    this.nextDayZy = false;
1142 1161
     this.currentTasktype = this.checkTypeLis.find(
1143 1162
       (item) => item.id == this.patientForm.controls.checkedType.value
1144 1163
     );
@@ -1236,10 +1255,7 @@ export class HushijiandanComponent implements OnInit {
1236 1255
       let timeList = linkCheckLis
1237 1256
         .map((item) => new Date(item.yyTime).getTime())
1238 1257
         .sort();
1239
-      this.yyTime = format(
1240
-        new Date(timeList[0] - this.leadTime * 60 * 1000),
1241
-        "yyyy-MM-dd HH:mm"
1242
-      );
1258
+      this.yyTime = new Date(timeList[0] - this.leadTime * 60 * 1000);
1243 1259
     }
1244 1260
     this.linkCheckLisTrue = this.linkCheckLis.some((item) => item.checked);
1245 1261
     if (!this.linkCheckLisTrue) {
@@ -1250,90 +1266,34 @@ export class HushijiandanComponent implements OnInit {
1250 1266
       );
1251 1267
     }
1252 1268
   }
1253
-  // 日期禁用
1254
-  range(start: number, end: number): number[] {
1255
-    const result: number[] = [];
1256
-    for (let i = start; i < end; i++) {
1257
-      result.push(i);
1258
-    }
1259
-    return result;
1260
-  }
1261
-  // 打开预约时间,选择日期时间
1262
-  disabledYYDate;
1263
-  disabledYYTime;
1264
-  openYYTime(flag: boolean, type) {
1265
-    if (flag) {
1266
-      let dataTime = "";
1267
-      if (type === "parent") {
1268
-        if (this.yyTime) {
1269
-          dataTime = format(new Date(this.yyTime), "yyyy-MM-dd HH:mm") + ":00";
1270
-        } else {
1271
-          dataTime = format(new Date(), "yyyy-MM-dd HH:mm") + ":00";
1272
-          this.timeDefaultValue = setSeconds(new Date(), 0);
1273
-        }
1274
-      } else if (type === "inspect") {
1275
-        if (this.yyTimeInspect) {
1276
-          dataTime =
1277
-            format(new Date(this.yyTimeInspect), "yyyy-MM-dd HH:mm") + ":00";
1278
-        } else {
1279
-          dataTime = format(new Date(), "yyyy-MM-dd HH:mm") + ":00";
1280
-          this.timeDefaultValue = setSeconds(new Date(), 0);
1281
-        }
1282
-      } else if (type === "parent-zy") {
1283
-        if (this.yyTimeZy) {
1284
-          dataTime =
1285
-            format(new Date(this.yyTimeZy), "yyyy-MM-dd HH:mm") + ":00";
1286
-        } else {
1287
-          dataTime = format(new Date(), "yyyy-MM-dd HH:mm") + ":00";
1288
-          this.timeDefaultValue = setSeconds(new Date(), 0);
1289
-        }
1290
-      }
1291
-      this.disabledYYDate = (current: Date): boolean => {
1292
-        return differenceInCalendarDays(current, new Date()) < 0;
1293
-      };
1294
-      this.timeOperate(dataTime);
1269
+  // 禁用小时
1270
+  disabledHours(): number[] {
1271
+    let now = new Date();
1272
+    let nHour = now.getHours();
1273
+    let nMinute = now.getMinutes();
1274
+    if (nMinute > 30) {
1275
+      return range(0, nHour + 1);
1276
+    } else {
1277
+      return range(0, nHour);
1295 1278
     }
1296 1279
   }
1297
-  /**
1298
-   * 时间处理,禁用时间
1299
-   * @param dataTime 对比的时间 yyyy-MM-dd HH:mm:ss
1300
-   */
1301
-  timeOperate(dataTime) {
1302
-    dataTime = dataTime.split(" ");
1303
-    let nowTime = (format(new Date(), "yyyy-MM-dd HH:mm") + ":00").split(" "); //当前时间 [yyyy-MM-dd,HH:mm:ss]
1304
-    console.log(dataTime, nowTime);
1305
-    let hours, minutes;
1306
-    if (dataTime[0] !== nowTime[0]) {
1307
-      //年月日不同,则时分都可选
1308
-      hours = [];
1309
-      minutes = [];
1310
-    } else {
1311
-      //年月日相同
1312
-      let dTimeArr = dataTime[1]
1313
-        .split(":")
1314
-        .map((item) => parseInt(item))
1315
-        .slice(0, 2); //[时,分]
1316
-      let nTimeArr = nowTime[1]
1317
-        .split(":")
1318
-        .map((item): any => parseInt(item))
1319
-        .slice(0, 2); //[时,分]
1320
-      if (dTimeArr[0] !== nTimeArr[0]) {
1321
-        //时,不相同
1322
-        hours = this.range(0, nTimeArr[0]);
1323
-        minutes = [];
1280
+  // 禁用分钟
1281
+  disabledMinutes(hour: number): number[] {
1282
+    let now = new Date();
1283
+    let nHour = now.getHours();
1284
+    let nMinute = now.getMinutes();
1285
+    console.log(hour, nHour);
1286
+    if (hour === nHour || hour === undefined) {
1287
+      if (nMinute == 0) {
1288
+        return [];
1289
+      } else if (nMinute <= 30 && nMinute > 0) {
1290
+        return [0];
1324 1291
       } else {
1325
-        //时,相同
1326
-        hours = this.range(0, nTimeArr[0]);
1327
-        minutes = this.range(0, nTimeArr[1]);
1292
+        return [0, 30];
1328 1293
       }
1294
+    } else {
1295
+      return [];
1329 1296
     }
1330
-    this.disabledYYTime = () => {
1331
-      return {
1332
-        nzDisabledHours: () => hours,
1333
-        nzDisabledMinutes: () => minutes,
1334
-        nzDisabledSeconds: () => this.range(1, 60),
1335
-      };
1336
-    };
1337 1297
   }
1338 1298
 
1339 1299
   // 快捷一键发起建单
@@ -1863,6 +1823,7 @@ export class HushijiandanComponent implements OnInit {
1863 1823
       that.closeRecallOrderModal();
1864 1824
       if (data.status == 200) {
1865 1825
         that.getOrderList();
1826
+        that.changeInfo();
1866 1827
         that.showPromptModal("撤销", true, "");
1867 1828
       } else {
1868 1829
         that.showPromptModal("撤销", false, data.msg);