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.

211 lines
5.6 KiB
Vue

2 years ago
<template>
<view class="Big">
<view id="page">
<!-- 导航栏 -->
<view v-if="showPop">
<view >
2 years ago
<text class="font-sm text-secondary px-3 py-2">ilsApi地址IP+端口</text>
<input type="text" class="font-md border bg-white px-3" placeholder="请填写ilsApi地址IP+端口" style="height: 100rpx;" v-model="ilsApi"/>
</view>
<view >
2 years ago
<text class="font-sm text-secondary px-3 py-2">打印机地址IP</text>
<input type="text" class="font-md border bg-white px-3" placeholder="请填写打印机地址IP" style="height: 100rpx;" v-model="printIp"/>
</view>
<view >
<text class="font-sm text-secondary px-3 py-2">打印机名称</text>
<input type="text" class="font-md border bg-white px-3" placeholder="请填写打印机名称" style="height: 100rpx;" v-model="printName"/>
</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";
2 years ago
// import { getCLodop } from '@/common/print/CLodopfuncs.js';
// import { getPrinterList } from '@/common/print/CLodopfuncs.js';
2 years ago
const printPdf = uni.requireNativePlugin('YanYu-PrintPDF');
2 years ago
export default {
data() {
return {
codes: undefined,
showPop: false,
2 years ago
selectClassEnd:[],
httpRoot: 'http://',
ilsApi: '192.168.1.56:9090',
2 years ago
printIp: '192.168.1.56',
serviceApi: ':8080/ilsApp/print',
printName: 'Xprinter',
2 years ago
onLoad(option) {
this.$broadcastScan.init(this.getScancode);
},
onUnload() {
this.$broadcastScan.stop();
},
onHide() {
this.$broadcastScan.stop();
},
onShow() {
this.$broadcastScan.start();
}
}
},
methods: {
pdaSystemInit: function(){
2 years ago
this.showPop = true;
},
2 years ago
selectClass(event){
},
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
uni.request({
2 years ago
url: this.httpRoot + this.printIp + this.serviceApi,
method: 'POST',
data: {
ilsApi: this.ilsApi,
printIp: this.printIp,
orderId: orderCoder,
printName: this.printName
},
2 years ago
success: (res) => {
2 years ago
console.log( res);
2 years ago
if(res.data.code==200){
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;
2 years ago
_this.showPop = false;
let orderCoder = data.code;
console.log("onShow orderCoder: " + orderCoder);
console.log("ilsApi:", _this.ilsApi);
console.log("printIp:", _this.printIp);
2 years ago
console.log("serviceApi:", _this.httpRoot + _this.printIp + _this.serviceApi);
if(orderCoder.length>18){
//orderCoder = "SF1642682535344";
uni.request({
url: _this.httpRoot + _this.printIp + _this.serviceApi,
method: 'POST',
data: {
ilsApi: _this.ilsApi,
printIp: _this.printIp,
orderId: orderCoder,
printName: _this.printName
},
success: (res) => {
console.log( res);
if(res.data.code==200){
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({
2 years ago
title: '接口访问异常,打印失败',
icon: 'none',
duration: 3000
})
2 years ago
},
});
}else{
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>