瀏覽代碼

feat:出入库打印

maliang 2 周之前
父節點
當前提交
257e0eae6b

+ 105 - 44
common/mixins/blePrintMixin.js

@@ -153,13 +153,16 @@ export default {
         barCode: data.barCode, // 商品条码
         customerName: data.customerName, //客户名
         number: data.number, // 单据编号
+        batchNumber: data.batchNumber, // 单据编号
+        type: data.type, // 入库:1 出库;2
+        status: data.status, //  订单状态 入库状态为2才有批次号,出库不显示批次号
       };
       try {
         let cellWidth = 6;
         if (obj.qrCode.length > 30) cellWidth = 4;
         if (obj.qrCode.length > 60) cellWidth = 2;
 
-        const startX = 80;
+        const startX = 50;
         const startY = 30;
         const qrcodeX = startX;
         const qrcodeY = startY;
@@ -172,48 +175,101 @@ export default {
         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 }))
-          .qrcode(
-            new TQRCode({
-              x: qrcodeX,
-              y: qrcodeY,
-              content: obj.qrCode,
-              cellWidth,
-            })
-          )
-          .text(
-            new TText({
-              x: textStartX,
-              y: textStartY,
-              content: obj.customerName,
-              font: TFont.TSS24,
-            })
-          )
-          .text(
-            new TText({
-              x: textStartX,
-              y: textStartY + textLineHeight * 2,
-              content: obj.number,
-              font: TFont.TSS24,
-            })
-          )
-          .barcode(
-            new TBarCode({
-              x: barcodeX,
-              y: barcodeY,
-              cellWidth: 2,
-              height: barcodeHeight,
-              content: obj.barCode,
-              rotation: TRotation.ROTATION_0,
-              codeType: TCodeType.CODE128,
-              showType: 2,
-            })
-          )
-          .print(num);
+        console.log("obj==========", obj);
+        let tspl;
+        if (obj.type == 2) {
+          tspl = await vm.$printer
+            .tspl()
+            .clear()
+            .page(new TPage({ width: 76, height: 130 }))
+            .qrcode(
+              new TQRCode({
+                x: qrcodeX,
+                y: qrcodeY,
+                content: obj.qrCode,
+                cellWidth,
+              })
+            )
+            .text(
+              new TText({
+                x: textStartX,
+                y: textStartY,
+                content: obj.customerName,
+                font: TFont.TSS24,
+              })
+            )
+            .text(
+              new TText({
+                x: textStartX,
+                y: textStartY + textLineHeight * 2,
+                content: obj.number,
+                font: TFont.TSS24,
+              })
+            )
+            .barcode(
+              new TBarCode({
+                x: barcodeX,
+                y: barcodeY,
+                cellWidth: 2,
+                height: barcodeHeight,
+                content: `${obj.barCode}`,
+                rotation: TRotation.ROTATION_0,
+                codeType: TCodeType.CODE128,
+                showType: 2,
+              })
+            )
+            .print(num);
+        } else {
+          if (obj.status == 2) {
+            tspl = await vm.$printer
+              .tspl()
+              .clear()
+              .page(new TPage({ width: 76, height: 130 }))
+              .barcode(
+                new TBarCode({
+                  x: 50,
+                  y: 30,
+                  cellWidth: 2,
+                  height: 100,
+                  content: `${obj.barCode}`,
+                  rotation: TRotation.ROTATION_0,
+                  codeType: TCodeType.CODE128,
+                  showType: 2,
+                })
+              )
+              .barcode(
+                new TBarCode({
+                  x: 50,
+                  y: 30 + 100 + 50,
+                  cellWidth: 2,
+                  height: 50,
+                  content: `${obj.batchNumber}`,
+                  rotation: TRotation.ROTATION_0,
+                  codeType: TCodeType.CODE128,
+                  showType: 2,
+                })
+              )
+              .print(num);
+          } else {
+            tspl = await vm.$printer
+              .tspl()
+              .clear()
+              .page(new TPage({ width: 76, height: 130 }))
+              .barcode(
+                new TBarCode({
+                  x: 50,
+                  y: 30,
+                  cellWidth: 2,
+                  height: 100,
+                  content: `${obj.barCode}`,
+                  rotation: TRotation.ROTATION_0,
+                  codeType: TCodeType.CODE128,
+                  showType: 2,
+                })
+              )
+              .print(num);
+          }
+        }
         var binary = tspl.command().binary();
         await sendMessage(Array.from(uint8ArrayToSignedArray(binary)));
       } catch (e) {
@@ -228,7 +284,7 @@ export default {
       await this.writeTsplModel(data, num);
     },
     //条码逻辑
-    async handlePrint(id) {
+    async handlePrint(id, type, status) {
       try {
         uni.showLoading({
           mask: true,
@@ -236,11 +292,16 @@ export default {
         const res = await printMaterial({ id });
         console.log("item===id==", id);
         console.log("res=====", res);
+        console.log("type=====", type);
+        console.log("status=====", status);
         if (res.code == 200) {
           const data = {
             customerName: res.data.customerName,
             number: res.data.number,
             barCode: res.data.barCode,
+            batchNumber: res.data.batchNumber,
+            type,
+            status,
           };
           this.openBlePrintPop(data);
         } else {

+ 57 - 12
components/print-pop/print-pop.vue

@@ -9,7 +9,8 @@
       :closeOnClickOverlay="false"
     >
       <view class="pop-content">
-        <view class="pop-main">
+				<!-- 出库 -->
+        <view class="pop-main" v-if="info.type==2">
           <view class="flex_box flex-row-center pd-30">
             <view class="qr-code">
               <uqrcode
@@ -25,17 +26,52 @@
               <view class="item-value">{{ info.number }}</view>
             </view>
           </view>
-          <tki-barcode
-            ref="barcode"
+					<tki-barcode
             :show="showBarCode"
             :val="barcodeVal"
+						cid="sku-barcode1"
+            :opations="{
+              width: 1,
+              height: 100,
+              displayValue: true,
+              margin: 10,
+            }"
+          />
+          <view class="tips-value">请确认打印条码数量</view>
+          <view class="num-box">
+            <u-number-box
+              v-model="printNum"
+              :inputWidth="56"
+              :min="0"
+            ></u-number-box>
+          </view>
+        </view> 
+				<!-- 入库 -->
+				<view class="pop-main" v-if="info.type==1">
+					<!-- sku -->
+					<tki-barcode
+            :show="showBarCode"
+            :val="barcodeVal"
+						cid="sku-barcode"
+            :opations="{
+              width: 1,
+              height: 100,
+              displayValue: true,
+              margin: 10,
+            }"
+          />
+					<!-- 批次号(入库已完成) -->
+					<tki-barcode
+					  v-if="info.status==2"
+            :show="showBarCode"
+            :val="batchNumberVal"
+						cid="batch-barcode"
             :opations="{
               width: 1,
               height: 100,
               displayValue: true,
               margin: 10,
             }"
-            @result="getBarCodeImg"
           />
           <view class="tips-value">请确认打印条码数量</view>
           <view class="num-box">
@@ -82,18 +118,28 @@ export default {
       type: Boolean,
       default: false,
     },
+		/**
+		 * 入库显示条码号、批次号(显示:订单状态且为已入库)
+		 * 出库显示二维码(订单编号)、发货客户名称、发货商品sku
+    */ 
     info: {
       type: Object,
       default: () => ({
-        customerName: "",
-        number: "",
-        barCode: "",
+        customerName: "", // 客户名称
+        number: "", // 订单编号
+        barCode: "", // 商品条码
+				batchNumber: "", // 批次号
+				type: null, // 入库:1 出库;2
+        status: "", // 订单状态 入库状态为2才有批次号,出库不显示批次号
       }),
     },
   },
   computed: {
     barcodeVal() {
-      return this.info.barCode || "";
+      return this.info.barCode?`SKU-${this.info.barCode}`:"";
+    },
+    batchNumberVal() {
+      return this.info.batchNumber?`PC${this.info.batchNumber}`:"";
     },
   },
   data() {
@@ -120,15 +166,14 @@ export default {
           barCode: this.info.barCode, // 商品条码
           customerName: this.info.customerName, //客户名
           number: this.info.number, // 单据编号
+          batchNumber: this.info.batchNumber, // 批次号
+					type: this.info.type, // 入库:1 出库;2
+					status: this.info.status, // 订单状态 入库状态为2才有批次号,出库不显示批次号
         },
       };
       this.$emit("confirm", params);
       this.handleClose();
     },
-    getBarCodeImg(res) {
-      console.log("条形码图片", res);
-      this.$emit("barCodeImg", res);
-    },
   },
 };
 </script>

+ 12 - 12
pages/inventory-inquiry/index.vue

@@ -130,10 +130,10 @@ export default {
       treeData: [],
       treeData2: [],
       tabList: [
-				{
-				  value: "all",
-				  name: "全部",
-				},
+        {
+          value: "all",
+          name: "全部",
+        },
         {
           value: "have",
           name: "有库存",
@@ -156,7 +156,7 @@ export default {
       loadStatus: "loadmore", //加载前值为loadmore,加载中为loading,没有数据为nomore
       goodsList: [],
       pageSize: 10,
-      pageNum: 1,
+      currentPage: 1,
       queryParams: {
         type: "all",
         categoryId: "",
@@ -234,21 +234,21 @@ export default {
     },
     async loadData(isRefresh = false) {
       if (isRefresh) {
-        this.pageNum = 1;
+        this.currentPage = 1;
         this.goodsList = [];
       }
 
       try {
         this.loadStatus = "loading";
-        const pageNum = this.pageNum;
+        const currentPage = this.currentPage;
         const pageSize = this.pageSize;
         const params = {
-          pageNum,
-          pageSize,
           ...this.queryParams,
+					currentPage,
+					pageSize,
         };
         const res = await inventoryInquiry(params);
-				console.log("inventoryInquiry====", params);
+        console.log("inventoryInquiry====", params);
         console.log("res====", res);
         const { rows, total } = res.data;
         const list = rows.map((item) => {
@@ -261,8 +261,8 @@ export default {
           };
         });
         this.goodsList = [...this.goodsList, ...list];
-        if (pageNum * pageSize < Number(total)) {
-          this.pageNum++;
+        if (currentPage * pageSize < Number(total)) {
+          this.currentPage++;
           this.loadStatus = "loadmore";
         } else {
           this.loadStatus = "nomore";

+ 5 - 5
pages/inventory-task/detail.vue

@@ -268,7 +268,7 @@ export default {
         fontSize: "32rpx",
         borderRadius: "8rpx",
       },
-      pageNum: 1,
+      currentPage: 1,
       pageSize: 10,
       inventoryInfo: {},
       loadStatus: "loadmore", //加载前值为loadmore,加载中为loading,没有数据为nomore
@@ -358,7 +358,7 @@ export default {
     // 商品列表
     async getTaskStocktakingItemList(taskId) {
       try {
-        const pageNum = this.pageNum;
+        const currentPage = this.currentPage;
         const pageSize = this.pageSize;
         const params = {
           taskId,
@@ -377,8 +377,8 @@ export default {
         });
         console.log("rows======", rows);
         this.goodsList = [...this.goodsList, ...rows];
-        if (pageNum * pageSize < Number(total)) {
-          this.pageNum++;
+        if (currentPage * pageSize < Number(total)) {
+          this.currentPage++;
           this.loadStatus = "loadmore";
         } else {
           this.loadStatus = "nomore";
@@ -393,7 +393,7 @@ export default {
       } catch (error) {}
     },
     resetData() {
-      this.pageNum = 1;
+      this.currentPage = 1;
       this.goodsList = [];
     },
     async loadData(id, isRefresh = false) {

+ 37 - 27
pages/inventory-task/index.vue

@@ -36,9 +36,19 @@
             @btnClick="handleBtnClick"
           ></check-item>
         </view>
-				<u-empty mode="data" text="暂无内容" marginTop="60" icon="https://xiangli-erp.oss-cn-hangzhou.aliyuncs.com/APP/no-notifcations.png" v-if="list.length == 0"></u-empty>
+        <u-empty
+          mode="data"
+          text="暂无内容"
+          marginTop="60"
+          icon="https://xiangli-erp.oss-cn-hangzhou.aliyuncs.com/APP/no-notifcations.png"
+          v-if="list.length == 0"
+        ></u-empty>
         <!-- 加载更多 -->
-        <u-loadmore v-if="list.length > 0" :status="loadStatus" @loadmore="onLoadMore" />
+        <u-loadmore
+          v-if="list.length > 0"
+          :status="loadStatus"
+          @loadmore="onLoadMore"
+        />
       </view>
     </view>
 
@@ -79,7 +89,7 @@ export default {
         number: "",
         status: "",
       },
-      pageNum: 1,
+      currentPage: 1,
       pageSize: 10,
       loadStatus: "loadmore", //加载前值为loadmore,加载中为loading,没有数据为nomore
       list: [],
@@ -91,8 +101,8 @@ export default {
         submitActionFlag: false,
         errorText: "是否提交盘点?",
       },
-			startTaskId:null,
-			toStock:false,//是否跳转盘点
+      startTaskId: null,
+      toStock: false, //是否跳转盘点
     };
   },
   onLoad() {
@@ -102,13 +112,13 @@ export default {
     // 初始化数据
     this.loadData();
   },
-	onShow() {
-		if(this.startTaskId) {
-			let index = this.list.findIndex(item=>item.id == this.startTaskId)
-			this.list[index].taskStatus = 2
-			this.startTaskId = null
-		}
-	},
+  onShow() {
+    if (this.startTaskId) {
+      let index = this.list.findIndex((item) => item.id == this.startTaskId);
+      this.list[index].taskStatus = 2;
+      this.startTaskId = null;
+    }
+  },
   onPullDownRefresh() {
     // 下拉刷新
     this.onRefresh();
@@ -136,24 +146,24 @@ export default {
     },
     async loadData(isRefresh = false) {
       if (isRefresh) {
-        this.pageNum = 1;
+        this.currentPage = 1;
         this.list = [];
       }
 
       try {
         this.loadStatus = "loading";
-        const pageNum = this.pageNum;
+        const currentPage = this.currentPage;
         const pageSize = this.pageSize;
         const params = {
-          pageNum,
+          currentPage,
           pageSize,
           ...this.query,
         };
         const res = await taskStocktakingList(params);
         const { rows, total } = res.data;
         this.list = [...this.list, ...rows];
-        if (pageNum * pageSize < Number(total)) {
-          this.pageNum++;
+        if (currentPage * pageSize < Number(total)) {
+          this.currentPage++;
           this.loadStatus = "loadmore";
         } else {
           this.loadStatus = "nomore";
@@ -184,7 +194,7 @@ export default {
               uni.navigateTo({
                 url: `/pages/inventory-task/detail?id=${data.id}&pageType=1`,
               });
-							this.startTaskId = data.id
+              this.startTaskId = data.id;
             } else {
               uni.$u.toast(res.data);
             }
@@ -204,7 +214,7 @@ export default {
             } else {
               this.actionPop.errorText = "尚有货物未完成盘点,请先去盘点";
               this.actionPop.submitActionFlag = false;
-							this.toStock = true
+              this.toStock = true;
             }
           });
 
@@ -222,7 +232,7 @@ export default {
           this.resetErrorPopData();
           if (res.code === 200) {
             uni.$u.toast(res.msg);
-						this.actionPop.errorShow  = false
+            this.actionPop.errorShow = false;
             this.onRefresh();
           } else {
             uni.$u.toast(res.data);
@@ -230,13 +240,13 @@ export default {
         });
       } else {
         this.resetErrorPopData();
-				if(this.toStock) {
-					this.toStock = false
-					this.actionPop.errorShow = false
-					uni.navigateTo({
-					  url: `/pages/inventory-task/detail?id=${this.activeTaskId}&pageType=1`,
-					});
-				}
+        if (this.toStock) {
+          this.toStock = false;
+          this.actionPop.errorShow = false;
+          uni.navigateTo({
+            url: `/pages/inventory-task/detail?id=${this.activeTaskId}&pageType=1`,
+          });
+        }
       }
     },
   },

+ 3 - 1
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" :show-print="true" @print="(e) => handlePrint(e.id)">
+					<good-item :item="item" @toDetail="toDetail" :show-print="true" @print="(e) => handlePrint(e.id,'2',status)">
 						<view class="num-box" @click.stop="">
 							<view class="num-box-text">已确认出库数量</view>
 							<u-number-box v-model="item.materialNumber" min="0" :inputWidth="56" :max="item.inventory">
@@ -176,10 +176,12 @@
 				voucherPicture:'',
 				scanIndex:-1,
 				scanNum:1,
+				status: null
 			}
 		},
 		onLoad(e) {
 			this.id = e.id
+			this.status = e.status
 			this.getOrderDetail(e.id)
 			this.getOrderInfo(e.id)
 		},

+ 4 - 2
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" :show-print="true" @print="(e) => handlePrint(e.id)">
+					<good-item :item="item" @toDetail="toDetail" :show-print="true" @print="(e) => handlePrint(e.id,'2',status)">
 						<view class="num-box">
 							<view class="num-box-text">已确认出库数量</view>
 							<u-number-box v-model="item.actualQuantityInStorage" disabled  min="0" :inputWidth="56" :max="item.inventory">
@@ -144,10 +144,12 @@
 				successShow:false,
 				isUnfold: true, //是否展开
 				orderInfo: {},
-				goodsList: []
+				goodsList: [],
+				status: null
 			}
 		},
 		onLoad(e) {
+			this.status = e.status
 			this.getOrderInfo(e.id)
 			this.getOrderDetail(e.id)
 		},

+ 1 - 1
pages/picking-task/index.vue

@@ -145,7 +145,7 @@
 			},
 			init() {
 				uni.showLoading()
-				this.params.pageNum = 1
+				this.params.currentPage = 1
 				this.taskList = []
 				this.getSaleOrder()
 			},

+ 4 - 2
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" :show-print="true" @print="(e) => handlePrint(e.id)">
+					<good-item :item="item" @toDetail="toDetail" :show-print="true" @print="(e) => handlePrint(e.id,'1',status)">
 						<view class="num-box">
 							<view class="num-box-text">已确认入库数量</view>
 							<u-number-box v-model="item.actualQuantityInStorage" disabled :inputWidth="56">
@@ -153,10 +153,12 @@
 				value:0,
 				isUnfold: true, //是否展开
 				orderInfo: {},
-				goodsList: []
+				goodsList: [],
+				status: null
 			}
 		},
 		onLoad(e) {
+			this.status = e.status
 			this.getOrderInfo(e.id)
 			this.getOrderDetail(e.id)
 		},

+ 6 - 4
pages/purchase/index.vue

@@ -152,12 +152,12 @@
 				this.init()
 			},
 			// 点击操作
-			toOrderStartHandle(id) {
+			toOrderStartHandle(id,status) {
 				orderStartHandle(id)
 				.then(res=>{
 					if(res.code == 200) {
 						uni.navigateTo({
-							url:`/pages/purchase/put-storage?id=${id}`
+							url:`/pages/purchase/put-storage?id=${id}&status=${status}`
 						})
 					}
 				})
@@ -172,6 +172,7 @@
 				}
 			},
 			getPurchaseInventory() {
+				console.log('getPurchaseInventory======',this.params)
 				purchaseInventory(this.params)
 				.then(res=>{
 					if(res.code == 200) {
@@ -183,6 +184,7 @@
 							this.status = 'nomore'
 						}
 						this.taskList =[...this.taskList,...res.data.rows];
+						console.log('this.taskList=======',this.taskList)
 					}
 					uni.hideLoading()
 				})
@@ -234,11 +236,11 @@
 			},
 			// 入库
 			toStorage(val) {
-				this.toOrderStartHandle(val.id)
+				this.toOrderStartHandle(val.id,val.status)
 			},
 			toDetail(val) {
 				uni.navigateTo({
-					url:`/pages/purchase/detail?id=${val.id}`
+					url:`/pages/purchase/detail?id=${val.id}&status=${val.status}`
 				})
 			}
 		}

+ 5 - 3
pages/purchase/put-storage.vue

@@ -82,10 +82,10 @@
 					<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" :show-print="true" @print="(e) => handlePrint(e.id)">
+					<good-item :item="item" @toDetail="toDetail" @calendarClick="calendarClick" :show-print="true" @print="(e) => handlePrint(e.id,'1',status)">
 						<view class="num-box">
 							<view class="num-box-text">已确认入库数量</view>
-							<u-number-box v-model="item.materialNumber" min="0" :inputWidth="56" :max="item.inventory">
+							<u-number-box v-model="item.materialNumber" min="0" :inputWidth="56">
 								<!-- <view slot="minus" class="minus">
 									<u-icon name="minus" color="#0256FF" size="12"></u-icon>
 								</view>
@@ -179,11 +179,13 @@
 				voucherPicture:'',
 				scanIndex:-1,
 				scanNum:1,
+				status:null
 			}
 		},
 		onLoad(e) {
 			
 			this.id = e.id
+			this.status = e.status
 			this.getOrderDetail(e.id)
 			this.getOrderInfo(e.id)
 		},
@@ -302,7 +304,7 @@
 			toOrderSubmit() {
 				let materials = this.goodsList.map(item=> {
 					return {
-						batchNumber:item.batchNumber,
+						barCode:item.barCode,
 						materialNumber:item.materialNumber,
 						productionDate:item.productionDate ? this.$u.timeFormat(item.productionDate, 'yyyy-mm-dd') : ''
 					}