@@ -6,14 +6,18 @@ import _ from 'lodash'
66// import { browserHistory } from 'react-router'
77
88import Box from 'grommet/components/Box'
9- import Search from 'grommet/components/Search'
9+ // import Search from 'grommet/components/Search'
1010import Header from 'grommet/components/Header'
1111import Tiles from 'grommet/components/Tiles'
1212import Heading from 'grommet/components/Heading'
13+ import { Modal } from 'antd'
1314
1415import Loading from 'react-loading'
1516import InfiniteScroll from 'react-infinite-scroller'
1617
18+ const catagoryList = [ '網路服務' , '科技' , '電商' , '顧問' , '廣告公關' , '金融' , '媒體' , '設計' ,
19+ '文創' , '醫療/生物' , '教育' , '旅遊' , '農業' , 'NPO/NGO' , '傳產' , '電信' , '批發零售' ,
20+ '食品' , '學校' , '研究機構' , '遊戲' , '運輸' , '政府' , '其他' ]
1721@Radium
1822export default CSSModules ( class extends Component {
1923 constructor ( props ) {
@@ -24,6 +28,11 @@ export default CSSModules(class extends Component {
2428 this . getMoreIntern = this . getMoreIntern . bind ( this )
2529 this . startFilter = this . startFilter . bind ( this )
2630 this . handleKeyPress = this . handleKeyPress . bind ( this )
31+ this . startCatagoryFilter = this . startCatagoryFilter . bind ( this )
32+ this . showCatagoryModal = this . showCatagoryModal . bind ( this )
33+ this . showSearchModal = this . showSearchModal . bind ( this )
34+ this . handleOk = this . handleOk . bind ( this )
35+ this . handleCancel = this . handleCancel . bind ( this )
2736 this . state = {
2837 copyInternList : { } ,
2938 renderInternList : { } ,
@@ -33,10 +42,36 @@ export default CSSModules(class extends Component {
3342 WindowContentIndex : 1 ,
3443 isWindowClose : true ,
3544 isLoading : true ,
36- isListEnd : false
45+ isListEnd : false ,
46+ catagoryVisible : false ,
47+ SearchVisible : false ,
48+ targetCatagory : ''
3749 }
3850 }
51+ showCatagoryModal ( ) {
52+ this . setState ( {
53+ catagoryVisible : true
54+ } )
55+ }
56+ showSearchModal ( ) {
57+ this . setState ( {
58+ SearchVisible : true
59+ } )
60+ }
61+ handleOk ( e ) {
62+ this . setState ( {
63+ catagoryVisible : false ,
64+ SearchVisible : false
65+ } )
66+ }
67+ handleCancel ( e ) {
68+ this . setState ( {
69+ catagoryVisible : false ,
70+ SearchVisible : false
71+ } )
72+ }
3973 changeFilterInput ( event ) {
74+ console . log ( event . target )
4075 this . setState ( { filterInput : event . target . value } )
4176 }
4277 handleKeyPress ( event ) {
@@ -48,8 +83,9 @@ export default CSSModules(class extends Component {
4883 this . setState ( { renderInternList : { } } )
4984 this . setState ( { currentIndex : 0 } )
5085 this . setState ( { isListEnd : false } )
86+ this . setState ( { SearchVisible : false } )
5187 let rowData = _ . reverse ( _ . values ( this . props . Intern . list ) )
52- // console.log('row', rowData )
88+ console . log ( 'row' , this . state . filterInput )
5389 let filterData = { }
5490 _ . map ( rowData , ( el , id ) => {
5591 let flag = false
@@ -70,6 +106,34 @@ export default CSSModules(class extends Component {
70106 // console.log('set url: ', this.props.router.push('/?search=' + this.state.filterInput))
71107 }
72108 }
109+ startCatagoryFilter ( input ) {
110+ this . setState ( { catagoryVisible : false } )
111+ this . setState ( { renderInternList : { } } )
112+ this . setState ( { currentIndex : 0 } )
113+ this . setState ( { isListEnd : false } )
114+ this . setState ( { targetCatagory : input } )
115+ let rowData = _ . reverse ( _ . values ( this . props . Intern . list ) )
116+ // console.log('row', rowData)
117+ let filterData = { }
118+ _ . map ( rowData , ( el , id ) => {
119+ let flag = false
120+ if ( el [ 'Catagory' ] !== undefined && el [ 'Catagory' ] . toString ( ) . toLowerCase ( ) . indexOf ( input . toLowerCase ( ) ) !== - 1 ) {
121+ flag = true
122+ }
123+ if ( flag ) {
124+ filterData [ id ] = el
125+ }
126+ } )
127+ this . setState ( {
128+ copyInternList : {
129+ ...filterData
130+ }
131+ } )
132+ if ( input !== undefined && input !== '' ) {
133+ this . props . router . push ( '/?catagory=' + input )
134+ // console.log('set url: ', this.props.router.push('/?search=' + this.state.filterInput))
135+ }
136+ }
73137 toggleWindowOpen ( id ) {
74138 console . log ( 'toggle: ' , id )
75139 this . props . getMessage ( id )
@@ -79,7 +143,6 @@ export default CSSModules(class extends Component {
79143 } )
80144 }
81145 toggleWindowClose ( ) {
82- console . log ( 'toggle close' )
83146 this . setState ( { isWindowClose : ! this . state . isWindowClose } )
84147 }
85148 getMoreIntern ( ) {
@@ -131,14 +194,17 @@ export default CSSModules(class extends Component {
131194 } )
132195 } )
133196 . then ( ( ) => {
134- let queryInput = this . props . location . query . search
135- if ( queryInput !== undefined ) {
197+ let queryInput = this . props . location . query
198+ if ( queryInput . search !== undefined ) {
136199 console . log ( 'get query: ' , queryInput )
137200 this . setState ( {
138- filterInput : queryInput
201+ filterInput : queryInput . search
139202 } , ( ) => {
140203 this . startFilter ( )
141204 } )
205+ } else if ( queryInput . catagory !== undefined ) {
206+ console . log ( 'get query: ' , queryInput )
207+ this . startCatagoryFilter ( queryInput . catagory )
142208 }
143209 } )
144210 . then ( ( ) => {
@@ -168,6 +234,51 @@ export default CSSModules(class extends Component {
168234 margin : '0' ,
169235 width : '100%'
170236 } } >
237+
238+ < Modal title = "類別搜尋 catagory" visible = { this . state . catagoryVisible }
239+ onOk = { this . handleOk } onCancel = { this . handleCancel }
240+ footer = { [ ] } >
241+ < div className = "loginContain" >
242+ </ div >
243+ < div style = { {
244+ margin : '20px 0 0' ,
245+ display : 'flex' ,
246+ justifyContent : 'flex-end'
247+ } } >
248+ < ul className = "catagoryList" >
249+ {
250+ catagoryList . map ( ( el , id ) =>
251+ < li className = { this . state . targetCatagory === el ? 'active' : null }
252+ key = { id }
253+ onClick = { ( ) => { this . startCatagoryFilter ( el ) } } >
254+ { el }
255+ </ li >
256+ )
257+ }
258+ </ ul >
259+ </ div >
260+ </ Modal >
261+ < Modal title = "關鍵字搜尋 text Search" visible = { this . state . SearchVisible }
262+ onOk = { this . handleOk } onCancel = { this . handleCancel }
263+ footer = { [ ] } >
264+ < div className = "loginContain" >
265+ </ div >
266+ < div style = { {
267+ margin : '20px 0 0' ,
268+ display : 'flex' ,
269+ justifyContent : 'flex-end'
270+ } } >
271+ < input
272+ type = "text"
273+ value = { this . state . filterInput }
274+ onChange = { this . changeFilterInput }
275+ onKeyPress = { this . handleKeyPress }
276+ />
277+ < div className = "searchBtn"
278+ onClick = { this . startFilter } > 搜尋
279+ </ div >
280+ </ div >
281+ </ Modal >
171282 < div
172283 style = { {
173284 position : 'absolute' ,
@@ -208,35 +319,25 @@ export default CSSModules(class extends Component {
208319 </ a >
209320 </ div >
210321 </ Box >
322+ < div className = "resultCounter" > 目前有 { _ . size ( this . state . copyInternList ) } 筆搜尋</ div >
211323 < Box flex = { true }
212324 justify = 'center'
213325 direction = 'row'
214326 responsive = { false }
215327 style = { {
216- margin : '30px 0 0 0' ,
328+ margin : '0' ,
217329 padding : '0 15px' ,
218330 position : 'relative' ,
219331 width : '100%' ,
220332 maxWidth : '1024px'
221333 } } >
222- < Search inline = { true }
223- fill = { true }
224- size = 'small'
225- value = { this . state . filterInput }
226- iconAlign = 'start'
227- placeHolder = '輸入公司名稱'
228- onDOMChange = { this . changeFilterInput }
229- onKeyPress = { this . handleKeyPress }
230- responsive = { false }
231- dropAlign = { { 'right' : 'right' } }
232- style = { {
233- border : '2px solid #50514F' ,
234- margin : '0 auto'
235- } } />
236- < div className = "searchBtn"
237- onClick = { this . startFilter } > 搜尋</ div >
334+ < div className = "searchBtn"
335+ onClick = { this . showSearchModal } > 關鍵字搜尋
336+ </ div >
337+ < div className = "searchBtn"
338+ onClick = { this . showCatagoryModal } > 類別搜尋
339+ </ div >
238340 </ Box >
239-
240341 </ Header >
241342 < InfiniteScroll
242343 pageStart = { 0 }
0 commit comments