shish 4 лет назад
Родитель
Сommit
13e481baa4
2 измененных файлов с 132 добавлено и 36 удалено
  1. 54 15
      ghsApp/src/admin/item/list.vue
  2. 78 21
      ghsApp/src/pagesPurchase/info.vue

+ 54 - 15
ghsApp/src/admin/item/list.vue

@@ -58,7 +58,7 @@ import { mapGetters } from "vuex";
 import { getWeixinId } from "@/api/invite/index";
 import { generatePriceTable,generateBarcodeTable } from '@/api/product/index'
 // #ifdef APP-PLUS
-const plug= uni.requireNativePlugin('Html5app-Gprinter')
+const plug = uni.requireNativePlugin('Html5app-Gprinter')
 // #endif
 export default {
 	name: "item_list",
@@ -102,8 +102,8 @@ export default {
 		moreToDo(item){
 			//查询是否已经连接蓝牙
 			let that=this;
-			let doList = ['复制花材', '打印1个条形', '打印条形2个', '打印条形5个','打印条形10个','打印条形20个']
-			let doNum = [0,1,2,5,10,20]
+			let doList = ['复制花材', '打印1个条形', '打印2个条形码', '打印条形10个','打印条形20个']
+			let doNum = [0,1,2,10,20]
 			uni.showActionSheet({
 				itemList: doList,
 				success: function (respond) {
@@ -111,7 +111,6 @@ export default {
 					if (index == 0) {
 						that.pageTo({url: '/admin/item/copy',query: {id: item.id}})
 					}
-
 					// #ifdef APP-PLUS
 					plug.state({},ret=>{
 						if(ret.code == 1){
@@ -120,27 +119,68 @@ export default {
 							})
 						}else{
 							let currentNum = Number(doNum[index])
-							console.log(currentNum)
+							if(Number(currentNum)<0){
+								this.$msg('请选择打印数量')
+								return false
+							}
+							let data = []
 							for (let i = 0; i < currentNum; i++) {
-								//https://ext.dcloud.net.cn/plugin?id=462
-								plug.printer({"TSC":that.OrderLable(item.name,item.itemId)},ret=>{
-									//uni.showToast({ title: JSON.stringify(ret), duration: 5000 })
-								})
+								let label = that.createLable(item.name,item.itemId)
+								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){
+
+			//制作标签格式, 
+			var data=[];  //定义一个数组
+			var line={};  //每添加一个,代表一行字
+
+			//设置标签纸大小
+			line={};
+			line.width=40; //mm
+			line.height=30; //mm
+			line.gap=2; //标签纸之间,间隙长度 mm
+			line.page=1; //打印几份
+			data.push(line); //每添加一个,代表一行字
+
+			//添加文字
+			line={};
+			line.text= itemName;
+			line.rotation=0;
+			line.x=30;
+			line.y=40;
+			line.xscal=1;
+			line.yscal=1;
+			data.push(line); //每添加一个,代表一行字
+
+			//添加条型码
+			line={};
+			line.barcode=itemId;
+			line.x=30;
+			line.y=110;
+			line.type="CODE128";
+			line.height=300;
+			line.readable=true;
+			line.rotation=0;
+			data.push(line);
 
+			return data;
 		},
-		
-		OrderLable(itemName,itemId){
-			
+		createLable2(itemName,itemId){
+
 			//制作标签格式, 
 			var data=[];  //定义一个数组
 			var line={};  //每添加一个,代表一行字
-			
+
 			//设置标签纸大小
 			line={};
 			line.width=30; //mm
@@ -180,7 +220,6 @@ export default {
 				itemList: doList,
 				success: function (respond) {
 					let index = respond.tapIndex
-
 					if(index == 0){
 						that.downBarcodeTable()
 					}
@@ -203,7 +242,7 @@ export default {
 							if(!that.$util.isEmpty(globalItem.child)){
 								globalItem.child.forEach((currentItem)=>{
 									console.log(currentItem)
-									plug.printer({"TSC":that.OrderLable(currentItem.name,currentItem.itemId)},ret=>{
+									plug.printer({"TSC":that.createLable(currentItem.name,currentItem.itemId)},ret=>{
 										//uni.showToast({ title: JSON.stringify(ret), duration: 5000 })
 									})
 								})

+ 78 - 21
ghsApp/src/pagesPurchase/info.vue

@@ -12,10 +12,7 @@
 					</view>
 				</view>
 				<view>
-					<i
-						@click="callUp(detailInfo.supplierMobile)"
-						class="iconfont icondianhua1"
-					></i>
+					<i @click="callUp(detailInfo.supplierMobile)" class="iconfont icondianhua1" ></i>
 				</view>
 			</view>
 			<view class="title">
@@ -30,12 +27,7 @@
 					<view>订单编码:</view>
 					<view>{{ detailInfo.orderSn }}</view>
 					<view class="price">
-						<button
-							@click="copy(detailInfo.orderSn)"
-							class="admin-button-com default"
-						>
-							复制
-						</button>
+						<button @click="copy(detailInfo.orderSn)" class="admin-button-com default" > 复制 </button>
 					</view>
 				</view>
 				<view class="order-info_box">
@@ -80,24 +72,19 @@
 			</view>
 
 			<view class="title">
-				商品信息
+				商品信息 <text @click="printAllLabel()" style="float:right;font-weight:normal;color:#3385FF;">打印标签</text>
 			</view>
 			<view class="module-com content-box">
 				<view class="commodity-view">
 					<view class="commodity-list">
-						<view
-							v-for="(s, idx) in detailInfo.itemInfo"
-							:key="idx"
-							class="commodity-item"
-						>
+						<view v-for="(s, idx) in detailInfo.itemInfo" :key="idx" class="commodity-item" >
 							<image class="item-icon" :src="s.cover" alt="" />
-
 							<view class="item-info">
 								<view class="info-line">
 									<text class="item-name">{{ s.name }}</text>
 									<text class="item-price">
 										<text class="unit">¥</text>
-										<text class="price">{{ s.bigPrice }}</text>
+										<text class="price">{{ s.bigPrice ? parseFloat(s.bigPrice) : 0 }}</text>
 									</text>
 								</view>
 								<view class="info-line">
@@ -110,8 +97,8 @@
 					<view class="summary-bar">
 						<view class="operate-view" ></view>
 						<view class="describe-view">
-							共{{ detailInfo.kind || 0 }}种, 共{{ detailInfo.bigNum }}扎{{
-								detailInfo.smallNum}}支,合计 ¥<text class="price">{{ detailInfo.price }}</text>
+							共{{ detailInfo.kind || 0 }}种,<text v-if="Number(detailInfo.bigNum)>0">{{ detailInfo.bigNum }}扎</text><text v-if="Number(detailInfo.smallNum)>0">{{detailInfo.smallNum}}支</text>,
+							合计 ¥<text class="price">{{ detailInfo.price ? parseFloat(detailInfo.price) : 0 }}</text>
 						</view>
 					</view>
 				</view>
@@ -208,7 +195,9 @@ import { getPurchaseDetailApi,updateRemark } from "@/api/purchase/index";
 import productMins from "@/mixins/product";
 import { clearOrderApi } from "@/api/gys/index";
 import TuiListCell from "@/components/plugin/list-cell";
-
+// #ifdef APP-PLUS
+const plug = uni.requireNativePlugin('Html5app-Gprinter')
+// #endif
 export default {
 	name: "info",
 	components: {
@@ -231,6 +220,74 @@ export default {
 
 	},
 	methods: {
+		printAllLabel(){
+			// #ifdef APP-PLUS
+			let that = this
+			plug.state({},ret=>{
+				if(ret.code == 1){
+					that.$util.confirmModal({content:'您还没有连接蓝牙,请先链接'},() => {
+						that.pageTo({url:'/admin/tools/blue'})
+					})
+				}else{
+					that.$util.confirmModal({content:'确定打印全部标签?'},() => {
+						if(!this.$util.isEmpty(this.detailInfo.itemInfo)){
+							let data = []
+							for (const elem of this.detailInfo.itemInfo) {
+								let currentNum = parseFloat(elem.itemNum)
+								for (let i = 0; i < currentNum; i++) {
+									if(elem.name && !this.$util.isEmpty(elem.name)){
+										let label = that.createLable(elem.name,elem.itemId)
+										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){
+
+			//制作标签格式, 
+			var data=[];  //定义一个数组
+			var line={};  //每添加一个,代表一行字
+
+			//设置标签纸大小
+			line={};
+			line.width=30; //mm
+			line.height=20; //mm
+			line.gap=2; //标签纸之间,间隙长度 mm
+			line.page=1; //打印几份
+			data.push(line); //每添加一个,代表一行字
+
+			//添加文字
+			line={};
+			line.text= itemName;
+			line.rotation=0;
+			line.x=35;
+			line.y=20;
+			line.xscal=1;
+			line.yscal=1;
+			data.push(line); //每添加一个,代表一行字
+
+			//添加条型码
+			line={};
+			line.barcode=itemId;
+			line.x=35;
+			line.y=55;
+			line.type="CODE128";
+			line.height=50;
+			line.readable=true;
+			line.rotation=0;
+			data.push(line);
+
+			return data;
+		},
 		//咨询是否结账
 		clearOrder(item){
 			let that = this