shish 4 лет назад
Родитель
Сommit
9c1c5a8a09

+ 2 - 0
ghsApp/src/admin/item/list.vue

@@ -139,6 +139,7 @@ export default {
 				}
 			})
 		},
+		//大标签
 		createLable(itemName,itemId,num){
 			//制作标签格式,
 			var data=[];  //定义一个数组
@@ -176,6 +177,7 @@ export default {
 
 			return data;
 		},
+		//小标签
 		createLable2(itemName,itemId){
 
 			//制作标签格式,

+ 14 - 0
hdPad/src/manifest.json

@@ -142,6 +142,20 @@
                     "pid" : "3514",
                     "parameters" : {}
                 }
+            },
+            "Html5app-Gprinter" : {
+                "__plugin_info__" : {
+                    "name" : "Android 和 IOS 佳博 蓝牙小票 标签 打印插件",
+                    "description" : "Android / IOS 佳博小票 、标签 打印机插件,QQ交流群:891416757",
+                    "platforms" : "Android,iOS",
+                    "url" : "https://ext.dcloud.net.cn/plugin?id=462",
+                    "android_package_name" : "zhh.huahuibao.hhb.app",
+                    "ios_bundle_id" : "",
+                    "isCloud" : true,
+                    "bought" : 1,
+                    "pid" : "462",
+                    "parameters" : {}
+                }
             }
         }
     },

+ 405 - 0
hdPad/src/pages/home/blue.vue

