|
@@ -13,7 +13,8 @@
|
|
|
</view>
|
|
|
<view class="space_between">
|
|
|
<view class="waybill_num">运单号: {{waybillNo}}</view>
|
|
|
- <view style="font-size: 28rpx;margin-top: 20rpx;">x{{waybillList.quantity}}</view>
|
|
|
+ <view style="font-size: 28rpx;margin-top: 20rpx;" v-if="printType == 'barCode'">
|
|
|
+ x{{waybillList.quantity}}</view>
|
|
|
</view>
|
|
|
<view class="waybill_numil" v-if="printType == 'record'">请选择运单温湿度时间段</view>
|
|
|
<view class="card_waybill" v-for="(item,index) in timeQuantumList" :key="index" @click="selectChange(item)">
|
|
@@ -27,6 +28,12 @@
|
|
|
@change="changeDatetime($event,item)" />
|
|
|
</view>
|
|
|
</view>
|
|
|
+ <view class="card_waybill" style="margin-top: 20rpx;">
|
|
|
+ <u-radio-group v-model="printerValue" placement="row">
|
|
|
+ <u-radio name="default" label="默认打印机设备"></u-radio>
|
|
|
+ <u-radio name="zicox" style="margin-left: 30rpx;" label="芝柯打印机设备"></u-radio>
|
|
|
+ </u-radio-group>
|
|
|
+ </view>
|
|
|
<view class="card_bluetooth" v-if="pairedDeviceList.length > 0">
|
|
|
<view class="equipment_title">已配对设备</view>
|
|
|
<view class="card_equipment">
|
|
@@ -52,6 +59,8 @@
|
|
|
import util from './gprint/util.js'
|
|
|
import drawQrcode from './gprint/weapp.qrcode.esm.js'
|
|
|
import getCode128 from './gprint/code128'
|
|
|
+ import * as blesdk from './gprint/bluetoolth.js'
|
|
|
+ import gbk from './gprint/printUtil-GBK.js'
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
@@ -76,12 +85,18 @@
|
|
|
checkboxValue: [],
|
|
|
userInfo: {},
|
|
|
disqualification: true,
|
|
|
+ connectBluetooth: {},
|
|
|
+ breakTime: null,
|
|
|
+ printerValue: 'default',
|
|
|
}
|
|
|
},
|
|
|
+ beforeDestroy() {
|
|
|
+ this.closeBLEConnectionil(this.connectBluetooth)
|
|
|
+ },
|
|
|
onLoad(value) {
|
|
|
const arr = this.$cache.getCache('commodity')
|
|
|
this.waybillList = JSON.parse(arr)
|
|
|
- // console.log(this.waybillList, 14)
|
|
|
+ console.log(this.waybillList, 14)
|
|
|
var userInfo = this.$cache.getCache('userInfo')
|
|
|
this.userInfo = userInfo
|
|
|
if (value.printType == 'barCode') {
|
|
@@ -179,12 +194,13 @@
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- connect(value) {
|
|
|
- // console.log(value, 66)
|
|
|
- this.createBLEConnection(value)
|
|
|
+ async connect(value) {
|
|
|
+ const arr = await this.closeBLEConnectionil(this.connectBluetooth)
|
|
|
+ this.connectBluetooth = value
|
|
|
+ await this.createBLEConnectionil(value)
|
|
|
},
|
|
|
// item 是要连接的设备数据
|
|
|
- createBLEConnection(item) {
|
|
|
+ createBLEConnectionil(item) {
|
|
|
let that = this;
|
|
|
that.matchingUnit.deviceId = item.deviceId
|
|
|
uni.showLoading({
|
|
@@ -196,8 +212,8 @@
|
|
|
success(res) {
|
|
|
that.stopFindBule(); // 停止搜索蓝牙
|
|
|
setTimeout(function() {
|
|
|
- that.getBLEDeviceServices(item); // 获取蓝牙的服务
|
|
|
- }, 2000)
|
|
|
+ that.getBLEDeviceServicesil(item); // 获取蓝牙的服务
|
|
|
+ }, 1000)
|
|
|
},
|
|
|
fail(res) {
|
|
|
uni.showToast({
|
|
@@ -208,62 +224,142 @@
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- getBLEDeviceServices(item) {
|
|
|
+ getBLEDeviceServicesil(item) {
|
|
|
const that = this
|
|
|
setTimeout(() => {
|
|
|
uni.getBLEDeviceServices({
|
|
|
// 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
|
|
|
deviceId: item.deviceId,
|
|
|
complete(res) {
|
|
|
- let serviceId = ""
|
|
|
+ console.log(res, '获取服务成功')
|
|
|
+ // let serviceId = ""
|
|
|
if (res.services.length > 0) {
|
|
|
- for (var s = 0; s < res.services.length; s++) {
|
|
|
- let serviceId = res.services[s].uuid
|
|
|
- that.matchingUnit.serviceId = serviceId
|
|
|
- uni.getBLEDeviceCharacteristics({ //获取蓝牙设备某个服务中所有特征值(characteristic)
|
|
|
- // 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
|
|
|
- deviceId: item.deviceId,
|
|
|
- // 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
|
|
|
- serviceId: serviceId,
|
|
|
- success(res) {
|
|
|
- // console.log('获取服务成功')
|
|
|
- that.pairedDeviceList = []
|
|
|
- that.pairedDeviceList.push(item)
|
|
|
- var re = JSON.parse(JSON.stringify(res))
|
|
|
- for (var c = 0; c < re.characteristics.length; c++) {
|
|
|
- if (re.characteristics[c].properties.write ==
|
|
|
- true) {
|
|
|
- let uuid = re.characteristics[c].uuid
|
|
|
- that.matchingUnit.characteristicId = uuid
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- uni.hideLoading()
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
+ let finished = false;
|
|
|
+ that.pairedDeviceList = []
|
|
|
+ that.pairedDeviceList.push(item)
|
|
|
+ that.uniAsyncPromise(item, res).then(flag => {
|
|
|
+ console.log(flag, 24)
|
|
|
+ if (flag) {
|
|
|
+ console.log(that.matchingUnit, 326)
|
|
|
+ uni.hideLoading()
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'success',
|
|
|
+ title: '连接成功',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ console.log(3)
|
|
|
+ that.pairedDeviceList = []
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ title: '获取特征值失败!请重新连接',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ uni.hideLoading()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // const serviceId = res.services.shift().uuid;
|
|
|
} else {
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ title: '连接失败!请重新连接',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
uni.hideLoading()
|
|
|
+ console.log(item, '没有服务')
|
|
|
+ setTimeout(() => {
|
|
|
+ that.closeBLEConnectionil(item)
|
|
|
+ }, 1000)
|
|
|
}
|
|
|
},
|
|
|
fail(res) {
|
|
|
console.log(res)
|
|
|
},
|
|
|
})
|
|
|
+ }, 1000);
|
|
|
+ },
|
|
|
+ uniAsyncPromise(item, arr) {
|
|
|
+ const that = this
|
|
|
+ return new Promise(async (resolve, reject) => {
|
|
|
+ for (var s = 0; s < arr.services.length; s++) {
|
|
|
+ let serviceId = arr.services[s].uuid
|
|
|
+ await uni.getBLEDeviceCharacteristics({ //获取蓝牙设备某个服务中所有特征值(characteristic)
|
|
|
+ // 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
|
|
|
+ deviceId: item.deviceId,
|
|
|
+ // 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
|
|
|
+ serviceId: serviceId,
|
|
|
+ success(res) {
|
|
|
+ let write = false;
|
|
|
+ let notify = false;
|
|
|
+ let indicate = false;
|
|
|
+ var readId;
|
|
|
+ var writeId;
|
|
|
+ console.log(res, serviceId, '获取特征值成功')
|
|
|
+ // that.pairedDeviceList = []
|
|
|
+ // that.pairedDeviceList.push(item)
|
|
|
+ var arrList = JSON.parse(JSON.stringify(res))
|
|
|
+ for (var i = 0; i < arrList.characteristics
|
|
|
+ .length; i++) {
|
|
|
+ if (!notify) {
|
|
|
+ notify = arrList.characteristics[i]
|
|
|
+ .properties
|
|
|
+ .notify;
|
|
|
+ if (notify) readId = arrList
|
|
|
+ .characteristics[i]
|
|
|
+ .uuid;
|
|
|
+ }
|
|
|
+ if (!indicate) {
|
|
|
+ indicate = arrList.characteristics[i]
|
|
|
+ .properties
|
|
|
+ .indicate;
|
|
|
+ if (indicate) readId = arrList
|
|
|
+ .characteristics[
|
|
|
+ i].uuid;
|
|
|
+ }
|
|
|
+ if (!write) {
|
|
|
+ write = arrList.characteristics[i]
|
|
|
+ .properties
|
|
|
+ .write;
|
|
|
+ writeId = arrList.characteristics[i].uuid;
|
|
|
+ }
|
|
|
+ if ((notify || indicate) && write) {
|
|
|
+ console.log(2)
|
|
|
+ /* 获取蓝牙特征值uuid */
|
|
|
+ let uuid = arrList.characteristics[i].uuid
|
|
|
+ that.matchingUnit.characteristicId = uuid
|
|
|
+ that.matchingUnit.serviceId = serviceId
|
|
|
+ resolve(true);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
});
|
|
|
},
|
|
|
// 断开连接
|
|
|
- closeBLEConnection(item) {
|
|
|
- uni.closeBLEConnection({
|
|
|
- deviceId: item.deviceId,
|
|
|
- success: (res) => {
|
|
|
- // res.characteristics 特征值列表
|
|
|
- // 读写都需要用到特征值
|
|
|
- },
|
|
|
- fail: (res) => {
|
|
|
- console.log(res);
|
|
|
- },
|
|
|
- })
|
|
|
+ async closeBLEConnectionil(event) {
|
|
|
+ if (event.deviceId) {
|
|
|
+ let that = this
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ uni.closeBLEConnection({
|
|
|
+ deviceId: event.deviceId,
|
|
|
+ success: (res) => {
|
|
|
+ console.log(res, '断开连接')
|
|
|
+ if (that.breakTime) {
|
|
|
+ clearTimeout(that.breakTime)
|
|
|
+ }
|
|
|
+ that.breakTime = setTimeout(() => {
|
|
|
+ resolve(true)
|
|
|
+ }, 1000)
|
|
|
+ },
|
|
|
+ fail: (res) => {
|
|
|
+ console.log(res, '断开失败')
|
|
|
+ reject(false)
|
|
|
+ },
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
// 配对设备打印
|
|
|
async getPrint(value) {
|
|
@@ -300,186 +396,301 @@
|
|
|
const ENV = require('../../.env.js')
|
|
|
let logistics = ENV.APP_LINK_URL + '/WaybillInquiry?waybillNo=' + codeValue
|
|
|
let code128 = getCode128(codeValue);
|
|
|
- let numArr = []
|
|
|
- for (var i = 0; i < this.waybillList.quantity; i++) {
|
|
|
- let numa = i + 1
|
|
|
- numArr.push(numa)
|
|
|
+ if (this.printerValue == 'zicox') {
|
|
|
+ let strCmd = blesdk.CreatCPCLPage(384, 820 * this.waybillList.quantity, 1, 0);
|
|
|
+ for (var i = 0; i < this.waybillList.quantity; i++) {
|
|
|
+ let numa = i + 1
|
|
|
+ let name = showFirstName(this.waybillList.senderAddressName)
|
|
|
+ let phone = this.waybillList.senderAddressPhone.substr(0, 3) + "****" + this
|
|
|
+ .waybillList
|
|
|
+ .senderAddressPhone.substr(7)
|
|
|
+ let name1 = showFirstName(this.waybillList.consigneeAddressName)
|
|
|
+ let phone1 = this.waybillList.consigneeAddressPhone.substr(0, 3) + "****" + this
|
|
|
+ .waybillList
|
|
|
+ .consigneeAddressPhone.substr(7)
|
|
|
+ strCmd += blesdk.addCPCLLocation(0);
|
|
|
+ strCmd += blesdk.addCPCLSETMAG(0, 0);
|
|
|
+ strCmd += blesdk.addCPCLText(0, 0 + 820 * i, '24', '0', 0, `#${this.userInfo.dept.name}`);
|
|
|
+ strCmd += blesdk.addCPCLText(0, 30 + 820 * i, '24', '0', 0, numa + '/' + this.waybillList
|
|
|
+ .quantity);
|
|
|
+ strCmd += blesdk.addCPCLLocation(2);
|
|
|
+ strCmd += blesdk.addCPCLBarCode(0, 50 + 820 * i, '128', 80, 0, 1, 1, '202405131452870423');
|
|
|
+ strCmd += blesdk.addCPCLText(0, 130 + 820 * i, '7', '2', 0, '202405131452870423');
|
|
|
+ strCmd += blesdk.addCPCLLocation(0);
|
|
|
+ strCmd += blesdk.addCPCLSETMAG(2, 2);
|
|
|
+ strCmd += blesdk.addCPCLText(0, 160 + 820 * i, '24', '0', 0, '收:');
|
|
|
+ strCmd += blesdk.addCPCLSETMAG(0, 0);
|
|
|
+ strCmd += blesdk.addCPCLText(90, 180 + 820 * i, '24', '0', 0, `${name}`);
|
|
|
+ strCmd += blesdk.addCPCLText(150, 180 + 820 * i, '24', '0', 0, `${phone}`);
|
|
|
+ strCmd += blesdk.addCPCLTextil(0, 210 + 820 * i, '24', '0', 0, this.waybillList
|
|
|
+ .senderAddressDetails);
|
|
|
+ strCmd += blesdk.addCPCLSETMAG(2, 2);
|
|
|
+ strCmd += blesdk.addCPCLText(0, 270 + 820 * i, '24', '0', 0, '寄:');
|
|
|
+ strCmd += blesdk.addCPCLSETMAG(0, 0);
|
|
|
+ strCmd += blesdk.addCPCLText(90, 290 + 820 * i, '24', '0', 0, `${name1}`);
|
|
|
+ strCmd += blesdk.addCPCLText(150, 290 + 820 * i, '24', '0', 0, `${phone1}`);
|
|
|
+ strCmd += blesdk.addCPCLTextil(0, 320 + 820 * i, '24', '0', 0, this.waybillList
|
|
|
+ .consigneeAddressDetails);
|
|
|
+ // strCmd += blesdk.addCPCLLine(0, 380, 384, 380, 1);
|
|
|
+ strCmd += blesdk.addCPCLText(0, 390 + 820 * i, '3', '0', 0, '下单时间:' + this.waybillList
|
|
|
+ .orderTime);
|
|
|
+ strCmd += blesdk.addCPCLText(0, 420 + 820 * i, '3', '0', 0, '备注:货物类型:' + this.waybillList
|
|
|
+ .cargoType);
|
|
|
+ strCmd += blesdk.addCPCLText(60, 450 + 820 * i, '3', '0', 0, '温度需求:' + this.waybillList
|
|
|
+ .temperatureInterval);
|
|
|
+ strCmd += blesdk.addCPCLText(60, 480 + 820 * i, '3', '0', 0, '配送要求:' + this.waybillList
|
|
|
+ .deliveryCondition);
|
|
|
+ strCmd += blesdk.addCPCLLocation(2);
|
|
|
+ strCmd += blesdk.addCPCLQRCode(0, 510 + 820 * i, 'M', 3, 5, `${logistics}`);
|
|
|
+ strCmd += blesdk.addCPCLText(0, 700 + 820 * i, '24', '0', 0, '扫码查询物流温湿度信息');
|
|
|
+ }
|
|
|
+ strCmd += blesdk.addCPCLPrint();
|
|
|
+ uni.hideLoading()
|
|
|
+ let buffer = gbk.strToGBKByte(strCmd)
|
|
|
+ // this.printbuffs(buffer);
|
|
|
+ let opt = {
|
|
|
+ deviceId: this.deviceId,
|
|
|
+ serviceId: this.serviceId,
|
|
|
+ characteristicId: this.characteristicId,
|
|
|
+ value: buffer,
|
|
|
+ onceLength: 20
|
|
|
+ }
|
|
|
+ blesdk.sendDataToDevice(opt);
|
|
|
+ } else {
|
|
|
+ let numArr = []
|
|
|
+ for (var i = 0; i < this.waybillList.quantity; i++) {
|
|
|
+ let numa = i + 1
|
|
|
+ numArr.push(numa)
|
|
|
+ }
|
|
|
+ numArr.forEach((numitem, indexnum) => {
|
|
|
+ printerJobs
|
|
|
+ .setSize(1, 1)
|
|
|
+ .setAlign('LT')
|
|
|
+ .print('#' + this.userInfo.dept.name)
|
|
|
+ .print(numitem + '/' + this.waybillList.quantity)
|
|
|
+ .setAlign('CT')
|
|
|
+ .printBarcode(code128)
|
|
|
+ .setSize(1, 1)
|
|
|
+ .setAlign('LT')
|
|
|
+ // .text(' ')
|
|
|
+ // .text(codeValue + ' \n')
|
|
|
+ // .print(printerUtil.fillLine())
|
|
|
+ .setAlign('LT')
|
|
|
+ .setSize(1, 2)
|
|
|
+ .setSize(2, 1)
|
|
|
+ .setBold()
|
|
|
+ .text('收:')
|
|
|
+ .setSize(1, 1)
|
|
|
+ .setBold(false)
|
|
|
+ .text(' ' + showFirstName(this.waybillList.senderAddressName))
|
|
|
+ .text(' ' + this.waybillList.senderAddressPhone.substr(0, 3) + "****" + this
|
|
|
+ .waybillList
|
|
|
+ .senderAddressPhone.substr(7) + ' \n')
|
|
|
+ .print(shippingAddress(this.waybillList.senderAddressDetails))
|
|
|
+ .setSize(1, 2)
|
|
|
+ .setSize(2, 1)
|
|
|
+ .setBold()
|
|
|
+ .text('寄:')
|
|
|
+ .setSize(1, 1)
|
|
|
+ .setBold(false)
|
|
|
+ .text(' ' + showFirstName(this.waybillList.consigneeAddressName))
|
|
|
+ .text(' ' + this.waybillList.consigneeAddressPhone.substr(0, 3) + "****" + this
|
|
|
+ .waybillList
|
|
|
+ .consigneeAddressPhone.substr(7) + ' \n')
|
|
|
+ .print(shippingAddress(this.waybillList.consigneeAddressDetails))
|
|
|
+ .print(printerUtil.fillLine())
|
|
|
+ .print('下单时间:' + this.waybillList.orderTime)
|
|
|
+ // .print(printerUtil.fillLine())
|
|
|
+ .text('备注:')
|
|
|
+ .text('货物类型:' + this.waybillList.cargoType + ' \n')
|
|
|
+ .print(' 温度需求:' + this.waybillList.temperatureInterval)
|
|
|
+ .print(' 配送要求:' + this.waybillList.deliveryCondition)
|
|
|
+ .setAlign('CT')
|
|
|
+ .printQrcode(logistics)
|
|
|
+ .print('扫码查询物流温湿度信息 \n')
|
|
|
+ .println()
|
|
|
+ })
|
|
|
+ let buffer = printerJobs.buffer();
|
|
|
+ // this.printbuffs(buffer);
|
|
|
+ let opt = {
|
|
|
+ deviceId: this.deviceId,
|
|
|
+ serviceId: this.serviceId,
|
|
|
+ characteristicId: this.characteristicId,
|
|
|
+ value: buffer,
|
|
|
+ onceLength: 20
|
|
|
+ }
|
|
|
+ blesdk.sendDataToDevice(opt);
|
|
|
}
|
|
|
- numArr.forEach((numitem, indexnum) => {
|
|
|
+ } else {
|
|
|
+ var flag = true;
|
|
|
+ for (let i = 0, len = this.humitureData.length; i < len; i++) {
|
|
|
+ if (!this.humitureData[i].belowStandard) {
|
|
|
+ flag = false;
|
|
|
+ uni.$u.toast('数据不合格,无法打印!')
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 选择项全部合格
|
|
|
+ if (flag) {
|
|
|
+ // if (this.printerValue == 'zicox') {
|
|
|
+ // let strHum = blesdk.CreatCPCLPage(384, 300, 1, 0);
|
|
|
+ // strHum += blesdk.addCPCLText(0, 0, '24', '0', 0, `#${this.userInfo.dept.name}`);
|
|
|
+ // strHum += blesdk.addCPCLText(0, 0, '24', '0', 0, `运单号:${this.waybillList.waybillNo}`);
|
|
|
+ // strHum += blesdk.addCPCLText(0, 0, '24', '0', 0, `货物类型:${this.waybillList.cargoType}`);
|
|
|
+ // strHum += blesdk.addCPCLText(0, 0, '24', '0', 0, `温度需求:${this.waybillList.temperatureInterval}`);
|
|
|
+ // strHum += blesdk.addCPCLText(0, 0, '24', '0', 0, `配送要求:${this.waybillList.deliveryCondition}`);
|
|
|
+ // strHum += blesdk.addCPCLText(0, 0, '24', '0', 0, `寄件人:${this.waybillList.senderAddressName}`);
|
|
|
+ // strHum += blesdk.addCPCLText(0, 0, '24', '0', 0, `收件人:${this.waybillList.consigneeAddressName}`);
|
|
|
+ // } else {
|
|
|
+
|
|
|
+ // }
|
|
|
+ let printerJobs = new PrinterJobs();
|
|
|
printerJobs
|
|
|
.setSize(1, 1)
|
|
|
- .setAlign('LT')
|
|
|
+ .setAlign('lt')
|
|
|
.print('#' + this.userInfo.dept.name)
|
|
|
- .print(numitem + '/' + this.waybillList.quantity)
|
|
|
- .setAlign('CT')
|
|
|
- .printBarcode(code128)
|
|
|
- .setSize(1, 1)
|
|
|
- .setAlign('LT')
|
|
|
- // .text(' ')
|
|
|
- // .text(codeValue + ' \n')
|
|
|
- // .print(printerUtil.fillLine())
|
|
|
-
|
|
|
- .setAlign('LT')
|
|
|
- .setSize(1, 2)
|
|
|
- .setSize(2, 1)
|
|
|
- .setBold()
|
|
|
- .text('收:')
|
|
|
- .setSize(1, 1)
|
|
|
- .setBold(false)
|
|
|
- .text(' ' + showFirstName(this.waybillList.senderAddressName))
|
|
|
- .text(' ' + this.waybillList.senderAddressPhone.substr(0, 3) + "****" + this
|
|
|
- .waybillList
|
|
|
- .senderAddressPhone.substr(7) + ' \n')
|
|
|
- .print(shippingAddress(this.waybillList.senderAddressDetails))
|
|
|
- .setSize(1, 2)
|
|
|
- .setSize(2, 1)
|
|
|
- .setBold()
|
|
|
- .text('寄:')
|
|
|
- .setSize(1, 1)
|
|
|
- .setBold(false)
|
|
|
- .text(' ' + showFirstName(this.waybillList.consigneeAddressName))
|
|
|
- .text(' ' + this.waybillList.consigneeAddressPhone.substr(0, 3) + "****" + this
|
|
|
- .waybillList
|
|
|
- .consigneeAddressPhone.substr(7) + ' \n')
|
|
|
- .print(shippingAddress(this.waybillList.consigneeAddressDetails))
|
|
|
+ .print('运单号:' + this.waybillList.waybillNo)
|
|
|
+ .print('货物类型:' + this.waybillList.cargoType)
|
|
|
+ .print('温度需求:' + this.waybillList.temperatureInterval)
|
|
|
+ .print('配送要求:' + this.waybillList.deliveryCondition)
|
|
|
+ .print('寄件人:' + this.waybillList.senderAddressName)
|
|
|
+ .print('收件人:' + this.waybillList.consigneeAddressName)
|
|
|
.print(printerUtil.fillLine())
|
|
|
- .print('下单时间:' + this.waybillList.orderTime)
|
|
|
- // .print(printerUtil.fillLine())
|
|
|
- .text('备注:')
|
|
|
- .text('货物类型:' + this.waybillList.cargoType + ' \n')
|
|
|
- .print(' 温度需求:' + this.waybillList.temperatureInterval)
|
|
|
- .print(' 配送要求:' + this.waybillList.deliveryCondition)
|
|
|
- .setAlign('CT')
|
|
|
- .printQrcode(logistics)
|
|
|
- .print('扫码查询物流温湿度信息 \n')
|
|
|
- .println()
|
|
|
- })
|
|
|
- let buffer = printerJobs.buffer();
|
|
|
- this.printbuffs(buffer);
|
|
|
- } else {
|
|
|
- let printerJobs = new PrinterJobs();
|
|
|
- printerJobs
|
|
|
- .setSize(1, 1)
|
|
|
- .setAlign('lt')
|
|
|
- .print('#' + this.userInfo.dept.name)
|
|
|
- .print('运单号:' + this.waybillNo)
|
|
|
- .print('货物类型:' + this.waybillList.cargoType)
|
|
|
- .print('温度需求:' + this.waybillList.temperatureInterval)
|
|
|
- .print('配送要求:' + this.waybillList.deliveryCondition)
|
|
|
- .print('寄件人:' + this.waybillList.senderAddressName)
|
|
|
- .print('收件人:' + this.waybillList.consigneeAddressName)
|
|
|
- .print(printerUtil.fillLine())
|
|
|
- this.humitureData.forEach((item, index) => {
|
|
|
- // console.log(item,123)
|
|
|
- const exists = this.checkboxValue.some(Tid => Tid === item.id);
|
|
|
- if (item.isChecked) {
|
|
|
- // printerJobs
|
|
|
- // .print('设备号:' + item.sn)
|
|
|
- // .print('标识名:' + item.title)
|
|
|
- // .print('开始时间:' + item.startTime)
|
|
|
- // .print('结束时间:' + item.endTime)
|
|
|
- // .print(printerUtil.fillLine())
|
|
|
- item.arr.forEach((item1, index1) => {
|
|
|
- if (item1.arrNum < 2) {
|
|
|
- printerJobs
|
|
|
- .print('日期:' + item1.time + '单位℃ ')
|
|
|
- .text('时间 ')
|
|
|
- .text('|')
|
|
|
- .text(' ')
|
|
|
- .text('T1 ')
|
|
|
- .text(' ')
|
|
|
- .text('|')
|
|
|
- .text(' ')
|
|
|
- .text('T2 ')
|
|
|
- .text(' ')
|
|
|
- .text('|')
|
|
|
- .text(' ')
|
|
|
- .text('T3 ')
|
|
|
- .text(' ')
|
|
|
- .text('|')
|
|
|
- .text(' ')
|
|
|
- .text('T4 \n')
|
|
|
- item1.arr.forEach((item2, index2) => {
|
|
|
+ this.humitureData.forEach((item, index) => {
|
|
|
+ // console.log(item,123)
|
|
|
+ const exists = this.checkboxValue.some(Tid => Tid === item.id);
|
|
|
+ if (item.isChecked) {
|
|
|
+ // printerJobs
|
|
|
+ // .print('设备号:' + item.sn)
|
|
|
+ // .print('标识名:' + item.title)
|
|
|
+ // .print('开始时间:' + item.startTime)
|
|
|
+ // .print('结束时间:' + item.endTime)
|
|
|
+ // .print(printerUtil.fillLine())
|
|
|
+ item.arr.forEach((item1, index1) => {
|
|
|
+ if (item1.arrNum < 2) {
|
|
|
printerJobs
|
|
|
- .text(`${item2[0].time}`)
|
|
|
+ .print('日期:' + item1.time + '单位℃ ')
|
|
|
+ .text('时间 ')
|
|
|
.text('|')
|
|
|
.text(' ')
|
|
|
- .text(
|
|
|
- `${item2[0] == '---' ? '----' : character(item2[0].T_t) }`
|
|
|
- )
|
|
|
+ .text('T1 ')
|
|
|
.text(' ')
|
|
|
.text('|')
|
|
|
.text(' ')
|
|
|
- .text(
|
|
|
- `${item2[1] == '---' ? '----' : character(item2[1].T_t) }`
|
|
|
- )
|
|
|
+ .text('T2 ')
|
|
|
.text(' ')
|
|
|
.text('|')
|
|
|
.text(' ')
|
|
|
- .text(
|
|
|
- `${item2[2] == '---' ? '----' : character(item2[2].T_t) }`
|
|
|
- )
|
|
|
+ .text('T3 ')
|
|
|
.text(' ')
|
|
|
.text('|')
|
|
|
.text(' ')
|
|
|
- .text(
|
|
|
- `${item2[3] == '---' ? '----' : character(item2[3].T_t) }`
|
|
|
- )
|
|
|
+ .text('T4 \n')
|
|
|
+ item1.arr.forEach((item2, index2) => {
|
|
|
+ printerJobs
|
|
|
+ .text(`${item2[0].time}`)
|
|
|
+ .text('|')
|
|
|
+ .text(' ')
|
|
|
+ .text(
|
|
|
+ `${item2[0] == '---' ? '----' : character(item2[0].T_t) }`
|
|
|
+ )
|
|
|
+ .text(' ')
|
|
|
+ .text('|')
|
|
|
+ .text(' ')
|
|
|
+ .text(
|
|
|
+ `${item2[1] == '---' ? '----' : character(item2[1].T_t) }`
|
|
|
+ )
|
|
|
+ .text(' ')
|
|
|
+ .text('|')
|
|
|
+ .text(' ')
|
|
|
+ .text(
|
|
|
+ `${item2[2] == '---' ? '----' : character(item2[2].T_t) }`
|
|
|
+ )
|
|
|
+ .text(' ')
|
|
|
+ .text('|')
|
|
|
+ .text(' ')
|
|
|
+ .text(
|
|
|
+ `${item2[3] == '---' ? '----' : character(item2[3].T_t) }`
|
|
|
+ )
|
|
|
|
|
|
- function character(value) {
|
|
|
- var arr = value.toFixed(1)
|
|
|
- if (arr.length == 3) {
|
|
|
- var arr1 = arr + ' '
|
|
|
- return arr1
|
|
|
- } else {
|
|
|
- return arr
|
|
|
+ function character(value) {
|
|
|
+ var arr = value.toFixed(1)
|
|
|
+ if (arr.length == 3) {
|
|
|
+ var arr1 = arr + ' '
|
|
|
+ return arr1
|
|
|
+ } else {
|
|
|
+ return arr
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- printerJobs
|
|
|
- .print('日期:' + item1.time + '单位℃ ')
|
|
|
- .text('时间')
|
|
|
- .text('|')
|
|
|
- .text('温度(℃)')
|
|
|
- .text(' ')
|
|
|
- .text('时间')
|
|
|
- .text('|')
|
|
|
- .text('温度(℃) \n')
|
|
|
- item1.arr.forEach((item2, index2) => {
|
|
|
+ })
|
|
|
+ } else {
|
|
|
printerJobs
|
|
|
- .text(`${item2[0].time}`)
|
|
|
+ .print('日期:' + item1.time + '单位℃ ')
|
|
|
+ .text('时间')
|
|
|
.text('|')
|
|
|
- .text(
|
|
|
- `${item2[0] == '---' ? '----' : character(item2[0].T_t) }`
|
|
|
- )
|
|
|
+ .text('温度(℃)')
|
|
|
+ .text(' ')
|
|
|
+ .text('时间')
|
|
|
.text('|')
|
|
|
- .text(
|
|
|
- `${item2[1] == '---' ? '----' : character(item2[1].T_t) }`
|
|
|
- )
|
|
|
- .text(' ')
|
|
|
+ .text('温度(℃) \n')
|
|
|
+ item1.arr.forEach((item2, index2) => {
|
|
|
+ printerJobs
|
|
|
+ .text(`${item2[0].time}`)
|
|
|
+ .text('|')
|
|
|
+ .text(
|
|
|
+ `${item2[0] == '---' ? '----' : character(item2[0].T_t) }`
|
|
|
+ )
|
|
|
+ .text('|')
|
|
|
+ .text(
|
|
|
+ `${item2[1] == '---' ? '----' : character(item2[1].T_t) }`
|
|
|
+ )
|
|
|
+ .text(' ')
|
|
|
+ if (isEven(index2 + 1)) {
|
|
|
+ printerJobs.text(' \n')
|
|
|
+ }
|
|
|
+
|
|
|
+ function isEven(num) {
|
|
|
+ return num % 2 === 0;
|
|
|
+ }
|
|
|
|
|
|
- function character(value) {
|
|
|
- var arr = value.toFixed(1)
|
|
|
- if (arr.length == 3) {
|
|
|
- var arr1 = arr + ' '
|
|
|
- return arr1
|
|
|
- } else {
|
|
|
- return arr
|
|
|
+ function character(value) {
|
|
|
+ var arr = value.toFixed(1)
|
|
|
+ if (arr.length == 3) {
|
|
|
+ var arr1 = arr + ' '
|
|
|
+ return arr1
|
|
|
+ } else {
|
|
|
+ return arr
|
|
|
+ }
|
|
|
}
|
|
|
+ })
|
|
|
+
|
|
|
+ function isLengthOdd(array) {
|
|
|
+ return array.length % 2 === 1;
|
|
|
}
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- // printerJobs.println()
|
|
|
+ if (isLengthOdd(item1.arr)) {
|
|
|
+ printerJobs.text(' \n')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // printerJobs.println()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ printerJobs.println()
|
|
|
+ let buffer = printerJobs.buffer();
|
|
|
+ // this.printbuffs(buffer);
|
|
|
+ let opt = {
|
|
|
+ deviceId: this.deviceId,
|
|
|
+ serviceId: this.serviceId,
|
|
|
+ characteristicId: this.characteristicId,
|
|
|
+ value: buffer,
|
|
|
+ onceLength: 20
|
|
|
}
|
|
|
- })
|
|
|
- printerJobs.println()
|
|
|
- let buffer = printerJobs.buffer();
|
|
|
- this.printbuffs(buffer);
|
|
|
+ blesdk.sendDataToDevice(opt);
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
- printbuffs(buffer) {
|
|
|
+ async printbuffs(buffer) {
|
|
|
+ uni.hideLoading()
|
|
|
// 1.并行调用多次会存在写失败的可能性
|
|
|
// 2.建议每次写入不超过20字节
|
|
|
// 分包处理,延时调用
|
|
@@ -487,7 +698,7 @@
|
|
|
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(this.printbuff, j * delay, subPackage);
|
|
|
+ setTimeout(await this.printbuff, j * delay, subPackage);
|
|
|
}
|
|
|
},
|
|
|
printbuff(buffer) {
|
|
@@ -573,8 +784,6 @@
|
|
|
},
|
|
|
// 获取温湿度信息
|
|
|
humitureInfo(value) {
|
|
|
- // console.log(printList(), 2666)
|
|
|
- // console.log(value, 25)
|
|
|
let arrData = value
|
|
|
let arrData1 = printList()
|
|
|
arrData.forEach((item, index) => {
|
|
@@ -588,96 +797,112 @@
|
|
|
waybillNo: this.waybillNo,
|
|
|
page: 1,
|
|
|
pageSize: 9999,
|
|
|
+ startTime: item.startTime,
|
|
|
+ endTime: item.endTime,
|
|
|
}
|
|
|
- // console.log(item,999)
|
|
|
item.arr = []
|
|
|
this.getWaybillTask(params).then(res => {
|
|
|
- const arrL = JSON.parse(JSON.stringify(res))
|
|
|
- const timeList = JSON.parse(JSON.stringify(res))
|
|
|
- const arrLil = res
|
|
|
- for (let i = 0; i < arrLil.length; i++) {
|
|
|
- for (let j = i + 1; j < arrLil.length; j++) {
|
|
|
- if (arrLil[i].T_time == arrLil[j].T_time) {
|
|
|
- arrLil.splice(j, 1);
|
|
|
- j--;
|
|
|
+ if (!res) {
|
|
|
+ item.belowStandard = false
|
|
|
+ } else {
|
|
|
+ item.belowStandard = true
|
|
|
+ const arrL = JSON.parse(JSON.stringify(res))
|
|
|
+ const timeList = JSON.parse(JSON.stringify(res))
|
|
|
+ const arrLil = res
|
|
|
+ for (let i = 0; i < arrLil.length; i++) {
|
|
|
+ for (let j = i + 1; j < arrLil.length; j++) {
|
|
|
+ if (arrLil[i].T_time == arrLil[j].T_time) {
|
|
|
+ arrLil.splice(j, 1);
|
|
|
+ j--;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- var resultArr = arrLil
|
|
|
- let list1 = []
|
|
|
- resultArr.forEach(k => {
|
|
|
- let arr1 = {
|
|
|
- T_sn: k.T_sn,
|
|
|
- time: k.T_time,
|
|
|
- arr: [],
|
|
|
- }
|
|
|
- list1.push(arr1)
|
|
|
- })
|
|
|
- this.maxData = list1
|
|
|
- for (let i = 0; i < timeList.length; i++) {
|
|
|
- for (let j = i + 1; j < timeList.length; j++) {
|
|
|
- if (timeList[i].time == timeList[j].time) {
|
|
|
- timeList.splice(j, 1);
|
|
|
- j--;
|
|
|
+ var resultArr = arrLil
|
|
|
+ let list1 = []
|
|
|
+ resultArr.forEach(k => {
|
|
|
+ let arr1 = {
|
|
|
+ T_sn: k.T_sn,
|
|
|
+ time: k.T_time,
|
|
|
+ arr: [],
|
|
|
+ }
|
|
|
+ list1.push(arr1)
|
|
|
+ })
|
|
|
+ this.maxData = list1
|
|
|
+ for (let i = 0; i < timeList.length; i++) {
|
|
|
+ for (let j = i + 1; j < timeList.length; j++) {
|
|
|
+ if (timeList[i].time == timeList[j].time) {
|
|
|
+ timeList.splice(j, 1);
|
|
|
+ j--;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- this.maxData.forEach((item3, index3) => {
|
|
|
- timeList.forEach((item2, index2) => {
|
|
|
- const result1 = arrL.find(fruit => fruit.T_id === 1 &&
|
|
|
- fruit.time === item2.time && fruit.T_time === item3
|
|
|
- .time)
|
|
|
- const result2 = arrL.find(fruit => fruit.T_id === 2 &&
|
|
|
- fruit.time === item2.time && fruit.T_time === item3
|
|
|
- .time)
|
|
|
- const result3 = arrL.find(fruit => fruit.T_id === 3 &&
|
|
|
- fruit.time === item2.time && fruit.T_time === item3
|
|
|
- .time)
|
|
|
- const result4 = arrL.find(fruit => fruit.T_id === 4 &&
|
|
|
- fruit.time === item2.time && fruit.T_time === item3
|
|
|
- .time)
|
|
|
+ this.maxData.forEach((item3, index3) => {
|
|
|
+ timeList.forEach((item2, index2) => {
|
|
|
+ const result1 = arrL.find(fruit => fruit.T_id === 1 &&
|
|
|
+ fruit.time === item2.time && fruit.T_time ===
|
|
|
+ item3
|
|
|
+ .time)
|
|
|
+ const result2 = arrL.find(fruit => fruit.T_id === 2 &&
|
|
|
+ fruit.time === item2.time && fruit.T_time ===
|
|
|
+ item3
|
|
|
+ .time)
|
|
|
+ const result3 = arrL.find(fruit => fruit.T_id === 3 &&
|
|
|
+ fruit.time === item2.time && fruit.T_time ===
|
|
|
+ item3
|
|
|
+ .time)
|
|
|
+ const result4 = arrL.find(fruit => fruit.T_id === 4 &&
|
|
|
+ fruit.time === item2.time && fruit.T_time ===
|
|
|
+ item3
|
|
|
+ .time)
|
|
|
|
|
|
- const flag = areAllUndefined(result1, result2, result3,
|
|
|
- result4)
|
|
|
- if (!flag) {
|
|
|
- function countFalseObjects(objects) {
|
|
|
- let count = 0;
|
|
|
- for (let i = 0; i < objects.length; i++) {
|
|
|
- if (objects[i] === undefined) {
|
|
|
- count++;
|
|
|
+ const flag = areAllUndefined(result1, result2, result3,
|
|
|
+ result4)
|
|
|
+ if (!flag) {
|
|
|
+ function countFalseObjects(objects) {
|
|
|
+ let count = 0;
|
|
|
+ for (let i = 0; i < objects.length; i++) {
|
|
|
+ if (objects[i] === undefined) {
|
|
|
+ count++;
|
|
|
+ }
|
|
|
}
|
|
|
+ return count;
|
|
|
}
|
|
|
- return count;
|
|
|
- }
|
|
|
- const arrNum = countFalseObjects([result1, result2,
|
|
|
- result3, result4
|
|
|
- ])
|
|
|
- let list2 = []
|
|
|
- if (arrNum < 2) {
|
|
|
- list2.push(result1 == undefined ? '---' : result1)
|
|
|
- list2.push(result2 == undefined ? '---' : result2)
|
|
|
- list2.push(result3 == undefined ? '---' : result3)
|
|
|
- list2.push(result4 == undefined ? '---' : result4)
|
|
|
- } else {
|
|
|
- list2.push(result1 == undefined ? '---' : result1)
|
|
|
- list2.push(result2 == undefined ? '---' : result2)
|
|
|
+ const arrNum = countFalseObjects([result1, result2,
|
|
|
+ result3, result4
|
|
|
+ ])
|
|
|
+ let list2 = []
|
|
|
+ if (arrNum < 2) {
|
|
|
+ list2.push(result1 == undefined ? '---' :
|
|
|
+ result1)
|
|
|
+ list2.push(result2 == undefined ? '---' :
|
|
|
+ result2)
|
|
|
+ list2.push(result3 == undefined ? '---' :
|
|
|
+ result3)
|
|
|
+ list2.push(result4 == undefined ? '---' :
|
|
|
+ result4)
|
|
|
+ } else {
|
|
|
+ list2.push(result1 == undefined ? '---' :
|
|
|
+ result1)
|
|
|
+ list2.push(result2 == undefined ? '---' :
|
|
|
+ result2)
|
|
|
+ }
|
|
|
+ // let list2 = [
|
|
|
+ // result1 == undefined ? '---' : result1,
|
|
|
+ // result2 == undefined ? '---' : result2,
|
|
|
+ // result3 == undefined ? '---' : result3,
|
|
|
+ // result4 == undefined ? '---' : result4,
|
|
|
+ // ]
|
|
|
+ item3.arrNum = arrNum
|
|
|
+ item3.arr.push(list2)
|
|
|
}
|
|
|
- // let list2 = [
|
|
|
- // result1 == undefined ? '---' : result1,
|
|
|
- // result2 == undefined ? '---' : result2,
|
|
|
- // result3 == undefined ? '---' : result3,
|
|
|
- // result4 == undefined ? '---' : result4,
|
|
|
- // ]
|
|
|
- item3.arrNum = arrNum
|
|
|
- item3.arr.push(list2)
|
|
|
- }
|
|
|
|
|
|
- function areAllUndefined(...args) {
|
|
|
- return args.every(arg => arg === undefined);
|
|
|
- }
|
|
|
+ function areAllUndefined(...args) {
|
|
|
+ return args.every(arg => arg === undefined);
|
|
|
+ }
|
|
|
+ })
|
|
|
})
|
|
|
- })
|
|
|
- item.arr = this.maxData
|
|
|
+ item.arr = this.maxData
|
|
|
+ }
|
|
|
})
|
|
|
})
|
|
|
this.humitureData = arrData
|
|
@@ -709,22 +934,26 @@
|
|
|
})
|
|
|
resolve(arr2)
|
|
|
}
|
|
|
- } else {
|
|
|
- this.disqualification = false
|
|
|
- let arr2 = []
|
|
|
- resolve(arr2)
|
|
|
+ this.disqualification = true
|
|
|
+ } else if (res.code == 5000) {
|
|
|
+ // this.disqualification = false
|
|
|
+ // let arr2 = []
|
|
|
+ // resolve(arr2)
|
|
|
+ resolve(false)
|
|
|
}
|
|
|
})
|
|
|
});
|
|
|
},
|
|
|
- changeDatetime(value, item) {
|
|
|
- console.log(value, item, 24)
|
|
|
+ changeDatetime(value, data) {
|
|
|
this.timeQuantumList.forEach((item, index) => {
|
|
|
- if (value.id == item.id) {
|
|
|
- console.log(item, 23)
|
|
|
+ if (data.id == item.id) {
|
|
|
item.datetimeRange = value
|
|
|
+ item.startTime = value[0]
|
|
|
+ item.endTime = value[1]
|
|
|
}
|
|
|
})
|
|
|
+ this.humitureData = []
|
|
|
+ this.humitureInfo(this.timeQuantumList)
|
|
|
}
|
|
|
}
|
|
|
}
|