|
@@ -1,21 +1,19 @@
|
|
|
<template>
|
|
<template>
|
|
|
- <z-paging ref="paging" bgColor="#fff" safe-area-inset-bottom scroll-with-animation>
|
|
|
|
|
|
|
+ <z-paging ref="paging" bgColor="#f7f7f7" safe-area-inset-bottom scroll-with-animation>
|
|
|
<template #top>
|
|
<template #top>
|
|
|
<ut-navbar :title="stepsObject[currentStep].title" :fixed="false" border :breadcrumb="false"></ut-navbar>
|
|
<ut-navbar :title="stepsObject[currentStep].title" :fixed="false" border :breadcrumb="false"></ut-navbar>
|
|
|
- <view class="pd-24">
|
|
|
|
|
- <ut-steps-title :stepsObject="stepsObject"></ut-steps-title>
|
|
|
|
|
- </view>
|
|
|
|
|
- <view class="pd-5 bg-#f7f7f7"></view>
|
|
|
|
|
|
|
+ <view class="pd-5"></view>
|
|
|
</template>
|
|
</template>
|
|
|
<view>
|
|
<view>
|
|
|
- <view v-show="currentStep === 'connect'">
|
|
|
|
|
|
|
+
|
|
|
|
|
+ <view v-show="currentStep === 'connect'" class="bg-fff">
|
|
|
<!-- 业务组件链接打印机 -->
|
|
<!-- 业务组件链接打印机 -->
|
|
|
- <connect-printer :info="stepsObject[currentStep]" @next="nextSteps" @prev="prevSteps" prevStepValue="confirm" nextStepValue="print"></connect-printer>
|
|
|
|
|
|
|
+ <connect-printer :info="stepsObject[currentStep]" @next="nextSteps" nextStepValue="print"></connect-printer>
|
|
|
</view>
|
|
</view>
|
|
|
- <view v-show="currentStep === 'print'">
|
|
|
|
|
|
|
+ <view v-show="currentStep === 'print'" class="bg-fff">
|
|
|
<!-- 业务组件打印 -->
|
|
<!-- 业务组件打印 -->
|
|
|
<!-- 打印写入打印机 -->
|
|
<!-- 打印写入打印机 -->
|
|
|
- <print-wrapper :info="stepsObject[currentStep]" @test="printTest" @prev="prevSteps" prevStepValue="connect"></print-wrapper>
|
|
|
|
|
|
|
+ <print-wrapper :info="stepsObject[currentStep]" :printCount="form?.printCount" @test="printTest" @prev="prevSteps" @print="printCodes" prevStepValue="connect"></print-wrapper>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
</z-paging>
|
|
</z-paging>
|
|
@@ -27,19 +25,39 @@ import { tem30x30, tem60x40, tem60x60 } from '../models/print-tem';
|
|
|
import PrintWrapper from '../models/print-wrapper.vue';
|
|
import PrintWrapper from '../models/print-wrapper.vue';
|
|
|
import { writeBLECharacteristicSend } from '@/utils/blue-device-services';
|
|
import { writeBLECharacteristicSend } from '@/utils/blue-device-services';
|
|
|
import jpPrinter from '../models/tspl';
|
|
import jpPrinter from '../models/tspl';
|
|
|
|
|
+import { useClientRequest } from '@/utils/request';
|
|
|
|
|
+import RangePrint from '../models/range-print.vue';
|
|
|
|
|
+const printSpec = ref('30x30');
|
|
|
|
|
+const printCodes = async (data: any) => {
|
|
|
|
|
+ printSpec.value = data.printSpec;
|
|
|
|
|
+ // 检查是否正在打印
|
|
|
|
|
+ if (isPrinting.value) {
|
|
|
|
|
+ uni.showToast({ icon: 'none', title: '当前打印任务未完成,请稍后' });
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ isPrinting.value = true;
|
|
|
|
|
+
|
|
|
|
|
+ getPrintCodeList();
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+// 打印列表
|
|
|
|
|
+const getPrintCodeList = async () => {
|
|
|
|
|
+ const res = await useClientRequest
|
|
|
|
|
+ .get(`/plt-api/app/printLog/getPrintCodeList/${opts.value?.id}`, {
|
|
|
|
|
+ start: opts.value?.startSn,
|
|
|
|
|
+ end: opts.value?.endSn,
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch((err) => {
|
|
|
|
|
+ isPrinting.value = false;
|
|
|
|
|
+ });
|
|
|
|
|
+ if (!res || res.code !== 200) {
|
|
|
|
|
+ isPrinting.value = false;
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ prepareSend(res?.data, printSpec.value)
|
|
|
|
|
+};
|
|
|
const stepsObject = reactive<any>({
|
|
const stepsObject = reactive<any>({
|
|
|
- check: {
|
|
|
|
|
- title: '核对信息',
|
|
|
|
|
- value: 'check',
|
|
|
|
|
- status: 'completed', // 为开始、进行中、已完成 三种状态分别值为 'not-started'、'in-progress'、'completed'
|
|
|
|
|
- sort: 0,
|
|
|
|
|
- },
|
|
|
|
|
- confirm: {
|
|
|
|
|
- title: '确认数量',
|
|
|
|
|
- value: 'confirm',
|
|
|
|
|
- status: 'completed', // 为开始、进行中、已完成 三种状态分别值为 'not-started'、'in-progress'、'completed'
|
|
|
|
|
- sort: 1,
|
|
|
|
|
- },
|
|
|
|
|
|
|
+
|
|
|
connect: {
|
|
connect: {
|
|
|
title: '连接打印机',
|
|
title: '连接打印机',
|
|
|
value: 'connect',
|
|
value: 'connect',
|
|
@@ -53,12 +71,14 @@ const stepsObject = reactive<any>({
|
|
|
sort: 3,
|
|
sort: 3,
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|
|
|
-// 打印模式
|
|
|
|
|
-const mode = ref('self'); // 自行打印, 区间打印 值分别为 self, range
|
|
|
|
|
const currentStep = ref('connect');
|
|
const currentStep = ref('connect');
|
|
|
-const paging = ref(null);
|
|
|
|
|
const isPrinting = ref(false);
|
|
const isPrinting = ref(false);
|
|
|
-onLoad((options: any) => {});
|
|
|
|
|
|
|
+const opts = ref<any>(null);
|
|
|
|
|
+onLoad((options: any) => {
|
|
|
|
|
+ console.log(options);
|
|
|
|
|
+ opts.value = options;
|
|
|
|
|
+ getBatchInfo()
|
|
|
|
|
+});
|
|
|
const nextSteps = (data: any) => {
|
|
const nextSteps = (data: any) => {
|
|
|
if (!data.info || !data?.info?.value) return;
|
|
if (!data.info || !data?.info?.value) return;
|
|
|
stepsObject[data?.info?.value] = {
|
|
stepsObject[data?.info?.value] = {
|
|
@@ -67,42 +87,52 @@ const nextSteps = (data: any) => {
|
|
|
stepsObject[data?.nextStepValue].status = 'in-progress';
|
|
stepsObject[data?.nextStepValue].status = 'in-progress';
|
|
|
currentStep.value = data?.nextStepValue;
|
|
currentStep.value = data?.nextStepValue;
|
|
|
};
|
|
};
|
|
|
|
|
+const info = ref<any>(null);
|
|
|
|
|
+const form = ref<any>(null);
|
|
|
|
|
+const getFormData = (data: any) => {
|
|
|
|
|
+ console.log(data);
|
|
|
|
|
+
|
|
|
|
|
+ form.value = data;
|
|
|
|
|
+};
|
|
|
const prevSteps = (data: any) => {
|
|
const prevSteps = (data: any) => {
|
|
|
currentStep.value = data?.prevStepValue;
|
|
currentStep.value = data?.prevStepValue;
|
|
|
};
|
|
};
|
|
|
const testList = reactive([
|
|
const testList = reactive([
|
|
|
{
|
|
{
|
|
|
- pm: '三七',
|
|
|
|
|
- zl: '20g',
|
|
|
|
|
- scrq: '2012.09.18',
|
|
|
|
|
- zzph: 87391273912,
|
|
|
|
|
- cj: '云南省文山市县中药材有限公司',
|
|
|
|
|
- zsm: 'QX0000005600000318',
|
|
|
|
|
- qr: 'https://t.zycpzs.cn/?c=QCCS412507030000101ND'
|
|
|
|
|
|
|
+ padSn: '0000002',
|
|
|
|
|
+ prefix: 'PCC1W1260311',
|
|
|
|
|
+ sn: 2,
|
|
|
|
|
+ traceCode: 'PCC1W12603110000002AV',
|
|
|
|
|
+ url: 'https://t.yujin.shuziyunyao.com/pt?c=PCC1W12603110000002AV',
|
|
|
},
|
|
},
|
|
|
]);
|
|
]);
|
|
|
const printTest = (data: any) => {
|
|
const printTest = (data: any) => {
|
|
|
|
|
+ const device = stepsObject['connect']?.device;
|
|
|
|
|
+ if (!device) {
|
|
|
|
|
+ uni.showToast({ icon: 'none', title: '未连接设备' });
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
// 检查是否正在打印
|
|
// 检查是否正在打印
|
|
|
if (isPrinting.value) {
|
|
if (isPrinting.value) {
|
|
|
uni.showToast({ icon: 'none', title: '当前打印任务未完成,请稍后' });
|
|
uni.showToast({ icon: 'none', title: '当前打印任务未完成,请稍后' });
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+ isPrinting.value = true;
|
|
|
// 测试数据
|
|
// 测试数据
|
|
|
prepareSend(testList, data.printSpec);
|
|
prepareSend(testList, data.printSpec);
|
|
|
};
|
|
};
|
|
|
// 打印写入
|
|
// 打印写入
|
|
|
const prepareSend = (list: any[], spec: string = '30x30') => {
|
|
const prepareSend = (list: any[], spec: string = '30x30') => {
|
|
|
if (spec == '30x30') {
|
|
if (spec == '30x30') {
|
|
|
- // 判断idx是否是奇数
|
|
|
|
|
writeSend30x30(list);
|
|
writeSend30x30(list);
|
|
|
}
|
|
}
|
|
|
if (spec == '60x40') {
|
|
if (spec == '60x40') {
|
|
|
// 40x40
|
|
// 40x40
|
|
|
- writeSendCommand(list, '60x40', 0)
|
|
|
|
|
|
|
+ writeSendCommand(list, '60x40', 0);
|
|
|
}
|
|
}
|
|
|
if (spec == '60x60') {
|
|
if (spec == '60x60') {
|
|
|
// 30x30
|
|
// 30x30
|
|
|
- writeSendCommand(list, '60x60', 0)
|
|
|
|
|
|
|
+ writeSendCommand(list, '60x60', 0);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
const writeSend30x30 = (list: any[]) => {
|
|
const writeSend30x30 = (list: any[]) => {
|
|
@@ -115,14 +145,11 @@ const writeSend30x30 = (list: any[]) => {
|
|
|
}
|
|
}
|
|
|
return acc;
|
|
return acc;
|
|
|
}, []);
|
|
}, []);
|
|
|
- writeSendCommand(arr, '30x30', 0)
|
|
|
|
|
|
|
+ writeSendCommand(arr, '30x30', 0);
|
|
|
};
|
|
};
|
|
|
// writeSend
|
|
// writeSend
|
|
|
const writeSendCommand = async (list: any[], spec: string = '30x30', idx = 0) => {
|
|
const writeSendCommand = async (list: any[], spec: string = '30x30', idx = 0) => {
|
|
|
// 首次调用时设置打印状态为进行中
|
|
// 首次调用时设置打印状态为进行中
|
|
|
- if (idx === 0) {
|
|
|
|
|
- isPrinting.value = true;
|
|
|
|
|
- }
|
|
|
|
|
let command = new jpPrinter();
|
|
let command = new jpPrinter();
|
|
|
if (spec == '30x30') {
|
|
if (spec == '30x30') {
|
|
|
// 判断idx是否是奇数
|
|
// 判断idx是否是奇数
|
|
@@ -130,7 +157,7 @@ const writeSendCommand = async (list: any[], spec: string = '30x30', idx = 0) =>
|
|
|
command.setGap(10);
|
|
command.setGap(10);
|
|
|
command.setCls();
|
|
command.setCls();
|
|
|
command.setDirection(1);
|
|
command.setDirection(1);
|
|
|
- command = tem30x30(command, list[idx]);
|
|
|
|
|
|
|
+ command = tem30x30(command, list[idx], info.value);
|
|
|
}
|
|
}
|
|
|
if (spec == '60x40') {
|
|
if (spec == '60x40') {
|
|
|
// 判断idx是否是奇数
|
|
// 判断idx是否是奇数
|
|
@@ -138,7 +165,7 @@ const writeSendCommand = async (list: any[], spec: string = '30x30', idx = 0) =>
|
|
|
command.setGap(10);
|
|
command.setGap(10);
|
|
|
command.setCls();
|
|
command.setCls();
|
|
|
command.setDirection(1);
|
|
command.setDirection(1);
|
|
|
- command = tem60x40(command, list[idx]);
|
|
|
|
|
|
|
+ command = tem60x40(command, list[idx], info.value);
|
|
|
}
|
|
}
|
|
|
if (spec == '60x60') {
|
|
if (spec == '60x60') {
|
|
|
// 判断idx是否是奇数
|
|
// 判断idx是否是奇数
|
|
@@ -146,16 +173,16 @@ const writeSendCommand = async (list: any[], spec: string = '30x30', idx = 0) =>
|
|
|
command.setGap(10);
|
|
command.setGap(10);
|
|
|
command.setCls();
|
|
command.setCls();
|
|
|
command.setDirection(1);
|
|
command.setDirection(1);
|
|
|
- command = tem60x60(command, list[idx]);
|
|
|
|
|
|
|
+ command = tem60x60(command, list[idx], info.value);
|
|
|
}
|
|
}
|
|
|
- command.setPagePrint()
|
|
|
|
|
|
|
+ command.setPagePrint();
|
|
|
const device = stepsObject['connect']?.device;
|
|
const device = stepsObject['connect']?.device;
|
|
|
if (!device) {
|
|
if (!device) {
|
|
|
uni.showToast({ icon: 'none', title: '未连接设备' });
|
|
uni.showToast({ icon: 'none', title: '未连接设备' });
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
console.log(command.getData());
|
|
console.log(command.getData());
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
await writeBLECharacteristicSend({
|
|
await writeBLECharacteristicSend({
|
|
|
deviceId: device.deviceId,
|
|
deviceId: device.deviceId,
|
|
|
serviceId: device.serviceId,
|
|
serviceId: device.serviceId,
|
|
@@ -163,16 +190,22 @@ const writeSendCommand = async (list: any[], spec: string = '30x30', idx = 0) =>
|
|
|
uint8Array: command.getData(),
|
|
uint8Array: command.getData(),
|
|
|
});
|
|
});
|
|
|
if (list.length - 1 > idx) {
|
|
if (list.length - 1 > idx) {
|
|
|
- writeSendCommand(list, spec, idx + 1)
|
|
|
|
|
|
|
+ writeSendCommand(list, spec, idx + 1);
|
|
|
} else {
|
|
} else {
|
|
|
// 打印完成,重置状态
|
|
// 打印完成,重置状态
|
|
|
isPrinting.value = false;
|
|
isPrinting.value = false;
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
icon: 'none',
|
|
icon: 'none',
|
|
|
- title: '打印完成'
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ title: '打印完成',
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
+// 获取批次信息接口
|
|
|
|
|
+const getBatchInfo = async () => {
|
|
|
|
|
+ const res = await useClientRequest.get(`/plt-api/app/packTask/getPackTraceSimpleInfo/${opts.value?.packId}`);
|
|
|
|
|
+ if (!res?.data) return
|
|
|
|
|
+ info.value = res?.data;
|
|
|
|
|
+}
|
|
|
// 如果是 30x30
|
|
// 如果是 30x30
|
|
|
</script>
|
|
</script>
|
|
|
<style lang="scss" scoped></style>
|
|
<style lang="scss" scoped></style>
|