diff options
Diffstat (limited to 'usecaseui-portal/src/app/views/services/slicing-management/csmf-slicing-business-management/business-order/business-order.component.ts')
-rw-r--r-- | usecaseui-portal/src/app/views/services/slicing-management/csmf-slicing-business-management/business-order/business-order.component.ts | 331 |
1 files changed, 136 insertions, 195 deletions
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 bfef2d20..4d3c7972 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,209 +1,150 @@ -import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; -import {COMMUNICATION_FORM_ITEMS, COMMUNICATION_FORM_ADDRESS} from "./constants"; -import { Util } from '../../../../../shared/utils/utils'; -import {SlicingTaskServices} from "../../../../../core/services/slicingTaskServices"; -import {NzMessageService} from "ng-zorro-antd"; +import { Component, EventEmitter, Input, OnInit, Output } from "@angular/core"; +import { COMMUNICATION_FORM_ITEMS } from "./constants"; +import { Util } from "../../../../../shared/utils/utils"; +import { SlicingTaskServices } from "../../../../../core/services/slicingTaskServices"; +import { NzMessageService } from "ng-zorro-antd"; @Component({ - selector: 'app-business-order', - templateUrl: './business-order.component.html', - styleUrls: ['./business-order.component.less'] + selector: "app-business-order", + templateUrl: "./business-order.component.html", + styleUrls: ["./business-order.component.less"], }) export class BusinessOrderComponent implements OnInit { + constructor( + private myhttp: SlicingTaskServices, + private message: NzMessageService, + private Util: Util + ) {} - constructor( - private myhttp: SlicingTaskServices, - private message: NzMessageService, - private Util: Util - ) { - } + ngOnInit() {} - ngOnInit() { - } + ngOnChanges() { + this.AreaFormatting(); + } - ngOnChanges() { - this.AreaFormatting(); - } + @Input() showModel: boolean; + @Output() cancel = new EventEmitter<boolean>(); + comunicationFormItems = COMMUNICATION_FORM_ITEMS; + slicing_order_info = { + name: null, + maxNumberofUEs: null, + expDataRateDL: null, + latency: null, + expDataRateUL: null, + resourceSharingLevel: "shared", + uEMobilityLevel: "stationary", + coverageArea: "", + coverageAreaNumber: null, + }; + areaList: any[] = []; + validateRulesShow: any[] = []; + rulesText: any[] = []; + areaLevel: number = 4; - @Input() showModel: boolean; - @Output() cancel = new EventEmitter<boolean>(); - comunicationFormItems = COMMUNICATION_FORM_ITEMS; - slicing_order_info = { - name: null, - maxNumberofUEs: null, - expDataRateDL: null, - latency: null, - expDataRateUL: null, - resourceSharingLevel: "shared", - uEMobilityLevel: "stationary", - coverageArea: '', - coverageAreaNumber: null - }; - areaList: any[] = []; - validateRulesShow: any[] = []; - rulesText: any[] = []; + AreaFormatting(): void { + let areaList = ["Beijing;Beijing;Haidian District;Wanshoulu Street"]; + this.areaList = areaList.map((item: any) => { + let arr = item.split(";"); + item = arr.map((it, index) => { + let key: string; + if (!index) { + key = "province"; + } else if (index === 1) { + key = "city"; + } else if (index === 2) { + key = "district"; + } else { + key = "street"; + } + const obj: any = {}; + obj.key = key; + obj.selected = it; + obj.options = [{ name: it, id: it }]; + return obj; + }); + return item; + }); + } - AreaFormatting(): void { - let areaList = ['Beijing;Beijing;Haidian District;Wanshoulu Street']; - this.areaList = areaList.map((item: any) => { - let arr = item.split(';'); - item = arr.map((it, index) => { - let key: string; - if (!index) { - key = 'province'; - } else if (index === 1) { - key = 'city' - } else if (index === 2) { - key = 'district' - } else { - key = 'street' - } - const obj: any = {}; - obj.key = key; - obj.selected = it; - obj.options = [{name: it, id: it}] - return obj - }) - return item; - }) - } + handleCancel(): void { + this.showModel = false; + this.cancel.emit(this.showModel); + this.slicing_order_info = { + name: null, + maxNumberofUEs: null, + expDataRateDL: null, + latency: null, + expDataRateUL: null, + resourceSharingLevel: "shared", + uEMobilityLevel: "stationary", + coverageArea: "", + coverageAreaNumber: null, + }; + this.validateRulesShow = []; + } - creatAreaList(): void { - const arr = [ - { - key: 'province', - selected: '', - options: [] - }, - { - key: 'city', - selected: '', - options: [] - }, - { - key: 'district', - selected: '', - options: [] - }, - { - key: 'street', - selected: '', - options: [] - } - ] - this.areaList.push(arr) - } + handleOk(): void { + const coverage_list: string[] = []; + let coverageAreas; - deleteAreaList(index: number): void { - this.areaList.splice(index, 1); - } + COMMUNICATION_FORM_ITEMS.forEach((item, index) => { + if (item.required && item.type === "input") { + this.Util.validator( + item.title, + item.key, + this.slicing_order_info[item.key], + index, + this.rulesText, + this.validateRulesShow + ); + } + }); + if (this.validateRulesShow.indexOf(true) > -1) { + return; + } - handleChange(area: any[], areaItem: any): void { - if (areaItem.key === 'province' && areaItem.options.length <= 1) { - areaItem.options = COMMUNICATION_FORM_ADDRESS; - } else if (areaItem.key === 'city' && areaItem.options.length <= 1) { - COMMUNICATION_FORM_ADDRESS.forEach(item => { - if (item.name === area[0].selected) { - areaItem.options = item.city; - } - }) - } else if (areaItem.key === 'district' && areaItem.options.length <= 1) { - COMMUNICATION_FORM_ADDRESS.forEach((item: any) => { - item.city.forEach(city => { - if (city.name === area[1].selected) { - areaItem.options = city.county; - } - }) - }) - } else if (areaItem.key === 'street' && areaItem.options.length <= 1) { - COMMUNICATION_FORM_ADDRESS.forEach((item: any) => { - item.city.forEach(city => { - if (city.name === area[1].selected) { - city.county.forEach(county => { - if (county.name === area[2].selected) { - areaItem.options = county.street; - } - }) - } - }) - }) - } - } + this.areaList.forEach((item) => { + let str = ""; + item.forEach((area) => { + str += area.selected + ";"; + }); + coverage_list.push(str.substring(0, str.length - 1)); + }); + if (coverage_list.length > 1) { + coverageAreas = coverage_list.join("|"); + } else { + coverageAreas = coverage_list.toString(); + } + const coverageAreaNumber = this.slicing_order_info[ + "coverageAreaNumber" + ]; + if (coverageAreaNumber) { + this.slicing_order_info.coverageArea = `${coverageAreas}-${coverageAreaNumber}`; + } else { + this.slicing_order_info.coverageArea = `${coverageAreas}`; + } + delete this.slicing_order_info.coverageAreaNumber; - handleChangeSelected(area: any[], areaItem: any): void { - let areaItemIndex = area.indexOf(areaItem); - area.map((item,index)=>{ - if(index > areaItemIndex){ - item.selected = ''; - item.options = []; - } - }) - } - - handleCancel(): void { - this.showModel = false; - this.cancel.emit(this.showModel); - this.slicing_order_info = { - name: null, - maxNumberofUEs: null, - expDataRateDL: null, - latency: null, - expDataRateUL: null, - resourceSharingLevel: "shared", - uEMobilityLevel: "stationary", - coverageArea: '', - coverageAreaNumber: null - }; - this.validateRulesShow = [] - } - - handleOk(): void { - const coverage_list: string[] = []; - let coverageAreas; - - COMMUNICATION_FORM_ITEMS.forEach((item, index) => { - if (item.required && item.type==="input") { - this.Util.validator(item.title,item.key, this.slicing_order_info[item.key], index, this.rulesText, this.validateRulesShow) - } - }); - if (this.validateRulesShow.indexOf(true) > -1) { - return - } - - this.areaList.forEach(item => { - let str = ''; - item.forEach(area => { - str += area.selected + ';'; - }); - coverage_list.push(str.substring(0, str.length - 1)); - }); - if (coverage_list.length > 1) { - coverageAreas = coverage_list.join('|') - } else { - coverageAreas = coverage_list.toString(); - } - const coverageAreaNumber = this.slicing_order_info["coverageAreaNumber"]; - if(coverageAreaNumber){ - this.slicing_order_info.coverageArea = `${coverageAreas}-${coverageAreaNumber}`; - }else{ - this.slicing_order_info.coverageArea = `${coverageAreas}`; - } - delete this.slicing_order_info.coverageAreaNumber - - const paramsObj = { - slicing_order_info: this.slicing_order_info - }; - const csmfSlicingPurchaseFailedCallback = () => { - this.handleCancel(); - } - this.myhttp.csmfSlicingPurchase(paramsObj, csmfSlicingPurchaseFailedCallback).then(res => { - const result = res.result_header; - if(result&&result.result_code&&+result.result_code===200){ - console.log(res) - }else{ - this.message.create('error','Network error') - } - this.handleCancel(); - }) - } + const paramsObj = { + slicing_order_info: this.slicing_order_info, + }; + const csmfSlicingPurchaseFailedCallback = () => { + this.handleCancel(); + }; + this.myhttp + .csmfSlicingPurchase(paramsObj, csmfSlicingPurchaseFailedCallback) + .then((res) => { + const result = res.result_header; + if ( + result && + result.result_code && + +result.result_code === 200 + ) { + console.log(res); + } else { + this.message.create("error", "Network error"); + } + this.handleCancel(); + }); + } } |