var vm = new Vue({ el: '#app', data: function () { return { // 加载状态 isLoading: false, // 用户信息 userInfo: { loginGuid: '', loginAccount: '', }, // 库位相关 sectionCode: "", // 库位编码 depotData: { // 仓库数据 depotName: "", depotCode: "" }, // 表单数据 formData: { barcode: "", // 物料条码 itemNo: "", // 物料编码 itemName: "", // 物料名称 itemModel: "", // 物料规格 sumQuantity: 0, // 已入总数 quantity: 0, // 到货单数量 cbillNo: "", // 到货单号 paperBillNo:"", // 到货单号 +送货单号 dhdQty: 0, // 到货单数量 tmsyQty: 0 // 剩余未扫条码张数 }, // 标签页数据 - 剩余未扫 unscannedList: [], // 标签页数据 - 剩余未扫(其他物料汇总) otherUnscannedList: [], // 标签页数据 - 到货单扫码进度 scanProgressList: [] } }, mounted() { var that = this; // 获取登录信息 this.userInfo = { loginGuid: this.GetLoginInfor().loginGuid, loginAccount: this.GetLoginInfor().loginAccount, }; }, methods: { /** * 获取库位信息 * 触发时机:扫描库位编码后按回车键 */ getModel() { var that = this; that.$refs.barcode.focus(); }, /** * 扫描物料条码入库 * 触发时机:扫描物料条码后按回车键 */ getScan() { var that = this; // 输入验证 if (!that.formData.barcode || that.formData.barcode.trim() === "") { that.$toast.fail("物料条码不能为空!"); that.$playSound('error'); that.$refs.barcode.focus(); return; } // if (!that.sectionCode || that.sectionCode.trim() === "") { // that.$toast.fail("库位编码不能为空!"); // that.$playSound('error'); // that.$refs.sectionCode.focus(); // return; // } that.isLoading = true; that.AxiosHttp("post", 'MesInvItemInCDetails/WcsmBar', { sectionCode: that.sectionCode.trim(), userName: that.userInfo.loginAccount, barcode: that.formData.barcode.trim(), }, false) .then(function (res) { var json = res; if (json.status == 0) { // 清空条码输入框 var dab001 = that.formData.barcode that.formData.barcode = ""; // 重新聚焦到条码输入框(支持连续扫码) that.$refs.barcode.focus(); // 提示成功 that.$notify({ type: 'success', message: json.message || '扫描成功' }); that.$playSound('success'); //根据条码获取信息 that.selectByBarcode(dab001); } else { // 失败处理 that.$toast.fail(json.message || "扫描失败!"); that.$playSound('error'); // 清空条码输入框 that.formData.barcode = ""; // 重新聚焦到条码输入框 that.$refs.barcode.focus(); } that.isLoading = false; }) .catch(function (error) { // 异常处理 that.isLoading = false; that.$toast.fail("网络错误,请重试!"); that.$playSound('error'); console.error("getScan error:", error); // 清空条码输入框 that.formData.barcode = ""; // 重新聚焦到条码输入框 that.$refs.barcode.focus(); }); }, /** * 清除库位编码 */ clearSectionCode() { this.sectionCode = ""; this.depotData = { depotName: "", depotCode: "" }; this.$refs.sectionCode.focus(); }, /// /// 根据条码查询相关信息 /// selectByBarcode(dab001) { var that = this; if (!dab001 || dab001.length <= 0) { that.$toast.fail("条码不能为空!"); that.$playSound('error'); that.$refs.barcode.focus(); return; } that.isLoading = true; that.AxiosHttp("post", 'MesInvItemInCDetails/WcsmDetail', { barcode: dab001 }, false) .then(function (res) { var json = res; if (json.status == 0) { // 标签页数据赋值 that.unscannedList = json.data.tbBillList.unscannedList; that.otherUnscannedList = json.data.tbBillList.otherUnscannedList; that.scanProgressList = json.data.tbBillList.scanProgressList; // 表单数据赋值(从daaInfo获取) var daaInfo = json.data.tbBillList.daaInfo; if (daaInfo && daaInfo.length > 0) { var info = daaInfo[0]; that.formData.itemNo = info.itemNo || ''; // 物料编码 that.formData.itemName = info.itemName || ''; // 物料编码 that.formData.itemModel = info.itemModel || ''; // 物料编码 that.formData.cbillNo = info.cbillNo || ''; // 到货单号 that.formData.paperBillNo = info.paperBillNo || ''; // 到货单号+送货单号 that.formData.quantity = info.quantity || 0; // 当前条码数量 that.formData.dhdQty = info.dhdQty || 0; // 到货单数量 that.formData.sumQuantity = info.sumQuantity || 0; // 已入总数 that.formData.tmsyQty = info.tmsyQty || 0; // 剩余未扫条码张数 } that.$refs.barcode.focus(); } else { that.$toast.fail(json.message); that.$playSound('error'); that.$refs.barcode.focus(); } that.isLoading = false; }) .catch(function (error) { that.isLoading = false; that.$toast.fail("网络错误,请重试!"); that.$playSound('error'); }); }, /** * 返回上一页 */ GoBack() { window.history.back(); } } });