Vue.http.interceptors.push(function (request, next) { next(function (response) { if (response.body && response.body.code === 500) { var msg = response.body.message; if (msg === null) msg = "服务器错误"; return vue.$toast(msg); } if (response.body.errorMsg) { return vue.$toast(response.body.errorMsg); } return response }); }); // 对Date的扩展,将 Date 转化为指定格式的String // 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符, // 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字) // 例子: // (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423 // (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18 Date.prototype.Format = function (fmt) { //author: meizz var o = { "M+": this.getMonth() + 1, //月份 "d+": this.getDate(), //日 "h+": this.getHours(), //小时 "m+": this.getMinutes(), //分 "s+": this.getSeconds(), //秒 "q+": Math.floor((this.getMonth() + 3) / 3), //季度 "S": this.getMilliseconds() //毫秒 }; if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); for (var k in o) if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); return fmt; }; var vue = new Vue({ el: '#app', filters: { datetime: function (val) { if (val === null || val === "") return val; return new Date(val).Format("yyyy-MM-dd hh:mm:ss"); }, date: function (val) { if (val === null || val === "") return val; return new Date(val).Format("yyyy-MM-dd"); }, receivedType: function (val) { if (val === null) return "-"; if (val === "R") return "Passed"; if (val === "QS") return "不良品"; return val; } }, data: function () { return { rendering: true, selectedTab: window.selectedTab, receive: { screen: "default", search: { receiveNo: "" }, summary: { id: "", receiveNo: "", orderNo: "", receivedDate: "", receivedBy: "", receivedType: "" }, scan: { finalRollNo: "", rolls: [] }, add: { orderNo: "" } }, shipment: { screen: "default", search: { shipNo: "" }, summary: { shipNo: "", shippedDate: "", shippedBy: "", totalBoxes: 0, boxNo: "", boxId: "" }, boxes: [], scan: { finalRollNo: "", rolls: [] }, print: { box: {} } }, counting: { screen: "default", search: { countingNo: "" }, summary: { countingNo: "", createdDate: "", createdBy: "", status: "" }, scan: { info: "", actData: [] } } }; }, methods: { logout: function () { document.getElementById("frmLogout").submit(); }, searchReceiveNo: function () { if (this.receive.search.receiveNo === "") { return vue.$toast("请输入入库单单号"); } var self = this; return vue.$http.post("/mobile/receive/search/receiveNo", { "receiveNo": this.receive.search.receiveNo }, {"emulateJSON": true}).then(function (resp) { self.receive.summary = resp.body.result }); }, scanReceive: function () { var self = this; if (this.receive.summary.receiveNo === "") { return vue.$toast("请先查询入库单"); } this.receive.screen = "scan"; this.loadReceiveRolls(); Vue.nextTick(function () { self.$refs.receiveScanFinalRollNoRef.focus(); }); }, loadReceiveRolls: function () { var self = this; return vue.$http.post("/mobile/receive/rolls", { "receiveNo": this.receive.summary.receiveNo }, {"emulateJSON": true}).then(function (resp) { self.receive.scan.rolls = resp.body.result }); }, confirmScanFinalRollNo: function () { var self = this; if (self.receive.scan.finalRollNo === "") { return vue.$toast("请扫描小卷卷号"); } vue.$http.post("/receive/scan/add", { "receiveId": self.receive.summary.id, "receiveNo": self.receive.summary.receiveNo, "type": "R", //良品R,不良品QS "finalRollNo": self.receive.scan.finalRollNo }, {"emulateJSON": true}).then(function (resp) { vue.$toast("扫描成功"); self.loadReceiveRolls(); }); setTimeout(function () { self.receive.scan.finalRollNo = ""; Vue.nextTick(function () { self.$refs.receiveScanFinalRollNoRef.focus(); }); }, 300); }, enterAddReceiveScreen: function () { var self = this; self.receive.screen = 'add'; Vue.nextTick(function () { self.$refs.receiveAddOrderNoRef.$refs.input.focus(); }); }, confirmAddReceive: function () { var self = this; if (self.receive.add.orderNo === "") { return vue.$toast("请输入生产订单单号"); } vue.$http.post("/receive/add", { "orderNo": self.receive.add.orderNo }, {"emulateJSON": true}).then(function (response) { self.receive.search.receiveNo = response.body.receiveNo; self.searchReceiveNo().then(function () { self.scanReceive(); vue.$toast("新增成功"); }); }); }, searchShipment: function () { if (this.shipment.search.shipNo === "") { return vue.$toast("请输入出库单号"); } var self = this; return vue.$http.post("/mobile/shipment/search/shipNo", { "shipNo": this.shipment.search.shipNo }, {"emulateJSON": true}).then(function (resp) { self.shipment.summary = resp.body.result.summary; self.shipment.summary.totalBoxes = resp.body.result.boxCount; }); }, enterShipmentBoxes: function () { if (this.shipment.summary.shipNo === "") { return vue.$toast("请先查询出库单"); } var self = this; this.shipment.screen = 'box'; vue.$http.post("/mobile/shipment/search/boxes", { "shipNo": this.shipment.search.shipNo }, {"emulateJSON": true}).then(function (resp) { self.shipment.boxes = resp.body.result; }); }, newShipmentBox: function () { var self = this; vue.$http.post("/shipment/boxes/add", {"shipNo": this.shipment.summary.shipNo}, {"emulateJSON": true}).then(function (resp) { self.enterShipmentBoxes(); vue.$toast("新增成功"); }); }, scanShipmentBox: function (boxNo, boxId) { var self = this; this.shipment.screen = 'scanBox'; this.shipment.summary.boxNo = boxNo; this.shipment.summary.boxId = boxId; Vue.nextTick(function () { self.$refs.shipmentScanFinalRollNoRef.focus(); }); this.loadShipmentBoxRolls(); }, gotoPrintBox: function (boxNo) { var self = this; return vue.$http.post("/mobile/shipment/box/" + boxNo + "/print", {}, {"emulateJSON": true}).then(function (resp) { self.shipment.print = resp.body.result; self.shipment.screen = "print"; }); }, loadShipmentBoxRolls: function () { var self = this; return vue.$http.post("/mobile/shipment/box/" + this.shipment.summary.boxNo + "/rolls", {}, {"emulateJSON": true}).then(function (resp) { self.shipment.scan.rolls = resp.body.result }); }, confirmScanBoxFinalRollNo: function () { var self = this; if (self.shipment.scan.finalRollNo === "") { return vue.$toast("请扫描小卷卷号"); } vue.$http.post("/shipment/boxes/scan/add", { "boxNo": self.shipment.summary.boxNo, "finalRollNo": self.shipment.scan.finalRollNo }, {"emulateJSON": true}).then(function (resp) { vue.$toast("扫描成功"); self.loadShipmentBoxRolls(); }); setTimeout(function () { self.shipment.scan.finalRollNo = ""; Vue.nextTick(function () { self.$refs.shipmentScanFinalRollNoRef.focus(); }); }, 300); }, finishScanShipmentBoxRoll: function () { var self = this; vue.$http.post("/shipment/boxes/finish", { "boxId": self.shipment.summary.boxId }, {"emulateJSON": true}).then(function (resp) { self.gotoPrintBox(self.shipment.summary.boxNo); vue.$toast("Successfully"); }); }, confirmAddShipment: function () { var self = this; vue.$http.post("/shipment/add", {}, {"emulateJSON": true}).then(function (resp) { self.shipment.search.shipNo = resp.body.shipNo; self.searchShipment(); vue.$toast("创建成功:" + resp.body.shipNo); }); }, searchCountingNo: function () { if (this.counting.search.countingNo === "") { return vue.$toast("请输入盘点单号"); } var self = this; return vue.$http.post("/mobile/counting/search/countingNo", { "countingNo": this.counting.search.countingNo }, {"emulateJSON": true}).then(function (resp) { self.counting.summary = resp.body.result }); }, scanCounting: function () { var self = this; if (this.counting.summary.countingNo === "") { return vue.$toast("请先查询盘点单"); } this.counting.screen = "scan"; this.loadCountingActData(); Vue.nextTick(function () { self.$refs.countingScanRef.focus(); }); }, loadCountingActData: function () { var self = this; return vue.$http.post("/mobile/counting/act/" + this.counting.summary.countingNo, {}, {"emulateJSON": true}).then(function (resp) { self.counting.scan.actData = resp.body.result }); }, printBox: function () { var self = this; vue.$http.post("http://localhost:30002/print", { "print": JSON.stringify(self.shipment.print) }, {"emulateJSON": true}).then(function (resp) { vue.$toast("等待打印中,请稍候"); }, function (errResp) { vue.$toast("等待打印中,请稍候"); }); }, confirmCountingScan: function () { var self = this; if (self.counting.scan.info === "") { return vue.$toast("请扫描盘点信息"); } vue.$http.post("/mobile/counting/scan/add", { "countingNo": this.counting.search.countingNo, "info": self.counting.scan.info }, {"emulateJSON": true}).then(function (resp) { self.loadCountingActData(); vue.$toast("扫描成功"); }); setTimeout(function () { self.counting.scan.info = ""; Vue.nextTick(function () { self.$refs.countingScanRef.focus(); }); }, 300); } }, mounted: function () { var self = this; this.rendering = false; if (this.$refs.countingScanRef) { this.$refs.countingScanRef.addEventListener('input', function (evt) { self.counting.scan.info = self.counting.scan.info.toUpperCase(); }); } if (this.$refs.receiveNoRef) { this.$refs.receiveNoRef.$refs.input.addEventListener('input', function (evt) { self.receive.search.receiveNo = self.receive.search.receiveNo.toUpperCase(); }); this.$refs.receiveNoRef.$refs.input.addEventListener('focus', function (evt) { if (self.receive.search.receiveNo === "") { self.receive.search.receiveNo = "R"; } }); } if (this.$refs.shipNoRef) { this.$refs.shipNoRef.$refs.input.addEventListener('input', function (evt) { self.shipment.search.shipNo = self.shipment.search.shipNo.toUpperCase(); }); this.$refs.shipNoRef.$refs.input.addEventListener('focus', function (evt) { if (self.shipment.search.shipNo === "") { self.shipment.search.shipNo = "D"; } }); } } });