diff --git a/src/api/checkCode/index.ts b/src/api/checkCode/index.ts index 0e1ce24..40f7e01 100644 --- a/src/api/checkCode/index.ts +++ b/src/api/checkCode/index.ts @@ -26,4 +26,20 @@ export function fetchCodeDetail(query?: Object) { method: 'get', params: query, }); +} +// 执行条码 +export function fetchCodeExec(query?: Object) { + return request({ + url: '/zyreq/exec', + method: 'get', + params: query, + }); +} +// 获取申请单主表信息 +export function fetchCodeReqmain(query?: Object) { + return request({ + url: 'zyreq/reqmain', + method: 'get', + params: query, + }); } \ No newline at end of file diff --git a/src/plugins/download.js b/src/plugins/download.js index 1a89efd..a4a0377 100644 --- a/src/plugins/download.js +++ b/src/plugins/download.js @@ -1,11 +1,21 @@ import axios from 'axios' -import { ElLoading, ElMessage } from 'element-plus' -import { saveAs } from 'file-saver' -import { getToken } from '@/utils/auth' +import { + ElLoading, + ElMessage +} from 'element-plus' +import { + saveAs +} from 'file-saver' +import { + getToken +} from '@/utils/auth' import errorCode from '@/utils/errorCode' -import { blobValidate } from '@/utils/ruoyi' +import { + blobValidate +} from '@/utils/ruoyi' -const baseURL = import.meta.env.VITE_APP_BASE_API +const baseURL = + import.meta.env.VITE_APP_BASE_API let downloadLoadingInstance; export default { @@ -15,7 +25,14 @@ export default { method: 'get', url: url, responseType: 'blob', - headers: { 'Authorization': 'Bearer ' + getToken() } + headers: { + 'Authorization': 'Bearer ' + getToken() + }, + onDownloadProgress: (progressEvent) => { + console.log(progressEvent) + //progressEvent.loaded 下载文件的当前大小 + //progressEvent.total 下载文件的总大小 如果后端没有返回 请让他加上 + } }).then((res) => { const isBlob = blobValidate(res.data); if (isBlob) { @@ -32,7 +49,9 @@ export default { method: 'get', url: url, responseType: 'blob', - headers: { 'Authorization': 'Bearer ' + getToken() } + headers: { + 'Authorization': 'Bearer ' + getToken() + } }).then((res) => { const isBlob = blobValidate(res.data); if (isBlob) { @@ -45,16 +64,23 @@ export default { }, zip(url, name) { var url = baseURL + url - downloadLoadingInstance = ElLoading.service({ text: "正在下载数据,请稍候", background: "rgba(0, 0, 0, 0.7)", }) + downloadLoadingInstance = ElLoading.service({ + text: "正在下载数据,请稍候", + background: "rgba(0, 0, 0, 0.7)", + }) axios({ method: 'get', url: url, responseType: 'blob', - headers: { 'Authorization': 'Bearer ' + getToken() } + headers: { + 'Authorization': 'Bearer ' + getToken() + } }).then((res) => { const isBlob = blobValidate(res.data); if (isBlob) { - const blob = new Blob([res.data], { type: 'application/zip' }) + const blob = new Blob([res.data], { + type: 'application/zip' + }) this.saveAs(blob, name) } else { this.printErrMsg(res.data); @@ -75,5 +101,4 @@ export default { const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default'] ElMessage.error(errMsg); } -} - +} \ No newline at end of file diff --git a/src/utils/hiprintPrinter.ts b/src/utils/hiprintPrinter.ts index a752904..98d3805 100644 --- a/src/utils/hiprintPrinter.ts +++ b/src/utils/hiprintPrinter.ts @@ -2,7 +2,9 @@ import { io, Socket } from "socket.io-client"; import { ElMessage, ElMessageBox } from 'element-plus' import { usePrintStore } from '@/store/modules/printStore' - +import { onUnmounted } from "vue" +// @ts-ignore +import Download from '@/plugins/download'; // ... 类型定义 ... type PrinterInfo = { name: string; @@ -61,7 +63,7 @@ function initSocket(onPrinterUpdate?: OnPrinterUpdate) { socket.on("connect_error", (err: Error) => { console.log('连接错误', err); ElMessageBox.alert( - `连接失败!
请确保目标服务器已 下载 并运行 打印服务!`, + `连接失败!
请确保目标服务器已 下载 并运行 打印服务!`, "客户端未连接", { dangerouslyUseHTMLString: true, @@ -70,8 +72,19 @@ function initSocket(onPrinterUpdate?: OnPrinterUpdate) { printStore.setConnected(false); socket?.close(); }); + + } + +const downExe = () => { + // 下载逻辑实现 + console.log('开始下载打印服务'); + Download.name('hiprint_win_x64-1.0.13.exe') +}; + +// 挂载到window,使其能被全局访问 +(window as any).downExe = downExe function silentPrintPdf(url: string, printOptions?: object) { const printStore = usePrintStore(); if (!url) { @@ -143,4 +156,10 @@ export const HiprintPrinter = { const printStore = usePrintStore(); return printStore.defaultPrinter; }, -}; \ No newline at end of file +}; + +onUnmounted(() => { + if ('downExe' in window) { + delete (window as any).downExe; + } +}); \ No newline at end of file diff --git a/src/views/checkCode/index.vue b/src/views/checkCode/index.vue index 5468e7b..f9c081b 100644 --- a/src/views/checkCode/index.vue +++ b/src/views/checkCode/index.vue @@ -4,7 +4,7 @@ - @@ -15,12 +15,12 @@ - + - + @@ -54,10 +54,10 @@ 打印 - 采样登记 + 采样登记 - 送检登记 + 送检登记 报告查询 @@ -76,7 +76,7 @@ + @row-click="rowHandle" @selection-change="selectionChange"> @@ -87,7 +87,7 @@ {{ formatDict(row.brly, 'PT') }}