Parcourir la source

app 快速打标签方法

shish il y a 4 ans
Parent
commit
190ddab02d
1 fichiers modifiés avec 77 ajouts et 1 suppressions
  1. 77 1
      ghsApp/src/admin/billing/affirm.vue

+ 77 - 1
ghsApp/src/admin/billing/affirm.vue

@@ -8,7 +8,7 @@
           <view class="commodity-view">
             <view class="commodity-list">
               <view class="commodity-item" v-for="(item, index) in selectList" :key="index">
-                <image class="item-icon" :src="item.cover" alt="" />
+                <image class="item-icon" :src="item.cover" alt="" @click.stop="moreToDo(item)" />
                 <view class="item-info" @click="showAddModelFn(item)">
                   <view class="info-line">
                     <text class="item-name">{{ item.itemName }}</text>
@@ -158,6 +158,9 @@ import { createOrder, updateOrder } from "@/api/order/index";
 import { mapActions, mapGetters } from "vuex";
 import { getUserDet} from "@/api/member";
 import ModalModule from "@/components/plugin/modal";
+// #ifdef APP-PLUS
+const plug= uni.requireNativePlugin('Html5app-Gprinter')
+// #endif
 export default {
   name: "BillingAffirm",
   components: {
@@ -254,6 +257,79 @@ export default {
   },
   methods: {
     ...mapActions(["initMerchantInfo"]),
+		// #ifdef APP-PLUS
+		moreToDo(item){
+			//查询是否已经连接蓝牙
+			let _this=this;
+			let doList = ['打印标签', '打印标签2个', '打印标签5个','打印标签10个','打印标签20个']
+			let doNum = [1,2,5,10,20]
+			uni.showActionSheet({
+				itemList: doList,
+				success: function (respond) {
+					let index = respond.tapIndex
+
+					plug.state({},ret=>{
+						if(ret.code == 1){
+							uni.showModal({
+								title: '提示',
+								content: '您还没有连接蓝牙,请先链接',
+								success: function (res) {
+									if (res.confirm) {
+										_this.pageTo({url:'/admin/tools/blue'})
+									}
+								}
+							})
+						}else{
+							let currentNum = Number(doNum[index])
+							console.log(currentNum)
+							for (let i = 0; i < currentNum; i++) {
+								plug.printer({"TSC":_this.OrderLable(item.name,item.id)},ret=>{
+									//uni.showToast({ title: JSON.stringify(ret), duration: 5000 })
+								})
+							}
+						}
+					})
+
+				}
+			})
+
+		},
+		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;
+		},
+    // #endif
 		reduceItemFn(item) {
 			this.replaceItemFn(item,0,'sub')
 		},