LuoDLeo пре 7 месеци
родитељ
комит
1d0c9eaead
2 измењених фајлова са 40 додато и 1 уклоњено
  1. 11 0
      src/api/facility/facility.js
  2. 29 1
      src/views/facility/facility.vue

+ 11 - 0
src/api/facility/facility.js

@@ -48,3 +48,14 @@ export const update = (row) => {
   })
 }
 
+export const buildQrcode = (id) => {
+  return request({
+    url: '/api/facility/buildQrcode',
+    method: 'get',
+    params: {
+      id
+    },
+    responseType: "blob"
+  })
+}
+

+ 29 - 1
src/views/facility/facility.vue

@@ -38,6 +38,13 @@
                    size="small"
                    @click="handleViewCargoWay(scope.row)"
         >查看设备货道</el-button>
+        <el-button type="text"
+                   size="small"
+                   icon="el-icon-download"
+                   plain
+                   class="none-border"
+                   @click="handleGenerareQrcode(scope.row)"
+        >下载设备码</el-button>
       </template>
     </avue-crud>
 
@@ -52,7 +59,7 @@
 </template>
 
 <script>
-  import {getList, getDetail, add, update, remove} from "@/api/facility/facility";
+  import {getList, getDetail, add, update, remove, buildQrcode} from "@/api/facility/facility";
   import {mapGetters} from "vuex";
   import CargoWay from "@/views/business/facilitycargoway.vue";
 
@@ -336,6 +343,27 @@
       handleViewCargoWay(row) {
         this.facilityId = row.id;
         this.cargowayBox = true;
+      },
+      handleGenerareQrcode(row) {
+        buildQrcode(row.id).then((res) => {
+          var fileName = row.facilityNo+'.jpg';
+          let blob = new Blob([res.data]); //res为从后台返回的数据
+          if (!fileName) {
+            fileName = res.headers['content-disposition'].split('filename=').pop();
+          }
+          if ('msSaveOrOpenBlob' in navigator) {
+            window.navigator.msSaveOrOpenBlob(blob, fileName);
+          } else {
+            const elink = document.createElement('a');
+            elink.download = fileName;
+            elink.style.display = 'none';
+            elink.href = URL.createObjectURL(blob);
+            document.body.appendChild(elink);
+            elink.click();
+            URL.revokeObjectURL(elink.href);
+            document.body.removeChild(elink);
+          }
+        })
       }
     }
   };