н¨Îļþ¼Ð/PDA/pages/stash/outFinish.vue
@@ -16,8 +16,14 @@
                  </uni-forms-item>
                  <uni-forms-item :label="order_qty">
                  </uni-forms-item>
                  <uni-forms-item label="待扫物料编码:">
                  <uni-easyinput type="text" placeholder="请扫描物料编码" ref='materialInput'
                     :focus="step === 1" v-model="materialCode"
                     @confirm="materialCodeInput"
                     @blur="materialCodeInput" />
                  </uni-forms-item>
                  <uni-forms-item label="库位编号:">
                     <uni-easyinput type="text" placeholder="请扫描库位编号" ref='midInput' :focus="!focus"
                     <uni-easyinput type="text" placeholder="请扫描库位编号" ref='midInput' :focus="focus"
                        v-model="barcode" @confirm="barcodeInput" />
                  </uni-forms-item>
                  <!-- <uni-forms-item label="出库数量:">
@@ -37,7 +43,7 @@
                     <view style="display: flex;justify-content: space-around;margin-top: 2%;">
                        <!-- <button @click="reset" type="default" size="default"
                           style="width: 160rpx;border: 1rpx solid #007aff;color: #007aff;">重置</button> -->
                        <button @click="submit" type="primary" size="default" style="width: 200rpx;">确认出库</button>
                        <button @click="submit" type="primary" size="default" style="width: 250rpx;">确认出库</button>
                     </view>
                  </uni-forms-item>
               </uni-forms>
