From 2215dc01a8573c3df889e7d4025c36ff41070a32 Mon Sep 17 00:00:00 2001
From: chenhaozhe <cgz@hz-kingdee.com>
Date: 星期三, 03 九月 2025 17:00:10 +0800
Subject: [PATCH] 修改 通用打印条码 模块 生成条码为 通过后端获取唯一条码 调整获取打印模板 请求参数

---
 manifest.json                    |    4 
 pages/tiaomaguanli/table_son.vue |  190 +++++++++++++++++++++++------------------------
 2 files changed, 94 insertions(+), 100 deletions(-)

diff --git a/manifest.json b/manifest.json
index 29001e9..12656ff 100644
--- a/manifest.json
+++ b/manifest.json
@@ -2,8 +2,8 @@
     "name" : "鏅轰簯LMES",
     "appid" : "__UNI__B002F49",
     "description" : "",
-    "versionName" : "1.0.64",
-    "versionCode" : 164,
+    "versionName" : "1.0.65",
+    "versionCode" : 165,
     "transformPx" : false,
     /* 5+App鐗规湁鐩稿叧 */
     "app-plus" : {
diff --git a/pages/tiaomaguanli/table_son.vue b/pages/tiaomaguanli/table_son.vue
index 0ec9bf2..dd9082e 100644
--- a/pages/tiaomaguanli/table_son.vue
+++ b/pages/tiaomaguanli/table_son.vue
@@ -55,14 +55,14 @@
                 <!-- <button class="btn-c" size="mini" type="default" @tap="searchLabelPrinter()">鎼滅储鎵撳嵃鏈�</button> -->
                 <!-- :disabled="codeGenComplete == false" -->
                 <button :class="codeGenComplete == false? 'btn-a': 'btn-c'" size="mini" type="default"
-                  :disabled="codeGenComplete == false"  @tap="search">鎵撳嵃</button>
+                    :disabled="codeGenComplete == false" @tap="search">鎵撳嵃</button>
             </view>
         </view>
 
         <view style="width: 100%;height: 16rpx;background-color: #e5e5e5;"></view>
 
         <view class="list" v-for="(item,index) in listData" :key="index">
-            <uni-card :title="item.鐗╂枡浠g爜 || item.HMaterNumber" :extra="'No. ' + Number(index+1)" style="margin: 10px;">
+            <uni-card :title="item['鐗╂枡浠g爜']|| item.HMaterNumber" :extra="'No. ' + Number(index+1)" style="margin: 10px;">
                 <view class="card-detail">
                     <view class="detail">
                         <text>鐗╂枡鍚嶇О锛�</text>{{item.HMaterName || item['鐗╂枡鍚嶇О']}}
@@ -74,7 +74,7 @@
                         <text>鏁伴噺锛�</text>{{item.HQty || item['鏁伴噺']}}
                     </view>
                     <view class="detail" style="width: 100%;">
-                        <text>鏉$爜缂栧彿锛�</text>{{item.HBarCodeNo}}
+                        <text>鏉$爜缂栧彿锛�</text>{{item.HBarCodeNo || item['鏉$爜缂栧彿']}}
                     </view>
                 </view>
                 <!-- 				<view class="detail" style="text-align: right;" @tap.stop="labelPrint(item)"><text
@@ -159,12 +159,23 @@
                 baseInfo: {
                     HMainID: '',
                     HSubID: '',
-                    HBillNo: '',
+                    HSourceBillSEQ: null,
+                    HSourceBillNo: '',
                     HBillType: '',
                     HMaterID: '',
                     HMaterNumber: '',
                     HMaterName: '',
                     HMaterModel: '',
+                    HBillNo: '',
+                    "HModel": null,
+                    "HPinfan": null,
+                    "HPinfanBarCode": null,
+                    "HAuxPropID": null,
+                    "HAuxPropNumber": null,
+                    "HAuxPropName": null,
+                    HUnitID: '',
+                    "HUnitNumber": "",
+                    "HUnitName": "",
                     HQty: '',
                     HMinQty: '',
                     HSupID: '',
@@ -175,12 +186,10 @@
                     HSupID: '',
                     HSupNumber: '',
                     HSupName: '',
-                    HUnitID: '',
                     HPcsName: '',
                     HSupNameShort: '',
                     HMTONo: '',
                     HDate: '',
-                    HSourceBillNo: '',
                     HMaker: getUserInfo()["Czymc"],
                     HCoilNO: '',
                     HFurnaceNO: '',
@@ -273,7 +282,7 @@
                             this.baseInfo.HBQty = Math.ceil(this.baseInfo.HQty / this.baseInfo.HMinQty)
 
                             this.listData = data
-                            
+
                         } else {
                             uni.showToast({
                                 title: res.data.Message,
@@ -305,8 +314,8 @@
             getHMinQtyByBQty() {
                 if (this.baseInfo.HBQty && this.baseInfo.HBQty > 0) {
                     let minQty = Math.ceil(this.baseInfo.HQty / this.baseInfo.HBQty)
-                    
-                  
+
+
                     this.baseInfo.HMinQty = minQty
                     this.$forceUpdate()
                 } else {
@@ -324,103 +333,85 @@
                 //鑾峰彇閫夋嫨鐨勭粍缁�
                 var HOrgType = uni.getStorageSync('Organization');
                 //鑾峰彇閫夋嫨鐨勫伐鍘備唬鐮�
-                var CampanyName = "xxx";
+                // var CampanyName = uni.getStorageSync('Organization');
+                var CampanyName = "鍏磋揪鏉$爜";
                 //鑾峰彇閫夋嫨鐨勬簮鍗曠被鍨�
                 var HSourceBillType = "鏀舵枡閫氱煡鍗�";
                 //鑾峰彇閫夋嫨鐨勬潯鐮佺被鍨�
                 var HSelectBarCodeType = "鍞竴鏉$爜";
-                
-                if(uni.getStorageSync('Organization').includes('娴疯瘹')){
+
+                if (uni.getStorageSync('Organization').includes('娴疯瘹')) {
                     HSelectBarCodeType = "鍝佺鏉$爜";
                 }
                 //鑾峰彇褰撳墠鐧诲綍浜哄憳
                 var UserName = uni.getStorageSync('HUserName');
-                let listDataTemp = []
-                let i = 0
-                let barCodeTemplate = await this.getBarCodeTemplate()
-                for (let receiveQty = this.baseInfo.HQty; receiveQty > 0; receiveQty -= this.baseInfo.HMinQty) {
-                    i++
-                    let baseInfoClone = JSON.parse(JSON.stringify(this.baseInfo))
-                    let barCodeNo = ''
-                    if (receiveQty - this.baseInfo.HMinQty >= 0) {
-                        listDataTemp.push(Object.assign(baseInfoClone, {
-                            HQty: this.baseInfo.HMinQty,
-                            HInterID: receiveQty + 1,
-                            HBatchNo: this.baseInfo.HBatchNo,
-                            HMTONo: this.baseInfo.HMTONo,
-                        }))
-                    } else {
-                        listDataTemp.push(Object.assign(baseInfoClone, {
-                            HQty: receiveQty % this.baseInfo.HMinQty,
-                            HInterID: receiveQty + 1,
-                            HBatchNo: '',
-                            HMTONo: '',
-                        }))
-                    }
-                    
-                    barCodeNo = CommonUtils.replaceWithFunction(barCodeTemplate.Format, (key) => {
-                      // 鑷畾涔夊鐞嗛�昏緫
-                      let date = new Date()
-                      if (key === 'FlowNumber'){
-                          // 娴佹按鍙� 璁剧疆涓嶅悓鐨勬祦姘村彿鐢熸垚閫昏緫 TODO 閫氳繃鍚庣鑾峰彇娴佹按鍙�
-                          return `${date.getFullYear().toString()}${(date.getMonth() + 1).toString()}${date.getDate().toString()}${i.toString().padStart(3, '0')}`
-                      } 
-                      else {
-                          return baseInfoClone[key]
-                      }
-                      
-                    });     
-                    
-                    listDataTemp[listDataTemp.length - 1]['HBarCodeNo'] = barCodeNo
-                    HBarCodeNoStrs.push(
-                        barCodeNo
-                    )
+                // let listDataTemp = []
+                // let i = 0
+                // let barCodeTemplate = await this.getBarCodeTemplate()
+                // for (let receiveQty = this.baseInfo.HQty; receiveQty > 0; receiveQty -= this.baseInfo.HMinQty) {
+                //     i++
+                //     let baseInfoClone = JSON.parse(JSON.stringify(this.baseInfo))
+                //     let barCodeNo = ''
+                //     if (receiveQty - this.baseInfo.HMinQty >= 0) {
+                //         listDataTemp.push(Object.assign(baseInfoClone, {
+                //             HQty: this.baseInfo.HMinQty,
+                //             HInterID: receiveQty + 1,
+                //             HBatchNo: this.baseInfo.HBatchNo,
+                //             HMTONo: this.baseInfo.HMTONo,
+                //         }))
+                //     } else {
+                //         listDataTemp.push(Object.assign(baseInfoClone, {
+                //             HQty: receiveQty % this.baseInfo.HMinQty,
+                //             HInterID: receiveQty + 1,
+                //             HBatchNo: '',
+                //             HMTONo: '',
+                //         }))
+                //     }
 
-                }
-                console.log('listDataTemp: ',listDataTemp);
-                this.listData = listDataTemp
-                console.log(listDataTemp)
-                HBarCodeNoStrs = JSON.stringify(HBarCodeNoStrs)
-                sMain = listDataTemp
-                let sMainStr = JSON.stringify(listDataTemp)
+                //     barCodeNo = CommonUtils.replaceWithFunction(barCodeTemplate.Format, (key) => {
+                //       // 鑷畾涔夊鐞嗛�昏緫
+                //       let date = new Date()
+                //       if (key === 'FlowNumber'){
+                //           // 娴佹按鍙� 璁剧疆涓嶅悓鐨勬祦姘村彿鐢熸垚閫昏緫 TODO 閫氳繃鍚庣鑾峰彇娴佹按鍙�
+                //           return `${date.getFullYear().toString()}${(date.getMonth() + 1).toString()}${date.getDate().toString()}${i.toString().padStart(3, '0')}`
+                //       } 
+                //       else {
+                //           return baseInfoClone[key]
+                //       }
+
+                //     });     
+
+                //     listDataTemp[listDataTemp.length - 1]['HBarCodeNo'] = barCodeNo
+                //     HBarCodeNoStrs.push(
+                //         barCodeNo
+                //     )
+
+                // }
+                // console.log('listDataTemp: ',listDataTemp);
+                // this.listData = listDataTemp
+                // console.log(listDataTemp)
+                // HBarCodeNoStrs = JSON.stringify(HBarCodeNoStrs)
+                // sMain = listDataTemp
+                let sMainStr = JSON.stringify([this.baseInfo])
                 let sMainSub = `${sMainStr};${HOrgType};${HSourceBillType};${HSelectBarCodeType};${CampanyName};${UserName};${HBarCodeNoStrs};${this.baseInfo.HFactory || ''};${this
-                    .baseInfo.HCoilNO || ''}; ${this.baseInfo.HFurnaceNO || ''}` 
-                console.log('sMainSub: ',sMainSub);
+                    .baseInfo.HCoilNO || ''}; ${this.baseInfo.HFurnaceNO || ''}`
+                console.log('sMainSub: ', sMainSub);
                 uni.showLoading()
                 uni.request({
-                    url: this.serverUrl + '/Sc_BarCode/SaveBarCode_NoGenerate_Batch',
+                    url: this.serverUrl + '/Sc_BarCode/Sub_SaveBill',
                     method: 'POST',
                     data: {
                         msg: sMainSub,
-                        CampanyName: CampanyName
                     },
                     success: (res) => {
                         if (res.data.count == 1) {
-                            if(res.data.code == 2) {
-                                // 鏁版嵁宸插瓨鍦ㄧ殑鎯呭喌
-                                this.listData = Array.from(res.data.data).map(item => {
-                                      let baseInfoClone = JSON.parse(JSON.stringify(this.baseInfo))
-                                      return Object.assign(baseInfoClone, {
-                                          HQty: item['HQty'],
-                                          HBarCodeNo: item['HBarCode'],
-                                          HInterID: item['HInterID']
-                                      })
-                                })
-                                
-                                this.baseInfo.HBQty = res.data.data.length
-                                this.baseInfo.HMinQty = Math.ceil(this.baseInfo.HQty /  res.data.data.length)
-                                this.codeGenComplete = true
-                                uni.showToast({
-                                    title: res.data.Message,
-                                    icon: 'none'
-                                })
-                            }else {
-                                this.codeGenComplete = true
-                                uni.showToast({
-                                    title: res.data.Message,
-                                    icon: 'none'
-                                })
-                            }
+                            this.listData = res.data.data
+                            this.codeGenComplete = true
+                            uni.showToast({
+                                title: res.data.Message,
+                                icon: 'none'
+                            })
+
                         } else {
                             uni.showToast({
                                 title: res.data.Message,
@@ -449,13 +440,17 @@
                             HBillSubType: '1103'
                         },
                         resFunction: (res) => {
-                            let {data, count, Message} = res.data
-                            if(count == 1) {
+                            let {
+                                data,
+                                count,
+                                Message
+                            } = res.data
+                            if (count == 1) {
                                 resolve(JSON.parse(data))
-                            }else {
+                            } else {
                                 uni.showToast({
                                     icon: 'none',
-                                    title:Message
+                                    title: Message
                                 })
                                 reject()
                             }
@@ -500,7 +495,7 @@
                     let printInfoBuffer = []
                     let count = 0
                     uni.showLoading()
-                    console.log('this.listData: ',this.listData);
+                    console.log('this.listData: ', this.listData);
                     for (let listOne of this.listData) {
                         //                         let pcsInfo = this.baseInfo.HPcsName ? '(' + this.baseInfo.HPcsName + ')' : ''
                         //                         let HFurnaceNO = this.baseInfo.HFurnaceNO.split('.')
@@ -548,7 +543,7 @@
                         // T 55 0 440 370 (Spec. accepted) 
                         // FORM
                         // PRINT`)
-                        let Message = await this.getPrintTemplate(listOne.HInterID)
+                        let Message = await this.getPrintTemplate(listOne.HInterID, listOne.HItemID)
                         printContent.push(Message)
                         count++;
                         if (count == 10) {
@@ -567,17 +562,16 @@
                     })
                 }
             },
-            async getPrintTemplate(HInterID) {
+            async getPrintTemplate(HInterID,HItemID) {
                 return new Promise((resolve, reject) => {
                     CommonUtils.doRequest2({
                         url: "/Sc_BarCode/Get_BarCodePrintCode_CPCL",
                         data: {
                             HOrginationName: uni.getStorageSync("Organization"),
-                            HBillInterID: this.linterid,
-                            HBillEntryID: this.HEntryID,
                             HViewName: 'h_v_IF_POInStockBillList',
                             HBillSubType: '1103',
-                            HInterID: HInterID
+                            HInterID: HInterID,
+                            HItemID: HItemID,
                         },
                         resFunction: (res) => {
                             let {

--
Gitblit v1.9.1