航班季度计划优化修改

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{ .tab-container{
padding: 10px; padding: 10px;
// height: 635px;
// overflow: auto;
// border: 1px solid #ccc;
.hr-line{ .hr-line{
font-weight: bold; font-weight: bold;
} }
+1 -1
View File
@@ -745,7 +745,7 @@ export class MainComponent implements OnInit {
let cols = this.col_lists; let cols = this.col_lists;
for (let i = 0; i < cols.length; i++) { for (let i = 0; i < cols.length; i++) {
if (item['renderFlight'][cols[i]['COL_CODE']]) { 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; is_satis = true;
break; break;
} else { } else {
@@ -2,7 +2,7 @@
<!-- <div class="hr-line">描述类 -----------------------------------------</div> --> <!-- <div class="hr-line">描述类 -----------------------------------------</div> -->
<div class="message-container"> <div class="message-container">
<p class="mt-2"><label>航班号:</label>{{flight.flightNumber}}</p> <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.internationalCode}}</p>
<p><label>航空公司:</label>{{flight.airlineChnName}}</p> <p><label>航空公司:</label>{{flight.airlineChnName}}</p>
<p><label>航线类别:</label>{{flight.routeTypeChn}}</p> <p><label>航线类别:</label>{{flight.routeTypeChn}}</p>
@@ -13,8 +13,9 @@
<p><label>结束日期:</label>{{flight.endDate}}</p> <p><label>结束日期:</label>{{flight.endDate}}</p>
<p><label>航线:</label>{{flight.startAirport}}</p> <p><label>航线:</label>{{flight.startAirport}}</p>
<p><label>到达/出发:</label>{{flight.arriOrDeptChn}}</p> <p><label>到达/出发:</label>{{flight.arriOrDeptChn}}</p>
<p><label>到达时间:</label>{{flight.arrivalTime}}</p> <p><label>到达时间:</label>{{flight.arrivalTimeTra}}</p>
<p><label>出发时间:</label>{{flight.departureTime}}</p> <p><label>出发时间:</label>{{flight.departureTimeTra}}</p>
<p><label>备注说明:</label>{{flight.remarks}}</p>
<p><label>机型:</label>{{flight.aircraftTypeName}}</p> <p><label>机型:</label>{{flight.aircraftTypeName}}</p>
</div> </div>
</div> </div>
@@ -1,8 +1,5 @@
.tab-container{ .tab-container{
padding: 10px; padding: 10px;
height: 635px;
overflow: auto;
border: 1px solid #ccc;
.hr-line{ .hr-line{
font-weight: bold; font-weight: bold;
} }
@@ -10,10 +7,6 @@
padding: 5px 10px 5px 10px; padding: 5px 10px 5px 10px;
p{ p{
margin: 0; margin: 0;
label{
width: 80px;
text-align: right;
}
} }
} }
} }
@@ -3,7 +3,7 @@
<fieldset> <fieldset>
<legend>共享航班代码</legend> <legend>共享航班代码</legend>
<div> <div>
<p>共享航班号:{{lines.flightNumber}}</p> <p>共享航班号:{{lines.subAirlineId}}</p>
</div> </div>
</fieldset> </fieldset>
</div> </div>
@@ -11,9 +11,8 @@
<fieldset> <fieldset>
<legend>经停机场</legend> <legend>经停机场</legend>
<div> <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> </div>
</fieldset> </fieldset>
</div> </div>
</div> </div>
@@ -1,12 +1,12 @@
.tab-container { .tab-container {
padding: 10px 10px; padding: 10px 10px;
height: 635px; display: inline-block;
overflow: auto;
border: 1px solid #ccc;
.fieldset-card { .fieldset-card {
fieldset { fieldset {
padding: 5px 10px 20px 10px; padding: 5px 10px 20px 10px;
border: 1px solid #ccc; border: 1px solid #ccc;
display: inline-block;
min-width: 100%;
legend { legend {
width: auto; width: auto;
padding: 0 5px; padding: 0 5px;
@@ -13,28 +13,10 @@ export class RelatedTabComponent implements OnInit {
public airports; public airports;
@Input() set flight(flight) { @Input() set flight(flight) {
this.lines = Object.assign({}, flight); this.lines = Object.assign({}, flight);
if (this.lines && !this.lines) { // this.airports = this.lines.split(' - ');
this.airports = this.lines.split(' - '); // for (let i = 0; i < erutArr.length; i++) {
for (let i = 0; i < this.airports.length; i++) { // this.airports[i] = { airport: erutArr[i], scdt: this.arrDeptTimeHandle(this.lines.departureTime), scat: "" }
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) }
}
}
}
}; };
@@ -43,4 +25,12 @@ export class RelatedTabComponent implements OnInit {
ngOnInit() { 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="search-filter mb-3" #searchFilter>
<div class="first-condition row"> <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"> <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 value="">选择列名</option>
<option *ngFor="let col of render_col_lists" [value]="col.COL_CODE">{{col.COL_CN}}</option> <option *ngFor="let col of render_col_lists" [value]="col.COL_CODE">{{col.COL_CN}}</option>
</select> </select>
@@ -15,7 +15,11 @@
<input type="radio" [(ngModel)]="FLT_POS" [value]="2" name="filter-position"> <input type="radio" [(ngModel)]="FLT_POS" [value]="2" name="filter-position">
<span>查找定位</span> <span>查找定位</span>
</label> </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>
<div class="line-operator-right mb-3 col-xlg-4 col-mlg-4 col-xl-4 col-lg-2"> <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> <button type="button" class="btn btn-info mr-2" (click)="toggleFilter()">{{filterClose?'展开':'关闭'}}</button>
@@ -28,7 +32,7 @@
<label for="airlineId">航空公司:&nbsp;&nbsp;</label> <label for="airlineId">航空公司:&nbsp;&nbsp;</label>
<select class="form-control" [(ngModel)]="filterItems.airlineId" (ngModelChange)="selectChange()"> <select class="form-control" [(ngModel)]="filterItems.airlineId" (ngModelChange)="selectChange()">
<option value=""></option> <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> </select>
</div> </div>
<div class="input-container mr-4"> <div class="input-container mr-4">
@@ -45,13 +49,9 @@
<label for="flightTypeCode">航班类别:&nbsp;&nbsp;</label> <label for="flightTypeCode">航班类别:&nbsp;&nbsp;</label>
<select class="form-control" [(ngModel)]="filterItems.flightTypeCode" (ngModelChange)="selectChange()"> <select class="form-control" [(ngModel)]="filterItems.flightTypeCode" (ngModelChange)="selectChange()">
<option value=""></option> <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> </select>
</div> </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"> <div class="input-container mr-4">
<label for="arriOrDept">到达/出发:&nbsp;&nbsp;</label> <label for="arriOrDept">到达/出发:&nbsp;&nbsp;</label>
<select class="form-control" [(ngModel)]="filterItems.arriOrDept" (ngModelChange)="selectChange()"> <select class="form-control" [(ngModel)]="filterItems.arriOrDept" (ngModelChange)="selectChange()">
@@ -60,12 +60,6 @@
<option value="D">出发</option> <option value="D">出发</option>
</select> </select>
</div> </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>
<div class="third-condition row" [ngClass]="{'filterClose-c':filterClose,'filterClose-o':!filterClose}"> <div class="third-condition row" [ngClass]="{'filterClose-c':filterClose,'filterClose-o':!filterClose}">
<label class="radio-inline custom-checkbox nowrap mr-4"> <label class="radio-inline custom-checkbox nowrap mr-4">
@@ -92,72 +86,25 @@
</table> </table>
</div> </div>
<div class="table-body" #tableBody (scroll)="handleScroll($event)"> <div class="table-body" #tableBody (scroll)="handleScroll($event)">
<div class="list-view-phantom" [ngStyle]="{ 'height': combined_data.length * 42 + 'px' }"></div> <div class="list-view-phantom" [ngStyle]="{ 'height': wait_render_data.length * 42 + 'px' }"></div>
<table #tableContent id="table" class="table table-striped"> <table #tableContent id="table" class="table table-striped">
<tbody> <tbody>
<tr *ngFor="let seasonal of render_data;let i = index" (click)="selectRow(seasonal)"> <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 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> </tr>
</tbody> </ng-container>
</table> </tbody>
</div> </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> -->
</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-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> <app-related-tab [flight]="row_state"></app-related-tab>
</nz-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> <app-detail-tab [flight]="row_state"></app-detail-tab>
</nz-tab> </nz-tab>
</nz-tabset> </nz-tabset>
@@ -26,32 +26,12 @@ export class SeasonalPlanComponent implements OnInit {
'detail': false '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 = ''; //手动输入条件 SEARCH = ''; //手动输入条件
LASTSEARCH = '';
FLT_POS = 1; //过滤还是定位 FLT_POS = 1; //过滤还是定位
SEL_COL = ''; //选择列名 SEL_COL = ''; //选择列名
LAST_SEL_COL = '';
public filterItems = { public filterItems = {
airlineId: '', //航空公司 airlineId: '', //航空公司
routeType: '', //航线类别 routeType: '', //航线类别
@@ -59,6 +39,7 @@ export class SeasonalPlanComponent implements OnInit {
arriOrDept: '', //到达/出发 arriOrDept: '', //到达/出发
/* flightTask: '', //航班任务 */ /* flightTask: '', //航班任务 */
} }
public tabClose: boolean = true; public tabClose: boolean = true;
yearLists: Array<any>; yearLists: Array<any>;
@@ -71,10 +52,14 @@ export class SeasonalPlanComponent implements OnInit {
flightTypes: Array<any>; //航班类别 flightTypes: Array<any>; //航班类别
airports: Array<any>; //机场 airports: Array<any>; //机场
public airlinesSelections: Array<any> = [];
public flightTypeSelections: Array<any> = [];
public row_state: any = {}; public row_state: any = {};
public combined_data: Array<object> = []; //组合数据,经过转换后的 public combined_data: Array<object> = []; //组合数据,经过转换后的
public wait_render_data: Array<object> = []; public wait_render_data: Array<object> = [];
public render_data: Array<object> = []; //显示数据,即需要显示的数据 public render_data: Array<object> = []; //显示数据,即需要显示的数据
public selectedFilterData: Array<object> = [];
public render_col_lists: Array<object> = [ public render_col_lists: Array<object> = [
{ "COL_CODE": "flightNumber", "COL_CN": "航班号", "COL_WIDTH": "85px" }, { "COL_CODE": "flightNumber", "COL_CN": "航班号", "COL_WIDTH": "85px" },
@@ -111,11 +96,6 @@ export class SeasonalPlanComponent implements OnInit {
scrollTop: number = 0; scrollTop: number = 0;
ngOnInit() { 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 () { window.onresize = function () {
this.calcVisibleCount(); this.calcVisibleCount();
}.bind(this) }.bind(this)
@@ -143,7 +123,6 @@ export class SeasonalPlanComponent implements OnInit {
this.basicDataService.airport_subject.subscribe( this.basicDataService.airport_subject.subscribe(
data => { data => {
this.airports = data; this.airports = data;
this.dataTransfer();
} }
) )
this.basicDataService.flightTypes_subject.subscribe( this.basicDataService.flightTypes_subject.subscribe(
@@ -154,7 +133,7 @@ export class SeasonalPlanComponent implements OnInit {
this.basicDataService.airline_subject.subscribe( this.basicDataService.airline_subject.subscribe(
data => { data => {
this.airlines = data; this.airlines = data;
this.dataTransfer();
} }
) )
} }
@@ -164,13 +143,6 @@ export class SeasonalPlanComponent implements OnInit {
).catch(err => { ).catch(err => {
alert('请求失败') 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() { dataTransfer() {
this.seasonals.forEach(item => { 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); let line = Object.assign({}, item);
line = this.airlinesHandle(line); line = this.airlinesHandle(line);
line = this.aircraftTypesHandle(line); line = this.aircraftTypesHandle(line);
@@ -285,25 +265,21 @@ export class SeasonalPlanComponent implements OnInit {
}) })
this.wait_render_data = this.combined_data; 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; if (this.render_data.length > 0) {
const fixedScrollTop = scrollTop - scrollTop % this.trItemHeight; this.row_state = this.render_data[0];
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)
this.operateSpinServiceService.hideSpin(); this.operateSpinServiceService.hideSpin();
} }
//查询年份事件 //查询年份事件
selectYearChange($event) { selectYearChange($event) {
this.operateSpinServiceService.showSpin(); this.operateSpinServiceService.showSpin();
this.positionedArray = []; //定位数组为清空
this.positionArrayIndex = 0; //定位元素Index归零
this.SEARCH = ''; this.SEARCH = '';
this.FLT_POS = 1; this.FLT_POS = 1;
this.SEL_COL = ''; this.SEL_COL = '';
@@ -333,6 +309,19 @@ export class SeasonalPlanComponent implements OnInit {
}, 10) }, 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.start = Math.floor(scrollTop / this.trItemHeight);
this.end = this.start + this.visibleCount; this.end = this.start + this.visibleCount;
this.render_data = this.wait_render_data.slice(this.start, this.end); 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.start = Math.floor(scrollTop / this.trItemHeight);
this.end = this.start + this.visibleCount; this.end = this.start + this.visibleCount;
this.render_data = this.wait_render_data.slice(this.start, this.end); 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() { checkboxChange() {
let tabClose = true
for (const key in this.checkboxGroup) { for (const key in this.checkboxGroup) {
if (this.checkboxGroup.hasOwnProperty(key)) { if (this.checkboxGroup.hasOwnProperty(key)) {
if (this.checkboxGroup[key]) { if (this.checkboxGroup[key]) {
this.tabClose = false; tabClose = false;
break; break;
} else { } else {
this.tabClose = true; tabClose = true;
continue; 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; this.row_state = seasonal;
} }
/**
* 选中高亮
* @param seasonal
*/
getSelectedRow(seasonal) {
if (seasonal.seasonflightId === this.row_state.seasonflightId) {
return true;
} else {
return false;
}
}
//输入框回车事件 //输入框回车事件
inputEnter() { inputEnter() {
if (this.FLT_POS === 1) { 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 { } else {
this.inputPosition(this.wait_render_data) this.inputPosition(this.wait_render_data)
} }
@@ -419,46 +421,58 @@ export class SeasonalPlanComponent implements OnInit {
//下拉框选择筛选 //下拉框选择筛选
selectChange() { selectChange() {
this.operateSpinServiceService.showSpin(); this.operateSpinServiceService.showSpin();
setTimeout(() => { this.positionedArray = [];
let filter_data = this.combined_data.filter(item => { this.positionArrayIndex = 0;
let is_satis = true; let filter_data = this.combined_data.filter(item => {
for (const key in this.filterItems) { let is_satis = true;
if (this.filterItems.hasOwnProperty(key) && this.filterItems[key]) { for (const key in this.filterItems) {
if (item[key] === this.filterItems[key]) { if (this.filterItems.hasOwnProperty(key) && this.filterItems[key]) {
is_satis = true; if (item[key] === this.filterItems[key]) {
continue; is_satis = true;
} else { continue;
is_satis = false; } else {
break; 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) { inputFilter(filterData) {
if (this.SEARCH) { if (this.LASTSEARCH) {
if (this.SEL_COL) { if (this.LAST_SEL_COL) {
let sel_col = this.SEL_COL; let sel_col = this.LAST_SEL_COL;
filterData = filterData.filter(item => { filterData = filterData.filter(item => {
if (item[sel_col]) { 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; return true;
} }
} else { } else {
@@ -471,7 +485,7 @@ export class SeasonalPlanComponent implements OnInit {
let cols = this.render_col_lists; let cols = this.render_col_lists;
for (let i = 0; i < cols.length; i++) { for (let i = 0; i < cols.length; i++) {
if (item[cols[i]['COL_CODE']]) { 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; is_satis = true;
break; break;
} else { } else {
@@ -489,76 +503,243 @@ export class SeasonalPlanComponent implements OnInit {
} }
this.wait_render_data = filterData; this.wait_render_data = filterData;
this.render_data = this.wait_render_data.slice(this.start, this.end); 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; positionArrayIndex: number = 0;
//输入框定位 //输入框定位
inputPosition(filterData) { inputPosition(filterData) {
let transArray = [] let hasSearchData: boolean = false;
let hasPositionedEle: boolean = false;
if (this.SEL_COL) { if (this.SEL_COL) {
let sel_col = this.SEL_COL; let sel_col = this.SEL_COL;
filterData.forEach(element => { for (let i = 0; i < filterData.length; i++) {
if (element[sel_col]) { if (i === filterData.length - 1) {
if (element[sel_col].toString().match(new RegExp(this.SEARCH, 'i'))) { this.positionedArray = [];
transArray.push(element) 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 { } else {
if (!this.SEARCH) { 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 { } else {
filterData.forEach(element => { let cols = this.render_col_lists;
let cols = this.render_col_lists; for (let i = 0; i < filterData.length; i++) {
for (let i = 0; i < cols.length; i++) { if (i === filterData.length - 1) {
if (element[cols[i]['COL_CODE']]) { this.positionedArray = [];
if (element[cols[i]['COL_CODE']].toString().match(new RegExp(this.SEARCH, 'i'))) { this.positionArrayIndex = 0;
transArray.push(element) }
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; break;
} else { } else {
continue; continue;
} }
} else { } else {
if (this.SEARCH) { if (!this.SEARCH) {
continue; let hasThisEle: boolean = false;
} else { hasSearchData = true;
transArray.push(element) 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; break;
} else {
continue;
} }
} }
} }
}); if (positionIsOk) {
break;
}
}
} }
if (transArray.length > 0) { if (!hasSearchData) {
if (transArray.toString() == this.positionArray.toString()) { alert("没有搜索到相关数据");
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"); if (hasPositionedEle) {
let objTr = tr[0]; const scrollTop = this.positionArrayIndex * this.trItemHeight
if (objTr) { this.tableBody.nativeElement.scrollTop = scrollTop;
$("#table-container").animate({ scrollTop: objTr.offsetTop - 42 }, "slow");
} }
// 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;
}
} }