@@ -126,385 +132,541 @@
</template>
<script>
   const innerAudioContext = uni.createInnerAudioContext();
   export default {
      data() {
         return {
            items: ['出库'], //, '解盘''组盘', , '单据信息'
            current: 0,
            taskId:"",
            matTotal: [],
            matInfos: [],
            orderNo: "",
            batchNo:"",
            orderqty:"",
            Inqty:"",
            goods_no:"",
            batch_num:"",
            order_qty:"",
            order_Inqty:"",
            label: "",
            orderInfo: [],
            focus: false,
            pkfocus: false,
            barcode: "",
            materSn: "",
            Initiallife: 1000,
            sns: [],
            pksns: [],
            addressFocus: false,
            inboundBarcode: "",
            address: "",
            check: true,
            value: "",
            matInfo: [],
            value2: "",
            matTotals: [],
            warehouseId: "",
            Test: false,
            Testlabel: "",
            Testplaceholder: "",
            Testcheck: false,
            pkmaterSn: "",
            pkmatInfos: [],
            addressdisabled: false
         }
      },
      onShow() {},
      onLoad(res) {
         this.focus = false;
         this.addressFocus = false;
         this.orderNo = res.orderNo;
         this.taskId=res.taskId;
         this.Inqty=res.order_Inqty;
         this.orderqty=res.order_qty;
         this.batchNo=res.batchNo;
         this.warehouseId = res.warehouseId;
         this.label = "单据编号:" + this.orderNo;
         this.batch_num="批次号:"+res.batchNo;
         this.order_qty="出库数量:"+res.stockQuantity;
         this.order_Inqty="物料名称:"+res.materielName;
         this.goods_no="物料编号:"+res.materielCode;
         // this.getData();
      },
      methods: {
         // voiceSpeech(src) {
         //    innerAudioContext.src = src; // '../../static/success.mp3';
         //    innerAudioContext.play();
         // },
         updateFocus() {
            debugger
            this.$nextTick(() => {
               this.materSn = '';
               if (!this.focus) {
                  this.focus = true;
               }
            });
         },
         barcodeFocus() {
            debugger
            this.barcode = '';
            if (this.focus) {
               this.focus = false;
            }
         },
         getData() {
            var postData = {
               MainData: {
                  orderNo: this.orderNo
               },
            }
            this.$u.post('/api/InboundOrderDetail/GetInboundOrderDetails', postData).then((res) => {
               if (res.status) {
                  this.orderInfo = res.data;
                  if (this.orderInfo.length > 3) {
                     this.loadVisible = true;
                  }
               }
            })
         },
         onClickItem(e) {
            this.focus = false;
            this.addressFocus = false;
            if (this.current !== e.currentIndex) {
               this.current = e.currentIndex;
               if (this.current == 2) {
                  this.getData();
               }
            }
         },
         barcodeInput() {
            this.$nextTick(function(x) {
               if (this.barcode.length > 0) {
                  // if (this.barcode.substring(0, 1) == 'A' || this.barcode.substring(0, 2) == 'TP') {
                  this.focus = true;
                  // } else {
                  //    this.$refs.uToast.show({
                  //       title: "扫码错误,请扫描托盘码",
                  //       type: "error"
                  //    })
                  // }
               }
            })
         },
         snInput() {
            this.$nextTick(() => {
               if (this.materSn != "") {
                  this.focus = false;
                  var matSn = this.materSn;
                  if (this.warehouseId == 11) {
                     matSn = matSn.replace(/,SC.*/, '');
                  }
                  //查询matSn是否存在字符
                  if(matSn.indexOf("POHA")>0){
                     this.$u.post('/api/MaterielInfo/CodeAnalysis?serNum=' + matSn, {}).then((res) => {
                        this.Testcheck = false;
                        if (res.status) {
                           this.sns.push(res.data.serialNumber);
                           this.matInfos.push(res.data);
                           if (res.message) {
                              this.$refs.uToast.show({
                                 title: res.message,
                                 type: "error"
                              })
                              // setTimeout(() => {
                              //    this.voiceSpeech('../../static/fail.mp3');
                              // }, 100);
                              return;
                           }
                           // setTimeout(() => {
                           //    this.voiceSpeech('../../static/success.mp3');
                           // }, 100);
                        } else {
                           this.$refs.uToast.show({
                              title: res.message,
                              type: "error"
                           })
                           // setTimeout(() => {
                           //    this.voiceSpeech('../../static/fail.mp3');
                           // }, 100);
                        }
                     })
                  }
                  setTimeout(() => {
                     this.materSn = "";
                  }, 100);
               }
            })
         },
         pksnInput() {
            this.$nextTick(() => {
               if (this.pkmaterSn != "") {
                  var matSn = this.pkmaterSn;
                  if(matSn.indexOf("POHA")>0){
                     this.$u.post('/api/MaterielInfo/CodeAnalysis?serNum=' + matSn, {}).then((res) => {
                        if (res.status) {
                           this.pksns.push(res.data.serialNumber);
                           this.pkmatInfos.push(res.data);
                           if (!res.status) {
                              this.$refs.uToast.show({
                                 title: res.message,
                                 type: "error"
                              })
                              // setTimeout(() => {
                              //    this.voiceSpeech('../../static/fail.mp3');
                              // }, 100);
                              return;
                           }
                           // setTimeout(() => {
                           //    this.voiceSpeech('../../static/success.mp3');
                           // }, 100);
                           return;
                        } else {
                           this.$refs.uToast.show({
                              title: res.message,
                              type: "error"
                           })
                           // setTimeout(() => {
                           //    this.voiceSpeech('../../static/fail.mp3');
                           // }, 100);
                        }
                     })
                  }
                  setTimeout(() => {
                     this.pkmaterSn = "";
                  }, 100);
               }
            })
         },
         inbound() {
            if (this.inboundBarcode == "") {
               this.$refs.uToast.show({
                  title: "请扫描托盘条码",
                  type: "error"
               })
               return;
            }
            if (this.address == "") {
               this.$refs.uToast.show({
                  title: "请扫描地址条码",
                  type: "error"
               })
               return;
            }
            var postData = {
               MainData: {
                  "barcode": this.inboundBarcode,
                  "startPoint": this.address,
                  "warehouseId": this.warehouseId
               }
            }
            this.$u.post('/api/Task/RequestInboundTask', postData).then(res => {
               if (res.status) {
                  this.inboundBarcode = "";
                  if (this.warehouseId != 5) this.address = "";
                  setTimeout(() => {
                     this.addressFocus = false;
                     this.$refs.uToast.show({
                        title: "成功",
                        type: "success"
                     })
                  }, 200);
               } else {
                  this.$refs.uToast.show({
                     title: res.message,
                     type: "error"
                  })
               }
            }).catch(err => {
               this.$refs.uToast.show({
                  title: err.message,
                  type: "error"
               })
            })
         },
         inputChangebarcode() {
            this.addressFocus = false;
            this.$nextTick(function(x) {
               if (this.inboundBarcode != '') {
                  this.addressFocus = true;
               }
            })
         },
         deleteList(res) {
            this.matInfos.splice(res, 1);
            this.sns.splice(res, 1);
         },
         pkdeleteList(res) {
            this.pkmatInfos.splice(res, 1);
            this.pksns.splice(res, 1);
         },
         reset() {
            this.barcode = "";
            this.matInfos = [];
            this.sns = [];
            this.materSn = "";
            if (this.warehouseId = !6) {
               this.Initiallife = 0;
            }
         },
         resetInPk() {
            this.pkmaterSn = "";
            this.pkfocus = false;
            this.pkmatInfos = [];
            this.pksns = [];
         },
         pksubmit() {
            if (this.pkmatInfos.length == 0) {
               this.$refs.uToast.show({
                  title: "请扫描内箱标签",
                  type: 'error'
               })
               return;
            }
            this.$u.post('/api/DeliveryOrder/FeedbackOut?warehouseId=' + this.warehouseId + "&orderNo=" + this.orderNo, this
               .pksns).then(res => {
               if (res.status) {
                  this.$refs.uToast.show({
                     title: "出库成功",
                     type: "success"
                  })
                  this.pkfocus = false;
                  this.pkmatInfos = [];
                  this.pksns = [];
               } else {
                  this.$refs.uToast.show({
                     title: res.message,
                     type: "error"
                  })
               }
            })
         },
         submit() {
            if (this.barcode == "") {
               this.$refs.uToast.show({
                  title: "请扫描货位编号",
                  type: 'error'
               })
               return;
            }
            // if (this.materSn.length == 0) {
            //    this.$refs.uToast.show({
            //       title: "请输入出库数量",
            //       type: 'error'
            //    })
            //    return;
            // }
            this.$u.post('/api/DeliveryOrder/OutFinish', {
               MainData: {
                  "locationCode": this.barcode,
                  "taskId":this.taskId,
                  // "warehouseCode": this.warehouseId,
                  // "orderNo": this.orderNo,
                  // "Inqty": this.materSn,
                  // "batchNo": this.batchNo,
               },
               // DelKeys: this.sns
            }).then(res => {
               this.Testcheck = false;
               if (res.status) {
                  this.$refs.uToast.show({
                     title: "出库成功",
                     type: "success"
                  })
                  this.Inqty=res.message;
                  // this.order_Inqty="已出库数量:"+this.Inqty;
                  this.barcode="";
                  // this.materSn="";
               } else {
                  this.$refs.uToast.show({
                     title: res.message,
                     type: "error"
                  })
               }
            })
         }
      }
   }
