shish 4 years ago
parent
commit
52b147d2d7

+ 6 - 2
ghsApp/src/admin/billing/affirm.vue

@@ -320,8 +320,12 @@ export default {
 
 					plug.state({},ret=>{
 						if(ret.code == 1){
-              that.$util.confirmModal({content:'您还没有连接蓝牙,请先链接'},() => {
-                that.pageTo({url:'/admin/tools/blue'})
+              that.$util.confirmModal({content:'您还没有连接标签机,请先连接'},() => {
+                // #ifdef APP-PLUS
+                plug.connectUSB({setBackgroundColor:"#2088d2"},ret=>{   
+                  //console.log(ret)
+                })
+                // #endif
               })
 						}else{
 							let currentNum = Number(doNum[index])

+ 12 - 4
ghsApp/src/admin/item/list.vue

@@ -113,8 +113,12 @@ export default {
 						// #ifdef APP-PLUS
 						plug.state({},ret=>{
 							if(ret.code == 1){
-								that.$util.confirmModal({content:'您还没有连接蓝牙,请先链接'},() => {
-									that.pageTo({url:'/admin/tools/blue'})
+								that.$util.confirmModal({content:'您还没有连接标签机,请先连接'},() => {
+									// #ifdef APP-PLUS
+									plug.connectUSB({setBackgroundColor:"#2088d2"},ret=>{   
+									//console.log(ret)
+									})
+									// #endif
 								})
 							}else{
 								let currentNum = Number(doNum[index])
@@ -237,8 +241,12 @@ export default {
 			let that = this
 			plug.state({},ret=>{
 				if(ret.code == 1){
-					that.$util.confirmModal({content:'您还没有连接蓝牙,请先链接'},() => {
-						that.pageTo({url:'/admin/tools/blue'})
+					that.$util.confirmModal({content:'您还没有连接标签机,请先连接'},() => {
+						// #ifdef APP-PLUS
+						plug.connectUSB({setBackgroundColor:"#2088d2"},ret=>{   
+						//console.log(ret)
+						})
+						// #endif
 					})
 				}else{
 					if(!that.$util.isEmpty(this.globalClassItemList)){

+ 7 - 3
ghsApp/src/admin/itemClass/list.vue

@@ -133,9 +133,13 @@ export default {
 			let that = this
 			plug.state({},ret=>{
 				if(ret.code == 1){
-					that.$util.confirmModal({content:'您还没有连接蓝牙,请先链接'},() => {
-                		that.pageTo({url:'/admin/tools/blue'})
-              		})
+					that.$util.confirmModal({content:'您还没有连接标签机,请先连接'},() => {
+						// #ifdef APP-PLUS
+						plug.connectUSB({setBackgroundColor:"#2088d2"},ret=>{   
+						//console.log(ret)
+						})
+						// #endif
+					})
 				}else{
 					that.$util.confirmModal({content:'确认打印?'},() => {
 						allProduct({classId:classId}).then(res=>{

+ 12 - 4
ghsApp/src/pagesPurchase/info.vue

@@ -225,8 +225,12 @@ export default {
 			// #ifdef APP-PLUS
 			plug.state({},ret=>{
 				if(ret.code == 1){
-					that.$util.confirmModal({content:'您还没有连接蓝牙,请先链接'},() => {
-						that.pageTo({url:'/admin/tools/blue'})
+					that.$util.confirmModal({content:'您还没有连接标签机,请先连接'},() => {
+						// #ifdef APP-PLUS
+						plug.connectUSB({setBackgroundColor:"#2088d2"},ret=>{   
+						//console.log(ret)
+						})
+						// #endif
 					})
 				}else{
 					that.$util.confirmModal({content:'确定打印'+ele.name+'的标签?'},() => {
@@ -253,8 +257,12 @@ export default {
 			// #ifdef APP-PLUS
 			plug.state({},ret=>{
 				if(ret.code == 1){
-					that.$util.confirmModal({content:'您还没有连接蓝牙,请先链接'},() => {
-						that.pageTo({url:'/admin/tools/blue'})
+					that.$util.confirmModal({content:'您还没有连接标签机,请先连接'},() => {
+						// #ifdef APP-PLUS
+						plug.connectUSB({setBackgroundColor:"#2088d2"},ret=>{   
+						//console.log(ret)
+						})
+						// #endif
 					})
 				}else{
 					that.$util.confirmModal({content:'确定打印全部标签?'},() => {

+ 1 - 1
hdPad/src/mixins/product.js

@@ -133,7 +133,7 @@ export default {
 		replaceItemFn(product,scan=0) {
 			let item = copyObject(product)
 			const list = this.selectList
-			let index = list.findIndex(element => element.id == item.id)
+			let index = list.findIndex(element => element.id == item.id && Number(element.property) == Number(item.property))
 
 			//扫码数量累加
 			if(index != -1 && scan == 1){

+ 102 - 18
hdPad/src/pages/home/components/createWork.vue

@@ -1,8 +1,8 @@
 <template>
     <view class="finish-area">
         <view class="cell-item">
-          <view class="item"><text class="left">名称</text> <input v-model="form.name" placeholder="请填写名称" placeholder-class="gray" /></view>
-          <view class="item"><text class="left">数量</text> <input v-model="form.num" placeholder="请填写数量" placeholder-class="gray" /></view>
+          <view class="item"><text class="left">名称</text> <input v-model="form.name" placeholder="请填写名称,留空默认花束" placeholder-class="gray" /></view>
+          <view class="item"><text class="left">数量</text> <input v-model="form.num" type="number" @focus="form.num=''" placeholder="请填写数量" placeholder-class="gray" /></view>
           <view class="item">
             <text class="left">分类</text>
             <view class="class-item-list">
@@ -41,6 +41,11 @@
             <button @click="cancelCreate()">取消</button>
             <button @click="confirmCreate()">确认</button>
         </view>
+
+        <uni-popup ref="getPrintRef" type="dialog">
+            <uni-popup-dialog type="info" cancelText="取消" confirmText="好的" title="提示" content="您还没有连接标签机,请先连接" @confirm="confirmGetPrint"></uni-popup-dialog>
+        </uni-popup>
+
     </view>
 </template>
 <script>
@@ -50,6 +55,9 @@ import { mapGetters } from "vuex"
 import {getClass} from '@/api/category'
 import productMins from "@/mixins/product"
 import { createWorkFn } from '@/api/work'
+// #ifdef APP-PLUS
+const plug = uni.requireNativePlugin('Html5app-Gprinter')
+// #endif
 export default {
     name:'finishWork',
     components:{
@@ -73,6 +81,7 @@ export default {
             currentImgData:[],
             currentJobType:'make',
             currentJobId:0,
+            hasConnect:true
         }
     },
 	computed:{
@@ -124,12 +133,18 @@ export default {
         cancelCreate(){
             this.$emit('cancelCreate')
         },
+        confirmGetPrint(){
+            plug.connectUSB({setBackgroundColor:"#2088d2"},ret=>{   
+                //console.log(ret)
+            })
+        },
         confirmCreate(){
+            // #ifdef MP-WEIXIN
+            this.$msg('请在APP上操作')
+            // #endif
+            // #ifdef APP-PLUS
+            let that = this
             this.$util.hitRemind()
-            if(this.$util.isEmpty(this.form.name)){
-                this.$msg('请填写名称')
-                return false
-            }
             if(this.form.cover == ''){
                 this.$msg('请上传图片')
                 return false
@@ -138,26 +153,95 @@ export default {
 				this.$msg('请选择花材')
 				return false
 			}
-			let product = this.selectList.map(i=>({ productId:i.id, unitType: i.unitType, num: i.currentNum}))
+            if(this.form.needPrint == 1){
+                plug.state({},ret=>{
+                    if(ret.code == 1){
+                        //提醒连接标签机
+                        that.$refs.getPrintRef.open('center')
+                    }else{
+                        this.commitCreate()
+                    }
+                })
+            }else{
+                this.commitCreate()
+            }
+            // #endif
+        },
+        commitCreate(){
+            let that = this
+            let product = this.selectList.map(i=>({ productId:i.id, unitType: i.unitType, num: i.currentNum}))
 			uni.showLoading({mask:true})
 			createWorkFn({...this.form,product:JSON.stringify(product)}).then(res=>{
 				uni.hideLoading()
 				if(res.code == 1){
-					this.$msg(res.msg)
-                    this.$emit('confirmCreate')
-					this.removeFromSaveDirect()
+					that.$msg(res.msg)
+                    that.$emit('confirmCreate')
+					that.removeFromSaveDirect()
 
-                    this.form.cover = ''
-                    this.currentImgData = []
-                    this.form.name=''
-                    this.form.catId = this.catList[0].id
-                    this.form.flowerNum = 0
-                    this.form.needPrint = 1
-                    this.form.complete = 1
+                    if(that.form.needPrint == 1){
+                        let goodsSn = res.data.goodsSn || ''
+                        let name = res.data.name || ''
+                        let currentNum = res.data.num ? Number(res.data.num) : 1
+                        if(!that.$util.isEmpty(goodsSn)){
+                            let data = []
+                            let label = that.createLable(name,goodsSn,currentNum)
+                            data.push(label)
+                            //说明地址 https://ext.dcloud.net.cn/plugin?id=462
+                            plug.printer({"TSC":data,isArray:true},result=>{
+                                //console.log(result)
+                            })
+                        }
+                    }
+
+                    that.form.cover = ''
+                    that.currentImgData = []
+                    that.form.name=''
+                    that.form.catId = that.catList[0].id
+                    that.form.flowerNum = 0
+                    that.form.needPrint = 1
+                    that.form.complete = 1
 
 				}
 			})
-        }
+        },
+		//大标签
+		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;
+		},
     }
 }
 </script>