|
|
@@ -30,7 +30,7 @@
|
|
|
<view class="module-com content-box proInfo">
|
|
|
<view class="commodity-view">
|
|
|
<view class="infoAEdit">
|
|
|
- <text>商品信息</text>
|
|
|
+ <text>商品信息</text> <text @click="printAllLabel()" style="float:right;font-weight:normal;color:#3385FF;margin-right:10upx;">打全部条码</text>
|
|
|
</view>
|
|
|
<view class="commodity-list">
|
|
|
<view v-for="(s, idx) in itemList" :key="idx" class="commodity-item" >
|
|
|
@@ -46,7 +46,7 @@
|
|
|
</text>
|
|
|
</view>
|
|
|
<view class="info-line">
|
|
|
- <text class="item-type"></text>
|
|
|
+ <text class="item-type" style="color:#3385FF;" @click.stop="printLabel(s)">打条码</text>
|
|
|
<text class="item-count">¥{{ parseFloat(s.totalPrice)||0 }}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -97,6 +97,9 @@
|
|
|
<script>
|
|
|
import { getPlantCgDetail} from "@/api/goods/index";
|
|
|
import TuiListCell from "@/components/plugin/list-cell";
|
|
|
+// #ifdef APP-PLUS
|
|
|
+const plug = uni.requireNativePlugin('Html5app-Gprinter')
|
|
|
+// #endif
|
|
|
export default {
|
|
|
name: "plantCgDetail",
|
|
|
components: {
|
|
|
@@ -127,6 +130,139 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
methods: {
|
|
|
+ printLabel(ele){
|
|
|
+ let that = this
|
|
|
+ // #ifdef APP-PLUS
|
|
|
+ plug.state({},ret=>{
|
|
|
+ if(ret.code == 1){
|
|
|
+ that.$util.confirmModal({content:'您还没有连接条码机,请先连接'},() => {
|
|
|
+ // #ifdef APP-PLUS
|
|
|
+ plug.connectUSB({setBackgroundColor:"#2088d2"},ret=>{
|
|
|
+ //console.log(ret)
|
|
|
+ })
|
|
|
+ // #endif
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ that.$util.confirmModal({content:'确认打印?'},() => {
|
|
|
+ let data = []
|
|
|
+ if(ele.name && !that.$util.isEmpty(ele.name)){
|
|
|
+ let num = parseFloat(ele.num)
|
|
|
+ let label = that.createLable(ele.name,ele.goodsSn,num)
|
|
|
+ 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
|
|
|
+ },
|
|
|
+ printAllLabel(){
|
|
|
+ let that = this
|
|
|
+ // #ifdef APP-PLUS
|
|
|
+ plug.state({},ret=>{
|
|
|
+ if(ret.code == 1){
|
|
|
+ that.$util.confirmModal({content:'您还没有连接条码机,请先连接'},() => {
|
|
|
+ // #ifdef APP-PLUS
|
|
|
+ plug.connectUSB({setBackgroundColor:"#2088d2"},ret=>{
|
|
|
+ //console.log(ret)
|
|
|
+ })
|
|
|
+ // #endif
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ that.$util.confirmModal({content:'确认打印全部条码?'},() => {
|
|
|
+ if(!that.$util.isEmpty(that.itemList)){
|
|
|
+ let data = []
|
|
|
+ for (const ele of that.itemList) {
|
|
|
+ if(ele.name && !that.$util.isEmpty(ele.name)){
|
|
|
+ let num = parseFloat(ele.num)
|
|
|
+ let label = that.createLable(ele.name,ele.goodsSn,num)
|
|
|
+ data.push(label)
|
|
|
+ let separateLabel = that.createSeparateLabel()
|
|
|
+ data.push(separateLabel)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //说明地址 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
|
|
|
+ },
|
|
|
+ //分隔条码
|
|
|
+ createSeparateLabel(){
|
|
|
+ //制作条码格式,
|
|
|
+ var data=[]; //定义一个数组
|
|
|
+ var line={}; //每添加一个,代表一行字
|
|
|
+
|
|
|
+ //设置条码纸大小
|
|
|
+ line={};
|
|
|
+ line.width=40; //mm
|
|
|
+ line.height=50; //mm
|
|
|
+ line.gap=2; //条码纸之间,间隙长度 mm
|
|
|
+ line.page=2; //打印几份
|
|
|
+ data.push(line); //每添加一个,代表一行字
|
|
|
+
|
|
|
+ //添加文字
|
|
|
+ line={};
|
|
|
+ line.text= '======';
|
|
|
+ line.rotation=0;
|
|
|
+ line.x=30;
|
|
|
+ line.y=15;
|
|
|
+ line.xscal=2;
|
|
|
+ line.yscal=2;
|
|
|
+ data.push(line); //每添加一个,代表一行字
|
|
|
+
|
|
|
+ return data;
|
|
|
+ },
|
|
|
+ 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=260;
|
|
|
+ line.y=15;
|
|
|
+ line.xscal=2;
|
|
|
+ line.yscal=2;
|
|
|
+ data.push(line); //每添加一个,代表一行字
|
|
|
+
|
|
|
+ //添加条型码
|
|
|
+ line={};
|
|
|
+ line.barcode=itemId;
|
|
|
+ line.x=260;
|
|
|
+ line.y=80;
|
|
|
+ line.type="CODE128";
|
|
|
+ line.width=2;//条型宽度,这里的宽指的是 条型码 竖条的宽度,不是整个条型码的宽度
|
|
|
+ line.height=90;
|
|
|
+ line.readable=true;
|
|
|
+ line.rotation=0;
|
|
|
+ data.push(line);
|
|
|
+
|
|
|
+ return data;
|
|
|
+ },
|
|
|
copy (val) {
|
|
|
const self = this;
|
|
|
uni.setClipboardData({
|
|
|
@@ -394,7 +530,6 @@ export default {
|
|
|
left: 0;
|
|
|
width: 100vw;
|
|
|
padding: 15upx 0;
|
|
|
- // height: 100upx;
|
|
|
background: #fff;
|
|
|
line-height: 100upx;
|
|
|
border-top: 1px solid #ddd;
|