bf046545770887788da32fc121d9b37bb456de26
[usecase-ui.git] /
1 import { Component, OnInit } from "@angular/core";
2 import { Router } from "@angular/router";
3 import { NzMessageService } from "ng-zorro-antd";
4 import { intentBaseService } from "../../../../core/services/intentBase.service";
5
6 @Component({
7   selector: 'app-cloud-leased-line',
8   templateUrl: './cloud-leased-line.component.html',
9   styleUrls: ['./cloud-leased-line.component.less']
10 })
11 export class CloudLeasedLineComponent implements OnInit {
12
13   constructor(
14     private router:Router,
15     private myHttp: intentBaseService,
16     private nzMessage: NzMessageService 
17   ) {}
18
19         ngOnChanges() {}
20
21         ngOnInit() {
22     this.pageIndex = 1;
23     this.pageSize = 10;
24     this.getCloudLeasedLineList();
25   }
26
27         ngOnDestroy() {}
28
29   statusObj: any = {
30     0: 'Incomplete',
31     1: 'Completed',
32     2: 'Deleted',
33     3: 'Inactive'
34   }
35   // 列表数据源
36         listOfData: any[] = [];
37   // 分页信息及总数
38         pageIndex: number = 1;
39         pageSize: number = 10;
40         total: number = 0;
41         loading = false;
42   // 控制弹窗展示变量
43   cloudLeasedLineShowFlag: boolean = false;
44   smartCloudLeasedLineShowFlag: boolean = false;
45   // 初始化查询数据源
46         getCloudLeasedLineList(): void {
47     this.myHttp.getInstanceList({
48       currentPage: this.pageIndex,
49       pageSize: this.pageSize
50     }).subscribe((response) => {
51       const { code, message, data } = response;
52       if (code !== 200) {
53         this.nzMessage.error(message);
54                                 return;
55       }
56       this.total = data.totalRecords;
57       this.listOfData = [...data.list];
58     }, (err) => {
59       console.log(err);
60     });
61   }
62   // 分页信息变更查询数据
63   searchData(): void {
64     this.getCloudLeasedLineList();
65   }
66   // 解析结果传递到create弹窗
67   resolveResult: any;
68   // 弹窗加载
69         cloudLeasedLineShow(): void {
70           this.cloudLeasedLineShowFlag = true;
71         }
72   // 弹窗关闭
73         cloudLeasedLineClose(): void {
74     this.cloudLeasedLineShowFlag = false;
75     this.pageIndex = 1;
76     this.pageSize = 10;
77     this.getCloudLeasedLineList();
78   }
79   // smart 弹窗加载
80         smartCloudLeasedLineShow(): void {
81           this.smartCloudLeasedLineShowFlag = true;
82         }
83   // smart 弹窗关闭
84         smartCloudLeasedLineClose(data): void {
85     this.smartCloudLeasedLineShowFlag = false;
86     if (data.cancel) {
87       return;
88     }
89     this.cloudLeasedLineShowFlag = true;
90     this.resolveResult = {
91       name: 'test',
92       instanceId: '123456',
93       accessPointOne: {
94         name: 'aaa',
95         bandwidth: '20'
96       },
97       cloudPointName: 'aaa',
98     };
99   }
100   // 跳转监控管理页面
101   goMonitorService(): void {
102     this.router.navigateByUrl('/fcaps/monitor_service');
103   }
104
105   activeCloudLeasedLine(row): void {
106     this.myHttp.activeIntentInstance({
107       instanceId: row.instanceId
108     }).subscribe((data) => {
109       console.log(data);
110     }, (err) => {
111       console.log(err);
112     });
113   }
114
115   inactiveCloudLeasedLine(row): void {
116     this.myHttp.invalidIntentInstance({
117       instanceId: row.instanceId
118     }).subscribe((data) => {
119       console.log(data);
120     }, (err) => {
121       console.log(err);
122     });
123   }
124
125   deleteCloudLeasedLine(row): void {
126     this.myHttp.deleteIntentInstance(row.instanceId).subscribe((data) => {
127       console.log(data);
128     }, (err) => {
129       console.log(err);
130     });
131   }
132 }