emis-frontend/src/views/emis/EmisBaseTools/TanexPrinterPanel.vue

705 lines
21 KiB
Vue
Raw Normal View History

2024-05-24 05:35:58 +00:00
<template>
<div>
<!-- 打印机状态 -->
<!-- style="padding:5px 0px;text-align: right;position: fixed;top: 150px;right: 10px; z-index: 9999;" -->
<div >
<div style="display: inline-flex;">
<div v-if="printerStatus==0" style="display: inline-flex;">
<el-tag type="danger" >{{ printerStatusMessage }}</el-tag>
</div>
<div v-if="printerStatus==1" style="display: inline-flex;">
2024-06-21 17:54:53 +00:00
<div v-if="isShowTpl==1" style="font-size: 12px; line-height: 28px;font-weight: 600;">模板:</div>
2024-05-30 12:39:28 +00:00
<div v-if="isShowTpl==1" style="width: 150px;">
2024-05-29 08:18:45 +00:00
<el-select v-model="selTplCode" size="mini" placeholder="选择打印模板" clearable filterable>
2024-05-30 12:39:28 +00:00
<template slot="prefix">
<span style="padding: 5px;line-height: 28px;font-size: 16px;color: rgb(111 111 111);cursor: pointer;" @click="refreshPrintTpl()">
<i class="el-icon-refresh"></i>
</span>
</template>
<el-option
2024-06-04 04:50:10 +00:00
v-for="item in printTplList"
2024-05-30 12:39:28 +00:00
:key="item.tplCode"
:label="item.tplName"
:value="item.tplCode"
/>
2024-05-24 05:35:58 +00:00
</el-select>
</div>
2024-05-30 12:39:28 +00:00
<div v-if="selTplCode=='TAN-GC-130' && isShowSubBillRange" class="subBillRange" style="display: inline-flex;font-size: 12px; line-height: 28px; font-weight: 600;">
<span >子单范围:
2024-05-29 08:18:45 +00:00
<el-input size="mini" style="width:40px" v-model="subBillStart" type="text" maxlength="4" ></el-input>
-
<el-input size="mini" style="width:40px" v-model="subBillEnd" type="text" maxlength="4" ></el-input>
</span>
</div>
2024-06-21 17:54:53 +00:00
<div v-if="isShowPinters==1" style="font-size: 12px;line-height: 28px;font-weight: 600;">选择打印机:</div>
2024-05-30 12:39:28 +00:00
<div v-if="isShowPinters==1" style="width: 150px;">
<el-select v-model="selPrinterName" size="mini" placeholder="打印机" clearable filterable>
<el-option
v-for="item in printerList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</div>
</div>
<div v-if="printerStatus==1" style="display: inline-flex;">
2024-05-31 00:36:52 +00:00
<!-- <span style="color: green;font-weight: 600;font-size:13px;">【Printer Online】</span> -->
<span style="color: #b12e29;font-size:23px;" class="icon iconfont icon-printer" title="Printer Online"></span>
2024-05-24 05:35:58 +00:00
</div>
<div v-if="printerStatus==0" style="display: inline-flex;">
2024-05-31 10:12:59 +00:00
<a :href="printerDownUrl" style="color: blue;font-weight: 600;font-size:13px;text-decoration: underline">下载打印组件</a>
2024-05-24 05:35:58 +00:00
</div>
</div>
</div>
2024-06-29 03:34:07 +00:00
<el-dialog :key="resetRefreshId+'.dlg'" class="printPreDialog" title="预览" :resizable="true" :visible.sync="openPdfView" width="90%" :close-on-click-modal="false" :destroy-on-close="true" v-dialogDrag append-to-body @close="handleClose">
2024-05-31 10:12:59 +00:00
<div style="height:100%;width:100%;overflow: auto;">
2024-06-21 17:54:53 +00:00
<PdfViewer :key="resetRefreshId+'.pdf'" ref="pdfViewer" v-if="openPdfView&&!isInitA4" :pdfList="pdfList" :isLoadComplete="isLoadComplete" @onPrint="onPdfViewPrint" ></PdfViewer>
<A4Viewer :key="resetRefreshId+'.pdf'" ref="pdfViewer" v-if="openPdfView&&isInitA4" :pdfList="pdfList" :isLoadComplete="isLoadComplete" ></A4Viewer>
2024-05-29 08:49:13 +00:00
</div>
2024-05-24 05:35:58 +00:00
</el-dialog>
</div>
</template>
<script>
import emitter from 'element-ui/src/mixins/emitter';
2024-05-31 10:12:59 +00:00
import PdfViewer from '@/components/PdfViewer/viewer.vue';
2024-06-21 17:54:53 +00:00
import A4Viewer from '@/components/PdfViewer/A4Viewer.vue';
2024-05-24 05:35:58 +00:00
import PdfUtils from '@/utils/pdfUtils'
2024-05-31 23:31:01 +00:00
import { deepClone } from '@/utils/index'
2024-05-24 05:35:58 +00:00
export default {
name: "TanexPrinterPanel",
components: {
2024-06-21 17:54:53 +00:00
PdfViewer,A4Viewer
2024-05-24 05:35:58 +00:00
},
mixins: [emitter],
props: {
value: {
2024-05-30 12:39:28 +00:00
type: [Number],
2024-05-24 05:35:58 +00:00
required: false
},
placeholder:{
type: [String],
required: false
2024-05-30 12:39:28 +00:00
},
isShowPinters:{
type: [Boolean],
required: false,
default: false
},
isShowTpl:{
type: [Boolean],
required: false,
default: false
},
isShowSubBillRange:{
type: [Boolean],
required: false,
default: false
2024-06-03 00:29:12 +00:00
},
2024-05-24 05:35:58 +00:00
},
data() {
return {
2024-06-21 17:54:53 +00:00
resetRefreshId:null,
2024-05-24 05:35:58 +00:00
svalue: this.value,
2024-05-29 08:18:45 +00:00
subBillStart:1,
2024-06-01 11:43:18 +00:00
subBillEnd:null,
2024-05-24 05:35:58 +00:00
openPdfView:false,
2024-05-31 23:31:01 +00:00
2024-07-02 11:39:24 +00:00
orderDetailMap:new Map(),
2024-06-07 02:26:05 +00:00
isInitA4:false,
2024-06-21 17:54:53 +00:00
2024-06-07 02:26:05 +00:00
printManCode:this.$store.getters.empCode,
2024-05-31 23:31:01 +00:00
// 计数器
showCounter:0,
2024-05-31 10:12:59 +00:00
pdfList:[],
2024-06-04 02:02:17 +00:00
pdfBase64List:[],
isLoadComplete:false,
2024-05-24 05:35:58 +00:00
tanexPrinter:null,
printerDownUrl:null,
printerStatus:0,
printerStatusMessage:'打印组件未连接',
orderList:[],
printerList:[],
printTplList:[],
2024-05-29 08:18:45 +00:00
selTplCode:null,
2024-05-24 05:35:58 +00:00
selPrinterName:null,
currentSelection:[],
2024-06-04 23:16:31 +00:00
pdfUtils:new PdfUtils({})
2024-05-24 05:35:58 +00:00
};
},
watch: {
value(newVal) {
this.svalue = newVal;
if(this.svalue!=null) {
}
},
},
created() {
this.initTanexPrinterSdk();
},
beforeDestroy(){
2024-05-30 12:39:28 +00:00
// this.tanexPrinter.close();
2024-05-24 05:35:58 +00:00
},
methods: {
2024-06-21 17:54:53 +00:00
getUUID() {
return Math.random().toString(36).substring(3,10);
},
refreshKey(){
this.resetRefreshId="print-"+this.getUUID();
},
2024-05-24 05:35:58 +00:00
initTanexPrinterSdk(){
2024-06-21 17:54:53 +00:00
this.refreshKey();
2024-05-24 05:35:58 +00:00
this.tanexPrinter = this.$tanexPrinter;
this.getConfigKey("sys.printer.downurl").then(response => {
this.printerDownUrl = response.msg;
});
this.tanexPrinter.init();
this.tanexPrinter.setOnOpen(this.onPrinterOpen);
this.tanexPrinter.setOnClose(this.onPrinterClose);
this.tanexPrinter.setOnError(this.onPrinterError);
this.tanexPrinter.setOnGetPrinter(this.onGetPrinter);
this.tanexPrinter.setOnGetPrintTpl(this.onGetPrintTpl);
},
onPrinterOpen(evt){
// console.log("onPrinterOpen")
this.printerStatus = 1;
2024-05-30 12:39:28 +00:00
this.$emit("input",this.printerStatus);
2024-05-24 05:35:58 +00:00
this.printerStatusMessage="打印组件已连接,可以打印.";
},
onPrinterClose(evt){
// console.log("onPrinterClose")
this.printerStatus = 0;
2024-05-30 12:39:28 +00:00
this.$emit("input",this.printerStatus);
2024-05-24 05:35:58 +00:00
this.printerStatusMessage="打印组件已断开!";
},
onPrinterError(evt){
// console.log("onPrinterError")
this.printerStatus = 0;
2024-05-30 12:39:28 +00:00
this.$emit("input",this.printerStatus);
2024-05-24 05:35:58 +00:00
this.printerStatusMessage="打印组件已断开!";
},
onGetPrinter(msg){
// console.log("onGetPrinter")
this.printerList=this.tanexPrinter.getPrinterTplList();
this.selPrinterName=this.tanexPrinter.getDefaultPrinter();
},
onGetPrintTpl(msg){
// console.log("onGetPrintTpl")
2024-05-29 08:18:45 +00:00
this.printTplList=[];
2024-05-24 05:35:58 +00:00
this.printTplList=this.tanexPrinter.getPrintTplList();
2024-06-04 14:31:32 +00:00
if(this.isInitA4){
const newList=this.printTplList.filter(item=>item.tplCode == 'A4-EP');
this.printTplList=newList;
}
2024-06-04 04:50:10 +00:00
2024-05-29 08:18:45 +00:00
// console.log(this.printTplList)
this.selTplCode=this.printTplList[0].tplCode;
},
2024-05-30 12:39:28 +00:00
getDefaultPrinter(){
return this.tanexPrinter.getDefaultPrinter();
},
2024-05-29 08:18:45 +00:00
refreshPrintTpl(){
this.printTplList=[];
this.selTplCode=null;
this.tanexPrinter.refreshPrintTpl()
},
lpadZero(val,len) {
return (new Array(len + 1).join('0') + val).slice(-len);
2024-05-24 05:35:58 +00:00
},
2024-05-30 12:39:28 +00:00
/*
高级批量打印
[
{
"tplCode":tplCode,
"printerName":printerName,
"orderList":orderList.toString()
}
]
*/
batchPrintAdv(printDataList){
2024-05-31 10:12:59 +00:00
if(this.printerStatus !=1){
this.$modal.msgError("打印机未连接");
return;
}
2024-06-07 02:26:05 +00:00
this.isInitA4=false;
this.tanexPrinter.batchPrintAdv(printDataList,this.printManCode);
2024-05-30 12:39:28 +00:00
},
2024-07-02 11:39:24 +00:00
batchPrint(orderList,tplCode,orderDetailList){
2024-05-31 10:12:59 +00:00
if(this.printerStatus !=1){
this.$modal.msgError("打印机未连接");
return;
}
2024-06-11 11:49:02 +00:00
this.isInitA4=false;
2024-06-07 02:26:05 +00:00
2024-07-02 11:39:24 +00:00
this.orderDetailMap=new Map();
if(orderDetailList){
orderDetailList.map(v=>{
this.orderDetailMap[v.billCode]=v;
});
}
2024-05-24 05:35:58 +00:00
let that = this;
2024-05-29 08:18:45 +00:00
let newOrderList=[];
2024-05-24 05:35:58 +00:00
if(orderList){
this.orderList=[...orderList]
}
2024-05-30 12:39:28 +00:00
if(tplCode){
this.selTplCode=tplCode
2024-05-29 08:18:45 +00:00
}
2024-06-21 17:54:53 +00:00
// 打印子单
if(this.selTplCode=="TAN-GC-130"){
2024-06-07 02:26:05 +00:00
for(let i=0;i<this.orderList.length;i++){
let billCode=this.orderList[i];
let subBillStart=1;
if(this.subBillStart&&this.subBillStart>0){
subBillStart=this.subBillStart;
}
2024-05-29 08:18:45 +00:00
2024-07-02 11:39:24 +00:00
let billDetail = this.orderDetailMap[billCode];
let subBillEnd=parseInt(billDetail.parcelQty);
if(this.subBillEnd&&this.subBillEnd!=''){
subBillEnd = parseInt(this.subBillEnd)<=parseInt(billDetail.parcelQty)?parseInt(this.subBillEnd):parseInt(billDetail.parcelQty);
2024-06-07 02:26:05 +00:00
}
2024-07-02 11:39:24 +00:00
2024-06-07 02:26:05 +00:00
// 循环子单范围
for(let i=subBillStart;i<=subBillEnd;i++){
2024-07-02 11:39:24 +00:00
let subBillCode = billCode+""+this.lpadZero(i,4);
2024-06-07 02:26:05 +00:00
newOrderList.push(subBillCode);
}
}
}else{
newOrderList=[...orderList];
}
2024-07-02 11:39:24 +00:00
// console.log("tnprint===>",newOrderList);
// console.log("tnprint===>",that.selTplCode);
2024-06-07 02:26:05 +00:00
that.tanexPrinter.batchPrint(that.selTplCode,that.selPrinterName,newOrderList,this.printManCode)
2024-05-30 12:39:28 +00:00
},
2024-05-31 10:12:59 +00:00
2024-05-30 12:39:28 +00:00
printPreviewAdv(printDataList,billCount){
2024-05-31 10:12:59 +00:00
if(this.printerStatus !=1){
this.$modal.msgError("打印机未连接");
return;
}
2024-06-07 02:26:05 +00:00
this.isInitA4=false;
2024-05-30 12:39:28 +00:00
let that = this;
const loadingInstance = this.$loading({
text: '正在生成预览...'
})
2024-05-31 10:12:59 +00:00
that.pdfList=[];
2024-05-31 23:31:01 +00:00
that.showCounter=0;
2024-06-07 02:26:05 +00:00
this.tanexPrinter.batchGetPDFAdv(printDataList,billCount,this.printManCode,async function(code,msg,data){
2024-06-11 11:49:02 +00:00
loadingInstance.close();
2024-05-31 10:12:59 +00:00
if(code == 500){
that.$modal.msgError("打印出错:"+msg);
}
else if(code == 200){
2024-05-31 23:31:01 +00:00
const pdfData=deepClone(data);
2024-06-11 11:49:02 +00:00
2024-05-31 10:12:59 +00:00
let pdfInfo={
2024-05-31 23:31:01 +00:00
"billCode":pdfData.ydSn,
2024-06-04 02:02:17 +00:00
"pdfUrl":null,
"pdfBase64":pdfData.file
2024-05-31 10:12:59 +00:00
}
2024-06-04 02:02:17 +00:00
2024-05-31 10:12:59 +00:00
that.pdfList.push(pdfInfo);
2024-05-31 23:31:01 +00:00
if(!that.openPdfView && that.showCounter==0){
that.openPdfView = true;
}
that.showCounter++;
2024-05-31 10:12:59 +00:00
2024-05-30 12:39:28 +00:00
}
2024-05-31 10:12:59 +00:00
else if(code == 800){
// 全部获取完成
2024-06-11 11:49:02 +00:00
// console.log("===全部获取完成1====>");
2024-06-04 02:02:17 +00:00
that.isLoadComplete=true;
2024-05-31 10:12:59 +00:00
}
2024-05-30 12:39:28 +00:00
});
2024-05-24 05:35:58 +00:00
},
2024-07-02 11:39:24 +00:00
printPreview(orderList,isA4,tplCode,orderDetailList){
2024-06-21 17:54:53 +00:00
this.refreshKey();
2024-05-31 10:12:59 +00:00
if(this.printerStatus !=1){
this.$modal.msgError("打印机未连接");
return;
}
2024-07-02 11:39:24 +00:00
this.orderDetailMap=new Map();
if(orderDetailList){
orderDetailList.map(v=>{
this.orderDetailMap[v.billCode]=v;
});
}
// console.log("====>orderDetailMap==>",this.orderDetailMap);
2024-06-21 17:54:53 +00:00
if(tplCode){
this.selTplCode=tplCode;
}
2024-06-07 02:26:05 +00:00
if(isA4){
this.isInitA4=isA4;
}
2024-05-29 08:18:45 +00:00
let that = this;
let newOrderList=[];
2024-05-24 05:35:58 +00:00
if(orderList){
this.orderList=[...orderList]
}
2024-05-30 12:39:28 +00:00
2024-07-02 11:39:24 +00:00
2024-05-31 23:31:01 +00:00
// 打印子单
if(this.selTplCode=="TAN-GC-130"){
for(let i=0;i<this.orderList.length;i++){
let billCode=this.orderList[i];
2024-06-01 11:43:18 +00:00
let subBillStart=1;
if(this.subBillStart&&this.subBillStart>0){
subBillStart=this.subBillStart;
}
2024-07-02 11:39:24 +00:00
let billDetail = this.orderDetailMap[billCode];
// console.log("====>billDetail==>",billDetail);
let subBillEnd=parseInt(billDetail.parcelQty);
2024-06-01 11:43:18 +00:00
if(this.subBillEnd){
2024-07-02 11:39:24 +00:00
subBillEnd = parseInt(this.subBillEnd)<=parseInt(billDetail.parcelQty)?parseInt(this.subBillEnd):parseInt(billDetail.parcelQty);
2024-06-01 11:43:18 +00:00
}
2024-07-02 11:39:24 +00:00
2024-05-31 23:31:01 +00:00
// 循环子单范围
2024-06-01 11:43:18 +00:00
for(let i=subBillStart;i<=subBillEnd;i++){
2024-05-31 23:31:01 +00:00
let subBillCode = billCode+""+this.lpadZero(i,4);
newOrderList.push(subBillCode);
}
2024-06-01 11:43:18 +00:00
2024-05-31 23:31:01 +00:00
}
}else{
newOrderList=[...orderList];
2024-05-30 12:39:28 +00:00
}
2024-05-24 05:35:58 +00:00
const loadingInstance = this.$loading({
text: '正在生成预览...'
})
2024-05-29 08:18:45 +00:00
2024-05-31 23:31:01 +00:00
that.pdfList=[];
that.showCounter=0;
2024-06-07 02:26:05 +00:00
this.tanexPrinter.batchGetPDF(this.selTplCode,this.selPrinterName,newOrderList,this.printManCode,async function(code,msg,data){
2024-06-11 11:49:02 +00:00
loadingInstance.close();
2024-05-31 10:12:59 +00:00
if(code == 500){
that.$modal.msgError("打印出错:"+msg);
}
else if(code == 200){
2024-06-11 11:49:02 +00:00
// console.log("===获取到数据====>");
2024-06-07 02:26:05 +00:00
2024-06-04 23:16:31 +00:00
const pdfData=deepClone(data);
2024-05-31 10:12:59 +00:00
let pdfInfo={
"billCode":pdfData.ydSn,
2024-06-04 02:02:17 +00:00
"pdfUrl":null,
"pdfBase64":pdfData.file
2024-05-31 10:12:59 +00:00
}
2024-06-04 02:02:17 +00:00
2024-05-31 10:12:59 +00:00
that.pdfList.push(pdfInfo);
2024-05-31 23:31:01 +00:00
if(!that.openPdfView && that.showCounter==0){
that.openPdfView = true;
}
that.showCounter++;
2024-05-31 10:12:59 +00:00
}
else if(code == 800){
// 全部获取完成
2024-06-11 11:49:02 +00:00
// console.log("===全部获取完成2====>");
2024-06-04 02:02:17 +00:00
that.isLoadComplete=true;
2024-05-24 05:35:58 +00:00
}
});
},
2024-07-02 11:39:24 +00:00
downPDF(orderList,isA4,tplCode,orderDetailList){
2024-05-31 10:12:59 +00:00
if(this.printerStatus !=1){
this.$modal.msgError("打印机未连接");
return;
}
2024-07-02 11:39:24 +00:00
this.orderDetailMap=new Map();
if(orderDetailList){
orderDetailList.map(v=>{
this.orderDetailMap[v.billCode]=v;
});
}
2024-06-21 17:54:53 +00:00
if(tplCode){
this.selTplCode=tplCode;
}
2024-06-07 02:26:05 +00:00
if(isA4){
this.isInitA4=isA4;
}
2024-05-31 10:12:59 +00:00
2024-05-29 08:18:45 +00:00
let that = this;
let newOrderList=[];
2024-05-24 05:35:58 +00:00
if(orderList){
this.orderList=[...orderList]
}
2024-05-29 08:18:45 +00:00
// 打印子单
if(this.selTplCode=="TAN-GC-130"){
for(let i=0;i<this.orderList.length;i++){
let billCode=this.orderList[i];
// 循环子单范围
2024-06-01 11:43:18 +00:00
let subBillStart=1;
if(this.subBillStart&&this.subBillStart>0){
subBillStart=this.subBillStart;
}
2024-07-02 11:39:24 +00:00
let billDetail = this.orderDetailMap[billCode];
// console.log("====>billDetail==>",billDetail);
let subBillEnd=parseInt(billDetail.parcelQty);
2024-06-01 11:43:18 +00:00
if(this.subBillEnd){
2024-07-02 11:39:24 +00:00
subBillEnd = parseInt(this.subBillEnd)<=parseInt(billDetail.parcelQty)?parseInt(this.subBillEnd):parseInt(billDetail.parcelQty);
2024-06-01 11:43:18 +00:00
}
for(let i=subBillStart;i<=subBillEnd;i++){
2024-05-29 08:18:45 +00:00
let subBillCode = billCode+""+this.lpadZero(i,4);
newOrderList.push(subBillCode);
}
}
}else{
newOrderList=[...orderList];
}
2024-05-24 05:35:58 +00:00
const loadingInstance = this.$loading({
text: '正在下载...'
})
2024-06-29 03:34:07 +00:00
// 清空以前的数据
this.pdfList=[];
2024-06-07 02:26:05 +00:00
this.tanexPrinter.batchGetPDF(this.selTplCode,this.selPrinterName,newOrderList,this.printManCode,function(code,msg,data){
2024-05-24 05:35:58 +00:00
loadingInstance.close();
2024-05-31 10:12:59 +00:00
if(code == 500){
that.$modal.msgError("下载出错:"+msg);
}
else if(code == 200){
2024-06-04 23:16:31 +00:00
2024-06-21 17:54:53 +00:00
const pdfData=deepClone(data);
2024-06-04 23:16:31 +00:00
let pdfInfo={
"billCode":pdfData.ydSn,
"pdfUrl":null,
"pdfBase64":pdfData.file
}
that.pdfList.push(pdfInfo);
2024-06-21 17:54:53 +00:00
// if(!that.isInitA4){
// const pdfData=deepClone(data);
// loadingInstance.close();
// that.pdfUtils.getBlobUrl(pdfData.file, pdfData.ydSn+".pdf",true )
// }else{
// const pdfData=deepClone(data);
// let pdfInfo={
// "billCode":pdfData.ydSn,
// "pdfUrl":null,
// "pdfBase64":pdfData.file
// }
// that.pdfList.push(pdfInfo);
// }
2024-05-24 05:35:58 +00:00
}
2024-05-31 10:12:59 +00:00
else if(code == 800){
2024-05-31 23:31:01 +00:00
// console.log("===全部获取完成====>");
2024-06-04 23:16:31 +00:00
// A4下载
if(that.isInitA4){
that.downA4PDF();
2024-06-21 17:54:53 +00:00
}else{
that.downSinglePDF();
2024-06-04 23:16:31 +00:00
}
2024-05-31 10:12:59 +00:00
}
2024-05-29 08:18:45 +00:00
});
2024-05-24 05:35:58 +00:00
},
2024-06-21 17:54:53 +00:00
downSinglePDF(){
2024-06-29 03:34:07 +00:00
this.$prompt('请输入保存文件名', "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
closeOnClickModal: false,
inputValidator (value) {
if (value) {
return true;
}else{
return false;
}
},
inputErrorMessage: "文件名不能为空"
}).then(async ({ value }) => {
if(!value){
this.$modal.msgError("文件名不能为空" );
return
}
let needGenList=[];
for(let j=0;j<this.pdfList.length;j++){
needGenList.push(this.pdfList[j].pdfBase64)
}
// let fileName=new Date().getTime()+".pdf";
let fileName=value+".pdf";
this.pdfUtils.mergePdf3(needGenList,fileName,true);
}).catch(() => {});
2024-06-21 17:54:53 +00:00
},
2024-06-04 23:16:31 +00:00
downA4PDF(){
2024-06-29 03:34:07 +00:00
this.$prompt('请输入保存文件名', "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
closeOnClickModal: false,
inputValidator (value) {
if (value) {
return true;
}else{
return false;
2024-06-04 23:16:31 +00:00
}
2024-06-29 03:34:07 +00:00
},
inputErrorMessage: "文件名不能为空"
}).then(async ({ value }) => {
if(!value){
this.$modal.msgError("文件名不能为空" );
return
}
let cacheA4FileList=[];
const newList = Object.assign([], this.pdfList);
if(newList&&newList.length>4){
let spliteArr = (array = [], subGroupLength = 0) => {
let index = 0;
const newArray = [];
while (index < array.length) {
newArray.push(array.slice(index, index += subGroupLength));
}
return newArray;
}
const subPdfList=spliteArr(newList, 4);
for (let i=0; i < subPdfList.length;i++){
let fileItem={
"billCode":"page-"+(i+1),
"pdfUrl":null,
"childreen":subPdfList[i]
}
cacheA4FileList.push(fileItem);
}
}else{
2024-06-04 23:16:31 +00:00
let fileItem={
2024-06-29 03:34:07 +00:00
"billCode":"page-"+1,
"pdfUrl":null,
"childreen":newList
2024-06-04 23:16:31 +00:00
}
cacheA4FileList.push(fileItem);
2024-06-29 03:34:07 +00:00
}
2024-06-04 23:16:31 +00:00
2024-06-29 03:34:07 +00:00
// 下载
// let mergeA4List=[];
let needGenList=[];
for(let i=0;i<cacheA4FileList.length;i++){
let thisSubList=cacheA4FileList[i].childreen;
for(let j=0;j<thisSubList.length;j++){
needGenList.push(thisSubList[j].pdfBase64)
}
}
// let pdfUrl=await this.pdfUtils.mergePdfToA4(needGenList);
// mergeA4List.push(pdfUrl);
// let fileName=new Date().getTime()+".pdf";
let fileName=value+".pdf";
this.pdfUtils.mergePdfToA4(needGenList,fileName,true);
}).catch(() => {});
2024-06-04 23:16:31 +00:00
},
2024-05-30 12:39:28 +00:00
// 响应PDF预览
onPdfViewPrint(){
this.$emit("onPrint");
2024-06-01 11:43:18 +00:00
},
handleClose(){
this.$emit("onPrintComplete");
2024-05-30 12:39:28 +00:00
}
2024-05-24 05:35:58 +00:00
}
};
</script>
<style lang="scss">
.printPreDialog .el-dialog__body {
margin: 0px!important;
}
2024-05-29 08:18:45 +00:00
.subBillRange .el-input__inner {
padding:0px;
text-align: center;
}
2024-05-24 05:35:58 +00:00
</style>