Commit b5c2afc1 authored by 前端-许佳敏's avatar 前端-许佳敏

fix: 修复请购单附件无法下载

parent 695cbc51
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>
}
},
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment