From 832bf90a245a5b164e2ed4363e58c7ddd34710a1 Mon Sep 17 00:00:00 2001 From: cyuamber Date: Mon, 24 Feb 2020 17:15:28 +0800 Subject: feat:Public method extraction and optimization of CSMF slicing page Change-Id: Iac04b79b18d324b16c791e58ae40d3c93165a381 Issue-ID: USECASEUI-368 Signed-off-by: cyuamber --- .../business-order/business-order.component.html | 14 ++-- .../business-order/business-order.component.ts | 89 +++++----------------- 2 files changed, 24 insertions(+), 79 deletions(-) (limited to 'usecaseui-portal/src/app/views') diff --git a/usecaseui-portal/src/app/views/services/slicing-management/csmf-slicing-business-management/business-order/business-order.component.html b/usecaseui-portal/src/app/views/services/slicing-management/csmf-slicing-business-management/business-order/business-order.component.html index 3b6debb9..be199b5e 100644 --- a/usecaseui-portal/src/app/views/services/slicing-management/csmf-slicing-business-management/business-order/business-order.component.html +++ b/usecaseui-portal/src/app/views/services/slicing-management/csmf-slicing-business-management/business-order/business-order.component.html @@ -10,15 +10,15 @@ + [ngClass]="{'error-input-border':validateRulesShow[i] === true}" + *ngIf=" item.title === 'Communication Service Name' " + (blur)="this.Util.validator(item.title,item.key,slicing_order_info[item.key],i,rulesText,validateRulesShow)"/> {{rulesText[i]}} diff --git a/usecaseui-portal/src/app/views/services/slicing-management/csmf-slicing-business-management/business-order/business-order.component.ts b/usecaseui-portal/src/app/views/services/slicing-management/csmf-slicing-business-management/business-order/business-order.component.ts index a07edce2..5320a064 100644 --- a/usecaseui-portal/src/app/views/services/slicing-management/csmf-slicing-business-management/business-order/business-order.component.ts +++ b/usecaseui-portal/src/app/views/services/slicing-management/csmf-slicing-business-management/business-order/business-order.component.ts @@ -1,5 +1,6 @@ import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; import {COMMUNICATION_FORM_ITEMS, COMMUNICATION_FORM_ADDRESS} from "../../../../../../constants/constants"; +import { Util } from '../../../../../shared/utils/utils'; import {SlicingTaskServices} from "../../../../../core/services/slicingTaskServices"; import {NzMessageService} from "ng-zorro-antd"; @@ -12,7 +13,8 @@ export class BusinessOrderComponent implements OnInit { constructor( private myhttp: SlicingTaskServices, - private message: NzMessageService + private message: NzMessageService, + private Util: Util ) { } @@ -38,11 +40,11 @@ export class BusinessOrderComponent implements OnInit { }; areaList: any[] = []; isSpinning: boolean = false; - validateRules: any[] = []; + validateRulesShow: any[] = []; rulesText: any[] = []; tooltipText: string = 'Scope: 1-100000'; - AreaFormatting() { + AreaFormatting(): void { let areaList = ['Beijing;Beijing;Haidian District;Wanshoulu Street']; this.areaList = areaList.map((item: any) => { let arr = item.split(';'); @@ -129,26 +131,17 @@ export class BusinessOrderComponent implements OnInit { } } - handleChangeSelected(area: any[], areaItem: any) { - if (areaItem.key === 'province') { - area[1].selected = '' - area[1].options = []; - area[2].selected = ''; - area[2].options = []; - area[3].selected = ''; - area[3].options = []; - } else if (areaItem.key === 'city') { - area[2].selected = ''; - area[2].options = []; - area[3].selected = ''; - area[3].options = []; - } else if (areaItem.key === 'district') { - area[3].selected = ''; - area[3].options = []; - } + handleChangeSelected(area: any[], areaItem: any): void { + let areaItemIndex = area.indexOf(areaItem); + area.map((item,index)=>{ + if(index > areaItemIndex){ + item.selected = ''; + item.options = []; + } + }) } - handleCancel() { + handleCancel(): void { this.showModel = false; this.cancel.emit(this.showModel); this.slicing_order_info = { @@ -163,7 +156,7 @@ export class BusinessOrderComponent implements OnInit { }; } - changeTooltipText(title) { + changeTooltipText(title): void { if (title === 'Max Number of UEs') { this.tooltipText = 'Scope: 1-100000' } else if (title === 'Data Rate Downlink (Mbps)' || title === 'Data Rate Uplink (Mbps)') { @@ -175,61 +168,13 @@ export class BusinessOrderComponent implements OnInit { } } - getRulesText = (words, title, val, index) => { - return this.rulesText[index] = words + title - }; - - validator(item, val, i) { - if (val === null || val.replace(/\s*/g, '').length <= 0) { - this.validateRules[i] = true; - this.getRulesText('Please enter ', item.title, val, i,); - return false - } else { - this.validateRules[i] = false; - } - if (item.key === 'maxNumberofUEs' && !/^([1-9]\d{0,4}|100000)$/.test(val) && isNaN(val)) { - this.validateRules[i] = true; - this.getRulesText('Only numbers can be entered', '', '', i); - return false - } else if (item.key === 'maxNumberofUEs' && !/^([1-9]\d{0,4}|100000)$/.test(val) && !isNaN(val)) { - console.log("-----maxNumberofUEs") - this.validateRules[i] = true; - this.getRulesText('Scope: 1-100000', '', '', i); - return false - } else { - this.validateRules[i] = false; - } - if ((item.key === 'expDataRateDL' || item.key === 'expDataRateUL') && !/^([1-9]\d{2}|[1-3]\d{3}|3000)$/.test(val) && isNaN(val)) { - this.validateRules[i] = true; - this.getRulesText('Only numbers can be entered', '', '', i); - return false - } else if ((item.key === 'expDataRateDL' || item.key === 'expDataRateUL') && !/^([1-9]\d{2}|[1-3]\d{3}|3000)$/.test(val) && !isNaN(val)) { - this.validateRules[i] = true; - this.getRulesText('Scope: 100-3000', '', '', i); - return false - } else { - this.validateRules[i] = false; - } - if (item.key === 'latency' && !/^1[0-9]$|^[2-9]\d$|^1\d{2}$|^200$/.test(val) && isNaN(val)) { - this.validateRules[i] = true; - this.getRulesText('Only numbers can be entered', '', '', i); - return false - } else if (item.key === 'latency' && !/^1[0-9]$|^[2-9]\d$|^1\d{2}$|^200$/.test(val) && !isNaN(val)) { - this.validateRules[i] = true; - this.getRulesText('Scope: 10-200', '', '', i); - return false - } else { - this.validateRules[i] = false; - } - } - handleOk(): void { COMMUNICATION_FORM_ITEMS.forEach((item, index) => { if (item.key !== 'resourceSharingLevel' && item.key !== 'uEMobilityLevel' && item.key !== 'coverageArea') { - this.validator(item, this.slicing_order_info[item.key], index) + this.Util.validator(item.title,item.key, this.slicing_order_info[item.key], index, this.rulesText, this.validateRulesShow) } }); - if (this.validateRules.indexOf(true) > -1) { + if (this.validateRulesShow.indexOf(true) > -1) { return } const coverage_list: string[] = []; -- cgit 1.2.3-korg