小小儁爺
2025-05-14 e4aa70e719eb1ee1bb4fb9886fec95d7b83e4f38
pages/wlgl/cgdh3.vue
@@ -315,32 +315,7 @@
            isDisabledSubmitButton: false,
            radioValue: '',
            purchorderArr: [
               // {
               //    partcode: 'MO-001',
               //    partname: '物料名称1',
               //    partspec: '#001',
               //    arrowType: false
               // },
               // {
               //    partcode: 'MO-002',
               //    partname: '物料名称1',
               //    partspec: '#001',
               //    arrowType: true
               // },
               // {
               //    partcode: 'MO-003',
               //    partname: '物料名称1',
               //    partspec: '#001',
               //    arrowType: true
               // },
               // {
               //    partcode: 'MO-004',
               //    partname: '物料名称1',
               //    partspec: '#001',
               //    arrowType: true
               // },
            ],
            purchorderArr: [],
            gfxxSheetShow: false,
            gfxxArr: [], //供方信息
@@ -411,27 +386,14 @@
            const res = await MesAppPurchOrderLabelBarCode(this.global.formatData(data))
            // this.labelArr = res.data
            // this.labelCount = 0
            // this.labelArr.map(i => i.labqty).forEach(i => {
            //    this.labelCount += parseFloat(i)
            // })
            this.purchorderArr.forEach(it => {
               if (it.partcode === partcode) {
                  it.labelArr = res.data
                  it.labelCount = 0
                  res.data.map(i => i.labqty).forEach(i => {
                     it.labelCount += parseFloat(i)
                  })
               }
               // else {
               //    it.labelArr = []
               //    it.labelCount = 0
               // }
            })
            console.log(this.purchorderArr, 88)
