seimin il y a 3 ans
Parent
commit
afa1d8b5ef

+ 1 - 1
angular.json

@@ -50,7 +50,7 @@
50 50
               ],
51 51
               "optimization": true,
52 52
               "outputHashing": "all",
53
-              "sourceMap": false,
53
+              "sourceMap": true,
54 54
               "extractCss": true,
55 55
               "namedChunks": false,
56 56
               "aot": true,

+ 8 - 0
src/app/views/main/main-routing.module.ts

@@ -226,6 +226,14 @@ const routes: Routes = [
226 226
           ).then((m) => m.TimingMessageSendingModule),
227 227
       },
228 228
       {
229
+        // 定时下班
230
+        path: "regularOffDuty",
231
+        loadChildren: () =>
232
+          import("../regular-off-duty/regular-off-duty.module").then(
233
+            (m) => m.RegularOffDutyModule
234
+          ),
235
+      },
236
+      {
229 237
         // 标本信息
230 238
         path: "specimenSearch",
231 239
         loadChildren: () =>

+ 12 - 0
src/app/views/regular-off-duty/regular-off-duty-routing.module.ts

@@ -0,0 +1,12 @@
1
+import { NgModule } from "@angular/core";
2
+import { Routes, RouterModule } from "@angular/router";
3
+
4
+import { RegularOffDutyComponent } from "./regular-off-duty.component";
5
+
6
+const routes: Routes = [{ path: "", component: RegularOffDutyComponent }];
7
+
8
+@NgModule({
9
+  imports: [RouterModule.forChild(routes)],
10
+  exports: [RouterModule],
11
+})
12
+export class RegularOffDutyRoutingModule {}

+ 165 - 0
src/app/views/regular-off-duty/regular-off-duty.component.html

@@ -0,0 +1,165 @@
1
+<div class="list-template">
2
+  <div class="list-template__content">
3
+    <div class="list-template__top" nz-row>
4
+      <div nz-col nzXl='15' class="list-template__searchBox"></div>
5
+      <div nz-col nzXl="9" class="list-template__btns">
6
+        <button nz-button *ngIf="coopBtns.add" class="btn default ml8" (click)="addModal()">新增</button>
7
+      </div>
8
+    </div>
9
+    <div class="list-template__bottom">
10
+      <nz-table class="list-template__nzTable" [nzData]="listOfData" nzSize="middle" [nzShowPagination]="false"
11
+        [nzLoading]="loading1">
12
+        <thead>
13
+          <tr class="thead">
14
+            <th nzWidth="5%">序号</th>
15
+            <th nzWidth="10%">标题</th>
16
+            <th nzWidth="10%">重复策略</th>
17
+            <th nzWidth="15%">定时发送时间</th>
18
+            <th nzWidth="10%">状态</th>
19
+            <th nzWidth="35%">定时下班班次</th>
20
+            <th nzWidth="15%">操作</th>
21
+          </tr>
22
+        </thead>
23
+        <tbody>
24
+          <tr *ngFor="let data of listOfData;let i = index">
25
+            <td>{{ i+1 }}</td>
26
+            <td>{{ data.title }}</td>
27
+            <td [ngSwitch]="data.timeStep">
28
+              <ng-container *ngSwitchCase="'day'">每日</ng-container>
29
+              <ng-container *ngSwitchCase="'week'">每周</ng-container>
30
+              <ng-container *ngSwitchCase="'month'">每月</ng-container>
31
+              <ng-container *ngSwitchCase="'year'">每年</ng-container>
32
+            </td>
33
+            <td [ngSwitch]="data.timeStep">
34
+              <ng-container *ngSwitchCase="'day'">{{ data.executeTime|date:'HH时mm分' }}</ng-container>
35
+              <ng-container *ngSwitchCase="'week'">{{data.weekName}} {{ data.executeTime|date:'HH时mm分' }}</ng-container>
36
+              <ng-container *ngSwitchCase="'month'">{{data.extra1}}日 {{ data.executeTime|date:'HH时mm分' }}</ng-container>
37
+              <ng-container *ngSwitchCase="'year'">{{ data.executeTime|date:'MM月dd日HH时mm分' }}</ng-container>
38
+            </td>
39
+            <td>{{ data.active?'开启':'关闭' }}</td>
40
+            <td>{{ data.usersName }}</td>
41
+            <td>
42
+              <div class="coop">
43
+                <span *ngIf="coopBtns.edit" (click)="edit(data)">编辑</span>
44
+                <span *ngIf="coopBtns.del" (click)="showDelModal(data,'您确认要删除吗?','删除','del')">删除</span>
45
+                <span *ngIf="coopBtns.isStartUp"
46
+                  (click)="showDelModal(data,data.active?'您确认要停用吗?':'您确认要启用吗?',data.active?'停用':'启用','switch',data.active)">{{data.active?'停用':'启用'}}</span>
47
+              </div>
48
+            </td>
49
+          </tr>
50
+        </tbody>
51
+      </nz-table>
52
+      <div class="list-template__pagination">
53
+        <nz-pagination [(nzPageIndex)]="pageIndex" [(nzTotal)]="listLength" [(nzPageSize)]="pageSize"
54
+          (nzPageIndexChange)="getList()" (nzPageSizeChange)="getList()">
55
+        </nz-pagination>
56
+      </div>
57
+    </div>
58
+  </div>
59
+
60
+  <!-- 编辑模态框 -->
61
+  <div class="save display_flex justify-content_flex-center align-items_center add" *ngIf="modal">
62
+    <div class="modalBody">
63
+      <div class="title">{{add?"新增":"编辑"}}定时消息发送<i class="icon_transport transport-guanbi" (click)="hideAddModal()"></i>
64
+      </div>
65
+      <overlay-scrollbars #osComponentRef1 class="content">
66
+        <form nz-form [formGroup]="validateForm" class="addForm" (ngSubmit)="submitForm()">
67
+          <nz-form-item>
68
+            <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="title">标题</nz-form-label>
69
+            <nz-form-control nzErrorTip="请输入标题!">
70
+              <nz-input-group>
71
+                <input nz-input formControlName="title" placeholder="请输入标题" />
72
+              </nz-input-group>
73
+            </nz-form-control>
74
+          </nz-form-item>
75
+          <nz-form-item>
76
+            <nz-form-label [nzSm]="24" [nzXs]="24" nzRequired nzFor="timeStep">重复策略</nz-form-label>
77
+            <nz-form-control nzErrorTip="请选择重复策略!">
78
+              <nz-radio-group formControlName="timeStep" (ngModelChange)="timeStepChange($event)">
79
+                <label nz-radio nzValue="day">每天</label>
80
+                <label nz-radio nzValue="week">每周</label>
81
+                <label nz-radio nzValue="month">每月</label>
82
+                <label nz-radio nzValue="year">每年</label>
83
+              </nz-radio-group>
84
+            </nz-form-control>
85
+          </nz-form-item>
86
+          <nz-form-item *ngIf="validateForm.value.timeStep == 'week'">
87
+            <nz-form-label [nzSm]="24" [nzXs]="24" nzRequired nzFor="doWeek">计划执行周(每周)</nz-form-label>
88
+            <nz-form-control nzErrorTip="请选择周!">
89
+              <nz-select formControlName="doWeek" nzPlaceHolder="请选择周">
90
+                <nz-option nzValue="1" nzLabel="周一"></nz-option>
91
+                <nz-option nzValue="2" nzLabel="周二"></nz-option>
92
+                <nz-option nzValue="3" nzLabel="周三"></nz-option>
93
+                <nz-option nzValue="4" nzLabel="周四"></nz-option>
94
+                <nz-option nzValue="5" nzLabel="周五"></nz-option>
95
+                <nz-option nzValue="6" nzLabel="周六"></nz-option>
96
+                <nz-option nzValue="7" nzLabel="周日"></nz-option>
97
+              </nz-select>
98
+            </nz-form-control>
99
+          </nz-form-item>
100
+          <nz-form-item *ngIf="validateForm.value.timeStep == 'month'">
101
+            <nz-form-label [nzSm]="24" [nzXs]="24" nzRequired nzFor="doMonth">计划执行(每月)</nz-form-label>
102
+            <nz-form-control nzErrorTip="请选择日!">
103
+              <nz-select formControlName="doMonth" nzPlaceHolder="请选择日">
104
+                <nz-option nzValue="{{item}}" nzLabel="{{item}}号" *ngFor="let item of months">
105
+                </nz-option>
106
+              </nz-select>
107
+            </nz-form-control>
108
+          </nz-form-item>
109
+          <nz-form-item *ngIf="validateForm.value.timeStep == 'year'">
110
+            <nz-form-label [nzSm]="24" [nzXs]="24" nzRequired nzFor="doYear">计划执行(每年)</nz-form-label>
111
+            <nz-form-control nzErrorTip="请选择月日!">
112
+              <nz-date-picker nzFormat="MM-dd" formControlName="doYear" nzPlaceHolder="请选择月日"></nz-date-picker>
113
+            </nz-form-control>
114
+          </nz-form-item>
115
+          <nz-form-item>
116
+            <nz-form-label [nzSm]="24" [nzXs]="24" nzRequired nzFor="executeTime">定时发送时间</nz-form-label>
117
+            <nz-form-control nzErrorTip="请选择定时发送时间!">
118
+              <nz-time-picker nzFormat="HH:mm" class="executeTime" formControlName="executeTime"
119
+                nzPlaceHolder="请选择定时发送时间" [nzAllowEmpty]="false">
120
+              </nz-time-picker>
121
+            </nz-form-control>
122
+          </nz-form-item>
123
+          <nz-form-item>
124
+            <nz-form-label [nzSm]="24" [nzXs]="24" nzRequired nzFor="active">是否启用</nz-form-label>
125
+            <nz-form-control nzErrorTip="请选择是否启用!">
126
+              <nz-radio-group formControlName="active">
127
+                <label nz-radio [nzValue]="true">开启</label>
128
+                <label nz-radio [nzValue]="false">关闭</label>
129
+              </nz-radio-group>
130
+            </nz-form-control>
131
+          </nz-form-item>
132
+          <nz-form-item>
133
+            <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="classIds">定时下班班次</nz-form-label>
134
+            <nz-form-control nzErrorTip="请选择定时下班班次!">
135
+              <nz-select [nzMode]="'multiple'" [nzDropdownMatchSelectWidth]="false" formControlName="classIds"
136
+                nzShowSearch nzAllowClear nzPlaceHolder="请选择定时下班班次" nzServerSearch (nzOpenChange)="changeForm($event)">
137
+                <ng-container *ngFor="let data of classes">
138
+                  <nz-option *ngIf="!isLoading" nzLabel="{{data.name}}" nzValue="{{data.id}}"></nz-option>
139
+                </ng-container>
140
+                <nz-option *ngIf="isLoading" nzDisabled nzCustomContent>
141
+                  <i nz-icon nzType="loading" class="loading-icon"></i> 搜索中...
142
+                </nz-option>
143
+              </nz-select>
144
+            </nz-form-control>
145
+          </nz-form-item>
146
+        </form>
147
+      </overlay-scrollbars>
148
+      <div class=" display_flex justify-content_flex-center">
149
+        <button nzType="primary" nz-button (click)="submitForm()" [nzLoading]="btnLoading">保存</button>
150
+        <button class="btn cancel" nz-button nzType="default" (click)="hideAddModal()">取消</button>
151
+      </div>
152
+    </div>
153
+  </div>
154
+
155
+
156
+  <!-- 启用/停用模态框 -->
157
+  <app-dialog-delete [delModal]="delModal" (hideDelModalEvent)="hideDelModal()" [btnLoading]="btnLoading"
158
+    (confirmDelEvent)="confirmDel()" [content]="tipsMsg1"></app-dialog-delete>
159
+</div>
160
+<!-- 操作成功/失败提示框 -->
161
+<app-prompt-modal *ngIf="promptModalShow" [content]="promptContent" [success]="ifSuccess" [show]="promptModalShow"
162
+  [info]="promptInfo">
163
+</app-prompt-modal>
164
+<!-- 遮罩 -->
165
+<app-mask *ngIf="maskFlag"></app-mask>

+ 177 - 0
src/app/views/regular-off-duty/regular-off-duty.component.less

@@ -0,0 +1,177 @@
1
+@import "../../../../src/theme.less";
2
+
3
+::ng-deep .executeTime,
4
+::ng-deep
5
+  .executeTime[nzplaceholder="请选择定时发送时间"]
6
+  .ant-calendar-picker {
7
+  width: 100% !important;
8
+}
9
+::ng-deep .ant-calendar-picker-input {
10
+  width: 410px !important;
11
+}
12
+
13
+.save {
14
+  position: fixed;
15
+  left: 0;
16
+  top: 0;
17
+  width: 100%;
18
+  height: 100%;
19
+  background: rgba(0, 0, 0, 0.4);
20
+  z-index: 99;
21
+
22
+  .modalBody {
23
+    width: 350px;
24
+    height: 220px;
25
+    background: #fff;
26
+    border-radius: 5px;
27
+    padding: 10px 20px;
28
+    color: #333;
29
+
30
+    .title {
31
+      width: 100%;
32
+      text-align: center;
33
+      font-size: 18px;
34
+      position: relative;
35
+
36
+      i {
37
+        position: absolute;
38
+        right: 0;
39
+        top: 0;
40
+        font-size: 20px;
41
+        color: #666;
42
+        cursor: pointer;
43
+        padding: 0 5px;
44
+      }
45
+    }
46
+
47
+    .content {
48
+      width: 310px;
49
+      height: 117px;
50
+      background: #f9fafb;
51
+      border: 1px solid #e5e9ed;
52
+      border-radius: 5px;
53
+      overflow: hidden;
54
+      margin-top: 12px;
55
+
56
+      & > div {
57
+        text-align: center;
58
+        margin: 0;
59
+
60
+        &.icon {
61
+          margin-top: 17px;
62
+
63
+          i {
64
+            color: #34b349;
65
+            font-size: 30px !important;
66
+
67
+            &.transport-wenhao {
68
+              color: #f5a523;
69
+            }
70
+
71
+            &.transport-shibai {
72
+              color: #ff3a52;
73
+            }
74
+          }
75
+        }
76
+
77
+        &.defeat {
78
+          color: #333;
79
+          font-size: 18px;
80
+        }
81
+
82
+        &:nth-child(3) {
83
+          font-size: 14px;
84
+          color: #666;
85
+        }
86
+      }
87
+      .timingMessageSendingTips {
88
+        font-size: 12px;
89
+      }
90
+    }
91
+
92
+    button {
93
+      margin-top: 10px;
94
+
95
+      &.btn {
96
+        margin-left: 8px;
97
+      }
98
+    }
99
+  }
100
+
101
+  // 新增
102
+  &.add {
103
+    .modalBody {
104
+      width: 480px;
105
+      height: auto;
106
+
107
+      .content {
108
+        width: 100%;
109
+        height: auto;
110
+        padding: 18px 14px 0 14px;
111
+        max-height: 497px;
112
+        overflow-y: auto;
113
+
114
+        .addForm {
115
+          .ant-form-item {
116
+            margin-bottom: 15px;
117
+
118
+            .ant-form-item-label {
119
+              line-height: 14px;
120
+              text-align: left;
121
+            }
122
+
123
+            .desc {
124
+              margin-top: 5px;
125
+            }
126
+          }
127
+
128
+          .datesControl {
129
+            margin-top: -16px;
130
+
131
+            .ant-form-item-label {
132
+              line-height: 40px;
133
+            }
134
+          }
135
+
136
+          .timer {
137
+            .ant-form-item-label {
138
+              width: 100%;
139
+              text-align: left;
140
+            }
141
+
142
+            .numInp {
143
+              margin-right: 5px;
144
+            }
145
+
146
+            .line {
147
+              margin-right: 5px;
148
+            }
149
+          }
150
+
151
+          .timer2 {
152
+            .ant-form-item-label {
153
+              line-height: 20px;
154
+            }
155
+          }
156
+        }
157
+
158
+        .editForm {
159
+          .ant-form-item {
160
+            margin-bottom: 15px;
161
+
162
+            .ant-form-item-label {
163
+              line-height: 14px;
164
+              text-align: left;
165
+            }
166
+          }
167
+        }
168
+      }
169
+
170
+      button {
171
+        &:nth-child(1) {
172
+          margin-right: 20px;
173
+        }
174
+      }
175
+    }
176
+  }
177
+}

+ 398 - 0
src/app/views/regular-off-duty/regular-off-duty.component.ts

@@ -0,0 +1,398 @@
1
+import { Component, OnInit, ViewChild } from "@angular/core";
2
+import { ActivatedRoute } from "@angular/router";
3
+import {
4
+  FormBuilder,
5
+  Validators,
6
+  FormGroup,
7
+  FormControl,
8
+} from "@angular/forms";
9
+
10
+import { MainService } from "../../services/main.service";
11
+import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
12
+import { ToolService } from "../../services/tool.service";
13
+import { NzMessageService } from "ng-zorro-antd";
14
+import { format } from "date-fns";
15
+@Component({
16
+  selector: "app-regular-off-duty",
17
+  templateUrl: "./regular-off-duty.component.html",
18
+  styleUrls: ["./regular-off-duty.component.less"],
19
+})
20
+export class RegularOffDutyComponent implements OnInit {
21
+  @ViewChild("osComponentRef1", {
22
+    read: OverlayScrollbarsComponent,
23
+    static: false,
24
+  })
25
+  osComponentRef1: OverlayScrollbarsComponent;
26
+  constructor(
27
+    private message: NzMessageService,
28
+    private fb: FormBuilder,
29
+    private mainService: MainService,
30
+    private route: ActivatedRoute,
31
+    private tool: ToolService
32
+  ) {}
33
+
34
+  userInfo: any = JSON.parse(localStorage.getItem("user")) || {}; //登录用户信息
35
+  hosId;
36
+  createUser = "";
37
+  classes = []; // 用户列表
38
+  listOfData: any[] = []; //表格数据
39
+  pageIndex: number = 1; //表格当前页码
40
+  pageSize: number = 10; //表格每页展示条数
41
+  listLength: number = 10; //表格总数据量
42
+  tableHeight: number; //表格动态高
43
+  modal: boolean = false; //新增/编辑模态框
44
+  validateForm: FormGroup; //新增/编辑表单
45
+  dataContent: any; //当前操作列
46
+
47
+  oneOption: any; //适用日期类型
48
+  btnLoading: boolean = false; //提交按钮loading状态
49
+
50
+  promptContent: string; //操作提示框提示信息
51
+  ifSuccess: boolean; //操作成功/失败
52
+  promptInfo: string; //操作结果提示信息
53
+  promptModalShow: boolean; //操作提示框是否展示
54
+  demoValue: number = 0;
55
+
56
+  ngOnInit() {
57
+    this.hosId = this.tool.getCurrentHospital().id;
58
+    this.getList();
59
+    this.coopBtns = this.tool.initCoopBtns(this.route);
60
+    this.initForm();
61
+  }
62
+  // 新增/编辑弹框
63
+  add: boolean; //true:新增;false:编辑
64
+  addModal() {
65
+    this.add = true; //新增
66
+    this.modal = true;
67
+    this.initForm();
68
+  }
69
+  changeForm(flag) {
70
+    if (flag) {
71
+      this.changeInp("no", "form");
72
+    }
73
+  }
74
+  // 边输边搜节流阀
75
+  isLoading = false;
76
+  changeInp(dept, type) {
77
+    if (!dept) {
78
+      return;
79
+    }
80
+    if (dept === "no") {
81
+      dept = "";
82
+    }
83
+    this.isLoading = true;
84
+    this.searchUsers(dept, type);
85
+  }
86
+  // 搜索班次
87
+  snum = 0;
88
+  searchUsers(dept, type) {
89
+    let data = {
90
+      scheduleClass: {
91
+        hospital: { id: this.hosId.toString() },
92
+      },
93
+      idx: 0,
94
+      sum: 20,
95
+    };
96
+    this.snum++;
97
+    this.mainService
98
+      .getFetchDataList("configuration", "scheduleClass", data)
99
+      .subscribe((data) => {
100
+        this.snum--;
101
+        if (data.status == 200) {
102
+          if (type === "form") {
103
+            if (this.snum === 0) {
104
+              this.isLoading = false;
105
+            }
106
+            this.classes = data.list;
107
+          }
108
+        }
109
+      });
110
+  }
111
+
112
+  // 初始化权限按钮
113
+  coopBtns: any = {};
114
+
115
+  // 表格数据
116
+  loading1 = false;
117
+  getList() {
118
+    let postData = {
119
+      idx: this.pageIndex - 1,
120
+      sum: this.pageSize,
121
+      messageJob: {
122
+        hospital: this.hosId,
123
+      },
124
+    };
125
+    this.loading1 = true;
126
+    this.mainService
127
+      .getFetchDataList("simple/data", "classesJob", postData)
128
+      .subscribe((data) => {
129
+        this.loading1 = false;
130
+        if (data.status == 200) {
131
+          this.listOfData = data.list;
132
+          this.listOfData.forEach((item) => {
133
+            if (item.timeStep == "week") {
134
+              let weeks = [
135
+                "周一",
136
+                "周二",
137
+                "周三",
138
+                "周四",
139
+                "周五",
140
+                "周六",
141
+                "周日",
142
+              ];
143
+              item.weekName = weeks[item.extra1 - 1];
144
+            }
145
+            item.usersName = item.classes.map((value) => value.name).join();
146
+          });
147
+          this.listLength = data.totalNum;
148
+        }
149
+      });
150
+  }
151
+  //关闭编辑弹框
152
+  hideAddModal() {
153
+    this.modal = false;
154
+    this.initForm();
155
+  }
156
+  // 初始化form表单
157
+  initForm() {
158
+    this.validateForm = this.fb.group({
159
+      title: [null, [Validators.required]], //标题
160
+      timeStep: ["day", [Validators.required]], //重复策略
161
+      executeTime: [null, [Validators.required]], //定时发送时间
162
+      active: [false, [Validators.required]], //是否启用
163
+      classIds: [null, [Validators.required]], //定时下班班次
164
+    });
165
+  }
166
+  //修改重复策略
167
+  months = [...Array(32).keys()].slice(1);
168
+  timeStepChange(e) {
169
+    switch (e) {
170
+      case "day":
171
+        this.validateForm.removeControl("doWeek");
172
+        this.validateForm.removeControl("doMonth");
173
+        this.validateForm.removeControl("doYear");
174
+        break;
175
+      case "week":
176
+        this.validateForm.addControl(
177
+          "doWeek",
178
+          new FormControl(null, Validators.required)
179
+        );
180
+        this.validateForm.removeControl("doMonth");
181
+        this.validateForm.removeControl("doYear");
182
+        break;
183
+      case "month":
184
+        this.validateForm.addControl(
185
+          "doMonth",
186
+          new FormControl(null, Validators.required)
187
+        );
188
+        this.validateForm.removeControl("doWeek");
189
+        this.validateForm.removeControl("doYear");
190
+        break;
191
+      case "year":
192
+        this.validateForm.addControl(
193
+          "doYear",
194
+          new FormControl(null, Validators.required)
195
+        );
196
+        this.validateForm.removeControl("doWeek");
197
+        this.validateForm.removeControl("doMonth");
198
+        break;
199
+    }
200
+  }
201
+
202
+  // 表单提交
203
+  submitForm(): void {
204
+    this.btnLoading = true;
205
+    for (const i in this.validateForm.controls) {
206
+      this.validateForm.controls[i].markAsDirty();
207
+      this.validateForm.controls[i].updateValueAndValidity();
208
+    }
209
+    if (this.validateForm.invalid) {
210
+      this.btnLoading = false;
211
+      return;
212
+    }
213
+    let postData: any = {};
214
+    if (this.add) {
215
+      postData = {
216
+        hospital: this.hosId,
217
+        title: this.validateForm.value.title,
218
+        executeTime: new Date(this.validateForm.value.executeTime).getTime(),
219
+        classesIds: this.validateForm.value.classIds.join(),
220
+        active: this.validateForm.value.active,
221
+        key: "regularOffDuty",
222
+        timeStep: this.validateForm.value.timeStep,
223
+      };
224
+    } else {
225
+      postData = {
226
+        title: this.validateForm.value.title,
227
+        executeTime: new Date(this.validateForm.value.executeTime).getTime(),
228
+        classesIds: this.validateForm.value.classIds.join(),
229
+        active: this.validateForm.value.active,
230
+        key: this.dataContent.key,
231
+        id: this.dataContent.id,
232
+        timeStep: this.validateForm.value.timeStep,
233
+      };
234
+    }
235
+    if (this.validateForm.value.timeStep == "day") {
236
+      delete postData.extra1;
237
+    } else if (this.validateForm.value.timeStep == "week") {
238
+      postData.extra1 = this.validateForm.value.doWeek;
239
+    } else if (this.validateForm.value.timeStep == "month") {
240
+      postData.extra1 = this.validateForm.value.doMonth;
241
+    } else if (this.validateForm.value.timeStep == "year") {
242
+      delete postData.extra1;
243
+      postData.executeTime = new Date(
244
+        format(new Date(this.validateForm.value.doYear), "yyyy-MM-dd") +
245
+          " " +
246
+          format(new Date(this.validateForm.value.executeTime), "HH:mm:ss")
247
+      ).getTime();
248
+    }
249
+    this.mainService
250
+      .simplePost(this.add ? "addData" : "updData", "classesJob", postData)
251
+      .subscribe((data) => {
252
+        this.btnLoading = false;
253
+        this.hideAddModal();
254
+        this.initForm();
255
+        if (data.status == 200) {
256
+          this.listLength++;
257
+          this.showPromptModal("修改", true, "");
258
+        } else {
259
+          this.showPromptModal("修改", false, data.msg);
260
+        }
261
+      });
262
+  }
263
+
264
+  // 编辑
265
+  maskFlag: any = false;
266
+  edit(data) {
267
+    this.add = false;
268
+    this.dataContent = data;
269
+    this.validateForm.controls.executeTime.setValue(new Date(data.executeTime)); //定时发送时间
270
+    this.validateForm.controls.title.setValue(data.title); //标题
271
+    this.validateForm.controls.active.setValue(data.active); //是否启用
272
+    this.timeStepChange(data.timeStep);
273
+    this.validateForm.controls.timeStep.setValue(data.timeStep); //重复策略
274
+    if (data.timeStep == "year") {
275
+      this.validateForm.controls.doYear.setValue(
276
+        format(data.executeTime, "yyyy-MM-dd HH:mm:ss")
277
+      );
278
+    } else if (data.timeStep == "month") {
279
+      this.validateForm.controls.doMonth.setValue(data.extra1);
280
+    } else if (data.timeStep == "week") {
281
+      this.validateForm.controls.doWeek.setValue(data.extra1);
282
+    }
283
+    // --------定时下班班次---
284
+    this.maskFlag = this.message.loading("正在加载中..", {
285
+      nzDuration: 0,
286
+    }).messageId;
287
+    this.mainService
288
+      .getFetchDataList("configuration", "scheduleClass", {
289
+        idx: 0,
290
+        sum: 20,
291
+        user: {
292
+          hosId: this.hosId,
293
+        },
294
+      })
295
+      .subscribe((result) => {
296
+        this.message.remove(this.maskFlag);
297
+        this.maskFlag = false;
298
+        this.modal = true;
299
+        if (result.status == 200) {
300
+          let add = data.classes.filter(
301
+            (item) => !result.list.some((ele) => ele.id == item.id)
302
+          );
303
+          this.classes = add.concat(result.list);
304
+          this.validateForm.controls.classIds.setValue(
305
+            data.classes.map((v) => v.id.toString())
306
+          ); //定时下班班次
307
+        }
308
+      });
309
+    // --------/定时下班班次---
310
+  }
311
+
312
+  // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
313
+  showPromptModal(con, success, promptInfo?) {
314
+    this.promptModalShow = false;
315
+    this.promptContent = con;
316
+    this.ifSuccess = success;
317
+    this.promptInfo = promptInfo;
318
+    setTimeout(() => {
319
+      this.promptModalShow = true;
320
+    }, 100);
321
+    this.getList();
322
+  }
323
+
324
+  // 是否启用
325
+  delModal: boolean = false; //删除模态框
326
+  tipsMsg1: string; //提示框信息
327
+  tipsMsg2: string; //操作后信息
328
+  confirmDelType: string; //确认的类型(启用/停用,删除)
329
+  confirmDelIsSwitch: boolean; //启用/停用
330
+  showDelModal(
331
+    dataContent,
332
+    tipsMsg1: string,
333
+    tipsMsg2: string,
334
+    type: string,
335
+    isSwitch?: boolean
336
+  ) {
337
+    this.confirmDelIsSwitch = isSwitch;
338
+    this.confirmDelType = type;
339
+    this.delModal = true;
340
+    this.dataContent = dataContent;
341
+    this.tipsMsg1 = tipsMsg1;
342
+    this.tipsMsg2 = tipsMsg2;
343
+  }
344
+  // 隐藏
345
+  hideDelModal() {
346
+    this.delModal = false;
347
+  }
348
+  // 确认
349
+  confirmDel() {
350
+    this.btnLoading = true;
351
+    if (this.confirmDelType === "del") {
352
+      //删除
353
+      this.mainService
354
+        .simplePost("rmvData", "classesJob", [this.dataContent.id])
355
+        .subscribe((data) => {
356
+          this.btnLoading = false;
357
+          this.delModal = false;
358
+          if (data.status == 200) {
359
+            if (
360
+              this.listOfData.length == 1 &&
361
+              this.pageIndex == Math.ceil(this.listLength / this.pageSize)
362
+            ) {
363
+              this.listLength--;
364
+              if (this.listLength === 0) {
365
+                this.pageIndex = 1;
366
+              } else {
367
+                this.pageIndex = Math.ceil(this.listLength / this.pageSize);
368
+              }
369
+            }
370
+            this.showPromptModal(this.tipsMsg2, true, "");
371
+          } else {
372
+            this.showPromptModal(this.tipsMsg2, false, data.msg);
373
+          }
374
+        });
375
+    } else if (this.confirmDelType === "switch") {
376
+      //启用/停用
377
+      let postData = {
378
+        id: this.dataContent.id,
379
+        title: this.dataContent.title,
380
+        executeTime: this.dataContent.executeTime,
381
+        classesIds: this.dataContent.classes.map((v) => v.id).join(),
382
+        active: this.dataContent.active ? false : true,
383
+        key: this.dataContent.key,
384
+      };
385
+      this.mainService
386
+        .simplePost("updData", "classesJob", postData)
387
+        .subscribe((data) => {
388
+          this.btnLoading = false;
389
+          this.delModal = false;
390
+          if (data.status == 200) {
391
+            this.showPromptModal(this.tipsMsg2, true, "");
392
+          } else {
393
+            this.showPromptModal(this.tipsMsg2, false, data.msg);
394
+          }
395
+        });
396
+    }
397
+  }
398
+}

+ 12 - 0
src/app/views/regular-off-duty/regular-off-duty.module.ts

@@ -0,0 +1,12 @@
1
+import { NgModule } from "@angular/core";
2
+import { CommonModule } from "@angular/common";
3
+
4
+import { RegularOffDutyRoutingModule } from "./regular-off-duty-routing.module";
5
+import { RegularOffDutyComponent } from "./regular-off-duty.component";
6
+import { ShareModule } from "src/app/share/share.module";
7
+
8
+@NgModule({
9
+  declarations: [RegularOffDutyComponent],
10
+  imports: [CommonModule, RegularOffDutyRoutingModule, ShareModule],
11
+})
12
+export class RegularOffDutyModule {}