seimin лет назад: 3
Родитель
Сommit
3212cc3924

+ 11 - 0
src/app/views/timing-message-sending/timing-message-sending.component.html

@@ -60,6 +60,17 @@
60 60
             </nz-form-control>
61 61
           </nz-form-item>
62 62
           <nz-form-item>
63
+            <nz-form-label [nzSm]="24" [nzXs]="24" nzRequired nzFor="xxx">重复策略</nz-form-label>
64
+            <nz-form-control nzErrorTip="请选择重复策略!">
65
+              <nz-radio-group formControlName="xxx">
66
+                <label nz-radio [nzValue]="1">每天</label>
67
+                <label nz-radio [nzValue]="2">每周</label>
68
+                <label nz-radio [nzValue]="3">每月</label>
69
+                <label nz-radio [nzValue]="4">每年</label>
70
+              </nz-radio-group>
71
+            </nz-form-control>
72
+          </nz-form-item>
73
+          <nz-form-item>
63 74
             <nz-form-label [nzSm]="24" [nzXs]="24" nzRequired nzFor="executeTime">定时发送时间</nz-form-label>
64 75
             <nz-form-control nzErrorTip="请选择定时发送时间!">
65 76
               <nz-time-picker class="executeTime" formControlName="executeTime" nzPlaceHolder="请选择定时发送时间">

+ 145 - 123
src/app/views/timing-message-sending/timing-message-sending.component.ts

@@ -1,18 +1,21 @@
1
-import { Component, OnInit, ViewChild } from '@angular/core';
2
-import { ActivatedRoute } from '@angular/router';
3
-import { FormBuilder, Validators, FormGroup } from '@angular/forms';
1
+import { Component, OnInit, ViewChild } from "@angular/core";
2
+import { ActivatedRoute } from "@angular/router";
3
+import { FormBuilder, Validators, FormGroup } from "@angular/forms";
4 4
 
5
-import { MainService } from "../../services/main.service"
6
-import { OverlayScrollbarsComponent } from 'overlayscrollbars-ngx';
7
-import { ToolService } from '../../services/tool.service';
8
-import { NzMessageService } from 'ng-zorro-antd';
5
+import { MainService } from "../../services/main.service";
6
+import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
7
+import { ToolService } from "../../services/tool.service";
8
+import { NzMessageService } from "ng-zorro-antd";
9 9
 @Component({
10
-  selector: 'app-timing-message-sending',
11
-  templateUrl: './timing-message-sending.component.html',
12
-  styleUrls: ['./timing-message-sending.component.less']
10
+  selector: "app-timing-message-sending",
11
+  templateUrl: "./timing-message-sending.component.html",
12
+  styleUrls: ["./timing-message-sending.component.less"],
13 13
 })
