From 71934f9ecfedbe856da16bfcc28e30c658cad616 Mon Sep 17 00:00:00 2001 From: cyuamber Date: Mon, 9 Dec 2019 12:11:36 +0800 Subject: feat: Optimize the selection box logic of the task processing component Change-Id: Ic08e3f986f2d72ea2d90b7a80da57cf3ac4d25d2 Issue-ID: USECASEUI-368 Signed-off-by: cyuamber --- .../src/app/core/services/slicingTaskServices.ts | 2 +- .../slicing-task-model.component.ts | 46 +++++++++++----------- 2 files changed, 24 insertions(+), 24 deletions(-) (limited to 'usecaseui-portal/src') diff --git a/usecaseui-portal/src/app/core/services/slicingTaskServices.ts b/usecaseui-portal/src/app/core/services/slicingTaskServices.ts index 7c50e561..3f38a717 100644 --- a/usecaseui-portal/src/app/core/services/slicingTaskServices.ts +++ b/usecaseui-portal/src/app/core/services/slicingTaskServices.ts @@ -84,7 +84,7 @@ export class SlicingTaskServices { getSubnetInContext (context: string, pageNo: string, pageSize: string) { const url = this.url.subnetInContext .replace('{environmentContext}', context) - .replace('{pageNo', pageNo) + .replace('{pageNo}', pageNo) .replace('{pageSize}', pageSize); return this.http.get(url); } diff --git a/usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/slicing-task-model/slicing-task-model.component.ts b/usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/slicing-task-model/slicing-task-model.component.ts index b55844bc..f9ef1511 100644 --- a/usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/slicing-task-model/slicing-task-model.component.ts +++ b/usecaseui-portal/src/app/views/services/slicing-management/slicing-task-management/slicing-task-model/slicing-task-model.component.ts @@ -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 { -- cgit 1.2.3-korg