|
|
@@ -5,18 +5,118 @@
|
|
|
<view class="result-view">
|
|
|
<view class="iconfont iconchenggong"></view>
|
|
|
<view class="result-title">操作成功</view>
|
|
|
- <button class="admin-button-com big blue" style="width:45vh;" @click="goBackHome">返回</button>
|
|
|
+ <button class="admin-button-com big blue" style="width:45vh;" @click="printLabel">打标签</button>
|
|
|
+ <button class="admin-button-com big default" style="width:45vh;margin-top:30upx;" @click="goBackHome">返回</button>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</template>
|
|
|
-
|
|
|
<script>
|
|
|
+import { getFullInfo } from "@/api/plant-cg";
|
|
|
+// #ifdef APP-PLUS
|
|
|
+const plug = uni.requireNativePlugin('Html5app-Gprinter')
|
|
|
+// #endif
|
|
|
export default {
|
|
|
name: "success",
|
|
|
methods: {
|
|
|
goBackHome() {
|
|
|
uni.navigateBack({})
|
|
|
+ },
|
|
|
+ printLabel(){
|
|
|
+ let that = this
|
|
|
+ // #ifdef APP-PLUS
|
|
|
+ plug.state({},ret=>{
|
|
|
+ if(ret.code == 1){
|
|
|
+ that.$util.confirmModal({content:'您还没有连接标签机,请先连接'},() => {
|
|
|
+ plug.connectUSB({setBackgroundColor:"#2088d2"},ret=>{
|
|
|
+ //console.log(ret)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ that.$util.confirmModal({content:'确认打印?'},() => {
|
|
|
+ that.confirmPrintLabel()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // #endif
|
|
|
+ },
|
|
|
+ confirmPrintLabel(){
|
|
|
+ let that = this
|
|
|
+ // #ifdef MP-WEIXIN
|
|
|
+ that.$msg('请在App上打印')
|
|
|
+ // #endif
|
|
|
+ // #ifdef APP-PLUS
|
|
|
+ plug.state({},ret=>{
|
|
|
+ if(ret.code == 1){
|
|
|
+ that.$util.confirmModal({content:'您还没有连接标签机,请先连接'},() => {
|
|
|
+ plug.connectUSB({setBackgroundColor:"#2088d2"},ret=>{
|
|
|
+ //console.log(ret)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ getFullInfo({id:this.option.id}).then(res=>{
|
|
|
+ if(res.code == 1){
|
|
|
+ if(res.data.itemList && !that.$util.isEmpty(res.data.itemList)){
|
|
|
+ let data = []
|
|
|
+ for (const info in res.data.itemList) {
|
|
|
+ let currentNum = info.num ? Number(info.num) : 0
|
|
|
+ let name = info.name || ''
|
|
|
+ let code = info.goodsSn || ''
|
|
|
+ if(Number(currentNum)<=0){
|
|
|
+ this.$msg('请选择打印数量')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ let label = that.createLable(name,code,currentNum)
|
|
|
+ data.push(label)
|
|
|
+ }
|
|
|
+ //说明地址 https://ext.dcloud.net.cn/plugin?id=462
|
|
|
+ plug.printer({"TSC":data,isArray:true},result=>{
|
|
|
+ //console.log(result)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // #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;
|
|
|
}
|
|
|
}
|
|
|
};
|