From 184046f782e107b52ca19684ba7b71a6b29c5e69 Mon Sep 17 00:00:00 2001 From: "714943302@qq.com" Date: Fri, 23 Nov 2018 13:41:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=8C=E6=9D=8E=E4=BC=A0=E9=80=81=E5=B8=A6?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E5=88=97=E5=90=8D=E6=95=B0=E6=8D=AE=E7=BB=91?= =?UTF-8?q?=E5=AE=9A=E5=8F=8A=E6=9F=A5=E6=89=BE=E5=AE=9A=E4=BD=8D=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=BF=87=E6=BB=A4=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/basic-data/chut/chut.component.html | 6 +- .../pages/basic-data/chut/chut.component.ts | 203 ++++++------------ 2 files changed, 72 insertions(+), 137 deletions(-) diff --git a/src/app/pages/basic-data/chut/chut.component.html b/src/app/pages/basic-data/chut/chut.component.html index 254b85a..a3abf59 100644 --- a/src/app/pages/basic-data/chut/chut.component.html +++ b/src/app/pages/basic-data/chut/chut.component.html @@ -5,6 +5,8 @@
@@ -36,7 +38,7 @@ - + {{i+1}} {{chut.chutCode}} {{chut.chutName}} diff --git a/src/app/pages/basic-data/chut/chut.component.ts b/src/app/pages/basic-data/chut/chut.component.ts index 9b382df..04b4e2e 100644 --- a/src/app/pages/basic-data/chut/chut.component.ts +++ b/src/app/pages/basic-data/chut/chut.component.ts @@ -20,9 +20,15 @@ SEARCH = ''; //手动输入条件 FLT_POS = 1; //过滤还是定位 SEL_COL = ''; //选择列名 +//下拉框 +public filterItems = { + +} + chuts : Array; public row_state: any = { renderFlight: {} }; public render_data: Array = []; //显示数据,即需要显示的数据 +public return_data: Array = []; //下拉框显示数据 ngOnInit() { this.chuts = this.basicDataService.chut; this.basicDataService.chut_subject.subscribe( @@ -42,160 +48,87 @@ ngOnInit() { tableCont.addEventListener('scroll',scrollHandle); } -//刷新 -clearFiter(){ - $("#inputerInfo").val(""); //清空过滤或查找定位文本框 - this.ngOnInit(); -} //输入框回车事件 inputEnter() { if (this.FLT_POS === 1) { - this.selectChange() + this.inputFilter(this.chuts) } else { - this.selectChange() - this.inputPosition(this.render_data) + this.inputFilter(this.chuts) + this.inputPosition(this.chuts) } } //下拉框选择筛选 selectChange() { -let filter_data = []; -let filterchuts = 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.chuts = filter_data; - this.row_state = this.chuts.length > 0 ? this.chuts[0] : { renderFlight: {} }; -} -//下拉框筛选 -filter_data = filter_data.filter(item => { - if (item) { - let is_satis = true; - for (const key in filterchuts) { - if (filterchuts.hasOwnProperty(key) && filterchuts[key]) { - if (item[key] === filterchuts[key]) { - is_satis = true; - continue; - } else { - is_satis = false; - break; + this.return_data = this.chuts.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; - } else if (item) { - let is_satis = true; - for (const key in filterchuts) { - if (filterchuts.hasOwnProperty(key) && filterchuts[key]) { - if (item[key] === filterchuts[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 filterchuts) { - if (filterchuts.hasOwnProperty(key) && filterchuts[key]) { - if (item[key] === filterchuts[key]) { - pre_satis = true; - continue; - } else { - pre_satis = false; - break; - } - - } - } - for (const key in filterchuts) { - if (filterchuts.hasOwnProperty(key) && filterchuts[key]) { - if (item[key] === filterchuts[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; - } - } -}) + return is_satis; + }) + this.render_data = this.return_data; } //输入框筛选 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; - } + 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 { - continue; + if (this.SEARCH) { + return false; + } else { + return true; + } } - } - return is_satis; - }) + }) + + } 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.chuts = filterData; - this.row_state = this.chuts.length > 0 ? this.chuts[0] : { renderFlight: {} }; + this.render_data = filterData; + this.row_state = this.render_data.length > 0 ? this.render_data[0] : { renderFlight: {} }; } positionArray: Array = [];