feat: Optimize the selection box logic of the task processing component 11/99311/1
authorcyuamber <xuranyjy@chinamobile.com>
Mon, 9 Dec 2019 04:11:36 +0000 (12:11 +0800)
committercyuamber <xuranyjy@chinamobile.com>
Mon, 9 Dec 2019 04:11:48 +0000 (12:11 +0800)
Change-Id: Ic08e3f986f2d72ea2d90b7a80da57cf3ac4d25d2
Issue-ID: USECASEUI-368
Signed-off-by: cyuamber <xuranyjy@chinamobile.com>
usecaseui-portal/src/app/core/services/slicingTaskServices.ts
usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/slicing-task-model/slicing-task-model.component.ts

index 7c50e56..3f38a71 100644 (file)
@@ -84,7 +84,7 @@ export class SlicingTaskServices {
     getSubnetInContext (context: string, pageNo: string, pageSize: string) {\r
         const url = this.url.subnetInContext\r
                         .replace('{environmentContext}', context)\r
-                        .replace('{pageNo', pageNo)\r
+                        .replace('{pageNo}', pageNo)\r
                         .replace('{pageSize}', pageSize);\r
         return this.http.get<any>(url);\r
     }\r
index b55844b..f9ef151 100644 (file)
@@ -26,7 +26,6 @@ export class SlicingTaskModelComponent implements OnInit {
   selectedServiceId: string;
   selectedServiceName: string;
   slicingInstances: any;
-  loading: boolean = false;
   // 子网实例
   slicingSubnet: any[] =  [
     {
@@ -180,27 +179,27 @@ export class SlicingTaskModelComponent implements OnInit {
     const { total, currentPage, pageSize} = this.slicingInstances;
     if (total - (+currentPage * +pageSize) > 0 ) {
       if (this.slicingInstances.flag) return;
-      this.slicingInstances.isLoading = true;
       this.slicingInstances.flag = true
-      setTimeout( () => {
-        this.getSlicingInstances(currentPage, pageSize)
-      }, 2000)
-      this.slicingInstances.currentPage ++ ;
+      this.getSlicingInstances(currentPage, pageSize)
+      this.slicingInstances.currentPage = (+this.slicingInstances.currentPage +1).toString();
     }
   }
 
   getSlicingInstances(pageNo: string, pageSize: string): void {
+    this.slicingInstances.isLoading = true;
     this.http.getSlicingInstance(pageNo, pageSize).subscribe ( res => {
       const { result_header: { result_code }, result_body } = res;
-      if (+result_code === 200) {
-        const { nsi_service_instances, record_number } = result_body;
-        this.slicingInstances.total = record_number;
-        this.slicingInstances.list.push(...nsi_service_instances);
-      } else {
-        this.message.error('Failed to get slicing instance ID')
-      }
-      this.slicingInstances.isLoading = false;
-      this.slicingInstances.flag = false;
+      setTimeout( () => {
+        if (+result_code === 200) {
+          const { nsi_service_instances, record_number } = result_body;
+          this.slicingInstances.total = record_number;
+          this.slicingInstances.list.push(...nsi_service_instances);
+        } else {
+          this.message.error('Failed to get slicing instance ID')
+        }
+        this.slicingInstances.isLoading = false;
+        this.slicingInstances.flag = false;
+      },2000)
 
     })
   }
@@ -275,16 +274,15 @@ export class SlicingTaskModelComponent implements OnInit {
     const { total, currentPage, pageSize} = instance;
     if(total - (+currentPage * +pageSize) > 0 ){
       if (instance.flag) return;
-      instance.isLoading = true;
       instance.flag = true;
-      setTimeout( () => {
-        this.getSubnetInstances(instance);
-      }, 2000)
-      instance.currentPage ++;
+      this.getSubnetInstances(instance);
+      let count = +instance.currentPage;
+      instance.currentPage = (++count).toString();
     }
   }
 
   getSubnetInstances (instance: any): void {
+    instance.isLoading = true;
     const { context, currentPage, pageSize } = instance;
     this.http.getSubnetInContext(context, currentPage, pageSize).subscribe( res => {
       const { result_header: { result_code }, result_body } = res;
@@ -293,9 +291,11 @@ export class SlicingTaskModelComponent implements OnInit {
         this.slicingSubnet.map (item => {
           if (item.context === context) {
             item.total = record_number;
-            item.instances.push(...nssi_service_instances);
-            item.isLoading = false;
-            item.flag = false;
+            setTimeout(() => {
+              item.instances.push(...nssi_service_instances);
+              item.isLoading = false;
+              item.flag = false;
+            },2000)
           }
         })
       } else {