lilei 2 rokov pred
rodič
commit
8825a5708b

+ 1 - 1
components/kk-printer/index.vue

@@ -48,7 +48,7 @@
 										</view>
 										<view style="width: 120rpx;text-align: right;">
 											<!-- <u-icon :size="60" color="#55aaff" name="plus-circle"></u-icon> -->
-											<u-button :loading="isConnecting" @tap="handleConnectDevice(item)" shape="circle" size="mini" :custom-style="{background:$config('primaryColor')}" type="primary">{{isConnecting?'连接中':'连接'}}</u-button>
+											<u-button :disabled="isConnecting" :loading="isConnecting&&deviceId==item.deviceId" @tap="handleConnectDevice(item)" shape="circle" size="mini" :custom-style="{background:$config('primaryColor')}" type="primary">{{isConnecting?'连接中':'连接'}}</u-button>
 										</view>
 									</view>
 								</view>

+ 10 - 9
libs/printTools.js

@@ -112,21 +112,22 @@ export const printTempl = function(tsc,data){
 }
 
 // 格式化cpcl打印文本
-export const textCpclFormat = function(cpcl,text,maxFontNums,left,top,lightHeight,align,fontName,fontSize){
+export const textCpclFormat = function(cpcl,text,maxFontNums,left,top,lightHeight,align,fontName,fontSize,ellipsis=false){
 	let rowTop = top
-	const maxNums = maxFontNums
+	const maxNums = maxFontNums*1.8
 	const rowHeight = lightHeight
-	const textArr = getTextRows(text.replace(/\s+/g, ' '),maxNums*2)
-	const rows = textArr.length
+	const textArr = getTextRows(text.replace(/\s+/g, ' '),maxNums)
+	const len = ellipsis ? 1 : textArr.length
 	let result = ''
-	for(let i=0;i<rows;i++){
+	for(let i=0;i<len;i++){
+		const texts = !ellipsis||(textArr.length==1) ? textArr[i] : (textArr[i].substr(0,maxFontNums-3)+'...')
 		if(align=="center"){
 			result += cpcl.addCPCLLocation(2)
 		}
 		else{
 			result += cpcl.addCPCLLocation(0)
 		}
-		result += cpcl.addCPCLText(left,rowTop,fontName,fontSize,0,textArr[i]);
+		result += cpcl.addCPCLText(left,rowTop,fontName,fontSize,0,texts);
 		rowTop = rowTop+rowHeight+5
 	}
 	return {result:result,top:rowTop}
@@ -139,19 +140,19 @@ export const printCpclTempl = function(cpcl,data){
 	const lightHeight = 24 // 行高3mm,1mm = 8点
 	const pageW = 60 // 页签宽度mm
 	const pageH = 40 // 页签高度mm
-	const maxFontNums = Math.floor((pageW*8-left*4)/lightHeight) // 每行最多字体数
+	const maxFontNums = Math.floor((pageW*8-left*2)/lightHeight) // 每行最多字体数
 	const leftMaxFnums = Math.floor(maxFontNums*0.4)
 	const rightMaxFnums = leftMaxFnums + 2
 	let rightLeft = (leftMaxFnums+2)*lightHeight
 	// 初始化打印机
-	let strCmd =cpcl.CreatCPCLPage(pageW*8,pageH*8,data.currentInven,0);
+	let strCmd =cpcl.CreatCPCLPage(pageW*8,pageH*8,data.currentInven,0,0);
 	// 经销商文字高度,是否换行
 	const a = textCpclFormat(cpcl,data.dealerName,maxFontNums,0,top,lightHeight,"center",'24',0);
 	top = a.top;
 	strCmd += a.result;
 	// 数字货架名称文字
 	top = top+10;
-	const b = textCpclFormat(cpcl,data.shelfName,maxFontNums,0,top,lightHeight,"center",'24',0);
+	const b = textCpclFormat(cpcl,data.shelfName,maxFontNums,0,top,lightHeight,"center",'24',0,true);
 	top = b.top;
 	strCmd += b.result;
 	// 二维码

+ 1 - 0
pages/batchShelves/batchPrint/batchPrint.vue

@@ -89,6 +89,7 @@
 			})
 		},
 		onUnload() {
+			// this.$refs.kkprinter.closeConnect()
 			this.partList = []
 			// 保持屏幕常亮
 			uni.setKeepScreenOn({

+ 4 - 4
pages/latePlay/chooseProduct.vue

@@ -125,7 +125,7 @@
 		},
 		// 批量打印
 		onNavigationBarButtonTap(e) {
-			if(this.queryWord=='' && this.placeTab.length>1){
+			if(this.queryWord=='' && this.placeTab.length>1&&this.allList.length>50){
 				if(this.curTab=='all'){
 					uni.showToast({
 						icon: 'none',
@@ -136,9 +136,9 @@
 				}
 			}
 			
-			const list = this.allList.filter(item => item.qty>0)
-			this.$store.state.vuex_tempPrintList = list
-			if(this.shelfInfo&&list.length){
+			// const list = this.allList.filter(item => item.qty>0)
+			this.$store.state.vuex_tempPrintList = this.allList
+			if(this.shelfInfo&&this.allList.length){
 				uni.navigateTo({
 					url: "/pages/shelfSetting/batchPrint?page=bdtq&data="+encodeURIComponent(JSON.stringify(this.shelfInfo)) 
 				})

+ 1 - 1
pages/shelfSetting/productList.vue

@@ -79,7 +79,7 @@
 		data() {
 			return {
 				partList: [],
-				printNum: 1
+				printNum: 2
 			}
 		},
 		methods: {

+ 1 - 0
pages/shelfSetting/quickReplenish.vue

@@ -90,6 +90,7 @@
 			});
 		},
 		onUnload() {
+			// this.$refs.kkprinter.closeConnect()
 			this.partList = []
 			this.$store.state.vuex_tempData = null
 			// 保持屏幕常亮

+ 3 - 0
pages/userCenter/index.vue

@@ -44,6 +44,7 @@
 	import { getUserInfo, logout, login, getUnreadCount, logoff } from '@/api/user.js'
 	import { getSysVersion } from '@/api/data.js'
 	import { checkVersionToLoadUpdate, clzConfirm } from '@/libs/tools';
+	import * as blesdk from '@/components/kk-printer/utils/bluetoolth';
 	import market from "@/js_sdk/dc-market/market.js"
 	export default {
 		data() {
@@ -112,6 +113,8 @@
 					content: '重置打印机后就可以重新选择其它打印机,您确定重置吗?',
 					success: function(res) {
 						if (res.confirm || res.index == 0) {
+							const lastDevice = uni.getStorageSync('vuex_lastBuleDevice')
+							blesdk.closeBLEConnection(lastDevice.deviceId)
 							uni.setStorageSync('vuex_lastBuleDevice','')
 							uni.showToast({
 								title: '重置成功'