Renxy il y a 2 ans
Parent
commit
7606241d24
2 fichiers modifiés avec 6 ajouts et 3 suppressions
  1. 5 2
      src/components/FileViewer/index.js
  2. 1 1
      src/pages/Detail/FormAndFilesNode.js

+ 5 - 2
src/components/FileViewer/index.js

@@ -4,6 +4,8 @@ import { memo } from 'react';
 
 const FileViewerModal = ({ data, visible, onCancel, downloadFile }) => {
   const type = data?.url?.split('.')[data?.url?.split('.').length - 1];
+  console.log(data?.url, type);
+
   return (
     <Modal
       destroyOnClose
@@ -18,8 +20,9 @@ const FileViewerModal = ({ data, visible, onCancel, downloadFile }) => {
         key={data?.name}
         fileType={type}
         filePath={data?.url}
-        onError={() => downloadFile(data)}
-        errorComponent={console.log('出现错误')}
+        // onError={() => downloadFile(data)}
+        onError={e => console.error(e)}
+        errorComponent={<div>文件加载错误</div>}
         unsupportedComponent={<div>不支持的文件格式</div>}
       />
     </Modal>

+ 1 - 1
src/pages/Detail/FormAndFilesNode.js

@@ -59,8 +59,8 @@ const FormAndFilesNode = ({ title, formData, excelFileData, loading, downloadFil
         <a
           style={{ marginLeft: 10 }}
           onClick={() => {
-            setExportData(record);
             setExcelFileVisible(true);
+            setExportData(record);
           }}
         >
           预览