Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
ik_invoicing
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_frontend
ik_invoicing
Commits
0786fc59
Commit
0786fc59
authored
Jan 11, 2017
by
小明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重构 components 组件下 Search 组件代码
parent
3dffd51a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
109 additions
and
0 deletions
+109
-0
src/components/Search/index.js
+98
-0
src/components/Search/tests/index.test.js
+11
-0
No files found.
src/components/Search/index.js
0 → 100644
View file @
0786fc59
/**
*
* IKSearch
*
*/
import
React
,
{
PureComponent
}
from
'react'
;
import
{
Row
,
Col
,
Icon
,
From
,
Button
,
Input
}
from
'antd'
;
const
InputGroup
=
Input
.
Group
;
class
IKSearch
extends
PureComponent
{
// eslint-disable-line react/prefer-stateless-function
static
propTypes
=
{
type
:
React
.
PropTypes
.
string
,
icon
:
React
.
PropTypes
.
string
,
className
:
React
.
PropTypes
.
string
,
onChange
:
React
.
PropTypes
.
func
,
onSearch
:
React
.
PropTypes
.
func
,
buttonEvent
:
React
.
PropTypes
.
func
,
};
state
=
{
value
:
this
.
props
.
value
||
''
,
noticeVisible
:
false
,
button
:
this
.
props
.
button
?
this
.
props
.
button
||
false
,
};
constructor
(
props
)
{
super
(
props
);
}
handleInputChange
(
e
)
{
if
(
e
.
target
.
value
>
50
)
{
if
(
!
this
.
state
.
noticeVisible
)
{
this
.
setState
({
noticeVisible
:
true
});
errorNotice
(
'字数不能超过50'
,
()
=>
{
this
.
setState
({
noticeVisible
:
false
});
});
}
}
else
{
this
.
setState
({
value
:
e
.
target
.
value
});
this
.
props
.
onChange
&&
this
.
props
.
onChange
(
e
);
}
}
componentWillReceiveProps
(
nextProps
)
{
this
.
setState
({
value
:
nextProps
.
vaule
});
}
handleSearch
()
{
this
.
props
.
onSearch
&&
this
.
props
.
onSearch
();
}
render
()
{
const
props
=
$
({},
this
.
props
);
let
svgElm
=
null
;
if
(
props
.
button
)
{
svgElm
=
(
<
Col
span
=
"3"
>
<
svg
>
<
use
xlinkHref
=
{
props
.
button
}
onClick
=
{
props
.
buttonEvent
}
/
>
<
/svg
>
<
/Col
>
);
}
return
(
<
div
className
=
"ik-search"
>
<
div
className
=
"ant-search-input-wrapper ik-width-percent-100"
>
<
Row
>
<
Col
span
=
{
`
${
this
.
props
.
button
?
'21'
:
'24'
}
`
}
<
Form
>
<
InputGroup
className
=
"ant-search-input"
>
<
Input
placeholder
=
{
this
.
props
.
placeholder
}
size
=
"large"
type
=
"search"
value
=
{
this
.
state
.
value
}
onChange
=
{
this
.
handleInputChange
}
onPressEnter
=
{
this
.
handleSearch
}
className
=
"ik-padding-right-40"
/>
<
div
className
=
"ant-input-group-wrap"
>
<
Button
icon
=
"search"
className
=
"ant-search-btn"
onClick
=
{
this
.
handleSearch
}
/
>
<
/div
>
<
/InputGroup
>
<
/Form
>
{
svgElm
}
<
/Col
>
<
/Row
>
<
/div
>
<
/div
>
)
}
}
export
default
IKSearch
;
src/components/Search/tests/index.test.js
0 → 100644
View file @
0786fc59
// import IKSearch from '../index';
import
expect
from
'expect'
;
// import { shallow } from 'enzyme';
// import React from 'react';
describe
(
'<IKSearch />'
,
()
=>
{
it
(
'Expect to have unit tests specified'
,
()
=>
{
expect
(
true
).
toEqual
(
false
);
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment