|
@@ -34,53 +34,7 @@ export const JGPrintTag = function (html, width, height, data) {
|
|
|
LODOP.SET_PRINT_PAGESIZE(1, width, height)
|
|
|
LODOP.PRINT()
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
export const demoGetBASE64 = function (dataArray) {
|
|
|
var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
|
|
|
var strData = ''
|
|
@@ -94,30 +48,6 @@ export const demoGetBASE64 = function (dataArray) {
|
|
|
}
|
|
|
return strData
|
|
|
}
|
|
|
-
|
|
|
-export const demoDownloadPDF = function (data) {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- var arrybuffer = true
|
|
|
- if (typeof Uint8Array !== 'undefined') {
|
|
|
- if (arrybuffer) var dataArray = new Uint8Array(data); else {
|
|
|
- var dataArray = new Uint8Array(data.length)
|
|
|
- for (var i = 0; i < dataArray.length; i++) { dataArray[i] = data.charCodeAt(i) }
|
|
|
- }
|
|
|
- }
|
|
|
- return demoGetBASE64(dataArray)
|
|
|
-}
|
|
|
|
|
|
|
|
|
export const downloadExcel = function (data, fileName) {
|
|
@@ -140,42 +70,6 @@ export const downloadExcel = function (data, fileName) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- *printerType: 打印机类型
|
|
|
- *type: 打印预览,打印,导出
|
|
|
- *url: 数据请求接口
|
|
|
- *params: 请求参数
|
|
|
- *fileName: 导出文件名称
|
|
|
- *callback: 回调函数
|
|
|
-*/
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
*printerType: 打印机类型
|
|
|
*type: 打印预览,打印,导出
|
|
@@ -218,6 +112,34 @@ export const hdPrint = function (printerType, type, url, params, fileName, callb
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+export const blobToBaseByPdf = function(data,callback){
|
|
|
+ const reader = new FileReader()
|
|
|
+ reader.readAsDataURL(new Blob([data], { type: 'application/pdf' }))
|
|
|
+ reader.addEventListener('load', () => {
|
|
|
+ callback(reader.result)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+ export const dataURItoBlobByPdf = function (data,callback) {
|
|
|
+ let byteLen = 0
|
|
|
+ for(let i=0;i<data.length;i++){
|
|
|
+ let byteString = atob(data[i]);
|
|
|
+ byteLen = byteLen + byteString.length
|
|
|
+ }
|
|
|
+ let arrayBuffer = new ArrayBuffer(byteLen);
|
|
|
+ let intArray = new Uint8Array(arrayBuffer);
|
|
|
+
|
|
|
+ for(let i=0;i<data.length;i++){
|
|
|
+ let byteString = atob(data[i]);
|
|
|
+ for (let i = 0; i < byteLen; i++) {
|
|
|
+ intArray[i] = byteString.charCodeAt(i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log(intArray)
|
|
|
+ blobToBaseByPdf(intArray,callback)
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
export const jGPrint = function (data, type, printerType) {
|
|
|
if (!data) {
|
|
@@ -248,13 +170,19 @@ export const jGPrint = function (data, type, printerType) {
|
|
|
LODOP.SET_SHOW_MODE('HIDE_PAPER_BOARD', 1)
|
|
|
|
|
|
if (type == 'preview') {
|
|
|
- const reader = new FileReader()
|
|
|
- reader.readAsDataURL(new Blob([data], { type: 'application/pdf' }))
|
|
|
- reader.addEventListener('load', () => {
|
|
|
- LODOP.ADD_PRINT_PDF(0, 0, '100%', '100%', reader.result.split('base64,')[1])
|
|
|
- LODOP.SET_PRINT_PAGESIZE(3,2090,65,"");
|
|
|
- LODOP.PREVIEW()
|
|
|
- })
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ LODOP.ADD_PRINT_PDF(0, 0, '100%', '100%', data.data[0])
|
|
|
+ LODOP.SET_PRINT_PAGESIZE(3,2090,65,"");
|
|
|
+ LODOP.PREVIEW()
|
|
|
} else if (type == 'print') {
|
|
|
const dlen = data.data.length
|
|
|
for(let i=0;i<dlen;i++){
|