diff --git a/src/app/pages/main/detail-tab/detail-tab.component.scss b/src/app/pages/main/detail-tab/detail-tab.component.scss index b454e14..0c0d3b5 100644 --- a/src/app/pages/main/detail-tab/detail-tab.component.scss +++ b/src/app/pages/main/detail-tab/detail-tab.component.scss @@ -1,8 +1,5 @@ .tab-container{ padding: 10px; - // height: 635px; - // overflow: auto; - // border: 1px solid #ccc; .hr-line{ font-weight: bold; } diff --git a/src/app/pages/main/main.component.ts b/src/app/pages/main/main.component.ts index 82186e2..2aba8d7 100644 --- a/src/app/pages/main/main.component.ts +++ b/src/app/pages/main/main.component.ts @@ -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 { diff --git a/src/app/pages/seasonal-plan/detail-tab/detail-tab.component.html b/src/app/pages/seasonal-plan/detail-tab/detail-tab.component.html index fb9d9b1..76dad76 100644 --- a/src/app/pages/seasonal-plan/detail-tab/detail-tab.component.html +++ b/src/app/pages/seasonal-plan/detail-tab/detail-tab.component.html @@ -2,7 +2,7 @@

{{flight.flightNumber}}

-

{{flight.seasonRecId}}

+

{{flight.seasonName}}

{{flight.internationalCode}}

{{flight.airlineChnName}}

{{flight.routeTypeChn}}

@@ -13,8 +13,9 @@

{{flight.endDate}}

{{flight.startAirport}}

{{flight.arriOrDeptChn}}

-

{{flight.arrivalTime}}

-

{{flight.departureTime}}

+

{{flight.arrivalTimeTra}}

+

{{flight.departureTimeTra}}

+

{{flight.remarks}}

{{flight.aircraftTypeName}}

\ No newline at end of file diff --git a/src/app/pages/seasonal-plan/detail-tab/detail-tab.component.scss b/src/app/pages/seasonal-plan/detail-tab/detail-tab.component.scss index 2b38b60..60ee159 100644 --- a/src/app/pages/seasonal-plan/detail-tab/detail-tab.component.scss +++ b/src/app/pages/seasonal-plan/detail-tab/detail-tab.component.scss @@ -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; - } } } } \ No newline at end of file diff --git a/src/app/pages/seasonal-plan/related-tab/related-tab.component.html b/src/app/pages/seasonal-plan/related-tab/related-tab.component.html index a54371e..e0cc8d9 100644 --- a/src/app/pages/seasonal-plan/related-tab/related-tab.component.html +++ b/src/app/pages/seasonal-plan/related-tab/related-tab.component.html @@ -3,7 +3,7 @@
共享航班代码
-

共享航班号:{{lines.flightNumber}}

+

共享航班号:{{lines.subAirlineId}}

@@ -11,9 +11,8 @@
经停机场
-

(到达   {{airport.scat?airport.scat:'__ : __'}}   |   出发   {{airport.scdt?airport.scdt:'__ : __'}})

- +
- + \ No newline at end of file diff --git a/src/app/pages/seasonal-plan/related-tab/related-tab.component.scss b/src/app/pages/seasonal-plan/related-tab/related-tab.component.scss index bf98646..a11b073 100644 --- a/src/app/pages/seasonal-plan/related-tab/related-tab.component.scss +++ b/src/app/pages/seasonal-plan/related-tab/related-tab.component.scss @@ -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; diff --git a/src/app/pages/seasonal-plan/related-tab/related-tab.component.ts b/src/app/pages/seasonal-plan/related-tab/related-tab.component.ts index e875e63..bd24151 100644 --- a/src/app/pages/seasonal-plan/related-tab/related-tab.component.ts +++ b/src/app/pages/seasonal-plan/related-tab/related-tab.component.ts @@ -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 ''; + } + } + } diff --git a/src/app/pages/seasonal-plan/seasonal-plan.component.html b/src/app/pages/seasonal-plan/seasonal-plan.component.html index 040afc2..399b7ce 100644 --- a/src/app/pages/seasonal-plan/seasonal-plan.component.html +++ b/src/app/pages/seasonal-plan/seasonal-plan.component.html @@ -3,7 +3,7 @@
- @@ -15,7 +15,11 @@ 查找定位 - + + +
@@ -28,7 +32,7 @@
@@ -45,13 +49,9 @@
-
-
- - -
-
- - - +
+
+ + + - + - -
{{start+i+1}}{{seasonal[airline_col.COL_CODE]}}{{seasonal[airline_col.COL_CODE]}}
-
- - - - - - + + + +
-
+
- + - + diff --git a/src/app/pages/seasonal-plan/seasonal-plan.component.ts b/src/app/pages/seasonal-plan/seasonal-plan.component.ts index afd8525..c1e7df7 100644 --- a/src/app/pages/seasonal-plan/seasonal-plan.component.ts +++ b/src/app/pages/seasonal-plan/seasonal-plan.component.ts @@ -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; @@ -71,10 +52,14 @@ export class SeasonalPlanComponent implements OnInit { flightTypes: Array; //航班类别 airports: Array; //机场 + public airlinesSelections: Array = []; + public flightTypeSelections: Array = []; + public row_state: any = {}; public combined_data: Array = []; //组合数据,经过转换后的 public wait_render_data: Array = []; public render_data: Array = []; //显示数据,即需要显示的数据 + public selectedFilterData: Array = []; public render_col_lists: Array = [ { "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 = []; + positionedArray: Array = []; 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; + } }