diff options
author | 2020-02-24 17:15:28 +0800 | |
---|---|---|
committer | 2020-02-24 19:40:58 +0800 | |
commit | 832bf90a245a5b164e2ed4363e58c7ddd34710a1 (patch) | |
tree | 020871c185f4002e6ff92e35f0ce3ec6e3a6d345 /usecaseui-portal/src/app/views/services/slicing-management/csmf-slicing-business-management/business-order | |
parent | 2f3a4ddaee7bf578f83fa9af7bd18e54c84b54d3 (diff) |
feat:Public method extraction and optimization of CSMF slicing page
Change-Id: Iac04b79b18d324b16c791e58ae40d3c93165a381
Issue-ID: USECASEUI-368
Signed-off-by: cyuamber <xuranyjy@chinamobile.com>
Diffstat (limited to 'usecaseui-portal/src/app/views/services/slicing-management/csmf-slicing-business-management/business-order')
2 files changed, 24 insertions, 79 deletions
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 @@ <nz-form-control [nzSpan]="15"> <input nz-input nz-tooltip [id]="item.key" [name]="item.key" [(ngModel)]="slicing_order_info[item.key]" - [ngClass]="{'error-input-border':validateRules[i] === true}" - *ngIf=" item.title === 'Slicing Business Name' " - (blur)="validator(item,slicing_order_info[item.key],i)"/> + [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)"/> <nz-tooltip [nzTitle]="tooltipText" [nzPlacement]="'right'" [nzTrigger]="'focus'"> <input nz-input nz-tooltip [id]="item.key" [name]="item.key" [(ngModel)]="slicing_order_info[item.key]" - [ngClass]="{'error-input-border':validateRules[i] === true}" - *ngIf=" item.title !== 'Slicing Business Name' && item.title !== 'Resource Sharing Level' && item.title !== 'Mobility' && item.title !== 'Area' " - (blur)="validator(item,slicing_order_info[item.key],i)" + [ngClass]="{'error-input-border':validateRulesShow[i] === true}" + *ngIf=" item.title !== 'Communication Service Name' && item.title !== 'Resource Sharing Level' && item.title !== 'Mobility' && item.title !== 'Area' " + (blur)="this.Util.validator(item.title,item.key,slicing_order_info[item.key],i,rulesText,validateRulesShow)" (focus)="changeTooltipText(item.title)"/> </nz-tooltip> <nz-radio-group [name]="item.key" [(ngModel)]="slicing_order_info[item.key]" @@ -34,7 +34,7 @@ </nz-option> </nz-select> <nz-form-explain - *ngIf=" item.title !== 'Resource Sharing Level' && item.title !== 'Mobility' && item.title !== 'Area' && validateRules[i]" + *ngIf=" item.title !== 'Resource Sharing Level' && item.title !== 'Mobility' && item.title !== 'Area' && validateRulesShow[i]" class="validateRules">{{rulesText[i]}} </nz-form-explain> </nz-form-control> 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[] = []; |