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
shenshaokai
jinfa-platform
Commits
b5c2afc1
Commit
b5c2afc1
authored
Apr 21, 2022
by
前端-许佳敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修复请购单附件无法下载
parent
695cbc51
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
3 deletions
+21
-3
index.tsx
...ion/purchaseRequisition/components/bilEnclosure/index.tsx
+7
-3
index.tsx
src/utils/index.tsx
+14
-0
No files found.
src/pages/transaction/purchaseRequisition/components/bilEnclosure/index.tsx
View file @
b5c2afc1
import
React
,
{
useContext
,
useEffect
,
useState
}
from
'react'
import
{
Table
,
Radio
}
from
'antd'
import
{
formatTimeString
}
from
'@/utils'
import
{
Table
,
Radio
,
Button
}
from
'antd'
import
{
downloadFile
,
formatTimeString
}
from
'@/utils'
import
MellowCard
from
'@/components/MellowCard'
import
{
TransferEnum
}
from
'../transferProcess'
;
import
style
from
'./index.less'
import
{
BillDetailContext
}
from
'@/pages/transaction/_public/bill/effects/context'
;
import
{
useIntl
}
from
'umi'
;
import
{
Link
,
useIntl
}
from
'umi'
;
/**
* 附件
...
...
@@ -27,6 +27,10 @@ const BilEnclosure: React.FC<BidTransformRecordProps> = ({ cardTitle }) => {
dataIndex
:
'name'
,
align
:
'left'
,
key
:
'name'
,
render
:
(
text
,
record
)
=>
{
console
.
log
(
record
)
return
<
Button
onClick=
{
()
=>
downloadFile
(
record
.
url
,
record
.
name
)
}
type=
'link'
>
{
text
}
</
Button
>
}
},
...
...
src/utils/index.tsx
View file @
b5c2afc1
...
...
@@ -714,6 +714,20 @@ export const getUrlMemberId = (url: string) => {
return
undefined
}
export
const
downloadFile
=
(
url
,
fileName
)
=>
{
const
x
=
new
XMLHttpRequest
();
x
.
open
(
"GET"
,
url
,
true
);
x
.
responseType
=
'blob'
;
x
.
onload
=
function
(
e
)
{
const
url
=
window
.
URL
.
createObjectURL
(
x
.
response
)
const
a
=
document
.
createElement
(
'a'
);
a
.
href
=
url
a
.
download
=
fileName
;
a
.
click
()
}
x
.
send
();
}
export
default
{
isArray
,
isObject
,
...
...
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