|
@@ -0,0 +1,466 @@
|
|
1
|
+import { Component, OnInit } from "@angular/core";
|
|
2
|
+import { ActivatedRoute, Router } from "@angular/router";
|
|
3
|
+import { FormBuilder, Validators, FormGroup } from "@angular/forms";
|
|
4
|
+import setSeconds from "date-fns/setSeconds";
|
|
5
|
+import setMinutes from "date-fns/setMinutes";
|
|
6
|
+import setHours from "date-fns/setHours";
|
|
7
|
+
|
|
8
|
+import { MainService } from "../../services/main.service";
|
|
9
|
+import { DisabledTimeFn } from "ng-zorro-antd/date-picker/standard-types";
|
|
10
|
+import { ToolService } from "../../services/tool.service";
|
|
11
|
+@Component({
|
|
12
|
+ selector: "app-questionnaire-management",
|
|
13
|
+ templateUrl: "./questionnaire-management.component.html",
|
|
14
|
+ styleUrls: ["./questionnaire-management.component.less"],
|
|
15
|
+})
|
|
16
|
+export class QuestionnaireManagementComponent implements OnInit {
|
|
17
|
+ constructor(
|
|
18
|
+ private fb: FormBuilder,
|
|
19
|
+ private mainService: MainService,
|
|
20
|
+ private route: ActivatedRoute,
|
|
21
|
+ private router: Router,
|
|
22
|
+ private tool: ToolService
|
|
23
|
+ ) {}
|
|
24
|
+
|
|
25
|
+ userInfo: any = JSON.parse(localStorage.getItem("user")) || {}; //登录用户信息
|
|
26
|
+ listOfData: any[] = []; //表格数据
|
|
27
|
+ pageIndex: number = 1; //表格当前页码
|
|
28
|
+ pageSize: number = 10; //表格每页展示条数
|
|
29
|
+ listLength: number = 10; //表格总数据量
|
|
30
|
+ tableHeight: number; //表格动态高
|
|
31
|
+ modal: boolean = false; //新增/编辑模态框
|
|
32
|
+ dateModal: boolean = false; //定时启用设置日期模态框
|
|
33
|
+ add: boolean; //true:新增;false:编辑
|
|
34
|
+ validateForm: FormGroup; //新增/编辑表单
|
|
35
|
+ validateDateForm: FormGroup; //定时启动设置日期表单
|
|
36
|
+ coopId: any; //当前操作列
|
|
37
|
+ currentHospital; //当前院区
|
|
38
|
+ timeDefaultValue = setHours(setMinutes(setSeconds(new Date(), 0), 0), 0);
|
|
39
|
+
|
|
40
|
+ btnLoading: boolean = false; //提交按钮loading状态
|
|
41
|
+
|
|
42
|
+ promptContent: string; //操作提示框提示信息
|
|
43
|
+ ifSuccess: boolean; //操作成功/失败
|
|
44
|
+ promptInfo: string; //操作结果提示信息
|
|
45
|
+ promptModalShow: boolean; //操作提示框是否展示
|
|
46
|
+ nextSchemeName = ""; //下一个开启的方案名称
|
|
47
|
+ modelName = ""; //模态框名称
|
|
48
|
+
|
|
49
|
+ ngOnInit() {
|
|
50
|
+ this.currentHospital = this.tool.getCurrentHospital();
|
|
51
|
+ this.coopBtns = this.tool.initCoopBtns(this.route);
|
|
52
|
+ this.initForm();
|
|
53
|
+ this.getList(1);
|
|
54
|
+ this.getSurveyTarget();
|
|
55
|
+ }
|
|
56
|
+
|
|
57
|
+ // 初始化增删改按钮
|
|
58
|
+ coopBtns: any = {};
|
|
59
|
+
|
|
60
|
+ // 获取字典数据-调查目标
|
|
61
|
+ surveyTargets: any[] = [];
|
|
62
|
+ getSurveyTarget() {
|
|
63
|
+ this.mainService
|
|
64
|
+ .getDictionary("list", "survey_target")
|
|
65
|
+ .subscribe((data) => {
|
|
66
|
+ this.surveyTargets = data;
|
|
67
|
+ });
|
|
68
|
+ }
|
|
69
|
+
|
|
70
|
+ // 表格数据
|
|
71
|
+ loading1 = false;
|
|
72
|
+ getList(type) {
|
|
73
|
+ if (type == 1) {
|
|
74
|
+ this.pageIndex = 1;
|
|
75
|
+ }
|
|
76
|
+ let data = {
|
|
77
|
+ idx: this.pageIndex - 1,
|
|
78
|
+ sum: this.pageSize,
|
|
79
|
+ workScheme: {
|
|
80
|
+ hosId: this.currentHospital.id,
|
|
81
|
+ },
|
|
82
|
+ };
|
|
83
|
+ this.loading1 = true;
|
|
84
|
+ this.mainService
|
|
85
|
+ .getFetchDataList("configuration", "workScheme", data)
|
|
86
|
+ .subscribe((data) => {
|
|
87
|
+ this.loading1 = false;
|
|
88
|
+ if (data.status == 200) {
|
|
89
|
+ this.listOfData = data.list;
|
|
90
|
+ this.listLength = data.totalNum;
|
|
91
|
+ }
|
|
92
|
+ });
|
|
93
|
+ }
|
|
94
|
+
|
|
95
|
+ // 新增弹框
|
|
96
|
+ addModal() {
|
|
97
|
+ this.modelName = "新增";
|
|
98
|
+ this.add = true; //新增
|
|
99
|
+ this.modal = true;
|
|
100
|
+ this.copyModel = false;
|
|
101
|
+ this.initForm();
|
|
102
|
+ }
|
|
103
|
+ //关闭新增/编辑弹框
|
|
104
|
+ hideAddModal() {
|
|
105
|
+ this.modal = false;
|
|
106
|
+ this.initForm();
|
|
107
|
+ }
|
|
108
|
+ // 新增/编辑弹框
|
|
109
|
+ timeFlag = ""; //open开启,close关闭
|
|
110
|
+ addDateModal(data) {
|
|
111
|
+ if (!data.timingStatus) {
|
|
112
|
+ this.datePicker = "";
|
|
113
|
+ }
|
|
114
|
+ this.timeFlag = data.timingStatus ? "close" : "open";
|
|
115
|
+ this.coopId = data;
|
|
116
|
+ if (this.timeFlag == "close") {
|
|
117
|
+ this.showDelModal(
|
|
118
|
+ data,
|
|
119
|
+ "是否确定关闭定时启用?确定后该方案将不会执行!",
|
|
120
|
+ "关闭定时启用",
|
|
121
|
+ "switchTime"
|
|
122
|
+ );
|
|
123
|
+ } else {
|
|
124
|
+ this.dateModal = true;
|
|
125
|
+ }
|
|
126
|
+ this.initDateForm();
|
|
127
|
+ }
|
|
128
|
+ //关闭定时启用设置日期弹框
|
|
129
|
+ hideDateModal() {
|
|
130
|
+ this.dateModal = false;
|
|
131
|
+ this.initDateForm();
|
|
132
|
+ }
|
|
133
|
+ // 初始化新增form表单
|
|
134
|
+ initForm() {
|
|
135
|
+ this.validateForm = this.fb.group({
|
|
136
|
+ title: [null, [Validators.required]],
|
|
137
|
+ surveyTarget: [null, [Validators.required]],
|
|
138
|
+ surveyDescribe: [null, [Validators.required]],
|
|
139
|
+ });
|
|
140
|
+ }
|
|
141
|
+ // 初始化新增form表单
|
|
142
|
+ initDateForm() {
|
|
143
|
+ this.validateDateForm = this.fb.group({
|
|
144
|
+ datePickerTime: [null, [Validators.required]],
|
|
145
|
+ });
|
|
146
|
+ }
|
|
147
|
+
|
|
148
|
+ // 新增/编辑表单提交
|
|
149
|
+ btnLoading1 = false; //完成
|
|
150
|
+ submitForm(noGoTo?): void {
|
|
151
|
+ for (const i in this.validateForm.controls) {
|
|
152
|
+ this.validateForm.controls[i].markAsDirty();
|
|
153
|
+ this.validateForm.controls[i].updateValueAndValidity();
|
|
154
|
+ }
|
|
155
|
+ if (this.validateForm.invalid) {
|
|
156
|
+ return;
|
|
157
|
+ }
|
|
158
|
+ if (noGoTo) {
|
|
159
|
+ this.btnLoading1 = true;
|
|
160
|
+ } else {
|
|
161
|
+ this.btnLoading = true;
|
|
162
|
+ }
|
|
163
|
+ let data = {};
|
|
164
|
+
|
|
165
|
+ if (this.add) {
|
|
166
|
+ //增加
|
|
167
|
+ data = {
|
|
168
|
+ questionnaireManagement: {
|
|
169
|
+ title: this.validateForm.value.title,
|
|
170
|
+ surveyTarget: { id: parseInt(this.validateForm.value.surveyTarget) },
|
|
171
|
+ surveyDescribe: this.validateForm.value.surveyDescribe,
|
|
172
|
+ hosId: this.currentHospital.id,
|
|
173
|
+ },
|
|
174
|
+ };
|
|
175
|
+ } else {
|
|
176
|
+ //编辑
|
|
177
|
+ data = {
|
|
178
|
+ questionnaireManagement: {
|
|
179
|
+ id: this.coopId.id,
|
|
180
|
+ title: this.validateForm.value.title,
|
|
181
|
+ surveyTarget: this.validateForm.value.surveyTarget,
|
|
182
|
+ surveyDescribe: this.validateForm.value.surveyDescribe,
|
|
183
|
+ hosId: this.currentHospital.id,
|
|
184
|
+ },
|
|
185
|
+ };
|
|
186
|
+ }
|
|
187
|
+ if (this.copyModel) {
|
|
188
|
+ //复制
|
|
189
|
+ data = {
|
|
190
|
+ workScheme: {
|
|
191
|
+ name: this.validateForm.value.title,
|
|
192
|
+ workType: this.validateForm.value.surveyTarget,
|
|
193
|
+ describe: this.validateForm.value.surveyDescribe,
|
|
194
|
+ status: 0,
|
|
195
|
+ copy: 1,
|
|
196
|
+ copySchemeId: this.coopId.id,
|
|
197
|
+ hosId: this.currentHospital.id,
|
|
198
|
+ },
|
|
199
|
+ };
|
|
200
|
+ }
|
|
201
|
+ this.mainService
|
|
202
|
+ .apiPost("addData", "questionnaireManagement", data)
|
|
203
|
+ .subscribe((result) => {
|
|
204
|
+ if (noGoTo) {
|
|
205
|
+ this.btnLoading1 = false;
|
|
206
|
+ } else {
|
|
207
|
+ this.btnLoading = false;
|
|
208
|
+ }
|
|
209
|
+ this.hideAddModal();
|
|
210
|
+ this.initForm();
|
|
211
|
+ if (result.status == 200) {
|
|
212
|
+ if (this.copyModel) {
|
|
213
|
+ //复制
|
|
214
|
+ this.listLength++;
|
|
215
|
+ this.showPromptModal("复制", true, "");
|
|
216
|
+ if (!noGoTo) {
|
|
217
|
+ this.router.navigateByUrl(
|
|
218
|
+ `/main/quickCombination?id=${result.data.id}&name=${result.data.name}&type=${result.data.workType}`
|
|
219
|
+ );
|
|
220
|
+ }
|
|
221
|
+ return;
|
|
222
|
+ }
|
|
223
|
+ if (!this.add) {
|
|
224
|
+ //编辑
|
|
225
|
+ this.showPromptModal("编辑", true, "");
|
|
226
|
+ if (!noGoTo) {
|
|
227
|
+ this.router.navigateByUrl(
|
|
228
|
+ `/main/quickCombination?id=${result.data.id}&name=${result.data.name}&type=${result.data.workType}`
|
|
229
|
+ );
|
|
230
|
+ }
|
|
231
|
+ return;
|
|
232
|
+ }
|
|
233
|
+ if (this.add) {
|
|
234
|
+ this.listLength++;
|
|
235
|
+ }
|
|
236
|
+ return;
|
|
237
|
+ this.router.navigateByUrl(
|
|
238
|
+ `/main/quickCombination?id=${result.data.id}&name=${result.data.name}&type=${result.data.workType}`
|
|
239
|
+ );
|
|
240
|
+ } else {
|
|
241
|
+ let msg = "";
|
|
242
|
+ if (this.add) {
|
|
243
|
+ msg = "新增";
|
|
244
|
+ } else {
|
|
245
|
+ msg = "修改";
|
|
246
|
+ }
|
|
247
|
+ if (this.copyModel) {
|
|
248
|
+ msg = "复制";
|
|
249
|
+ }
|
|
250
|
+ this.showPromptModal(msg, false, result.msg);
|
|
251
|
+ }
|
|
252
|
+ });
|
|
253
|
+ }
|
|
254
|
+ // 时间选择范围
|
|
255
|
+ disabledDateTime: DisabledTimeFn = () => {
|
|
256
|
+ return {
|
|
257
|
+ nzDisabledHours: () => [],
|
|
258
|
+ nzDisabledMinutes: () => [],
|
|
259
|
+ nzDisabledSeconds: () => this.range(1, 60),
|
|
260
|
+ };
|
|
261
|
+ };
|
|
262
|
+ range(start: number, end: number): number[] {
|
|
263
|
+ const result: number[] = [];
|
|
264
|
+ for (let i = start; i < end; i++) {
|
|
265
|
+ result.push(i);
|
|
266
|
+ }
|
|
267
|
+ return result;
|
|
268
|
+ }
|
|
269
|
+ // 选择日期表单提交
|
|
270
|
+ submitDateForm(): void {
|
|
271
|
+ this.btnLoading = true;
|
|
272
|
+ for (const i in this.validateDateForm.controls) {
|
|
273
|
+ this.validateDateForm.controls[i].markAsDirty();
|
|
274
|
+ this.validateDateForm.controls[i].updateValueAndValidity();
|
|
275
|
+ }
|
|
276
|
+ if (this.validateDateForm.invalid) {
|
|
277
|
+ this.btnLoading = false;
|
|
278
|
+ return;
|
|
279
|
+ }
|
|
280
|
+ let data = {};
|
|
281
|
+ let todayDate = new Date(this.validateDateForm.value.datePickerTime);
|
|
282
|
+ let year = todayDate.getFullYear();
|
|
283
|
+ let month = (todayDate.getMonth() + 1).toString().padStart(2, "0");
|
|
284
|
+ let date = todayDate.getDate().toString().padStart(2, "0");
|
|
285
|
+ let hour = todayDate.getHours().toString().padStart(2, "0");
|
|
286
|
+ let minutes = todayDate.getMinutes().toString().padStart(2, "0");
|
|
287
|
+ // 2020-07-28 16:45:00
|
|
288
|
+ data = {
|
|
289
|
+ workScheme: {
|
|
290
|
+ id: this.coopId.id,
|
|
291
|
+ timingStatus: 1,
|
|
292
|
+ startTime: `${year}-${month}-${date} ${hour}:${minutes}:00`,
|
|
293
|
+ hosId: this.currentHospital.id,
|
|
294
|
+ },
|
|
295
|
+ };
|
|
296
|
+ this.mainService
|
|
297
|
+ .coopTypeConfig("addData", "workScheme", data)
|
|
298
|
+ .subscribe((data) => {
|
|
299
|
+ this.btnLoading = false;
|
|
300
|
+ this.hideDateModal();
|
|
301
|
+ this.initDateForm();
|
|
302
|
+ if (data.status == 200) {
|
|
303
|
+ this.listLength++;
|
|
304
|
+ this.showPromptModal("定时启用时间设置", true, "");
|
|
305
|
+ } else {
|
|
306
|
+ this.showPromptModal("定时启用时间设置", false, data.msg);
|
|
307
|
+ }
|
|
308
|
+ });
|
|
309
|
+ }
|
|
310
|
+
|
|
311
|
+ // 编辑
|
|
312
|
+ edit(data) {
|
|
313
|
+ console.log(data);
|
|
314
|
+ this.modelName = "编辑";
|
|
315
|
+ this.add = false;
|
|
316
|
+ this.modal = true;
|
|
317
|
+ this.coopId = data;
|
|
318
|
+ this.copyModel = false;
|
|
319
|
+ this.validateForm.controls.title.setValue(data.name); //名称
|
|
320
|
+ this.validateForm.controls.surveyTarget.setValue(data.workType + ""); //类型
|
|
321
|
+ this.validateForm.controls.surveyDescribe.setValue(data.describe); //描述
|
|
322
|
+ }
|
|
323
|
+ //复制
|
|
324
|
+ copyModel = false; //复制
|
|
325
|
+ copy(data) {
|
|
326
|
+ this.modelName = "复制";
|
|
327
|
+ this.copyModel = true;
|
|
328
|
+ this.modal = true;
|
|
329
|
+ this.coopId = data;
|
|
330
|
+ this.validateForm.controls.title.setValue(data.name); //名称
|
|
331
|
+ this.validateForm.controls.surveyTarget.setValue(data.workType + ""); //类型
|
|
332
|
+ this.validateForm.controls.surveyDescribe.setValue(data.describe); //描述
|
|
333
|
+ }
|
|
334
|
+
|
|
335
|
+ // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
|
|
336
|
+ // promptModalUrl = '';
|
|
337
|
+ showPromptModal(con, success, promptInfo?) {
|
|
338
|
+ this.promptModalShow = false;
|
|
339
|
+ this.promptContent = con;
|
|
340
|
+ this.ifSuccess = success;
|
|
341
|
+ this.promptInfo = promptInfo;
|
|
342
|
+ // this.promptModalUrl = url;
|
|
343
|
+ setTimeout(() => {
|
|
344
|
+ this.promptModalShow = true;
|
|
345
|
+ }, 100);
|
|
346
|
+ this.getList(0);
|
|
347
|
+ }
|
|
348
|
+
|
|
349
|
+ // 启用
|
|
350
|
+ delModal: boolean = false; //删除模态框
|
|
351
|
+ tipsMsg1: string; //提示框信息
|
|
352
|
+ tipsMsg2: string; //操作后信息
|
|
353
|
+ confirmDelType: string; //确认的类型(启用/停用,删除)
|
|
354
|
+ confirmDelIsSwitch: boolean; //启用/停用
|
|
355
|
+ showDelModal(
|
|
356
|
+ data,
|
|
357
|
+ tipsMsg1: string,
|
|
358
|
+ tipsMsg2: string,
|
|
359
|
+ type: string,
|
|
360
|
+ isSwitch?: boolean
|
|
361
|
+ ) {
|
|
362
|
+ this.confirmDelIsSwitch = isSwitch;
|
|
363
|
+ this.confirmDelType = type;
|
|
364
|
+ this.delModal = true;
|
|
365
|
+ this.coopId = data;
|
|
366
|
+ this.tipsMsg1 = tipsMsg1;
|
|
367
|
+ this.tipsMsg2 = tipsMsg2;
|
|
368
|
+ }
|
|
369
|
+ // 隐藏删除框
|
|
370
|
+ hideDelModal() {
|
|
371
|
+ this.delModal = false;
|
|
372
|
+ }
|
|
373
|
+ // 确认删除
|
|
374
|
+ confirmDel() {
|
|
375
|
+ this.btnLoading = true;
|
|
376
|
+ if (this.confirmDelType === "del") {
|
|
377
|
+ //删除
|
|
378
|
+ this.mainService
|
|
379
|
+ .coopTypeConfig("rmvData", "workScheme", [this.coopId.id])
|
|
380
|
+ .subscribe((data) => {
|
|
381
|
+ this.btnLoading = false;
|
|
382
|
+ this.delModal = false;
|
|
383
|
+ if (data.status == 200) {
|
|
384
|
+ if (
|
|
385
|
+ this.listOfData.length == 1 &&
|
|
386
|
+ this.pageIndex == Math.ceil(this.listLength / this.pageSize)
|
|
387
|
+ ) {
|
|
388
|
+ this.listLength--;
|
|
389
|
+ if (this.listLength === 0) {
|
|
390
|
+ this.pageIndex = 1;
|
|
391
|
+ } else {
|
|
392
|
+ this.pageIndex = Math.ceil(this.listLength / this.pageSize);
|
|
393
|
+ }
|
|
394
|
+ }
|
|
395
|
+ this.showPromptModal(this.tipsMsg2, true, "");
|
|
396
|
+ } else {
|
|
397
|
+ this.showPromptModal(this.tipsMsg2, false, data.msg);
|
|
398
|
+ }
|
|
399
|
+ });
|
|
400
|
+ } else if (this.confirmDelType === "switch") {
|
|
401
|
+ //启用
|
|
402
|
+ let data = {
|
|
403
|
+ workScheme: {
|
|
404
|
+ id: this.coopId.id,
|
|
405
|
+ hosId: this.currentHospital.id,
|
|
406
|
+ status: 1,
|
|
407
|
+ workType: this.coopId.workType,
|
|
408
|
+ },
|
|
409
|
+ };
|
|
410
|
+ this.mainService
|
|
411
|
+ .coopConfig("activeWorkScheme", data)
|
|
412
|
+ .subscribe((result) => {
|
|
413
|
+ this.btnLoading = false;
|
|
414
|
+ this.delModal = false;
|
|
415
|
+ if (result.status == 200) {
|
|
416
|
+ this.showPromptModal(this.tipsMsg2, true, "");
|
|
417
|
+ } else {
|
|
418
|
+ this.showPromptModal(this.tipsMsg2, false, result.msg);
|
|
419
|
+ }
|
|
420
|
+ });
|
|
421
|
+ } else if (this.confirmDelType === "switchTime") {
|
|
422
|
+ //关闭定时启用
|
|
423
|
+ let data = {
|
|
424
|
+ workScheme: {
|
|
425
|
+ id: this.coopId.id,
|
|
426
|
+ hosId: this.currentHospital.id,
|
|
427
|
+ timingStatus: 0,
|
|
428
|
+ },
|
|
429
|
+ };
|
|
430
|
+ this.mainService
|
|
431
|
+ .coopTypeConfig("addData", "workScheme", data)
|
|
432
|
+ .subscribe((result) => {
|
|
433
|
+ this.btnLoading = false;
|
|
434
|
+ this.delModal = false;
|
|
435
|
+ if (result.status == 200) {
|
|
436
|
+ this.showPromptModal(this.tipsMsg2, true, "");
|
|
437
|
+ } else {
|
|
438
|
+ this.showPromptModal(this.tipsMsg2, false, result.msg);
|
|
439
|
+ }
|
|
440
|
+ });
|
|
441
|
+ }
|
|
442
|
+ }
|
|
443
|
+
|
|
444
|
+ // 查看
|
|
445
|
+ detail(id) {
|
|
446
|
+ this.router.navigateByUrl(
|
|
447
|
+ "/main/workAssignment/workAssignmentDetail/" + id
|
|
448
|
+ );
|
|
449
|
+ }
|
|
450
|
+ //时间选择框相关
|
|
451
|
+ defaultTimePickerOpenValue = new Date();
|
|
452
|
+ // 更改日期
|
|
453
|
+ datePicker;
|
|
454
|
+ datePickerChange(e) {
|
|
455
|
+ if (!e) {
|
|
456
|
+ return;
|
|
457
|
+ }
|
|
458
|
+ let todayDate = new Date(e);
|
|
459
|
+ let year = todayDate.getFullYear();
|
|
460
|
+ let month = (todayDate.getMonth() + 1).toString().padStart(2, "0");
|
|
461
|
+ let date = todayDate.getDate().toString().padStart(2, "0");
|
|
462
|
+ let hour = todayDate.getHours().toString().padStart(2, "0");
|
|
463
|
+ let minutes = todayDate.getMinutes().toString().padStart(2, "0");
|
|
464
|
+ this.datePicker = `${year}-${month}-${date} ${hour}:${minutes}:00`;
|
|
465
|
+ }
|
|
466
|
+}
|