Commit e3d7aab6 by 施宇

1

parent 894f2d5f
{"ignoreds":["node_modules/**/*","**/node_modules/**","**/.git/**",".git/**/*","**/.svn/**",".svn/**/*",".DS_Store","**/.DS_Store"],"folderInfo":{"./":{"mtimeMs":1588039958728.2603,"children":["app.js","app.json","app.wxss","project.config.json","sitemap.json"]},"pages/":{"mtimeMs":1588761186704.5857,"children":[]},"res/":{"mtimeMs":1587987929535.54,"children":[]},"res/css/":{"mtimeMs":1587468648224.7944,"children":["res/css/base.wxss"]},"res/img/":{"mtimeMs":1588153975467.2988,"children":["res/img/all-check-left-a.png","res/img/all-check-left.png","res/img/all-check-right-a.png","res/img/all-check-right.png","res/img/ck-icon-a.png","res/img/ck-icon.png","res/img/close-icon.png","res/img/kc-icon-a.png","res/img/kc-icon.png","res/img/login-img.png","res/img/login-text.png","res/img/nav-arrow-down.png","res/img/question-icon.png","res/img/search-icon.png","res/img/sh-icon-a.png","res/img/sh-icon.png","res/img/sigle-check-left-a.png","res/img/sigle-check-left.png","res/img/sigle-check-right-a.png","res/img/sigle-check-right.png","res/img/sj-icon-a.png","res/img/sj-icon.png","res/img/sz-icon-a.png","res/img/sz-icon.png","res/img/warn-icon.png"]},"utils/":{"mtimeMs":1588729595864.972,"children":["utils/api.js","utils/axios.js","utils/md5.js","utils/printerjobs.js","utils/textEncoding.js","utils/util.js"]},".git/":{"mtimeMs":1588838797639.358,"children":[]},".wechatide/":{"mtimeMs":1587519550088.0625,"children":[".wechatide/fileCache.cfg"]},"pages/home/":{"mtimeMs":1587536014892.4702,"children":["pages/home/home.js","pages/home/home.json","pages/home/home.wxml","pages/home/home.wxss"]},"pages/login/":{"mtimeMs":1587535974795.0686,"children":["pages/login/login.js","pages/login/login.json","pages/login/login.wxml","pages/login/login.wxss"]},"components/":{"mtimeMs":1587538211879.0247,"children":[]},"components/navC/":{"mtimeMs":1587538221287.4016,"children":["components/navC/navC.js","components/navC/navC.json","components/navC/navC.wxml","components/navC/navC.wxss"]},"pages/receivinggoods/":{"mtimeMs":1587538742321.587,"children":["pages/receivinggoods/receivinggoods.js","pages/receivinggoods/receivinggoods.json","pages/receivinggoods/receivinggoods.wxml","pages/receivinggoods/receivinggoods.wxss"]},"pages/upperShelf/":{"mtimeMs":1587622056930.153,"children":["pages/upperShelf/upperShelf.js","pages/upperShelf/upperShelf.json","pages/upperShelf/upperShelf.wxml","pages/upperShelf/upperShelf.wxss"]},"pages/outbound/":{"mtimeMs":1587626008346.8442,"children":["pages/outbound/outbound.js","pages/outbound/outbound.json","pages/outbound/outbound.wxml","pages/outbound/outbound.wxss"]},"pages/scanDelivery/":{"mtimeMs":1587627596586.3196,"children":["pages/scanDelivery/scanDelivery.js","pages/scanDelivery/scanDelivery.json","pages/scanDelivery/scanDelivery.wxml","pages/scanDelivery/scanDelivery.wxss"]},"pages/picking/":{"mtimeMs":1587631234329.3645,"children":["pages/picking/picking.js","pages/picking/picking.json","pages/picking/picking.wxml","pages/picking/picking.wxss"]},"pages/cardBoard/":{"mtimeMs":1587632724321.1174,"children":["pages/cardBoard/cardBoard.js","pages/cardBoard/cardBoard.json","pages/cardBoard/cardBoard.wxml","pages/cardBoard/cardBoard.wxss"]},"pages/changeWarehouse/":{"mtimeMs":1587635396534.957,"children":["pages/changeWarehouse/changeWarehouse.js","pages/changeWarehouse/changeWarehouse.json","pages/changeWarehouse/changeWarehouse.wxml","pages/changeWarehouse/changeWarehouse.wxss"]},"pages/systemSettings/":{"mtimeMs":1587637181028.4365,"children":["pages/systemSettings/systemSettings.js","pages/systemSettings/systemSettings.json","pages/systemSettings/systemSettings.wxml","pages/systemSettings/systemSettings.wxss"]},"pages/printer/":{"mtimeMs":1587637593187.5686,"children":["pages/printer/printer.js","pages/printer/printer.json","pages/printer/printer.wxml","pages/printer/printer.wxss"]},"pages/inventoryQuery/":{"mtimeMs":1587639536186.8396,"children":["pages/inventoryQuery/inventoryQuery.js","pages/inventoryQuery/inventoryQuery.json","pages/inventoryQuery/inventoryQuery.wxml","pages/inventoryQuery/inventoryQuery.wxss"]},"pages/startPage/":{"mtimeMs":1588045543126.067,"children":["pages/startPage/startPage.js","pages/startPage/startPage.json","pages/startPage/startPage.wxml","pages/startPage/startPage.wxss"]},"pages/mountingPlate/":{"mtimeMs":1588761190467.1958,"children":["pages/mountingPlate/mountingPlate.js","pages/mountingPlate/mountingPlate.json","pages/mountingPlate/mountingPlate.wxml","pages/mountingPlate/mountingPlate.wxss"]}},"cacheVersion":1} {"ignoreds":["node_modules/**/*","**/node_modules/**","**/.git/**",".git/**/*","**/.svn/**",".svn/**/*",".DS_Store","**/.DS_Store"],"folderInfo":{"./":{"mtimeMs":1588039958728.2603,"children":["app.js","app.json","app.wxss","project.config.json","sitemap.json"]},"pages/":{"mtimeMs":1588761186704.5857,"children":[]},"res/":{"mtimeMs":1587987929535.54,"children":[]},"res/css/":{"mtimeMs":1587468648224.7944,"children":["res/css/base.wxss"]},"res/img/":{"mtimeMs":1588153975467.2988,"children":["res/img/all-check-left-a.png","res/img/all-check-left.png","res/img/all-check-right-a.png","res/img/all-check-right.png","res/img/ck-icon-a.png","res/img/ck-icon.png","res/img/close-icon.png","res/img/kc-icon-a.png","res/img/kc-icon.png","res/img/login-img.png","res/img/login-text.png","res/img/nav-arrow-down.png","res/img/question-icon.png","res/img/search-icon.png","res/img/sh-icon-a.png","res/img/sh-icon.png","res/img/sigle-check-left-a.png","res/img/sigle-check-left.png","res/img/sigle-check-right-a.png","res/img/sigle-check-right.png","res/img/sj-icon-a.png","res/img/sj-icon.png","res/img/sz-icon-a.png","res/img/sz-icon.png","res/img/warn-icon.png"]},"utils/":{"mtimeMs":1588729595864.972,"children":["utils/api.js","utils/axios.js","utils/md5.js","utils/printerjobs.js","utils/textEncoding.js","utils/util.js"]},".git/":{"mtimeMs":1588929605569.4866,"children":[]},".wechatide/":{"mtimeMs":1587519550088.0625,"children":[".wechatide/fileCache.cfg"]},"pages/home/":{"mtimeMs":1587536014892.4702,"children":["pages/home/home.js","pages/home/home.json","pages/home/home.wxml","pages/home/home.wxss"]},"pages/login/":{"mtimeMs":1587535974795.0686,"children":["pages/login/login.js","pages/login/login.json","pages/login/login.wxml","pages/login/login.wxss"]},"components/":{"mtimeMs":1587538211879.0247,"children":[]},"components/navC/":{"mtimeMs":1587538221287.4016,"children":["components/navC/navC.js","components/navC/navC.json","components/navC/navC.wxml","components/navC/navC.wxss"]},"pages/receivinggoods/":{"mtimeMs":1587538742321.587,"children":["pages/receivinggoods/receivinggoods.js","pages/receivinggoods/receivinggoods.json","pages/receivinggoods/receivinggoods.wxml","pages/receivinggoods/receivinggoods.wxss"]},"pages/upperShelf/":{"mtimeMs":1587622056930.153,"children":["pages/upperShelf/upperShelf.js","pages/upperShelf/upperShelf.json","pages/upperShelf/upperShelf.wxml","pages/upperShelf/upperShelf.wxss"]},"pages/outbound/":{"mtimeMs":1587626008346.8442,"children":["pages/outbound/outbound.js","pages/outbound/outbound.json","pages/outbound/outbound.wxml","pages/outbound/outbound.wxss"]},"pages/scanDelivery/":{"mtimeMs":1587627596586.3196,"children":["pages/scanDelivery/scanDelivery.js","pages/scanDelivery/scanDelivery.json","pages/scanDelivery/scanDelivery.wxml","pages/scanDelivery/scanDelivery.wxss"]},"pages/picking/":{"mtimeMs":1587631234329.3645,"children":["pages/picking/picking.js","pages/picking/picking.json","pages/picking/picking.wxml","pages/picking/picking.wxss"]},"pages/cardBoard/":{"mtimeMs":1587632724321.1174,"children":["pages/cardBoard/cardBoard.js","pages/cardBoard/cardBoard.json","pages/cardBoard/cardBoard.wxml","pages/cardBoard/cardBoard.wxss"]},"pages/changeWarehouse/":{"mtimeMs":1587635396534.957,"children":["pages/changeWarehouse/changeWarehouse.js","pages/changeWarehouse/changeWarehouse.json","pages/changeWarehouse/changeWarehouse.wxml","pages/changeWarehouse/changeWarehouse.wxss"]},"pages/systemSettings/":{"mtimeMs":1587637181028.4365,"children":["pages/systemSettings/systemSettings.js","pages/systemSettings/systemSettings.json","pages/systemSettings/systemSettings.wxml","pages/systemSettings/systemSettings.wxss"]},"pages/printer/":{"mtimeMs":1587637593187.5686,"children":["pages/printer/printer.js","pages/printer/printer.json","pages/printer/printer.wxml","pages/printer/printer.wxss"]},"pages/inventoryQuery/":{"mtimeMs":1587639536186.8396,"children":["pages/inventoryQuery/inventoryQuery.js","pages/inventoryQuery/inventoryQuery.json","pages/inventoryQuery/inventoryQuery.wxml","pages/inventoryQuery/inventoryQuery.wxss"]},"pages/startPage/":{"mtimeMs":1588045543126.067,"children":["pages/startPage/startPage.js","pages/startPage/startPage.json","pages/startPage/startPage.wxml","pages/startPage/startPage.wxss"]},"pages/mountingPlate/":{"mtimeMs":1588761190467.1958,"children":["pages/mountingPlate/mountingPlate.js","pages/mountingPlate/mountingPlate.json","pages/mountingPlate/mountingPlate.wxml","pages/mountingPlate/mountingPlate.wxss"]}},"cacheVersion":1}
\ No newline at end of file \ No newline at end of file
{ {
"pages": [ "pages": [
"pages/picking/picking",
"pages/receivinggoods/receivinggoods",
"pages/mountingPlate/mountingPlate",
"pages/upperShelf/upperShelf",
"pages/startPage/startPage", "pages/startPage/startPage",
"pages/home/home", "pages/home/home",
"pages/cardBoard/cardBoard", "pages/cardBoard/cardBoard",
"pages/receivinggoods/receivinggoods",
"pages/scanDelivery/scanDelivery", "pages/scanDelivery/scanDelivery",
"pages/mountingPlate/mountingPlate",
"pages/picking/picking",
"pages/inventoryQuery/inventoryQuery", "pages/inventoryQuery/inventoryQuery",
...@@ -27,8 +38,8 @@ ...@@ -27,8 +38,8 @@
"pages/changeWarehouse/changeWarehouse", "pages/changeWarehouse/changeWarehouse",
"pages/login/login", "pages/login/login",
"pages/systemSettings/systemSettings", "pages/systemSettings/systemSettings",
"pages/outbound/outbound", "pages/outbound/outbound"
"pages/upperShelf/upperShelf"
], ],
"window": { "window": {
"backgroundTextStyle": "light", "backgroundTextStyle": "light",
......
...@@ -14,8 +14,376 @@ Page({ ...@@ -14,8 +14,376 @@ Page({
palletObj:null,//接口返回的卡板号 palletObj:null,//接口返回的卡板号
numText:"",//input值 numText:"",//input值
kbText:"",//卡板号 kbText:"",//卡板号
kbDeviceId:"",//卡板标签的蓝牙deviceId
blueNameDefault:"L51 BT Printer",//默认连接蓝牙的名字
}, },
initBlue:function(data){
//data为需要打印的数据
let blueStorageData = wx.getStorageSync('blueData');//获取打印机设定的缓存数据
if(blueStorageData){
//请求接口获取设定的数据然后缓存起来
let kbBlueName = blueStorageData.pallet_printer ||this.data.blueNameDefault;//卡板打印机的名称
if(this.data.kbDeviceId){
console.log('重新连接')
//重新连接
this.createBLEConnectionWithDeviceId(this.data.kbDeviceId,data)
}else{
this.openBluetoothAdapter(kbBlueName,data)
}
}else{
wx.showModal({
title: '提示',
content: '请先绑定指定打印机',
showCancel: false
})
}
},
//初始化蓝牙设备
openBluetoothAdapter:function(name,data){
var that = this;
if (wx.openBluetoothAdapter) {
wx.showLoading({
title: '打印设备连接中',
mask:true
})
wx.openBluetoothAdapter({
success: function(res) {
/* 获取本机的蓝牙状态 */
setTimeout(() => {
that.getBluetoothAdapterState(name,data)
}, 1000)
},
fail: function(res) {
// 初始化失败
wx.hideLoading()
if (res.errCode === 10001) {
wx.showModal({
title: '错误',
content: '未找到打印设备, 请打开蓝牙后重试。',
showCancel: false
})}else{
wx.showModal({
title: '错误',
content: '打印设备连接失败, 请重试。',
showCancel: false
})
}
}
})
} else {
wx.showModal({
title: '提示',
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
})
return
}
},
getBluetoothAdapterState(name,data) {
let that = this;
wx.getBluetoothAdapterState({
success: function(res) {
that.startBluetoothDevicesDiscovery(name,data)
},
fail(res) {
console.log(res);
wx.hideLoading()
wx.showModal({
title: '错误',
content: '打印设备连接失败, 请重试。',
showCancel: false
})
}
})
},
startBluetoothDevicesDiscovery(name,data) {
var that = this;
setTimeout(() => {
wx.startBluetoothDevicesDiscovery({
success: function(res) {
console.log(res)
/* 获取蓝牙设备列表 */
that.getBluetoothDevices(name,data)
},
fail(res) {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '打印设备连接失败, 请重试。',
showCancel: false
})
}
})
}, 1000)
},
getBluetoothDevices(name,data) {
let that = this;
setTimeout(() => {
wx.getBluetoothDevices({
services: [],
allowDuplicatesKey: false,
interval: 0,
success: function(res) {
console.log(res)
if (res.devices.length > 0) {
if (JSON.stringify(res.devices).indexOf(name) !== -1) {
for (let i = 0; i < res.devices.length; i++) {
if (res.devices[i].name == name || res.devices[i].localName == name) {
/* 根据指定的蓝牙设备名称匹配到deviceId */
setTimeout(() => {
that.connectTO(res.devices[i].deviceId,data);
}, 2000);
};
};
} else {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '找不到指定蓝牙设备, 请重试。',
showCancel: false
})
}
} else {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '找不到指定蓝牙设备, 请重试。',
showCancel: false
})
}
},
fail(res) {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '获取蓝牙设备列表失败, 请重试。',
showCancel: false
})
console.log(res, '获取蓝牙设备列表失败=====')
}
})
}, 2000)
},
connectTO(deviceId,data,isConnectionWithDeviceId) {
//isConnectionWithDeviceId 是否是重新连接
let that = this;
wx.createBLEConnection({
deviceId: deviceId,
success: function(res) {
/* 4.获取连接设备的service服务 */
that.setData({
kbDeviceId: deviceId
})
wx.setStorageSync("kbDeviceId",deviceId)
that.getBLEDeviceServices(deviceId,data);
wx.stopBluetoothDevicesDiscovery({
success: function(res) {
console.log(res, '停止搜索')
},
fail(res) {
}
})
},
fail: function(res) {
console.log(res);
if(!isConnectionWithDeviceId){
wx.hideLoading()
wx.showModal({
title: '错误',
content: '打印设备连接失败, 请重试。',
showCancel: false
})
}else{
wx.removeStorageSync({
key: 'kbDeviceId',
});
that.setData({
kbDeviceId:""
})
if(res.errCode == -1){
//表示需要断开后再连接
wx.closeBLEConnection({
deviceId,
success (res) {
that.initBlue(data);
},
fail(res){
wx.hideLoading()
wx.showModal({
title: '错误',
content: '请关闭蓝牙重新打开',
showCancel: false
}) }
})
}else{
that.initBlue(data);
}
}
}
})
},
getBLEDeviceServices(deviceId,data) {
let that = this;
// setTimeout(() => {
wx.getBLEDeviceServices({
deviceId: deviceId,
success: function(res) {
/* 获取连接设备的所有特征值 */
for (let i = 0; i < res.services.length; i++) {
if (res.services[i].isPrimary) {
that.getBLEDeviceCharacteristics(deviceId, res.services[i].uuid,data)
break
}
}
},
fail: (res) => {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '打印设备连接失败, 请重试。',
showCancel: false
})
}
})
// }, 2000)
},
getBLEDeviceCharacteristics(deviceId, serviceId,data) {
let that = this;
// setTimeout(() => {
wx.getBLEDeviceCharacteristics({
deviceId: deviceId,
serviceId: serviceId,
success: function(res) {
console.log('getBLEDeviceCharacteristics success', res.characteristics)
for (let i = 0; i < res.characteristics.length; i++) {
let item = res.characteristics[i]
if (item.properties.write) {
that.writeBLECharacteristicValue(deviceId,serviceId, item.uuid,data)
}
if (item.properties.notify || item.properties.indicate) {
wx.notifyBLECharacteristicValueChange({
deviceId,
serviceId,
characteristicId: item.uuid,
state: true,
})
}
}
},
fail: function(res) {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '打印设备连接失败, 请重试。',
showCancel: false
})
}
})
// }, 1000)
},
///重新连接
createBLEConnectionWithDeviceId(deviceId,data) {
// 小程序在之前已有搜索过某个蓝牙设备,并成功建立连接,可直接传入之前搜索获取的 deviceId 直接尝试连接该设备
let that = this;
if (!deviceId) {
return
}
wx.showLoading({
title: '打印设备连接中',
mask:true
})
console.log('createBLEConnectionWithDeviceId', + deviceId)
wx.openBluetoothAdapter({
success: (res) => {
console.log('openBluetoothAdapter success', res)
that.connectTO(deviceId,data,true)
},
fail: (res) => {
console.log('openBluetoothAdapter fail', res)
if (res.errCode === 10001) {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '未找到打印设备, 请打开蓝牙后重试。',
showCancel: false
})
}else{
wx.removeStorageSync({
key: 'kbDeviceId',
});
that.setData({
kbDeviceId:""
})
that.initBlue(data);
}
}
})
},
writeBLECharacteristicValue(deviceId,services, writeId,data){
let printerJobs = new PrinterJobs();
printerJobs
.print(data);
let buffer = printerJobs.buffer();
console.log(data)
const maxChunk = 20;
const delay = 20;
for (let i = 0, j = 0, length = buffer.byteLength; i < length; i += maxChunk, j++) {
let subPackage = buffer.slice(i, i + maxChunk <= length ? (i + maxChunk) : length);
setTimeout(function(){
wx.writeBLECharacteristicValue({
// 这里的 deviceId 需要在上面的 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
deviceId: deviceId,
// 这里的 serviceId 需要在上面的 getBLEDeviceServices 接口中获取
serviceId: services,
// 这里的 characteristicId 需要在上面的 getBLEDeviceCharacteristics 接口中获取
characteristicId: writeId,//第二步写入的特征值
// 这里的value是ArrayBuffer类型
value: subPackage,
success: function (res) {
console.log("写入成功");
if(i+maxChunk>=length){
wx.hideLoading();
wx.closeBLEConnection({//安卓如果不断开导致重新连接失败 ios断开打印不了 这里只针对安卓平板开发,所以不做兼容性
deviceId,
success (res) {
console.log(res)
}
})
}
},
fail: function () {
wx.hideLoading();
console.log('写入失败');
wx.showModal({
title: '错误',
content: '打印失败, 请重试。',
showCancel: false
})
},
complete:function(){
console.log("调用结束");
}
})
}, j * delay);
}
},
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
...@@ -223,7 +591,7 @@ Page({ ...@@ -223,7 +591,7 @@ Page({
getData(apis.pallet_active, 'post', {...obj}, function(res) { getData(apis.pallet_active, 'post', {...obj}, function(res) {
if (res.errcode === 0) { if (res.errcode === 0) {
console.log('连接蓝牙打印') me.bdPallet()
} else { } else {
...@@ -235,6 +603,45 @@ Page({ ...@@ -235,6 +603,45 @@ Page({
} }
}, true,true) }, true,true)
}, },
bdPallet:function(){
//补打卡板标签
let me = this;
if(!me.data.palletObj){
wx.showToast({
title: '卡板号不能为空',
icon: 'none',
duration: 2000
});
return
}else{
getData(apis.get_pallet_info, 'post', {"pallet_sn":me.data.palletObj.pallet_sn}, function(res) {
if (res.errcode === 0) {
console.log('连接蓝牙打印')
let data = res.data;
let str = "! 0 200 200 400 1 \n"+
"B QR 200 0 M 2 2 10 \n"+
"MA,QR code :"+(data.pallet_sn||'--')+","+(data.box_num||'--')+","+(data.box_weight||'--')+"\n"+
"ENDQR \n"+
"TEXT 55 1 380 20 卡板号: \n"+
"TEXT 55 1 380 60 内含箱数: \n"+
"TEXT 55 1 380 100 净重: \n"+
"TEXT 55 1 480 20 "+(data.pallet_sn||'--')+" \n"+
"TEXT 55 1 480 60 "+(data.box_num||'--')+"\n"+
"TEXT 55 1 480 100 "+(data.box_weight||'--')+" \n"+
"FORM \n"+
"PRINT";
me.initBlue(str)
} else {
wx.showToast({
title: res.errmsg,
icon: 'none',
duration: 2000
});
}
}, true,true)
}
},
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
</view> </view>
<view class="btn-group Bflex"> <view class="btn-group Bflex">
<view class="btn-item btn blue-border-btn" bindtap="putOnPallet">装卡板</view> <view class="btn-item btn blue-border-btn" bindtap="putOnPallet">装卡板</view>
<view class="btn-item btn blue-border-btn">补打卡板标签</view> <view class="btn-item btn blue-border-btn" bindtap="bdPallet">补打卡板标签</view>
<view class="btn-item btn disbled-btn" bindtap="clearFun">清除卡板记录</view> <view class="btn-item btn disbled-btn" bindtap="clearFun">清除卡板记录</view>
</view> </view>
</view> </view>
......
const PrinterJobs = require('../../utils/printerjobs');
import { import {
getData getData
} from '../../utils/axios.js'; } from '../../utils/axios.js';
...@@ -14,13 +15,381 @@ Page({ ...@@ -14,13 +15,381 @@ Page({
palletObj:null,//接口返回的卡板号 palletObj:null,//接口返回的卡板号
numText:"",//input值 numText:"",//input值
kbText:"",//卡板号 kbText:"",//卡板号
kbDeviceId:"",//卡板标签的蓝牙deviceId
blueNameDefault:"L51 BT Printer",//默认连接蓝牙的名字
}, },
initBlue:function(data){
//data为需要打印的数据
let blueStorageData = wx.getStorageSync('blueData');//获取打印机设定的缓存数据
if(blueStorageData){
//请求接口获取设定的数据然后缓存起来
let kbBlueName = blueStorageData.pallet_printer ||this.data.blueNameDefault;//卡板打印机的名称
if(this.data.kbDeviceId){
console.log('重新连接')
//重新连接
this.createBLEConnectionWithDeviceId(this.data.kbDeviceId,data)
}else{
this.openBluetoothAdapter(kbBlueName,data)
}
}else{
wx.showModal({
title: '提示',
content: '请先绑定指定打印机',
showCancel: false
})
}
},
//初始化蓝牙设备
openBluetoothAdapter:function(name,data){
var that = this;
if (wx.openBluetoothAdapter) {
wx.showLoading({
title: '打印设备连接中',
mask:true
})
wx.openBluetoothAdapter({
success: function(res) {
/* 获取本机的蓝牙状态 */
setTimeout(() => {
that.getBluetoothAdapterState(name,data)
}, 1000)
},
fail: function(res) {
// 初始化失败
wx.hideLoading()
if (res.errCode === 10001) {
wx.showModal({
title: '错误',
content: '未找到打印设备, 请打开蓝牙后重试。',
showCancel: false
})}else{
wx.showModal({
title: '错误',
content: '打印设备连接失败, 请重试。',
showCancel: false
})
}
}
})
} else {
wx.showModal({
title: '提示',
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
})
return
}
},
getBluetoothAdapterState(name,data) {
let that = this;
wx.getBluetoothAdapterState({
success: function(res) {
that.startBluetoothDevicesDiscovery(name,data)
},
fail(res) {
console.log(res);
wx.hideLoading()
wx.showModal({
title: '错误',
content: '打印设备连接失败, 请重试。',
showCancel: false
})
}
})
},
startBluetoothDevicesDiscovery(name,data) {
var that = this;
setTimeout(() => {
wx.startBluetoothDevicesDiscovery({
success: function(res) {
console.log(res)
/* 获取蓝牙设备列表 */
that.getBluetoothDevices(name,data)
},
fail(res) {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '打印设备连接失败, 请重试。',
showCancel: false
})
}
})
}, 1000)
},
getBluetoothDevices(name,data) {
let that = this;
setTimeout(() => {
wx.getBluetoothDevices({
services: [],
allowDuplicatesKey: false,
interval: 0,
success: function(res) {
console.log(res)
if (res.devices.length > 0) {
if (JSON.stringify(res.devices).indexOf(name) !== -1) {
for (let i = 0; i < res.devices.length; i++) {
if (res.devices[i].name == name || res.devices[i].localName == name) {
/* 根据指定的蓝牙设备名称匹配到deviceId */
setTimeout(() => {
that.connectTO(res.devices[i].deviceId,data);
}, 2000);
};
};
} else {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '找不到指定蓝牙设备, 请重试。',
showCancel: false
})
}
} else {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '找不到指定蓝牙设备, 请重试。',
showCancel: false
})
}
},
fail(res) {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '获取蓝牙设备列表失败, 请重试。',
showCancel: false
})
console.log(res, '获取蓝牙设备列表失败=====')
}
})
}, 2000)
},
connectTO(deviceId,data,isConnectionWithDeviceId) {
//isConnectionWithDeviceId 是否是重新连接
let that = this;
wx.createBLEConnection({
deviceId: deviceId,
success: function(res) {
/* 4.获取连接设备的service服务 */
that.setData({
kbDeviceId: deviceId
})
wx.setStorageSync("kbDeviceId",deviceId)
that.getBLEDeviceServices(deviceId,data);
wx.stopBluetoothDevicesDiscovery({
success: function(res) {
console.log(res, '停止搜索')
},
fail(res) {
}
})
},
fail: function(res) {
console.log(res);
if(!isConnectionWithDeviceId){
wx.hideLoading()
wx.showModal({
title: '错误',
content: '打印设备连接失败, 请重试。',
showCancel: false
})
}else{
wx.removeStorageSync({
key: 'kbDeviceId',
});
that.setData({
kbDeviceId:""
})
if(res.errCode == -1){
//表示需要断开后再连接
wx.closeBLEConnection({
deviceId,
success (res) {
that.initBlue(data);
},
fail(res){
wx.hideLoading()
wx.showModal({
title: '错误',
content: '请关闭蓝牙重新打开',
showCancel: false
}) }
})
}else{
that.initBlue(data);
}
}
}
})
},
getBLEDeviceServices(deviceId,data) {
let that = this;
// setTimeout(() => {
wx.getBLEDeviceServices({
deviceId: deviceId,
success: function(res) {
/* 获取连接设备的所有特征值 */
for (let i = 0; i < res.services.length; i++) {
if (res.services[i].isPrimary) {
that.getBLEDeviceCharacteristics(deviceId, res.services[i].uuid,data)
break
}
}
},
fail: (res) => {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '打印设备连接失败, 请重试。',
showCancel: false
})
}
})
// }, 2000)
},
getBLEDeviceCharacteristics(deviceId, serviceId,data) {
let that = this;
// setTimeout(() => {
wx.getBLEDeviceCharacteristics({
deviceId: deviceId,
serviceId: serviceId,
success: function(res) {
console.log('getBLEDeviceCharacteristics success', res.characteristics)
for (let i = 0; i < res.characteristics.length; i++) {
let item = res.characteristics[i]
if (item.properties.write) {
that.writeBLECharacteristicValue(deviceId,serviceId, item.uuid,data)
}
if (item.properties.notify || item.properties.indicate) {
wx.notifyBLECharacteristicValueChange({
deviceId,
serviceId,
characteristicId: item.uuid,
state: true,
})
}
}
},
fail: function(res) {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '打印设备连接失败, 请重试。',
showCancel: false
})
}
})
// }, 1000)
},
///重新连接
createBLEConnectionWithDeviceId(deviceId,data) {
// 小程序在之前已有搜索过某个蓝牙设备,并成功建立连接,可直接传入之前搜索获取的 deviceId 直接尝试连接该设备
let that = this;
if (!deviceId) {
return
}
wx.showLoading({
title: '打印设备连接中',
mask:true
})
console.log('createBLEConnectionWithDeviceId', + deviceId)
wx.openBluetoothAdapter({
success: (res) => {
console.log('openBluetoothAdapter success', res)
that.connectTO(deviceId,data,true)
},
fail: (res) => {
console.log('openBluetoothAdapter fail', res)
if (res.errCode === 10001) {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '未找到打印设备, 请打开蓝牙后重试。',
showCancel: false
})
}else{
wx.removeStorageSync({
key: 'kbDeviceId',
});
that.setData({
kbDeviceId:""
})
that.initBlue(data);
}
}
})
},
writeBLECharacteristicValue(deviceId,services, writeId,data){
let printerJobs = new PrinterJobs();
printerJobs
.print(data);
let buffer = printerJobs.buffer();
console.log(data)
const maxChunk = 20;
const delay = 20;
for (let i = 0, j = 0, length = buffer.byteLength; i < length; i += maxChunk, j++) {
let subPackage = buffer.slice(i, i + maxChunk <= length ? (i + maxChunk) : length);
setTimeout(function(){
wx.writeBLECharacteristicValue({
// 这里的 deviceId 需要在上面的 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
deviceId: deviceId,
// 这里的 serviceId 需要在上面的 getBLEDeviceServices 接口中获取
serviceId: services,
// 这里的 characteristicId 需要在上面的 getBLEDeviceCharacteristics 接口中获取
characteristicId: writeId,//第二步写入的特征值
// 这里的value是ArrayBuffer类型
value: subPackage,
success: function (res) {
console.log("写入成功");
if(i+maxChunk>=length){
wx.hideLoading();
wx.closeBLEConnection({//安卓如果不断开导致重新连接失败 ios断开打印不了 这里只针对安卓平板开发,所以不做兼容性
deviceId,
success (res) {
console.log(res)
}
})
}
},
fail: function () {
wx.hideLoading();
console.log('写入失败');
wx.showModal({
title: '错误',
content: '打印失败, 请重试。',
showCancel: false
})
},
complete:function(){
console.log("调用结束");
}
})
}, j * delay);
}
},
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
}, },
cancelFun:function(e){ cancelFun:function(e){
let {index} = e.currentTarget.dataset; let {index} = e.currentTarget.dataset;
...@@ -224,8 +593,20 @@ Page({ ...@@ -224,8 +593,20 @@ Page({
getData(apis.put_on_pallet, 'post', {...obj}, function(res) { getData(apis.put_on_pallet, 'post', {...obj}, function(res) {
if (res.errcode === 0) { if (res.errcode === 0) {
console.log('连接蓝牙打印') console.log('连接蓝牙打印')
let data = res.data;
let str = "! 0 200 200 400 1 \n"+
"B QR 200 0 M 2 2 10 \n"+
"MA,QR code :"+(data.NO||'--')+","+(data.QTY||'--')+","+(data.WEIGHT||'--')+"\n"+
"ENDQR \n"+
"TEXT 55 1 380 20 卡板号: \n"+
"TEXT 55 1 380 60 内含箱数: \n"+
"TEXT 55 1 380 100 净重: \n"+
"TEXT 55 1 480 20 "+(data.NO||'--')+" \n"+
"TEXT 55 1 480 60 "+(data.QTY||'--')+"\n"+
"TEXT 55 1 480 100 "+(data.WEIGHT||'--')+" \n"+
"FORM \n"+
"PRINT";
me.initBlue(str)
} else { } else {
wx.showToast({ wx.showToast({
title: res.errmsg, title: res.errmsg,
...@@ -235,6 +616,45 @@ Page({ ...@@ -235,6 +616,45 @@ Page({
} }
}, true,true) }, true,true)
}, },
bdPallet:function(){
//补打卡板标签
let me = this;
if(!me.data.palletObj){
wx.showToast({
title: '卡板号不能为空',
icon: 'none',
duration: 2000
});
return
}else{
getData(apis.hd_pallet_label, 'post', {"pallet_sn":me.data.palletObj.pallet_sn}, function(res) {
if (res.errcode === 0) {
console.log('连接蓝牙打印')
let data = res.data;
let str = "! 0 200 200 400 1 \n"+
"B QR 200 0 M 2 2 10 \n"+
"MA,QR code :"+(data.NO||'--')+","+(data.QTY||'--')+","+(data.WEIGHT||'--')+"\n"+
"ENDQR \n"+
"TEXT 55 1 380 20 卡板号: \n"+
"TEXT 55 1 380 60 内含箱数: \n"+
"TEXT 55 1 380 100 净重: \n"+
"TEXT 55 1 480 20 "+(data.NO||'--')+" \n"+
"TEXT 55 1 480 60 "+(data.QTY||'--')+"\n"+
"TEXT 55 1 480 100 "+(data.WEIGHT||'--')+" \n"+
"FORM \n"+
"PRINT";
me.initBlue(str)
} else {
wx.showToast({
title: res.errmsg,
icon: 'none',
duration: 2000
});
}
}, true,true)
}
},
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
...@@ -253,7 +673,7 @@ Page({ ...@@ -253,7 +673,7 @@ Page({
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
*/ */
onHide: function () { onHide: function () {
wx.closeBluetoothAdapter();
}, },
/** /**
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
</view> </view>
<view class="btn-group Bflex"> <view class="btn-group Bflex">
<view class="btn-item btn blue-border-btn" bindtap="putOnPallet">装卡板</view> <view class="btn-item btn blue-border-btn" bindtap="putOnPallet">装卡板</view>
<view class="btn-item btn blue-border-btn">补打卡板标签</view> <view class="btn-item btn blue-border-btn" bindtap="bdPallet">补打卡板标签</view>
<view class="btn-item btn disbled-btn" bindtap="clearFun">清除卡板记录</view> <view class="btn-item btn disbled-btn" bindtap="clearFun">清除卡板记录</view>
</view> </view>
</view> </view>
......
...@@ -15,7 +15,13 @@ Page({ ...@@ -15,7 +15,13 @@ Page({
hwVal:"0", hwVal:"0",
kbVal:"", kbVal:"",
listArr:[], listArr:[],
initId:"" initId:"",
kbText:"",
xText:"",
isKb:false,
isHw:false,
xDeviceId:"",//卡板标签的蓝牙deviceId
blueNameDefault:"L51 BT Printer",//默认连接蓝牙的名字
}, },
/** /**
...@@ -49,6 +55,9 @@ Page({ ...@@ -49,6 +55,9 @@ Page({
let me = this; let me = this;
getData(apis.cancel_pick, 'post', {"pick_task_detail_id":me.data.initId}, function(res) { getData(apis.cancel_pick, 'post', {"pick_task_detail_id":me.data.initId}, function(res) {
if (res.errcode === 0) { if (res.errcode === 0) {
me.setData({
initId:""
})
me.getList() me.getList()
} else { } else {
wx.showToast({ wx.showToast({
...@@ -60,7 +69,15 @@ Page({ ...@@ -60,7 +69,15 @@ Page({
}, true,true) }, true,true)
}, },
chooseData:function(e){ chooseData:function(e){
let {id} = e.currentTarget.dataset; let {id,status} = e.currentTarget.dataset;
if(status == 1 || status == 4 ){
wx.showToast({
title: '请选择已拣货的数据',
icon: 'none',
duration: 2000
});
return
}
let newId = ""; let newId = "";
if(this.data.initId != id){ if(this.data.initId != id){
newId = id newId = id
...@@ -69,27 +86,23 @@ Page({ ...@@ -69,27 +86,23 @@ Page({
initId:newId initId:newId
}) })
}, },
rwInput:function(e){//任务号input监听 rwConfirm:function(e){
let {value} = e.detail ; let {value} = e.detail ;
this.setData({ this.setData({
rwVal:value, rwVal:value,
hwVal:"", hwVal:"",
kbVal:"", kbVal:"",
kbText:"",
xText:""
}) })
},
rwConfirm:function(e){
this.getList() this.getList()
}, },
hwInput:function(e){//货位号input监听
let {value} = e.detail ;
this.setData({
hwVal:value,
kbVal:"",
})
},
hwConfirm:function(e){ hwConfirm:function(e){
let rwVal = this.data.rwVal; let rwVal = this.data.rwVal;
let {value} = e.detail ;
this.setData({
isHw:false,
});
if(!rwVal){ if(!rwVal){
wx.showToast({ wx.showToast({
title: '上架任务号不能为空', title: '上架任务号不能为空',
...@@ -97,19 +110,24 @@ Page({ ...@@ -97,19 +110,24 @@ Page({
duration: 2000 duration: 2000
}); });
}else{ }else{
this.setData({
hwVal:value,
kbVal:"",
kbText:"",
xText:"",
})
this.getList() this.getList()
} }
}, },
kbInput:function(e){//卡板/箱号input监听
let {value} = e.detail ;
this.setData({
kbVal:value
})
},
kbConfirm:function(e){ kbConfirm:function(e){
let {value} = e.detail ;
let str = value.substring(0, 2);
let rwVal = this.data.rwVal; let rwVal = this.data.rwVal;
let hwVal = this.data.hwVal; let hwVal = this.data.hwVal;
this.setData({
isKb:false,
});
if(!rwVal){ if(!rwVal){
wx.showToast({ wx.showToast({
title: '上架任务号不能为空', title: '上架任务号不能为空',
...@@ -123,18 +141,32 @@ Page({ ...@@ -123,18 +141,32 @@ Page({
duration: 2000 duration: 2000
}); });
}else{ }else{
this.setData({
kbVal:value
})
if(str == 'KB'){
this.setData({
kbText:value
})
}else if(str == 'XB'){
this.setData({
xText:value
})
}else{
this.getList(true)
}
this.getList() this.getList()
} }
}, },
getList:function(){ getList:function(bool){
let me = this; let me = this;
let url = ""; let url = "";
let data = {pick_task_sn:me.data.rwVal}; let data = {pick_task_sn:me.data.rwVal};
if(!me.data.kbVal){ if(!me.data.kbVal){
url = apis.pick_task_list; url = apis.pick_task_list;
if(me.data.hwVal){ if(me.data.hwVal){
data['location_id'] = me.data.hwVal data['location_id'] = me.data.hwVal;
} }
}else{ }else{
url = apis.confirm_pick; url = apis.confirm_pick;
...@@ -146,17 +178,419 @@ Page({ ...@@ -146,17 +178,419 @@ Page({
let data = res.data; let data = res.data;
me.setData({ me.setData({
listArr:data||[] listArr:data||[]
}) });
if(!me.data.kbVal){
if(me.data.hwVal){
me.setData({
isKb:true,
});
}else{
me.setData({
isHw:true,
});
}
}
if(bool){
//调用接口检查是否需要打印箱标签
me.printFun()
}
} else { } else {
wx.showToast({ wx.showToast({
title: res.errmsg, title: res.errmsg||"未知错误",
icon: 'none', icon: 'none',
duration: 2000 duration: 2000
}); });
} }
}, true,true) }, true,true)
}, },
printFun:function(){
//补打卡板标签
let me = this;
if(!me.data.xText){
return
}else{
getData(apis.get_box_info1, 'post', {"box_sn":me.data.xText}, function(res) {
if (res.errcode === 0) {
console.log('连接蓝牙打印')
me.initBlue(str)
} else {
wx.showToast({
title: res.errmsg,
icon: 'none',
duration: 2000
});
}
}, true,true)
}
},
initBlue:function(data){
//data为需要打印的数据
let blueStorageData = wx.getStorageSync('blueData');//获取打印机设定的缓存数据
if(blueStorageData){
//请求接口获取设定的数据然后缓存起来
let xBlueName = blueStorageData.box_printer ||this.data.blueNameDefault;//卡板打印机的名称
if(this.data.xDeviceId){
console.log('重新连接')
//重新连接
this.createBLEConnectionWithDeviceId(this.data.xDeviceId,data)
}else{
this.openBluetoothAdapter(xBlueName,data)
}
}else{
wx.showModal({
title: '提示',
content: '请先绑定指定打印机',
showCancel: false
})
}
},
//初始化蓝牙设备
openBluetoothAdapter:function(name,data){
var that = this;
if (wx.openBluetoothAdapter) {
wx.showLoading({
title: '打印设备连接中',
mask:true
})
wx.openBluetoothAdapter({
success: function(res) {
/* 获取本机的蓝牙状态 */
setTimeout(() => {
that.getBluetoothAdapterState(name,data)
}, 1000)
},
fail: function(res) {
// 初始化失败
wx.hideLoading()
if (res.errCode === 10001) {
wx.showModal({
title: '错误',
content: '未找到打印设备, 请打开蓝牙后重试。',
showCancel: false
})}else{
wx.showModal({
title: '错误',
content: '打印设备连接失败, 请重试。',
showCancel: false
})
}
}
})
} else {
wx.showModal({
title: '提示',
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
})
return
}
},
getBluetoothAdapterState(name,data) {
let that = this;
wx.getBluetoothAdapterState({
success: function(res) {
that.startBluetoothDevicesDiscovery(name,data)
},
fail(res) {
console.log(res);
wx.hideLoading()
wx.showModal({
title: '错误',
content: '打印设备连接失败, 请重试。',
showCancel: false
})
}
})
},
startBluetoothDevicesDiscovery(name,data) {
var that = this;
setTimeout(() => {
wx.startBluetoothDevicesDiscovery({
success: function(res) {
console.log(res)
/* 获取蓝牙设备列表 */
that.getBluetoothDevices(name,data)
},
fail(res) {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '打印设备连接失败, 请重试。',
showCancel: false
})
}
})
}, 1000)
},
getBluetoothDevices(name,data) {
let that = this;
setTimeout(() => {
wx.getBluetoothDevices({
services: [],
allowDuplicatesKey: false,
interval: 0,
success: function(res) {
console.log(res)
if (res.devices.length > 0) {
if (JSON.stringify(res.devices).indexOf(name) !== -1) {
for (let i = 0; i < res.devices.length; i++) {
if (res.devices[i].name == name || res.devices[i].localName == name) {
/* 根据指定的蓝牙设备名称匹配到deviceId */
setTimeout(() => {
that.connectTO(res.devices[i].deviceId,data);
}, 2000);
};
};
} else {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '找不到指定蓝牙设备, 请重试。',
showCancel: false
})
}
} else {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '找不到指定蓝牙设备, 请重试。',
showCancel: false
})
}
},
fail(res) {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '获取蓝牙设备列表失败, 请重试。',
showCancel: false
})
console.log(res, '获取蓝牙设备列表失败=====')
}
})
}, 2000)
},
connectTO(deviceId,data,isConnectionWithDeviceId) {
//isConnectionWithDeviceId 是否是重新连接
let that = this;
wx.createBLEConnection({
deviceId: deviceId,
success: function(res) {
/* 4.获取连接设备的service服务 */
that.setData({
xDeviceId: deviceId
})
wx.setStorageSync("xDeviceId",deviceId)
that.getBLEDeviceServices(deviceId,data);
wx.stopBluetoothDevicesDiscovery({
success: function(res) {
console.log(res, '停止搜索')
},
fail(res) {
}
})
},
fail: function(res) {
console.log(res);
if(!isConnectionWithDeviceId){
wx.hideLoading()
wx.showModal({
title: '错误',
content: '打印设备连接失败, 请重试。',
showCancel: false
})
}else{
wx.removeStorageSync({
key: 'xDeviceId',
});
that.setData({
xDeviceId:""
})
if(res.errCode == -1){
//表示需要断开后再连接
wx.closeBLEConnection({
deviceId,
success (res) {
that.initBlue(data);
},
fail(res){
wx.hideLoading()
wx.showModal({
title: '错误',
content: '请关闭蓝牙重新打开',
showCancel: false
}) }
})
}else{
that.initBlue(data);
}
}
}
})
},
getBLEDeviceServices(deviceId,data) {
let that = this;
// setTimeout(() => {
wx.getBLEDeviceServices({
deviceId: deviceId,
success: function(res) {
/* 获取连接设备的所有特征值 */
for (let i = 0; i < res.services.length; i++) {
if (res.services[i].isPrimary) {
that.getBLEDeviceCharacteristics(deviceId, res.services[i].uuid,data)
break
}
}
},
fail: (res) => {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '打印设备连接失败, 请重试。',
showCancel: false
})
}
})
// }, 2000)
},
getBLEDeviceCharacteristics(deviceId, serviceId,data) {
let that = this;
// setTimeout(() => {
wx.getBLEDeviceCharacteristics({
deviceId: deviceId,
serviceId: serviceId,
success: function(res) {
console.log('getBLEDeviceCharacteristics success', res.characteristics)
for (let i = 0; i < res.characteristics.length; i++) {
let item = res.characteristics[i]
if (item.properties.write) {
that.writeBLECharacteristicValue(deviceId,serviceId, item.uuid,data)
}
if (item.properties.notify || item.properties.indicate) {
wx.notifyBLECharacteristicValueChange({
deviceId,
serviceId,
characteristicId: item.uuid,
state: true,
})
}
}
},
fail: function(res) {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '打印设备连接失败, 请重试。',
showCancel: false
})
}
})
// }, 1000)
},
///重新连接
createBLEConnectionWithDeviceId(deviceId,data) {
// 小程序在之前已有搜索过某个蓝牙设备,并成功建立连接,可直接传入之前搜索获取的 deviceId 直接尝试连接该设备
let that = this;
if (!deviceId) {
return
}
wx.showLoading({
title: '打印设备连接中',
mask:true
})
console.log('createBLEConnectionWithDeviceId', + deviceId)
wx.openBluetoothAdapter({
success: (res) => {
console.log('openBluetoothAdapter success', res)
that.connectTO(deviceId,data,true)
},
fail: (res) => {
console.log('openBluetoothAdapter fail', res)
if (res.errCode === 10001) {
wx.hideLoading()
wx.showModal({
title: '错误',
content: '未找到打印设备, 请打开蓝牙后重试。',
showCancel: false
})
}else{
wx.removeStorageSync({
key: 'xDeviceId',
});
that.setData({
xDeviceId:""
})
that.initBlue(data);
}
}
})
},
writeBLECharacteristicValue(deviceId,services, writeId,data){
let printerJobs = new PrinterJobs();
printerJobs
.print(data);
let buffer = printerJobs.buffer();
console.log(data)
const maxChunk = 20;
const delay = 20;
for (let i = 0, j = 0, length = buffer.byteLength; i < length; i += maxChunk, j++) {
let subPackage = buffer.slice(i, i + maxChunk <= length ? (i + maxChunk) : length);
setTimeout(function(){
wx.writeBLECharacteristicValue({
// 这里的 deviceId 需要在上面的 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
deviceId: deviceId,
// 这里的 serviceId 需要在上面的 getBLEDeviceServices 接口中获取
serviceId: services,
// 这里的 characteristicId 需要在上面的 getBLEDeviceCharacteristics 接口中获取
characteristicId: writeId,//第二步写入的特征值
// 这里的value是ArrayBuffer类型
value: subPackage,
success: function (res) {
console.log("写入成功");
if(i+maxChunk>=length){
wx.hideLoading();
wx.closeBLEConnection({//安卓如果不断开导致重新连接失败 ios断开打印不了 这里只针对安卓平板开发,所以不做兼容性
deviceId,
success (res) {
console.log(res)
}
})
}
},
fail: function () {
wx.hideLoading();
console.log('写入失败');
wx.showModal({
title: '错误',
content: '打印失败, 请重试。',
showCancel: false
})
},
complete:function(){
console.log("调用结束");
}
})
}, j * delay);
}
},
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
...@@ -175,7 +609,7 @@ Page({ ...@@ -175,7 +609,7 @@ Page({
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
*/ */
onHide: function () { onHide: function () {
wx.closeBluetoothAdapter();
}, },
/** /**
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
<view class="pinking-wrapper "> <view class="pinking-wrapper ">
<view class="view-top Bflex aic"> <view class="view-top Bflex aic">
<text class="desc">上架任务号:</text> <text class="desc">上架任务号:</text>
<input class="input input-border" value="{{rwVal}}" bindinput="rwInput" bindconfirm="rwConfirm"></input> <input class="input input-border" value="{{rwVal}}" bindconfirm="rwConfirm"></input>
<text class="desc">货位号:</text> <text class="desc">货位号:</text>
<input class="input input-border" value="{{hwVal}}" bindinput="hwInput" bindconfirm="hwConfirm"></input> <input class="input input-border" value="{{hwVal}}" bindconfirm="hwConfirm" focus="{{isHw}}"></input>
<text class="desc">卡板号/箱号/型号:</text> <text class="desc">卡板号/箱号/型号:</text>
<input class="input input-border" value="{{kbVal}}" bindinput="kbInput" bindconfirm="kbConfirm"></input> <input class="input input-border" value="{{kbVal}}" bindconfirm="kbConfirm" focus="{{isKb}}"></input>
<view class="number"> <view class="number">
拣货任务号: <text>{{rwVal}}</text> 拣货任务号: <text>{{rwVal}}</text>
</view> </view>
...@@ -15,6 +15,14 @@ ...@@ -15,6 +15,14 @@
当前货位号: 当前货位号:
<text>{{hwVal}}</text> <text>{{hwVal}}</text>
</view> </view>
<view class="hw">
当前卡板号:
<text>{{kbText}}</text>
</view>
<view class="hw">
当前箱号:
<text>{{xText}}</text>
</view>
</view> </view>
<view class="table-view"> <view class="table-view">
<view class="scroll-view"> <view class="scroll-view">
...@@ -41,7 +49,7 @@ ...@@ -41,7 +49,7 @@
</view> </view>
</block> </block>
<block wx:else> <block wx:else>
<view class="body-data Bflex {{initId == item.pick_task_detail_id ?'active':'' }}" wx:for="{{listArr}}" wx:key="index" bindtap="chooseData" data-id="{{ item.pick_task_detail_id}}"> <view class="body-data Bflex {{initId == item.pick_task_detail_id ?'active':'' }}" wx:for="{{listArr}}" wx:key="index" bindtap="chooseData" data-id="{{ item.pick_task_detail_id}}" data-status="{{item.pick_status}}">
<view class="td-1 td borderBox Iflex jcc aic td-50"><text class="box-icon {{initId == item.pick_task_detail_id ?'checked':'' }}"></text></view> <view class="td-1 td borderBox Iflex jcc aic td-50"><text class="box-icon {{initId == item.pick_task_detail_id ?'checked':'' }}"></text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text> <view class="td-2 td borderBox Iflex jcc aic"><text>
<block wx:if="{{item.pick_status == 1}}">未拣货</block> <block wx:if="{{item.pick_status == 1}}">未拣货</block>
...@@ -49,15 +57,15 @@ ...@@ -49,15 +57,15 @@
<block wx:elif="{{item.pick_status == 3}}">已拣货</block> <block wx:elif="{{item.pick_status == 3}}">已拣货</block>
<block wx:elif="{{item.pick_status == 4}}">取消拣货</block> <block wx:elif="{{item.pick_status == 4}}">取消拣货</block>
</text></view> </text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>{{item.pick_remark}}</text></view> <view class="td-2 td borderBox Iflex jcc aic"><text>{{item.pick_remark||"--"}}</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>{{item.location_id_cn}}</text></view> <view class="td-2 td borderBox Iflex jcc aic"><text>{{item.location_id_cn||"--"}}</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>{{item.pallet_id_cn}}</text></view> <view class="td-2 td borderBox Iflex jcc aic td-119"><text>{{item.pallet_id_cn||"--"}}</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>{{item.box_id_cn}}</text></view> <view class="td-2 td borderBox Iflex jcc aic td-119"><text>{{item.box_id_cn||"--"}}</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>{{item.goods_name}}</text></view> <view class="td-2 td borderBox Iflex jcc aic td-119"><text>{{item.goods_name||"--"}}</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>{{item.piece_num}}</text></view> <view class="td-2 td borderBox Iflex jcc aic"><text>{{item.piece_num||"--"}}</text></view>
<view class="td-2 td borderBox Iflex jcc aic "><text>{{item.number}}</text></view> <view class="td-2 td borderBox Iflex jcc aic "><text>{{item.number||"--"}}</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>{{item.pick_user_id_cn}}</text></view> <view class="td-2 td borderBox Iflex jcc aic"><text>{{item.pick_user_id_cn||"--"}}</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-125"><text>{{item.pick_time}}</text></view> <view class="td-2 td borderBox Iflex jcc aic td-125"><text>{{item.pick_time||"--"}}</text></view>
</view> </view>
</block> </block>
</view> </view>
......
...@@ -19,9 +19,6 @@ Page({ ...@@ -19,9 +19,6 @@ Page({
isShowX:false, isShowX:false,
isShowKb:false isShowKb:false
}, },
onUnload:function(){
wx.closeBluetoothAdapter();
},
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
...@@ -235,7 +232,7 @@ Page({ ...@@ -235,7 +232,7 @@ Page({
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
*/ */
onHide: function () { onHide: function () {
wx.closeBluetoothAdapter();
}, },
/** /**
......
...@@ -6,6 +6,9 @@ import { ...@@ -6,6 +6,9 @@ import {
import { import {
apis apis
} from '../../utils/api.js'; } from '../../utils/api.js';
import {
printData
} from '../../utils/util.js';
Page({ Page({
/** /**
...@@ -451,7 +454,7 @@ writeBLECharacteristicValue(deviceId,services, writeId,data,type){ ...@@ -451,7 +454,7 @@ writeBLECharacteristicValue(deviceId,services, writeId,data,type){
}, },
onUnload:function(){ onUnload:function(){
wx.closeBluetoothAdapter(); // wx.closeBluetoothAdapter();
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
...@@ -484,6 +487,7 @@ onUnload:function(){ ...@@ -484,6 +487,7 @@ onUnload:function(){
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
*/ */
onHide: function () { onHide: function () {
wx.closeBluetoothAdapter();
}, },
...@@ -1186,7 +1190,7 @@ onUnload:function(){ ...@@ -1186,7 +1190,7 @@ onUnload:function(){
if(type == 1){ if(type == 1){
if(me.data.xiangIndex == 0){ if(me.data.xiangIndex == 0){
obj['sale_type'] = 'bulk'; obj['sale_type'] = 'bulk';
me.saveSaleTaskAjax(obj) me.saveSaleTaskAjax(obj,type)
}else{ }else{
return return
} }
...@@ -1210,7 +1214,7 @@ onUnload:function(){ ...@@ -1210,7 +1214,7 @@ onUnload:function(){
if(xiangIndex == 1){ if(xiangIndex == 1){
//新箱 //新箱
obj['sale_type'] = 'new_box'; obj['sale_type'] = 'new_box';
me.saveSaleTaskAjax(obj) me.saveSaleTaskAjax(obj,type)
}else if(xiangIndex == 2){ }else if(xiangIndex == 2){
//合箱 //合箱
obj['sale_type'] = 'merge_box'; obj['sale_type'] = 'merge_box';
...@@ -1240,7 +1244,12 @@ onUnload:function(){ ...@@ -1240,7 +1244,12 @@ onUnload:function(){
me.getReceivingList(2) me.getReceivingList(2)
if(type == 2){ if(type == 2){
console.log('打印箱标签') console.log('打印箱标签')
// me.initBlue(type,data) let data = res.data;
if(data){
let str = printData(data.box_sn,data.weight,data.receiving_list);
me.initBlue(2,str)
}
} }
}else{ }else{
wx.showToast({ wx.showToast({
......
// pages/upperShelf/upperShelf.js // pages/upperShelf/upperShelf.js
// pages/picking/picking.js
import {
getData
} from '../../utils/axios.js';
import {
apis
} from '../../utils/api.js';
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
rwVal:"",
hwVal:"",
kbVal:"",
listArr:[],
taskId:"",
isKb:false,
isHw:false,
isShowMask:false,
maskText:"",
type:"0",//1 卡板 2//箱子 3 型号
receivingId:"",
}, },
...@@ -14,7 +32,218 @@ Page({ ...@@ -14,7 +32,218 @@ Page({
onLoad: function (options) { onLoad: function (options) {
}, },
closeMask:function(){
this.setData({
isShowMask:false,
maskText:""
})
},
rwConfirm:function(e){
let {value} = e.detail;
this.setData({
rwVal:value,
hwVal:"",
kbVal:"",
taskId:""
});
this.getRwList()
} ,
kbConfirm:function(e){
let {value} = e.detail;
let rwVal = this.data.rwVal;
this.setData({
isKb:false,
});
if(!rwVal){
wx.showToast({
title: '上架任务号不能为空',
icon: 'none',
duration: 2000
});
}else{
this.setData({
kbVal:value,
hwVal:"",
type:"0",
receivingId:"",
});
this.getKbList()
}
} ,
hwConfirm:function(e){
let {value} = e.detail;
let rwVal = this.data.rwVal;
let kbVal = this.data.kbVal;
this.setData({
isHw:false,
});
if(!rwVal){
wx.showToast({
title: '上架任务号不能为空',
icon: 'none',
duration: 2000
});
}else if(!kbVal){
wx.showToast({
title: '卡板号/箱号/型号',
icon: 'none',
duration: 2000
});
}else{
this.setData({
hwVal:value
});
this.getHwList()
}
} ,
getRwList:function(){
let me = this;
getData(apis.sale_task_sn_find_info, 'post', {"sale_task_sn":me.data.rwVal}, function(res) {
if (res.errcode === 0) {
let data = res.data;
if(data.sale_task){
me.setData({
taskId:data.sale_task.sale_task_id||"",
listArr:data.detail||[],
isKb:true
})
}
} else {
wx.showToast({
title: res.errmsg,
icon: 'none',
duration: 2000
});
}
}, true,true)
},
getHwList:function(){
let me = this;
let type = me.data.type;
let receivingId = me.data.receivingId
let obj = {
"location_sn":me.data.hwVal
};
if(type == 3){
obj['sale_task_id'] = me.data.taskId;
obj['receiving_id'] = receivingId
}else if(type == 2){
obj['box_id'] = receivingId
}else if(type == 1){
obj['pallet_id'] = receivingId
}
getData(apis.scan_location, 'post', {...obj}, function(res) {
if (res.errcode === 0) {
wx.showToast({
title: '操作成功',
icon: 'none',
duration: 2000
});
me.setData({
rwVal:"",
hwVal:"",
kbVal:"",
listArr:[],
taskId:"",
isKb:false,
isHw:false,
isShowMask:false,
maskText:"",
type:"0",
receivingId:"",
})
} else {
wx.showToast({
title: res.errmsg,
icon: 'none',
duration: 2000
});
}
}, true,true)
},
getKbList:function(){
let me = this;
let taskId = me.data.taskId
if(!taskId){
wx.showToast({
title: '上架任务id不能为空',
icon: 'none',
duration: 2000
});
}else{
getData(apis.scan_goods_discern, 'post', {"sale_task_id":taskId,"code":me.data.kbVal}, function(res) {
if (res.errcode === 0) {
let info = res.data.info || null;
let type = res.data.type
if(null){
wx.showToast({
title: '未找到对应的商品',
icon: 'none',
duration: 2000
});
}else{
me.setData({
type:type
})
if(type == 1){
me.setData({
listArr:[info],
receivingId:info.pallet_id
})
}
if(type == 2&&info.pallet_id!=0){
me.setData({
isShowMask:true,
maskText:"箱号存于卡板记录中,请直接扫描卡板上架。"
});
return;
} else{
me.setData({
listArr:[info],
receivingId:info.box_id
})
}
if(type == 3){
if(info.pallet_id!=0){
me.setData({
isShowMask:true,
maskText:"型号存于卡板记录中,请直接扫描卡板上架。"
})
return;
}else if(info.box_id!=0){
console.log(111)
me.setData({
isShowMask:true,
maskText:"型号存于箱记录中,请直接扫描卡板上架。"
})
return;
}else{
me.setData({
listArr:[info],
receivingId:info.receiving_id
})
}
}
}
} else {
wx.showToast({
title: res.errmsg,
icon: 'none',
duration: 2000
});
}
}, true,true)
}
},
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
......
<nav-c title="上架"> <nav-c title="上架">
<view class="upper-shelf-view width-854px nav-view borderBox"> <view class="upper-shelf-view width-854px nav-view borderBox">
<view class="upper-shelf-wrapper"> <view class="upper-shelf-wrapper">
<view class="view-top Bflex aic"> <view class="view-top Bflex aic">
<text class="desc">上架任务号/货位/卡板号/箱号/型号:</text> <text class="desc">上架任务号:</text>
<input class="input input-border" placeholder="请输入用户名"></input> <input class="input input-border" bindconfirm="rwConfirm" value="{{rwVal}}"></input>
<view class="number"> <text class="desc">卡板号/箱号/型号:</text>
上架任务号: <text>0609</text> <input class="input input-border" bindconfirm="kbConfirm" focus="{{isKb}}" value="{{kbVal}}"></input>
</view> <text class="desc">货位号:</text>
<view class="hw"> <input class="input input-border" bindconfirm="hwConfirm" focus="{{isHw}}" value="{{hwVal}}"></input>
当前货位: <view class="number">
<text>9857</text> 拣货任务号: <text>{{rwVal}}</text>
</view> </view>
</view> <view class="hw">
<view class="table-view"> 当前货位号:
<view class="data-table borderBox"> <text>{{hwVal}}</text>
<view class="head Bflex"> </view>
<view class="td-1 td borderBox Iflex jcc aic"><text>上架任务号</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>状态</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>货位</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>卡板号</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>箱号 </text></view>
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>型号</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>品牌</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>数量</text></view>
</view> </view>
<view class="body"> <view class="table-view">
<view class="body-data Bflex"> <view class="data-table borderBox">
<view class="td-1 td borderBox Iflex jcc aic"><text>上架任务号</text></view> <view class="head Bflex">
<view class="td-2 td borderBox Iflex jcc aic"><text>状态</text></view> <view class="td-1 td borderBox Iflex jcc aic td-140"><text>上架任务号</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>货位</text></view> <view class="td-2 td borderBox Iflex jcc aic"><text>状态</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>卡板号</text></view> <!-- <view class="td-2 td borderBox Iflex jcc aic"><text>货位</text></view> -->
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>箱号 </text></view> <view class="td-2 td borderBox Iflex jcc aic td-119"><text>卡板号</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>型号</text></view> <view class="td-2 td borderBox Iflex jcc aic td-119"><text>箱号 </text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>品牌</text></view> <view class="td-2 td borderBox Iflex jcc aic td-141"><text>型号</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>数量</text></view> <view class="td-2 td borderBox Iflex jcc aic"><text>品牌</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>数量</text></view>
</view>
<view class="body">
<block wx:if="{{!listArr.length}}">
<view class="body-data Bflex">
<view class="no-data-td ">暂无数据</view>
</view>
</block>
<block wx:else>
<view class="body-data Bflex" wx:for="{{listArr}}" wx:key="index">
<view class="td-1 td borderBox Iflex jcc aic td-140" ><text>{{rwVal}}</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>未上架</text></view>
<!-- <view class="td-2 td borderBox Iflex jcc aic"><text>货位</text></view> -->
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>{{item.pallet_sn||"--"}}</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-119"><text>{{item.box_sn||"--"}}</text></view>
<view class="td-2 td borderBox Iflex jcc aic td-141"><text>{{item.goods_name||"--"}}</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>{{item.brand_name||"--"}}</text></view>
<view class="td-2 td borderBox Iflex jcc aic"><text>{{item.number||"--"}}</text></view>
</view>
</block>
</view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<view class="mask " wx:if="{{isShowMask}}">
<view class=" upper-shelf-mask">
<image class="close-icon" src="../../res/img/close-icon.png" bindtap="closeMask"></image>
<view class="tips Bflex jcc aic">
<image src="../../res/img/warn-icon.png" class="warn-icon"></image>
<text class="text">{{maskText}}</text>
</view>
</view>
</view>
</view>
<view class="mask ">
<view class=" upper-shelf-mask">
<image class="close-icon" src="../../res/img/close-icon.png"></image>
<view class="tips Bflex jcc aic">
<image src="../../res/img/warn-icon.png" class="warn-icon"></image>
<text class="text">箱号/型号/卡板号已经上架,无需再次上架,请确认。</text>
</view> </view>
</view> </nav-c>
\ No newline at end of file
</view>
</nav-c>
\ No newline at end of file
...@@ -13,6 +13,7 @@ page { ...@@ -13,6 +13,7 @@ page {
font-size: 14px; font-size: 14px;
color: #666666; color: #666666;
padding: 13px 0; padding: 13px 0;
flex-wrap: wrap;
} }
.desc { .desc {
...@@ -20,7 +21,7 @@ page { ...@@ -20,7 +21,7 @@ page {
} }
.input { .input {
width: 212px; width: 140px;
height: 33px; height: 33px;
color: #333; color: #333;
padding: 0 7px; padding: 0 7px;
...@@ -30,10 +31,11 @@ page { ...@@ -30,10 +31,11 @@ page {
.number, .number,
.hw { .hw {
font-size: 12px; font-size: 12px;
margin-top: 10px;
} }
.number { .number {
margin-left: 8px; margin-left: 33px;
} }
.hw { .hw {
...@@ -90,7 +92,12 @@ page { ...@@ -90,7 +92,12 @@ page {
.data-table .td-119 { .data-table .td-119 {
width: 119px; width: 119px;
} }
.data-table .td-140 {
width: 140px;
}
.data-table .td-141 {
width: 141px;
}
.upper-shelf-mask { .upper-shelf-mask {
width: 320px; width: 320px;
position: fixed; position: fixed;
...@@ -116,6 +123,3 @@ page { ...@@ -116,6 +123,3 @@ page {
.tips .text{ .tips .text{
flex:0 0 185px; flex:0 0 185px;
} }
.mask{
display: none;
}
\ No newline at end of file
...@@ -22,6 +22,10 @@ export const apis = { ...@@ -22,6 +22,10 @@ export const apis = {
put_on_pallet:in_store_url+"/in_store/put_on_pallet",//装卡板 put_on_pallet:in_store_url+"/in_store/put_on_pallet",//装卡板
inquire_stock:in_store_url+"/stock/inquire_stock",//查询实时库存 inquire_stock:in_store_url+"/stock/inquire_stock",//查询实时库存
location_list:in_store_url+"/location/location_list",//获取货位列表 location_list:in_store_url+"/location/location_list",//获取货位列表
sale_task_sn_find_info:in_store_url+"/in_store/sale_task_sn_find_info",//任务号查找所有待上架商品
scan_location:in_store_url+"/in_store/scan_location",//扫描货架
scan_goods_discern:in_store_url+"/in_store/scan_goods_discern",//扫卡板号或者箱号或者型号
hd_pallet_label:in_store_url+"/in_store/hd_pallet_label",//获取卡板标签
// 入库结束 // 入库结束
//出库开始 //出库开始
pick_task_list:out_store_url+'/out_store/pick_task_list',//api_拣货任务明细 pick_task_list:out_store_url+'/out_store/pick_task_list',//api_拣货任务明细
...@@ -33,6 +37,8 @@ export const apis = { ...@@ -33,6 +37,8 @@ export const apis = {
cancel_out_store:out_store_url+"/out_store/cancel_out_store",//api_取消出库 cancel_out_store:out_store_url+"/out_store/cancel_out_store",//api_取消出库
deliver_goods:out_store_url+"/out_store/deliver_goods",//api_发货 deliver_goods:out_store_url+"/out_store/deliver_goods",//api_发货
cancel_pick:out_store_url+"/out_store/cancel_pick",//api_拣货任务取消 cancel_pick:out_store_url+"/out_store/cancel_pick",//api_拣货任务取消
get_box_info1:out_store_url+"/out_store/get_box_info",//api_获取箱包信息
get_pallet_info:out_store_url+"/out_store/get_pallet_info",//补打卡板
//出库结束 //出库结束
get_store_list:in_store_url+"/store_account/get_store_list",//获取仓库列表 get_store_list:in_store_url+"/store_account/get_store_list",//获取仓库列表
change_store:in_store_url+'/store_account/change_store',//变更仓库 change_store:in_store_url+'/store_account/change_store',//变更仓库
......
const formatTime = date => {
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const minute = date.getMinutes()
const second = date.getSeconds()
return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':') const printData = (xnum,weight,arr) =>{
let length = arr.length;
let newLength = Math.ceil(length/10);//十条数据为一个标签
let str = "";
for(let i = 0;i<newLength;i++){
let j = i*10;
let k = (i+1)*10;
str+="! 0 200 200 400 1\n";
str+="B QR 200 0 M 2 2 10\n";
str+="MA,QR code :"+xnum+","+weight+"\n";
str+="ENDQR\n";
str+="TEXT 55 1 200 160 箱号:\n";
str+="TEXT 55 1 250 160 "+xnum+"\n";
str+="TEXT 55 1 200 200 重量:\n";
str+="TEXT 55 1 250 200 "+weight+"\n";
str+="TEXT 55 1 "+380+" 0 型号\n";
str+="TEXT 55 1 "+380+" 0 数量\n";
let newArr = arr.slice(j,k)
for(let s=0;s<newArr.length;s++){
let num = newArr[s].number;
let name = newArr[s].goods_name;
str+="TEXT 55 1 520 "+(40*(s+1))+" "+name+"\n";
str+="TEXT 55 1 520 "+(40*(s+1))+" "+num+"\n";
}
str+="FORM\n";
str+="PRINT\n";
}
return str
} }
const formatNumber = n => {
n = n.toString()
return n[1] ? n : '0' + n
}
module.exports = { module.exports = {
formatTime: formatTime printData: printData
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment