Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
submodule
Project
Project
Details
Activity
Releases
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
web_component
submodule
Commits
58b7b4c5
Commit
58b7b4c5
authored
May 12, 2020
by
满振华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改控件
parent
3f5f9181
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
104 additions
and
8 deletions
+104
-8
DataViewReducer.ts
components/dataView-V2/DataViewReducer.ts
+1
-1
index.tsx
...components/searchView/baseComponent/rangePicker/index.tsx
+19
-0
index.tsx
...omponents/searchView/baseComponent/selectSearch/index.tsx
+46
-0
index.tsx
components/dataView-V2/_components/searchView/index.tsx
+23
-1
styles.less
components/dataView-V2/_components/searchView/styles.less
+2
-0
index.tsx
components/dataView-V2/index.tsx
+13
-6
No files found.
components/dataView-V2/DataViewReducer.ts
View file @
58b7b4c5
...
...
@@ -73,7 +73,7 @@ export const effect = (reduceArr: any, registerFun: { fetch: Function }) => {
newParams
=
await
registerFun
.
fetch
({
searchForm
:
{
...
state
.
searchForm
,
...(
payload
.
searchForm
||
{})
}
})
break
case
'onResert'
:
newParams
=
await
registerFun
.
fetch
({
searchForm
:
undefined
,
pagination
:
initState
.
pagination
})
newParams
=
await
registerFun
.
fetch
({
searchForm
:
null
,
pagination
:
initState
.
pagination
})
dispatch
({
type
:
'onResert'
,
payload
:
{
...
...
components/dataView-V2/_components/searchView/baseComponent/rangePicker/index.tsx
0 → 100644
View file @
58b7b4c5
import
React
from
'react'
;
import
moment
from
'moment'
;
import
{
DatePicker
}
from
'antd'
;
export
const
formatStr
=
'YYYY-MM-DD HH:mm:ss'
;
const
{
RangePicker
}
=
DatePicker
const
CustomInput
=
(
props
:
any
)
=>
{
const
value
=
props
.
value
&&
Array
.
isArray
(
props
.
value
)
?
props
.
value
.
map
((
ls
:
string
)
=>
moment
(
ls
))
:
props
.
value
const
onChange
=
(
val
:
any
)
=>
{
if
(
props
.
onChange
)
{
let
setFormat
=
formatStr
;
const
newVal
=
val
&&
Array
.
isArray
(
val
)
?
val
.
map
(
ls
=>
ls
.
format
?
ls
.
format
(
setFormat
)
:
ls
)
:
val
;
return
props
.
onChange
(
newVal
)
}
}
return
<
RangePicker
placeholder=
{
props
.
placeholder
||
[
'开始时间'
,
'结束时间'
]
}
{
...
props
}
value=
{
value
}
onChange=
{
onChange
}
/>
}
export
default
CustomInput
;
\ No newline at end of file
components/dataView-V2/_components/searchView/baseComponent/selectSearch/index.tsx
0 → 100644
View file @
58b7b4c5
import
React
,
{
useState
}
from
'react'
;
import
{
Select
}
from
'antd'
;
import
{
SelectProps
}
from
'antd/es/select'
;
const
Option
:
any
=
Select
.
Option
;
export
interface
ApolloSelectProps
extends
SelectProps
<
any
>
{
request
:
Function
;
isMultiple
?:
boolean
;
options
?:
any
[];
optionsKey
?:
{
label
:
string
;
value
:
string
;
}
}
const
Custom
=
(
props
:
ApolloSelectProps
)
=>
{
const
[
dataSource
,
setData
]
=
useState
<
any
[]
>
([])
const
optionsKey
=
props
.
optionsKey
||
{
value
:
'id'
,
label
:
'name'
}
const
getList
=
async
(
val
:
string
)
=>
{
if
(
props
.
request
&&
typeof
props
.
request
===
'function'
)
{
const
data
=
await
props
.
request
(
val
);
if
(
data
&&
Array
.
isArray
(
data
))
{
const
newData
=
data
.
map
(
ls
=>
({
...
ls
,
_id
:
ls
[
optionsKey
.
value
],
_name
:
ls
[
optionsKey
.
label
]
}))
setData
(
newData
)
}
}
}
const
handleSearch
=
(
val
:
string
)
=>
{
getList
(
val
);
};
return
<
Select
showSearch
filterOption=
{
false
}
onSearch=
{
handleSearch
}
onFocus=
{
getList
.
bind
(
null
,
''
)
}
labelInValue
{
...
props
}
>
{
dataSource
.
map
((
ls
:
any
)
=>
(
<
Option
key=
{
ls
.
_id
}
>
{
ls
.
_name
}
</
Option
>)
)
}
</
Select
>
}
Custom
.
Option
=
Option
export
default
Custom
;
\ No newline at end of file
components/dataView-V2/_components/searchView/index.tsx
View file @
58b7b4c5
...
...
@@ -9,6 +9,8 @@ import {
// base-component
import
Input
from
'./baseComponent/input'
;
import
DatePicker
from
'./baseComponent/date'
;
import
RangePicker
from
'./baseComponent/rangePicker'
;
import
Search
from
'./baseComponent/selectSearch'
import
Filter
from
'../filterCondition'
;
import
styles
from
'./styles.less'
;
...
...
@@ -76,7 +78,26 @@ const SearchForm = (props: Props) => {
disabled=
{
disabled
}
/>
);
case
'daterange'
:
return
(
<
RangePicker
{
...
componentAttr
}
placeholder=
{
placeholder
}
className=
{
classnames
(
styles
.
timeStyle
,
className
||
styles
.
itemContent
)
}
disabled=
{
disabled
}
/>
);
case
'search'
:
return
(
<
Search
{
...
componentAttr
}
request=
{
col
.
request
}
optionsKey=
{
col
.
optionsKey
}
placeholder=
{
placeholder
}
className=
{
classnames
(
styles
.
timeStyle
,
className
||
styles
.
itemContent
)
}
disabled=
{
disabled
}
/>
);
default
:
return
(
<
Input
...
...
@@ -98,6 +119,7 @@ const SearchForm = (props: Props) => {
<
div
className=
{
styles
.
itemContent
}
>
{
node
?
(
<
Form
.
Item
{
...
(
ls
.
itemAttr
||
{})}
name=
{
ls
.
key
}
>
...
...
components/dataView-V2/_components/searchView/styles.less
View file @
58b7b4c5
...
...
@@ -22,6 +22,7 @@
justify-content: flex-start;
width: 100%;
margin-right: 20px;
text-align: left;
}
.checkboxContainer {
display: flex;
...
...
@@ -33,6 +34,7 @@
}
.timeStyle{
max-width: 320px;
}
.searchBtnWrap {
display: inline-block;
...
...
components/dataView-V2/index.tsx
View file @
58b7b4c5
import
React
,
{
useReducer
,
useEffect
}
from
'react'
;
import
React
,
{
useReducer
,
useEffect
,
MutableRefObject
,
useRef
,
forwardRef
,
useImperativeHandle
,
Ref
}
from
'react'
;
import
_
from
'lodash'
;
import
{
Button
}
from
'antd'
;
import
IconFont
from
'@/submodule/components/CustomIcon/IconFont'
;
...
...
@@ -32,10 +32,11 @@ interface State {
}
const
DataView
=
(
props
:
Props
)
=>
{
const
DataView
=
(
props
:
Props
,
ref
:
Ref
<
any
>
)
=>
{
let
registerFun
:
any
=
{
fetch
:
_fetch
}
const
testRef
:
MutableRefObject
<
any
>
=
useRef
();
const
{
style
,
hideForm
,
tips
}
=
props
;
const
[
state
,
dispatch
,
effectDispatch
]
=
effect
(
useReducer
(
reducer
,
initState
),
registerFun
);
const
initView
=
async
()
=>
{
...
...
@@ -50,9 +51,10 @@ const DataView = (props: Props) => {
useEffect
(()
=>
{
initView
()
},
[])
const
_beforeFetch
=
(
params
:
any
)
=>
{
const
{
pagination
=
{},
searchForm
}
=
params
||
{};
const
newSearchForm
=
searchForm
===
undefined
?
{}
:
{
...
state
.
searchForm
,
...(
searchForm
||
{})
}
// 手动清空
const
{
pagination
=
{},
searchForm
=
{}
}
=
params
||
{};
const
newSearchForm
=
searchForm
===
null
?
{}
:
{
...
state
.
searchForm
,
...(
searchForm
||
{})
}
// 手动清空
return
Object
.
assign
({},
newSearchForm
,
{
pageSize
:
state
.
pagination
.
pageSize
,
pageNum
:
state
.
pagination
.
pageNum
,
...
...
@@ -73,6 +75,11 @@ const DataView = (props: Props) => {
return
await
onAfterFetch
(
res
)
}
}
useImperativeHandle
(
ref
,
()
=>
{
//第一个参数,要暴露给哪个(ref)?第二个参数要暴露出什么?
return
{
fetch
:
effectDispatch
.
bind
(
null
,
{
type
:
'onSearch'
})
}
});
const
_renderBtns
=
()
=>
{
if
(
props
.
btns
&&
props
.
btns
.
length
>
0
)
{
return
(<
div
className=
{
styles
.
row
}
>
...
...
@@ -116,7 +123,7 @@ const DataView = (props: Props) => {
<>
<
div
className=
{
styles
.
formWrap
}
>
{
/* 基本筛选条件 */
}
<
SearchForm
searchCols=
{
props
.
searchCols
}
/>
<
SearchForm
searchCols=
{
props
.
searchCols
}
ref=
{
testRef
}
/>
</
div
>
<
div
className=
{
styles
.
split
}
/>
</>
...
...
@@ -131,4 +138,4 @@ const DataView = (props: Props) => {
</
div
>
)
}
export
default
DataView
\ No newline at end of file
export
default
forwardRef
(
DataView
)
\ No newline at end of file
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