第一次行排序(待优化)
This commit is contained in:
@@ -106,17 +106,20 @@
|
||||
</div>
|
||||
<div class="airline-table">
|
||||
<div class="table-container">
|
||||
<table class="table table-striped">
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>序号</th>
|
||||
<th>重要提示</th>
|
||||
<th *ngFor="let airline_col of airline_col_lists">{{airline_col.COL_CN}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr *ngFor="let airline_row of airline_row_lists;let i = index" (click)="selectRow($event,i)" [ngClass]="{'active':row_state===i}">
|
||||
<tr *ngFor="let airline_row of airline_row_lists;let i = index" (click)="selectRow($event,i)"
|
||||
[ngClass]="{'active':row_state===i}">
|
||||
<td>{{i+1}}</td>
|
||||
<td [ngStyle]="{'background-color':''}" *ngFor="let airline_col of airline_col_lists">{{airline_row[airline_col.COL_CODE]}}</td>
|
||||
<td></td>
|
||||
<td *ngFor="let airline_col of airline_col_lists" [ngStyle]="{'background-color':getColor(airline_col.COL_CODE)}">{{airline_col.COL_CODE|dataFormatter:airline_row}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -28,12 +28,12 @@
|
||||
}
|
||||
.airline-table{
|
||||
.table-container{
|
||||
border: 1px solid #ccc;
|
||||
// border: 1px solid #ccc;
|
||||
width: 100%;
|
||||
height: 700px;
|
||||
overflow: scroll;
|
||||
table{
|
||||
width: auto;
|
||||
width: max-content;
|
||||
tr{
|
||||
cursor: pointer;
|
||||
&.active{
|
||||
@@ -41,7 +41,7 @@
|
||||
}
|
||||
}
|
||||
th,td{
|
||||
border: none;
|
||||
// border: none;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,11 @@ import { Component, OnInit } from '@angular/core';
|
||||
|
||||
import { HttpClientService } from '../../services/http-client.service';
|
||||
|
||||
import dateFormatter from '../../utils/data-formatter';
|
||||
import routeType from '../../utils/route-type';
|
||||
import flightType from '../../utils/flight-type';
|
||||
import arriDept from '../../utils/arri-dept';
|
||||
|
||||
@Component({
|
||||
selector: 'app-main',
|
||||
templateUrl: './main.component.html',
|
||||
@@ -13,12 +18,30 @@ export class MainComponent implements OnInit {
|
||||
public airline_color: Array<object> = [];
|
||||
public row_state: number;
|
||||
|
||||
public TOP_1 = 100000000000; // 0-1
|
||||
public TOP_2 = 200000000000; // 0-2
|
||||
public TOP_3 = 300000000000; // 1
|
||||
public TOP_4 = 400000000000; // 2
|
||||
public TOP_5 = 500000000000; // 3
|
||||
public TOP_6 = 600000000000; // 4-1-1
|
||||
public TOP_7 = 700000000000; // 4-1-2
|
||||
public TOP_8 = 800000000000; // 4-2-1-1
|
||||
public TOP_9 = 900000000000; // 4-2-1-2
|
||||
public TOP_10 = 1000000000000; // 4-2-2-1
|
||||
public TOP_11 = 1100000000000; // 4-2-2-2
|
||||
public TOP_12 = 1200000000000; // 5-1
|
||||
public TOP_13 = 1300000000000; // 5-2
|
||||
public TOP_14 = 1400000000000; // 6-1-1
|
||||
public TOP_15 = 10000000000000; // 6-1-2
|
||||
public TOP_16 = 20000000000000; // 6-2
|
||||
|
||||
|
||||
constructor(
|
||||
private httpCilent: HttpClientService
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
/* 获取显示列 */
|
||||
this.httpCilent.get('/assets/mock-data/airline-col_code.json').subscribe(
|
||||
data => {
|
||||
@@ -31,36 +54,229 @@ export class MainComponent implements OnInit {
|
||||
/* 获取航班动态信息 */
|
||||
this.httpCilent.get('/assets/mock-data/airline-data.json').subscribe(
|
||||
data => {
|
||||
this.airline_row_lists = []
|
||||
//解析数据
|
||||
data.forEach(element => {
|
||||
this.airline_row_lists.push(JSON.parse(element.value));
|
||||
let air_message = JSON.parse(element.value)
|
||||
this.airline_row_lists.push(air_message);
|
||||
});
|
||||
|
||||
//查找链接航班并将其组合成一条数据
|
||||
for (let i = 0; i < this.airline_row_lists.length; i++) {
|
||||
if (this.airline_row_lists[i]['MVIN'] === 'D') {
|
||||
if (this.airline_row_lists[i]['TAID']) {
|
||||
let index = this.airline_row_lists.findIndex(val => { return val['FLID'] === this.airline_row_lists[i]['TAID'] })
|
||||
if (index > -1) {
|
||||
this.airline_row_lists[i]['isLinked'] = true;
|
||||
this.airline_row_lists[i]['linkFlight'] = this.airline_row_lists[index];
|
||||
this.airline_row_lists.splice(index, 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** (0)000000+实际时间(到达航班有实际时间,且未超过1小时)
|
||||
(0-1)无链接航班,取实际(到达)时间
|
||||
(0-2)有链接航班,且出发航班未有实际时间,取实际(到达)时间
|
||||
(1)100000+商调完成时间(商调完成登机未开始)
|
||||
(2)110000+登机开始时间(登机开始尚未登机结束)
|
||||
(3)111000+登机结束时间(登机结束)
|
||||
(4)111100+计划/预计时间(无商调完成时间、登机开始时间、登机结束时间、航班实际完成时间)
|
||||
(4-1)无链接航班
|
||||
(4-1-1)若有预计时间则取预计时间
|
||||
(4-1-2)若无预计时间则取计划时间
|
||||
(4-2)有链接航班
|
||||
(4-2-1)若无实际到达时间,则
|
||||
(4-2-1-1)若有预计到达时间则取预计到达时间
|
||||
(4-2-1-2)若无预计到达时间则取计划到达时间
|
||||
(4-2-2)若有实际到达时间,
|
||||
(4-2-2-1)若有预计出发时间则取预计出发时间
|
||||
(4-2-2-2)若无预计出发时间则取计划出发时间
|
||||
(5)111110+计划/预计时间(航班取消)[只考虑无链接航班,因为链接航班不会有取消状态]
|
||||
(5-1)若有预计时间则取预计时间
|
||||
(5-2)若无预计时间则取计划时间
|
||||
(6)111111+实际时间(航班完成)
|
||||
(6-1)无链接航班,取实际(到达/出发)时间
|
||||
(6-1-1)到达航班有实际时间,且超过(含)1小时
|
||||
(6-1-2)出发航班有实际时间
|
||||
(6-2)有链接航班,取实际(出发)时间
|
||||
*/
|
||||
|
||||
//排序
|
||||
this.airline_row_lists.forEach(element => {
|
||||
if (element['ACTT']) {
|
||||
if (this.isArriFlight(element)) {
|
||||
if (!this.isOneHourLater(element['ACTT'])) {
|
||||
element['ORDER'] = 'TOP_1' //到港航班(无链接)有实际时间,且未超过一小时
|
||||
element['order'] = new Date(dateFormatter(element['ACTT'])).getTime() + this.TOP_1
|
||||
} else {
|
||||
element['ORDER'] = 'TOP_14' //到港航班(无链接)有实际时间,但超过一小时
|
||||
element['order'] = new Date(dateFormatter(element['ACTT'])).getTime() + this.TOP_14
|
||||
}
|
||||
} else if (this.isDeptFlight(element)) {
|
||||
element['ORDER'] = 'TOP_15' //出发航班(无链接)有实际时间
|
||||
element['order'] = new Date(dateFormatter(element['ACTT'])).getTime() + this.TOP_15
|
||||
} else if (this.isLinked(element)) {
|
||||
element['ORDER'] = 'TOP_16' //链接航班有实际出发时间
|
||||
element['order'] = new Date(dateFormatter(element['ACTT'])).getTime() + this.TOP_16
|
||||
}
|
||||
|
||||
} else {
|
||||
// if (element['SDSJ'] && !this.isBoading()) {
|
||||
// element['ORDER'] = 'TOP_3'
|
||||
// element['order'] = new Date(dateFormatter(element['SDSJ'])).getTime() + this.TOP_3
|
||||
// }
|
||||
// else if (this.isBoading() && !this.isOverBoading()){
|
||||
// element['ORDER'] = 'TOP_4'
|
||||
// element['order'] = new Date(dateFormatter(element['DJKS'])).getTime() + this.TOP_4
|
||||
// }else if(this.isOverBoading()){
|
||||
// element['ORDER'] = 'TOP_5'
|
||||
// element['order'] = new Date(dateFormatter(element['DJJS'])).getTime() + this.TOP_5
|
||||
// }else if(this.isCancled()){
|
||||
// if(element['ESTT']){
|
||||
// element['ORDER'] = 'TOP_12'
|
||||
// element['order'] = new Date(dateFormatter(element['ESTT'])).getTime() + this.TOP_12
|
||||
// }else{
|
||||
// element['ORDER'] = 'TOP_13'
|
||||
// element['order'] = new Date(dateFormatter(element['SODT'])).getTime() + this.TOP_13
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
if(this.isArriFlight(element)||this.isDeptFlight(element)){
|
||||
if(element['ESTT']){
|
||||
element['ORDER'] = 'TOP_6' //航班(无链接)无实际时间,取预计时间
|
||||
element['order'] = new Date(dateFormatter(element['ESTT'])).getTime() + this.TOP_6
|
||||
}else{
|
||||
element['ORDER'] = 'TOP_7' //航班(无链接)无实际时间和预计时间,取计划时间
|
||||
element['order'] = new Date(dateFormatter(element['SODT'])).getTime() + this.TOP_7
|
||||
}
|
||||
}else if(this.isLinked(element)){
|
||||
if(element['linkFlight']['ACTT']){
|
||||
element['ORDER'] = 'TOP_2' //链接航班有实际到达时间,无出发时间
|
||||
element['order'] = new Date(dateFormatter(element['linkFlight']['ACTT'])).getTime() + this.TOP_2
|
||||
}else if(!element['linkFlight']['ACTT']){
|
||||
if(element['linkFlight']['ESTT']){
|
||||
element['ORDER'] = 'TOP_8' //链接航班无实际到达时间,取预计到达时间
|
||||
element['order'] = new Date(dateFormatter(element['linkFlight']['ESTT'])).getTime() + this.TOP_8
|
||||
}else{
|
||||
element['ORDER'] = 'TOP_9' //链接航班无实际到达时间和预计到达时间,取计划到达时间
|
||||
element['order'] = new Date(dateFormatter(element['linkFlight']['SODT'])).getTime() + this.TOP_9
|
||||
}
|
||||
}
|
||||
// else if()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
this.airline_row_lists.sort(function (a, b) {
|
||||
return (a['order'] - b['order']);
|
||||
})
|
||||
}
|
||||
)
|
||||
/* 获取颜色数据 */
|
||||
// this.httpCilent.get('/assets/mock-data/airline-color.json').subscribe(
|
||||
// data => {
|
||||
// this.airline_color = data;
|
||||
// console.log(data);
|
||||
// }
|
||||
// )
|
||||
}
|
||||
|
||||
|
||||
selectRow($event, i) {
|
||||
this.row_state = i;
|
||||
}
|
||||
|
||||
findColor(items,marryItem){
|
||||
// console.log(items,marryItem);
|
||||
let index = items.findIndex(element=>{
|
||||
element.COL_CODE === marryItem;
|
||||
})
|
||||
console.log(index)
|
||||
if(index===-1){
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
getColor(col_CODE) {
|
||||
if (col_CODE === 'SODT') {
|
||||
return 'skyblue'
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 判断航班是否是链接航班
|
||||
* @return
|
||||
*/
|
||||
public isLinked(flight) {
|
||||
if (flight.isLinked) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断航班是否是纯离港航班
|
||||
* @return
|
||||
*/
|
||||
public isDeptFlight(flight) {
|
||||
if (flight.MVIN === 'D' && !flight.isLinked) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断航班是否是纯到港航班
|
||||
* @return
|
||||
*/
|
||||
public isArriFlight(flight) {
|
||||
if (flight.MVIN === 'A' && !flight.isLinked) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断航班是否已经执行完成
|
||||
* @return
|
||||
*/
|
||||
public isDone(flight) {
|
||||
if (this.isArriFlight(flight) && flight.ACTT) {
|
||||
return true;
|
||||
} else if (this.isDeptFlight(flight) && flight.ACTT) {
|
||||
return true;
|
||||
} else if (this.isLinked(flight) && flight.Actt) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断航班是否开始登机
|
||||
* @return
|
||||
*/
|
||||
public isBoading() {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* 判断航班是否登机结束
|
||||
* @return
|
||||
*/
|
||||
public isOverBoading() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断航班是否取消
|
||||
* @return
|
||||
*/
|
||||
public isCancled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断实际时间是否已超过一小时
|
||||
* @return
|
||||
*
|
||||
*/
|
||||
public isOneHourLater(dateString) {
|
||||
let nowTimeStamp = new Date().getTime()
|
||||
let actTimeStamp = new Date(dateFormatter(dateString)).getTime()
|
||||
if (nowTimeStamp - actTimeStamp > 3600000) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +1,13 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import {PipesModule} from '../../pipes/pipes.module';
|
||||
import { MainComponent } from './main.component';
|
||||
import { MainRoutingModule } from './main-routing.module'
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
PipesModule,
|
||||
MainRoutingModule
|
||||
],
|
||||
declarations: [MainComponent]
|
||||
|
||||
Reference in New Issue
Block a user