@@ -451,16 +413,6 @@
                  this.radioValue = item.partcode
               }
            })
            // const that = this
            // that.$nextTick(() => {
            //    console.log('11111')
            //    // setTimeout(() => {ss
            //    that.$forceUpdate()
            //    console.log('22222')
            //    // }, 1000)
            // })
         },
         // 获取供方信息下拉
         async getPurchSupplierSelect() {
@@ -548,15 +500,6 @@
         // 删除
         deleteLabel(number, val) {
            // VAL 父 item  val子it
            // this.labelArr = this.labelArr.filter(i => i.labcode !== val.labcode)
            // this.labelCount = 0
            // this.labelArr.map(i => i.labqty).forEach(i => {
            //    this.labelCount += parseFloat(i)
            // })
            console.log(number, val)
            this.purchorderArr[number].labelArr = this.purchorderArr[number].labelArr.filter(i => i.labcode !== val
               .labcode)
            this.purchorderArr[number].labelCount = 0
@@ -566,40 +509,16 @@
            })
            this.$forceUpdate()
         },
         // 提交
         async submit() {
            const data1 = {
               purordercode: this.cgdh,
               // orderstaus: this.labelCount + this.purchorderArr.find(i => i.partcode === this
               //    .radioValue).countarrivalquantity === this.purchorderArr.find(i => i.partcode === this
               //    .radioValue).quantity ? 'INARIVE' : 'BINARIVE', //单据状态:BINARIVE(部分到货)、INARIVE(已到货)
               username: uni.getStorageSync("username")
            }
            let submitData = JSON.parse(JSON.stringify(this.purchorderArr))
            // submitData = submitData.filter(i => parseFloat(i.labelCount))
            let data2 = []
            // [{
            //    "Inventory": {
            //       "Code": "81000241"
            //    },
            //    "Unit": {
            //       "Name": "箱"
            //    },
            //    "Quantity": 5,
            //    "OrigTaxAmount": 400,
            //    "OrigDiscountAmount": 400,
            //    "idsourcevouchertype": 27,
            //    "sourceVoucherCode": "PO-2021-09-0001",
            //    "sourceVoucherDetailId": 25
            // }]
            // let VoucherDetails = []
            submitData.forEach(i => {
               if (i.labelArr.length > 0) {
@@ -614,59 +533,15 @@
                     hpartcode: i.partcode,
                     hplanqty: i.quantity,
                     hqty: i.labelCount,
                     hsourceid: i.orderid,
                     hsourcesbid: i.sbid,
                     hischeck: i.is_incheck, //暂时写死
                     children: i.labelArr
                  })
                  // VoucherDetails.push({
                  //    "Inventory": {
                  //       "Code": i.partcode
                  //    },
                  //    "Unit": {
                  //       "Name": i.uomname
                  //    },
                  //    "Quantity": i.dhsl,
                  //    "OrigTaxPrice": 0,
                  //    "OrigTaxAmount": 0,
                  //    "idsourcevouchertype": 27,
                  //    "sourceVoucherCode": i.ordercode,
                  //    "sourceVoucherDetailId": i.sbid
                  // })
               }
            })
            // console.log('我是最先执行!')
            // this.isDisabledSubmitButton = true
            // const openToken = await this.global.getTPlusToken()
            // console.log(openToken)
            // console.log('我是最后执行!')
            // const headers = {
            //    'openToken': openToken,
            //    'appKey': Vue.prototype.$AppKey,
            //    'appSecret': Vue.prototype.$AppSecret,
            //    'Content-Type': 'application/json'
            // }
            // let DATA = {
            //    "dto": {
            //       "Code": this.cgdh,
            //       "IsModifiedCode": true,
            //       "VoucherDate": this.global.handleDatetime(new Date().getTime()),
            //       "ExternalCode": this.cgdh,
            //       "BusinessType": {
            //          "Code": "01"
            //       },
            //       "Partner": {
            //          "Code": this.purchorderArr[0].customercode
            //       },
            //       "Warehouse": {
            //          "Code": "03" //仓库目前传空
            //       },
            //       "VoucherDetails": VoucherDetails
            //    }
            // }
            this.isDisabledSubmitButton = true
            MesAppPurchOrderSave(this.global.formatData(
               data1), data2).then(res => {
@@ -698,68 +573,6 @@
               this.isDisabledSubmitButton = false
               this.$u.toast(res.Message)
            })
            // console.log(headers, DATA, 18)
            // await new Promise((resolve, reject) => {
            //    uni.request({
            //       url: Vue.prototype.$chanjetBaseUrl +
            //          '/tplus/api/v2/PurchaseArrivalOpenApi/Create',
            //       data: DATA,
            //       method: 'POST',
            //       header: headers,
            //       success: (r2) => {
            //          console.log(r2)
            //          if (r2.data.code === 0) {
            //             MesAppPurchOrderSave(this.global.formatData(
            //                data1), data2).then(res => {
            //                if (res.code === '200') {
            //                   submitData.forEach(i => {
            //                      if (i.labelArr.length > 0) {
            //                         i.labelArr.forEach(it => {
            //                            this.printWL(it
            //                               .labcode, res
            //                               .data,
            //                               i.partcode, i
            //                               .partname, i
            //                               .partspec ? i
            //                               .partspec :
            //                               '/', it
            //                               .labqty)
            //                         })
            //                      }
            //                   })
            //                   let prevPage = getCurrentPages()[getCurrentPages()
            //                      .length -
            //                      2]; // 上一页面实例
            //                   prevPage.$vm
            //                      .getMesAppPurchOrderSearch() // 调用上一页 定义的方法
            //                   uni.navigateBack({
            //                      delta: 1, //返回层数,2则上上页
            //                   })
            //                }
            //                this.$u.toast(res.Message)
            //                this.isDisabledSubmitButton = false
            //             })
            //          } else {
            //             this.$u.toast('接口报错,请联系开发人员!')
            //             this.isDisabledSubmitButton = false
            //          }
            //       },
            //       fail: (e) => {
            //          console.log(e, 7)
            //       }
            //    })
            // })
         },