1 import { Component, OnInit } from '@angular/core';
2 import { BUSINESS_STATUS } from "../../../../../constants/constants";
3 import { SlicingTaskServices } from '.././../../../core/services/slicingTaskServices';
4 import { NzModalService, NzMessageService } from 'ng-zorro-antd';
5 import * as moment from 'moment';
7 selector: 'app-csmf-slicing-business-management',
8 templateUrl: './csmf-slicing-business-management.component.html',
9 styleUrls: ['./csmf-slicing-business-management.component.less']
11 export class CsmfSlicingBusinessManagementComponent implements OnInit {
14 private myhttp: SlicingTaskServices,
15 private modalService: NzModalService,
16 private message: NzMessageService
21 this.getCSMFBusinessList()
24 this.progressingTimer.forEach((item) => {
25 clearInterval(item.timer);
27 this.progressingTimer = [];
30 selectedValue: string = BUSINESS_STATUS[0];
31 listOfData: any[] = [];
32 pageIndex: number = 1;
33 pageSize: number = 10;
36 statusOptions: any[] = BUSINESS_STATUS;
37 progressingTimer: any[] = [];
38 terminateStart: any[] = [];
39 businessOrderShow: boolean = false;
40 getCSMFBusinessList() {
44 status: this.selectedValue.toLocaleLowerCase(),
45 pageNo: this.pageIndex,
46 pageSize: this.pageSize
48 this.myhttp.getCSMFSlicingBusinessList(paramsObj).subscribe(res => {
49 const { result_header: { result_code }, result_body: { slicing_order_list, record_number } } = res;
51 if (+result_code === 200) {
52 this.total = record_number;
53 if (slicing_order_list !== null && slicing_order_list.length > 0) {
54 this.listOfData = slicing_order_list.map((item, index) => {
55 item.order_creation_time = moment(Number(item.order_creation_time)).format('YYYY-MM-DD HH:mm:ss');
56 if (item.last_operation_progress && item.last_operation_type && Number(item.last_operation_progress) < 100) {
57 let updata = (prodata: { operation_progress: string }) => {
58 item.last_operation_progress = prodata.operation_progress || item.last_operation_progress;
61 serviceId: item.order_id
63 if (item.last_operation_type === 'DELETE') this.terminateStart[index] = true
64 else this.terminateStart[index] = false;
65 this.queryProgress(obj, index, updata).then((res) => {
66 item.last_operation_progress = '100';
67 this.getCSMFBusinessList();
77 getListOfProcessingStatus() {
80 this.progressingTimer.forEach((item) => {
81 clearInterval(item.timer);
83 this.progressingTimer = [];
84 this.getCSMFBusinessList();
87 searchData(reset: boolean = false) {
88 this.progressingTimer.forEach((item) => {
89 clearInterval(item.timer);
91 this.progressingTimer = [];
92 this.getCSMFBusinessList();
95 switchChange(slicing, i) {
96 // console.log(slicing, i, "slicing");
97 this.modalService.confirm({
98 nzTitle: '<i>Are you sure you want to perform this task?</i>',
99 nzContent: '<b>Name:' + slicing.order_name + '</b>',
102 serviceId: slicing.order_id
104 if (slicing.order_status === 'activated') {
105 this.changeActivate(paramsObj, false, slicing, "deactivate", "deactivated", i)
107 this.changeActivate(paramsObj, true, slicing, "activate", "activated", i);
112 let singleSlicing = Object.assign({}, this.listOfData[i]);
113 this.listOfData[i] = singleSlicing;
114 this.listOfData = [...this.listOfData];
118 changeActivate(paramsObj, isActivate, slicing, activateValue, finished, index) {
120 this.myhttp.changeActivateSlicingService(paramsObj, isActivate).subscribe(res => {
121 const { result_header: { result_code, result_message }, result_body: { operation_id } } = res;
122 this.loading = false;
123 if (+result_code === 200) {
124 this.getCSMFBusinessList();
126 let singleSlicing = Object.assign({}, this.listOfData[index]);
127 this.listOfData[index] = singleSlicing;
128 this.listOfData = [...this.listOfData];
129 this.getCSMFBusinessList();
131 this.getCSMFBusinessList();
133 this.loading = false;
134 let singleSlicing = Object.assign({}, this.listOfData[index]);
135 this.listOfData[index] = singleSlicing;
136 this.listOfData = [...this.listOfData];
137 this.getCSMFBusinessList();
141 terminate(slicing, index) {
142 this.modalService.confirm({
143 nzTitle: 'Are you sure you want to terminate this task?',
144 nzContent: '<b>Name: </b>' + slicing.order_name,
146 let paramsObj = { serviceId: slicing.order_id };
147 this.terminateStart[index] = true;
149 this.myhttp.terminateSlicingService(paramsObj).subscribe(res => {
150 const { result_header: { result_code, result_message }, result_body: { operation_id } } = res;
151 this.loading = false;
152 if (+result_code === 200) {
153 this.getCSMFBusinessList();
155 this.terminateStart[index] = false;
158 this.loading = false;
159 this.terminateStart[index] = false;
164 console.info('Cancel termination')
168 queryProgress(obj, index, callback) {
169 return new Promise(res => {
170 let requery = () => {
171 this.myhttp.getSlicingBusinessProgress(obj)
172 .subscribe((data) => {
173 const { result_header: { result_code, result_message }, result_body: { operation_id } } = data;
174 if (+result_code === 200) {
175 if (data.result_body.operation_progress && Number(data.result_body.operation_progress) < 100) {
176 callback(data.result_body);
177 let progressSetTimeOut = setTimeout(() => {
180 this.progressingTimer.push({
182 timer: progressSetTimeOut
185 this.progressingTimer.forEach((item) => {
186 if (item.serviceId === obj.serviceId) {
187 clearInterval(item.timer);
190 res(data.result_body);
193 this.progressingTimer.forEach((item) => {
194 if (item.serviceId === obj.serviceId) {
195 clearInterval(item.timer);
198 this.getCSMFBusinessList();
199 this.message.error(result_message);
202 this.progressingTimer.forEach((item) => {
203 if (item.serviceId === obj.serviceId) {
204 clearInterval(item.timer);
207 this.getCSMFBusinessList();
208 this.message.error(err);
216 this.businessOrderShow = true;
218 orderModelClose($event) {
219 this.businessOrderShow = $event;
220 this.getCSMFBusinessList();