| | |
| | | <div class="location-section compact"> |
| | | <el-form :model="form" :rules="rules" ref="locationForm" class="compact-form"> |
| | | <el-form-item label="ä»åºåºå" prop="locationType" class="location-select compact-item"> |
| | | <el-select v-model="form.locationType" placeholder="请å
éæ©ä»åº" clearable filterable |
| | | @change="handleLocationChange" style="width: 100%" :loading="locationLoading" size="medium"> |
| | | <el-select v-model="form.locationType" placeholder="èªå¨è·åä»åºåºå" clearable filterable |
| | | @change="handleLocationChange" style="width: 100%" :loading="locationLoading" size="medium" :disabled="true"> |
| | | <el-option v-for="item in locationTypes" :key="item.locationType" :label="item.locationTypeDesc" |
| | | :value="item.locationType" /> |
| | | </el-select> |
| | |
| | | class="custom-input" size="medium"> |
| | | <template slot="append"> |
| | | <el-button :loading="loading" @click="handleBarcodeSubmit" type="primary" icon="el-icon-search" |
| | | :disabled="!form.locationType || !trayBarcode || !barcode || !from.warehouseType" size="medium"> |
| | | :disabled="!form.locationType || !trayBarcode || !barcode || !form.warehouseType" size="medium"> |
| | | {{ loading ? 'æ¥è¯¢ä¸...' : 'æ¥è¯¢' }} |
| | | </el-button> |
| | | </template> |
| | |
| | | trigger: 'change' |
| | | } |
| | | ] |
| | | } |
| | | }, |
| | | |
| | | // æ°å¢ï¼é®çäºä»¶ç嬿 è®° |
| | | keyPressListenerAdded: false, |
| | | isDialogClosing: false |
| | | } |
| | | }, |
| | | |
| | |
| | | return location ? location.locationTypeDesc : '' |
| | | } |
| | | }, |
| | | |
| | | 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) { |
| | | if (!this.form.warehouseType) { |
| | | callback(new Error('请å
éæ©ä»åº')); |
| | |
| | | })); |
| | | } |
| | | }, |
| | | |
| | | async initLocationTypes() { |
| | | try { |
| | | const { data } = await this.http.post("api/LocationInfo/GetLocationTypes") |
| | |
| | | this.$message.error('è·ååºåç±»å失败') |
| | | } |
| | | }, |
| | | |
| | | async initwarehouseTypes() { |
| | | try { |
| | | const { data } = await this.http.post("api/Warehouse/GetwarehouseTypes") |
| | |
| | | } |
| | | }, |
| | | |
| | | fetchLocationByWarehouse(warehouseCode) { |
| | | if (!warehouseCode) { |
| | | this.form.locationType = null; |
| | | return; |
| | | } |
| | | this.locationLoading = true; |
| | | http.post(`/api/InboundOrder/GetLocationType?code=${warehouseCode}`) |
| | | .then(({ data }) => { |
| | | if (data) { |
| | | this.form.locationType = data.locationType || data; |
| | | if (!this.locationTypes.find(item => item.locationType === this.form.locationType)) { |
| | | this.locationTypes.push({ |
| | | locationType: this.form.locationType, |
| | | locationTypeDesc: this.form.locationType |
| | | }); |
| | | } |
| | | } |
| | | }) |
| | | .catch((err) => { |
| | | console.error("è·åä»åºåºå失败:", err); |
| | | this.$message.error("è·åä»åºåºå失败ï¼è¯·éè¯"); |
| | | this.form.locationType = null; |
| | | }) |
| | | .finally(() => { |
| | | this.locationLoading = false; |
| | | }); |
| | | }, |
| | | async fetchStockStatistics(orderNo) { |
| | | // åæ®å·ä¸ºç©ºæ¶ä¸æ¥è¯¢ |
| | | if (!orderNo) { |
| | |
| | | this.error = ''; |
| | | resolve(true); |
| | | } else { |
| | | if (!this.from.warehouseType) { |
| | | // ä¿®å¤æ¼åé误ï¼this.from.warehouseType åºè¯¥æ¯ this.form.warehouseType |
| | | if (!this.form.warehouseType) { |
| | | this.error = '请å
éæ©ä»åº'; |
| | | } |
| | | else if (this.form.locationType === null || this.form.locationType === undefined || this.form.locationType === '') { |
| | |
| | | }); |
| | | }); |
| | | }, |
| | | |
| | | // èç¦å°æçè¾å
¥æ¡ |
| | | focusTrayInput() { |
| | | if (this.$refs.trayInput && this.$refs.trayInput.$el) { |
| | |
| | | } |
| | | } |
| | | }, |
| | | |
| | | // éç½®æææ°æ® |
| | | resetData() { |
| | | // å
ç§»é¤é®çäºä»¶çå¬ |
| | | this.removeKeyPressListener(); |
| | | |
| | | this.trayBarcode = ''; |
| | | this.barcode = ''; |
| | | this.materials = []; |
| | |
| | | } |
| | | this.warehouseTypes = []; |
| | | this.locationTypes = []; |
| | | this.isDialogClosing = false; |
| | | this.keyPressListenerAdded = false; |
| | | |
| | | // æ¸
é¤è¡¨åéªè¯ç¶æ |
| | | this.$nextTick(() => { |
| | | if (this.$refs.locationForm) { |
| | |
| | | this.scanTimer = null; |
| | | } |
| | | }, |
| | | |
| | | handleDialogClose() { |
| | | // å
ç§»é¤é®çäºä»¶çå¬ |
| | | this.removeKeyPressListener(); |
| | | this.show = false; |
| | | this.resetData(); |
| | | }, |
| | |
| | | this.$emit('back-success', result); |
| | | this.palletVisible = false; |
| | | }, |
| | | |
| | | // å¤çæçè¾å
¥ |
| | | handleTrayInput() { |
| | | // æ 记为æå¨è¾å
¥æ¨¡å¼ |
| | |
| | | |
| | | // å¤çæ«ç æªè¾å
¥ |
| | | handleKeyPress(event) { |
| | | // æ£æ¥å¼¹çªæ¯å¦æ¾ç¤º |
| | | if (!this.show || this.isDialogClosing) { |
| | | return; |
| | | } |
| | | |
| | | // å¦ææ¯æå¨è¾å
¥æ¨¡å¼ï¼ä¸å¤çæ«ç æªé»è¾ |
| | | if (this.isManualInput) { |
| | | return; |
| | |
| | | const seconds = String(date.getSeconds()).padStart(2, '0'); |
| | | |
| | | return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; |
| | | }, |
| | | |
| | | // ä»åºåæ¢äºä»¶ |
| | | handleWarehouseChange() { |
| | | this.form.locationType = null; |
| | | this.trayBarcode = ''; |
| | | this.barcode = ''; |
| | | this.materials = []; |
| | | this.error = ''; |
| | | this.fetchLocationByWarehouse(this.form.warehouseType); |
| | | }, |
| | | |
| | | // åºå忢äºä»¶ |
| | | handleLocationChange() { |
| | | this.trayBarcode = ''; |
| | | this.barcode = ''; |
| | | this.materials = []; |
| | | this.error = ''; |
| | | } |
| | | } |
| | | } |