Merge branch '20221118-修改获取下载路径方法' of http://gitlab.tianti.tg.unicom.local/eshop/fe_service_ebtp_frontend into release_electronic_bid_evaluation_room
This commit is contained in:
@ -3,7 +3,7 @@ import { Modal, Button } from 'antd';
|
|||||||
import PDF from 'react-pdf-js';
|
import PDF from 'react-pdf-js';
|
||||||
import ProCard from '@ant-design/pro-card';
|
import ProCard from '@ant-design/pro-card';
|
||||||
import FileDown from '@/utils/Download';
|
import FileDown from '@/utils/Download';
|
||||||
import { getDownloadFileUrl, getFileListByBid } from '@/utils/DownloadUtils';
|
import { getFileListByBid, useDownLoadUrl } from '@/utils/DownloadUtils';
|
||||||
|
|
||||||
interface PreviewJgtzsModalProps {
|
interface PreviewJgtzsModalProps {
|
||||||
fileId: string,
|
fileId: string,
|
||||||
@ -14,6 +14,7 @@ interface PreviewJgtzsModalProps {
|
|||||||
|
|
||||||
const PreviewJgtzsModal: React.FC<PreviewJgtzsModalProps> = (props) => {
|
const PreviewJgtzsModal: React.FC<PreviewJgtzsModalProps> = (props) => {
|
||||||
const { fileId, downLoadFileName, modalVisible, onCancel } = props
|
const { fileId, downLoadFileName, modalVisible, onCancel } = props
|
||||||
|
const [url] = useDownLoadUrl(fileId);
|
||||||
const [page, setPage] = useState<number>(1);
|
const [page, setPage] = useState<number>(1);
|
||||||
const [pages, setPages] = useState<number>(0);
|
const [pages, setPages] = useState<number>(0);
|
||||||
const [fileExist, setFileExist] = useState<string>("0");//0:未验证,1:验证后有,2:验证后没有
|
const [fileExist, setFileExist] = useState<string>("0");//0:未验证,1:验证后有,2:验证后没有
|
||||||
@ -81,10 +82,10 @@ const PreviewJgtzsModal: React.FC<PreviewJgtzsModalProps> = (props) => {
|
|||||||
>
|
>
|
||||||
{fileExist == "0" ? (
|
{fileExist == "0" ? (
|
||||||
<div />
|
<div />
|
||||||
) : fileExist == "1" ? (
|
) : fileExist == "1" ? url != "" && (
|
||||||
<>
|
<>
|
||||||
<PDF
|
<PDF
|
||||||
file={getDownloadFileUrl(fileId)}
|
file={url}
|
||||||
scale={1.6}
|
scale={1.6}
|
||||||
onDocumentComplete={onDocumentComplete}
|
onDocumentComplete={onDocumentComplete}
|
||||||
page={page}
|
page={page}
|
||||||
|
@ -3,7 +3,7 @@ import { Modal, Button } from 'antd';
|
|||||||
import PDF from 'react-pdf-js';
|
import PDF from 'react-pdf-js';
|
||||||
import ProCard from '@ant-design/pro-card';
|
import ProCard from '@ant-design/pro-card';
|
||||||
import FileDown from '@/utils/Download';
|
import FileDown from '@/utils/Download';
|
||||||
import { getDownloadFileUrl, getFileListByBid } from '@/utils/DownloadUtils';
|
import { getFileListByBid, useDownLoadUrl } from '@/utils/DownloadUtils';
|
||||||
|
|
||||||
interface PreviewJgtzsModalProps {
|
interface PreviewJgtzsModalProps {
|
||||||
fileId: string,
|
fileId: string,
|
||||||
@ -13,6 +13,7 @@ interface PreviewJgtzsModalProps {
|
|||||||
|
|
||||||
const PreviewJgtzsModal: React.FC<PreviewJgtzsModalProps> = (props) => {
|
const PreviewJgtzsModal: React.FC<PreviewJgtzsModalProps> = (props) => {
|
||||||
const { fileId, modalVisible, onCancel } = props
|
const { fileId, modalVisible, onCancel } = props
|
||||||
|
const [url] = useDownLoadUrl(fileId);
|
||||||
const [page, setPage] = useState<number>(1);
|
const [page, setPage] = useState<number>(1);
|
||||||
const [pages, setPages] = useState<number>(0);
|
const [pages, setPages] = useState<number>(0);
|
||||||
const [fileExist, setFileExist] = useState<string>("0");//0:未验证,1:验证后有,2:验证后没有
|
const [fileExist, setFileExist] = useState<string>("0");//0:未验证,1:验证后有,2:验证后没有
|
||||||
@ -79,10 +80,10 @@ const PreviewJgtzsModal: React.FC<PreviewJgtzsModalProps> = (props) => {
|
|||||||
>
|
>
|
||||||
{fileExist == "0" ? (
|
{fileExist == "0" ? (
|
||||||
<div />
|
<div />
|
||||||
) : fileExist == "1" ? (
|
) : fileExist == "1" ? url != "" && (
|
||||||
<>
|
<>
|
||||||
<PDF
|
<PDF
|
||||||
file={getDownloadFileUrl(fileId)}
|
file={url}
|
||||||
scale={1.6}
|
scale={1.6}
|
||||||
onDocumentComplete={onDocumentComplete}
|
onDocumentComplete={onDocumentComplete}
|
||||||
page={page}
|
page={page}
|
||||||
|
@ -2,11 +2,12 @@
|
|||||||
* @Author: zhoujianlong
|
* @Author: zhoujianlong
|
||||||
* @Date: 2022-03-03 09:06:36
|
* @Date: 2022-03-03 09:06:36
|
||||||
* @Last Modified by: zhoujianlong
|
* @Last Modified by: zhoujianlong
|
||||||
* @Last Modified time: 2022-05-18 17:23:26
|
* @Last Modified time: 2022-11-21 11:04:43
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { getDownloadSecretKey, getFilelist, getFilelistBySecond } from "@/services/download_";
|
import { getDownloadSecretKey, getFilelist, getFilelistBySecond } from "@/services/download_";
|
||||||
import { message } from "antd";
|
import { message } from "antd";
|
||||||
|
import { Dispatch, SetStateAction, useEffect, useRef, useState } from "react";
|
||||||
import { isEmpty, isNotEmpty } from "./CommonUtils";
|
import { isEmpty, isNotEmpty } from "./CommonUtils";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -149,6 +150,37 @@ export const getDownloadFileUrl = async (objectId: string) => {
|
|||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* objectId获取文件下载链接
|
||||||
|
* @param objectId
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export const useDownLoadUrl = (objectId: string): string[] => {
|
||||||
|
const [url, setUrl] = useState<string>("");
|
||||||
|
useEffect(() => {
|
||||||
|
const getFileUrl = async () => {
|
||||||
|
console.log("objectId", objectId);
|
||||||
|
await getFilelist([objectId]).then(async res => {
|
||||||
|
if (res?.success && res?.data?.length > 0) {
|
||||||
|
const keyRes = await getDownloadSecretKey({ fileId: res?.data[res?.data?.length - 1].fileId });//获取key
|
||||||
|
let url = downloadAttachmentPath + '?fileId=' + res?.data[res?.data?.length - 1].fileId + '&documentSecretKey=' + keyRes?.data;
|
||||||
|
setUrl(url);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (isNotEmpty(objectId)) {
|
||||||
|
if (checkObjectId(objectId)) {//判断3.0 objectId
|
||||||
|
getFileUrl();
|
||||||
|
} else {
|
||||||
|
let url = downloadPathBySecond + '?id=' + objectId + '&p=' + getTimeStamp();
|
||||||
|
setUrl(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}, [objectId])
|
||||||
|
|
||||||
|
return [url];
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 获取文件列表
|
* 获取文件列表
|
||||||
* @param objectId
|
* @param objectId
|
||||||
|
@ -3,7 +3,7 @@ import { Modal, Button } from 'antd';
|
|||||||
import PDF from 'react-pdf-js';
|
import PDF from 'react-pdf-js';
|
||||||
import ProCard from '@ant-design/pro-card';
|
import ProCard from '@ant-design/pro-card';
|
||||||
import FileDown from '@/utils/Download';
|
import FileDown from '@/utils/Download';
|
||||||
import { getDownloadFileUrl, getFileListByBid } from '../DownloadUtils';
|
import { getFileListByBid, useDownLoadUrl } from '../DownloadUtils';
|
||||||
/**
|
/**
|
||||||
* Pdf Modal弹窗公共组件
|
* Pdf Modal弹窗公共组件
|
||||||
* 2021.8.25 zhoujianlong 根据定标结果通知书的弹出窗口改造初始版本,增加备注
|
* 2021.8.25 zhoujianlong 根据定标结果通知书的弹出窗口改造初始版本,增加备注
|
||||||
@ -17,6 +17,7 @@ interface PdfModalProps {
|
|||||||
|
|
||||||
const PdfModal: React.FC<PdfModalProps> = (props) => {
|
const PdfModal: React.FC<PdfModalProps> = (props) => {
|
||||||
const { fileId, downLoadFileName, modalVisible, onCancel } = props;
|
const { fileId, downLoadFileName, modalVisible, onCancel } = props;
|
||||||
|
const [url] = useDownLoadUrl(fileId);
|
||||||
const [page, setPage] = useState<number>(1); //页码
|
const [page, setPage] = useState<number>(1); //页码
|
||||||
const [pages, setPages] = useState<number>(0); //总页数
|
const [pages, setPages] = useState<number>(0); //总页数
|
||||||
const [fileExist, setFileExist] = useState<string>('0'); //0:未验证,1:验证后有,2:验证后没有
|
const [fileExist, setFileExist] = useState<string>('0'); //0:未验证,1:验证后有,2:验证后没有
|
||||||
@ -93,10 +94,10 @@ const PdfModal: React.FC<PdfModalProps> = (props) => {
|
|||||||
<ProCard layout="center" direction="column" ghost>
|
<ProCard layout="center" direction="column" ghost>
|
||||||
{fileExist == '0' ? (
|
{fileExist == '0' ? (
|
||||||
<div />
|
<div />
|
||||||
) : fileExist == '1' ? (
|
) : fileExist == '1' ? url != "" && (
|
||||||
<>
|
<>
|
||||||
<PDF
|
<PDF
|
||||||
file={getDownloadFileUrl(fileId)}
|
file={url}
|
||||||
scale={1.6}
|
scale={1.6}
|
||||||
onDocumentComplete={onDocumentComplete}
|
onDocumentComplete={onDocumentComplete}
|
||||||
page={page}
|
page={page}
|
||||||
|
Reference in New Issue
Block a user