You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

206 lines
6.3 KiB
Vue

2 years ago
<template>
<view class="Big">
<view id="page">
<!-- 导航栏 -->
<view v-if="showPop">
<view >
<text class="font-sm text-secondary px-3 py-2">ilsApi地址</text>
<input type="text" class="font-md border bg-white px-3" placeholder="请填写ilsApi地址" style="height: 100rpx;" v-model="ilsApi"/>
</view>
<view >
<text class="font-sm text-secondary px-3 py-2">打印机IP</text>
<input type="text" class="font-md border bg-white px-3" placeholder="请填写ilsApi地址" style="height: 100rpx;" v-model="printIp"/>
</view>
<view >
<button class="systemSty" @tap="cancelAdd"></button>
<button class="systemSty" @tap="confirmAdd"></button>
</view>
</view>
当前单号:
2 years ago
<text class="nameSty">{{codes}}</text>
<button v-if="!showPop" @click="pdaSystemInit()" class="systemSty">PDA</button>
<button v-if="codes" @click="doPrinter(codes)" class="nameSty"></button>
2 years ago
</view>
<scan-code></scan-code>
2 years ago
</view>
</template>
<script>
import scanCode from "@/components/scan-code/scan-code.vue";
import { getCLodop } from '@/common/print/CLodopfuncs.js';
const printPdf = uni.requireNativePlugin('YanYu-PrintPDF');
2 years ago
export default {
data() {
return {
codes: undefined,
showPop: false,
httpRoot: 'http://',
ilsApi: '192.168.1.56:9090',
2 years ago
printIp: '192.168.1.26',
onLoad(option) {
this.$broadcastScan.init(this.getScancode);
},
onUnload() {
this.$broadcastScan.stop();
},
onHide() {
this.$broadcastScan.stop();
},
onShow() {
this.$broadcastScan.start();
}
}
},
methods: {
pdaSystemInit: function(){
this.showPop = true;
},
confirmAdd() {
//确认
this.showPop = false;
console.log("ilsApi:", this.ilsApi);
console.log("printIp:", this.printIp);
},
cancelAdd() {
//取消
this.ilsApi = '';
this.printIp = '';
this.showPop = false;
},
// 打印
2 years ago
doPrinter: function(orderCoder) {
this.showPop = false;
console.log("doPrinter orderCoder: " + orderCoder);
console.log("ilsApi:", this.ilsApi);
console.log("printIp:", this.printIp);
2 years ago
// LODOP.PRINT_INIT(null, "192.168.1.26");
// LODOP.SET_PRINTER_INDEX(-1);
// LODOP.PRINT_INITA(0, 0, "100mm", "150mm", "100X150");
// LODOP.SET_PRINT_PAGESIZE(1, "100mm", "150mm", "");
// LODOP.SET_PRINT_MODE("POS_BASEON_PAPER", true);
// //LODOP.ADD_PRINT_HTM(10, 20, "100mm", "150mm", "<img src="+this.imageData+" style=\"width: 100mm; height: 100mm;\"/>");
// LODOP.ADD_PRINT_PDF(0, 0, "100mm", "150mm", this.imgePdfData);
// LODOP.PRINT();
2 years ago
uni.request({
url: this.httpRoot + this.ilsApi + '/jeecg-boot/front/getOrderPayStateAndPdfBase64?OrderId=' + orderCoder,
2 years ago
method: 'GET',
success: (res) => {
console.log( res.data.result);
if(res.data.code==200){
let LODOP = getCLodop();
2 years ago
LODOP.PRINT_INIT(null, this.printIp);
LODOP.SET_PRINTER_INDEX(-1);
LODOP.PRINT_INITA(2, 0, "100mm", "150mm", "100X150");
LODOP.SET_PRINT_PAGESIZE(1, "100mm", "150mm", "");
LODOP.SET_PRINT_MODE("POS_BASEON_PAPER", true);
// LODOP.ADD_PRINT_HTM(2, 0, "100mm", "150mm", "<img src="+ this.imgBase64Root + res.data.message+" style=\"width: 100mm; height: 100mm;\"/>");
LODOP.ADD_PRINT_PDF(0, 0, "100mm", "150mm", res.data.result);
2 years ago
LODOP.PRINT();
uni.showToast({
title: '面单下发成功.正在打印,请稍候...',
icon: 'none',
duration: 3000
2 years ago
});
}else{
uni.showToast({
title: res.data.message,
2 years ago
icon: 'none',
duration: 3000
2 years ago
})
}
},
fail: (error) => {
2 years ago
uni.showToast({
title: '接口访问异常,打印失败',
2 years ago
icon: 'none',
duration: 3000
2 years ago
})
},
});
},
onShow: function() {
var _this = this;
2 years ago
uni.$off('scancodedate'); // 每次进来先 移除全局自定义事件监听器
uni.$on('scancodedate', function(data) {
console.log('你想要的code', data.code);
_this.codes = data.code;
this.showPop = false;
let orderCoder = data.code;
console.log("onShow orderCoder: " + orderCoder);
console.log("ilsApi:", _this.ilsApi);
console.log("printIp:", _this.printIp);
//orderCoder = "SF1642682535344";
uni.request({
url: _this.httpRoot + _this.ilsApi + '/jeecg-boot/front/getOrderPayStateAndPdfBase64?OrderId=' + orderCoder,
method: 'GET',
success: (res) => {
console.log( res.data.result);
if(res.data.code==200){
let LODOP = getCLodop();
LODOP.PRINT_INIT(null, _this.printIp);
LODOP.SET_PRINTER_INDEX(-1);
LODOP.PRINT_INITA(2, 0, "100mm", "150mm", "100X150");
LODOP.SET_PRINT_PAGESIZE(1, "100mm", "150mm", "");
LODOP.SET_PRINT_MODE("POS_BASEON_PAPER", true);
// LODOP.ADD_PRINT_HTM(2, 0, "100mm", "150mm", "<img src="+ this.imgBase64Root + res.data.message+" style=\"width: 100mm; height: 100mm;\"/>");
LODOP.ADD_PRINT_PDF(0, 0, "100mm", "150mm", res.data.result);
LODOP.PRINT();
uni.showToast({
title: '下发成功.正在打印,请稍候...',
icon: 'none',
duration: 3000
});
}else{
uni.showToast({
title: res.data.message,
icon: 'none',
duration: 3000
})
}
},
fail: (error) => {
console.log("error: ", error);
uni.showToast({
title: '接口访问异常,打印失败',
icon: 'none',
duration: 3000
})
},
});
2 years ago
})
},
getScancode(code) {
// 有些PDA会自带换行符trim函数处理下
code = code.trim()
//code就是扫描获取的值
console.log(code)
},
printPdf() {
// 有些PDA会自带换行符trim函数处理下
printPdf.managerPrint("D:\LeStoreDownload\EXP-LHJ1239002405-3676E4041337.pdf");
}
}
}
</script>
<style>
.Big{
width: 220px;
margin: 200px 100px;
}
.nameSty{
height: 30px;
width: 220px !important;
line-height: 30px;
font-size: 18px;
font-weight: bold;
color: #828282 !important;
}
/deep/.u-size-default,/deep/.uni-input-input{
font-size: 18px;
}
</style>