航班季度计划优化修改

This commit is contained in:
zhouyuejun
2019-02-18 10:06:09 +08:00
parent 107494c097
commit a61cdd7741
9 changed files with 361 additions and 253 deletions
@@ -1,8 +1,5 @@
.tab-container{
padding: 10px;
// height: 635px;
// overflow: auto;
// border: 1px solid #ccc;
.hr-line{
font-weight: bold;
}
+1 -1
View File
@@ -745,7 +745,7 @@ export class MainComponent implements OnInit {
let cols = this.col_lists;
for (let i = 0; i < cols.length; i++) {
if (item['renderFlight'][cols[i]['COL_CODE']]) {
if (item['renderFlight'][cols[i]['COL_CODE']].toString().match(new RegExp(this.SEARCH, 'i'))) {
if (item['renderFlight'][cols[i]['COL_CODE']].toString().match(new RegExp(this.LASTSEARCH, 'i'))) {
is_satis = true;
break;
} else {
@@ -2,7 +2,7 @@
<!-- <div class="hr-line">描述类 -----------------------------------------</div> -->
<div class="message-container">
<p class="mt-2"><label>航班号:</label>{{flight.flightNumber}}</p>
<p><label>航班季度:</label>{{flight.seasonRecId}}</p>
<p><label>航班季度:</label>{{flight.seasonName}}</p>
<p><label>国际代码:</label>{{flight.internationalCode}}</p>
<p><label>航空公司:</label>{{flight.airlineChnName}}</p>
<p><label>航线类别:</label>{{flight.routeTypeChn}}</p>
@@ -13,8 +13,9 @@
<p><label>结束日期:</label>{{flight.endDate}}</p>
<p><label>航线:</label>{{flight.startAirport}}</p>
<p><label>到达/出发:</label>{{flight.arriOrDeptChn}}</p>
<p><label>到达时间:</label>{{flight.arrivalTime}}</p>
<p><label>出发时间:</label>{{flight.departureTime}}</p>
<p><label>到达时间:</label>{{flight.arrivalTimeTra}}</p>
<p><label>出发时间:</label>{{flight.departureTimeTra}}</p>
<p><label>备注说明:</label>{{flight.remarks}}</p>
<p><label>机型:</label>{{flight.aircraftTypeName}}</p>
</div>
</div>
@@ -1,8 +1,5 @@
.tab-container{
padding: 10px;
height: 635px;
overflow: auto;
border: 1px solid #ccc;
.hr-line{
font-weight: bold;
}
@@ -10,10 +7,6 @@
padding: 5px 10px 5px 10px;
p{
margin: 0;
label{
width: 80px;
text-align: right;
}
}
}
}
@@ -3,7 +3,7 @@
<fieldset>
<legend>共享航班代码</legend>
<div>
<p>共享航班号:{{lines.flightNumber}}</p>
<p>共享航班号:{{lines.subAirlineId}}</p>
</div>
</fieldset>
</div>
@@ -11,9 +11,8 @@
<fieldset>
<legend>经停机场</legend>
<div>
<p *ngFor="let airport of airports"><label>{{airport.airport}}</label>(到达 &nbsp;&nbsp;{{airport.scat?airport.scat:'__ : __'}} &nbsp;&nbsp;| &nbsp;&nbsp;出发 &nbsp;&nbsp;{{airport.scdt?airport.scdt:'__ : __'}}</p>
</div>
</fieldset>
</div>
</div>
</div>
@@ -1,12 +1,12 @@
.tab-container {
padding: 10px 10px;
height: 635px;
overflow: auto;
border: 1px solid #ccc;
display: inline-block;
.fieldset-card {
fieldset {
padding: 5px 10px 20px 10px;
border: 1px solid #ccc;
display: inline-block;
min-width: 100%;
legend {
width: auto;
padding: 0 5px;
@@ -13,28 +13,10 @@ export class RelatedTabComponent implements OnInit {
public airports;
@Input() set flight(flight) {
this.lines = Object.assign({}, flight);
if (this.lines && !this.lines) {
this.airports = this.lines.split(' - ');
for (let i = 0; i < this.airports.length; i++) {
this.airports[i] = { airport: this.airports[i], scdt: this.utils.timeFormatter(this.lines[i].departureTime), scat: this.utils.timeFormatter(this.lines[i].arrivalTime) }
}
} else if (!this.lines && this.lines) {
this.airports = this.lines.split(' - ');
for (let i = 0; i < this.airports.length; i++) {
this.airports[i] = { airport: this.airports[i], scdt: this.utils.timeFormatter(this.lines[i].departureTime), scat: this.utils.timeFormatter(this.lines[i].arrivalTime) }
}
} else {
// this.lines[this.lines.length - 1] = this.lines[0];
// let concatArray = this.lines.arrivalTime.slice(1);
// let linkAirport = this.lines.arrivalTime.concat(concatArray)
if (this.lines.startAirport) {
this.airports = this.lines.startAirport.split(' - ');
for (let i = 0; i < this.airports.length; i++) {
this.airports[i] = { airport: this.airports[i], scdt: this.utils.timeFormatter(this.lines.departureTime), scat: this.utils.timeFormatter(this.lines.arrivalTime) }
}
}
}
// this.airports = this.lines.split(' - ');
// for (let i = 0; i < erutArr.length; i++) {
// this.airports[i] = { airport: erutArr[i], scdt: this.arrDeptTimeHandle(this.lines.departureTime), scat: "" }
// }
};
@@ -43,4 +25,12 @@ export class RelatedTabComponent implements OnInit {
ngOnInit() {
}
arrDeptTimeHandle(timeString) {
if(timeString){
return timeString.substr(0, 2) + ':' + timeString.substr(2, 3);
}else{
return '';
}
}
}
@@ -3,7 +3,7 @@
<div class="search-filter mb-3" #searchFilter>
<div class="first-condition row">
<div class="line-operator-left input-container mb-3 col-xlg-8 col-mlg-8 col-xl-8 col-lg-10">
<select class="mr-4 form-control" [(ngModel)]="SEL_COL" name="" id="">
<select class="mr-4 form-control" [(ngModel)]="SEL_COL" (ngModelChange)="resetPositionArray()" name="" id="">
<option value="">选择列名</option>
<option *ngFor="let col of render_col_lists" [value]="col.COL_CODE">{{col.COL_CN}}</option>
</select>
@@ -15,7 +15,11 @@
<input type="radio" [(ngModel)]="FLT_POS" [value]="2" name="filter-position">
<span>查找定位</span>
</label>
<input class="form-control" [(ngModel)]="SEARCH" type="text" (keyup.enter)="inputEnter()">
<input class="form-control mr-4" [(ngModel)]="SEARCH" (ngModelChange)="resetPositionArray()" type="text" (keyup.enter)="inputEnter()">
<label for="arriOrDept">查询年份:&nbsp;&nbsp;</label>
<select class="form-control" [(ngModel)]="filterYear" (ngModelChange)="selectYearChange($event)">
<option *ngFor="let year of yearLists" [value]="year">{{year}}</option>
</select>
</div>
<div class="line-operator-right mb-3 col-xlg-4 col-mlg-4 col-xl-4 col-lg-2">
<button type="button" class="btn btn-info mr-2" (click)="toggleFilter()">{{filterClose?'展开':'关闭'}}</button>
@@ -28,7 +32,7 @@
<label for="airlineId">航空公司:&nbsp;&nbsp;</label>
<select class="form-control" [(ngModel)]="filterItems.airlineId" (ngModelChange)="selectChange()">
<option value=""></option>
<option *ngFor="let item of airlines" [value]="item.airlineId">{{item.airlineName}}</option>
<option *ngFor="let item of airlinesSelections" [value]="item.airlineId">{{item.airlineName}}</option>
</select>
</div>
<div class="input-container mr-4">
@@ -45,13 +49,9 @@
<label for="flightTypeCode">航班类别:&nbsp;&nbsp;</label>
<select class="form-control" [(ngModel)]="filterItems.flightTypeCode" (ngModelChange)="selectChange()">
<option value=""></option>
<option *ngFor="let item of flightTypes" [value]="item.flightTypeCode">{{item.flightTypeNameCn}}</option>
<option *ngFor="let item of flightTypeSelections" [value]="item.flightTypeCode">{{item.flightTypeNameCn}}</option>
</select>
</div>
<!-- <div class="input-container mr-4">
<label for="startDate">查询年份:&nbsp;&nbsp;</label>
<input readonly type="text" id="startDate" class="form-control" style="background:transparent;cursor: pointer">
</div> -->
<div class="input-container mr-4">
<label for="arriOrDept">到达/出发:&nbsp;&nbsp;</label>
<select class="form-control" [(ngModel)]="filterItems.arriOrDept" (ngModelChange)="selectChange()">
@@ -60,12 +60,6 @@
<option value="D">出发</option>
</select>
</div>
<div class="input-container mr-4">
<label for="arriOrDept">查询年份:&nbsp;&nbsp;</label>
<select class="form-control" [(ngModel)]="filterYear" (ngModelChange)="selectYearChange($event)">
<option *ngFor="let year of yearLists" [value]="year">{{year}}</option>
</select>
</div>
</div>
<div class="third-condition row" [ngClass]="{'filterClose-c':filterClose,'filterClose-o':!filterClose}">
<label class="radio-inline custom-checkbox nowrap mr-4">
@@ -92,72 +86,25 @@
</table>
</div>
<div class="table-body" #tableBody (scroll)="handleScroll($event)">
<div class="list-view-phantom" [ngStyle]="{ 'height': combined_data.length * 42 + 'px' }"></div>
<table #tableContent id="table" class="table table-striped">
<tbody>
<tr *ngFor="let seasonal of render_data;let i = index" (click)="selectRow(seasonal)">
<div class="list-view-phantom" [ngStyle]="{ 'height': wait_render_data.length * 42 + 'px' }"></div>
<table #tableContent id="table" class="table table-striped">
<tbody>
<ng-container *ngFor="let seasonal of render_data;last as isLast;index as i">
<tr *ngIf="setWidth(isLast)" (click)="selectRow(seasonal)" [ngClass]="{'selected':getSelectedRow(seasonal)}">
<td style="min-width:55px">{{start+i+1}}</td>
<td *ngFor="let airline_col of render_col_lists" [ngStyle]="{'min-width':airline_col.COL_WIDTH}" [title]="seasonal[airline_col.COL_CODE]">{{seasonal[airline_col.COL_CODE]}}</td>
<td *ngFor="let airline_col of render_col_lists" [ngStyle]="{'min-width':airline_col.COL_WIDTH}">{{seasonal[airline_col.COL_CODE]}}</td>
</tr>
</tbody>
</table>
</div>
<!-- <table id="table" class="table table-bordered table-striped">
<thead>
<tr>
<th>序号</th>
<th>航班号</th>
<th>航班季度</th>
<th>国际代码</th>
<th>航空公司</th>
<th>航线类别</th>
<th>航班类别</th>
<th>运营日</th>
<th>开始日期</th>
<th>结束日期</th>
<th>航线</th>
<th>进/出港</th>
<th>到达时间</th>
<th>出发时间</th>
<th>机型</th>
<th>飞行距离(千米)</th>
<th>飞行时间(分钟)</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let seasonal of render_data;let i = index" (click)="selectRow(seasonal)" [ngClass]="{'selected':row_state.seasonflightId===seasonal.seasonflightId}">
<td>{{i+1}}</td>
<td>{{seasonal.flightNumber}}</td>
<td>{{seasonal.seasonRecIdChn}}</td>
<td>{{seasonal.internationalCode}}</td>
<td>{{seasonal.airlineChnName}}</td>
<td>{{seasonal.routeTypeChn}}</td>
<td>{{seasonal.flightTypeChnName}}</td>
<td>{{seasonal.operationDays}}</td>
<td>{{seasonal.startDate}}</td>
<td>{{seasonal.endDate}}</td>
<td>{{seasonal.AirportChn}}</td>
<td>{{seasonal.arriOrDeptChn}}</td>
<td>{{seasonal.arrivalTimeTra}}</td>
<td>{{seasonal.departureTimeTra}}</td>
<td>{{seasonal.aircraftTypeName}}</td>
<td>{{seasonal.flyingDistance}}</td>
<td>{{seasonal.flyingTime}}</td>
</tr>
</tbody>
</table> -->
</ng-container>
</tbody>
</table>
</div>
</div>
<div class="airline-message" [ngClass]="{'tab-c': tabClose,'tab-o': !tabClose}">
<div #tabContainer class="airline-message" [ngClass]="{'tab-c': tabClose,'tab-o': !tabClose}">
<nz-tabset [nzTabPosition]="'top'" [nzType]="'card'" [nzShowPagination]="false">
<nz-tab nzTitle="关联信息" (nzClick)="nzClick()" *ngIf="checkboxGroup.related">
<nz-tab nzTitle="关联信息" *ngIf="checkboxGroup.related">
<app-related-tab [flight]="row_state"></app-related-tab>
</nz-tab>
<nz-tab nzTitle="详细信息" (nzClick)="nzClick()" *ngIf="checkboxGroup.detail">
<nz-tab nzTitle="详细信息" *ngIf="checkboxGroup.detail">
<app-detail-tab [flight]="row_state"></app-detail-tab>
</nz-tab>
</nz-tabset>
@@ -26,32 +26,12 @@ export class SeasonalPlanComponent implements OnInit {
'detail': false
}
//选择列名
// public col_lists = [
// { col_code: 'flightNumber', col_chn: '航班号' },
// { col_code: 'seasonName', col_chn: '航班季度' },
// { col_code: 'internationalCode', col_chn: '国际代码' },
// { col_code: 'airlineChnName', col_chn: '航空公司' },
// { col_code: 'routeTypeChn', col_chn: '航线类别' },
// { col_code: 'flightTypeChnName', col_chn: '航班类别' },
// /* { col_code: 'flightTask', col_chn: '航班任务' }, */
// { col_code: 'operationDays', col_chn: '运营日' },
// { col_code: 'startDate', col_chn: '开始日期' },
// { col_code: 'endDate', col_chn: '结束日期' },
// { col_code: 'routChn', col_chn: '航线' },
// { col_code: 'arriOrDeptChn', col_chn: '进/出港' },
// { col_code: 'arrivalTimeTra', col_chn: '到达时间' },
// { col_code: 'departureTimeTra', col_chn: '出发时间' },
// { col_code: 'aircraftTypeName', col_chn: '机型' },
// { col_code: 'flyingDistance', col_chn: '飞行距离(千米)' },
// { col_code: 'flyingTime', col_chn: '飞行时间(分钟)' },
// ]
// 搜索条件
SEARCH = ''; //手动输入条件
LASTSEARCH = '';
FLT_POS = 1; //过滤还是定位
SEL_COL = ''; //选择列名
LAST_SEL_COL = '';
public filterItems = {
airlineId: '', //航空公司
routeType: '', //航线类别
@@ -59,6 +39,7 @@ export class SeasonalPlanComponent implements OnInit {
arriOrDept: '', //到达/出发
/* flightTask: '', //航班任务 */
}
public tabClose: boolean = true;
yearLists: Array<any>;
@@ -71,10 +52,14 @@ export class SeasonalPlanComponent implements OnInit {
flightTypes: Array<any>; //航班类别
airports: Array<any>; //机场
public airlinesSelections: Array<any> = [];
public flightTypeSelections: Array<any> = [];
public row_state: any = {};
public combined_data: Array<object> = []; //组合数据,经过转换后的
public wait_render_data: Array<object> = [];
public render_data: Array<object> = []; //显示数据,即需要显示的数据
public selectedFilterData: Array<object> = [];
public render_col_lists: Array<object> = [
{ "COL_CODE": "flightNumber", "COL_CN": "航班号", "COL_WIDTH": "85px" },
@@ -111,11 +96,6 @@ export class SeasonalPlanComponent implements OnInit {
scrollTop: number = 0;
ngOnInit() {
this.renderer2.setStyle(this.tableContainer.nativeElement, 'height', this.pageContent.nativeElement.offsetHeight - this.searchFilter.nativeElement.offsetHeight - 35 + 'px');
this.renderer2.setStyle(this.tableBody.nativeElement, 'height', this.tableContainer.nativeElement.offsetHeight - this.tableHead.nativeElement.offsetHeight + 'px');
if (!this.tabClose) {
this.renderer2.setStyle(this.tabContainer.nativeElement, 'height', this.pageContent.nativeElement.offsetHeight - this.searchFilter.nativeElement.offsetHeight - 35 + 'px');
}
window.onresize = function () {
this.calcVisibleCount();
}.bind(this)
@@ -143,7 +123,6 @@ export class SeasonalPlanComponent implements OnInit {
this.basicDataService.airport_subject.subscribe(
data => {
this.airports = data;
this.dataTransfer();
}
)
this.basicDataService.flightTypes_subject.subscribe(
@@ -154,7 +133,7 @@ export class SeasonalPlanComponent implements OnInit {
this.basicDataService.airline_subject.subscribe(
data => {
this.airlines = data;
this.dataTransfer();
}
)
}
@@ -164,13 +143,6 @@ export class SeasonalPlanComponent implements OnInit {
).catch(err => {
alert('请求失败')
})
var tableCont = document.querySelector('#table-container');
function scrollHandle() {
var scrollTop = this.scrollTop;
this.querySelector('thead').style.transform = 'translateY(' + scrollTop + 'px)';
}
tableCont.addEventListener('scroll', scrollHandle);
}
//航空公司名称数据转换处理
@@ -273,6 +245,14 @@ export class SeasonalPlanComponent implements OnInit {
//数据转换统一处理
dataTransfer() {
this.seasonals.forEach(item => {
if (this.airlinesSelections.findIndex(airline => airline.airlineId === item.airlineId) === -1) {
let index = this.airlines.findIndex(val => val.airlineId === item.airlineId);
this.airlinesSelections.push(this.airlines[index]);
}
if (this.flightTypeSelections.findIndex(flightType => flightType.flightTypeCode === item.flightTypeCode) === -1) {
let index = this.flightTypes.findIndex(val => val.flightTypeCode === item.flightTypeCode);
this.flightTypeSelections.push(this.flightTypes[index]);
}
let line = Object.assign({}, item);
line = this.airlinesHandle(line);
line = this.aircraftTypesHandle(line);
@@ -285,25 +265,21 @@ export class SeasonalPlanComponent implements OnInit {
})
this.wait_render_data = this.combined_data;
this.selectedFilterData = this.combined_data;
this.calcVisibleCount();
this.visibleCount = Math.ceil(this.tableBody.nativeElement.clientHeight / this.trItemHeight);
const scrollTop = this.tableBody.nativeElement.scrollTop;
const fixedScrollTop = scrollTop - scrollTop % this.trItemHeight;
this.tableContent.nativeElement.style.webkitTransform = `translateY(${fixedScrollTop}px)`;
this.start = Math.floor(scrollTop / this.trItemHeight);
this.end = this.start + this.visibleCount;
this.render_data = this.wait_render_data.slice(this.start, this.end);
setTimeout(() => {
$(".table-body tbody>tr").eq(0).find('td').each((index, element) => {
$(".table-head table thead tr").eq(0).find('th').eq(index).attr('width', $(element).innerWidth() + 'px');
})
}, 500)
//默认选中第一条
if (this.render_data.length > 0) {
this.row_state = this.render_data[0];
}
this.operateSpinServiceService.hideSpin();
}
//查询年份事件
selectYearChange($event) {
this.operateSpinServiceService.showSpin();
this.positionedArray = []; //定位数组为清空
this.positionArrayIndex = 0; //定位元素Index归零
this.SEARCH = '';
this.FLT_POS = 1;
this.SEL_COL = '';
@@ -333,6 +309,19 @@ export class SeasonalPlanComponent implements OnInit {
}, 10)
}
/**
* 设置动态设置单元格的宽度
* @param isLast
*/
setWidth(isLast) {
if (isLast) {
$(".table-body tbody>tr").eq(0).find('td').each((index, element) => {
$(".table-head table thead tr").eq(0).find('th').eq(index).attr('width', $(element).innerWidth() + 'px');
})
}
return true;
}
/**
* 纵向滚动条滚动渲染数据
*/
@@ -344,11 +333,6 @@ export class SeasonalPlanComponent implements OnInit {
this.start = Math.floor(scrollTop / this.trItemHeight);
this.end = this.start + this.visibleCount;
this.render_data = this.wait_render_data.slice(this.start, this.end);
setTimeout(() => {
$(".table-body tbody>tr").eq(0).find('td').each((index, element) => {
$(".table-head table thead tr").eq(0).find('th').eq(index).attr('width', $(element).innerWidth() + 'px');
})
}, 500)
}
/**
@@ -368,28 +352,30 @@ export class SeasonalPlanComponent implements OnInit {
this.start = Math.floor(scrollTop / this.trItemHeight);
this.end = this.start + this.visibleCount;
this.render_data = this.wait_render_data.slice(this.start, this.end);
setTimeout(() => {
$(".table-body tbody>tr").eq(0).find('td').each((index, element) => {
$(".table-head table thead tr").eq(0).find('th').eq(index).attr('width', $(element).innerWidth() + 'px');
})
}, 500)
}
/**
* 复选框勾选事件
*/
checkboxChange() {
let tabClose = true
for (const key in this.checkboxGroup) {
if (this.checkboxGroup.hasOwnProperty(key)) {
if (this.checkboxGroup[key]) {
this.tabClose = false;
tabClose = false;
break;
} else {
this.tabClose = true;
tabClose = true;
continue;
}
}
}
this.tabClose = tabClose;
if (!this.tabClose) {
setTimeout(() => {
this.renderer2.setStyle(this.tabContainer.nativeElement, 'height', this.pageContent.nativeElement.offsetHeight - this.searchFilter.nativeElement.offsetHeight - 35 + 'px');
}, 10)
}
}
/**
@@ -407,10 +393,26 @@ export class SeasonalPlanComponent implements OnInit {
this.row_state = seasonal;
}
/**
* 选中高亮
* @param seasonal
*/
getSelectedRow(seasonal) {
if (seasonal.seasonflightId === this.row_state.seasonflightId) {
return true;
} else {
return false;
}
}
//输入框回车事件
inputEnter() {
if (this.FLT_POS === 1) {
this.selectChange()
this.LAST_SEL_COL = this.SEL_COL;
this.LASTSEARCH = this.SEARCH;
this.operateSpinServiceService.showSpin();
this.inputFilter(this.selectedFilterData);
// this.selectChange()
} else {
this.inputPosition(this.wait_render_data)
}
@@ -419,46 +421,58 @@ export class SeasonalPlanComponent implements OnInit {
//下拉框选择筛选
selectChange() {
this.operateSpinServiceService.showSpin();
setTimeout(() => {
let filter_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;
}
this.positionedArray = [];
this.positionArrayIndex = 0;
let filter_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(filter_data);
} else {
this.wait_render_data = filter_data;
this.render_data = this.wait_render_data.slice(this.start, this.end);
setTimeout(() => {
$(".table-body tbody>tr").eq(0).find('td').each((index, element) => {
$(".table-head table thead tr").eq(0).find('th').eq(index).attr('width', $(element).innerWidth() + 'px');
})
}, 500)
this.row_state = this.render_data.length > 0 ? this.render_data[0] : {};
this.operateSpinServiceService.hideSpin();
}
}, 10)
return is_satis;
})
this.selectedFilterData = filter_data;
if (this.FLT_POS === 1) {
this.inputFilter(filter_data);
} else {
this.wait_render_data = filter_data;
this.render_data = this.wait_render_data.slice(this.start, this.end);
let hasSelectedRow: boolean = false;
for (let i = 0; i < this.wait_render_data.length; i++) {
let seasonal = this.wait_render_data[i];
if (seasonal['seasonflightId'] === this.row_state.seasonflightId) {
this.row_state = seasonal;
hasSelectedRow = true;
break;
}
}
if (!hasSelectedRow) {
if (this.render_data.length > 0) {
this.row_state = this.render_data[0];
}
}
this.operateSpinServiceService.hideSpin();
}
}
//输入框筛选
inputFilter(filterData) {
if (this.SEARCH) {
if (this.SEL_COL) {
let sel_col = this.SEL_COL;
if (this.LASTSEARCH) {
if (this.LAST_SEL_COL) {
let sel_col = this.LAST_SEL_COL;
filterData = filterData.filter(item => {
if (item[sel_col]) {
if (item[sel_col].toString().match(new RegExp(this.SEARCH, 'i'))) {
if (item[sel_col].toString().match(new RegExp(this.LASTSEARCH, 'i'))) {
return true;
}
} else {
@@ -471,7 +485,7 @@ export class SeasonalPlanComponent implements OnInit {
let cols = this.render_col_lists;
for (let i = 0; i < cols.length; i++) {
if (item[cols[i]['COL_CODE']]) {
if (item[cols[i]['COL_CODE']].toString().match(new RegExp(this.SEARCH, 'i'))) {
if (item[cols[i]['COL_CODE']].toString().match(new RegExp(this.LASTSEARCH, 'i'))) {
is_satis = true;
break;
} else {
@@ -489,76 +503,243 @@ export class SeasonalPlanComponent implements OnInit {
}
this.wait_render_data = filterData;
this.render_data = this.wait_render_data.slice(this.start, this.end);
setTimeout(() => {
$(".table-body tbody>tr").eq(0).find('td').each((index, element) => {
$(".table-head table thead tr").eq(0).find('th').eq(index).attr('width', $(element).innerWidth() + 'px');
})
}, 500)
this.operateSpinServiceService.hideSpin();
let hasSelectedRow: boolean = false;
for (let i = 0; i < this.wait_render_data.length; i++) {
let seasonal = this.wait_render_data[i];
if (seasonal['seasonflightId'] === this.row_state.seasonflightId) {
this.row_state = seasonal;
hasSelectedRow = true;
break;
}
}
if (!hasSelectedRow) {
if (this.render_data.length > 0) {
this.row_state = this.render_data[0];
}
}
this.operateSpinServiceService.hideSpin();
}
positionArray: Array<any> = [];
positionedArray: Array<any> = [];
positionArrayIndex: number = 0;
//输入框定位
inputPosition(filterData) {
let transArray = []
let hasSearchData: boolean = false;
let hasPositionedEle: boolean = false;
if (this.SEL_COL) {
let sel_col = this.SEL_COL;
filterData.forEach(element => {
if (element[sel_col]) {
if (element[sel_col].toString().match(new RegExp(this.SEARCH, 'i'))) {
transArray.push(element)
for (let i = 0; i < filterData.length; i++) {
if (i === filterData.length - 1) {
this.positionedArray = [];
this.positionArrayIndex = 0;
}
let fliterElement = filterData[i];
if (fliterElement[sel_col]) {
if (fliterElement[sel_col].toString().match(new RegExp(this.SEARCH, 'i'))) {
let hasThisEle: boolean = false;
hasSearchData = true;
for (let k = 0; k < this.positionedArray.length; k++) {
let positionedElement = this.positionedArray[k];
let diffResult = (positionedElement.seasonflightId === fliterElement.seasonflightId);
if (diffResult) {
hasThisEle = true;
break;
} else {
continue;
}
};
if (!hasThisEle) {
hasPositionedEle = true;
this.row_state = fliterElement;
this.positionArrayIndex = i;
this.positionedArray.push(fliterElement);
break;
}
} else {
continue;
}
} else {
if (!this.SEARCH) {
transArray.push(element)
let hasThisEle: boolean = false;
hasSearchData = true;
for (let k = 0; k < this.positionedArray.length; k++) {
let positionedElement = this.positionedArray[k];
let diffResult = (positionedElement.seasonflightId === fliterElement.seasonflightId);
if (diffResult) {
hasThisEle = true;
break;
} else {
continue;
}
};
if (!hasThisEle) {
hasPositionedEle = true;
this.row_state = fliterElement;
this.positionArrayIndex = i;
this.positionedArray.push(fliterElement);
break;
}
} else {
continue;
}
}
});
}
} else {
filterData.forEach(element => {
let cols = this.render_col_lists;
for (let i = 0; i < cols.length; i++) {
if (element[cols[i]['COL_CODE']]) {
if (element[cols[i]['COL_CODE']].toString().match(new RegExp(this.SEARCH, 'i'))) {
transArray.push(element)
let cols = this.render_col_lists;
for (let i = 0; i < filterData.length; i++) {
if (i === filterData.length - 1) {
this.positionedArray = [];
this.positionArrayIndex = 0;
}
let positionIsOk: boolean = false;
let filterElement = filterData[i];
for (let j = 0; j < cols.length; j++) {
let elementCol = cols[j];
if (filterElement[elementCol['COL_CODE']]) {
if (filterElement[elementCol['COL_CODE']].toString().match(new RegExp(this.SEARCH, 'i'))) {
let hasThisEle: boolean = false;
hasSearchData = true;
for (let k = 0; k < this.positionedArray.length; k++) {
let positionedElement = this.positionedArray[k];
let diffResult = (positionedElement.seasonflightId === filterElement.seasonflightId);
if (diffResult) {
hasThisEle = true;
break;
} else {
continue;
}
};
if (!hasThisEle) {
hasPositionedEle = true;
positionIsOk = true;
this.row_state = filterElement;
this.positionArrayIndex = i;
this.positionedArray.push(filterElement);
}
break;
} else {
continue;
}
} else {
if (this.SEARCH) {
continue;
} else {
transArray.push(element)
if (!this.SEARCH) {
let hasThisEle: boolean = false;
hasSearchData = true;
for (let k = 0; k < this.positionedArray.length; k++) {
let positionedElement = this.positionedArray[k];
let diffResult = (positionedElement.seasonflightId === filterElement.seasonflightId);
if (diffResult) {
hasThisEle = true;
break;
} else {
continue;
}
};
if (!hasThisEle) {
hasPositionedEle = true;
positionIsOk = true;
this.row_state = filterElement;
this.positionArrayIndex = i;
this.positionedArray.push(filterElement);
}
break;
} else {
continue;
}
}
}
});
if (positionIsOk) {
break;
}
}
}
if (transArray.length > 0) {
if (transArray.toString() == this.positionArray.toString()) {
this.positionArrayIndex++;
if (this.positionArrayIndex === this.positionArray.length) {
this.positionArrayIndex = 0;
}
this.row_state = this.positionArray[this.positionArrayIndex];
} else {
this.positionArray = transArray;
this.positionArrayIndex = 0;
this.row_state = this.positionArray[this.positionArrayIndex];
}
} else {
alert('没有搜索到相关数据');
if (!hasSearchData) {
alert("没有搜索到相关数据");
}
let tr = $(".selected");
let objTr = tr[0];
if (objTr) {
$("#table-container").animate({ scrollTop: objTr.offsetTop - 42 }, "slow");
if (hasPositionedEle) {
const scrollTop = this.positionArrayIndex * this.trItemHeight
this.tableBody.nativeElement.scrollTop = scrollTop;
}
// let transArray = []
// if (this.SEL_COL) {
// let sel_col = this.SEL_COL;
// filterData.forEach(element => {
// if (element[sel_col]) {
// if (element[sel_col].toString().match(new RegExp(this.SEARCH, 'i'))) {
// transArray.push(element)
// }
// } else {
// if (!this.SEARCH) {
// transArray.push(element)
// }
// }
// });
// } else {
// filterData.forEach(element => {
// let cols = this.render_col_lists;
// for (let i = 0; i < cols.length; i++) {
// if (element[cols[i]['COL_CODE']]) {
// if (element[cols[i]['COL_CODE']].toString().match(new RegExp(this.SEARCH, 'i'))) {
// transArray.push(element)
// break;
// } else {
// continue;
// }
// } else {
// if (this.SEARCH) {
// continue;
// } else {
// transArray.push(element)
// break;
// }
// }
// }
// });
// }
// if (transArray.length > 0) {
// if (transArray.toString() == this.positionArray.toString()) {
// this.positionArrayIndex++;
// if (this.positionArrayIndex === this.positionArray.length) {
// this.positionArrayIndex = 0;
// }
// this.row_state = this.positionArray[this.positionArrayIndex];
// } else {
// this.positionArray = transArray;
// this.positionArrayIndex = 0;
// this.row_state = this.positionArray[this.positionArrayIndex];
// }
// } else {
// alert('没有搜索到相关数据');
// }
// let tr = $(".selected");
// let objTr = tr[0];
// if (objTr) {
// $("#table-container").animate({ scrollTop: objTr.offsetTop - 42 }, "slow");
// }
}
/**
* 重置定位数组
*/
resetPositionArray() {
this.positionedArray = [];
this.positionArrayIndex = 0;
}
}