diff --git a/src/api/itextpdf/orderPrint.js b/src/api/itextpdf/orderPrint.js new file mode 100644 index 00000000..c7b4ed60 --- /dev/null +++ b/src/api/itextpdf/orderPrint.js @@ -0,0 +1,22 @@ + +import axios from "@/utils/request"; + + +//---------打印订单 +export function inspectionOrderPDFFromTemplateFile(query) { + return axios({ + url: "/udiwms/pdf/template/inspection/order/file", + method: "post", + data: query, + }); +} + +export function orderPDFFromTemplateFile(query) { + return axios({ + url: "/udiwms/pdf/template/order/file", + method: "post", + data: query, + headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}, + responseType: 'arraybuffer', //一定要设置响应类型,否则页面会是空白pdf + }); +} diff --git a/src/views/inout/IoAuditedOrder.vue b/src/views/inout/IoAuditedOrder.vue index 9c35bee3..6a326eee 100644 --- a/src/views/inout/IoAuditedOrder.vue +++ b/src/views/inout/IoAuditedOrder.vue @@ -127,7 +127,7 @@ 打印 @@ -340,6 +340,7 @@ import {selectSysParamByKey} from "@/api/param/systemParamConfig"; import {getResultDetailList} from "@/api/inout/orderDetailResult"; import {getCodeDetailList} from "@/api/inout/orderDetailCode"; import {getCodeList} from "@/api/inout/code"; +import {inspectionOrderPDFFromTemplateFile,orderPDFFromTemplateFile} from "@/api/itextpdf/orderPrint" const formJson = { @@ -686,6 +687,40 @@ export default { }, editCodeDialog(row) { + }, + printOrder(row) { + let tQuery = { + action: row.action, + moduleId: 1, + } + this.loading = true; + inspectionOrderPDFFromTemplateFile(tQuery).then((response) => { + if (response.code === 20000) { + tQuery = { + templateId: response.data, + orderIdFk: row.billNo, + action: row.action, + } + orderPDFFromTemplateFile(tQuery).then((response) => { + //将pdf文件转换为url。 + const binaryData = []; + binaryData.push(response); + //获取blob链接。 + let url = window.URL.createObjectURL( + new Blob(binaryData, {type: "application/pdf"}) + ); + this.loading = false; + window.open(url);//打开新标签页,预览pdf。 + }).catch(() => { + this.loading = false; + }); + } else { + this.loading = false; + this.$message.error(response.message); + } + }).catch(() => { + this.loading = false; + }); }, onResultReset() { this.resultQuery = { diff --git a/src/views/inout/IoCheckSuccessOrder.vue b/src/views/inout/IoCheckSuccessOrder.vue index f3d689d1..b68d7e03 100644 --- a/src/views/inout/IoCheckSuccessOrder.vue +++ b/src/views/inout/IoCheckSuccessOrder.vue @@ -128,7 +128,7 @@ 打印 @@ -454,6 +454,8 @@ import {getBizDetailList} from "@/api/inout/orderDetailBiz"; import {getCodeDetailList} from "@/api/inout/orderDetailCode"; import {getCodeList} from "@/api/inout/code"; import AcceptOrder from "@/views/inout/DialogReviewOrder"; +import {inspectionOrderPDFFromTemplateFile,orderPDFFromTemplateFile} from "@/api/itextpdf/orderPrint" + const formJson = { site_id: "", @@ -623,6 +625,40 @@ export default { this.filterQuery.action = null; this.getBusType(); }, + printOrder(row) { + let tQuery = { + action: row.action, + moduleId: 1, + } + this.loading = true; + inspectionOrderPDFFromTemplateFile(tQuery).then((response) => { + if (response.code === 20000) { + tQuery = { + templateId: response.data, + orderIdFk: row.billNo, + action: row.action, + } + orderPDFFromTemplateFile(tQuery).then((response) => { + //将pdf文件转换为url。 + const binaryData = []; + binaryData.push(response); + //获取blob链接。 + let url = window.URL.createObjectURL( + new Blob(binaryData, {type: "application/pdf"}) + ); + this.loading = false; + window.open(url);//打开新标签页,预览pdf。 + }).catch(() => { + this.loading = false; + }); + } else { + this.loading = false; + this.$message.error(response.message); + } + }).catch(() => { + this.loading = false; + }); + }, getBusType() { let query = { code: this.filterQuery.invCode,