From de349cf086c765d30defa87dc58deb2a41566e37 Mon Sep 17 00:00:00 2001
From: SHAOJIAHAO <55341701@qq.com>
Date: Tue, 28 Dec 2021 11:12:59 +0800
Subject: [PATCH] =?UTF-8?q?[=E6=96=B0=E5=A2=9E]=E7=9F=AD=E4=BF=A1=E6=8E=A8?=
 =?UTF-8?q?=E9=80=81=E5=BC=80=E5=85=B3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../push/push.component.html                  |  1 +
 .../system-management/push/push.component.ts  | 38 ++++++++++++++++---
 2 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/src/app/system-management/push/push.component.html b/src/app/system-management/push/push.component.html
index 1fda6ab..7125fd5 100644
--- a/src/app/system-management/push/push.component.html
+++ b/src/app/system-management/push/push.component.html
@@ -2,6 +2,7 @@
     <div class="topbox">
         <div class="lefttop">
             <span>通知推送权限配置</span>
+            <label nz-checkbox [(ngModel)]="checked" (ngModelChange)='changeNotePush($event)'>是否开启短信推送</label>
         </div>
         <div class="righttop">
             <form nz-form [formGroup]="validateForm" (ngSubmit)="submitForm()">
diff --git a/src/app/system-management/push/push.component.ts b/src/app/system-management/push/push.component.ts
index 944b28f..1538028 100644
--- a/src/app/system-management/push/push.component.ts
+++ b/src/app/system-management/push/push.component.ts
@@ -14,7 +14,7 @@ export class PushComponent implements OnInit {
 
   validateForm!: FormGroup;
   constructor(private modal: NzModalService, private viewContainerRef: ViewContainerRef, private fb: FormBuilder, private http: HttpClient, private message: NzMessageService) { }
-
+  checked
   async ngOnInit(): Promise<void> {
     this.validateForm = this.fb.group({
       search: [null]
@@ -23,9 +23,35 @@ export class PushComponent implements OnInit {
     await this.getPutRoles()
     await this.getHandleRoles()
     this.getViolation()
+    this.getSetting()
   }
 
 
+  //获取短信推送状态
+  getSetting() {
+    let params = {
+      settingName: 'ViolationSmsSwitch',
+    }
+    this.http.get('/api/services/app/Configuration/GetSetting', { params: params }).subscribe((data: any) => {
+      // console.log('获取短信推送状态', data)
+      data.result == 'true' ? this.checked = true : this.checked = false
+    })
+  }
+  changeNotePush(e) {
+    console.log(e)
+    let params = {
+      settingName: 'ViolationSmsSwitch',
+      value: e
+    }
+    this.http.post('/api/services/app/Configuration/SetSetting', '', { params: params }).subscribe((data: any) => {
+      // console.log('设置短信推送状态成功', data)
+      if(e){
+        this.message.create('success', '开启成功!');
+      }else{
+        this.message.create('success', '关闭成功!');
+      }
+    })
+  }
   //获取预警类型
   list: any
   getViolation() {
@@ -121,14 +147,14 @@ export class PushComponent implements OnInit {
       this.validateForm.controls[i].markAsDirty();
       this.validateForm.controls[i].updateValueAndValidity();
     }
-    
-    if(this.validateForm.value.search){
-      this.list = this.list.filter((item)=>{
+
+    if (this.validateForm.value.search) {
+      this.list = this.list.filter((item) => {
         return item.violationType.indexOf(this.validateForm.value.search) != -1
       })
-    }else{
+    } else {
       this.getViolation()
     }
-    
+
   }
 }