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
3dffd51a
Commit
3dffd51a
authored
Jan 11, 2017
by
小明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重构 components 组件下 Select 组件代码
parent
a22ead52
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
0 deletions
+86
-0
src/components/Select/index.js
+75
-0
src/components/Select/tests/index.test.js
+11
-0
No files found.
src/components/Select/index.js
0 → 100644
View file @
3dffd51a
/**
*
* @IKSelect
*
*/
import
React
,
{
PureComponent
}
from
'react'
;
class
@
IKSelect
extends
PureComponent
{
// eslint-disable-line react/prefer-stateless-function
static
propTypes
=
{
required
:
React
.
PropTypes
.
boolean
,
subtitle
:
React
.
PropTypes
.
string
,
tips
:
React
.
PropTypes
.
string
,
errorMsg
:
React
.
PropTypes
.
string
,
onClick
:
React
.
PropTypes
.
func
,
};
state
=
{
needValidate
:
this
.
props
.
required
,
subtitle
:
this
.
props
.
subtitle
,
validate
:
true
,
tips
:
this
.
props
.
tips
||
(
this
.
props
.
required
?
'必填'
:
''
),
errorMsg
:
this
.
props
.
errorMsg
||
(
this
.
props
.
required
?
'不能为空'
:
''
),
};
constructor
(
props
)
{
super
(
props
);
}
validate
()
{
let
flag
=
true
;
if
(
this
.
state
.
needValidate
)
{
flag
=
this
.
state
.
subtitle
&&
this
.
state
.
subtitle
.
length
;
}
this
.
setState
({
validate
:
flag
});
}
componentWillReceiveProps
(
nextProps
)
{
this
.
setState
({
subtitle
:
nextProps
.
subtitle
});
}
render
()
{
const
props
=
$
({},
this
.
props
);
let
msgElm
=
this
.
state
.
errorMsg
;
if
(
!
props
.
subtitle
)
{
props
.
subtitle
=
''
;
}
if
(
this
.
state
.
validate
)
{
msgElm
=
this
.
state
.
tips
;
}
return
(
<
div
className
=
{
`ikmd-select
${
this
.
state
.
needValidate
?
'ikmd-validate'
:
''
}
`
}
onClick
=
{
props
.
onClick
}
data
-
valid
=
{
this
.
state
.
validate
}
>
<
p
className
=
{
`ikmd-select-title
${
this
.
state
.
subtitle
?
'shrunken'
:
''
}
`
}
>
{
this
.
state
.
title
}
<
/p
>
<
p
className
=
"ikmd-select-subtitle"
>
{
this
.
state
.
subtitle
}
<
/p
>
<
div
className
=
{
`ikmd-select-tips
${
props
.
subtitle
?
'ik-hidden'
:
''
}
${
this
.
state
.
validate
?
''
:
'ikmd-input-errors'
}
`
}
>
{
msgElm
}
<
/div
>
<
div
className
=
"ikmd-select-arrow"
>
<
Icon
type
=
"right"
/>
<
/div
>
<
/div
>
);
}
}
export
default
@
IKSelect
;
src/components/Select/tests/index.test.js
0 → 100644
View file @
3dffd51a
// import @IKSelect from '../index';
import
expect
from
'expect'
;
// import { shallow } from 'enzyme';
// import React from 'react';
describe
(
'<@IKSelect />'
,
()
=>
{
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