修改 通用打印条码 模块 生成条码为 通过后端获取唯一条码 调整获取打印模板 请求参数
2个文件已修改
160 ■■■■ 已修改文件
manifest.json 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/tiaomaguanli/table_son.vue 156 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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" : {
pages/tiaomaguanli/table_son.vue
@@ -62,7 +62,7 @@
        <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.物料代码 || item.HMaterNumber" :extra="'No. ' + Number(index+1)" style="margin: 10px;">
            <uni-card :title="item['物料代码']|| 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: '',
@@ -324,7 +333,8 @@
                //获取选择的组织
                var HOrgType = uni.getStorageSync('Organization');
                //获取选择的工厂代码
                var CampanyName = "xxx";
                // var CampanyName = uni.getStorageSync('Organization');
                var CampanyName = "兴达条码";
                //获取选择的源单类型
                var HSourceBillType = "收料通知单";
                //获取选择的条码类型
@@ -335,92 +345,73 @@
                }
                //获取当前登录人员
                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: '',
                        }))
                    }
                // 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]
                      }
                //     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
                    )
                //     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(listDataTemp)
                // }
                // 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);
                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.listData = res.data.data
                            this.codeGenComplete = true
                            uni.showToast({
                                title: res.data.Message,
                                icon: 'none'
                                })
                                
                                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'
                                })
                            }
                        } else {
                            uni.showToast({
                                title: res.data.Message,
@@ -449,7 +440,11 @@
                            HBillSubType: '1103'
                        },
                        resFunction: (res) => {
                            let {data, count, Message} = res.data
                            let {
                                data,
                                count,
                                Message
                            } = res.data
                            if(count == 1) {
                                resolve(JSON.parse(data))
                            }else {
@@ -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 {