@@ -0,0 +1,405 @@
+<template>
+<view class="app-content">
+	<view class="content">
+		<view>
+			<button @click="openDefault" >连接</button>
+			<!-- <button @click="open" >打开自定义蓝牙搜索页面</button>
+			<button @click="connectIP" >端口ip连接标签机</button>
+			<button @click="connectUSB" >USB 连接标签机</button> -->
+			<!-- <button @click="printer" >打印小票</button> -->
+			<!-- <button @click="printerLable" >打印样签</button>	 -->
+			<!-- <button @click="writePDFToTsc" >标签打印PDF</button>
+			<button @click="writePDFToEsc" >小票打印PDF</button>
+			<button @click="writeTSC" >tsc指令打印</button> -->
+			<!-- <button @click="state" >标签机状态</button> -->
+			<button @click="dis" >断开</button>
+			<text>{{tip}}</text>
+		</view>
+	</view>
+</view>
+</template>
+<script>
+const plug= uni.requireNativePlugin('Html5app-Gprinter');
+export default {
+	data() {
+		return {
+			tip: ''
+		}
+	},
+	methods: {
+		openDefault()
+		{
+			//蓝牙连接标签机
+			const that=this;
+			plug.BluetoothPort({setBackgroundColor:"#2088d2"},result=>{
+				if(result.code == 3){
+					that.$msg('连接成功')
+					setTimeout(function(){
+						uni.navigateBack()
+					},2000)
+					that.tip=''
+				}else{
+					that.tip=JSON.stringify(result)
+				}
+			})
+		},
+		open(){
+			uni.navigateTo({ "url":"./Bluetooth" })
+		},
+		connectIP()
+		{
+			//端口网络连接
+			let that=this;
+			plug.connectIP({},ret=>{	
+				that.tip=JSON.stringify(ret)
+			})
+		},
+		connectUSB()
+		{
+			//USB网络连接
+			let that=this;
+			plug.connectUSB({setBackgroundColor:"#2088d2"},ret=>{	
+				that.tip=JSON.stringify(ret)
+			});
+		},
+		state(){
+			//查询标签机状态
+			let that=this;
+			plug.state({},ret=>{
+				that.tip=JSON.stringify(ret.msg)
+			});
+		},
+		dis()
+		{
+			//断开标签机
+			let that=this;
+			plug.disconnect({},ret=>{	
+				that.tip=JSON.stringify(ret.msg)
+			});
+		},
+		printer(){
+			//标签机小票
+			const that=this;
+			plug.printer({"ESC":that.setDate()},ret=>{
+				that.tip=JSON.stringify(ret)
+			})
+		},
+		printerLable(){
+			//打印标签
+			const that=this;
+			plug.printer({"TSC":that.OrderLable('粉红雪山','11054')},ret=>{
+				that.tip=JSON.stringify(ret);
+			})
+		},
+		writePDFToTsc()
+		{
+			//打印pdf 档标签文件
+			let filePath=plus.io.convertLocalFileSystemURL("static/pdfFile.pdf");
+			plug.writePDFToTsc({filePath:filePath,width:400},ret=>{
+			
+			});
+		},
+		writePDFToEsc()
+		{
+			//打印pdf 档小票文件
+			let filePath=plus.io.convertLocalFileSystemURL("static/pdfFile.pdf");
+			plug.writePDFToEsc({filePath:filePath,width:400},ret=>{
+			
+			});
+		},
+		writeTSC()
+		{
+			//打印图片和文字
+			let image=plus.io.convertLocalFileSystemURL("static/gprinter.png");
+			
+			//图片指令,BITMAP x,y,宽度,图片路径 ,四个参数组成
+			
+			const that=this;
+			let str="SIZE 40 mm,15 mm \n";
+				str+="GAP 2 mm,0 mm \n";
+				str+"SET RESPONSE NO \n";
+				str+="CLS \n";
+				str+="TEXT 50,50,\"3\",0,1,1,\"DEMO FOR TEXT\" \n";
+				str+="BITMAP 20,20,100,"+image+" \n";
+				str+=" PRINT 1 \n";
+
+			plug.writeTSC({"tsc":str},function(e){
+					that.tip=JSON.stringify(e);
+			});
+			
+		},
+		setDate()
+		{
+			//打印小票
+			const that=this;
+			
+			//制作小票格式, 
+			var data=[];  //定义一个数组
+			var line={};  //每添加一个,代表一行字
+			
+			var filePath=plus.io.convertLocalFileSystemURL("static/gprinter.png");
+			//加入logo图片
+			var Path=filePath; 
+			line.image=Path;
+			line.width="350";
+			line.center="center";
+			line.bottom="1";
+			data.push(line);
+			
+			line={};
+			line.text="万达广场欢迎您";
+			line.center="center";
+			line.font="max";
+			line.bottom="3";
+			data.push(line); //每添加一个,代表一行字
+
+			line={};
+			line.text="收银员:00056";
+			line.center="left";
+			line.font="bold";
+			line.bottom="2";
+			data.push(line);
+			
+			line={};  
+			line.text="单号:00256933";
+			line.center="left";
+			line.font="normal";
+			line.bottom="2";
+			data.push(line);
+			
+			line={};  
+			line.text="业务日期:2019-05-30 18:15:25";
+			line.center="left";
+			line.font="normal";
+			line.bottom="1";
+			data.push(line);
+			
+			line={};
+			line.text="------------------------------";
+			line.center="left";
+			line.font="normal";
+			line.bottom="1";
+			data.push(line);
+			
+			//商品列表,示例
+			for(let i=0;i<4;i++)
+			{
+							
+			line={};
+			line.text="商品名称:小黑瓶眼霜";
+			line.center="left";
+			line.font="normal";
+			line.bottom="1";
+			data.push(line);
+			
+			line={};
+			line.title=["数量:1","单价:305","金额:305"];
+			line.left=[0,30,60];
+			line.center="left";
+			line.font="normal";
+			line.bottom="2";
+			data.push(line);
+								
+			}
+			
+			line={}; //清空一下
+			
+			line.text="------------------------------";
+			line.center="left";
+			line.font="normal";
+			line.bottom="2";
+			data.push(line);
+			
+			line={};
+			line.text="数量:4 ,金额:¥1220.00";
+			line.center="left";
+			line.font="bold";
+			line.bottom="1";
+			data.push(line);
+			
+			line={};
+			line.text="实收金额:¥1220.00";
+			line.center="left";
+			line.font="bold";
+			line.bottom="2";
+			data.push(line);
+			
+			line={};
+			line.text="活动期间满500送100";
+			line.center="left";
+			line.font="normal";
+			line.bottom="1";
+			data.push(line);
+			line={};
+			line.text="折让金额500";
+			line.center="left";
+			line.font="normal";
+			line.bottom="1";
+			data.push(line);
+			line={};
+			line.text="折后金额2029";
+			line.center="left";
+			line.font="normal";
+			line.bottom="3";
+			data.push(line);
+			
+			line={};
+			line.text="30天内可凭小票换开发票";
+			line.center="left";
+			line.font="normal";
+			line.bottom="2";
+			data.push(line);
+			line={};
+			line.text="活动商品,不退不换";
+			line.center="left";
+			line.font="normal";
+			line.bottom="2";
+			data.push(line);
+			
+			//加入条型码
+			line={};
+			line.barcode="2019563352660";
+			line.type="CODE128";
+			line.height="100";
+			line.position="BELOW";
+			line.width="2";
+			line.center="center";
+			line.bottom="2";
+			data.push(line);
+			
+			
+				//加入二维码
+			line={};
+			line.qrcode="d68242b5e540aa7f21173c2d65b2c5ad";
+			line.size="10";
+			line.center="center";
+			line.bottom="0";
+			line.errorlevel="L";
+			
+			
+			data.push(line);
+			
+			// line={};
+			// //加入图片
+			// line.image="http://www.html5-app.com/uploads/file/20190307/20190307172436572807.png";
+			// line.width="150";
+			// line.center="center";
+			// line.bottom="3";
+			// data.push(line);
+				
+			return data;
+			
+		},
+		OrderLable(itemName,itemId){
+			
+			//制作标签格式, 
+			var data=[];  //定义一个数组
+			var line={};  //每添加一个,代表一行字
+			
+			//设置标签纸大小
+			line={};
+			line.width=30; //mm
+			line.height=20; //mm
+			line.gap=2; //标签纸之间,间隙长度 mm
+			line.page=1; //打印几份
+			data.push(line); //每添加一个,代表一行字
+
+				//添加文字
+			line={};
+			line.text= itemName;
+			line.rotation=0;
+			line.x=35;
+			line.y=20;
+			line.xscal=1;
+			line.yscal=1;
+			data.push(line); //每添加一个,代表一行字
+
+			//添加条型码
+			line={};
+			line.barcode=itemId;
+			line.x=35;
+			line.y=55;
+			line.type="CODE128";
+			line.height=50;
+			line.readable=true;
+			line.rotation=0;
+			data.push(line);
+
+			return data;
+		},
+		Lable(){
+			
+			//制作标签格式, 
+			var data=[];  //定义一个数组
+			var line={};  //每添加一个,代表一行字
+			
+			//设置标签纸大小
+			line={};
+			line.width=40; //mm
+			line.height=30; //mm
+			line.gap=3; //标签纸之间,间隙长度 mm
+			line.page=1; //打印几份
+			data.push(line); //每添加一个,代表一行字
+
+			//添加图片
+			line={};
+			line.image="http://www.html5-app.com/gprinter.png";
+			line.x=30;
+			line.y=20;
+			line.width=70;
+			data.push(line);
+			
+			
+				//添加文字
+			line={};
+			line.text="HTML5+混合APP开发社区";
+			line.rotation=0;
+			line.x=30;
+			line.y=90;
+			line.xscal=1;
+			line.yscal=1;
+			data.push(line); //每添加一个,代表一行字
+			
+			//添加条型码
+			line={};
+			line.barcode="2019563352660";
+			line.x=30;
+			line.y=130;
+			line.type="CODE128";
+			line.height=50;
+			line.readable=true;
+			line.rotation=0;
+			data.push(line);
+			
+				//加入二维码
+			line={};
+			line.qrcode="1234566";	
+			line.x=190;
+			line.y=20;
+			line.width=3
+			line.rotation=0;
+			data.push(line);
+			
+			//添加黑块
+			line={};
+			line.addBar={x:25,y:2,width:300,height:3};
+			data.push(line);
+			
+			//添加方框
+			line={};
+			line.addBox={x:25,y:15,xend:300,yend:120,thickness:2};
+			data.push(line);
+			
+			return data;
+		}
+
+	}
+}
+</script>
+<style>
+	.content {
+		margin: 10px;
+		margin-top:30px;
+	}
+	button{ margin-bottom: 25px;}
+</style>

