seimin 1 year ago
parent
commit
ee771fb6d7

+ 1 - 1
proxy.conf.json

@@ -1,6 +1,6 @@
1 1
 {
2 2
   "/service": {
3
-    "target": "http://192.168.4.240",
3
+    "target": "http://192.168.3.108",
4 4
     "logLevel": "debug",
5 5
     "changeOrigin": true,
6 6
     "pathRewrite": {

+ 4 - 0
src/app/services/main.service.ts

@@ -694,4 +694,8 @@ export class MainService {
694 694
       }
695 695
     );
696 696
   }
697
+  // 获取logo和title
698
+  getSysNameAndLogo(): any {
699
+    return this.http.get(host.host + "/auth/getSysNameAndLogo", {});
700
+  }
697 701
 }

+ 15 - 3
src/app/services/tool.service.ts

@@ -5,9 +5,21 @@ import { MainService } from "./main.service";
5 5
   providedIn: "root",
6 6
 })
7 7
 export class ToolService {
8
-  constructor(private mainService: MainService) {}
9
-  logoUrl = '/assets/images/login_logo.png';
10
-  logoTitle = '大势医院输送保障管理平台';
8
+  logoUrl = '';
9
+  logoTitle = '';
10
+
11
+  constructor(private mainService: MainService) {
12
+    this.getSysNameAndLogo();
13
+  }
14
+
15
+  // 获取logoUrl和logoTitle
16
+  getSysNameAndLogo(){
17
+    this.mainService.getSysNameAndLogo().subscribe(result => {
18
+      console.log(result);
19
+      this.logoTitle = result.sysName || '大势医院输送保障管理平台';
20
+      this.logoUrl = result.logo || '/assets/images/login_logo.png';
21
+    })
22
+  }
11 23
 
12 24
   // 获取权限中的院区
13 25
   getHospitalList() {

+ 3 - 1
src/app/share/share.module.ts

@@ -1,6 +1,7 @@
1 1
 import { NgModule } from '@angular/core';
2 2
 import { CommonModule } from '@angular/common';
3 3
 import { NgZorroAntdModule } from 'ng-zorro-antd';
4
+import { NzIconModule } from 'ng-zorro-antd/icon';
4 5
 import { FormsModule, ReactiveFormsModule } from '@angular/forms';
5 6
 import { NgxEchartsModule } from 'ngx-echarts';
6 7
 import { OverlayscrollbarsModule } from 'overlayscrollbars-ngx';
@@ -84,7 +85,8 @@ import { BloodHistoryPromptModalComponent } from './blood-history-prompt-modal/b
84 85
     ReactiveFormsModule,
85 86
     NgxEchartsModule,
86 87
     OverlayscrollbarsModule,
87
-    SortablejsModule
88
+    SortablejsModule,
89
+    NzIconModule,
88 90
   ],
89 91
   exports: [
90 92
     DetailSampleComponent,

+ 33 - 0
src/app/views/sys-config/sys-config.component.html

@@ -5,6 +5,39 @@
5 5
       <div class="form">
6 6
         <h3>基本配置</h3>
7 7
         <nz-form-item class="formItem">
8
+          <nz-form-label [nzSpan]="24" nzFor="systemName" nzRequired class="label">系统名称</nz-form-label>
9
+          <nz-form-control [nzSpan]="24" nzErrorTip="请输入系统名称!">
10
+            <input nz-input formControlName="systemName" id="systemName" placeholder="请输入系统名称">
11
+          </nz-form-control>
12
+        </nz-form-item>
13
+        <nz-form-item class="formItem">
14
+          <nz-form-label [nzSpan]="24" nzFor="largeScreenName" nzRequired class="label">名称</nz-form-label>
15
+          <nz-form-control [nzSpan]="24" nzErrorTip="请输入名称!">
16
+            <input nz-input formControlName="largeScreenName" id="largeScreenName" placeholder="请输入名称">
17
+          </nz-form-control>
18
+        </nz-form-item>
19
+        <nz-form-item class="formItem">
20
+          <nz-form-label [nzSpan]="24" class="label" nzFor="logo" nzRequired>系统logo</nz-form-label>
21
+          <nz-form-control [nzSpan]="24" nzErrorTip="请选择系统logo!">
22
+            <nz-upload nzFor="logo"
23
+              class="avatar-uploader"
24
+              nzAction="/service/common/common/uploadAttachment/sysLogo/777/777" 
25
+              [nzCustomRequest]="customReq"
26
+              nzName="file"
27
+              nzListType="picture-card"
28
+              [nzShowUploadList]="false"
29
+              [nzBeforeUpload]="beforeUpload"
30
+              (nzChange)="handleChange($event)"
31
+            >
32
+              <ng-container *ngIf="!avatarUrl">
33
+                <i class="upload-icon" nz-icon [nzType]="avatarLoading ? 'avatarLoading' : 'plus'"></i>
34
+                <div class="ant-upload-text">点击上传</div>
35
+              </ng-container>
36
+              <img *ngIf="avatarUrl" [src]="avatarUrl" class="avatar" />
37
+            </nz-upload>
38
+          </nz-form-control>
39
+        </nz-form-item>
40
+        <nz-form-item class="formItem">
8 41
           <nz-form-label [nzSpan]="24" nzFor="defaultPwd" nzRequired class="label">用户默认密码</nz-form-label>
9 42
           <nz-form-control [nzSpan]="24" nzErrorTip="请输入用户默认密码!">
10 43
             <input nz-input formControlName="defaultPwd" id="defaultPwd" placeholder="请输入用户默认密码">

+ 12 - 0
src/app/views/sys-config/sys-config.component.less

@@ -3,6 +3,18 @@
3 3
   display: flex;
4 4
   flex-direction: column;
5 5
   justify-content: space-between;
6
+  .avatar {
7
+    width: 128px;
8
+    height: 128px;
9
+  }
10
+  .upload-icon {
11
+    font-size: 32px;
12
+    color: #999;
13
+  }
14
+  .ant-upload-text {
15
+    margin-top: 8px;
16
+    color: #666;
17
+  }
6 18
   .main {
7 19
     height: calc(100vh - 161px);
8 20
     h2 {

+ 117 - 1
src/app/views/sys-config/sys-config.component.ts

@@ -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
 }