This commit is contained in:
liuyp 2024-06-04 15:19:26 +08:00
commit e4f720fd40
6 changed files with 912 additions and 196 deletions

View File

@ -5,7 +5,6 @@
v-show="true" v-show="true"
v-model="datetimeRange" v-model="datetimeRange"
type="datetimerange" type="datetimerange"
start-placeholder="开始日期" start-placeholder="开始日期"
end-placeholder="结束日期" end-placeholder="结束日期"
ref="timeRangePicker" ref="timeRangePicker"
@ -18,6 +17,8 @@
</template> </template>
<script> <script>
import {dateToStr} from '@/utils/custom'
export default { export default {
name: "elDateAdvPicker", name: "elDateAdvPicker",
model: { model: {
@ -167,13 +168,20 @@ export default {
this.datetimeRange = newVal; this.datetimeRange = newVal;
}, },
datetimeRange(newVal, oldVal) { datetimeRange(newVal, oldVal) {
this.$emit("input", this.datetimeRange); // this.$emit("input", this.datetimeRange);
} }
}, },
methods: { methods: {
dateTimeChange(value) { dateTimeChange(value) {
if(this.datetimeRange&&this.datetimeRange.length==2){
this.datetimeRange[0]=dateToStr(this.datetimeRange[0]);
this.datetimeRange[1]=dateToStr(this.datetimeRange[1]);
}
// this.datetimeRange
this.$emit("input", this.datetimeRange); this.$emit("input", this.datetimeRange);
this.$emit('dateTimeChange', value) this.$emit('dateTimeChange', this.datetimeRange)
}, },
} }
} }

View File

