瀏覽代碼

feat:打印联调

maliang 3 周之前
父節點
當前提交
5258698239

+ 76 - 32
common/mixins/blePrintMixin.js

@@ -1,6 +1,10 @@
 import { mapState, mapActions } from "vuex";
 import { FakeConnectedDevice } from "@psdk/frame-father";
 import bluetoothTool from "@/plugins/BluetoothTool.js";
+import { printMaterial } from "@/common/request/apis/print";
+import printPop from "@/components/print-pop/print-pop.vue";
+import blePop from "@/components/ble-pop/ble-pop.vue";
+import bleTipPop from "@/components/ble-tip-pop/ble-tip-pop.vue";
 
 import {
   TBar,
@@ -41,6 +45,11 @@ async function sendMessage(cmd) {
 
 export default {
   name: "blePrintMixin",
+  components: {
+    printPop,
+    blePop,
+    bleTipPop,
+  },
   computed: {
     ...mapState({
       discoveredDevices: (state) => state.ble.discoveredDevices, // 已发现的蓝牙设备
@@ -67,7 +76,6 @@ export default {
       },
     };
   },
-  mounted() {},
   methods: {
     ...mapActions("ble", [
       "checkBleStatus", // 检查蓝牙设备连接状态
@@ -136,71 +144,76 @@ export default {
     /**
      * 打印
      *@data {Object} 需要打印的数据
+     *@num {number} 需要打印的数量
      * */
-    async writeTsplModel(data) {
+    async writeTsplModel(data, num = 1) {
       const vm = this;
       const obj = {
-        qrCode: data.qrCode, // 二维码
+        qrCode: data.number, // 二维码
         barCode: data.barCode, // 商品条码
         customerName: data.customerName, //客户名
         number: data.number, // 单据编号
-        batchNumber: data.batchNumber, // 批次条码
       };
       try {
+        let cellWidth = 6;
+        if (obj.qrCode.length > 30) cellWidth = 4;
+        if (obj.qrCode.length > 60) cellWidth = 2;
+
+        const startX = 80;
+        const startY = 30;
+        const qrcodeX = startX;
+        const qrcodeY = startY;
+        const qrcodeSize = cellWidth * 21; // 经验值
+        const textStartX = qrcodeX + qrcodeSize + 10;
+        const textStartY = qrcodeY;
+        const textLineHeight = 28;
+
+        const barcodeX = startX;
+        const barcodeY =
+          Math.max(qrcodeY + qrcodeSize, textStartY + textLineHeight * 3) + 15;
+        const barcodeHeight = 50;
+
         const tspl = await vm.$printer
           .tspl()
           .clear()
-          .page(
-            new TPage({
-              width: 76,
-              height: 130,
-            })
-          )
+          .page(new TPage({ width: 76, height: 130 }))
           .qrcode(
             new TQRCode({
-              x: 50,
-              y: 20,
-              content: "283423982494284284828484",
-              cellWidth: 10,
+              x: qrcodeX,
+              y: qrcodeY,
+              content: obj.qrCode,
+              cellWidth,
             })
           )
           .text(
             new TText({
-              x: 50 + 30,
-              y: 20,
+              x: textStartX,
+              y: textStartY,
               content: obj.customerName,
               font: TFont.TSS24,
             })
           )
           .text(
             new TText({
-              x: 50 + 30,
-              y: 20 + 35,
+              x: textStartX,
+              y: textStartY + textLineHeight * 2,
               content: obj.number,
               font: TFont.TSS24,
             })
           )
           .barcode(
             new TBarCode({
-              x: 50,
-              y: 20 + 35 + 20,
+              x: barcodeX,
+              y: barcodeY,
               cellWidth: 2,
-              height: 60,
+              height: barcodeHeight,
               content: obj.barCode,
               rotation: TRotation.ROTATION_0,
               codeType: TCodeType.CODE128,
               showType: 2,
             })
           )
-          .text(
-            new TText({
-              x: 50 + 20,
-              y: 50 + 100,
-              content: obj.barCode,
-              font: TFont.TSS24,
-            })
-          )
-          .print();
+          .print(num);
         var binary = tspl.command().binary();
         await sendMessage(Array.from(uint8ArrayToSignedArray(binary)));
       } catch (e) {
@@ -212,9 +225,40 @@ export default {
     },
 
     async writeData({ num = 1, data }) {
-      for (let i = 0; i < num; i++) {
-        await this.writeTsplModel(data);
+      await this.writeTsplModel(data, num);
+    },
+    //条码逻辑
+    async handlePrint(id) {
+      try {
+        uni.showLoading({
+          mask: true,
+        });
+        const res = await printMaterial({ id });
+        console.log("item===id==", id);
+        console.log("res=====", res);
+        if (res.code == 200) {
+          const data = {
+            customerName: res.data.customerName,
+            number: res.data.number,
+            barCode: res.data.barCode,
+          };
+          this.openBlePrintPop(data);
+        } else {
+          uni.showToast({
+            icon: "none",
+            title: res.msg || res.data || "服务器错误",
+            duration: 2000,
+          });
+        }
+      } catch (error) {
+        //TODO handle the exception
+      } finally {
+        uni.hideLoading();
       }
     },
+    //开始打印
+    startPrint(data) {
+      this.writeData(data);
+    },
   },
 };

+ 4 - 0
common/request/apis/print.js

@@ -0,0 +1,4 @@
+//打印
+export const printMaterial = (params, config = { custom: { auth: true } }) => {
+  return uni.$u.http.get(`/pda/printMaterial`, { params }, config);
+};

+ 1 - 1
components/ble-pop/ble-pop.vue

@@ -131,7 +131,7 @@ export default {
 }
 .ble-item {
   display: grid;
-  grid-template-columns: 100rpx 1fr 120rpx;
+  grid-template-columns: 80rpx 300rpx 120rpx;
   align-items: center;
   margin-bottom: 20rpx;
   width: 100%;

+ 0 - 0
pages/picking-task/components/ble-tip-pop.vue → components/ble-tip-pop/ble-tip-pop.vue


+ 23 - 1
components/good-item/good-item.vue

@@ -41,6 +41,11 @@
 			</view>
 			</view>
 			<slot></slot>
+			<view class="action-btn-box" v-if="showPrint">
+				<view class="print-btn" @click="clickPrint">
+					打印条码
+				</view>
+			</view>
 		</view>
 	</view>
 </template>
@@ -51,6 +56,10 @@
 			item:{
 				type:Object,
 				default:()=>{}
+			},
+			showPrint:{
+				type:Boolean,
+				default: false
 			}
 		},
 		data() {
@@ -66,6 +75,9 @@
 			},
 			calendarClick() {
 				this.$emit('calendarClick',this.item)
+			},
+			clickPrint(){
+				this.$emit('print',this.item)
 			}
 		}
 	}
@@ -115,5 +127,15 @@
 			}
 		}
 	}
-	
+	.action-btn-box{
+		text-align: right;
+		padding: 30rpx 48rpx 0 26rpx;
+		
+		.print-btn{
+			font-family: PingFang SC;
+			font-weight: 500;
+			font-size: 28rpx;
+			color: #0256FF;
+		}
+	}
 </style>

+ 11 - 11
components/print-pop/print-pop.vue

@@ -15,15 +15,14 @@
               <uqrcode
                 ref="uqrcode"
                 canvas-id="qrcode"
-                value="https://uqrcode.cn/doc"
+                :value="info.number"
                 sizeUnit="rpx"
                 :size="200"
               ></uqrcode>
             </view>
             <view class="flex-box flex-column flex-justify-sa info-box">
-              <view class="item-value">快马便利</view>
-              <view class="item-value">阳光店</view>
-              <view class="item-value">DD2500426-188</view>
+              <view class="item-value">{{ info.customerName }}</view>
+              <view class="item-value">{{ info.number }}</view>
             </view>
           </view>
           <tki-barcode
@@ -85,7 +84,11 @@ export default {
     },
     info: {
       type: Object,
-      default: () => ({}),
+      default: () => ({
+        customerName: "",
+        number: "",
+        barCode: "",
+      }),
     },
   },
   computed: {
@@ -113,13 +116,10 @@ export default {
     handleConfirm() {
       const params = {
         num: this.printNum,
-        // data: this.info,
         data: {
-          qrCode: "12892u483482731", // 二维码
-          barCode: "189387467634928", // 商品条码
-          customerName: "快马便利(阳光店)", //客户名
-          number: "DD2500426-188", // 单据编号
-          batchNumber: "12892847378728467", // 批次条码
+          barCode: this.info.barCode, // 商品条码
+          customerName: this.info.customerName, //客户名
+          number: this.info.number, // 单据编号
         },
       };
       this.$emit("confirm", params);

+ 3 - 2
pages/goods/detail.vue

@@ -104,8 +104,8 @@
 						<view class="crk-item-line">{{currentCrkId == 'out' ?'出库':'入库'}}时间:{{item.warehousingTime || '-'}}</view>
 						<view class="crk-item-line">{{currentCrkId == 'out' ?'出库':'入库'}}数量:{{(item.actualQuantityInStorage * 1).toFixed(0) || 0}}{{item.commodityUnit || ''}}</view>
 						<view class="img-box">
-							<u-image v-if="currentCrkId == 0" src="@/static/image/yck-img.png" width="132rpx" height="132rpx"></u-image>
-							<u-image v-if="currentCrkId == 1" src="@/static/image/yrk-img.png" width="132rpx" height="132rpx"></u-image>
+							<u-image v-if="currentCrkId == 'out'" src="@/static/image/yck-img.png" width="132rpx" height="132rpx"></u-image>
+							<u-image v-if="currentCrkId == 'in'" src="@/static/image/yrk-img.png" width="132rpx" height="132rpx"></u-image>
 						</view>
 					</view>
 					<u-empty mode="data" text="暂无内容" marginTop="60" icon="https://xiangli-erp.oss-cn-hangzhou.aliyuncs.com/APP/no-notifcations.png" v-if="cukList.length == 0"></u-empty>
@@ -150,6 +150,7 @@
 		},
 		methods:{
 			tabClick(item) {
+				console.log('tabClick=====',item)
 				this.currentCrkId = item.id
 				this.getMaterialDepotDetail()
 			},

+ 43 - 5
pages/inventory-task/components/inventoryFilterPopup.vue

@@ -10,7 +10,7 @@
   >
     <view class="filter-popup">
       <view class="filter-header">
-        <u-tabs
+        <!-- <u-tabs
           :list="tabList"
           :current="currentTab"
           @change="tabChange"
@@ -22,7 +22,20 @@
             color: '#333333',
           }"
           itemStyle="padding-left: 30rpx; padding-right: 30rpx; height: 100rpx;"
-        ></u-tabs>
+        ></u-tabs> -->
+        <view class="type-box flex_box">
+          <view
+            class="type-item"
+            v-for="(item, index) in tabList"
+            :key="index"
+            @click="tabChange({ index })"
+          >
+            <view class="type-val" :class="{ actived: currentTab === index }">{{
+              item.name
+            }}</view>
+            <u-icon name="arrow-down-fill" color="#999999" size="12"></u-icon>
+          </view>
+        </view>
       </view>
       <view class="filter-content">
         <!-- 盘点状态 -->
@@ -395,7 +408,8 @@ export default {
   height: 70vh;
 
   .filter-header {
-    border-bottom: 1rpx solid #f5f6f7;
+    padding: 0 30rpx;
+    margin-top: 40rpx;
   }
 
   .filter-content {
@@ -413,7 +427,6 @@ export default {
       padding: 30rpx;
       font-size: 28rpx;
       color: #333;
-      border-bottom: 1rpx solid #f5f6f7;
 
       &.active {
         background-color: #f0f6fb;
@@ -468,7 +481,6 @@ export default {
     .checkbox-item {
       padding: 30rpx;
       font-size: 28rpx;
-      border-bottom: 1rpx solid #f5f6f7;
 
       &:last-child {
         border-bottom: none;
@@ -488,3 +500,29 @@ export default {
   }
 }
 </style>
+
+<style lang="scss" scoped>
+.type-box {
+  .type-item {
+    padding: 20rpx 0;
+    margin-right: 50rpx;
+    height: 88rpx;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    .type-val {
+      color: #000;
+      font-family: "PingFang SC";
+      font-size: 28rpx;
+      font-weight: 400;
+      margin-right: 10rpx;
+      font-family: PingFang SC;
+
+      &.actived {
+        color: rgba(2, 86, 255, 1);
+        font-weight: 500;
+      }
+    }
+  }
+}
+</style>

+ 1 - 31
pages/picking-task/delivery.vue

@@ -90,7 +90,7 @@
 					<view class="cargo-list-title-tips">(轻触货物查看详情)</view>
 				</view>
 				<block v-for="(item,i) in goodsList" :key="i">
-					<good-item :item="item" @toDetail="toDetail">
+					<good-item :item="item" @toDetail="toDetail" :show-print="true" @print="(e) => handlePrint(e.id)">
 						<view class="num-box" @click.stop="">
 							<view class="num-box-text">已确认出库数量</view>
 							<u-number-box v-model="item.materialNumber" min="0" :inputWidth="56">
@@ -103,11 +103,6 @@
 								</view> -->
 							</u-number-box>
 						</view>
-						<view class="action-btn-box">
-							<view class="print-btn" @click="handlePrint(item)">
-								打印条码
-							</view>
-						</view>
 					</good-item>
 				</block>
 			</view>
@@ -143,9 +138,6 @@
 	import successPop from '@/components/success-pop/success-pop.vue'
 	import scanedPop from '@/components/scaned-pop/scaned-pop.vue'
 	import goodsPop from '@/components/goods-pop/goods-pop.vue'
-	import printPop from '@/components/print-pop/print-pop.vue'
-	import blePop from '@/components/ble-pop/ble-pop.vue'
-	import bleTipPop from './components/ble-tip-pop.vue'
 	import {orderDetail, orderInfo, orderSubmit} from '@/common/request/apis/purchase'
 	import {mapGetters} from 'vuex'
 	import blePrintMixin from '@/common/mixins/blePrintMixin.js'
@@ -157,9 +149,6 @@
 			successPop,
 			scanedPop,
 			goodsPop,
-			printPop,
-			blePop,
-			bleTipPop
 		},
 		data() {
 			return {
@@ -354,14 +343,6 @@
 					url:`/pages/goods/detail?id=${val.id}&name=${val.materialName}`
 				})
 			},
-			//条码逻辑
-			handlePrint(item) {
-				this.openBlePrintPop(item)
-			},
-			//开始打印
-			startPrint(data){
-				this.writeData(data)
-			}
 		}
 	}
 </script>
@@ -591,15 +572,4 @@
 		}
 		
 	}
-	.action-btn-box{
-		text-align: right;
-		padding: 30rpx 48rpx 0 26rpx;
-		
-		.print-btn{
-			font-family: PingFang SC;
-			font-weight: 500;
-			font-size: 28rpx;
-			color: #0256FF;
-		}
-	}
 </style>

+ 9 - 1
pages/picking-task/detail.vue

@@ -102,7 +102,7 @@
 					<view class="cargo-list-title-tips">(轻触货物查看详情)</view>
 				</view>
 				<block v-for="(item,i) in goodsList" :key="i">
-					<good-item :item="item" @toDetail="toDetail">
+					<good-item :item="item" @toDetail="toDetail" :show-print="true" @print="(e) => handlePrint(e.id)">
 						<view class="num-box">
 							<view class="num-box-text">已确认出库数量</view>
 							<u-number-box v-model="item.actualQuantityInStorage" disabled>
@@ -119,7 +119,12 @@
 				</block>
 			</view>
 		</view>
+		<!-- 打印条码弹框 -->
+		<print-pop :show.sync="blePrintPop.show" :info="blePrintPop.data" @confirm="startPrint"></print-pop>
+		<!-- 选择蓝牙设备弹框 -->
+		<ble-pop :show.sync="bleSelectPop.show" :list="discoveredDevices" @close="closeBleSelectPop" @refresh="refreshBleDevice" @selectItem="handleSelectBle"></ble-pop>
 		
+		<ble-tip-pop v-model="bleErrorTipPop.show" :is-center="true" @confirm="bleErrorTipConfirm" :content="bleErrorTipPop.content" :extraText="bleErrorTipPop.extraText"> </ble-tip-pop>
 	</view>
 </template>
 
@@ -127,7 +132,9 @@
 	import goodItem from '@/components/good-item/good-item.vue'
 	import {orderDetail, orderInfo} from '@/common/request/apis/purchase'
 	import {mapGetters} from 'vuex'
+	import blePrintMixin from '@/common/mixins/blePrintMixin.js'
 	export default {
+		mixins: [blePrintMixin],
 		components: {
 			goodItem,
 		},
@@ -363,4 +370,5 @@
 			}
 		}
 	}
+	
 </style>

+ 9 - 1
pages/purchase/detail.vue

@@ -110,7 +110,7 @@
 					<view class="cargo-list-title-tips">(轻触货物查看详情)</view>
 				</view>
 				<block v-for="(item,i) in goodsList" :key="i">
-					<good-item :item="item" @toDetail="toDetail">
+					<good-item :item="item" @toDetail="toDetail" :show-print="true" @print="(e) => handlePrint(e.id)">
 						<view class="num-box">
 							<view class="num-box-text">已确认入库数量</view>
 							<u-number-box v-model="item.actualQuantityInStorage" disabled :inputWidth="56">
@@ -127,7 +127,12 @@
 				</block>
 			</view>
 		</view>
+		<!-- 打印条码弹框 -->
+		<print-pop :show.sync="blePrintPop.show" :info="blePrintPop.data" @confirm="startPrint"></print-pop>
+		<!-- 选择蓝牙设备弹框 -->
+		<ble-pop :show.sync="bleSelectPop.show" :list="discoveredDevices" @close="closeBleSelectPop" @refresh="refreshBleDevice" @selectItem="handleSelectBle"></ble-pop>
 		
+		<ble-tip-pop v-model="bleErrorTipPop.show" :is-center="true" @confirm="bleErrorTipConfirm" :content="bleErrorTipPop.content" :extraText="bleErrorTipPop.extraText"> </ble-tip-pop>
 	</view>
 </template>
 
@@ -135,7 +140,9 @@
 	import goodItem from '@/components/good-item/good-item.vue'
 	import {orderDetail, orderInfo} from '@/common/request/apis/purchase'
 	import {mapGetters} from 'vuex'
+	import blePrintMixin from '@/common/mixins/blePrintMixin.js'
 	export default {
+		mixins: [blePrintMixin],
 		components: {
 			goodItem,
 		},
@@ -177,6 +184,7 @@
 							}
 						})
 						this.goodsList = res.data.rows
+						console.log('this.goodsList==========',this.goodsList)
 					}
 				})
 			},

