zhangjie 1 年之前
父节点
当前提交
187f8babe0
共有 2 个文件被更改,包括 22 次插入23 次删除
  1. 19 2
      src/modules/admin/views/ScanLogManage.vue
  2. 3 21
      src/plugins/utils.js

+ 19 - 2
src/modules/admin/views/ScanLogManage.vue

@@ -16,6 +16,13 @@
             ></el-option>
           </el-select>
         </el-form-item>
+        <el-form-item>
+          <el-input
+            v-model.trim="filter.loginName"
+            placeholder="扫描账号模糊查询"
+            clearable
+          ></el-input>
+        </el-form-item>
 
         <el-form-item label-width="0px">
           <el-button type="primary" @click="toPage(1)">查询</el-button>
@@ -31,6 +38,11 @@
           label="学校Code"
           width="200"
         ></el-table-column>
+        <el-table-column
+          prop="loginName"
+          label="扫描账号"
+          width="120"
+        ></el-table-column>
         <el-table-column
           prop="deviceCode"
           label="设备号"
@@ -80,6 +92,7 @@
 </template>
 
 <script>
+import { download } from "@/plugins/utils";
 import { schoolList, scanLogListPage } from "../api";
 
 export default {
@@ -88,6 +101,7 @@ export default {
     return {
       filter: {
         schoolCode: null,
+        loginName: "",
       },
       current: 1,
       size: this.GLOBAL.pageSize,
@@ -120,8 +134,11 @@ export default {
       this.current = page;
       this.getList();
     },
-    toView(row) {
-      window.open(row.pathUrl);
+    async toView(row) {
+      const res = await download({ url: row.pathUrl });
+      const win = window.open("", "_blank");
+      win.document.write(`<pre>${res}</pre>`);
+      win.document.close();
     },
   },
 };

+ 3 - 21
src/plugins/utils.js

@@ -57,13 +57,14 @@ export function download(option) {
     data: "",
     fileName: "",
     header: "",
+    responseType: "",
   };
   let opt = objAssign(defOpt, option);
 
   return new Promise((resolve, reject) => {
     let xhr = new XMLHttpRequest();
     xhr.open(opt.type.toUpperCase(), opt.url, true);
-    xhr.responseType = "blob";
+    if (opt.responseType) xhr.responseType = opt.responseType;
 
     // header set
     if (opt.header && objTypeOf(opt.header) === "object") {
@@ -74,26 +75,7 @@ export function download(option) {
 
     xhr.onload = function () {
       if (this.readyState === 4 && this.status === 200) {
-        if (this.response.size < 1024) {
-          reject("文件不存在!");
-          return;
-        }
-
-        var blob = this.response;
-        let pdfUrl = "";
-        let uRl = window.URL || window.webkitURL;
-        if (uRl && uRl.createObjectURL) {
-          pdfUrl = uRl.createObjectURL(blob);
-        } else {
-          reject("浏览器不兼容!");
-        }
-        let a = document.createElement("a");
-        a.download = opt.fileName;
-        a.href = pdfUrl;
-        document.body.appendChild(a);
-        a.click();
-        a.parentNode.removeChild(a);
-        resolve(true);
+        resolve(this.response);
       } else {
         reject("请求错误!");
       }