diff --git a/src/api/cashierclass.ts b/src/api/cashierclass.ts index fa8e338..29d3110 100644 --- a/src/api/cashierclass.ts +++ b/src/api/cashierclass.ts @@ -28,4 +28,9 @@ export function apiCashierclassDetail(params: any) { // 零售单详情 export function apiCashierclassAuditing(params: any) { return request.post({ url: '/retail/cashierclass/auditing', params }) +} + +// 手动打印小票 +export function apiCashierclassprints(params: any) { + return request.get({ url: '/retail/Cashierclass/prints', params }) } \ No newline at end of file diff --git a/src/api/opurchaseclass.ts b/src/api/opurchaseclass.ts index 91362a4..e5886a0 100644 --- a/src/api/opurchaseclass.ts +++ b/src/api/opurchaseclass.ts @@ -55,3 +55,24 @@ export function apioperationOpurchaseclassAdd() { return request.post({ url: '/operation/opurchaseclass/add' }) } +// 回调打印成功设置 +export function cashierclassSetPrintAdd(params: any) { + return request.get({ url: '/retail/cashierclass/set_print', params }) +} + +// 入库列表 +export function opurchaseclassStorageListApi(params: any) { + return request.get({ url: '/operation/opurchaseclass/storage_list', params }) +} + +// 出库列表 +export function opurchaseclassStreamListApi(params: any) { + return request.get({ url: '/operation/opurchaseclass/stream_list', params }) +} + +// 出库 +export function opurchaseclassStreamUpdateApi(params: any) { + return request.post({ url: '/operation/opurchaseclass/stream_update', params }) +} + + diff --git a/src/components/subOrderDetail/index.vue b/src/components/subOrderDetail/index.vue new file mode 100644 index 0000000..de7dab6 --- /dev/null +++ b/src/components/subOrderDetail/index.vue @@ -0,0 +1,144 @@ + + + diff --git a/src/layout/default/index.vue b/src/layout/default/index.vue index 436e187..3319bf9 100644 --- a/src/layout/default/index.vue +++ b/src/layout/default/index.vue @@ -1,97 +1,96 @@ diff --git a/src/utils/print.ts b/src/utils/print.ts index 18eed04..5d61d20 100644 --- a/src/utils/print.ts +++ b/src/utils/print.ts @@ -1,4 +1,5 @@ import { hiprint, defaultElementTypeProvider } from "vue-plugin-hiprint"; +import { cashierclassSetPrintAdd } from "@/api/opurchaseclass"; // 引入后使用示例 hiprint.init(); @@ -8,8 +9,10 @@ hiprint.hiwebSocket.setHost("http://localhost:17521"); // 配置 const WIDTH = 58; //纸张宽度 mm +const HEIGHT = 155; //纸张高度 mm 使用时需另外计算商品高度 const T_WIDTH = 150; //文本宽度 pt const T_LEFT = 4; //文本左边距 pt +const textHeight = 10; //文本高度 export const print = (data: any) => { // hiprint对象获取 @@ -17,18 +20,17 @@ export const print = (data: any) => { console.log(list); let nowHeight = 0; - let textHeight = 10; // 下列方法都是没有拖拽设计页面的, 相当于代码模式, 使用代码设计页面 // 想要实现拖拽设计页面,请往下看 '自定义设计' var hiprintTemplate = new hiprint.PrintTemplate(); // 纸张高度 固定为 130 pt + 商品数量高度 - let oneHeight = 120 + Math.ceil((data.info.length * 2 * 10) / 2.84); + let oneHeight = HEIGHT + Math.ceil((data.info.length * 2 * 10) / 2.84); // 模板宽度单位是mm ( 1mm ~= 2.84pt ) 其他的宽高单位是pt var panel = hiprintTemplate.addPrintPanel({ - width: 58, // 58mm = 164pt + width: WIDTH, // 58mm = 164pt height: oneHeight, paperNumberDisabled: true, }); @@ -119,7 +121,9 @@ export const print = (data: any) => { }); }; - //文本 *1 + //文本 *3 + panel.addPrintText(options("======================")); + panel.addPrintText(options("")); panel.addPrintText( options({ title: "泸优采-采购单", @@ -139,7 +143,8 @@ export const print = (data: any) => { lineTitle(); data.info.forEach((item: any) => { panel.addPrintText(options(item.goods_name)); - if(item.nums==Math.floor(+item.nums)) item.nums = Number(item.nums).toFixed(0); + if (item.nums == Math.floor(+item.nums)) + item.nums = Number(item.nums).toFixed(0); lineOptions( `${item.price}元`, `${item.nums}${item.unit_name}`, @@ -170,6 +175,7 @@ export const print = (data: any) => { }, }); nowHeight += 60; + // 文本 *4 panel.addPrintText(options("收货人: " + data.real_name)); panel.addPrintText(options("收货地址: " + data.user_address)); @@ -190,6 +196,15 @@ export const print = (data: any) => { }); nowHeight += 60; + // 文本 *3 + panel.addPrintText(options("出库码: ")); + panel.addPrintText(options("")); + panel.addPrintText(options("")); + + // 文本 *4 + panel.addPrintText({ options: { width: T_WIDTH, height: 35, top: nowHeight, left: T_LEFT, title: data.number, textType: 'barcode',textAlign: "center" } }); + nowHeight += 40 + // 文本 *4 panel.addPrintText(options("")); panel.addPrintText(options("")); @@ -199,19 +214,22 @@ export const print = (data: any) => { // 合计高度 23 + length * 2 //打印 - // hiprintTemplate.print({}); + hiprintTemplate.print({}); //直接打印,需要安装客户端 - hiprintTemplate.print2({}); + // hiprintTemplate.print2({}); // 直接打印回调 // 发送任务到打印机成功 hiprintTemplate.on("printSuccess", (e: any) => { console.log("printSuccess", e); - ElMessage.success('订单已加入打印队列'); + ElMessage.success("订单已加入打印队列"); + cashierclassSetPrintAdd({ + id: data.id, + }); }); // 发送任务到打印机失败 hiprintTemplate.on("printError", (e: any) => { console.log("printError", e); - ElMessage.error('打印失败,请检查是否正确连接打印机!'); + ElMessage.error("打印失败,请检查是否正确连接打印机!"); }); }; @@ -221,16 +239,18 @@ export const testPrint = () => { console.log(list); let nowHeight = 0; - let textHeight = 10; // 下列方法都是没有拖拽设计页面的, 相当于代码模式, 使用代码设计页面 // 想要实现拖拽设计页面,请往下看 '自定义设计' var hiprintTemplate = new hiprint.PrintTemplate(); + // 纸张高度 固定为 130 pt + 商品数量高度 + let oneHeight = HEIGHT + Math.ceil((9 * 2 * 10) / 2.84); + // 模板宽度单位是mm ( 1mm ~= 2.84pt ) 其他的宽高单位是pt var panel = hiprintTemplate.addPrintPanel({ - width: 58, // 58mm = 164pt - height: 145, + width: WIDTH, // 58mm = 164pt + height: oneHeight, paperNumberDisabled: true, }); @@ -320,14 +340,19 @@ export const testPrint = () => { }); }; - //文本 *1 + + //文本 *3 + panel.addPrintText(options("======================")); + panel.addPrintText(options("")); panel.addPrintText( options({ - title: "泸优采-小票0", + title: "泸优采-小票测试", textAlign: "center", }) ); + + //文本 *6 panel.addPrintText(options("单号: PF171617436315965155")); panel.addPrintText(options("配送时间: 2024-05-20 11:06:03")); @@ -344,8 +369,20 @@ export const testPrint = () => { lineOptions("0.01元", "25个", "0.25元"); panel.addPrintText(options("朝天椒, 辣椒")); lineOptions("0.01元", "25个", "0.25元"); + panel.addPrintText(options("朝天椒, 辣椒")); + lineOptions("0.01元", "25个", "0.25元"); + panel.addPrintText(options("朝天椒, 辣椒")); + lineOptions("0.01元", "25个", "0.25元"); + panel.addPrintText(options("朝天椒, 辣椒")); + lineOptions("0.01元", "25个", "0.25元"); + panel.addPrintText(options("朝天椒, 辣椒")); + lineOptions("0.01元", "25个", "0.25元"); + panel.addPrintText(options("朝天椒, 辣椒")); + lineOptions("0.01元", "25个", "0.25元"); + panel.addPrintText(options("朝天椒, 辣椒")); + lineOptions("0.01元", "25个", "0.25元"); - //文本 *13 + //文本 *5 panel.addPrintText(options("======================")); panel.addPrintText(options("合计: 0.75元")); @@ -356,22 +393,8 @@ export const testPrint = () => { // https://lihai001.oss-cn-chengdu.aliyuncs.com/def/54705202405221504133485.png //有字 // panel.addPrintRect({ options: { width: T_WIDTH, height:30,top: nowHeight + 15, left: T_LEFT,borderColor:'',borderWidth:0.75 } }); // nowHeight+=40; - panel.addPrintImage({ - options: { - width: T_WIDTH, - height: 50, - top: nowHeight + 15, - left: T_LEFT, - title: "", - src: "https://lihai001.oss-cn-chengdu.aliyuncs.com/def/db264202405221455038529.png", - }, - }); - nowHeight += 60; - panel.addPrintText(options("收货人: 阿哈")); - panel.addPrintText(options("收货地址: 里海科技")); - panel.addPrintText(options("联系电话: 17685151643")); - panel.addPrintText(options("收货人签字:")); - // panel.addPrintRect({ options: { width: T_WIDTH, height:30,top: nowHeight+15, left: T_LEFT,borderColor:'',borderWidth:0.75 } }); + + // 文本 *6 panel.addPrintImage({ options: { width: T_WIDTH, @@ -384,7 +407,37 @@ export const testPrint = () => { }); nowHeight += 60; + // 文本 *4 + panel.addPrintText(options("收货人: 阿哈")); + panel.addPrintText(options("收货地址: 里海科技")); + panel.addPrintText(options("联系电话: 17685151643")); + panel.addPrintText(options("收货人签字:")); + // panel.addPrintRect({ options: { width: T_WIDTH, height:30,top: nowHeight+15, left: T_LEFT,borderColor:'',borderWidth:0.75 } }); + + // 文本 *6 + panel.addPrintImage({ + options: { + width: T_WIDTH, + height: 50, + top: nowHeight + 15, + left: T_LEFT, + title: "", + src: "https://lihai001.oss-cn-chengdu.aliyuncs.com/def/db264202405221455038529.png", + }, + }); + nowHeight += 60; + + panel.addPrintText(options("出库码: ")); + + // 文本 *4 + panel.addPrintText({ options: { width: T_WIDTH, height: 35, top: nowHeight, left: T_LEFT, title: '65155', textType: 'barcode',textAlign: "center" } }); + nowHeight += 40 + + // 文本 *1 panel.addPrintText(options("")); + + + // 文本 *3 panel.addPrintText(options("")); panel.addPrintText(options("")); panel.addPrintText(options("======================")); @@ -392,19 +445,19 @@ export const testPrint = () => { // 合计高度 23 + length * 2 //打印 - // hiprintTemplate.print({}); + hiprintTemplate.print({}); //直接打印,需要安装客户端 - hiprintTemplate.print2({}); + // hiprintTemplate.print2({}); // 直接打印回调 // 发送任务到打印机成功 hiprintTemplate.on("printSuccess", (e: any) => { console.log("printSuccess", e); - ElMessage.success('订单已加入打印队列'); + ElMessage.success("订单已加入打印队列"); }); // 发送任务到打印机失败 hiprintTemplate.on("printError", (e: any) => { console.log("printError", e); - ElMessage.error('打印失败,请检查是否正确连接打印机!'); + ElMessage.error("打印失败,请检查是否正确连接打印机!"); }); }; diff --git a/src/views/opurchase/opurchaseclass/detail.vue b/src/views/opurchase/opurchaseclass/detail.vue index 1f9bf4e..ad9a309 100644 --- a/src/views/opurchase/opurchaseclass/detail.vue +++ b/src/views/opurchase/opurchaseclass/detail.vue @@ -33,13 +33,13 @@ - + diff --git a/src/views/opurchase/opurchaseclass/index.vue b/src/views/opurchase/opurchaseclass/index.vue index f2f0d3c..e96f8aa 100644 --- a/src/views/opurchase/opurchaseclass/index.vue +++ b/src/views/opurchase/opurchaseclass/index.vue @@ -50,11 +50,12 @@ v-perms="['operation.opurchaseclass/add']" type="success" @click="onPrintOrder()" + v-if="isShowPrint" > - 打印 + 打印测试
@@ -101,7 +102,11 @@ prop="money" show-overflow-tooltip /> - +