@ -31,8 +31,8 @@
</div> </div>
<div class="tools"> <div class="tools">
<div style="width:100%;text-align: right;"> <div style="width:100%;text-align: right;">
<el-button title="" type="primary" v-if="isA4" @click="showSinglePage">切换单页</el-button> <!-- <el-button title="" type="primary" v-if="isA4" @click="showSinglePage(1)">切换单页</el-button> -->
<el-button title="" type="primary" v-else @click="showA4Page">切换A4</el-button> <!-- <el-button title="" type="primary" v-else @click="showA4Page(1)">切换A4</el-button> -->
<el-button title="" type="primary" icon="el-icon-download" @click="downPDF">下载</el-button> <el-button title="" type="primary" icon="el-icon-download" @click="downPDF">下载</el-button>
<el-button title="" type="primary" icon="el-icon-printer" @click="printPDF">打印</el-button> <el-button title="" type="primary" icon="el-icon-printer" @click="printPDF">打印</el-button>
</div> </div>
@ -63,7 +63,6 @@
* 一定要使用4.2的话就手动装一下pdfjs-dist的2.5.207 ==> npm i pdfjs-dist@2.5.207 * 一定要使用4.2的话就手动装一下pdfjs-dist的2.5.207 ==> npm i pdfjs-dist@2.5.207
*/ */
import pdf from 'vue-pdf' import pdf from 'vue-pdf'
import { jsPDF } from "jspdf";
import PdfUtils from '@/utils/pdfUtils.js'; import PdfUtils from '@/utils/pdfUtils.js';
export default { export default {
components: { pdf }, components: { pdf },
@ -78,6 +77,10 @@ export default {
isInitA4:{ isInitA4:{
type: Boolean, type: Boolean,
default: false default: false
},
isLoadComplete:{
type: Boolean,
default: false
} }
}, },
data() { data() {
@ -101,14 +104,8 @@ export default {
scale: 20, scale: 20,
preScale: 20, preScale: 20,
// // A4 pdfUtils:new PdfUtils(),
// newPrototype: [],
// newPrototypeValue: [],
// imgFiles: [], //pdf页数列表
// filelist: [], //列表
// //img
// realWidth: 720,
// dpr: '',
loading: false, loading: false,
} }
@ -130,43 +127,96 @@ export default {
watch: { watch: {
pdfList(){ pdfList(){
this.cacheFileList=this.pdfList; this.cacheFileList=this.pdfList;
this.pageCount=this.cacheFileList.length; this.initA4List();
if(this.isA4){
setTimeout( this.showA4Page(),2000); this.showFirstFile();
}
// if(this.isA4){
// this.pageCount=this.cacheA4FileList.length;
// setTimeout( this.showA4Page(this.cacheA4FileList.length),2000);
// }else{
// this.pageCount=this.cacheFileList.length;
// setTimeout( this.showSinglePage(1),2000);
// }
// console.log(this.loadPdfUrl); // console.log(this.loadPdfUrl);
// this.showFirstFile(); // this.showFirstFile();
}, },
thisPageCount(value) { thisPageCount(value) {
// console.log("============11111====================")
// console.log(this.isA4)
if(this.isA4){ if(this.isA4){
// if (value) this.page = 1
this.doScale(75); this.doScale(75);
}else{ }else{
this.doScale(20); this.doScale(20);
} }
},
isLoadComplete(newVal,oldVal){
console.log("isLoadComplete==>"+this.isLoadComplete);
this.showA4Page(1);
} }
}, },
mounted() { mounted() {
this.initA4List();
this.showFirstFile(); this.showFirstFile();
window.addEventListener('mousewheel', this.handleScroll, { passive: false }) window.addEventListener('mousewheel', this.handleScroll, { passive: false })
}, },
methods: { methods: {
showFirstFile(){ initA4List(){
if(this.isA4){ this.cacheA4FileList=[];
// this.isA4=false; const newList = Object.assign([], this.pdfList);
setTimeout( this.showA4Page(),2000); if(newList&&newList.length>4){
let spliteArr = (array = [], subGroupLength = 0) => {
}else{ let index = 0;
if(this.cacheFileList&& this.cacheFileList.length>0){ const newArray = [];
this.loadPdfUrl =this.pdfList[0].pdfUrl; while (index < array.length) {
this.resetCountKey++; 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]
}
this.cacheA4FileList.push(fileItem);
}
}else{
let fileItem={
"billCode":"page-"+1,
"pdfUrl":null,
"childreen":newList
}
this.cacheA4FileList.push(fileItem);
} }
console.log(this.cacheA4FileList)
},
showFirstFile(){
// if(this.isA4){
// setTimeout( this.showA4Page(this.cacheA4FileList.length),2000);
// }else{
// if(this.cacheFileList&& this.cacheFileList.length>0){
// setTimeout( this.showSinglePage(this.cacheFileList.length),2000);
// this.resetCountKey++;
// }
// }
if(this.isA4){
this.scale=75;
this.preScale=75;
this.pageCount=this.cacheA4FileList.length;
setTimeout( this.showA4Page(this.cacheA4FileList.length),2000);
}else{
this.scale=20;
this.preScale=20;
this.pageCount=this.cacheFileList.length;
setTimeout( this.showSinglePage(1),2000);
}
this.resetCountKey++;
}, },
addPdfUrl(billCode,pdfUrl){ addPdfUrl(billCode,pdfUrl){
let item={ let item={
@ -240,13 +290,13 @@ export default {
let fileNo = this.currentPage - 1 let fileNo = this.currentPage - 1
if (fileNo < 1) return if (fileNo < 1) return
this.currentPage = fileNo this.currentPage = fileNo
this.loadPdfUrl =this.cacheFileList[this.currentPage-1].pdfUrl; this.showSinglePage(this.currentPage)
} }
else{ else{
let fileNo = this.currentPage - 1 let fileNo = this.currentPage - 1
if (fileNo < 1) return if (fileNo < 1) return
this.currentPage = fileNo this.currentPage = fileNo
this.loadPdfUrl =this.cacheA4FileList[this.currentPage-1].pdfUrl; this.showA4Page(this.currentPage)
} }
}, },
nextPage() { nextPage() {
@ -255,13 +305,13 @@ export default {
let fileNo = this.currentPage + 1 let fileNo = this.currentPage + 1
if (fileNo > this.pageCount) return if (fileNo > this.pageCount) return
this.currentPage = fileNo this.currentPage = fileNo
this.loadPdfUrl =this.cacheFileList[this.currentPage-1].pdfUrl; this.showSinglePage(this.currentPage)
} }
else{ else{
let fileNo = this.currentPage + 1 let fileNo = this.currentPage + 1
if (fileNo > this.pageCount) return if (fileNo > this.pageCount) return
this.currentPage = fileNo this.currentPage = fileNo
this.loadPdfUrl =this.cacheA4FileList[this.currentPage-1].pdfUrl; this.showA4Page(this.currentPage)
} }
}, },
// 下载 // 下载
@ -269,13 +319,27 @@ export default {
// 下载所有预览的PDF文件 // 下载所有预览的PDF文件
if(this.isA4){ if(this.isA4){
if(this.cacheA4FileList&&this.cacheA4FileList.length>0){ if(this.cacheA4FileList&&this.cacheA4FileList.length>0){
this.cacheA4FileList.forEach(item=>{ this.cacheA4FileList.forEach(async item=>{
this.downPdfFile(item.billCode,item.pdfUrl); if(!item.pdfUrl){
let thisSubList=item.childreen;
let needGenList=[];
for(let j=0;j<thisSubList.length;j++){
needGenList.push(thisSubList[j].pdfBase64)
}
item.pdfUrl=await this.pdfUtils.mergePdfToA4(needGenList);
this.downPdfFile(item.billCode,item.pdfUrl);
}else{
this.downPdfFile(item.billCode,item.pdfUrl);
}
}); });
} }
}else{ }else{
if(this.cacheFileList&&this.cacheFileList.length>0){ if(this.cacheFileList&&this.cacheFileList.length>0){
this.cacheFileList.forEach(item=>{ this.cacheFileList.forEach( item=>{
if(!item.pdfUrl){
item.pdfUrl = this.pdfUtils.getBlobUrl(item.pdfBase64);
}
this.downPdfFile(item.billCode,item.pdfUrl); this.downPdfFile(item.billCode,item.pdfUrl);
}); });
} }
@ -297,157 +361,79 @@ export default {
printPDF() { printPDF() {
// this.$refs.pdf.print() // this.$refs.pdf.print()
if(this.isA4){ if(this.isA4){
if(this.cacheA4FileList&&this.cacheA4FileList.length>0){ // if(this.cacheA4FileList&&this.cacheA4FileList.length>0){
this.cacheA4FileList.forEach(item=>{ // this.cacheA4FileList.forEach(async item=>{
this.loadPdfUrl=item.pdfUrl; // if(!item.pdfUrl){
this.$refs.pdf.print(); // let thisSubList=item.childreen;
}); // let needGenList=[];
} // for(let j=0;j<thisSubList.length;j++){
// needGenList.push(thisSubList[j].pdfBase64)
// }
// item.pdfUrl=await this.pdfUtils.mergePdfToA4(needGenList);
// this.loadPdfUrl=item.pdfUrl;
// }else{
// this.loadPdfUrl=item.pdfUrl;
// }
// });
// }
this.$refs.pdf.print();
// window.print();
}else{ }else{
this.$emit("onPrint"); this.$emit("onPrint");
} }
}, },
// initA4() { showSinglePage(page){
// //此功能是为了pdf.js内部,有时候会报for....in的错误,原因是原型方法被其他地方改变,这里需要改回来
// for (let key in Array.prototype) {
// if (!Array.prototype.hasOwnProperty(key)) continue;
// this.newPrototype.push(key);
// }
// // 存放原始键 原始方法
// this.newPrototypeValue = this.newPrototype.map((v) => ({ [v]: Array.prototype[v] }));
// // 删除直接属性
// this.newPrototype.forEach((v) => delete Array.prototype[v]);
// },
showSinglePage(){
this.showFirstFile();
this.isA4 = false; this.isA4 = false;
if(!page || Object.is(page, NaN)){
page=1;
}
this.pageCount=this.cacheFileList.length;
const thisPage=this.cacheFileList[page-1];
const pdfBase64 = thisPage.pdfBase64;
this.loadPdfUrl = this.pdfUtils.getBlobUrl(pdfBase64);
this.doScale(20); this.doScale(20);
this.resetCountKey++; this.resetCountKey++;
}, },
async showA4Page(){ async showA4Page(page){
// this.initA4(); this.isA4 = true
this.isA4 = true if(!page || Object.is(page, NaN)){
this.doScale(75); page=1;
this.cacheA4FileList=[];
let pdfUtils= new PdfUtils();
let that = this;
const loadingInstance = this.$loading({
text: '正在生成A4预览...'
})
try {
let imgFiles = [];
for(let i=0;i<this.cacheFileList.length;i++){
let file=this.cacheFileList[i].pdfUrl;
const img = await pdfUtils.pdfToImg(file);
imgFiles.push(img);
} }
// 每4个图片放一页 if(!this.cacheA4FileList || this.cacheA4FileList.length==0){
if(imgFiles&&imgFiles.length>0){ return;
// 数组拆分
const subImageList=imgFiles.reduce((acc, curr, index) => {
if (index % 4 === 0) acc.push([])
acc[Math.floor(index / 4)].push(curr)
return acc
}, [])
// 分页生成文件
for(let i=0; i<subImageList.length;i++){
let thisSubList=subImageList[i];
let pageNo = i+1;
console.log(thisSubList);
let pdfUrl=this.mergeImgToPdf(pdfUtils,thisSubList,pageNo);
if(pdfUrl){
let fileItem={
"billCode":"page-"+pageNo,
"pdfUrl":pdfUrl,
}
this.cacheA4FileList.push(fileItem);
if(i==0){
loadingInstance.close();
this.loadPdfUrl=this.cacheA4FileList[0].pdfUrl;
this.pageCount=1;
this.page=1;
}
}
}
this.loadPdfUrl=this.cacheA4FileList[0].pdfUrl;
this.pageCount=this.cacheA4FileList.length;
this.currentPage=1;
this.page=1;
this.resetCountKey++;
}
// 自行更改要保存的pdf名字
// doc.save('a4pdf.pdf')
} catch (error) {
console.log(error);
}
},
mergeImgToPdf(pdfUtils,imgFiles,pageNo){
try {
var doc = new jsPDF('', 'pt', 'a4')
// doc.addPage() //添加页
//a4纸的尺寸[595.28,841.89],html页面生成的canvas在pdf中图片的宽高
// var imgWidth = 595.28
// var imgHeight = (592.28 / contentWidth) * contentHeight
// let imgRealWidth=595.28/2-50;
let imgRealHeight=841.89/2-50;
let x=0;
let y=0;
for(let i=0;i<imgFiles.length;i++){
let imgItem=imgFiles[i];
// 计算宽高比
let whRate=imgItem.imgWidth/imgItem.imgHeight;
var contentWidth = imgRealHeight*whRate
var contentHeight = imgRealHeight;
// imgRealWidth/whRate
var imgUrl = imgItem.url;
let left=40*(x+1)+x*contentWidth;
let top=40*(y+1)+y*contentHeight;
// console.log("top:"+top+",left:"+left);
doc.addImage(imgUrl, 'PNG',left, top, contentWidth, contentHeight)
// 0,0 1,0
// 0,1 1,1
// console.log("x:"+x+",y:"+y);
if(x==0){
x++;
}
else if(x==1){
x=0;
y++;
}
if(y>1){
x=0;
y=0;
// doc.addPage() //添加页
}
}
var pdfBase64 = doc.output('datauristring')
let pdfUrl=URL.createObjectURL(pdfUtils.base64ToBlob(pdfBase64));
return pdfUrl;
} catch (error) {
console.log(error);
return null;
} }
}
const loadingInstance = this.$loading({
text: '正在生成A4预览...'
})
this.pageCount=this.cacheA4FileList.length;
console.log(this.cacheA4FileList)
// 分页生成文件,只渲染第一页
let thisSubList=this.cacheA4FileList[page-1].childreen;
let needGenList=[];
for(let j=0;j<thisSubList.length;j++){
needGenList.push(thisSubList[j].pdfBase64)
}
let pdfUrl=await this.pdfUtils.mergePdfToA4(needGenList);
if(pdfUrl){
loadingInstance.close();
this.cacheA4FileList[page-1].pdfUrl=pdfUrl;
this.loadPdfUrl=this.cacheA4FileList[page-1].pdfUrl;
}
this.resetCountKey++;
},
} }
} }

View File

@ -1,9 +1,8 @@
import { degrees, PDFDocument, rgb, StandardFonts } from 'pdf-lib'; import { degrees,PageSizes, PDFDocument, rgb, StandardFonts } from 'pdf-lib';
import axios from "axios"; import axios from "axios";
import Buffer from 'vue-buffer' import Buffer from 'vue-buffer'
import * as pdfjs from 'pdfjs-dist'; import * as pdfjs from 'pdfjs-dist';
import * as pdfjsWorker from 'pdfjs-dist/build/pdf.worker.entry'; import * as pdfjsWorker from 'pdfjs-dist/build/pdf.worker.entry';
/** /**
* 浏览器打开新页签预览pdf * 浏览器打开新页签预览pdf
* blob(必选): pdf文件信息(Blob对象)【Blob】 * blob(必选): pdf文件信息(Blob对象)【Blob】
@ -243,7 +242,7 @@ export default class PdfUtils {
* @param {Number} y - 页面展示高 * @param {Number} y - 页面展示高
* @param {String}fileName - 文件名称 * @param {String}fileName - 文件名称
*/ */
savePdfImage(newimgList, x, y, fileName) { savePdfImage(newimgList, x, y, fileName) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// 创建canvas // 创建canvas
@ -403,6 +402,100 @@ export default class PdfUtils {
return URL.createObjectURL(mergedPdfBlob); return URL.createObjectURL(mergedPdfBlob);
} }
} }
async mergePdfToA4(pdfFileList, fileName,isNeedDown=false) {
let pdfBuffers = [];
pdfFileList.map((item) => {
let dateArray=this.base64ToBuffer(item);
pdfBuffers.push(Buffer.from(dateArray));
});
const pdfDoc = await PDFDocument.create();
const pageA4 = pdfDoc.addPage(PageSizes.A4);
const drawHeight = pageA4.getHeight()/2;
const drawWidth = pageA4.getWidth()/2;
let i=0;
let x=0;
let y=0;
let width=0;
let height=0;
let spaceWidth=2;
for (let buffer of pdfBuffers) {
const [page] = await pdfDoc.embedPdf(buffer);
const pageDims = page.scale(1.0);
// ...pageDims,
// rotate: degrees(30),
// opacity: 0.75,
// Optional blendMode
// Optional height
// Optional opacity
// Optional rotate
// Optional width
// Optional x
// Optional xScale
// Optional xSkew
// Optional y
// Optional yScale
// Optional ySkew
// let rateDif=pageDims.width/pageDims.height;
// width = drawHeight*rateDif
width = pageDims.width;
height = pageDims.height;
if(i==0){
x=spaceWidth;
y=pageA4.getHeight()/2;
}
else if(i==1){
x=spaceWidth+pageA4.getWidth()/2;
y=pageA4.getHeight()/2;
}
else if(i==2){
x=spaceWidth;
y=spaceWidth;
}
else if(i==3){
x=spaceWidth+pageA4.getWidth()/2;
y=spaceWidth;
}
pageA4.drawPage(page, {
x: x,
y: y,
width:width,
height:height
});
i++;
}
const uint8Array = await pdfDoc.save();
let mergeBuffer = Buffer.from(uint8Array);
var blob=new Blob([mergeBuffer]);
if(isNeedDown){
const url = window.URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.setAttribute("download", fileName);
if (typeof link.download === 'undefined') {
link.setAttribute('target', '_blank')
}
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
}else{
const mergedPdfBlob = new Blob([mergeBuffer], {
type: "application/pdf",
});
return URL.createObjectURL(mergedPdfBlob);
}
}
downloadBase64(base64Str,fileName) { downloadBase64(base64Str,fileName) {
let result = base64Str.replace(/[\r\n]/g, ""); let result = base64Str.replace(/[\r\n]/g, "");
let pdfBase64 = `data:application/pdf;base64,${result}`; let pdfBase64 = `data:application/pdf;base64,${result}`;
@ -419,11 +512,41 @@ export default class PdfUtils {
} }
async urlToBlob(url) {
const response = await fetch(url);
const arrayBuffer = await response.arrayBuffer();
const byteArray = new Uint8Array(arrayBuffer);
return new Blob([byteArray], {type: response.headers.get('content-type')});
}
blobToBase64(blob) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => resolve(reader.result);
reader.onerror = reject;
reader.readAsDataURL(blob);
});
}
fileTobase64(file) { fileTobase64(file) {
let reader = new FileReader(); let reader = new FileReader();
reader.readAsDataURL(file) reader.readAsDataURL(file)
} }
blobToArrayBuffer(blob, callback) {
let reader = new FileReader();
reader.readAsArrayBuffer(blob);
reader.onload = function () {
return callback(this.result);
}
}
// let blob = new Blob([1, 2, 3, 4, 5]);
// blobToArrayBuffer(blob, (arrayBuffer) => { console.log(arrayBuffer) })
base64ToFile(base64Data, filename) { // 64转file base64ToFile(base64Data, filename) { // 64转file
if (typeof base64Data != 'string') { if (typeof base64Data != 'string') {

View File

@ -18,7 +18,7 @@
</span> </span>
</template> </template>
<el-option <el-option
v-for="item in printTplList.filter(el=>isInitA4?(el.tplCode == 'A4-EP'?true:false):true)" v-for="item in printTplList"
:key="item.tplCode" :key="item.tplCode"
:label="item.tplName" :label="item.tplName"
:value="item.tplCode" :value="item.tplCode"
@ -59,7 +59,7 @@
<el-dialog class="printPreDialog" title="预览" :visible.sync="openPdfView" width="95%" height="100%" :close-on-click-modal="false" :destroy-on-close="true" v-dialogDrag append-to-body @close="handleClose"> <el-dialog class="printPreDialog" title="预览" :visible.sync="openPdfView" width="95%" height="100%" :close-on-click-modal="false" :destroy-on-close="true" v-dialogDrag append-to-body @close="handleClose">
<div style="height:100%;width:100%;overflow: auto;"> <div style="height:100%;width:100%;overflow: auto;">
<PdfViewer ref="pdfViewer" v-if="openPdfView" :pdfList="pdfList" :isInitA4="isInitA4" @onPrint="onPdfViewPrint" ></PdfViewer> <PdfViewer ref="pdfViewer" v-if="openPdfView" :pdfList="pdfList" :isLoadComplete="isLoadComplete" :isInitA4="isInitA4" @onPrint="onPdfViewPrint" ></PdfViewer>
</div> </div>
</el-dialog> </el-dialog>
@ -120,6 +120,8 @@
showCounter:0, showCounter:0,
pdfList:[], pdfList:[],
pdfBase64List:[],
isLoadComplete:false,
tanexPrinter:null, tanexPrinter:null,
printerDownUrl:null, printerDownUrl:null,
@ -198,6 +200,9 @@
this.printTplList=[]; this.printTplList=[];
this.printTplList=this.tanexPrinter.getPrintTplList(); this.printTplList=this.tanexPrinter.getPrintTplList();
const newList=this.printTplList.filter(item=>item.tplCode == 'A4-EP');
this.printTplList=newList;
// console.log(this.printTplList) // console.log(this.printTplList)
this.selTplCode=this.printTplList[0].tplCode; this.selTplCode=this.printTplList[0].tplCode;
@ -271,21 +276,18 @@
that.pdfList=[]; that.pdfList=[];
that.showCounter=0; that.showCounter=0;
this.tanexPrinter.batchGetPDFAdv(printDataList,billCount,async function(code,msg,data){ this.tanexPrinter.batchGetPDFAdv(printDataList,billCount,async function(code,msg,data){
console.log(msg);
console.log(code);
if(code == 500){ if(code == 500){
that.$modal.msgError("打印出错:"+msg); that.$modal.msgError("打印出错:"+msg);
} }
else if(code == 200){ else if(code == 200){
const pdfData=deepClone(data); const pdfData=deepClone(data);
loadingInstance.close(); loadingInstance.close();
let pdfUtils=new PdfUtils({});
let blobUrl= await pdfUtils.getBlobUrl(pdfData.file);
let pdfInfo={ let pdfInfo={
"billCode":pdfData.ydSn, "billCode":pdfData.ydSn,
"pdfUrl":blobUrl "pdfUrl":null,
"pdfBase64":pdfData.file
} }
that.pdfList.push(pdfInfo); that.pdfList.push(pdfInfo);
@ -298,7 +300,8 @@
} }
else if(code == 800){ else if(code == 800){
// 全部获取完成 // 全部获取完成
// console.log("===预览全部获取完成====>"); console.log("===全部获取完成1====>");
that.isLoadComplete=true;
} }
}); });
@ -351,17 +354,19 @@
that.$modal.msgError("打印出错:"+msg); that.$modal.msgError("打印出错:"+msg);
} }
else if(code == 200){ else if(code == 200){
console.log("===获取到数据====>");
const pdfData=deepClone(data); const pdfData=deepClone(data);
loadingInstance.close(); loadingInstance.close();
let pdfUtils=new PdfUtils({});
let blobUrl= await pdfUtils.getBlobUrl(pdfData.file);
let pdfInfo={ let pdfInfo={
"billCode":pdfData.ydSn, "billCode":pdfData.ydSn,
"pdfUrl":blobUrl "pdfUrl":null,
"pdfBase64":pdfData.file
} }
that.pdfList.push(pdfInfo); that.pdfList.push(pdfInfo);
console.log(that.pdfList);
if(!that.openPdfView && that.showCounter==0){ if(!that.openPdfView && that.showCounter==0){
that.openPdfView = true; that.openPdfView = true;
} }
@ -370,7 +375,8 @@
} }
else if(code == 800){ else if(code == 800){
// 全部获取完成 // 全部获取完成
// console.log("===全部获取完成====>"); console.log("===全部获取完成2====>");
that.isLoadComplete=true;
} }
}); });
}, },
@ -429,6 +435,7 @@
pdfUtils.getBlobUrl(pdfData.file, pdfData.ydSn+".pdf",true ) pdfUtils.getBlobUrl(pdfData.file, pdfData.ydSn+".pdf",true )
} }
else if(code == 800){ else if(code == 800){
// 全部获取完成 // 全部获取完成
// console.log("===全部获取完成====>"); // console.log("===全部获取完成====>");
} }

