shish 4 anni fa
parent
commit
6d47f85a6a

+ 4 - 0
hdPad/src/api/work/index.js

@@ -1,5 +1,9 @@
 import https from '@/plugins/luch-request_0.0.7/request'
 
+export const print = data => {
+	return https.get('/work/print', data)
+}
+
 //制作单列表
 export const getWorkList = data => {
 	return https.get('/work/list', data)

+ 3 - 83
hdPad/src/pages/home/components/createWork.vue

@@ -18,11 +18,9 @@
           <view class="item">
             <text class="left">图片</text>
             <view>
-
                 <htz-image-upload :max="1" :compress="true" v-model="currentImgData" :headers="headers"
                 @uploadSuccess="imgUploadSuccess" @imgDelete="imgDeleteFn" :action="getLoginInfo.imgUploadApi">
                 </htz-image-upload>
-
             </view>
           </view>
 
@@ -32,7 +30,7 @@
           </view>
 
           <view class="item" v-if="form.complete == 1">
-              <text class="left">打印条码</text>
+              <text class="left">打印</text>
               <switch :checked="form.needPrint == 1 ? true : false" @change="changePrint" style="transform: scale(0.9,0.8)" />
           </view>
 
@@ -42,10 +40,6 @@
             <button @click="confirmAdd()">确认</button>
         </view>
 
-        <uni-popup ref="getPrintRef" type="dialog">
-            <uni-popup-dialog type="info" cancelText="取消" confirmText="好的" title="提示" content="您还没有连接标签机,请先连接" @confirm="confirmGetPrint"></uni-popup-dialog>
-        </uni-popup>
-
         <uni-popup ref="confirmCreateRef" type="dialog">
             <uni-popup-dialog type="info" cancelText="取消" confirmText="确认" title="提示" content="确认提交?" @confirm="confirmCreate"></uni-popup-dialog>
         </uni-popup>
@@ -137,11 +131,6 @@ export default {
         cancelCreate(){
             this.$emit('cancelCreate')
         },
-        confirmGetPrint(){
-            plug.connectUSB({setBackgroundColor:"#2088d2"},ret=>{   
-                //console.log(ret)
-            })
-        },
         confirmAdd(){
             this.$refs.confirmCreateRef.open('center')
         },
@@ -159,23 +148,7 @@ export default {
             if(this.form.complete == 0){
                 this.form.needPrint = 2
             }
-            if(this.form.needPrint == 1){
-                // #ifdef MP-WEIXIN
-                this.$msg('小程序不支持打印条码')
-                // #endif
-                // #ifdef APP-PLUS
-                plug.state({},ret=>{
-                    if(ret.code == 1){
-                        //提醒连接标签机
-                        that.$refs.getPrintRef.open('center')
-                    }else{
-                        this.commitCreate()
-                    }
-                })
-                // #endif
-            }else{
-                this.commitCreate()
-            }
+            this.commitCreate()            
         },
         commitCreate(){
             let that = this
@@ -188,21 +161,6 @@ export default {
                     that.$emit('confirmCreate')
 					that.removeFromSaveDirect()
 
-                    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=''
@@ -213,45 +171,7 @@ export default {
 
 				}
 			})
-        },
-		//大标签
-		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>

+ 6 - 70
hdPad/src/pages/home/components/workInfo.vue

@@ -104,7 +104,7 @@
 </view>
 </template>
 <script>
-import { getFullInfo,finish,lockWork,cancelWork } from '@/api/work'
+import { getFullInfo,finish,lockWork,cancelWork,print } from '@/api/work'
 import {modifyWastage} from '@/api/work-item'
 import wastageSelectNum from './wastageSelectNum.vue'
 // #ifdef APP-PLUS
@@ -124,77 +124,13 @@ export default {
     }
   },
   methods:{
-    confirmGetPrint(){
-      // #ifdef APP-PLUS
-			plug.connectUSB({setBackgroundColor:"#2088d2"},ret=>{   
-			  //console.log(ret)
+    printFn(item){
+			print({id:item.id}).then(res=>{
+				if(res.code == 1){
+					this.$msg(res.msg)
+				}
 			})
-      // #endif
     },
-    printFn(info){
-      let that = this
-      // #ifdef APP-PLUS
-      plug.state({},ret=>{
-        if(ret.code == 1){
-          that.$refs.getPrintRef.open('center')
-        }else{
-          let currentNum = parseFloat(Number(info.num))
-          if(Number(currentNum)<0){
-            this.$msg('数量错误')
-            return false
-          }
-          let data = []
-          let label = that.createLable(info.name,info.goodsSn,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')
     },