|
@@ -4,6 +4,9 @@ import { ActivatedRoute } from "@angular/router";
|
4
|
4
|
import { MainService } from "../../services/main.service";
|
5
|
5
|
import { ToolService } from "src/app/services/tool.service";
|
6
|
6
|
import { OverlayScrollbarsComponent } from 'overlayscrollbars-ngx';
|
|
7
|
+import { Observable, Observer } from 'rxjs';
|
|
8
|
+import { NzMessageService, UploadFile, UploadXHRArgs } from 'ng-zorro-antd';
|
|
9
|
+import { HttpRequest, HttpEventType, HttpEvent, HttpResponse, HttpClient } from '@angular/common/http';
|
7
|
10
|
|
8
|
11
|
@Component({
|
9
|
12
|
selector: "app-sys-config",
|
|
@@ -28,7 +31,9 @@ export class SysConfigComponent implements OnInit {
|
28
|
31
|
private mainService: MainService,
|
29
|
32
|
private fb: FormBuilder,
|
30
|
33
|
private route: ActivatedRoute,
|
31
|
|
- private tool: ToolService
|
|
34
|
+ private tool: ToolService,
|
|
35
|
+ private msg: NzMessageService,
|
|
36
|
+ private http: HttpClient
|
32
|
37
|
) {}
|
33
|
38
|
@ViewChild("osComponentRef1", {
|
34
|
39
|
read: OverlayScrollbarsComponent,
|
|
@@ -47,6 +52,9 @@ export class SysConfigComponent implements OnInit {
|
47
|
52
|
workOrderSettings: [5, [Validators.required]],
|
48
|
53
|
nurseDeptSwitchTip: [0, [Validators.required]],
|
49
|
54
|
updateTipsForNurses: [""],
|
|
55
|
+ systemName: ["", [Validators.required]],
|
|
56
|
+ largeScreenName: ["", [Validators.required]],
|
|
57
|
+ logo: ["", [Validators.required]],
|
50
|
58
|
defaultRoleOfNurse: [null, [Validators.required]],
|
51
|
59
|
formUrl: [{ value: null, disabled: true }, [Validators.required]],
|
52
|
60
|
serviceUrl: [{ value: null, disabled: true }, [Validators.required]],
|
|
@@ -57,7 +65,10 @@ export class SysConfigComponent implements OnInit {
|
57
|
65
|
this.getDeptType();
|
58
|
66
|
this.coopBtns = this.tool.initCoopBtns(this.route);
|
59
|
67
|
this.getRoleList();
|
|
68
|
+ this.avatarUrl = this.tool.logoUrl;
|
|
69
|
+ this.validateForm.controls.logo.setValue(this.tool.logoUrl);
|
60
|
70
|
}
|
|
71
|
+
|
61
|
72
|
// 角色列表
|
62
|
73
|
roleList = [];
|
63
|
74
|
getRoleList() {
|
|
@@ -98,6 +109,9 @@ export class SysConfigComponent implements OnInit {
|
98
|
109
|
this.validateForm.controls[i].markAsDirty();
|
99
|
110
|
this.validateForm.controls[i].updateValueAndValidity();
|
100
|
111
|
}
|
|
112
|
+ if (this.validateForm.invalid) {
|
|
113
|
+ return;
|
|
114
|
+ }
|
101
|
115
|
let filterData = this.initConfig.filter(
|
102
|
116
|
(item) =>
|
103
|
117
|
item.keyconfig === "pwd" ||
|
|
@@ -110,6 +124,8 @@ export class SysConfigComponent implements OnInit {
|
110
|
124
|
item.keyconfig === "workOrderSettings" ||
|
111
|
125
|
item.keyconfig === "nurseDeptSwitchTip" ||
|
112
|
126
|
item.keyconfig === "updateTipsForNurses" ||
|
|
127
|
+ item.keyconfig === "systemName" ||
|
|
128
|
+ item.keyconfig === "largeScreenName" ||
|
113
|
129
|
item.keyconfig === "defaultRoleOfNurse" ||
|
114
|
130
|
item.keyconfig === "busiViewDeptId"
|
115
|
131
|
);
|
|
@@ -136,6 +152,10 @@ export class SysConfigComponent implements OnInit {
|
136
|
152
|
item.valueconfig = this.validateForm.controls.nurseDeptSwitchTip.value;
|
137
|
153
|
} else if (item.keyconfig === "updateTipsForNurses") {
|
138
|
154
|
item.valueconfig = this.validateForm.controls.updateTipsForNurses.value;
|
|
155
|
+ } else if (item.keyconfig === "systemName") {
|
|
156
|
+ item.valueconfig = this.validateForm.controls.systemName.value;
|
|
157
|
+ } else if (item.keyconfig === "largeScreenName") {
|
|
158
|
+ item.valueconfig = this.validateForm.controls.largeScreenName.value;
|
139
|
159
|
} else if (item.keyconfig === "defaultRoleOfNurse") {
|
140
|
160
|
item.valueconfig = this.validateForm.controls.defaultRoleOfNurse.value;
|
141
|
161
|
} else if (item.keyconfig === "busiViewDeptId") {
|
|
@@ -220,6 +240,12 @@ export class SysConfigComponent implements OnInit {
|
220
|
240
|
case "updateTipsForNurses":
|
221
|
241
|
this.validateForm.controls.updateTipsForNurses.setValue(c[1]);
|
222
|
242
|
break;
|
|
243
|
+ case "systemName":
|
|
244
|
+ this.validateForm.controls.systemName.setValue(c[1]);
|
|
245
|
+ break;
|
|
246
|
+ case "largeScreenName":
|
|
247
|
+ this.validateForm.controls.largeScreenName.setValue(c[1]);
|
|
248
|
+ break;
|
223
|
249
|
case "defaultRoleOfNurse":
|
224
|
250
|
this.validateForm.controls.defaultRoleOfNurse.setValue(
|
225
|
251
|
c[1] - 0
|
|
@@ -260,4 +286,94 @@ export class SysConfigComponent implements OnInit {
|
260
|
286
|
}, 100);
|
261
|
287
|
this.getDeptType();
|
262
|
288
|
}
|
|
289
|
+
|
|
290
|
+ avatarLoading = false;
|
|
291
|
+ avatarUrl: string;
|
|
292
|
+ beforeUpload = (file: File) => {
|
|
293
|
+ return new Observable((observer: Observer<boolean>) => {
|
|
294
|
+ const isPic = (file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'image/jpg');
|
|
295
|
+ if (!isPic) {
|
|
296
|
+ this.msg.error('只能上传jpg|jpeg|png图片!');
|
|
297
|
+ observer.complete();
|
|
298
|
+ return;
|
|
299
|
+ }
|
|
300
|
+ const isLt2M = file.size / 1024 / 1024 < 2;
|
|
301
|
+ if (!isLt2M) {
|
|
302
|
+ this.msg.error('图片大小不能大于2MB!');
|
|
303
|
+ observer.complete();
|
|
304
|
+ return;
|
|
305
|
+ }
|
|
306
|
+ observer.next(isPic && isLt2M);
|
|
307
|
+ observer.complete();
|
|
308
|
+ });
|
|
309
|
+ };
|
|
310
|
+
|
|
311
|
+ private getBase64(img: File, callback: (img: string) => void): void {
|
|
312
|
+ const reader = new FileReader();
|
|
313
|
+ reader.addEventListener('load', () => callback(reader.result!.toString()));
|
|
314
|
+ reader.readAsDataURL(img);
|
|
315
|
+ }
|
|
316
|
+
|
|
317
|
+ private checkImageDimension(file: File): Promise<boolean> {
|
|
318
|
+ return new Promise(resolve => {
|
|
319
|
+ const img = new Image(); // create image
|
|
320
|
+ img.src = window.URL.createObjectURL(file);
|
|
321
|
+ img.onload = () => {
|
|
322
|
+ const width = img.naturalWidth;
|
|
323
|
+ const height = img.naturalHeight;
|
|
324
|
+ window.URL.revokeObjectURL(img.src!);
|
|
325
|
+ resolve(width === height && width >= 300);
|
|
326
|
+ };
|
|
327
|
+ });
|
|
328
|
+ }
|
|
329
|
+
|
|
330
|
+ handleChange(info: { file: UploadFile }): void {
|
|
331
|
+ switch (info.file.status) {
|
|
332
|
+ case 'uploading':
|
|
333
|
+ this.avatarLoading = true;
|
|
334
|
+ break;
|
|
335
|
+ case 'done':
|
|
336
|
+ // Get this url from response in real world.
|
|
337
|
+ this.getBase64(info.file!.originFileObj!, (img: string) => {
|
|
338
|
+ this.avatarLoading = false;
|
|
339
|
+ this.avatarUrl = img;
|
|
340
|
+ });
|
|
341
|
+ break;
|
|
342
|
+ case 'error':
|
|
343
|
+ this.msg.error('Network error');
|
|
344
|
+ this.avatarLoading = false;
|
|
345
|
+ break;
|
|
346
|
+ }
|
|
347
|
+ }
|
|
348
|
+
|
|
349
|
+ customReq = (item: UploadXHRArgs) => {
|
|
350
|
+ console.log(item);
|
|
351
|
+ // Create a FormData here to store files and other parameters.
|
|
352
|
+ const formData = new FormData();
|
|
353
|
+ // tslint:disable-next-line:no-any
|
|
354
|
+ formData.append('file', item.file as any);
|
|
355
|
+ formData.append('filename', item.file.name);
|
|
356
|
+ const req = new HttpRequest('POST', item.action!, formData, {
|
|
357
|
+ reportProgress: true,
|
|
358
|
+ withCredentials: true
|
|
359
|
+ });
|
|
360
|
+ // Always returns a `Subscription` object. nz-upload would automatically unsubscribe it at correct time.
|
|
361
|
+ return this.http.request(req).subscribe(
|
|
362
|
+ // tslint:disable-next-line no-any
|
|
363
|
+ (event: HttpEvent<any>) => {
|
|
364
|
+ if (event.type === HttpEventType.UploadProgress) {
|
|
365
|
+ if (event.total! > 0) {
|
|
366
|
+ // tslint:disable-next-line:no-any
|
|
367
|
+ (event as any).percent = (event.loaded / event.total!) * 100;
|
|
368
|
+ }
|
|
369
|
+ item.onProgress!(event, item.file!);
|
|
370
|
+ } else if (event instanceof HttpResponse) {
|
|
371
|
+ item.onSuccess!(event.body, item.file!, event);
|
|
372
|
+ }
|
|
373
|
+ },
|
|
374
|
+ err => {
|
|
375
|
+ item.onError!(err, item.file!);
|
|
376
|
+ }
|
|
377
|
+ );
|
|
378
|
+ };
|
263
|
379
|
}
|