基础数据--飞机优化
This commit is contained in:
@@ -11,13 +11,13 @@
|
||||
<div class="form-group mt-3 mb-4">
|
||||
<input formControlName="username" class="form-control" type="text" placeholder="请输入用户名...">
|
||||
<div class="validator" [hidden]="!(loginForm.controls['username'].errors && loginForm.controls['username'].dirty) && !(loginFormSub.submitted && loginForm.controls['username'].errors)">
|
||||
请输入用户名,6-15位
|
||||
请输入用户名,2-15位
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group mb-4">
|
||||
<input formControlName="password" class="form-control" type="password" placeholder="请输入密码...">
|
||||
<div class="validator" [hidden]="!(loginForm.controls['password'].errors && loginForm.controls['password'].dirty) && !(loginFormSub.submitted && loginForm.controls['password'].errors)">
|
||||
请输入密码,6-15位
|
||||
请输入密码,2-15位
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group mb-3">
|
||||
|
||||
@@ -25,8 +25,8 @@ export class LoginComponent implements OnInit {
|
||||
) { }
|
||||
|
||||
loginForm: FormGroup = this.formBuilder.group({
|
||||
'username': ['', [Validators.required, Validators.minLength(5), Validators.maxLength(15)]],
|
||||
'password': ['', [Validators.required, Validators.minLength(5), Validators.maxLength(15)]]
|
||||
'username': ['', [Validators.required, Validators.minLength(2), Validators.maxLength(15)]],
|
||||
'password': ['', [Validators.required, Validators.minLength(2), Validators.maxLength(15)]]
|
||||
})
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
<td>{{aircraft.maxFreightWeight}}</td>
|
||||
<td>{{aircraft.maxTakeoffWeight}}</td>
|
||||
<td>{{aircraft.maxAirbridges}}</td>
|
||||
<td>{{aircraft.aircraftOwnerCode}}</td>
|
||||
<td>{{aircraft.airlineOwnerName}}</td>
|
||||
<td>{{aircraft.airlineName}}</td>
|
||||
<td>{{aircraft.aircraftTypeName}}</td>
|
||||
</tr>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, ChangeDetectorRef } from '@angular/core';
|
||||
import { BasicDataService } from '../../../services/basic-data-service';
|
||||
import { ChangeDetectorRef } from '@angular/core';
|
||||
import { OperateSpinServiceService } from '../../../services/operate-spin-service.service';
|
||||
import * as $ from 'jquery';
|
||||
@Component({
|
||||
selector: 'app-aircraft',
|
||||
@@ -11,8 +11,12 @@ export class AircraftComponent implements OnInit {
|
||||
|
||||
constructor(
|
||||
private basicDataService: BasicDataService,
|
||||
private changeDetectorRef: ChangeDetectorRef
|
||||
) { }
|
||||
private changeDetectorRef: ChangeDetectorRef,
|
||||
private operateSpinServiceService: OperateSpinServiceService
|
||||
) {
|
||||
this.operateSpinServiceService.showSpin();
|
||||
this.changeDetectorRef.detach();
|
||||
}
|
||||
|
||||
public col_lists = [
|
||||
{ col_code: 'aircraftNumber', col_chn: '飞机号' },
|
||||
@@ -40,40 +44,36 @@ export class AircraftComponent implements OnInit {
|
||||
aircrafts: Array<any>;
|
||||
public row_state: any = { renderFlight: {} };
|
||||
public render_data: Array<object> = []; //显示数据,即需要显示的数据
|
||||
public combined_data:Array<object> = [];
|
||||
|
||||
ngOnInit() {
|
||||
this.airlines = this.basicDataService.airline;
|
||||
this.aircraftTypes = this.basicDataService.aircraft_type;
|
||||
this.aircrafts = this.basicDataService.aircraft;
|
||||
this.render_data = this.basicDataService.aircraft;
|
||||
this.basicDataService.aircraft_subject.subscribe(
|
||||
data => {
|
||||
this.aircrafts = data;
|
||||
this.render_data = data;
|
||||
if(this.aircraftTypes && this.aircraftTypes.length > 0){//机型列表数据转换
|
||||
this.basicDataTransHandle();
|
||||
}
|
||||
setTimeout(()=>{
|
||||
this.airlines = this.basicDataService.airline;
|
||||
this.aircraftTypes = this.basicDataService.aircraft_type;
|
||||
this.aircrafts = this.basicDataService.aircraft;
|
||||
|
||||
if (this.aircrafts && this.aircrafts.length > 0) {
|
||||
this.dataTransfer();
|
||||
} else {
|
||||
this.basicDataService.aircraft_type_subject.subscribe(
|
||||
data => {
|
||||
this.aircraftTypes = data;
|
||||
}
|
||||
)
|
||||
this.basicDataService.aircraft_subject.subscribe(
|
||||
data => {
|
||||
this.aircrafts = data;
|
||||
}
|
||||
)
|
||||
this.basicDataService.airline_subject.subscribe(
|
||||
data => {
|
||||
this.airlines = data;
|
||||
this.dataTransfer();
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
this.basicDataService.airline_subject.subscribe(
|
||||
data => {
|
||||
this.airlines = data;
|
||||
if(this.airlines && this.airlines.length > 0){//航空公司数据转换处理
|
||||
this.airlinesHandle();
|
||||
}
|
||||
}
|
||||
)
|
||||
this.basicDataService.aircraft_type_subject.subscribe(
|
||||
data => {
|
||||
this.aircraftTypes = data;
|
||||
}
|
||||
)
|
||||
if(this.render_data){
|
||||
//机型数据转换处理
|
||||
this.basicDataTransHandle();
|
||||
//航空公司数据转换处理
|
||||
this.airlinesHandle();
|
||||
}
|
||||
},10)
|
||||
|
||||
/**
|
||||
* 固定表头
|
||||
*/
|
||||
@@ -86,23 +86,44 @@ export class AircraftComponent implements OnInit {
|
||||
}
|
||||
|
||||
//航空公司数据转换处理
|
||||
airlinesHandle() {
|
||||
this.render_data.forEach(item => {
|
||||
let airlinesLinkIndex = this.airlines.findIndex(val => val.airlineCode === item['airlineCode']);
|
||||
if(this.airlines[airlinesLinkIndex]){
|
||||
item['airlineName'] = this.airlines[airlinesLinkIndex].airlineName;
|
||||
}
|
||||
})
|
||||
airlinesHandle(item) {
|
||||
let airlinesLinkIndex = this.airlines.findIndex(val => val.airlineCode === item['airlineCode']);
|
||||
if (airlinesLinkIndex > -1) {
|
||||
item['airlineName'] = this.airlines[airlinesLinkIndex].airlineName;
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
//机型数据转换处理
|
||||
basicDataTransHandle() {
|
||||
this.render_data.forEach(item => {
|
||||
let aircraftTypesLinkIndex = this.aircraftTypes.findIndex(val => val.aircraftTypeCode === item['aircraftTypeCode']);
|
||||
if(this.aircraftTypes[aircraftTypesLinkIndex]){
|
||||
item['aircraftTypeName'] = this.aircraftTypes[aircraftTypesLinkIndex].aircraftTypeName;
|
||||
}
|
||||
//机主航空公司数据转换出来
|
||||
airlineOwnerHandle(item) {
|
||||
let airlinesLinkIndex = this.airlines.findIndex(val => val.airlineCode === item['aircraftOwnerCode']);
|
||||
if (airlinesLinkIndex > -1) {
|
||||
item['airlineOwnerName'] = this.airlines[airlinesLinkIndex].airlineName;
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
//机型数据转换处理
|
||||
aircraftTypeHandle(item) {
|
||||
let aircraftTypesLinkIndex = this.aircraftTypes.findIndex(val => val.aircraftTypeCode === item['aircraftTypeCode']);
|
||||
if (aircraftTypesLinkIndex > -1) {
|
||||
item['aircraftTypeName'] = this.aircraftTypes[aircraftTypesLinkIndex].aircraftTypeName;
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
//数据转换统一处理
|
||||
dataTransfer() {
|
||||
this.aircrafts.forEach(item => {
|
||||
let aircraft = Object.assign({}, item);
|
||||
aircraft = this.airlinesHandle(aircraft);
|
||||
aircraft = this.airlineOwnerHandle(aircraft);
|
||||
aircraft = this.aircraftTypeHandle(aircraft);
|
||||
this.combined_data.push(aircraft);
|
||||
})
|
||||
this.render_data = this.combined_data;
|
||||
this.changeDetectorRef.detectChanges();
|
||||
this.operateSpinServiceService.hideSpin();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,6 +132,7 @@ export class AircraftComponent implements OnInit {
|
||||
*/
|
||||
selectRow(i) {
|
||||
this.row_state = i;
|
||||
this.changeDetectorRef.detectChanges();
|
||||
}
|
||||
|
||||
//输入框回车事件
|
||||
@@ -124,26 +146,31 @@ export class AircraftComponent implements OnInit {
|
||||
|
||||
//下拉框选择筛选
|
||||
selectChange() {
|
||||
this.render_data = this.aircrafts.filter(item => {
|
||||
let is_satis = true;
|
||||
for (const key in this.filterItems) {
|
||||
if (this.filterItems.hasOwnProperty(key) && this.filterItems[key]) {
|
||||
if (item[key] == this.filterItems[key]) {
|
||||
is_satis = true;
|
||||
continue;
|
||||
} else {
|
||||
is_satis = false;
|
||||
break;
|
||||
this.operateSpinServiceService.showSpin();
|
||||
setTimeout(() => {
|
||||
this.render_data = this.combined_data.filter(item => {
|
||||
let is_satis = true;
|
||||
for (const key in this.filterItems) {
|
||||
if (this.filterItems.hasOwnProperty(key) && this.filterItems[key]) {
|
||||
if (item[key] == this.filterItems[key]) {
|
||||
is_satis = true;
|
||||
continue;
|
||||
} else {
|
||||
is_satis = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return is_satis;
|
||||
})
|
||||
if (this.FLT_POS === 1) {
|
||||
this.inputFilter(this.render_data);
|
||||
} else {
|
||||
this.row_state = this.render_data.length > 0 ? this.render_data[0] : { renderFlight: {} };
|
||||
this.changeDetectorRef.detectChanges();
|
||||
this.operateSpinServiceService.hideSpin();
|
||||
}
|
||||
return is_satis;
|
||||
})
|
||||
if (this.FLT_POS === 1) {
|
||||
this.inputFilter(this.render_data);
|
||||
} else {
|
||||
this.row_state = this.render_data.length > 0 ? this.render_data[0] : { renderFlight: {} };
|
||||
}
|
||||
}, 10)
|
||||
}
|
||||
|
||||
//输入框筛选
|
||||
@@ -182,9 +209,9 @@ export class AircraftComponent implements OnInit {
|
||||
return is_satis;
|
||||
})
|
||||
}
|
||||
} else {
|
||||
this.render_data = filterData;
|
||||
}
|
||||
this.changeDetectorRef.detectChanges();
|
||||
this.operateSpinServiceService.hideSpin();
|
||||
}
|
||||
|
||||
positionArray: Array<any> = [];
|
||||
|
||||
Reference in New Issue
Block a user