Browse Source

删除用户,是否删除企业微信用户

seimin 3 years ago
parent
commit
c85cdf38da

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

@@ -502,4 +502,14 @@ export class MainService {
502 502
       headers: this.headers,
503 503
     });
504 504
   }
505
+  //删除用户(包含企业微信用户)
506
+  rmvDataAndWeChatNum(data, flag) {
507
+    return this.http.post(
508
+      host.host + "/user/data/rmvDataAndWeChatNum/" + flag,
509
+      data,
510
+      {
511
+        headers: this.headers,
512
+      }
513
+    );
514
+  }
505 515
 }

+ 1 - 1
src/app/share/dialog-delete/dialog-delete.component.html

@@ -9,7 +9,7 @@
9 9
     </div>
10 10
     <div class="operate">
11 11
       <button nz-button nzType="primary" (click)="confirmDel()" [nzLoading]="btnLoading">{{confirmTxt}}</button>
12
-      <button class="btn cancel ml8" nz-button nzType="default" (click)="hideDelModal('cancel')" [nzLoading]="cancenlLoading">{{cancelTxt}}</button>
12
+      <button class="btn cancel ml8" nz-button nzType="default" (click)="cancel(cancelTxt=='否'?'no':'cancel')" [nzLoading]="cancenlLoading">{{cancelTxt}}</button>
13 13
     </div>
14 14
   </div>
15 15
 </div>

+ 21 - 13
src/app/share/dialog-delete/dialog-delete.component.ts

@@ -1,31 +1,39 @@
1
-import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
1
+import { Component, EventEmitter, Input, OnInit, Output } from "@angular/core";
2 2
 
3 3
 @Component({
4
-  selector: 'app-dialog-delete',
5
-  templateUrl: './dialog-delete.component.html',
6
-  styleUrls: ['./dialog-delete.component.less']
4
+  selector: "app-dialog-delete",
5
+  templateUrl: "./dialog-delete.component.html",
6
+  styleUrls: ["./dialog-delete.component.less"],
7 7
 })
8 8
 export class DialogDeleteComponent implements OnInit {
9 9
   @Output() hideDelModalEvent = new EventEmitter<any>();
10 10
   @Output() confirmDelEvent = new EventEmitter<any>();
11
+  @Output() cancelDelEvent = new EventEmitter<any>();
11 12
   @Input() btnLoading: boolean = false;
12 13
   @Input() cancenlLoading: boolean = false;
13 14
   @Input() delModal: boolean = false;
14
-  @Input() content: string = '您确定要删除吗?';
15
-  @Input() tips: string = '';
16
-  @Input() confirmTxt: string = '确定';
17
-  @Input() cancelTxt: string = '取消';
18
-  constructor() { }
15
+  @Input() content: string = "您确定要删除吗?";
16
+  @Input() tips: string = "";
17
+  @Input() confirmTxt: string = "确定";
18
+  @Input() cancelTxt: string = "取消";
19
+  constructor() {}
19 20
 
20
-  ngOnInit() {
21
-  }
21
+  ngOnInit() {}
22 22
   // 隐藏
23
-  hideDelModal(e:string) {
23
+  hideDelModal(e: string) {
24 24
     this.hideDelModalEvent.emit(e);
25 25
   }
26 26
   // 确认删除
27 27
   confirmDel() {
28 28
     this.confirmDelEvent.emit();
29 29
   }
30
-
30
+  cancel(type: string) {
31
+    if (type == "cancel") {
32
+      //取消
33
+      this.hideDelModal("cancel");
34
+    } else if (type == "no") {
35
+      //否
36
+      this.cancelDelEvent.emit();
37
+    }
38
+  }
31 39
 }

+ 3 - 2
src/app/views/users-management/users-management.component.html

@@ -202,8 +202,9 @@
202 202
   </div>
203 203
 </div>
204 204
 <!-- 删除模态框 -->
205
-<app-dialog-delete [delModal]="delModal" (hideDelModalEvent)="hideDelModal()" [btnLoading]="btnLoading"
206
-  (confirmDelEvent)="confirmDel()" content="是否删除企业微信同用户?"></app-dialog-delete>
205
+<app-dialog-delete [delModal]="delModal" (hideDelModalEvent)="hideDelModal()" [btnLoading]="btnLoading" [cancenlLoading]="cancenlLoading"
206
+  (confirmDelEvent)="confirmDel()" (cancelDelEvent)="cancelDel()" content="是否删除企业微信同用户?" confirmTxt="是" cancelTxt="否">
207
+</app-dialog-delete>
207 208
 <!-- 操作成功/失败提示框 -->
208 209
 <app-prompt-modal *ngIf="promptModalShow" [content]="promptContent" [success]="ifSuccess" [show]="promptModalShow"
209 210
   [info]="promptInfo"></app-prompt-modal>

+ 28 - 4
src/app/views/users-management/users-management.component.ts

@@ -413,16 +413,40 @@ export class UsersManagementComponent implements OnInit {
413 413
     that.coopId = data.id;
414 414
     that.delModal = true;
415 415
   }
416
-  // 确认删除
416
+  // 确认删除(删除企业微信用户)
417 417
   confirmDel() {
418 418
     let that = this;
419 419
     that.btnLoading = true;
420 420
     that.mainService
421
-      .coopData("rmvData", "user", [that.coopId])
421
+      .rmvDataAndWeChatNum([that.coopId], true)
422 422
       .subscribe((data) => {
423 423
         that.btnLoading = false;
424 424
         that.hideDelModal();
425
-        if (data.status == 200) {
425
+        if (data["status"] == 200) {
426
+          if (
427
+            that.listOfData.length == 1 &&
428
+            that.pageIndex == Math.ceil(that.listLength / that.pageSize)
429
+          ) {
430
+            that.listLength--;
431
+            that.pageIndex = Math.ceil(that.listLength / that.pageSize);
432
+          }
433
+          that.showPromptModal("删除", true, "");
434
+        } else {
435
+          that.showPromptModal("删除", false, data["msg"]);
436
+        }
437
+      });
438
+  }
439
+  // 确认删除(不删除企业用户)
440
+  cancenlLoading = false;
441
+  cancelDel() {
442
+    let that = this;
443
+    that.cancenlLoading = true;
444
+    that.mainService
445
+      .rmvDataAndWeChatNum([that.coopId], false)
446
+      .subscribe((data) => {
447
+        that.cancenlLoading = false;
448
+        that.hideDelModal();
449
+        if (data["status"] == 200) {
426 450
           if (
427 451
             that.listOfData.length == 1 &&
428 452
             that.pageIndex == Math.ceil(that.listLength / that.pageSize)
@@ -432,7 +456,7 @@ export class UsersManagementComponent implements OnInit {
432 456
           }
433 457
           that.showPromptModal("删除", true, "");
434 458
         } else {
435
-          that.showPromptModal("删除", false, data.msg);
459
+          that.showPromptModal("删除", false, data["msg"]);
436 460
         }
437 461
       });
438 462
   }