소스 검색

pic download

begmoon 1 년 전
부모
커밋
31b7fdbd7f
3개의 변경된 파일57개의 추가작업 그리고 1개의 파일을 삭제
  1. 6 0
      src/api.js
  2. 44 0
      src/views/data/index.vue
  3. 7 1
      src/views/match/addChampionSay.vue

+ 6 - 0
src/api.js

@@ -466,4 +466,10 @@ export default {
         return axios.get(`${baseURL}/api/admin/article/spider`, { params: params })
     },
 
+    //下载排名数据图片
+    getDataPic: params => {
+        return axios.get(`${baseURL}/api/admin/player/record/downloadimage`, { params: params })
+    },
+
+
 }

+ 44 - 0
src/views/data/index.vue

@@ -85,6 +85,11 @@
                         <el-button icon="el-icon-download" type="primary" @click="downloadAll" size="mini">导出全部</el-button>
                     </el-form-item>
                 </el-col>
+                <el-col :span="3">
+                    <el-form-item style="margin-left:10px;" label-width="10">
+                        <el-button icon="el-icon-download" type="primary" @click="downloadPic" size="mini">下载图片</el-button>
+                    </el-form-item>
+                </el-col>
                 <!-- <el-col :span="3">
                     <el-form-item style="margin-left:10px;" label-width="10">
                         <el-button icon="el-icon-plus" type="warning" @click="autoCompleteData" size="mini">补全数据</el-button>
@@ -456,7 +461,46 @@ export default {
                 this.startDownload();
             })
         },
+
+        downloadPic(){
+            this.loading = true;
+
+            this.$api.getDataPic(this.queryParams).then((res)=>{
+                this.loading = false;
+                console.log(res.data)
+                var elink = document.createElement('a');
+                let blob=new Blob([res.data], {type: 'image/png'});
+                let objUrl=URL.createObjectURL(blob);
+                let file_name= decodeURIComponent(res.headers['content-disposition'].split('=')[1]);
+                console.log(file_name)
+                
+                elink.download = "12.png";// this.queryParams.stock_date + gname;
+                elink.style.display = 'none';                
+                elink.href = objUrl;
+                document.body.appendChild(elink);
+                elink.click();
+                document.body.removeChild(elink);  
+                
+            })
+        },
         
+        ways(blob, suffix,res) {
+            let elink = document.createElement("a");   // 创建一个&lt;a&gt;标签
+            elink.style.display = "none";                       // 隐藏标签
+            elink.href = window.URL.createObjectURL(blob);      // 配置href
+            // 获取后端返回的响应头中的名称
+            // let filename = res.headers["content-disposition"]; 
+            // let newFilename = filename.split(';')[1].split('=')[1];
+            //自定义名称
+            // let newFilename = "样例文件" + new Date().getTime() + suffix; //自定义名字
+            // let newFilename = decodeURIComponent(res.headers["content-disposition"].split(';')[1].split('=')[1])
+            // newFilename = decodeURIComponent('11.png');
+            elink.download = '11.png';
+            elink.click();
+            URL.revokeObjectURL(elink.href);   // 释放URL 对象(弹出框进行下载)
+            document.body.removeChild(elink);  // 移除&lt;a&gt;标签
+        },
+
         del(row) {
         this.$confirm("确定删除吗?", "提示", {
             type: "warning",

+ 7 - 1
src/views/match/addChampionSay.vue

@@ -36,9 +36,15 @@
     margin-bottom: 100px;
     width: 70%;
   }
+  
 }
 
-
+.w-e-text{
+    font-size: 16px;
+    img{
+      max-width: 50% !important;
+    }
+}
 </style>
 <template>
   <section class="content">