View File

@ -0,0 +1,592 @@
<template>
<XdPageContainer class="app-container">
<SearchForm slot="pageHeader" class="queryForm" :model="queryParams" ref="queryForm" size="mini" :maxShow="9" label-width="100px" v-show="showSearch" @search="handleQuery" @reset="resetQuery">
<!-- label-width="100px" -->
<el-row :gutter="0" style="display: flex;flex-wrap: wrap;">
<!-- :span="6" -->
<el-col :xs="8" :sm="8" :md="8" :lg="8" :xl="6">
<el-row :gutter="0" style="display: flex;flex-wrap: wrap;">
<el-col :span="24">
<el-form-item label="" prop="billCode">
<div slot="label">
<el-radio-group class="query-label" v-model="queryOrderType">
<el-radio :key="1" label="1">运单号</el-radio>
<!-- <el-radio :key="0" label="0">订单号</el-radio> -->
</el-radio-group>
</div>
<XdTextareaInput
v-model="queryParams.billCode"
:placeholder="$t('多个流水号逗号或换行隔开')"
clearable
:rows="4"
/>
</el-form-item>
</el-col>
</el-row>
</el-col>
</el-row>
</SearchForm>
<el-table v-loading="loading" :data="emisWaybillList" @selection-change="handleSelectionChange">
<el-table-column label="入库单编号" align="center" prop="receiptNo" min-width="100" />
</el-table>
<el-table v-loading="loading" :data="emisWaybillList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column :label="$t('快件当前最新状态')" align="center" prop="lastTraceInfo" min-width="350" :show-overflow-tooltip="true" />
<el-table-column :label="$t('收款状态')" align="center" prop="paymentStatus" width="100" >
<template slot-scope="scope">
<dict-tag :options="dict.type.emis_payment_status" :value="scope.row.paymentStatus"/>
</template>
</el-table-column>
<el-table-column :label="$t('取件方式')" align="center" prop="pickupMethod" width="100" >
<template slot-scope="scope">
<dict-tag :options="dict.type.emis_qujian_fangshi" :value="scope.row.pickupMethod"/>
</template>
</el-table-column>
<el-table-column :label="$t('发件人')" align="center" prop="pickupMethod" width="180" :show-overflow-tooltip="true">
<template slot-scope="scope">
<span>{{ scope.row.sendName }}--{{ scope.row.receiveName }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('快件类型')" align="center" prop="pickupMethod" width="180" :show-overflow-tooltip="true">
<template slot-scope="scope">
<span>{{ scope.row.sendSiteName }}--{{ scope.row.dispatchUnderlingSiteName }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('预计送达时间')" align="center" prop="estimateDate" min-width="100" >
<template slot-scope="scope">
<span>{{ parseTime(scope.row.estimateDate, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('发货日期')" align="center" prop="sendDate" min-width="100" :show-overflow-tooltip="true"/>
<el-table-column :label="$t('收件员')" align="center" prop="takePieceEmployeeName" min-width="100" :show-overflow-tooltip="true">
<template slot-scope="scope">
<span v-if="scope.row.pickupMethod==2">{{scope.row.takePieceEmployeeName}}</span>
<span v-else></span>
</template>
</el-table-column>
<!-- <el-table-column :label="$t('订单号')" align="center" prop="orderSn" width="100" :show-overflow-tooltip="true"/> -->
<el-table-column :label="$t('运单号')" align="center" prop="billCode" min-width="120" :show-overflow-tooltip="true" />
<el-table-column :label="$t('合同号')" align="center" prop="custOrderId" width="100" :show-overflow-tooltip="true"/>
</el-table>
</XdPageContainer>
</template>
<script>
import 'element-ui/lib/theme-chalk/display.css';
import { listEmisWaybill, getEmisWaybill, delEmisWaybill, addEmisWaybill, updateEmisWaybill } from "@/api/emis/emisWaybill";
import elDateSimplePicker from '@/components/DatePickerAdv/elDateSimplePicker';
// import emisWaybillView from '@/views/emis/emisWaybill/emisWaybillView';
import emisWaybillForm from '@/views/emis/emisWaybill/emisWaybillForm';
import elDateAdvPicker from '@/components/DatePickerAdv/elDateAdvPicker';
import CountryPicker1 from '@/views/emis/EmisBaseTools/CountryPicker.vue';
import CountryPicker2 from '@/views/emis/EmisBaseTools/CountryPicker.vue';
import ProvincePicker2 from '@/views/emis/EmisBaseTools/ProvincePicker.vue';
import TransLinePicker from '@/views/emis/EmisBaseTools/TransLinePicker.vue';
import TransProductPicker from '@/views/emis/EmisBaseTools/TransProductPicker.vue';
import PayeePicker from '@/views/emis/EmisBaseTools/PayeePicker.vue';
import SalemanPicker from '@/views/emis/EmisBaseTools/SalemanPicker.vue';
import EmisUserSimplePicker0 from '@/views/emis/EmisBaseTools/EmisUserSimplePicker.vue';
import EmisUserSimplePicker1 from '@/views/emis/EmisBaseTools/EmisUserSimplePicker.vue';
import EmisUserSimplePicker2 from '@/views/emis/EmisBaseTools/EmisUserSimplePicker.vue';
import EmisSiteSimplePicker1 from '@/views/emis/EmisBaseTools/EmisSiteSimplePicker.vue';
import EmisSiteSimplePicker2 from '@/views/emis/EmisBaseTools/EmisSiteSimplePicker.vue';
import ProblemTypePicker from '@/views/emis/EmisBaseTools/ProblemTypePicker.vue';
import EmisMonthpayAccountPicker from '@/views/emis/EmisBaseTools/EmisMonthpayAccountPicker.vue';
import {dateToStr} from '@/utils/custom'
import { formatSearchStr,deepClone } from '@/utils/index'
export default {
name: "SendWaybillList",
// name: "DispatchWaybillList",
components: {
EmisMonthpayAccountPicker,
elDateAdvPicker,emisWaybillForm,
CountryPicker1,
CountryPicker2,ProvincePicker2,
TransLinePicker,TransProductPicker,
PayeePicker,
SalemanPicker,
EmisUserSimplePicker0,
EmisUserSimplePicker1,
EmisUserSimplePicker2,
EmisSiteSimplePicker1,
EmisSiteSimplePicker2,
ProblemTypePicker
},
dicts: ['emis_qujian_fangshi','emis_declare_mode','emis_customs_clear',
'emis_tab_packing_type','emis_tab_dispatch_mode','emis_payment_type',
'emis_calc_fee_type','emis_print_type','emis_payment_status','emis_waybill_status','emis_tab_dispatch_mode'
],
data() {
return {
tableHeight: 200,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 创建时间搜索
dateTimeRange:[],
// 总条数
total: 0,
// 运单列表表格数据
emisWaybillList: [],
currentId:null,
openForm: false,
titleForm: "",
billCode:null,
queryOrderType:null,
queryOrderDateType:null,
queryExpireNotSign:null,
// 弹出展示层
id:null,
titleView:"",
openView: false,
// 更新网点时间范围
daterangeOrderDate: [],
// 更新网点时间范围
daterangeEstimateDate: [],
// 更新网点时间范围
daterangePickStartDate: [],
// 更新网点时间范围
daterangePickFinishDate: [],
// 更新网点时间范围
daterangeDispFdDate: [],
// 更新网点时间范围
daterangeRegisterDate: [],
// 更新网点时间范围
daterangeSendDate: [],
// 更新网点时间范围
daterangeProduceBillDate: [],
// 更新网点时间范围
daterangeCreateTime: [],
// 更新网点时间范围
daterangeUpdateTime: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 20,
orderSn: null,
billCode: null,
billCodeSub: null,
orderStatus: null,
waybillStatus: null,
orderType: null,
orderDate: null,
customerCode: null,
customerName: null,
receiveCustomerCode: null,
receiveCustomerName: null,
thirdCustomerCode: null,
thirdCustomerName: null,
receiveName: null,
receiveCompany: null,
receiveMobile: null,
receiveTel: null,
receiveCountry: null,
receiveProvince: null,
receiveCity: null,
receiveCounty: null,
receiveTown: null,
receiveAddress: null,
receivePostcode: null,
receivePcd: null,
sendName: null,
sendCompany: null,
sendMobile: null,
sendTel: null,
sendCountry: null,
sendProvince: null,
sendCity: null,
sendCounty: null,
sendTown: null,
sendAddress: null,
sendPostcode: null,
sendPcd: null,
paymentType: null,
calcFeeType: null,
custNo: null,
transLineType: null,
productType: null,
timeType: null,
meterType: null,
customsClear: null,
customsEclaration: null,
estimateDate: null,
packType: null,
dispatchMethod: null,
pickupMethod: null,
pickStartDate: null,
pickFinishDate: null,
pickFailReason: null,
intoWarehouseCode: null,
intoWarehouseName: null,
intoWarehouseAddress: null,
intoWarehouseContact: null,
intoWarehousePhone: null,
intoWarehouseBillCode: null,
warehouseInNo: null,
customerDeliveryBeginTime: null,
customerDeliveryEndTime: null,
goodsType: null,
goodsInfo: null,
goodsPics: null,
blPrepareInFreight: null,
prepareInEstFee: null,
prepareInRealFee: null,
prepareInExpress: null,
prepareInBillCode: null,
prepareInRemark: null,
prepareInSupplier: null,
totalWeight: null,
totalVolume: null,
parcelQty: null,
billWeight: null,
volumeWeight: null,
currency: null,
settlementWeight: null,
feeWeight: null,
freight: null,
blOverLong: null,
blBill: null,
blOverWeight: null,
overWeightNumber: null,
feeRemaker: null,
thirdCode: null,
realValue: null,
blInsure: null,
insureValue: null,
insureValueCurrency: null,
insureFeeCurrency: null,
insureFee: null,
insureRemark: null,
insureSiteCode: null,
insureDate: null,
blPrint: null,
printManCode: null,
printSite: null,
printDate: null,
printCount: null,
blDispFd: null,
transferCode: null,
transferBillcode: null,
dispFdDate: null,
dispFdReason: null,
currentSiteCode: null,
lastSiteCode: null,
registerSiteCode: null,
registerDate: null,
registerManCode: null,
takePieceEmployeeCode: null,
sendSiteCode: null,
sendDate: null,
dispatchManCode: null,
dispatchDate: null,
dispatchSiteCode: null,
produceBillDate: null,
produceBillSiteCode: null,
produceBillManCode: null,
destinationCode: null,
destinationProvince: null,
destinationCity: null,
destinationCounty: null,
dispatchUnderlingSiteCode: null,
destinationCenterCode: null,
marketManCode: null,
payee: null,
salesmen: null,
operateEmployeeCode: null,
blIsQuestion: null,
problemType: null,
problemCause: null,
problemDelayDays: null,
blMessage: null,
blAcceptMessage: null,
blGenSubbill: null,
signMan: null,
signManCode: null,
signSiteCode: null,
signDate: null,
billPicSendRmk: null,
billPicDispatchRmk: null,
timezoneOffset: null,
delFlag: null,
remark: null,
params:{
signStatus:null,
expireNotSign:null,
problemQueryType:null,
}
},
};
},
created() {
const end = new Date()
const start = new Date()
start.setHours(0,0,0,0)
end.setHours(23,59,59,0)
this.dateTimeRange=[start,end];
this.getList();
this.queryOrderType="1";
this.queryOrderDateType="1";
// this.queryExpireNotSign="1"
// 调整表格的高度,不允许滚动
this.$nextTick(function() {
let queryFormEl = this.$refs.queryForm.$el;
let tableH = queryFormEl.offsetHeight+190;
this.tableHeight = window.innerHeight - tableH;
});
},
mounted() {
const end = new Date()
const start = new Date()
start.setHours(0,0,0,0)
end.setHours(23,59,59,0)
this.dateTimeRange=[start,end];
},
methods: {
/** 查询运单列表列表 */
getList() {
this.loading = true;
let queryParams=deepClone(this.queryParams);
// this.queryOrderType="1";
// this.queryOrderDateType="1";
if(queryParams.billCode){
if(this.queryOrderType != "1"){
queryParams.orderSn=formatSearchStr(queryParams.billCode);
queryParams.billCode=null;
}else{
// 处理子单号
let qBillCode=formatSearchStr(queryParams.billCode);
let billArr = qBillCode.split(",");
let newBillCodeStr="";
billArr.forEach(item=>{
if(item.startsWith("T")){
let mainBillCode=item.substr(0,14);
newBillCodeStr=newBillCodeStr+mainBillCode+",";
}else{
newBillCodeStr=newBillCodeStr+item+",";
}
});
queryParams.billCode=newBillCodeStr;
}
}
if(this.dateTimeRange&&this.dateTimeRange.length==2){
let startDate = new Date(this.dateTimeRange[0]);
let endDate= new Date(this.dateTimeRange[1]);
startDate=dateToStr(startDate);
endDate=dateToStr(endDate)
if(this.queryOrderDateType != "1"){
queryParams.params["beginCreateTime"] = startDate;
queryParams.params["endCreateTime"] = endDate;
}else{
queryParams.params["beginSendDate"] = startDate;
queryParams.params["endSendDate"] = endDate;
}
}
console.log(queryParams);
listEmisWaybill(queryParams).then(response => {
this.emisWaybillList = response.rows;
this.total = response.total;
this.loading = false;
});
},
onDateSelect(value){
this.dateTimeRange=value;
// scanDate
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
if(selection!=null){
this.billCode=selection[0].billCode;
}
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
// 排序 查询字段是表格中字段名字 动态取值排序顺序
handleSortChange(column) {
this.queryParams.orderByColumn = column.prop;
this.queryParams.isAsc = column.order;
this.getList();
},
/** 新增按钮操作 */
handleAdd(row) {
// <router-link :to="'/waybillManagement/waybillEntry?billCode=' + scope.row.billCode" class="link-type">
this.$router.push({ path: '/d24/waybillManagement/WaybillEntry', query: { action:"add"} });
},
/** 修改按钮操作 */
handleUpdate(row) {
// const waybill = this.emisWaybillList.find(item => item.id === id)
this.$router.push({ path: '/d24/waybillManagement/WaybillModify', query: { action:"modify",billCode: this.billCode }})
},
handleView(row) {
this.$router.push({ path: '/d24/waybillManagement/WaybillDetail', query: { billCode: this.billCode }})
},
handleFormChanged(){
this.openForm = false;
this.getList();
},
cancelForm(){
this.openForm = false;
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除').then(function() {
return delEmisWaybill(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
// this.download('emis/emisWaybill/export', {
// ...this.queryParams
// }, `emisWaybill_${new Date().getTime()}.xlsx`)
const loadingInstance = this.$loading({
text: '正在导出...'
})
var qParam = {...this.queryParams};
qParam.pageNum=1;
qParam.pageSize=5000;
listEmisWaybill(this.addDateRange(qParam, this.dateTimeRange)).then(response => {
this.downloadLoading = false
if (response.code === 200) {
const curList = response.rows
import('@/vendor/Export2Excel').then(excel => {
const tHeader = ['id','订单号','客户单号,合同号','运单号','子单号,逗号隔开','订单状态','运单状态','订单类型','下单时间','客户ID','客户编号2502021','客户名称','收件客户编号2502021','收件客户客户名称','第三方客户客户编号','第三方客户客户名称','wx','收货人名','收货公司','收货人手机号','收货人电话','收货人国家','省','市','区','县','收货地址','邮编','寄件人省市区名称,逗号分隔','寄件人名','寄件公司','寄件人手机号','寄件人电话','寄件人国家','寄件省','寄件市','寄件区','寄件县','寄件地址','寄件邮编','发件人省市区名称,逗号分隔','支付方式','计费方式','支付月结编号','快递线路','快递产品类型','时效','计泡比例','清关方式','报关方式','预计到达时间','包装类型','派件方式:1-送货上门','取件方式:1-上门取件','预计上门取件开始时间','预计上门取件结束时间','取货失败原因','入仓代码','入仓名称','入仓地址','入仓联系人','入仓联系人电话','入仓单号','实际进仓单关联','客户发货开始时间','客户发货截止时间','货物大类','货物描述','货物图片,逗号隔开','预入仓代垫运费','预入仓代垫运费','预入仓实际运费','预入仓快递公司','预入仓快递单号','预入仓自定义标识','预入仓供应商','总重量','总体积','件数','实际重量','体积重量','费用币种','结算重量','计费重量','运费','是否超长','是否出账','账单备注','是否超重','超重重量','费用备注','三段码','实际货值','是否投保','投保货值','投保货值币种','保费币种','保费','保险备注','保险站点代码','投保日期','是否打印','打印人编号','打印站点','打印时间','打印次数','是否同行转单','转单代码','转单单号','转单时间','转单原因','当前网点编号','下一网点编号','上一网点点号','寄件站点代码','寄件日期','寄件人编号','取件员代码','发件网点代码','发货时间','派件人代码','派件时间','派件网点代码','生成账单时间','生成账单站点代码','生成账单人代码','目的地编号','目的省','目的城市','目的国家','目的地网点代码','目的地财务中心代码','业务人代码','销售回款人','销售联系人','操作员代码','是否问题件','问题件类型','问题件原因','问题件延期天数','是否备注消息','是否发送收件人短信','是否生成子单','签收人','签收人代码','签收站点代码','签收时间','揽收图片备注','签收底单图片','时区偏差','删除标志(0代表存在','创建者','创建时间','更新者','更新时间','备注','创建网点','更新网点',];
const filterVal = ['id','orderSn','custOrderId','billCode','billCodeSub','orderStatus','waybillStatus','orderType','orderDate','userId','customerCode','customerName','receiveCustomerCode','receiveCustomerName','thirdCustomerCode','thirdCustomerName','openId','receiveName','receiveCompany','receiveMobile','receiveTel','receiveCountry','receiveProvince','receiveCity','receiveCounty','receiveTown','receiveAddress','receivePostcode','receivePcd','sendName','sendCompany','sendMobile','sendTel','sendCountry','sendProvince','sendCity','sendCounty','sendTown','sendAddress','sendPostcode','sendPcd','paymentType','calcFeeType','custNo','transLineType','productType','timeType','meterType','customsClear','customsEclaration','estimateDate','packType','dispatchMethod','pickupMethod','pickStartDate','pickFinishDate','pickFailReason','intoWarehouseCode','intoWarehouseName','intoWarehouseAddress','intoWarehouseContact','intoWarehousePhone','intoWarehouseBillCode','warehouseInNo','customerDeliveryBeginTime','customerDeliveryEndTime','goodsType','goodsInfo','goodsPics','blPrepareInFreight','prepareInEstFee','prepareInRealFee','prepareInExpress','prepareInBillCode','prepareInRemark','prepareInSupplier','totalWeight','totalVolume','parcelQty','billWeight','volumeWeight','currency','settlementWeight','feeWeight','freight','blOverLong','blBill','blBillText','blOverWeight','overWeightNumber','feeRemaker','thirdCode','realValue','blInsure','insureValue','insureValueCurrency','insureFeeCurrency','insureFee','insureRemark','insureSiteCode','insureDate','blPrint','printManCode','printSite','printDate','printCount','blDispFd','transferCode','transferBillcode','dispFdDate','dispFdReason','currentSiteCode','nextSiteCode','lastSiteCode','registerSiteCode','registerDate','registerManCode','takePieceEmployeeCode','sendSiteCode','sendDate','dispatchManCode','dispatchDate','dispatchSiteCode','produceBillDate','produceBillSiteCode','produceBillManCode','destinationCode','destinationProvince','destinationCity','destinationCounty','dispatchUnderlingSiteCode','destinationCenterCode','marketManCode','payee','salesmen','operateEmployeeCode','blIsQuestion','problemType','problemCause','problemDelayDays','blMessage','blAcceptMessage','blGenSubbill','signMan','signManCode','signSiteCode','signDate','billPicSendRmk','billPicDispatchRmk','timezoneOffset','delFlag','createBy','createTime','updateBy','updateTime','remark','createSite','updateSite',];
const data = this.formatJson(filterVal, curList, response.rows)
excel.export_json_to_excel({
header: tHeader,
data,
filename: '运单列表',
autoWidth: true
})
loadingInstance.close()
})
}
});
},
formatJson(filterVal, jsonData, resData) {
let index = 0
return jsonData.map(v => filterVal.map(j => {
if (j === 'index') {
return ++index
}
if (j === 'status') {
var statusStr='xxx'
if(v[j] == 10){
statusStr='xxx'
}
return statusStr;
}
return v[j]
}))
},
/** 列索引函数 */
getIndex($index) {
return (this.queryParams.pageNum - 1) * this.queryParams.pageSize + $index + 1
},
/** 时间搜索响应函数 */
dateTimeChange(value){
this.dateTimeRange=value;
},
}
};
</script>
<style lang="scss" scoped>
:deep .el-form-item__label-wrap {
margin-left: 0 !important;
}
.el-divider{
margin-top: 0px;
background: 0 0;
border-top: 1px solid #E6EBF5;
}
.el-divider__text {
color: #0955ee;
cursor: pointer;
}
.query-label {
.el-radio{
display: block;
line-height: 23px;
white-space: normal;
margin-right: 0;
}
}
.queryForm .el-form-item {
margin-bottom: 0px !important;
}
</style>

View File

@ -138,7 +138,7 @@
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<TanexPrinterPanel ref="tanexPrinter" :isShowPinters="true" :isShowTpl="true" :isInitA4="true" :isShowSubBillRange="true" @onPrint="handleBatchPrint"></TanexPrinterPanel> <TanexPrinterPanel ref="tanexPrinter" :isShowPinters="false" :isShowTpl="false" :isInitA4="true" :isShowSubBillRange="false" @onPrint="handleBatchPrint"></TanexPrinterPanel>
</el-col> </el-col>