| | |
| | | import http from '@/api/http.js'; |
| | | import VolBox from '@/components/basic/VolBox.vue'; |
| | | |
| | | // 鲿彿°ä¿æä¸å |
| | | // 鲿彿° |
| | | function debounce(func, wait) { |
| | | let timeout; |
| | | return function () { |
| | |
| | | trigger: 'change' |
| | | } |
| | | ] |
| | | } |
| | | }, |
| | | |
| | | // æ°å¢ï¼é®çäºä»¶ç嬿 è®° |
| | | keyPressListenerAdded: false, |
| | | isDialogClosing: false |
| | | } |
| | | }, |
| | | |
| | |
| | | }, |
| | | |
| | | watch: { |
| | | // çå¬showåéåå |
| | | show(newVal) { |
| | | if (newVal === true) { |
| | | console.log('å¼¹æ¡æå¼ï¼éç½®æ°æ®'); |
| | | this.isDialogClosing = false; |
| | | this.resetData(); |
| | | this.$nextTick(() => { |
| | | setTimeout(() => { |
| | | this.fetchUnpalletMaterialDetails(); |
| | | this.addKeyPressListener(); // æ·»å é®çäºä»¶çå¬ |
| | | }, 300); |
| | | }); |
| | | } else if (newVal === false && !this.isDialogClosing) { |
| | | console.log('å¼¹æ¡å
³éï¼ç§»é¤äºä»¶çå¬'); |
| | | this.isDialogClosing = true; |
| | | this.removeKeyPressListener(); // ç§»é¤é®çäºä»¶çå¬ |
| | | this.resetData(); |
| | | } |
| | | }, |
| | | |
| | | visible(newVal, oldVal) { |
| | | this.palletVisible = newVal; |
| | | |
| | |
| | | }, |
| | | |
| | | mounted() { |
| | | document.addEventListener('keypress', this.handleKeyPress); |
| | | // ä¸å¨mountedæ¶æ·»å çå¬ï¼å¨å¼¹çªæå¼æ¶æ·»å |
| | | }, |
| | | |
| | | beforeDestroy() { |
| | | document.removeEventListener('keypress', this.handleKeyPress); |
| | | // ç¡®ä¿ç»ä»¶éæ¯æ¶ç§»é¤çå¬ |
| | | this.removeKeyPressListener(); |
| | | this.clearAllTimers(); |
| | | }, |
| | | |
| | | methods: { |
| | | // æ·»å é®çäºä»¶çå¬ |
| | | addKeyPressListener() { |
| | | if (!this.keyPressListenerAdded) { |
| | | document.addEventListener('keypress', this.handleKeyPress); |
| | | this.keyPressListenerAdded = true; |
| | | console.log('é®çäºä»¶çå¬å·²æ·»å '); |
| | | } |
| | | }, |
| | | |
| | | // ç§»é¤é®çäºä»¶çå¬ |
| | | removeKeyPressListener() { |
| | | if (this.keyPressListenerAdded) { |
| | | document.removeEventListener('keypress', this.handleKeyPress); |
| | | this.keyPressListenerAdded = false; |
| | | console.log('é®çäºä»¶çå¬å·²ç§»é¤'); |
| | | } |
| | | }, |
| | | |
| | | open() { |
| | | this.show = true; |
| | | this.orderNo = ""; |
| | |
| | | this.initLocationTypes(); |
| | | this.initwarehouseTypes(); |
| | | this.fetchUnpalletMaterialDetails(); |
| | | |
| | | // å¼¹çªæå¼æ¶æ·»å é®çäºä»¶çå¬ |
| | | this.$nextTick(() => { |
| | | setTimeout(() => { |
| | | this.addKeyPressListener(); |
| | | }, 100); |
| | | }); |
| | | }, |
| | | |
| | | validateLocationType(rule, value, callback) { |
| | |
| | | }, |
| | | |
| | | resetData() { |
| | | // å
ç§»é¤é®çäºä»¶çå¬ |
| | | this.removeKeyPressListener(); |
| | | |
| | | this.palletGroupedBarcodes = {}; |
| | | this.isSubmitting = false; |
| | | this.trayBarcode = ''; |
| | |
| | | }; |
| | | this.warehouseTypes = []; |
| | | this.locationTypes = []; |
| | | this.isDialogClosing = false; |
| | | this.keyPressListenerAdded = false; |
| | | |
| | | this.$nextTick(() => { |
| | | if (this.$refs.locationForm) { |
| | |
| | | }, |
| | | |
| | | handleDialogClose() { |
| | | // å
ç§»é¤é®çäºä»¶çå¬ |
| | | this.removeKeyPressListener(); |
| | | this.show = false; |
| | | this.resetData(); |
| | | }, |
| | |
| | | this.isManualInput = true; |
| | | this.isScanning = false; |
| | | |
| | | if (this.trayBarcode) { |
| | | this.trayBarcode = this.trayBarcode.replace(/\s+/g, ""); |
| | | } |
| | | |
| | | if (this.manualInputTimer) { |
| | | clearTimeout(this.manualInputTimer); |
| | | } |
| | |
| | | this.isManualInput = true; |
| | | this.isScanning = false; |
| | | |
| | | if (this.barcode) { |
| | | this.barcode = this.barcode.replace(/\s+/g, ""); |
| | | } |
| | | if (this.manualInputTimer) { |
| | | clearTimeout(this.manualInputTimer); |
| | | } |
| | |
| | | .then(valid => { |
| | | if (!valid) return; |
| | | |
| | | const currentTrayBarcode = this.trayBarcode.trim(); |
| | | let currentTrayBarcode = (this.trayBarcode || "").replace(/\s+/g, "").trim(); |
| | | |
| | | this.trayBarcode = currentTrayBarcode; |
| | | |
| | | if (!currentTrayBarcode) { |
| | | this.error = '请è¾å
¥ææ«ææçæ¡ç '; |
| | |
| | | }); |
| | | }, |
| | | |
| | | // APIè¯·æ± |
| | | // APIè¯·æ± - 注æè¿éä¿®æ¹äºAPIå°å为/AllGroupPallet |
| | | fetchMaterialData(barcode) { |
| | | return http.post('/api/Inbound/AllGroupPallet', { |
| | | palletCode: this.trayBarcode, |
| | |
| | | |
| | | // å¤çæ«ç æªè¾å
¥ |
| | | handleKeyPress(event) { |
| | | // æ£æ¥å¼¹çªæ¯å¦æ¾ç¤º |
| | | if (!this.show || this.isDialogClosing) { |
| | | return; |
| | | } |
| | | |
| | | if (this.isManualInput || this.isSubmitting) { |
| | | return; |
| | | } |