+ 68 - 3
hdPad/src/pages/home/components/workInfo.vue

@@ -88,7 +88,7 @@
       <view :class="[orderInfo.status==0 ? 'active' : '']" @tap="finishFn()">完成</view>
       <view :class="[orderInfo.status != 2 && orderInfo.stockLock==0 ? 'active' : '']" @click="modifyItem(orderInfo)">修改</view>
       <view :class="[orderInfo.status != 2 && orderInfo.stockLock==0 ? 'active' : '']" @click="lockFn()">锁定</view>
-      <view :class="[orderInfo.status==1 ? 'active' : '']" @click="printFn()">打印</view>
+      <view :class="[orderInfo.status==1 ? 'active' : '']" @click="printFn(orderInfo)">打印</view>
       <view :class="[orderInfo.status==0 ? 'active' : '']" @click="cancelFn()">取消</view>
     </view>
 
@@ -117,6 +117,9 @@
 import { getFullInfo,finish,lockWork,cancelWork } from '@/api/work'
 import {modifyWastage} from '@/api/work-item'
 import wastageSelectNum from './wastageSelectNum.vue'
+// #ifdef APP-PLUS
+const plug = uni.requireNativePlugin('Html5app-Gprinter')
+// #endif
 export default {
 	name: "orderInfo",
 	components: {wastageSelectNum},
@@ -149,9 +152,71 @@ export default {
       }
   },
   methods:{
-    printFn(){
-      this.$msg('开发中')
+    printFn(info){
+      // #ifdef APP-PLUS
+      plug.state({},ret=>{
+        if(ret.code == 1){
+          that.$util.confirmModal({content:'您还没有连接蓝牙,请先链接'},() => {
+            that.pageTo({url:'/pages/home/blue'})
+          })
+        }else{
+          let currentNum = parseFloat(Number(info.num))
+          if(Number(currentNum)<0){
+            this.$msg('工单数量错误')
+            return false
+          }
+          let data = []
+          let label = that.createLable(info.name,info.goodsId,currentNum)
+          data.push(label)
+          //说明地址 https://ext.dcloud.net.cn/plugin?id=462
+          plug.printer({"TSC":data,isArray:true},result=>{
+            //console.log(result)
+          })
+        }
+      })
+      // #endif
+      // #ifdef MP-WEIXIN
+      that.$msg('请在App上打印')
+      // #endif
     },
+		//大标签
+		createLable(itemName,itemId,num){
+			//制作标签格式,
+			var data=[];  //定义一个数组
+			var line={};  //每添加一个,代表一行字
+
+			//设置标签纸大小
+			line={};
+			line.width=40; //mm
+			line.height=50; //mm
+			line.gap=2; //标签纸之间,间隙长度 mm
+			line.page=num; //打印几份
+			data.push(line); //每添加一个,代表一行字
+
+			//添加文字
+			line={};
+			line.text= itemName;
+			line.rotation=0;
+			line.x=30;
+			line.y=15;
+			line.xscal=2;
+			line.yscal=2;
+			data.push(line); //每添加一个,代表一行字
+
+			//添加条型码
+			line={};
+			line.barcode=itemId;
+			line.x=30;
+			line.y=80;
+			line.type="CODE128";
+			line.width=2;//条型宽度,这里的宽指的是 条型码 竖条的宽度,不是整个条型码的宽度
+			line.height=90;
+			line.readable=true;
+			line.rotation=0;
+			data.push(line);
+
+			return data;
+		},
     lockFn(){
       this.$refs.lockWorkRef.open('center')
     },

+ 28 - 0
开发/hdPad/src/manifest.json

@@ -129,6 +129,34 @@
             }
         },
         "nativePlugins" : {
+            "G5KJ-ShangMiPrint" : {
+                "__plugin_info__" : {
+                    "name" : "商米内置打印机与扫码",
+                    "description" : "实现商米内置打印机与外接usb扫码枪识别",
+                    "platforms" : "Android",
+                    "url" : "https://ext.dcloud.net.cn/plugin?id=3514",
+                    "android_package_name" : "zhh.huahuibao.hhb.app",
+                    "ios_bundle_id" : "com.zhh.hhb",
+                    "isCloud" : true,
+                    "bought" : 1,
+                    "pid" : "3514",
+                    "parameters" : {}
+                }
+            },
+            "Html5app-Gprinter" : {
+                "__plugin_info__" : {
+                    "name" : "Android 和 IOS 佳博 蓝牙小票 标签 打印插件",
+                    "description" : "Android / IOS 佳博小票 、标签 打印机插件,QQ交流群:891416757",
+                    "platforms" : "Android,iOS",
+                    "url" : "https://ext.dcloud.net.cn/plugin?id=462",
+                    "android_package_name" : "zhh.huahuibao.hhb.app",
+                    "ios_bundle_id" : "",
+                    "isCloud" : true,
+                    "bought" : 1,
+                    "pid" : "462",
+                    "parameters" : {}
+                }
+            }
         }
     },
     /* 快应用特有相关 */

