From b12e8a1065e7cc8f4ac93040ebf54a16e9ae90a3 Mon Sep 17 00:00:00 2001 From: "714943302@qq.com" Date: Thu, 22 Nov 2018 13:52:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=80=BC=E6=9C=BA=E6=9F=9C=E5=8F=B0=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../checkin-desk/checkin-desk.component.html | 31 +- .../checkin-desk/checkin-desk.component.ts | 126 ++----- .../checkin-group/checkin-group.component.ts | 322 +++++++++--------- 3 files changed, 207 insertions(+), 272 deletions(-) diff --git a/src/app/pages/basic-data/checkin-desk/checkin-desk.component.html b/src/app/pages/basic-data/checkin-desk/checkin-desk.component.html index a78066f..d24a132 100644 --- a/src/app/pages/basic-data/checkin-desk/checkin-desk.component.html +++ b/src/app/pages/basic-data/checkin-desk/checkin-desk.component.html @@ -19,36 +19,39 @@
- +
- - - + +
- - - + +
- - - + +
@@ -69,7 +72,7 @@ - + {{i+1}} {{checkinDesk.checkindeskCode}} {{checkinDesk.checkindeskName}} diff --git a/src/app/pages/basic-data/checkin-desk/checkin-desk.component.ts b/src/app/pages/basic-data/checkin-desk/checkin-desk.component.ts index f244420..dee02ef 100644 --- a/src/app/pages/basic-data/checkin-desk/checkin-desk.component.ts +++ b/src/app/pages/basic-data/checkin-desk/checkin-desk.component.ts @@ -20,9 +20,17 @@ SEARCH = ''; //手动输入条件 FLT_POS = 1; //过滤还是定位 SEL_COL = ''; //选择列名 +//下拉框 +public filterItems = { + terminalAreaCode:'', + checkinGroupCode:'', + chutCode:'', +} + checkinDesks : Array; public row_state: any = { renderFlight: {} }; public render_data: Array = []; //显示数据,即需要显示的数据 +public return_data: Array = []; //下拉框显示数据 ngOnInit() { this.checkinDesks = this.basicDataService.checkin_desk; this.basicDataService.checkin_desk_subject.subscribe( @@ -42,114 +50,38 @@ ngOnInit() { tableCont.addEventListener('scroll',scrollHandle); } -//刷新 -clearFiter(){ - $("#inputerInfo").val(""); //清空过滤或查找定位文本框 - $("#qy").val(""); //清空所属航站楼区域 - $("#zjd").val(""); //清空值机岛 - $("#xl").val(""); //清空行李传送带 - this.ngOnInit(); -} //输入框回车事件 inputEnter() { -if (this.FLT_POS === 1) { - this.selectChange() -} else { - this.selectChange() - this.inputPosition(this.render_data) -} + if (this.FLT_POS === 1) { + this.inputFilter(this.checkinDesks) + } else { + this.inputFilter(this.checkinDesks) + this.inputPosition(this.checkinDesks) + } } //下拉框选择筛选 selectChange() { - let filter_data = []; - let filtercheckinDesks = this.render_data; - this.render_data.forEach(item => { - filter_data.push(Object.assign({}, item)); - }) - if (this.FLT_POS === 1) { - this.inputFilter(filter_data); - } else { - this.checkinDesks = filter_data; - this.row_state = this.checkinDesks.length > 0 ? this.checkinDesks[0] : { renderFlight: {} }; - } - //下拉框筛选 - filter_data = filter_data.filter(item => { - if (item) { + this.return_data = this.checkinDesks.filter(item=>{ let is_satis = true; - for (const key in filtercheckinDesks) { - if (filtercheckinDesks.hasOwnProperty(key) && filtercheckinDesks[key]) { - if (item[key] === filtercheckinDesks[key]) { + 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; - } else if (item) { - let is_satis = true; - for (const key in filtercheckinDesks) { - if (filtercheckinDesks.hasOwnProperty(key) && filtercheckinDesks[key]) { - if (item[key] === filtercheckinDesks[key]) { - is_satis = true; - continue; - } else { - is_satis = false; - break; - } - - } - } - return is_satis; - } else { - let pre_satis = true; - let rea_satis = true; - for (const key in filtercheckinDesks) { - if (filtercheckinDesks.hasOwnProperty(key) && filtercheckinDesks[key]) { - if (item[key] === filtercheckinDesks[key]) { - pre_satis = true; - continue; - } else { - pre_satis = false; - break; - } - - } - } - for (const key in filtercheckinDesks) { - if (filtercheckinDesks.hasOwnProperty(key) && filtercheckinDesks[key]) { - if (item[key] === filtercheckinDesks[key]) { - rea_satis = true; - continue; - } else { - rea_satis = false; - break; - } - - } - } - - if (pre_satis && !rea_satis) { - item = item; - return pre_satis; - } else if (!pre_satis && rea_satis) { - item = item; - return rea_satis; - } else if (pre_satis && rea_satis) { - return pre_satis && rea_satis; - } else { - return false; - } - } }) - } + this.render_data = this.return_data; +} - //输入框筛选 - inputFilter(filterData) { +//输入框筛选 +inputFilter(filterData) { if (this.SEARCH) { if (this.SEL_COL) { let sel_col = this.SEL_COL; @@ -197,14 +129,14 @@ selectChange() { }) } } - this.checkinDesks = filterData; - this.row_state = this.checkinDesks.length > 0 ? this.checkinDesks[0] : { renderFlight: {} }; - } + this.render_data = filterData; + this.row_state = this.render_data.length > 0 ? this.render_data[0] : { renderFlight: {} }; +} - positionArray: Array = []; - positionArrayIndex: number = 0; - //输入框定位 - inputPosition(filterData) { +positionArray: Array = []; +positionArrayIndex: number = 0; +//输入框定位 +inputPosition(filterData) { let transArray = [] if (this.SEL_COL) { let sel_col = this.SEL_COL; diff --git a/src/app/pages/basic-data/checkin-group/checkin-group.component.ts b/src/app/pages/basic-data/checkin-group/checkin-group.component.ts index 553b222..b5e5067 100644 --- a/src/app/pages/basic-data/checkin-group/checkin-group.component.ts +++ b/src/app/pages/basic-data/checkin-group/checkin-group.component.ts @@ -59,204 +59,204 @@ if (this.FLT_POS === 1) { //下拉框选择筛选 selectChange() { -let filter_data = []; -let filtercheckinGroups = this.render_data; -this.render_data.forEach(item => { - filter_data.push(Object.assign({}, item)); -}) -if (this.FLT_POS === 1) { - this.inputFilter(filter_data); -} else { - this.checkinGroups = filter_data; - this.row_state = this.checkinGroups.length > 0 ? this.checkinGroups[0] : { renderFlight: {} }; -} -//下拉框筛选 -filter_data = filter_data.filter(item => { - if (item) { - let is_satis = true; - for (const key in filtercheckinGroups) { - if (filtercheckinGroups.hasOwnProperty(key) && filtercheckinGroups[key]) { - if (item[key] === filtercheckinGroups[key]) { - is_satis = true; - continue; - } else { - is_satis = false; - break; - } - - } - } - return is_satis; - } else if (item) { - let is_satis = true; - for (const key in filtercheckinGroups) { - if (filtercheckinGroups.hasOwnProperty(key) && filtercheckinGroups[key]) { - if (item[key] === filtercheckinGroups[key]) { - is_satis = true; - continue; - } else { - is_satis = false; - break; - } - - } - } - return is_satis; + let filter_data = []; + let filtercheckinGroups = this.render_data; + this.render_data.forEach(item => { + filter_data.push(Object.assign({}, item)); + }) + if (this.FLT_POS === 1) { + this.inputFilter(filter_data); } else { - let pre_satis = true; - let rea_satis = true; - for (const key in filtercheckinGroups) { - if (filtercheckinGroups.hasOwnProperty(key) && filtercheckinGroups[key]) { - if (item[key] === filtercheckinGroups[key]) { - pre_satis = true; - continue; - } else { - pre_satis = false; - break; + this.checkinGroups = filter_data; + this.row_state = this.checkinGroups.length > 0 ? this.checkinGroups[0] : { renderFlight: {} }; + } + //下拉框筛选 + filter_data = filter_data.filter(item => { + if (item) { + let is_satis = true; + for (const key in filtercheckinGroups) { + if (filtercheckinGroups.hasOwnProperty(key) && filtercheckinGroups[key]) { + if (item[key] === filtercheckinGroups[key]) { + is_satis = true; + continue; + } else { + is_satis = false; + break; + } + } - } - } - for (const key in filtercheckinGroups) { - if (filtercheckinGroups.hasOwnProperty(key) && filtercheckinGroups[key]) { - if (item[key] === filtercheckinGroups[key]) { - rea_satis = true; - continue; - } else { - rea_satis = false; - break; + return is_satis; + } else if (item) { + let is_satis = true; + for (const key in filtercheckinGroups) { + if (filtercheckinGroups.hasOwnProperty(key) && filtercheckinGroups[key]) { + if (item[key] === filtercheckinGroups[key]) { + is_satis = true; + continue; + } else { + is_satis = false; + break; + } + } - } - } - - if (pre_satis && !rea_satis) { - item = item; - return pre_satis; - } else if (!pre_satis && rea_satis) { - item = item; - return rea_satis; - } else if (pre_satis && rea_satis) { - return pre_satis && rea_satis; + return is_satis; } else { - return false; + let pre_satis = true; + let rea_satis = true; + for (const key in filtercheckinGroups) { + if (filtercheckinGroups.hasOwnProperty(key) && filtercheckinGroups[key]) { + if (item[key] === filtercheckinGroups[key]) { + pre_satis = true; + continue; + } else { + pre_satis = false; + break; + } + + } + } + for (const key in filtercheckinGroups) { + if (filtercheckinGroups.hasOwnProperty(key) && filtercheckinGroups[key]) { + if (item[key] === filtercheckinGroups[key]) { + rea_satis = true; + continue; + } else { + rea_satis = false; + break; + } + + } + } + + if (pre_satis && !rea_satis) { + item = item; + return pre_satis; + } else if (!pre_satis && rea_satis) { + item = item; + return rea_satis; + } else if (pre_satis && rea_satis) { + return pre_satis && rea_satis; + } else { + return false; + } + } + }) + } + + //输入框筛选 + inputFilter(filterData) { + if (this.SEARCH) { + if (this.SEL_COL) { + let sel_col = this.SEL_COL; + filterData = filterData.filter(item => { + if (item[sel_col]) { + if (item[sel_col].toString().match(new RegExp(this.SEARCH, 'i'))) { + return true; + } + } else { + if (this.SEARCH) { + return false; + } else { + return true; + } + } + }) + + } else { + filterData = filterData.filter(item => { + let is_satis = false; + for (const key in item) { + if (item.hasOwnProperty(key)) { + if (item[key]) { + if (item[key].toString().match(new RegExp(this.SEARCH, 'i'))) { + is_satis = true; + break; + } else { + is_satis = false; + continue; + } + } else { + if (this.SEARCH) { + is_satis = false; + continue; + } else { + is_satis = true; + break; + } + } + } else { + continue; + } + } + return is_satis; + }) } } -}) -} + this.checkinGroups = filterData; + this.row_state = this.checkinGroups.length > 0 ? this.checkinGroups[0] : { renderFlight: {} }; + } -//输入框筛选 -inputFilter(filterData) { -if (this.SEARCH) { + positionArray: Array = []; + positionArrayIndex: number = 0; + //输入框定位 + inputPosition(filterData) { + let transArray = [] if (this.SEL_COL) { let sel_col = this.SEL_COL; - filterData = filterData.filter(item => { - if (item[sel_col]) { - if (item[sel_col].toString().match(new RegExp(this.SEARCH, 'i'))) { - return true; + 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) { - return false; - } else { - return true; + if (!this.SEARCH) { + transArray.push(element) } } - }) - + }); } else { - filterData = filterData.filter(item => { - let is_satis = false; - for (const key in item) { - if (item.hasOwnProperty(key)) { - if (item[key]) { - if (item[key].toString().match(new RegExp(this.SEARCH, 'i'))) { - is_satis = true; + filterData.forEach(element => { + for (const key in element) { + if (element.hasOwnProperty(key)) { + if (element[key]) { + if (element[key].toString().match(new RegExp(this.SEARCH, 'i'))) { + transArray.push(element) break; } else { - is_satis = false; continue; } } else { if (this.SEARCH) { - is_satis = false; continue; } else { - is_satis = true; + transArray.push(element) break; } } + } else { continue; } } - return is_satis; - }) + }); } -} -this.checkinGroups = filterData; -this.row_state = this.checkinGroups.length > 0 ? this.checkinGroups[0] : { renderFlight: {} }; -} -positionArray: Array = []; -positionArrayIndex: number = 0; -//输入框定位 -inputPosition(filterData) { -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) + 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 { - if (!this.SEARCH) { - transArray.push(element) - } - } - }); -} else { - filterData.forEach(element => { - for (const key in element) { - if (element.hasOwnProperty(key)) { - if (element[key]) { - if (element[key].toString().match(new RegExp(this.SEARCH, 'i'))) { - transArray.push(element) - break; - } else { - continue; - } - } else { - if (this.SEARCH) { - continue; - } else { - transArray.push(element) - break; - } - } - - } else { - continue; - } - } - }); -} - -if (transArray.length > 0) { - if (transArray.toString() == this.positionArray.toString()) { - this.positionArrayIndex++; - if (this.positionArrayIndex === this.positionArray.length) { + this.positionArray = transArray; this.positionArrayIndex = 0; + this.row_state = this.positionArray[this.positionArrayIndex]; } - this.row_state = this.positionArray[this.positionArrayIndex]; } else { - this.positionArray = transArray; - this.positionArrayIndex = 0; - this.row_state = this.positionArray[this.positionArrayIndex]; + alert('没有搜索到相关数据'); + } } -} else { - alert('没有搜索到相关数据'); -} -} }