|
|
@@ -40,7 +40,8 @@
|
|
|
<span style="margin-left: 30px" v-if="wave.updateTime">{{wave.updateTime}}</span>
|
|
|
</div>
|
|
|
<el-button size="small" @click="generatePdfCombinationBatch" :disabled="wave.productionStatus == 0" :loading="wavePrintOrderPdfDownloadLoading">批量生成PDF</el-button>
|
|
|
- <el-button size="small" @click="downloadPdfBatch" :disabled="wave.productionStatus == 0" :loading="wavePrintOrderPdfDownloadLoading">批量下载ZIP</el-button>
|
|
|
+<!-- <el-button size="small" @click="downloadPdfBatch" :disabled="wave.productionStatus == 0" :loading="wavePrintOrderPdfDownloadLoading">批量下载ZIP</el-button>-->
|
|
|
+ <el-button size="small" @click="mergeAndDownloadPDF" :disabled="wave.productionStatus == 0" :loading="wavePrintOrderPdfDownloadLoading">合并PDF并下载</el-button>
|
|
|
<!-- <el-button size="small" @click="downloadPrintOrderPdfZip" :disabled="wave.productionStatus == 0" :loading="wavePrintOrderPdfDownloadLoading">批量下载PDF</el-button>-->
|
|
|
<el-button size="small" :loading="wavePrintOrderInfoDownloadLoading" @click="downloadWavePrintOrderInfo" :disabled="wave.productionStatus == 0">下载订单信息</el-button>
|
|
|
<el-button size="small" @click="openScanDialog" :disabled="wave.productionStatus == 0">扫描发货</el-button>
|
|
|
@@ -77,9 +78,9 @@
|
|
|
</el-form>
|
|
|
</template>
|
|
|
</el-table-column>-->
|
|
|
- <el-table-column
|
|
|
- type="selection">
|
|
|
- </el-table-column>
|
|
|
+<!-- <el-table-column-->
|
|
|
+<!-- type="selection">-->
|
|
|
+<!-- </el-table-column>-->
|
|
|
<el-table-column
|
|
|
align="center"
|
|
|
prop="serialNo"
|
|
|
@@ -251,7 +252,7 @@
|
|
|
@size-change="handleSizeChange"
|
|
|
@current-change="handleCurrentChange"
|
|
|
:current-page="page.currentPage"
|
|
|
- :page-sizes="[61, 122]"
|
|
|
+ :page-sizes="[61, 200, 400, 600]"
|
|
|
:page-size="page.pageSize"
|
|
|
layout="total, sizes, prev, pager, next, jumper"
|
|
|
:total="page.total">
|
|
|
@@ -298,6 +299,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+ import {PDFDocument} from 'pdf-lib';
|
|
|
import ProdPic from '@/components/prod-pic';
|
|
|
import InputNumberRange from '@/components/input-number-range';
|
|
|
import ExpressBillUpload from './express-bill-upload';
|
|
|
@@ -633,17 +635,18 @@
|
|
|
})
|
|
|
},
|
|
|
generatePdfCombinationBatch(){
|
|
|
- if(this.dataListSelections.size == 0){
|
|
|
- this.$message.error("请至少选择一个订单");
|
|
|
- return ;
|
|
|
- }
|
|
|
+ // if(this.dataListSelections.size == 0){
|
|
|
+ // this.$message.error("请至少选择一个订单");
|
|
|
+ // return ;
|
|
|
+ // }
|
|
|
this.$confirm('确定要批量生成PDF吗?', '提示', {
|
|
|
confirmButtonText: '确定',
|
|
|
cancelButtonText: '取消',
|
|
|
type: 'warning'
|
|
|
}).then(() => {
|
|
|
- let orderNumberList = this.dataListSelections.map(item=>item['orderNumber'])
|
|
|
- let dataBody = {"printChannel": this.printChannel, "waveId": this.wave.waveId, orderNumberList: orderNumberList};
|
|
|
+ // let orderNumberList = this.dataListSelections.map(item=>item['orderNumber'])
|
|
|
+ // let dataBody = {"printChannel": this.printChannel, "waveId": this.wave.waveId, orderNumberList: orderNumberList};
|
|
|
+ let dataBody = {"printChannel": this.printChannel, "waveId": this.wave.waveId};
|
|
|
this.$http({
|
|
|
url: this.$http.adornUrl('/printOrder/printOrder/generatePdfCombinationBatch'),
|
|
|
method: 'post',
|
|
|
@@ -677,7 +680,6 @@
|
|
|
type: 'application/zip'
|
|
|
})
|
|
|
saveAs(blob, fileName)
|
|
|
- // downloadZip(data, fileName + ".zip");
|
|
|
}).catch((error) => {
|
|
|
this.wavePrintOrderPdfDownloadLoading = false;
|
|
|
})
|
|
|
@@ -712,6 +714,23 @@
|
|
|
xmlhttp.send();
|
|
|
});
|
|
|
},
|
|
|
+ getPdfFile2 (url) {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ try {
|
|
|
+ let xmlhttp = new XMLHttpRequest();
|
|
|
+ xmlhttp.open("GET", url, true);
|
|
|
+ xmlhttp.responseType = "arraybuffer";
|
|
|
+ xmlhttp.onload = function () {
|
|
|
+ if (this.status == 200) {
|
|
|
+ resolve(this.response);
|
|
|
+ }else{
|
|
|
+ reject(this.status);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ xmlhttp.send();
|
|
|
+ } catch (ignored) {}
|
|
|
+ });
|
|
|
+ },
|
|
|
downloadPdfBatch () {
|
|
|
if(this.dataListSelections.size == 0){
|
|
|
this.$message.error("请至少选择一个订单");
|
|
|
@@ -752,6 +771,112 @@
|
|
|
});
|
|
|
},
|
|
|
|
|
|
+ /*//合并并下载PDF
|
|
|
+ async mergeAndDownloadPDF(){ // urlList 单个PDF文件的URL
|
|
|
+ try{
|
|
|
+ this.wavePrintOrderPdfDownloadLoading = true;
|
|
|
+ // 获取pdf链接集合
|
|
|
+ this.getPrintPdfBatch().then(async (list)=>{
|
|
|
+ let pdfUrlList = [];
|
|
|
+ for(let i=0 ; i <list.length; i++){
|
|
|
+ let pdfList = list[i].pdfList;
|
|
|
+ for(let j=0 ; j <pdfList.length; j++){
|
|
|
+ pdfUrlList.push(this.resourcesUrl + pdfList[j].pdfUrl);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let promises = [];
|
|
|
+ pdfUrlList.forEach(url =>{
|
|
|
+ let promise = this.getPdfFile2(url);
|
|
|
+ promises.push(promise);
|
|
|
+ })
|
|
|
+ let pdfBuffers = await Promise.all(promises);
|
|
|
+ let newPdf = await PDFDocument.create();
|
|
|
+ for (let k=0 ; k<pdfBuffers.length; k++) {
|
|
|
+ let pdfDocument = await PDFDocument.load(pdfBuffers[k]);
|
|
|
+ let contentPages = await newPdf.copyPages(pdfDocument, pdfDocument.getPageIndices());
|
|
|
+ for (let l=0; l<contentPages.length; l++) {
|
|
|
+ newPdf.addPage(contentPages[l]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let uint8Array = await newPdf.save();
|
|
|
+ let mergeBuffer = Buffer.from(uint8Array);
|
|
|
+ downloadPdf(mergeBuffer, this.wave.waveNo + "_" + this.wave.waveName + ".pdf");
|
|
|
+ this.wavePrintOrderPdfDownloadLoading = false;
|
|
|
+ });
|
|
|
+ }catch (error) {
|
|
|
+ this.wavePrintOrderPdfDownloadLoading = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ },*/
|
|
|
+
|
|
|
+ //合并并下载PDF
|
|
|
+ async mergeAndDownloadPDF(){ // urlList 单个PDF文件的URL
|
|
|
+ try{
|
|
|
+ this.wavePrintOrderPdfDownloadLoading = true;
|
|
|
+ // 获取pdf链接集合
|
|
|
+ this.getPrintPdfBatch().then(async (list)=>{
|
|
|
+ // let pdfUrlList = [];
|
|
|
+ let newPdf = await PDFDocument.create();
|
|
|
+ for(let i=0 ; i <list.length; i++){
|
|
|
+ let pdfList = list[i].pdfList;
|
|
|
+ for(let j=0 ; j <pdfList.length; j++){
|
|
|
+ // pdfUrlList.push(this.resourcesUrl + pdfList[j].pdfUrl);
|
|
|
+ let pdfBuffer = await this.getPdfFile2(this.resourcesUrl + pdfList[j].pdfUrl);
|
|
|
+ let pdfDocument = await PDFDocument.load(pdfBuffer);
|
|
|
+ let contentPages = await newPdf.copyPages(pdfDocument, pdfDocument.getPageIndices());
|
|
|
+ for (let l=0; l<contentPages.length; l++) {
|
|
|
+ newPdf.addPage(contentPages[l]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // let promises = [];
|
|
|
+ // pdfUrlList.forEach(url =>{
|
|
|
+ // let promise = this.getPdfFile2(url);
|
|
|
+ // promises.push(promise);
|
|
|
+ // })
|
|
|
+ // let pdfBuffers = await Promise.all(promises);
|
|
|
+ //
|
|
|
+ // for (let k=0 ; k<pdfBuffers.length; k++) {
|
|
|
+ // let pdfDocument = await PDFDocument.load(pdfBuffers[k]);
|
|
|
+ // let contentPages = await newPdf.copyPages(pdfDocument, pdfDocument.getPageIndices());
|
|
|
+ // for (let l=0; l<contentPages.length; l++) {
|
|
|
+ // newPdf.addPage(contentPages[l]);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ let uint8Array = await newPdf.save();
|
|
|
+ let mergeBuffer = Buffer.from(uint8Array);
|
|
|
+ downloadPdf(mergeBuffer, this.wave.waveNo + "_" + this.wave.waveName + ".pdf");
|
|
|
+ this.wavePrintOrderPdfDownloadLoading = false;
|
|
|
+ });
|
|
|
+ }catch (error) {
|
|
|
+ this.wavePrintOrderPdfDownloadLoading = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取打印订单的所有PDF文件
|
|
|
+ */
|
|
|
+ getPrintPdfBatch(){
|
|
|
+ // if(this.dataListSelections.size == 0){
|
|
|
+ // this.$message.error("请至少选择一个订单");
|
|
|
+ // return ;
|
|
|
+ // }
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ // 获取pdf链接集合
|
|
|
+ // let orderNumberList = this.dataListSelections.map(item=>item['orderNumber'])
|
|
|
+ this.$http({
|
|
|
+ url: this.$http.adornUrl(`/printOrder/printOrder/getPrintPdfBatch`),
|
|
|
+ method: 'POST',
|
|
|
+ // data: this.$http.adornData({printChannel: this.wave.printChannel, waveId: this.wave.waveId, orderNumberList: orderNumberList})
|
|
|
+ data: this.$http.adornData({printChannel: this.wave.printChannel, waveId: this.wave.waveId})
|
|
|
+ }).then(({ data }) => {
|
|
|
+ resolve(data);
|
|
|
+ });
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
// 跳转至导入选择
|
|
|
getUpload () {
|
|
|
this.uploadVisible = true
|