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
9bfbdf37
Commit
9bfbdf37
authored
Jun 02, 2021
by
XieZhiXiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 抽离 formily Upload 组件
parent
5093e150
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
5 deletions
+28
-5
index.tsx
src/components/NiceForm/components/AntUpload/index.tsx
+0
-5
FixUpload.tsx
src/components/NiceForm/components/FixUpload.tsx
+26
-0
index.tsx
src/components/NiceForm/index.tsx
+2
-0
No files found.
src/components/NiceForm/components/AntUpload/index.tsx
View file @
9bfbdf37
...
@@ -11,9 +11,7 @@ import {
...
@@ -11,9 +11,7 @@ import {
FileFilled
,
FileFilled
,
DeleteOutlined
DeleteOutlined
}
from
'@ant-design/icons'
}
from
'@ant-design/icons'
import
{
getAuth
}
from
'@/utils/auth'
const
{
userId
,
memberId
,
token
}
=
getAuth
()
||
{}
const
{
Dragger
:
UploadDragger
}
=
AntdUpload
const
{
Dragger
:
UploadDragger
}
=
AntdUpload
const
exts
=
[
const
exts
=
[
...
@@ -262,7 +260,6 @@ export const Upload = connect({
...
@@ -262,7 +260,6 @@ export const Upload = connect({
onChange=
{
this
.
onChangeHandler
}
onChange=
{
this
.
onChangeHandler
}
onRemove=
{
this
.
onRemoveHandler
}
onRemove=
{
this
.
onRemoveHandler
}
listType=
{
'picture-card'
}
listType=
{
'picture-card'
}
headers=
{
{
token
}
}
>
>
{
!
others
.
readOnly
?
(
{
!
others
.
readOnly
?
(
<
UploadPlaceholder
/>
<
UploadPlaceholder
/>
...
@@ -279,7 +276,6 @@ export const Upload = connect({
...
@@ -279,7 +276,6 @@ export const Upload = connect({
onRemove=
{
this
.
onRemoveHandler
}
onRemove=
{
this
.
onRemoveHandler
}
// TODO image 类型是跟 picture 一样 ?
// TODO image 类型是跟 picture 一样 ?
listType=
{
listType
.
indexOf
(
'image'
)
>
-
1
?
'picture'
:
'text'
}
listType=
{
listType
.
indexOf
(
'image'
)
>
-
1
?
'picture'
:
'text'
}
headers=
{
{
token
}
}
>
>
<
p
className=
{
'ant-upload-drag-icon'
}
>
<
p
className=
{
'ant-upload-drag-icon'
}
>
<
InboxOutlined
/>
<
InboxOutlined
/>
...
@@ -301,7 +297,6 @@ export const Upload = connect({
...
@@ -301,7 +297,6 @@ export const Upload = connect({
onChange=
{
this
.
onChangeHandler
}
onChange=
{
this
.
onChangeHandler
}
onRemove=
{
this
.
onRemoveHandler
}
onRemove=
{
this
.
onRemoveHandler
}
listType=
{
listType
}
listType=
{
listType
}
headers=
{
{
token
}
}
itemRender=
{
()
=>
null
}
itemRender=
{
()
=>
null
}
>
>
{
!
others
.
readOnly
?
(
{
!
others
.
readOnly
?
(
...
...
src/components/NiceForm/components/FixUpload.tsx
0 → 100644
View file @
9bfbdf37
/*
* @Author: XieZhiXiong
* @Date: 2021-06-01 17:32:51
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-06-01 17:44:27
* @Description: 默认带上 token 的 AntUpload
*/
import
React
from
'react'
;
import
{
getAuth
}
from
'@/utils/auth'
;
import
AntUpload
from
'./AntUpload'
;
const
FixUpload
=
(
props
)
=>
{
const
{
token
}
=
(
getAuth
()
||
{});
return
(
<
AntUpload
headers=
{
{
token
,
}
}
{
...
props
}
/>
);
};
FixUpload
.
isFieldComponent
=
true
;
export
default
FixUpload
;
src/components/NiceForm/index.tsx
View file @
9bfbdf37
...
@@ -37,6 +37,7 @@ import Loading from '../Loading';
...
@@ -37,6 +37,7 @@ import Loading from '../Loading';
import
MultAddress
from
'./components/MultAddress'
;
import
MultAddress
from
'./components/MultAddress'
;
import
CustomAddress
from
'./components/CustomAddress'
;
import
CustomAddress
from
'./components/CustomAddress'
;
import
CustomCascader
from
'./components/CustomCascader'
;
import
CustomCascader
from
'./components/CustomCascader'
;
import
FixUpload
from
'./components/FixUpload'
;
import
{
currentStateType
,
getCurrentState
}
from
'./utils/keepAlive'
;
import
{
currentStateType
,
getCurrentState
}
from
'./utils/keepAlive'
;
import
{
useRouteMatch
}
from
'umi'
;
import
{
useRouteMatch
}
from
'umi'
;
...
@@ -119,6 +120,7 @@ export const componentExport = {
...
@@ -119,6 +120,7 @@ export const componentExport = {
MultAddress
,
MultAddress
,
CustomAddress
,
CustomAddress
,
CustomCascader
,
CustomCascader
,
FixUpload
,
}
}
const
NiceForm
:
React
.
FC
<
NiceFormProps
>
=
props
=>
{
const
NiceForm
:
React
.
FC
<
NiceFormProps
>
=
props
=>
{
const
{
children
,
components
,
effects
,
expressionScope
,
loading
=
false
,
...
reset
}
=
props
;
const
{
children
,
components
,
effects
,
expressionScope
,
loading
=
false
,
...
reset
}
=
props
;
...
...
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