var vm = new Vue({ el: '#app', data: function () { return { isLoading: false, modeInfo: { deptSectionCode: "", rkDate: "" }, // 入库日期默认空 scanInfo: { barcode: "", itemNo: "", itemName: "", itemModel: "", depotCode: "", depotName: "", sectionCode: "", sectionName: "", oldqty: "", quantity: "" }, barInfoList: [], selectKW: "", tbKWInfo: [], tbItemInfo: [], actions: [], show: false, zkChecked: false, showDatePicker: false, tempDate: new Date(), // 日期选择器默认今天 itemNo: { barCode: "", itemNo: "" }, // 入库日期默认空 } }, mounted() { var that = this; this.userInfo = { loginGuid: this.GetLoginInfor().loginGuid, loginAccount: this.GetLoginInfor().loginAccount, }; }, watch: { showDatePicker(val) { if (val) { // 弹窗打开时,重置为当天 this.tempDate = new Date(); } } }, methods: { formatDate(date) { const d = new Date(date); console.log(d); return `${d.getFullYear()}-${(d.getMonth() + 1).toString().padStart(2, '0')}-${d.getDate().toString().padStart(2, '0')}`; }, onDateConfirm(date) { this.modeInfo.rkDate = this.formatDate(date); this.showDatePicker = false; this.getBarInfoListModel(); }, getBarInfoListModel() { var that = this; that.isLoading = true; that.AxiosHttp("post", 'MesKwcx/GetBarInfoList', { deptSectionCode: that.modeInfo.deptSectionCode, rkDate: that.modeInfo.rkDate, zkChecked: that.zkChecked }, false) .then(function (res) { var json = res; if (json.status == 0) { that.barInfoList = json.data.tbBarInfoList; } else { that.barInfoList = []; that.modeInfo.deptSectionCode = ''; that.$toast.fail(json.message); that.$playSound('error'); } that.isLoading = false; }) .catch(function () { that.isLoading = false; that.$toast.fail("网络错误,请重试!"); that.$playSound('error'); }); }, getScan() { var that = this; that.isLoading = true; that.AxiosHttp("post", 'MesKwcx/GetBarInfo', { barcode: that.scanInfo.barcode }, false) .then(function (res) { var json = res; if (json.status == 0) { Object.assign(that.scanInfo, json.data.tbBarInfo); } else { that.scanInfo.barcode = ''; that.$toast.fail(json.message); that.$playSound('error'); } that.isLoading = false; }) .catch(function () { that.isLoading = false; that.$toast.fail("网络错误,请重试!"); that.$playSound('error'); }); }, getKWInfo() { var that = this; that.show = true; that.actions = []; that.isLoading = true; that.AxiosHttp("post", 'MesKwcx/GetKWList', { selectKW: that.selectKW }, false) .then(function (res) { var json = res; if (json.status == 0 && json.data.tbKWList.length > 0) { that.actions = json.data.tbKWList.map(item => ({ name: item.code })); } else { that.$toast.fail("没有可用的数据"); that.$playSound('error'); } that.isLoading = false; }) .catch(function () { that.isLoading = false; that.$toast.fail("网络错误,请重试!"); that.$playSound('error'); }); }, onSelect(item) { var that = this; that.show = false; that.isLoading = true; that.selectKW = item.name; that.AxiosHttp("post", 'MesKwcx/GetKWInfo', { code: item.name }, false) .then(function (res) { var json = res; if (json.status == 0) { that.tbKWInfo = json.data.tbKWInfo; } else { that.tbKWInfo = []; that.$toast.fail(json.message); that.$playSound('error'); } that.isLoading = false; }) .catch(function () { that.isLoading = false; that.$toast.fail("网络错误,请重试!"); that.$playSound('error'); }); }, getItemInfoListModel() { var that = this; that.isLoading = true; that.AxiosHttp("post", 'MesKwcx/GetItemInfoList', { barCode: that.itemNo.barCode, itemNo: that.itemNo.itemNo }, false) .then(function (res) { var json = res; if (json.status == 0) { that.tbItemInfo = json.data.tbItemInfo; } else { that.tbItemInfo = []; that.itemNo.barCode = ''; that.itemNo.itemNo = ''; that.$toast.fail(json.message); that.$playSound('error'); } that.isLoading = false; }) .catch(function () { that.isLoading = false; that.$toast.fail("网络错误,请重试!"); //that.$playSound('error'); }); }, } });