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