shish 2 years ago
parent
commit
c41a19b02d
1 changed files with 21 additions and 3 deletions
  1. 21 3
      ghs/src/views/order/list.vue

+ 21 - 3
ghs/src/views/order/list.vue

@@ -62,8 +62,8 @@
         <el-button v-if="scope.row.status != 1 && scope.row.status != 5" @click.stop="printOrder(scope.row)" size="small" type="primary">打A4</el-button>
         <el-button v-else disabled size="small">打A4</el-button>
         <el-button @click.stop="detailShowFn(scope.row)" size="small" type="success">详情</el-button>
-        <el-button @click.stop="detailShowFn(scope.row)" size="small" type="primary">下载</el-button>
-        <el-button @click.stop="detailShowFn(scope.row)" size="small" type="primary">全部下载</el-button>
+        <el-button @click.stop="down(scope.row)" size="small" type="primary">下载</el-button>
+        <el-button @click.stop="allDown(scope.row)" size="small" type="primary">全部下载</el-button>
       </template>
 
       <template #slot-order-book="{scope}">
@@ -243,7 +243,25 @@ export default {
         this.$refs.selOrder.init();
       });
     },
-    //获取订单详情
+    async down(){
+     // 获取图片对象和画布对象
+     const imgUrl = 'https://api.shop.hzghd.com/image.png'
+     const response = await fetch(imgUrl)
+     const blob = await response.blob()
+     // 创建下载链接
+     const url = window.URL.createObjectURL(blob)
+     const link = document.createElement('a')
+     link.href = url
+     link.download = 'image.png'
+     document.body.appendChild(link)
+     link.click()
+     document.body.removeChild(link)
+     // 释放 Blob URL
+     window.URL.revokeObjectURL(url)
+    },
+    allDown(){
+
+    },
     detailShowFn(item) {
       this.optionData = item;
       setTimeout(() => {