浏览代码

download pdf

amenpunk 2 年之前
父节点
当前提交
28df2d4180
共有 1 个文件被更改,包括 15 次插入2 次删除
  1. 15 2
      src/Pages/Resultados.jsx

+ 15 - 2
src/Pages/Resultados.jsx

40
     setNumPages(numPages);
40
     setNumPages(numPages);
41
   }
41
   }
42
 
42
 
43
+  const Download = () => {
44
+    let url = `/report/cleaverResult/${props.id}?output=pdf`
45
+    let rest = new Service(url);
46
+
47
+    rest
48
+      .getBlob(props.token)
49
+      .then(blob => {
50
+        var file = window.URL.createObjectURL(blob.data);
51
+        window.location.assign(file);
52
+      })
53
+      .catch(error => console.log({ error }))
54
+  }
55
+
43
   const [progress, setProgress] = useState(10);
56
   const [progress, setProgress] = useState(10);
44
 
57
 
45
   if(!pdf){
58
   if(!pdf){
85
           <Button 
98
           <Button 
86
             className="btnmain"
99
             className="btnmain"
87
             variant="contained" 
100
             variant="contained" 
88
-            onClick={() => console.log('download')} >
101
+            onClick={Download} >
89
             <DownloadIcon/>
102
             <DownloadIcon/>
90
           </Button>
103
           </Button>
91
         </div>
104
         </div>
139
           <Paper 
152
           <Paper 
140
             elevation={2} 
153
             elevation={2} 
141
             sx={{ mb: 2, padding: 2, height: '100%', minHeight: '95vh', boxShadow: 'none !important' }}>
154
             sx={{ mb: 2, padding: 2, height: '100%', minHeight: '95vh', boxShadow: 'none !important' }}>
142
-            <MyDocument pdf={pdf} />
155
+            <MyDocument token={auth.token} id={id} pdf={pdf} />
143
           </Paper>
156
           </Paper>
144
         </Box>
157
         </Box>
145
       </div>
158
       </div>