const innerAudioContext = uni.createInnerAudioContext();
export default {
  data() {
    return {
      items: ["出库"], //, '解盘''组盘', , '单据信息'
      current: 0,
      taskId: "",
      matTotal: [],
      matInfos: [],
      orderNo: "",
      batchNo: "",
      orderqty: "",
      Inqty: "",
      goods_no: "",
      batch_num: "",
      order_qty: "",
      order_Inqty: "",
      label: "",
      orderInfo: [],
      focus: false,
      pkfocus: false,
      barcode: "",
      materSn: "",
      Initiallife: 1000,
      sns: [],
      pksns: [],
      addressFocus: false,
      inboundBarcode: "",
      address: "",
      check: true,
      value: "",
      matInfo: [],
      value2: "",
      matTotals: [],
      warehouseId: "",
      Test: false,
      Testlabel: "",
      Testplaceholder: "",
      Testcheck: false,
      pkmaterSn: "",
      pkmatInfos: [],
      addressdisabled: false,
      materialCode: "", // æ–°å¢žï¼šæ‰«æçš„物料编码
      materialCodeValid: false, // æ–°å¢žï¼šç‰©æ–™ç¼–码验证状态
      step: 1, // æ–°å¢žï¼š1-物料编码,2-库位编号,
    };
  },
  onShow() {},
  onLoad(res) {
    this.focus = false;
    this.addressFocus = false;
    this.orderNo = res.orderNo;
    this.taskId = res.taskId;
    this.Inqty = res.order_Inqty;
    this.orderqty = res.order_qty;
    this.batchNo = res.batchNo;
    this.warehouseId = res.warehouseId;
    this.label = "单据编号:" + this.orderNo;
    this.batch_num = "批次号:" + res.batchNo;
    this.order_qty = "出库数量:" + res.stockQuantity;
    this.order_Inqty = "物料名称:" + res.materielName;
    this.goods_no = "物料编号:" + res.materielCode;
    this.materielCode = res.materielCode; // è®¾ç½®ç”¨äºŽéªŒè¯çš„物料编码
    // this.getData();
  },
  methods: {
    // voiceSpeech(src) {
    //    innerAudioContext.src = src; // '../../static/success.mp3';
    //    innerAudioContext.play();
    // },
    // ç‰©æ–™ç¼–码验证
    materialCodeInput() {
      console.log("materialCodeInput è¢«è§¦å‘");
      console.log("输入值:", this.materialCode);
      this.$nextTick(() => {
        if (this.materialCode.trim() !== "") {
          const scannedCode = this.materialCode.trim();
          const expectedCode = this.materielCode;
          console.log("扫描编码:", scannedCode);
          console.log("期望编码(materielCode):", expectedCode);
          if (scannedCode === expectedCode) {
            this.materialCodeValid = true;
            console.log("✅ ç‰©æ–™ç¼–码验证成功");
            this.step = 2;
            this.$refs.uToast.show({
              title: "物料编码验证成功",
              type: "success",
            });
            this.$nextTick(() => {
              this.$refs.midInput.focus();
            });
          } else {
            this.materialCodeValid = false;
            console.log("❌ ç‰©æ–™ç¼–码验证失败");
            this.$refs.uToast.show({
              title: `物料编码不匹配`,
              type: "error",
            });
            setTimeout(() => {
              this.materialCode = "";
              this.step = 1;
              this.$nextTick(() => {
                this.$refs.materialInput.focus();
              });
            }, 500);
          }
        }
      });
    },
    updateFocus() {
      debugger;
      this.$nextTick(() => {
        this.materSn = "";
        if (!this.focus) {
          this.focus = true;
        }
      });
    },
    barcodeFocus() {
      debugger;
      this.barcode = "";
      if (this.focus) {
        this.focus = false;
      }
    },
    getData() {
      var postData = {
        MainData: {
          orderNo: this.orderNo,
        },
      };
      this.$u
        .post("/api/InboundOrderDetail/GetInboundOrderDetails", postData)
        .then((res) => {
          if (res.status) {
            this.orderInfo = res.data;
            if (this.orderInfo.length > 3) {
              this.loadVisible = true;
            }
          }
        });
    },
    onClickItem(e) {
      this.focus = false;
      this.addressFocus = false;
      if (this.current !== e.currentIndex) {
        this.current = e.currentIndex;
        if (this.current == 2) {
          this.getData();
        }
      }
    },
    // barcodeInput() {
    //   this.$nextTick(function (x) {
    //     if (this.barcode.length > 0) {
    //       // if (this.barcode.substring(0, 1) == 'A' || this.barcode.substring(0, 2) == 'TP') {
    //       this.focus = true;
    //       // } else {
    //       //    this.$refs.uToast.show({
    //       //       title: "扫码错误,请扫描托盘码",
    //       //       type: "error"
    //       //    })
    //       // }
    //     }
    //   });
    // },
    barcodeInput() {
      this.$nextTick(() => {
        if (this.barcode.length > 0) {
          this.$refs.uToast.show({
            title: "库位编号扫描成功",
            type: "success",
          });
          setTimeout(() => {
            this.$nextTick(() => {
              this.$refs.midInput.focus();
            });
          }, 100);
        }
      });
    },
    snInput() {
      this.$nextTick(() => {
        if (this.materSn != "") {
          this.focus = false;
          var matSn = this.materSn;
          if (this.warehouseId == 11) {
            matSn = matSn.replace(/,SC.*/, "");
          }
          //查询matSn是否存在字符
          if (matSn.indexOf("POHA") > 0) {
            this.$u
              .post("/api/MaterielInfo/CodeAnalysis?serNum=" + matSn, {})
              .then((res) => {
                this.Testcheck = false;
                if (res.status) {
                  this.sns.push(res.data.serialNumber);
                  this.matInfos.push(res.data);
                  if (res.message) {
                    this.$refs.uToast.show({
                      title: res.message,
                      type: "error",
                    });
                    // setTimeout(() => {
                    //    this.voiceSpeech('../../static/fail.mp3');
                    // }, 100);
                    return;
                  }
                  // setTimeout(() => {
                  //    this.voiceSpeech('../../static/success.mp3');
                  // }, 100);
                } else {
                  this.$refs.uToast.show({
                    title: res.message,
                    type: "error",
                  });
                  // setTimeout(() => {
                  //    this.voiceSpeech('../../static/fail.mp3');
                  // }, 100);
                }
              });
          }
          setTimeout(() => {
            this.materSn = "";
          }, 100);
        }
      });
    },
    pksnInput() {
      this.$nextTick(() => {
        if (this.pkmaterSn != "") {
          var matSn = this.pkmaterSn;
          if (matSn.indexOf("POHA") > 0) {
            this.$u
              .post("/api/MaterielInfo/CodeAnalysis?serNum=" + matSn, {})
              .then((res) => {
                if (res.status) {
                  this.pksns.push(res.data.serialNumber);
                  this.pkmatInfos.push(res.data);
                  if (!res.status) {
                    this.$refs.uToast.show({
                      title: res.message,
                      type: "error",
                    });
                    // setTimeout(() => {
                    //    this.voiceSpeech('../../static/fail.mp3');
                    // }, 100);
                    return;
                  }
                  // setTimeout(() => {
                  //    this.voiceSpeech('../../static/success.mp3');
                  // }, 100);
                  return;
                } else {
                  this.$refs.uToast.show({
                    title: res.message,
                    type: "error",
                  });
                  // setTimeout(() => {
                  //    this.voiceSpeech('../../static/fail.mp3');
                  // }, 100);
                }
              });
          }
          setTimeout(() => {
            this.pkmaterSn = "";
          }, 100);
        }
      });
    },
    inbound() {
      if (this.inboundBarcode == "") {
        this.$refs.uToast.show({
          title: "请扫描托盘条码",
          type: "error",
        });
        return;
      }
      if (this.address == "") {
        this.$refs.uToast.show({
          title: "请扫描地址条码",
          type: "error",
        });
        return;
      }
      var postData = {
        MainData: {
          barcode: this.inboundBarcode,
          startPoint: this.address,
          warehouseId: this.warehouseId,
        },
      };
      this.$u
        .post("/api/Task/RequestInboundTask", postData)
        .then((res) => {
          if (res.status) {
            this.inboundBarcode = "";
            if (this.warehouseId != 5) this.address = "";
            setTimeout(() => {
              this.addressFocus = false;
              this.$refs.uToast.show({
                title: "成功",
                type: "success",
              });
            }, 200);
          } else {
            this.$refs.uToast.show({
              title: res.message,
              type: "error",
            });
          }
        })
        .catch((err) => {
          this.$refs.uToast.show({
            title: err.message,
            type: "error",
          });
        });
    },
    inputChangebarcode() {
      this.addressFocus = false;
      this.$nextTick(function (x) {
        if (this.inboundBarcode != "") {
          this.addressFocus = true;
        }
      });
    },
    deleteList(res) {
      this.matInfos.splice(res, 1);
      this.sns.splice(res, 1);
    },
    pkdeleteList(res) {
      this.pkmatInfos.splice(res, 1);
      this.pksns.splice(res, 1);
    },
    reset() {
      this.barcode = "";
      this.matInfos = [];
      this.sns = [];
      this.materSn = "";
      if ((this.warehouseId = !6)) {
        this.Initiallife = 0;
      }
    },
    resetInPk() {
      this.pkmaterSn = "";
      this.pkfocus = false;
      this.pkmatInfos = [];
      this.pksns = [];
    },
    pksubmit() {
      if (this.pkmatInfos.length == 0) {
        this.$refs.uToast.show({
          title: "请扫描内箱标签",
          type: "error",
        });
        return;
      }
      this.$u
        .post(
          "/api/DeliveryOrder/FeedbackOut?warehouseId=" +
            this.warehouseId +
            "&orderNo=" +
            this.orderNo,
          this.pksns
        )
        .then((res) => {
          if (res.status) {
            this.$refs.uToast.show({
              title: "出库成功",
              type: "success",
            });
            this.pkfocus = false;
            this.pkmatInfos = [];
            this.pksns = [];
          } else {
            this.$refs.uToast.show({
              title: res.message,
              type: "error",
            });
          }
        });
    },
    //    submit() {
    //          if (this.barcode == "") {
    //             this.$refs.uToast.show({
    //             title: "请扫描货位编号",
    //             type: 'error'
    //             })
    //             return;
    //          }
    //   this.$u.post('/api/DeliveryOrder/OutFinish', {
    //     MainData: {
    //       "locationCode": this.barcode,
    //       "taskId": this.taskId,
    //     },
    //   }).then(res => {
    //     if (res.status) {
    //       this.$refs.uToast.show({
    //         title: "出库成功",
    //         type: "success"
    //       })
    //       this.barcode = "";
    //       // å…³é”®ä¿®æ”¹ï¼šä½¿ç”¨ getCurrentPages èŽ·å–å‰ä¸€ä¸ªé¡µé¢å¹¶ç›´æŽ¥è°ƒç”¨å…¶æ–¹æ³•
    //       const pages = getCurrentPages();
    //       const prevPage = pages[pages.length - 2]; // èŽ·å–ä¸Šä¸€ä¸ªé¡µé¢å®žä¾‹
    //       if (prevPage && prevPage.refreshData) {
    //         // ç›´æŽ¥è°ƒç”¨ä¸Šä¸€ä¸ªé¡µé¢çš„刷新方法
    //         prevPage.refreshData();
    //       }
    //       setTimeout(() => {
    //         uni.navigateBack({
    //           delta: 1
    //         });
    //       }, 300);
    //     } else {
    //       this.$refs.uToast.show({
    //         title: res.message,
    //         type: "error"
    //       })
    //     }
    //   })
    // }
    submit() {
      if (!this.materialCodeValid) {
        this.$refs.uToast.show({
          title: "请先扫描并验证物料编码",
          type: "error",
        });
        return;
      }
      if (this.barcode == "") {
        this.$refs.uToast.show({
          title: "请扫描货位编号",
          type: "error",
        });
        return;
      }
      // æ–°å¢žäºŒæ¬¡ç¡®è®¤é€»è¾‘
      uni.showModal({
        title: "确认出库",
        content: "您确定要提交出库信息吗?",
        success: (res) => {
          if (res.confirm) {
            // æ˜¾ç¤ºåŠ è½½ä¸­
            uni.showLoading({
              title: '提交中...',
              mask: true
            });
            this.$u.post("/api/DeliveryOrder/OutFinish", {
              MainData: {
                locationCode: this.barcode,
                taskId: this.taskId,
              },
            }).then((res) => {
              uni.hideLoading();
              if (res.status) {
                this.$refs.uToast.show({
                  title: "出库成功",
                  type: "success",
                });
                // æ¸…空输入框
                this.barcode = "";
                this.materialCode = "";
                this.materialCodeValid = false;
                // è®¾ç½®åˆ·æ–°æ ‡è®°
                uni.setStorageSync('needRefreshOutbound', true);
                // å»¶è¿Ÿè¿”回
                setTimeout(() => {
                  uni.navigateBack({
                    delta: 1
                  });
                }, 500);
              } else {
                this.$refs.uToast.show({
                  title: res.message || "出库失败",
                  type: "error",
                });
              }
            }).catch(err => {
              uni.hideLoading();
              this.$refs.uToast.show({
                title: "请求失败,请重试",
                type: "error",
              });
            });
          }
        },
      });
    }
  },
};
</script>
<style lang="scss">
   @import '@/common/uni-ui.scss';
@import "@/common/uni-ui.scss";
   .content {
      display: flex;
      height: 150px;
   }
.content {
  display: flex;
  height: 150px;
}
   .content-text {
      font-size: 14px;
      color: #666;
   }
.content-text {
  font-size: 14px;
  color: #666;
}
   .itemstyle {
      margin-top: 30px;
      margin-left: 5%;
   }
.itemstyle {
  margin-top: 30px;
  margin-left: 5%;
}
   .headerstyle {
      width: 90%;
   }
.headerstyle {
  width: 90%;
}
</style>