You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

385 lines
14 KiB

3 days ago
  1. Vue.http.interceptors.push(function (request, next) {
  2. next(function (response) {
  3. if (response.body && response.body.code === 500) {
  4. var msg = response.body.message;
  5. if (msg === null) msg = "服务器错误";
  6. return vue.$toast(msg);
  7. }
  8. if (response.body.errorMsg) {
  9. return vue.$toast(response.body.errorMsg);
  10. }
  11. return response
  12. });
  13. });
  14. // 对Date的扩展,将 Date 转化为指定格式的String
  15. // 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符,
  16. // 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
  17. // 例子:
  18. // (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
  19. // (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18
  20. Date.prototype.Format = function (fmt) { //author: meizz
  21. var o = {
  22. "M+": this.getMonth() + 1, //月份
  23. "d+": this.getDate(), //日
  24. "h+": this.getHours(), //小时
  25. "m+": this.getMinutes(), //分
  26. "s+": this.getSeconds(), //秒
  27. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  28. "S": this.getMilliseconds() //毫秒
  29. };
  30. if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  31. for (var k in o)
  32. if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  33. return fmt;
  34. };
  35. var vue = new Vue({
  36. el: '#app',
  37. filters: {
  38. datetime: function (val) {
  39. if (val === null || val === "") return val;
  40. return new Date(val).Format("yyyy-MM-dd hh:mm:ss");
  41. },
  42. date: function (val) {
  43. if (val === null || val === "") return val;
  44. return new Date(val).Format("yyyy-MM-dd");
  45. },
  46. receivedType: function (val) {
  47. if (val === null) return "-";
  48. if (val === "R") return "Passed";
  49. if (val === "QS") return "不良品";
  50. return val;
  51. }
  52. },
  53. data: function () {
  54. return {
  55. rendering: true,
  56. selectedTab: window.selectedTab,
  57. receive: {
  58. screen: "default",
  59. search: {
  60. receiveNo: ""
  61. },
  62. summary: {
  63. id: "",
  64. receiveNo: "",
  65. orderNo: "",
  66. receivedDate: "",
  67. receivedBy: "",
  68. receivedType: ""
  69. },
  70. scan: {
  71. finalRollNo: "",
  72. rolls: []
  73. },
  74. add: {
  75. orderNo: ""
  76. }
  77. },
  78. shipment: {
  79. screen: "default",
  80. search: {
  81. shipNo: ""
  82. },
  83. summary: {
  84. shipNo: "",
  85. shippedDate: "",
  86. shippedBy: "",
  87. totalBoxes: 0,
  88. boxNo: "",
  89. boxId: ""
  90. },
  91. boxes: [],
  92. scan: {
  93. finalRollNo: "",
  94. rolls: []
  95. },
  96. print: {
  97. box: {}
  98. }
  99. },
  100. counting: {
  101. screen: "default",
  102. search: {
  103. countingNo: ""
  104. },
  105. summary: {
  106. countingNo: "",
  107. createdDate: "",
  108. createdBy: "",
  109. status: ""
  110. },
  111. scan: {
  112. info: "",
  113. actData: []
  114. }
  115. }
  116. };
  117. },
  118. methods: {
  119. logout: function () {
  120. document.getElementById("frmLogout").submit();
  121. },
  122. searchReceiveNo: function () {
  123. if (this.receive.search.receiveNo === "") {
  124. return vue.$toast("请输入入库单单号");
  125. }
  126. var self = this;
  127. return vue.$http.post("/mobile/receive/search/receiveNo", {
  128. "receiveNo": this.receive.search.receiveNo
  129. }, {"emulateJSON": true}).then(function (resp) {
  130. self.receive.summary = resp.body.result
  131. });
  132. },
  133. scanReceive: function () {
  134. var self = this;
  135. if (this.receive.summary.receiveNo === "") {
  136. return vue.$toast("请先查询入库单");
  137. }
  138. this.receive.screen = "scan";
  139. this.loadReceiveRolls();
  140. Vue.nextTick(function () {
  141. self.$refs.receiveScanFinalRollNoRef.focus();
  142. });
  143. },
  144. loadReceiveRolls: function () {
  145. var self = this;
  146. return vue.$http.post("/mobile/receive/rolls", {
  147. "receiveNo": this.receive.summary.receiveNo
  148. }, {"emulateJSON": true}).then(function (resp) {
  149. self.receive.scan.rolls = resp.body.result
  150. });
  151. },
  152. confirmScanFinalRollNo: function () {
  153. var self = this;
  154. if (self.receive.scan.finalRollNo === "") {
  155. return vue.$toast("请扫描小卷卷号");
  156. }
  157. vue.$http.post("/receive/scan/add", {
  158. "receiveId": self.receive.summary.id,
  159. "receiveNo": self.receive.summary.receiveNo,
  160. "type": "R", //良品R,不良品QS
  161. "finalRollNo": self.receive.scan.finalRollNo
  162. }, {"emulateJSON": true}).then(function (resp) {
  163. vue.$toast("扫描成功");
  164. self.loadReceiveRolls();
  165. });
  166. setTimeout(function () {
  167. self.receive.scan.finalRollNo = "";
  168. Vue.nextTick(function () {
  169. self.$refs.receiveScanFinalRollNoRef.focus();
  170. });
  171. }, 300);
  172. },
  173. enterAddReceiveScreen: function () {
  174. var self = this;
  175. self.receive.screen = 'add';
  176. Vue.nextTick(function () {
  177. self.$refs.receiveAddOrderNoRef.$refs.input.focus();
  178. });
  179. },
  180. confirmAddReceive: function () {
  181. var self = this;
  182. if (self.receive.add.orderNo === "") {
  183. return vue.$toast("请输入生产订单单号");
  184. }
  185. vue.$http.post("/receive/add", {
  186. "orderNo": self.receive.add.orderNo
  187. }, {"emulateJSON": true}).then(function (response) {
  188. self.receive.search.receiveNo = response.body.receiveNo;
  189. self.searchReceiveNo().then(function () {
  190. self.scanReceive();
  191. vue.$toast("新增成功");
  192. });
  193. });
  194. },
  195. searchShipment: function () {
  196. if (this.shipment.search.shipNo === "") {
  197. return vue.$toast("请输入出库单号");
  198. }
  199. var self = this;
  200. return vue.$http.post("/mobile/shipment/search/shipNo", {
  201. "shipNo": this.shipment.search.shipNo
  202. }, {"emulateJSON": true}).then(function (resp) {
  203. self.shipment.summary = resp.body.result.summary;
  204. self.shipment.summary.totalBoxes = resp.body.result.boxCount;
  205. });
  206. },
  207. enterShipmentBoxes: function () {
  208. if (this.shipment.summary.shipNo === "") {
  209. return vue.$toast("请先查询出库单");
  210. }
  211. var self = this;
  212. this.shipment.screen = 'box';
  213. vue.$http.post("/mobile/shipment/search/boxes", {
  214. "shipNo": this.shipment.search.shipNo
  215. }, {"emulateJSON": true}).then(function (resp) {
  216. self.shipment.boxes = resp.body.result;
  217. });
  218. },
  219. newShipmentBox: function () {
  220. var self = this;
  221. vue.$http.post("/shipment/boxes/add", {"shipNo": this.shipment.summary.shipNo}, {"emulateJSON": true}).then(function (resp) {
  222. self.enterShipmentBoxes();
  223. vue.$toast("新增成功");
  224. });
  225. },
  226. scanShipmentBox: function (boxNo, boxId) {
  227. var self = this;
  228. this.shipment.screen = 'scanBox';
  229. this.shipment.summary.boxNo = boxNo;
  230. this.shipment.summary.boxId = boxId;
  231. Vue.nextTick(function () {
  232. self.$refs.shipmentScanFinalRollNoRef.focus();
  233. });
  234. this.loadShipmentBoxRolls();
  235. },
  236. gotoPrintBox: function (boxNo) {
  237. var self = this;
  238. return vue.$http.post("/mobile/shipment/box/" + boxNo + "/print", {}, {"emulateJSON": true}).then(function (resp) {
  239. self.shipment.print = resp.body.result;
  240. self.shipment.screen = "print";
  241. });
  242. },
  243. loadShipmentBoxRolls: function () {
  244. var self = this;
  245. return vue.$http.post("/mobile/shipment/box/" + this.shipment.summary.boxNo + "/rolls", {}, {"emulateJSON": true}).then(function (resp) {
  246. self.shipment.scan.rolls = resp.body.result
  247. });
  248. },
  249. confirmScanBoxFinalRollNo: function () {
  250. var self = this;
  251. if (self.shipment.scan.finalRollNo === "") {
  252. return vue.$toast("请扫描小卷卷号");
  253. }
  254. vue.$http.post("/shipment/boxes/scan/add", {
  255. "boxNo": self.shipment.summary.boxNo,
  256. "finalRollNo": self.shipment.scan.finalRollNo
  257. }, {"emulateJSON": true}).then(function (resp) {
  258. vue.$toast("扫描成功");
  259. self.loadShipmentBoxRolls();
  260. });
  261. setTimeout(function () {
  262. self.shipment.scan.finalRollNo = "";
  263. Vue.nextTick(function () {
  264. self.$refs.shipmentScanFinalRollNoRef.focus();
  265. });
  266. }, 300);
  267. },
  268. finishScanShipmentBoxRoll: function () {
  269. var self = this;
  270. vue.$http.post("/shipment/boxes/finish", {
  271. "boxId": self.shipment.summary.boxId
  272. }, {"emulateJSON": true}).then(function (resp) {
  273. self.gotoPrintBox(self.shipment.summary.boxNo);
  274. vue.$toast("Successfully");
  275. });
  276. },
  277. confirmAddShipment: function () {
  278. var self = this;
  279. vue.$http.post("/shipment/add", {}, {"emulateJSON": true}).then(function (resp) {
  280. self.shipment.search.shipNo = resp.body.shipNo;
  281. self.searchShipment();
  282. vue.$toast("创建成功:" + resp.body.shipNo);
  283. });
  284. },
  285. searchCountingNo: function () {
  286. if (this.counting.search.countingNo === "") {
  287. return vue.$toast("请输入盘点单号");
  288. }
  289. var self = this;
  290. return vue.$http.post("/mobile/counting/search/countingNo", {
  291. "countingNo": this.counting.search.countingNo
  292. }, {"emulateJSON": true}).then(function (resp) {
  293. self.counting.summary = resp.body.result
  294. });
  295. },
  296. scanCounting: function () {
  297. var self = this;
  298. if (this.counting.summary.countingNo === "") {
  299. return vue.$toast("请先查询盘点单");
  300. }
  301. this.counting.screen = "scan";
  302. this.loadCountingActData();
  303. Vue.nextTick(function () {
  304. self.$refs.countingScanRef.focus();
  305. });
  306. },
  307. loadCountingActData: function () {
  308. var self = this;
  309. return vue.$http.post("/mobile/counting/act/" + this.counting.summary.countingNo, {}, {"emulateJSON": true}).then(function (resp) {
  310. self.counting.scan.actData = resp.body.result
  311. });
  312. },
  313. printBox: function () {
  314. var self = this;
  315. vue.$http.post("http://localhost:30002/print", {
  316. "print": JSON.stringify(self.shipment.print)
  317. }, {"emulateJSON": true}).then(function (resp) {
  318. vue.$toast("等待打印中,请稍候");
  319. }, function (errResp) {
  320. vue.$toast("等待打印中,请稍候");
  321. });
  322. },
  323. confirmCountingScan: function () {
  324. var self = this;
  325. if (self.counting.scan.info === "") {
  326. return vue.$toast("请扫描盘点信息");
  327. }
  328. vue.$http.post("/mobile/counting/scan/add", {
  329. "countingNo": this.counting.search.countingNo,
  330. "info": self.counting.scan.info
  331. }, {"emulateJSON": true}).then(function (resp) {
  332. self.loadCountingActData();
  333. vue.$toast("扫描成功");
  334. });
  335. setTimeout(function () {
  336. self.counting.scan.info = "";
  337. Vue.nextTick(function () {
  338. self.$refs.countingScanRef.focus();
  339. });
  340. }, 300);
  341. }
  342. },
  343. mounted: function () {
  344. var self = this;
  345. this.rendering = false;
  346. if (this.$refs.countingScanRef) {
  347. this.$refs.countingScanRef.addEventListener('input', function (evt) {
  348. self.counting.scan.info = self.counting.scan.info.toUpperCase();
  349. });
  350. }
  351. if (this.$refs.receiveNoRef) {
  352. this.$refs.receiveNoRef.$refs.input.addEventListener('input', function (evt) {
  353. self.receive.search.receiveNo = self.receive.search.receiveNo.toUpperCase();
  354. });
  355. this.$refs.receiveNoRef.$refs.input.addEventListener('focus', function (evt) {
  356. if (self.receive.search.receiveNo === "") {
  357. self.receive.search.receiveNo = "R";
  358. }
  359. });
  360. }
  361. if (this.$refs.shipNoRef) {
  362. this.$refs.shipNoRef.$refs.input.addEventListener('input', function (evt) {
  363. self.shipment.search.shipNo = self.shipment.search.shipNo.toUpperCase();
  364. });
  365. this.$refs.shipNoRef.$refs.input.addEventListener('focus', function (evt) {
  366. if (self.shipment.search.shipNo === "") {
  367. self.shipment.search.shipNo = "D";
  368. }
  369. });
  370. }
  371. }
  372. });