Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
Project
Project
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄庭坚
jinfa-platform
Commits
b9863fef
Commit
b9863fef
authored
Aug 26, 2020
by
LeeJiancong
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
http://10.0.0.22:3000/lingxi/lingxi-business-paltform
into dev
parents
0332bf08
6226b7ff
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
131 additions
and
11 deletions
+131
-11
SearchSelect.tsx
src/components/NiceForm/components/SearchSelect.tsx
+29
-7
index.less
src/components/NiceForm/index.less
+24
-0
index.tsx
src/components/NiceForm/index.tsx
+25
-0
global.d.ts
src/global/config/global.d.ts
+47
-0
index.tsx
src/pages/repositories/schema/index.tsx
+2
-2
request.ts
src/utils/request.ts
+4
-2
No files found.
src/components/NiceForm/components/SearchSelect.tsx
View file @
b9863fef
import
React
,
{
useState
,
useEffect
,
useRef
}
from
'react'
import
{
Select
,
Input
}
from
'antd'
;
import
{
Select
,
Input
,
Row
,
Button
}
from
'antd'
;
import
{
useDebounceFn
}
from
'@umijs/hooks'
;
import
{
ISchemaFieldComponentProps
,
FormPath
,
useFormEffects
,
createFormActions
,
createAsyncFormActions
}
from
'@formily/antd'
import
pinyin
from
'pinyin'
const
SelectContent
=
(
props
)
=>
{
const
{
handleChange
}
=
props
return
<
div
>
const
{
handleChange
,
multiple
,
confirm
,
resetField
}
=
props
return
<
div
onBlur=
{
confirm
}
>
<
div
style=
{
{
padding
:
'12px'
}
}
>
<
Input
.
Search
onChange=
{
handleChange
}
/>
</
div
>
{
props
.
children
}
{
multiple
&&
<
Row
justify=
'end'
style=
{
{
borderTop
:
'1px solid #eee'
}
}
>
<
Button
type=
'link'
onClick=
{
resetField
}
>
重置
</
Button
>
<
Button
type=
'link'
onClick=
{
confirm
}
>
确定
</
Button
>
</
Row
>
}
</
div
>
}
// 自定义搜索型下拉框
const
SearchSelect
=
(
props
:
ISchemaFieldComponentProps
)
=>
{
const
ref
=
useRef
<
any
>
({})
const
{
schema
,
form
,
path
,
mutators
}
=
props
const
dataSourceRef
=
useRef
<
any
[]
>
([])
const
pinyinRef
=
useRef
<
any
[]
>
([])
// 可选参数 fetchSearch, select为search
const
{
fetchSearch
,
fetchParams
=
'name'
,
fetchFormat
,
...
resetProps
}
=
schema
.
getExtendsComponentProps
()
// multiple 是否开启多选
const
{
fetchSearch
,
fetchParams
=
'name'
,
fetchFormat
,
multiple
=
false
,
...
resetProps
}
=
schema
.
getExtendsComponentProps
()
const
[
dataSource
,
setDataSource
]
=
useState
<
any
[]
>
([])
const
[
loading
,
setLoading
]
=
useState
(
false
)
const
[
openSelect
,
setOpenSelect
]
=
useState
(
false
)
const
fuzzyQuery
=
(
keyword
)
=>
{
const
pinyinArr
=
pinyinRef
.
current
...
...
@@ -42,6 +52,15 @@ const SearchSelect = (props: ISchemaFieldComponentProps) => {
return
result
}
const
resetField
=
()
=>
{
form
.
setFieldValue
(
path
,
multiple
?
[]
:
''
)
}
const
confirm
=
(
e
)
=>
{
e
.
preventDefault
()
setOpenSelect
(
false
)
}
useEffect
(()
=>
{
setLoading
(
true
)
fetchSearch
({
...
...
@@ -97,15 +116,18 @@ const SearchSelect = (props: ISchemaFieldComponentProps) => {
// }
// const { run } = useDebounceFn(dispatchSearch, 500)
return
(
<
Select
ref=
{
ref
}
mode=
{
multiple
?
'multiple'
:
null
}
onChange=
{
e
=>
mutators
.
change
(
e
)
}
filterOption=
{
false
}
loading=
{
loading
}
options=
{
dataSource
}
onFocus=
{
()
=>
setOpenSelect
(
true
)
}
value=
{
props
.
value
}
dropdownRender=
{
originNode
=>
<
SelectContent
handleChange=
{
handleChange
}
>
{
originNode
}
</
SelectContent
>
}
open=
{
multiple
?
openSelect
:
null
}
dropdownRender=
{
originNode
=>
<
SelectContent
confirm=
{
confirm
}
resetField=
{
resetField
}
parentRef=
{
ref
}
handleChange=
{
handleChange
}
multiple=
{
multiple
}
value=
{
props
.
value
}
>
{
originNode
}
</
SelectContent
>
}
{
...
resetProps
}
>
</
Select
>
...
...
src/components/NiceForm/index.less
View file @
b9863fef
...
...
@@ -23,4 +23,27 @@
box-shadow: none;
border-bottom: 1px solid #DFE1E6;
}
}
.flex-layout-label-required {
display: -webkit-inline-box;
display: -webkit-inline-flex;
display: -ms-inline-flexbox;
display: inline-flex;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
height: 32px;
color: rgba(0, 0, 0, 0.85);
font-size: 14px;
&::before {
display: inline-block;
margin-right: 4px;
color: #ff4d4f;
font-size: 14px;
font-family: SimSun, sans-serif;
line-height: 1;
content: '*';
}
}
\ No newline at end of file
src/components/NiceForm/index.tsx
View file @
b9863fef
...
...
@@ -24,6 +24,7 @@ import CustomRadio from './components/CustomRadio';
import
SearchSelect
from
'./components/SearchSelect'
;
import
'./index.less'
import
{
Checkbox
}
from
'@formily/antd-components'
;
import
cx
from
'classnames'
export
interface
NiceFormProps
extends
IAntdSchemaFormProps
{}
...
...
@@ -36,6 +37,30 @@ const RowLayout = styled(props => <Row justify='end' {...props}/>)`
}
`
const
renderCol
=
(
schema
,
isLast
)
=>
{
const
{
flexcol
=
{}
}
=
schema
[
'x-component-props'
]
return
<
Col
style=
{
isLast
?
{}
:
{
marginRight
:
24
}
}
{
...
flexcol
}
key=
{
schema
.
path
}
>
<
SchemaField
schema=
{
schema
.
toJSON
()
}
path=
{
schema
.
path
}
/>
</
Col
>
}
// 自定义flex布局容器
registerVirtualBox
(
'flex-box'
,
props
=>
{
const
childProperties
=
props
.
schema
.
getOrderProperties
()
const
{
title
,
required
}
=
props
.
props
const
{
labelcol
,
wrappercol
}
=
props
.
schema
.
getExtendsComponentProps
()
return
<
Row
>
{
title
&&
<
Col
span=
{
labelcol
}
className=
{
cx
(
required
?
'flex-layout-label-required'
:
''
)
}
>
{
title
}
</
Col
>
}
<
Col
span=
{
wrappercol
}
>
<
Row
>
{
childProperties
.
map
((
v
,
i
,
arr
)
=>
renderCol
(
v
.
schema
,
arr
.
length
-
1
===
i
))
}
</
Row
>
</
Col
>
</
Row
>
})
registerVirtualBox
(
'flex-layout'
,
(
_props
)
=>
{
const
{
children
,
props
}
=
_props
const
rowStyle
=
props
[
'x-component-props'
]
?
props
[
'x-component-props'
].
rowStyle
:
{}
...
...
src/global/config/global.d.ts
0 → 100644
View file @
b9863fef
export
interface
MemberType
{
id
:
number
;
typeName
:
string
;
}
export
interface
BusinessType
{
id
:
number
;
typeName
:
string
;
}
export
interface
UseType
{
memberType
:
MemberType
[];
businessType
:
BusinessType
[];
}
export
interface
UserRegister
{
useType
:
UseType
;
}
export
interface
Web
{
shopInfo
:
any
[];
}
export
interface
PayConfig
{
paymemberConfig
?:
any
;
}
export
interface
CountryList
{
name
:
string
;
key
:
string
;
icon
:
string
;
}
export
interface
Global
{
siteId
:
number
;
siteUrl
:
string
;
logo
:
string
;
countryList
:
CountryList
[];
}
export
interface
RootObject
{
userRegister
:
UserRegister
;
web
:
Web
;
payConfig
:
PayConfig
;
global
:
Global
;
}
\ No newline at end of file
src/pages/repositories/schema/index.tsx
View file @
b9863fef
...
...
@@ -77,7 +77,7 @@ export const repositSchema: ISchema = {
fetchSearch
:
PublicApi
.
getProductSelectGetSelectCategory
,
placeholder
:
'请选择品类'
,
style
:
{
minWidth
:
160
width
:
160
,
}
},
enum
:
[]
...
...
@@ -89,7 +89,7 @@ export const repositSchema: ISchema = {
fetchSearch
:
PublicApi
.
getProductSelectGetSelectBrand
,
placeholder
:
'请选择品牌'
,
style
:
{
minW
idth
:
160
w
idth
:
160
}
},
enum
:
[]
...
...
src/utils/request.ts
View file @
b9863fef
...
...
@@ -70,10 +70,12 @@ const baseRequest = extend({
// 请求拦截器
baseRequest
.
interceptors
.
request
.
use
((
url
:
string
,
options
:
RequestOptionsInit
):
{
url
:
string
,
options
:
RequestOptionsInit
}
=>
{
// 判断是否有权限
const
loginAfterHeaders
=
getAuth
()
const
{
userId
,
memberId
,
token
}
=
getAuth
()
||
{}
const
headers
=
{
...
options
.
headers
,
...
loginAfterHeaders
userId
,
memberId
,
token
}
return
{
// 前缀如果已经带上api, 跳过自动补前缀
...
...
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