+ 10 - 1
pages/purchase/put-storage.vue

@@ -82,7 +82,7 @@
 					<view class="cargo-list-title-tips">(轻触货物查看详情)</view>
 				</view>
 				<block v-for="(item,i) in goodsList" :key="i">
-					<good-item :item="item" @toDetail="toDetail" @calendarClick="calendarClick">
+					<good-item :item="item" @toDetail="toDetail" @calendarClick="calendarClick" :show-print="true" @print="(e) => handlePrint(e.id)">
 						<view class="num-box">
 							<view class="num-box-text">已确认入库数量</view>
 							<u-number-box v-model="item.materialNumber" min="0" :inputWidth="56">
@@ -125,6 +125,13 @@
 			@confirm="calendarConfirm"
 			@cancel="calendarShow = false"
 		></u-datetime-picker>
+		
+		<!-- 打印条码弹框 -->
+		<print-pop :show.sync="blePrintPop.show" :info="blePrintPop.data" @confirm="startPrint"></print-pop>
+		<!-- 选择蓝牙设备弹框 -->
+		<ble-pop :show.sync="bleSelectPop.show" :list="discoveredDevices" @close="closeBleSelectPop" @refresh="refreshBleDevice" @selectItem="handleSelectBle"></ble-pop>
+		
+		<ble-tip-pop v-model="bleErrorTipPop.show" :is-center="true" @confirm="bleErrorTipConfirm" :content="bleErrorTipPop.content" :extraText="bleErrorTipPop.extraText"> </ble-tip-pop>
 	</view>
 </template>
 
@@ -136,7 +143,9 @@
 	import goodsPop from '@/components/goods-pop/goods-pop.vue'
 	import {orderDetail, orderInfo, orderSubmit} from '@/common/request/apis/purchase'
 	import {mapGetters} from 'vuex'
+	import blePrintMixin from '@/common/mixins/blePrintMixin.js'
 	export default {
+		mixins: [blePrintMixin],
 		components: {
 			goodItem,
 			errorPop,