+ 28 - 0
线上/hdPad/src/manifest.json

@@ -129,6 +129,34 @@
             }
         },
         "nativePlugins" : {
+            "G5KJ-ShangMiPrint" : {
+                "__plugin_info__" : {
+                    "name" : "商米内置打印机与扫码",
+                    "description" : "实现商米内置打印机与外接usb扫码枪识别",
+                    "platforms" : "Android",
+                    "url" : "https://ext.dcloud.net.cn/plugin?id=3514",
+                    "android_package_name" : "zhh.huahuibao.hhb.app",
+                    "ios_bundle_id" : "com.zhh.hhb",
+                    "isCloud" : true,
+                    "bought" : 1,
+                    "pid" : "3514",
+                    "parameters" : {}
+                }
+            },
+            "Html5app-Gprinter" : {
+                "__plugin_info__" : {
+                    "name" : "Android 和 IOS 佳博 蓝牙小票 标签 打印插件",
+                    "description" : "Android / IOS 佳博小票 、标签 打印机插件,QQ交流群:891416757",
+                    "platforms" : "Android,iOS",
+                    "url" : "https://ext.dcloud.net.cn/plugin?id=462",
+                    "android_package_name" : "zhh.huahuibao.hhb.app",
+                    "ios_bundle_id" : "",
+                    "isCloud" : true,
+                    "bought" : 1,
+                    "pid" : "462",
+                    "parameters" : {}
+                }
+            }
         }
     },
     /* 快应用特有相关 */