emis-app/pages/print/courierNote.vue

307 lines
9.9 KiB
Vue
Raw Normal View History

2023-12-30 15:28:01 +00:00
<template>
2024-05-09 09:34:27 +00:00
<tpx-page>
<tpx-layout>
<template v-slot:body>
2024-05-12 14:34:20 +00:00
<view class="pos-abt-all">
<tpx-scroll-view v-model:resObject="resData" :searchParam="searchParam" :getListFun="getListFun"
ref="listRef"
2024-05-09 09:34:27 +00:00
>
2024-05-12 14:34:20 +00:00
<view class="blcok-white-noradius" style="margin-top: 0;">
<u-row justify="between">
<view style="width: 140rpx;" class="font-weight">运单号</view>
<view style="flex:1;">
<tpx-scan-input v-model:value="searchParam.billCode" placeholder="请输入或扫码"
@change="handleScanValChange" iconPos="right"></tpx-scan-input>
2024-05-09 09:34:27 +00:00
</view>
2024-05-12 14:34:20 +00:00
</u-row>
<u-row justify="between" custom-style="margin-top:20rpx;">
<view style="width: 140rpx;" class="font-weight">下单时间</view>
<view style="flex:1;">
<tpx-date-input v-model:value="searchParam._date" placeholder="请选择时间"></tpx-date-input>
2024-05-09 09:34:27 +00:00
</view>
</u-row>
2024-05-12 14:34:20 +00:00
<u-row custom-style="margin-top:20rpx;" justify="end">
<u-row>
<text class="pr-30">是否已打印</text>
<u-switch v-model="searchParam.printFlag" activeValue="1" inactiveValue="0"
active-color="#B12D29" size="34"></u-switch>
</u-row>
</u-row>
<view class="mt-30">
<u-button type="primary" size="large" shape="square" plain="true" @click="handleSearch"
custom-style="height:80rpx;font-size: 30rpx;border-radius: 14rpx;">查询</u-button>
</view>
2024-05-09 09:34:27 +00:00
</view>
2024-05-12 14:34:20 +00:00
<view class="blcok-white-noradius">
2024-06-04 08:19:30 +00:00
<u-row justify="between" custom-style="padding-top:20rpx;">
<view class="com-section">打印配置</view>
2024-05-12 14:34:20 +00:00
</u-row>
2024-06-04 08:19:30 +00:00
<view class="clr-prm mt-20">注意:当打印出来寄件分拨或未端分拨返回为空时,请等待5分钟后再补 打印</view>
2024-05-12 14:34:20 +00:00
<view class="mt-20">
<u-checkbox-group v-model="submitParam.printType" placement="column">
<u-row custom-style="flex-wrap: wrap;">
<u-col span="6" v-for="(item, index) in dicData.emis_print_type">
2024-06-04 08:19:30 +00:00
<u-checkbox size="30" labelSize="30" label-color=":#999" activeColor="#B12D29"
:customStyle="{marginBottom: '20rpx'}"
2024-05-12 14:34:20 +00:00
:label="item.title" :name="item.val"
></u-checkbox>
</u-col>
</u-row>
</u-checkbox-group>
</view>
<u-row custom-style="margin-top:30rpx;">
<view style="width: 200rpx;" class="">子单打印区间</view>
<u-row>
<tpx-input customStyle="width:60rpx;" v-model:value="submitParam.subBillCodeRange[0]" :isWhite="true" placeholder="" type="number"></tpx-input>
<text class="pl-10 pr-10">到</text>
<tpx-input customStyle="width:60rpx;" v-model:value="submitParam.subBillCodeRange[1]" :isWhite="true" placeholder="" type="number"></tpx-input>
</u-row>
</u-row>
</view>
<view class="blcok-white-noradius">
<view class="pb-20 com-section">运单列表</view>
<view class="pb-20">
<u-row>
<u-col span="8">
<u-row @click="handleSelAll">
<view class="com-chk-icon">
<u-checkbox-group>
<u-checkbox size="26" labelSize="26" label-color=":#999" activeColor="#B12D29"
label="" :checked="resData.list.length > 0 && submitParam.billCode.length == resData.list.length"
></u-checkbox>
</u-checkbox-group>
</view>
<text class="font-weight pl-10">运单号</text>
</u-row>
</u-col>
<u-col span="4">
<text class="font-weight">下单时间</text>
</u-col>
</u-row>
</view>
<tpx-checkitems :list="resData.list" v-model:value="submitParam.billCode" v-slot="dlCurrent" type="multiple"
2024-05-22 17:06:55 +00:00
vdataType="array"
2024-05-12 14:34:20 +00:00
>
2024-05-12 16:49:19 +00:00
<view slot class="yditem">
2024-05-12 14:34:20 +00:00
<u-row>
<u-col span="8">
<u-row>
<view class="com-chk-icon">
<u-checkbox-group>
<u-checkbox size="26" labelSize="26" label-color=":#999" activeColor="#B12D29"
label="" :checked="dlCurrent.checked"
></u-checkbox>
</u-checkbox-group>
</view>
<text class="">{{dlCurrent.item.billCode}}</text>
</u-row>
</u-col>
<u-col span="4">
<text class="clr-sub">{{dlCurrent.item.sendDate}}</text>
</u-col>
</u-row>
</view>
</tpx-checkitems>
</view>
</tpx-scroll-view>
2024-05-09 09:34:27 +00:00
</view>
</template>
2024-05-12 14:34:20 +00:00
2024-05-09 09:34:27 +00:00
<template v-slot:footer>
<view class="blcok-white-noradius">
<u-row>
<u-button @click="handleSubmit()" type="primary" size="large" shape="square"
custom-style="height:80rpx;font-size: 30rpx;border-radius: 14rpx;margin: 0 10rpx;">打印</u-button>
</u-row>
</view>
</template>
</tpx-layout>
2024-05-12 12:49:00 +00:00
<tpx-bluetooth-print ref="curPrint"></tpx-bluetooth-print>
2024-05-09 09:34:27 +00:00
</tpx-page>
2023-12-30 15:28:01 +00:00
</template>
<script>
2024-05-09 09:34:27 +00:00
import { debounce } from "@/common/util"
import dayjs from "dayjs"
import * as apiService from "@/common/api"
2024-06-08 17:31:07 +00:00
import { checkParams } from "@/common/validate"
2023-12-30 15:28:01 +00:00
export default {
props: {
// hasLeftWin: {
// type: Boolean
// }
},
computed: {
2024-05-09 09:34:27 +00:00
dicData() {
return this.$store.getters.dicData
},
2023-12-30 15:28:01 +00:00
},
data() {
2024-05-09 09:34:27 +00:00
let { dicData } = this.$store.getters
2023-12-30 15:28:01 +00:00
return {
submitParam: {
2024-05-09 09:34:27 +00:00
lang: 'zh',
printType: [],
2024-05-12 14:34:20 +00:00
billCode: [],
2024-05-09 09:34:27 +00:00
subBillCodeRange: []
2023-12-30 15:28:01 +00:00
},
2024-06-08 17:31:07 +00:00
submitValidConfig: {
printType: { required: true, requiredMsg: '请勾选打印配' },
billCode: { required: true, requiredMsg: '请选择运单号' },
},
2023-12-30 15:28:01 +00:00
yinlTypeList: [
2024-05-09 09:34:27 +00:00
{ title: '中文', val: 'zh' },
{ title: '英文', val: 'en' },
2023-12-30 15:28:01 +00:00
],
2024-05-12 14:34:20 +00:00
searchParam: {
printFlag: '0',
billCode: '',
_date: [],
2024-06-21 04:55:51 +00:00
params: {}
2024-05-12 14:34:20 +00:00
},
2024-05-12 12:49:00 +00:00
resData: { list: [] }
2023-12-30 15:28:01 +00:00
}
},
onShareAppMessage() {
return {
}
},
onLoad() {
this.initData();
},
onUnload() {
},
methods: {
2024-05-12 14:34:20 +00:00
async getListFun(param){
let cpParam = JSON.parse(JSON.stringify(param))
2024-06-21 04:55:51 +00:00
cpParam.params.beginSendDate = cpParam._date[0]
cpParam.params.endSendDate = cpParam._date[1]
2024-05-12 14:34:20 +00:00
let res = await apiService.queryPrintListSimple(cpParam)
// list增加新字段
res.rows.map(t=> {
t.val = t.billCode
})
return res
},
2023-12-30 15:28:01 +00:00
initData() {
},
2024-05-09 09:34:27 +00:00
handleScanValChange: debounce(function(val){
}),
2024-05-12 14:34:20 +00:00
handleSearch(){
},
2024-05-11 05:11:46 +00:00
async handleSubmit() {
2024-06-04 08:19:30 +00:00
const imgUrls = await this.getPrintImages()
2024-05-12 12:49:00 +00:00
this.$refs.curPrint.startPrint({
2024-06-04 08:19:30 +00:00
imageUrl: imgUrls.filter(v=> !!v),
2024-05-12 12:49:00 +00:00
})
2023-12-30 15:28:01 +00:00
},
handleSelAll() {
2024-05-12 14:34:20 +00:00
if(this.submitParam.billCode.length == this.resData.list.length) {
this.submitParam.billCode = []
2023-12-30 15:28:01 +00:00
} else {
2024-05-12 14:34:20 +00:00
this.submitParam.billCode = this.resData.list.map(item=> item.val)
2023-12-30 15:28:01 +00:00
}
2024-05-09 09:34:27 +00:00
},
async getRealGetWaybillPrintData() {
2024-05-12 14:34:20 +00:00
// 请求后端接口
2024-05-09 09:34:27 +00:00
let param = JSON.parse(JSON.stringify(this.submitParam))
param.printType = param.printType.join(',')
2024-05-12 14:34:20 +00:00
param.billCode = param.billCode.join(',')
2024-05-09 09:34:27 +00:00
param.subBillCodeRange = param.subBillCodeRange.join(',')
2024-06-08 17:31:07 +00:00
await checkParams(param, this.submitValidConfig)
2024-05-11 05:17:59 +00:00
let res = await apiService.getRealGetWaybillPrintData({ ...param, _loading: true })
2024-05-11 05:11:46 +00:00
return res
2024-06-04 08:19:30 +00:00
},
async getPrintImages() {
let res = await this.getRealGetWaybillPrintData()
const imgUrls = res?.data?.map(t=> t.imageUrl) || []
return imgUrls
2023-12-30 15:28:01 +00:00
}
}
}
</script>
2024-06-05 06:09:00 +00:00
<script module="acceptance" lang="renderjs">
import { PDFDocument, StandardFonts } from "pdf-lib/dist/pdf-lib.esm.min"
export default {
mounted() {
// const script = document.createElement('script')
// // view 层的页面运行在 www 根目录,其相对路径相对于 www 计算
// script.src = 'static/js/jquery-3.1.1.min.js'
// script.onload = this.initEvent.bind(this, this.$ownerInstance)
// document.head.appendChild(script)
this.initEvent()
},
methods: {
async initEvent(ownerInstance) {
// 通过事件委托给按钮添加事件
// 添加事件前先清除事件避免重复绑定
// $(document).off("touchend")
// 新增
// $(document).on('touchend', '.add', function() {
// const wbsId = this.getAttribute('wbsId');
// const taskId = this.getAttribute('taskId');
// const taskName = this.getAttribute('taskName');
// // 调用 service 层的方法
// ownerInstance.callMethod('toAdd', {
// wbsId: wbsId,
// taskId: taskId,
// taskName: taskName
// })
// });
// Create a new PDFDocument
const pdfDoc = await PDFDocument.create()
// Embed the Times Roman font
const timesRomanFont = await pdfDoc.embedFont(StandardFonts.TimesRoman)
// Add a page and draw some text on it
const page = pdfDoc.addPage([500, 600])
page.setFont(timesRomanFont)
page.drawText('The Life of an Egg', { x: 60, y: 500, size: 50 })
page.drawText('An Epic Tale of Woe', { x: 125, y: 460, size: 25 })
// Set all available metadata fields on the PDFDocument. Note that these fields
// are visible in the "Document Properties" section of most PDF readers.
pdfDoc.setTitle('🥚 The Life of an Egg 🍳')
pdfDoc.setAuthor('Humpty Dumpty')
pdfDoc.setSubject('📘 An Epic Tale of Woe 📖')
pdfDoc.setKeywords(['eggs', 'wall', 'fall', 'king', 'horses', 'men'])
pdfDoc.setProducer('PDF App 9000 🤖')
pdfDoc.setCreator('pdf-lib (https://github.com/Hopding/pdf-lib)')
pdfDoc.setCreationDate(new Date('2018-06-24T01:58:37.228Z'))
pdfDoc.setModificationDate(new Date('2019-12-21T07:00:11.000Z'))
// Serialize the PDFDocument to bytes (a Uint8Array)
const pdfBytes = await pdfDoc.save()
console.log("=========pdfBytes============", pdfBytes)
},
}
}
</script>
2023-12-30 15:28:01 +00:00
<style lang="scss">
@import '@/common/uni-nvue.scss';
page {
background-color: #F6F6F6;
height: 100% !important;
}
</style>
<style scoped lang="scss">
.ddhao {
2024-05-12 14:34:20 +00:00
}
.yditem{
padding: 20rpx 0;
border-top: 2px solid #F6F6F6;
2023-12-30 15:28:01 +00:00
}
</style>