From b9a432a11ef1b664fb557a9c514bbbfc61802bb0 Mon Sep 17 00:00:00 2001 From: "714943302@qq.com" Date: Fri, 23 Nov 2018 11:55:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=80=BC=E6=9C=BA=E5=B2=9B=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E5=88=97=E5=90=8D=E6=95=B0=E6=8D=AE=E7=BB=91=E5=AE=9A=E5=8F=8A?= =?UTF-8?q?=E6=9F=A5=E6=89=BE=E5=AE=9A=E4=BD=8D=E6=95=B0=E6=8D=AE=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../checkin-group.component.html | 7 +- .../checkin-group/checkin-group.component.ts | 127 +++++------------- 2 files changed, 39 insertions(+), 95 deletions(-) diff --git a/src/app/pages/basic-data/checkin-group/checkin-group.component.html b/src/app/pages/basic-data/checkin-group/checkin-group.component.html index 9eb8af7..391876e 100644 --- a/src/app/pages/basic-data/checkin-group/checkin-group.component.html +++ b/src/app/pages/basic-data/checkin-group/checkin-group.component.html @@ -5,6 +5,8 @@
@@ -36,7 +38,8 @@ - + {{i+1}} {{checkinGroup.checkinGroupCode}} {{checkinGroup.checkinGroupName}} 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 b5e5067..2bc869d 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 @@ -20,9 +20,15 @@ SEARCH = ''; //手动输入条件 FLT_POS = 1; //过滤还是定位 SEL_COL = ''; //选择列名 +//下拉框 +public filterItems = { + +} + checkinGroups : Array; public row_state: any = { renderFlight: {} }; public render_data: Array = []; //显示数据,即需要显示的数据 +public return_data: Array = []; //下拉框显示数据 ngOnInit() { this.checkinGroups = this.basicDataService.checkin_group; this.basicDataService.checkin_group_subject.subscribe( @@ -42,111 +48,46 @@ ngOnInit() { tableCont.addEventListener('scroll',scrollHandle); } -//刷新 -clearFiter(){ - $("#inputerInfo").val(""); //清空过滤或查找定位文本框 - this.ngOnInit(); +/** + * 选中某行 + * @param i + */ +selectRow(i) { + this.row_state = i; } + //输入框回车事件 inputEnter() { -if (this.FLT_POS === 1) { - this.selectChange() -} else { - this.selectChange() - this.inputPosition(this.render_data) -} + if (this.FLT_POS === 1) { + this.inputFilter(this.checkinGroups) + } else { + this.inputFilter(this.checkinGroups) + this.inputPosition(this.checkinGroups) + } } //下拉框选择筛选 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) { + this.return_data = this.checkinGroups.filter(item=>{ let is_satis = true; - for (const key in filtercheckinGroups) { - if (filtercheckinGroups.hasOwnProperty(key) && filtercheckinGroups[key]) { - if (item[key] === filtercheckinGroups[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 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 { - 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; - } - } }) - } + this.render_data = this.return_data; +} - //输入框筛选 - inputFilter(filterData) { +//输入框筛选 +inputFilter(filterData) { if (this.SEARCH) { if (this.SEL_COL) { let sel_col = this.SEL_COL; @@ -194,14 +135,14 @@ selectChange() { }) } } - this.checkinGroups = filterData; - this.row_state = this.checkinGroups.length > 0 ? this.checkinGroups[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;