From 636ec4ed02aa281487e058f8961b6e82a2a4174d Mon Sep 17 00:00:00 2001 From: "714943302@qq.com" Date: Thu, 22 Nov 2018 13:54:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=BA=E4=BD=8D=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/basic-data/city/city.component.html | 13 +- .../pages/basic-data/city/city.component.ts | 122 ++++-------------- .../pages/basic-data/stand/stand.component.ts | 5 +- 3 files changed, 37 insertions(+), 103 deletions(-) diff --git a/src/app/pages/basic-data/city/city.component.html b/src/app/pages/basic-data/city/city.component.html index fa31878..8471a11 100644 --- a/src/app/pages/basic-data/city/city.component.html +++ b/src/app/pages/basic-data/city/city.component.html @@ -22,7 +22,7 @@ --> - + @@ -36,12 +36,13 @@
- - - + +
@@ -72,7 +73,7 @@ - + {{i+1}} {{city.cityCode}} {{city.cityNameChn}} diff --git a/src/app/pages/basic-data/city/city.component.ts b/src/app/pages/basic-data/city/city.component.ts index 35c9aaa..415d25b 100644 --- a/src/app/pages/basic-data/city/city.component.ts +++ b/src/app/pages/basic-data/city/city.component.ts @@ -20,9 +20,15 @@ SEARCH = ''; //手动输入条件 FLT_POS = 1; //过滤还是定位 SEL_COL = ''; //选择列名 +//下拉框 +public filterItems = { + countryId:'', +} + citys : Array; public row_state: any = { renderFlight: {} }; public render_data: Array = []; //显示数据,即需要显示的数据 +public return_data: Array = []; //下拉框显示数据 ngOnInit() { this.citys = this.basicDataService.city; this.basicDataService.city_subject.subscribe( @@ -42,112 +48,38 @@ ngOnInit() { tableCont.addEventListener('scroll',scrollHandle); } -//刷新 -clearFiter(){ - $("#inputerInfo").val(""); //清空过滤或查找定位文本框 - $("#citry").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.citys) + } else { + this.inputFilter(this.citys) + this.inputPosition(this.citys) + } } //下拉框选择筛选 selectChange() { - let filter_data = []; - let filtercitys = 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.citys = filter_data; - this.row_state = this.citys.length > 0 ? this.citys[0] : { renderFlight: {} }; - } - //下拉框筛选 - filter_data = filter_data.filter(item => { - if (item) { + this.return_data = this.citys.filter(item=>{ let is_satis = true; - for (const key in filtercitys) { - if (filtercitys.hasOwnProperty(key) && filtercitys[key]) { - if (item[key] === filtercitys[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 filtercitys) { - if (filtercitys.hasOwnProperty(key) && filtercitys[key]) { - if (item[key] === filtercitys[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 filtercitys) { - if (filtercitys.hasOwnProperty(key) && filtercitys[key]) { - if (item[key] === filtercitys[key]) { - pre_satis = true; - continue; - } else { - pre_satis = false; - break; - } - - } - } - for (const key in filtercitys) { - if (filtercitys.hasOwnProperty(key) && filtercitys[key]) { - if (item[key] === filtercitys[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; @@ -195,14 +127,14 @@ selectChange() { }) } } - this.citys = filterData; - this.row_state = this.citys.length > 0 ? this.citys[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/stand/stand.component.ts b/src/app/pages/basic-data/stand/stand.component.ts index 1a79f12..c94a0a0 100644 --- a/src/app/pages/basic-data/stand/stand.component.ts +++ b/src/app/pages/basic-data/stand/stand.component.ts @@ -23,7 +23,8 @@ SEL_COL = ''; //选择列名 //下拉框 public filterItems = { terminalAreaCode:'', - gateStatus:'', + standType:'', + standStatus:'', } stands : Array; @@ -55,7 +56,7 @@ inputEnter() { this.inputFilter(this.stands) } else { this.inputFilter(this.stands) - // this.inputPosition(this.render_data) + this.inputPosition(this.stands) } }