|
|
@@ -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>
|