Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
TOSTUMI
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
Maple
TOSTUMI
Commits
ff46bff4
Commit
ff46bff4
authored
Feb 18, 2021
by
cellee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Signed-off-by: cellee <893264950@qq.com>
parent
af1211bb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
26 deletions
+46
-26
proxy.ts
config/proxy.ts
+6
-6
PdfUpload.tsx
src/components/Form/PdfUpload.tsx
+40
-20
No files found.
config/proxy.ts
View file @
ff46bff4
...
@@ -86,15 +86,15 @@ export default {
...
@@ -86,15 +86,15 @@ export default {
changeOrigin
:
true
,
changeOrigin
:
true
,
pathRewrite
:
{
'^'
:
''
},
pathRewrite
:
{
'^'
:
''
},
},
},
'/tos/'
:
{
target
:
'http://47.74.233.180:8651'
,
changeOrigin
:
true
,
pathRewrite
:
{
'^'
:
''
},
},
// '/tos/': {
// '/tos/': {
// target: 'http://
192.168.1.28
:8651',
// target: 'http://
47.74.233.180
:8651',
// changeOrigin: true,
// changeOrigin: true,
// pathRewrite: { '^': '' },
// pathRewrite: { '^': '' },
// },
// },
'/tos/'
:
{
target
:
'http://192.168.1.28:8651'
,
changeOrigin
:
true
,
pathRewrite
:
{
'^'
:
''
},
},
},
},
};
};
src/components/Form/PdfUpload.tsx
View file @
ff46bff4
/*
/*
* @Author: your name
* @Author: your name
* @Date: 2021-02-01 14:54:48
* @Date: 2021-02-01 14:54:48
* @LastEditTime: 2021-02-
06 11:51:58
* @LastEditTime: 2021-02-
18 13:54:59
* @LastEditors: Please set LastEditors
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @Description: In User Settings Edit
* @FilePath: \tostumi\src\components\Form\PdfUpload.tsx
* @FilePath: \tostumi\src\components\Form\PdfUpload.tsx
*/
*/
import
React
,
{
useState
}
from
'react'
;
import
React
,
{
useState
}
from
'react'
;
import
{
Input
,
Upload
,
message
,
Button
,
Spin
}
from
'antd'
;
import
{
Input
,
Upload
,
message
,
Button
,
Spin
}
from
'antd'
;
import
{
LoadingOutlined
,
PlusOutlined
,
MinusCircleOutlined
}
from
'@ant-design/icons'
;
import
{
LoadingOutlined
,
PlusOutlined
,
MinusCircleOutlined
,
FilePdfOutlined
,
}
from
'@ant-design/icons'
;
interface
PriceInputProps
{
interface
PriceInputProps
{
value
?:
any
;
value
?:
any
;
...
@@ -19,8 +24,12 @@ interface PriceInputProps {
...
@@ -19,8 +24,12 @@ interface PriceInputProps {
}
}
const
PdfUpload
:
React
.
FC
<
PriceInputProps
>
=
({
value
=
{},
onChange
,
disabled
,
action
,
data
})
=>
{
const
PdfUpload
:
React
.
FC
<
PriceInputProps
>
=
({
value
=
{},
onChange
,
disabled
,
action
,
data
})
=>
{
const
[
loading
,
setLoading
]
=
useState
([
false
,
false
,
false
,
false
,
false
]);
const
[
loading
,
setLoading
]
=
useState
([
false
,
false
,
false
,
false
,
false
]);
// 上传中控制
const
[
imgList
,
setImgList
]
=
useState
([]
as
any
);
const
[
idx
,
setIdx
]
=
useState
(
0
);
// 点击的第几个
const
[
imgList
,
setImgList
]
=
useState
([]
as
any
);
// 列表
const
[
PdfUrl
,
setPdfUrl
]
=
useState
(
null
);
//地址
const
[
ModalVisible
,
setModalVisible
]
=
useState
(
false
);
//显示隐藏
// 上传前检测
// 上传前检测
function
beforeUpload
(
file
:
any
)
{
function
beforeUpload
(
file
:
any
)
{
...
@@ -38,22 +47,26 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
...
@@ -38,22 +47,26 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
// 上传成功怎么做
// 上传成功怎么做
const
handleChange
=
(
info
:
any
)
=>
{
const
handleChange
=
(
info
:
any
)
=>
{
console
.
log
(
info
);
console
.
log
(
info
);
console
.
log
(
info
.
event
);
let
{
status
,
response
}
=
info
.
file
;
let
{
status
,
response
}
=
info
.
file
;
if
(
status
===
'uploading'
)
{
if
(
status
===
'uploading'
)
{
// setLoading();
// setLoading();
return
;
let
v
=
loading
;
v
[
idx
]
=
true
;
setLoading
([...
v
]);
}
else
{
}
else
{
// setLoading(false);
let
v
=
loading
;
v
[
idx
]
=
false
;
setLoading
([...
v
]);
}
}
if
(
status
===
'done'
)
{
if
(
status
===
'done'
)
{
let
{
fileName
,
key
}
=
response
.
data
;
console
.
log
(
'上传成功'
);
let
{
fileName
,
key
,
fileUrl
}
=
response
.
data
;
let
list
=
JSON
.
parse
(
JSON
.
stringify
(
imgList
));
let
list
=
JSON
.
parse
(
JSON
.
stringify
(
imgList
));
let
obj
=
{
let
obj
=
{
uid
:
Math
.
floor
(
Math
.
random
()
*
100
),
uid
:
Math
.
floor
(
Math
.
random
()
*
100
),
name
:
fileName
,
name
:
fileName
,
status
:
'done'
,
status
:
'done'
,
url
:
'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png'
,
url
:
fileUrl
,
};
};
if
(
!
list
[
parseInt
(
key
)])
{
if
(
!
list
[
parseInt
(
key
)])
{
// 先判断这个是不是在上传途中被删除掉了
// 先判断这个是不是在上传途中被删除掉了
...
@@ -74,7 +87,7 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
...
@@ -74,7 +87,7 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
id
:
Math
.
floor
(
Math
.
random
()
*
100
),
id
:
Math
.
floor
(
Math
.
random
()
*
100
),
name
:
''
,
name
:
''
,
fileList
:
[],
fileList
:
[],
tip
:
tru
e
,
tip
:
fals
e
,
loading
:
false
,
loading
:
false
,
message
:
'123'
,
message
:
'123'
,
};
};
...
@@ -97,13 +110,17 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
...
@@ -97,13 +110,17 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
// 点击预览
// 点击预览
const
handlePreview
=
async
(
file
:
any
)
=>
{
const
handlePreview
=
async
(
file
:
any
)
=>
{
if
(
!
file
.
url
&&
!
file
.
preview
)
{
setPdfUrl
(
file
);
// file.preview = await getBase64(file.originFileObj);
setModalVisible
(
true
);
}
};
console
.
log
(
file
);
// setpreviewImage(file.url || file.preview);
// 点击上传记录index
// setpreviewTitle(file.name);
const
opens
=
(
i
:
any
)
=>
{
// setpreviewVisible(true);
setIdx
(
i
);
};
const
icons
=
()
=>
{
return
<
FilePdfOutlined
/>;
};
};
return
(
return
(
...
@@ -124,15 +141,16 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
...
@@ -124,15 +141,16 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
name=
"file"
name=
"file"
listType=
"picture-card"
listType=
"picture-card"
fileList=
{
item
.
fileList
}
fileList=
{
item
.
fileList
}
// showUploadList=
{
false
}
onPreview=
{
handlePreview
}
// 预览
onPreview=
{
handlePreview
}
// 预览
beforeUpload=
{
beforeUpload
}
beforeUpload=
{
beforeUpload
}
//上传前检测
onChange=
{
handleChange
}
onChange=
{
handleChange
}
id=
{
index
}
id=
{
index
}
iconRender=
{
icons
}
>
>
{
item
.
fileList
&&
item
.
fileList
.
length
>=
5
?
null
:
(
{
item
.
fileList
&&
item
.
fileList
.
length
>=
5
?
null
:
(
<
div
>
<
div
onClick=
{
()
=>
opens
(
index
)
}
>
{
loading
[
index
]
?
<
LoadingOutlined
/>
:
<
PlusOutlined
/>
}
{
loading
[
index
]
?
<
LoadingOutlined
/>
:
<
PlusOutlined
/>
}
{
/* <PlusOutlined></PlusOutlined> */
}
<
div
style=
{
{
marginTop
:
8
}
}
>
Upload
</
div
>
<
div
style=
{
{
marginTop
:
8
}
}
>
Upload
</
div
>
</
div
>
</
div
>
)
}
)
}
...
@@ -161,6 +179,8 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
...
@@ -161,6 +179,8 @@ const PdfUpload: React.FC<PriceInputProps> = ({ value = {}, onChange, disabled,
)
:
(
)
:
(
''
''
)
}
)
}
{
/* 弹出层 */
}
</>
</>
);
);
};
};
...
...
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