14 14
 export class TimingMessageSendingComponent implements OnInit {
15
-  @ViewChild('osComponentRef1', { read: OverlayScrollbarsComponent, static: false })
15
+  @ViewChild("osComponentRef1", {
16
+    read: OverlayScrollbarsComponent,
17
+    static: false,
18
+  })
16 19
   osComponentRef1: OverlayScrollbarsComponent;
17 20
   constructor(
18 21
     private message: NzMessageService,
@@ -20,29 +23,29 @@ export class TimingMessageSendingComponent implements OnInit {
20 23
     private mainService: MainService,
21 24
     private route: ActivatedRoute,
22 25
     private tool: ToolService
23
-  ) { }
26
+  ) {}
24 27
 
25
-  userInfo: any = JSON.parse(localStorage.getItem('user')) || {};//登录用户信息
26
-  menu: any = JSON.parse(localStorage.getItem('menu')) || [];//菜单
28
+  userInfo: any = JSON.parse(localStorage.getItem("user")) || {}; //登录用户信息
29
+  menu: any = JSON.parse(localStorage.getItem("menu")) || []; //菜单
27 30
   hosId;
28
-  createUser = '';
29
-  users = [];// 用户列表
30
-  listOfData: any[] = [];//表格数据
31
-  pageIndex: number = 1;//表格当前页码
32
-  pageSize: number = 10;//表格每页展示条数
33
-  listLength: number = 10;//表格总数据量
34
-  tableHeight: number;//表格动态高
35
-  modal: boolean = false;//新增/编辑模态框
36
-  validateForm: FormGroup;//新增/编辑表单
37
-  dataContent: any;//当前操作列
31
+  createUser = "";
32
+  users = []; // 用户列表
33
+  listOfData: any[] = []; //表格数据
34
+  pageIndex: number = 1; //表格当前页码
35
+  pageSize: number = 10; //表格每页展示条数
36
+  listLength: number = 10; //表格总数据量
37
+  tableHeight: number; //表格动态高
38
+  modal: boolean = false; //新增/编辑模态框
39
+  validateForm: FormGroup; //新增/编辑表单
40
+  dataContent: any; //当前操作列
38 41
 
39
-  oneOption: any;//适用日期类型
40
-  btnLoading: boolean = false;//提交按钮loading状态
42
+  oneOption: any; //适用日期类型
43
+  btnLoading: boolean = false; //提交按钮loading状态
41 44
 
42
-  promptContent: string;//操作提示框提示信息
43
-  ifSuccess: boolean;//操作成功/失败
44
-  promptInfo: string;//操作结果提示信息
45
-  promptModalShow: boolean;//操作提示框是否展示
45
+  promptContent: string; //操作提示框提示信息
46
+  ifSuccess: boolean; //操作成功/失败
47
+  promptInfo: string; //操作结果提示信息
48
+  promptModalShow: boolean; //操作提示框是否展示
46 49
   demoValue: number = 0;
47 50
 
48 51
   ngOnInit() {
@@ -53,7 +56,7 @@ export class TimingMessageSendingComponent implements OnInit {
53 56
   }
54 57
   changeForm(flag) {
55 58
     if (flag) {
56
-      this.changeInp('no', 'form');
59
+      this.changeInp("no", "form");
57 60
     }
58 61
   }
59 62
   // 边输边搜节流阀
@@ -62,8 +65,8 @@ export class TimingMessageSendingComponent implements OnInit {
62 65
     if (!dept) {
63 66
       return;
64 67
     }
65
-    if (dept === 'no') {
66
-      dept = '';
68
+    if (dept === "no") {
69
+      dept = "";
67 70
     }
68 71
     this.isLoading = true;
69 72
     this.searchUsers(dept, type);
@@ -74,48 +77,50 @@ export class TimingMessageSendingComponent implements OnInit {
74 77
     let data = {
75 78
       user: {
76 79
         name: dept,
77
-        hospital: { id: this.hosId }
80
+        hospital: { id: this.hosId },
78 81
       },
79 82
       idx: 0,
80
-      sum: 20
81
-    }
83
+      sum: 20,
84
+    };
82 85
     this.snum++;
83
-    this.mainService.getFetchDataList('data', 'user', data).subscribe(data => {
84
-      this.snum--;
85
-      if (data.status == 200) {
86
-        if (type === 'form') {
87
-          if (this.snum === 0) {
88
-            this.isLoading = false;
86
+    this.mainService
87
+      .getFetchDataList("data", "user", data)
88
+      .subscribe((data) => {
89
+        this.snum--;
90
+        if (data.status == 200) {
91
+          if (type === "form") {
92
+            if (this.snum === 0) {
93
+              this.isLoading = false;
94
+            }
95
+            this.users = data.list;
89 96
           }
90
-          this.users = data.list;
91 97
         }
92
-      }
93
-    })
98
+      });
94 99
   }
95 100
 
96 101
   // 初始化权限按钮
97 102
   coopBtns: any = {
98
-    edit: false,//编辑
99
-    isStartUp: false//是否启用
103
+    edit: false, //编辑
104
+    isStartUp: false, //是否启用
100 105
   };
101 106
   initCoopBtns() {
102 107
     // 二级菜单
103
-    let secondMenus = []
104
-    this.menu.forEach(e => {
105
-      e.childrens.forEach(el => {
106
-        secondMenus.push(el)
108
+    let secondMenus = [];
109
+    this.menu.forEach((e) => {
110
+      e.childrens.forEach((el) => {
111
+        secondMenus.push(el);
107 112
       });
108 113
     });
109 114
     let link = this.route.parent.snapshot.routeConfig.path;
110
-    let btns = []
111
-    secondMenus.forEach(e => {
115
+    let btns = [];
116
+    secondMenus.forEach((e) => {
112 117
       if (e.link == link) {
113 118
         btns = e.childrens || [];
114 119
       }
115 120
     });
116
-    btns.forEach(e => {
121
+    btns.forEach((e) => {
117 122
       this.coopBtns[e.link] = true;
118
-    })
123
+    });
119 124
   }
120 125
 
121 126
   // 表格数据
@@ -125,20 +130,22 @@ export class TimingMessageSendingComponent implements OnInit {
125 130
       idx: this.pageIndex - 1,
126 131
       sum: this.pageSize,
127 132
       messageJob: {
128
-        hospital: this.hosId
129
-      }
130
-    }
133
+        hospital: this.hosId,
134
+      },
135
+    };
131 136
     this.loading1 = true;
132
-    this.mainService.getFetchDataList('simple/data', 'messageJob', postData).subscribe(data => {
133
-      this.loading1 = false;
134
-      if (data.status == 200) {
135
-        this.listOfData = data.list;
136
-        this.listOfData.forEach(item => {
137
-          item.usersName = item.users.map(value => value.name).join();
138
-        })
139
-        this.listLength = data.totalNum;
140
-      }
141
-    })
137
+    this.mainService
138
+      .getFetchDataList("simple/data", "messageJob", postData)
139
+      .subscribe((data) => {
140
+        this.loading1 = false;
141
+        if (data.status == 200) {
142
+          this.listOfData = data.list;
143
+          this.listOfData.forEach((item) => {
144
+            item.usersName = item.users.map((value) => value.name).join();
145
+          });
146
+          this.listLength = data.totalNum;
147
+        }
148
+      });
142 149
   }
143 150
   //关闭编辑弹框
144 151
   hideAddModal() {
@@ -148,10 +155,11 @@ export class TimingMessageSendingComponent implements OnInit {
148 155
   // 初始化form表单
149 156
   initForm() {
150 157
     this.validateForm = this.fb.group({
151
-      title: [null, [Validators.required]],//标题
152
-      executeTime: [null, [Validators.required]],//定时发送时间
153
-      active: [false, [Validators.required]],//是否启用
154
-      userIds: [null, [Validators.required]],//接收人
158
+      title: [null, [Validators.required]], //标题
159
+      xxx: [1, [Validators.required]], //重复策略
160
+      executeTime: [null, [Validators.required]], //定时发送时间
161
+      active: [false, [Validators.required]], //是否启用
162
+      userIds: [null, [Validators.required]], //接收人
155 163
     });
156 164
   }
157 165
 
@@ -165,7 +173,7 @@ export class TimingMessageSendingComponent implements OnInit {
165 173
     if (this.validateForm.invalid) {
166 174
       this.btnLoading = false;
167 175
       return;
168
-    };
176
+    }
169 177
     let postData = {
170 178
       title: this.validateForm.value.title,
171 179
       executeTime: new Date(this.validateForm.value.executeTime).getTime(),
@@ -174,46 +182,53 @@ export class TimingMessageSendingComponent implements OnInit {
174 182
       content: this.dataContent.content,
175 183
       key: this.dataContent.key,
176 184
       id: this.dataContent.id,
177
-      // sqlQuery:this.dataContent.sqlQuery
178 185
     };
179
-    this.mainService.simplePost('updData', 'messageJob', postData).subscribe(data => {
180
-      this.btnLoading = false;
181
-      this.hideAddModal();
182
-      this.initForm();
183
-      if (data.status == 200) {
184
-        this.listLength++;
185
-        this.showPromptModal('修改', true, '');
186
-      } else {
187
-        this.showPromptModal('修改', false, data.msg);
188
-      }
189
-    })
186
+    this.mainService
187
+      .simplePost("updData", "messageJob", postData)
188
+      .subscribe((data) => {
189
+        this.btnLoading = false;
190
+        this.hideAddModal();
191
+        this.initForm();
192
+        if (data.status == 200) {
193
+          this.listLength++;
194
+          this.showPromptModal("修改", true, "");
195
+        } else {
196
+          this.showPromptModal("修改", false, data.msg);
197
+        }
198
+      });
190 199
   }
191 200
 
192 201
   // 编辑
193 202
   maskFlag: any = false;
194 203
   edit(data) {
195 204
     this.dataContent = data;
196
-    this.validateForm.controls.executeTime.setValue(new Date(data.executeTime));//定时发送时间
197
-    this.validateForm.controls.title.setValue(data.title);//标题
198
-    this.validateForm.controls.active.setValue(data.active);//是否启用
205
+    this.validateForm.controls.executeTime.setValue(new Date(data.executeTime)); //定时发送时间
206
+    this.validateForm.controls.title.setValue(data.title); //标题
207
+    this.validateForm.controls.active.setValue(data.active); //是否启用
199 208
     // --------接收人---
200
-    this.maskFlag = this.message.loading('正在加载中..', { nzDuration: 0 }).messageId;
201
-    this.mainService.getFetchDataList('data', 'user', {
202
-      idx: 0,
203
-      sum: 20,
204
-      user: {
205
-        hosId: this.hosId
206
-      }
207
-    }).subscribe(result => {
208
-      this.message.remove(this.maskFlag);
209
-      this.maskFlag = false;
210
-      this.modal = true;
211
-      if (result.status == 200) {
212
-        let add = data.users.filter(item => !result.list.some(ele => ele.id == item.id));
213
-        this.users = add.concat(result.list);
214
-        this.validateForm.controls.userIds.setValue(data.userIds.split(','));//接收人
215
-      }
216
-    })
209
+    this.maskFlag = this.message.loading("正在加载中..", {
210
+      nzDuration: 0,
211
+    }).messageId;
212
+    this.mainService
213
+      .getFetchDataList("data", "user", {
214
+        idx: 0,
215
+        sum: 20,
216
+        user: {
217
+          hosId: this.hosId,
218
+        },
219
+      })
220
+      .subscribe((result) => {
221
+        this.message.remove(this.maskFlag);
222
+        this.maskFlag = false;
223
+        this.modal = true;
224
+        if (result.status == 200) {
225
+          let add = data.users.filter(
226
+            (item) => !result.list.some((ele) => ele.id == item.id)
227
+          );
228
+          this.users = add.concat(result.list);
229
+          this.validateForm.controls.userIds.setValue(data.userIds.split(",")); //接收人
230
+        }
231
+      });
217 232
     // --------/接收人---
218 233
   }
219 234
 
@@ -230,12 +245,18 @@ export class TimingMessageSendingComponent implements OnInit {
230 245
   }
231 246
 
232 247
   // 是否启用
233
-  delModal: boolean = false;//删除模态框
234
-  tipsMsg1: string;//提示框信息
235
-  tipsMsg2: string;//操作后信息
236
-  confirmDelType: string;//确认的类型(启用/停用,删除)
237
-  confirmDelIsSwitch: boolean;//启用/停用
238
-  showDelModal(dataContent, tipsMsg1: string, tipsMsg2: string, type: string, isSwitch?: boolean) {
248
+  delModal: boolean = false; //删除模态框
249
+  tipsMsg1: string; //提示框信息
250
+  tipsMsg2: string; //操作后信息
251
+  confirmDelType: string; //确认的类型(启用/停用,删除)
252
+  confirmDelIsSwitch: boolean; //启用/停用
253
+  showDelModal(
254
+    dataContent,
255
+    tipsMsg1: string,
256
+    tipsMsg2: string,
257
+    type: string,
258
+    isSwitch?: boolean
259
+  ) {
239 260
     this.confirmDelIsSwitch = isSwitch;
240 261
     this.confirmDelType = type;
241 262
     this.delModal = true;
@@ -250,7 +271,8 @@ export class TimingMessageSendingComponent implements OnInit {
250 271
   // 确认
251 272
   confirmDel() {
252 273
     this.btnLoading = true;
253
-    if (this.confirmDelType === 'switch') {//启用/停用
274
+    if (this.confirmDelType === "switch") {
275
+      //启用/停用
254 276
       let postData = {
255 277
         id: this.dataContent.id,
256 278
         title: this.dataContent.title,
@@ -260,17 +282,17 @@ export class TimingMessageSendingComponent implements OnInit {
260 282
         content: this.dataContent.content,
261 283
         key: this.dataContent.key,
262 284
       };
263
-      this.mainService.simplePost('updData', 'messageJob', postData).subscribe(data => {
264
-        this.btnLoading = false;
265
-        this.delModal = false;
266
-        if (data.status == 200) {
267
-          this.showPromptModal(this.tipsMsg2, true, '');
268
-        } else {
269
-          this.showPromptModal(this.tipsMsg2, false, data.msg);
270
-        }
271
-      })
285
+      this.mainService
286
+        .simplePost("updData", "messageJob", postData)
287
+        .subscribe((data) => {
288
+          this.btnLoading = false;
289
+          this.delModal = false;
290
+          if (data.status == 200) {
291
+            this.showPromptModal(this.tipsMsg2, true, "");
292
+          } else {
293
+            this.showPromptModal(this.tipsMsg2, false, data.msg);
294
+          }
295
+        });
272 296
     }
273 297
   }
274 298
 }
275
-
276
-