| | |
| | | <div class="input-label">ç©ææ¡ç </div> |
| | | <el-input ref="barcodeInput" v-model="barcode" placeholder="è¯·æ«ææè¾å
¥ç©ææ¡ç åæå车é®" clearable |
| | | :disabled="!form.locationType || !trayBarcode || !form.warehouseType" |
| | | @keyup.enter.native="handleBarcodeSubmit" @clear="handleClear" @input="handleBarcodeInput" |
| | | @keyup.enter.native="debounceHandleBarcodeSubmit" @clear="handleClear" @input="handleBarcodeInput" |
| | | 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"> |
| | | <el-button :loading="loading" @click="debounceHandleBarcodeSubmit" type="primary" icon="el-icon-search" |
| | | :disabled="!form.locationType || !trayBarcode || !barcode || !form.warehouseType" size="medium"> |
| | | {{ loading ? 'æ¥è¯¢ä¸...' : 'æ¥è¯¢' }} |
| | | </el-button> |
| | | </template> |
| | |
| | | <div class="input-tips compact-tips"> |
| | | <p>æç¤ºï¼è¯·å
éæ©ä»åº â éæ©ä»åºåºå â è¾å
¥æç®±ç â è¾å
¥ç©ææ¡ç </p> |
| | | <p v-if="!form.warehouseType" class="warning-text">â ï¸ è¯·å
éæ©ä»åº</p> |
| | | <p v-if="!form.locationType && !form.warehouseType" class="warning-text">â ï¸ è¯·å
éæ©ä»åºåºå</p> |
| | | <p v-if="form.warehouseType && !form.locationType" class="warning-text">â ï¸ è¯·å
éæ©ä»åºåºå</p> |
| | | <p v-if="form.warehouseType && form.locationType && !trayBarcode" class="warning-text">â ï¸ è¯·å
è¾å
¥æç®±ç </p> |
| | | </div> |
| | | |
| | |
| | | <el-tag type="primary" size="small">æªç»ç {{ totalStockCount }}</el-tag> |
| | | </span> |
| | | </div> |
| | | |
| | | |
| | | <div class="table-container"> |
| | | <el-table :data="unpalletMaterials" stripe style="width: 100%" height="100%" size="small" |
| | |
| | | <div v-if="materials.length === 0" class="empty-state compact"> |
| | | <i class="el-icon-document"></i> |
| | | <p v-if="!form.warehouseType">请å
éæ©ä»åº</p> |
| | | <p v-if="!form.locationType">请å
éæ©ä»åºåºå</p> |
| | | <p v-if="form.warehouseType && !form.locationType">请å
éæ©ä»åºåºå</p> |
| | | <p v-else-if="!trayBarcode">请å
è¾å
¥æç®±æ¡ç </p> |
| | | <p v-else>ææ ç©ææ°æ®ï¼è¯·æ«ææè¾å
¥ç©ææ¡ç </p> |
| | | </div> |
| | |
| | | </template> |
| | | </vol-box> |
| | | </template> |
| | | |
| | | <script> |
| | | import http from '@/api/http.js'; |
| | | import VolBox from '@/components/basic/VolBox.vue'; |
| | | |
| | | // æ°å¢ï¼é²æå½æ° |
| | | function debounce(func, wait) { |
| | | let timeout; |
| | | return function () { |
| | | const context = this; |
| | | const args = arguments; |
| | | clearTimeout(timeout); |
| | | timeout = setTimeout(() => { |
| | | func.apply(context, args); |
| | | }, wait); |
| | | }; |
| | | } |
| | | |
| | | export default { |
| | | components: { VolBox }, |
| | |
| | | manualInputTimer: null, |
| | | scanTarget: 'tray', // å½åæ«ç ç®æ : tray æ material |
| | | isSubmitting: false, // æ°å¢ï¼æäº¤éå®ï¼é²æ¢éå¤è¯·æ± |
| | | groupedBarcodes: [], |
| | | // ä¿®å¤ï¼æ¹ä¸ºææçåå¨å·²ç»çæ¡ç ï¼é¿å
ç¶ææ··æ· |
| | | palletGroupedBarcodes: {}, // æ ¼å¼ï¼{ [trayBarcode]: [barcode1, barcode2, ...] } |
| | | |
| | | // åºåç»è®¡ç¸å
³åé |
| | | totalStockSum: 0, |
| | |
| | | currentLocationDesc() { |
| | | const location = this.locationTypes.find(item => item.locationType === this.form.locationType) |
| | | return location ? location.locationTypeDesc : '' |
| | | }, |
| | | // æ°å¢ï¼é²æåçç©ææäº¤æ¹æ³ |
| | | debounceHandleBarcodeSubmit() { |
| | | return debounce(this.handleBarcodeSubmit, 500); |
| | | } |
| | | }, |
| | | watch: { |
| | |
| | | }, |
| | | async initLocationTypes() { |
| | | try { |
| | | // ä¿®å¤ï¼http æ¹ä¸º this.$httpï¼å代ç éè¯¯ï¼ |
| | | const { data } = await this.http.post("api/LocationInfo/GetLocationTypes") |
| | | this.locationTypes = data |
| | | } catch (e) { |
| | |
| | | }, |
| | | async initwarehouseTypes() { |
| | | try { |
| | | // ä¿®å¤ï¼http æ¹ä¸º this.$httpï¼å代ç éè¯¯ï¼ |
| | | const { data } = await this.http.post("api/Warehouse/GetwarehouseTypes") |
| | | this.warehouseTypes = data |
| | | } catch (e) { |
| | |
| | | this.error = ''; |
| | | resolve(true); |
| | | } else { |
| | | if (!this.from.warehouseType) { |
| | | // ä¿®å¤ï¼from æ¹ä¸º formï¼åä»£ç æ¼åéè¯¯ï¼ |
| | | if (!this.form.warehouseType) { |
| | | this.error = '请å
éæ©ä»åº'; |
| | | } |
| | | else if (this.form.locationType === null || this.form.locationType === undefined || this.form.locationType === '') { |
| | | } else if (this.form.locationType === null || this.form.locationType === undefined || this.form.locationType === '') { |
| | | this.error = '请å
éæ©ä»åºåºå'; |
| | | } else { |
| | | this.error = 'è¯·æ£æ¥è¡¨å填忝妿£ç¡®'; |
| | |
| | | }, |
| | | // éç½®æææ°æ® |
| | | resetData() { |
| | | this.groupedBarcodes = []; // æ¸
空已ç»çæ¡ç |
| | | // ä¿®å¤ï¼æ¸
空ææçåå¨çå·²ç»çæ¡ç |
| | | this.palletGroupedBarcodes = {}; |
| | | this.isSubmitting = false; // éç½®æäº¤é |
| | | this.trayBarcode = ''; |
| | | this.barcode = ''; |
| | |
| | | this.unpalletMaterials = []; |
| | | this.loading = false; |
| | | this.error = ''; |
| | | this.scanCode = ''; |
| | | this.scanCode = ''; // æ¸
空æ«ç ç¼å |
| | | this.lastKeyTime = null; |
| | | this.isManualInput = false; |
| | | this.isScanning = false; |
| | | this.currentFocus = 'warehouse'; |
| | | this.scanTarget = 'tray'; |
| | | this.scanTarget = 'tray'; // éç½®æ«ç ç®æ |
| | | this.clearAllTimers(); |
| | | this.totalStockSum = 0; |
| | | this.totalStockCount = 0; |
| | |
| | | |
| | | // å¤çæçæ¡ç æäº¤ |
| | | async handleTraySubmit() { |
| | | // ä¿®å¤ï¼åæ¢æçæ¶æ¸
ç©ºç©æç¸å
³ç¶æï¼é¿å
æ§æ°æ®æ®ç |
| | | this.barcode = ''; |
| | | this.materials = []; |
| | | this.error = ''; |
| | | |
| | | // å
ç´æ¥æ£æ¥locationTypeï¼é¿å
表åéªè¯ç弿¥é®é¢ |
| | | if (!this.form.warehouseType) { |
| | | this.error = '请å
éæ©ä»åº'; |
| | |
| | | } |
| | | if (!this.form.locationType) { |
| | | this.error = '请å
éæ©ä»åºåºå'; |
| | | //this.$message.warning('请å
éæ©ä»åºåºå'); |
| | | return; |
| | | } |
| | | |
| | |
| | | this.error = ''; |
| | | |
| | | if (!this.trayBarcodeReg.test(currentTrayBarcode)) { |
| | | // ElMessage.warning({ |
| | | // message: 'æçå·æ ¼å¼é误', |
| | | // type: 'warning', |
| | | // duration: 3000 |
| | | // }) |
| | | this.$message("æçå·æ ¼å¼é误"); |
| | | this.focusTrayInput(); |
| | | return; |
| | |
| | | // 设置æçæ¡ç åï¼èªå¨èç¦å°ç©æè¾å
¥æ¡ |
| | | this.focusBarcodeInput(); |
| | | |
| | | // this.$message({ |
| | | // message: `æçæ¡ç 已设置: ${currentTrayBarcode}`, |
| | | // type: 'success', |
| | | // duration: 2000 |
| | | // }); |
| | | this.$message.success(`æçæ¡ç 已设置: ${currentTrayBarcode}`); |
| | | }, |
| | | |
| | |
| | | this.isScanning = false; |
| | | }, |
| | | |
| | | |
| | | // å¤çç©ææ¡ç æäº¤ |
| | | async handleBarcodeSubmit() { |
| | | if (this.isSubmitting) { |
| | | this.$message.warning('æ£å¨å¤çä¸ï¼è¯·ç¨å'); |
| | | return; |
| | | } |
| | | if (!await this.validateForm()) return; |
| | | this.$message.warning('æ£å¨å¤çä¸ï¼è¯·ç¨å'); |
| | | return; |
| | | } |
| | | |
| | | // æ°å¢ï¼æ ¡éªå½åæ¡ç æ¯å¦å·²è¢«å½åæçç»ç |
| | | const currentBarcode = this.barcode.trim(); |
| | | const currentTrayGrouped = this.palletGroupedBarcodes[this.trayBarcode] || []; |
| | | if (currentTrayGrouped.includes(currentBarcode)) { |
| | | this.error = `æ¡ç ${currentBarcode} 已被å½åæçç»çï¼è¯·å¿é夿ä½`; |
| | | this.barcode = ''; |
| | | this.focusBarcodeInput(); |
| | | return; |
| | | } |
| | | |
| | | if (!await this.validateForm()) return; |
| | | |
| | | if (!this.trayBarcode) { |
| | | this.error = '请å
è¾å
¥æçæ¡ç '; |
| | |
| | | this.isSubmitting = true; // å¼å¯æäº¤é |
| | | |
| | | try { |
| | | // æ°å¢ï¼è°è¯æ¥å¿ï¼æå°è¯·æ±åæ° |
| | | console.log('ç»ç请æ±åæ°:', { |
| | | palletCode: this.trayBarcode, |
| | | barcode: currentBarcode, |
| | | locationTypeDesc: this.currentLocationDesc, |
| | | locationType: this.form.locationType, |
| | | warehouseType: this.form.warehouseType |
| | | }); |
| | | |
| | | // è°ç¨APIæ¥è¯¢ç©æä¿¡æ¯ |
| | | const materialData = await this.fetchMaterialData(currentBarcode); |
| | | if (!materialData || materialData.length === 0) { |
| | |
| | | }); |
| | | newBarcodes.push(item.barcode); // æ¶éæ¬æ¬¡ç»ççæ¡ç |
| | | }); |
| | | // å°æ¬æ¬¡ç»ççæ¡ç å å
¥å·²ç»çå表 |
| | | this.groupedBarcodes = [...new Set([...this.groupedBarcodes, ...newBarcodes])]; |
| | | |
| | | // ä¿®å¤ï¼ææçåå¨å·²ç»çæ¡ç |
| | | if (!this.palletGroupedBarcodes[this.trayBarcode]) { |
| | | this.palletGroupedBarcodes[this.trayBarcode] = []; |
| | | } |
| | | this.palletGroupedBarcodes[this.trayBarcode] = [...new Set([...this.palletGroupedBarcodes[this.trayBarcode], ...newBarcodes])]; |
| | | |
| | | this.orderNo = materialData[0].orderNo; |
| | | await this.fetchStockStatistics(materialData[0].orderNo); |
| | |
| | | let materialData; |
| | | |
| | | if (typeof response.data === 'string') { |
| | | |
| | | try { |
| | | materialData = JSON.parse(response.data); |
| | | } catch (e) { |
| | | |
| | | } |
| | | } catch (e) { } |
| | | } else { |
| | | materialData = response.data; |
| | | } |
| | |
| | | |
| | | } catch (error) { |
| | | console.error('APIè°ç¨å¤±è´¥:', error); |
| | | this.$message.error('æ¥å£è¯·æ±å¤±è´¥ï¼è¯·è系管çå'); |
| | | return []; |
| | | } |
| | | }, |
| | | |
| | | // å¤çæ«ç æªè¾å
¥ |
| | | handleKeyPress(event) { |
| | | // å¦ææ¯æå¨è¾å
¥æ¨¡å¼ï¼ä¸å¤çæ«ç æªé»è¾ |
| | | // å¦ææ¯æå¨è¾å
¥æ¨¡å¼ææ£å¨æäº¤ï¼ä¸å¤çæ«ç æªé»è¾ |
| | | if (this.isManualInput || this.isSubmitting) { |
| | | return; |
| | | } |
| | |
| | | if (key === 'Enter') { |
| | | event.preventDefault(); // 强å¶é»æ¢é»è®¤è¡ä¸ºï¼é¿å
éå¤è§¦å |
| | | if (this.scanCode.length > 0) { |
| | | // 黿¢é»è®¤å车è¡ä¸ºï¼é¿å
表åæäº¤ |
| | | event.preventDefault(); |
| | | // æ°å¢ï¼æ«ç ç®æ ä¸ºç©ææ¶ï¼æ ¡éªå½åæçæ¯å¦åå¨ |
| | | if (this.scanTarget === 'material' && !this.trayBarcode) { |
| | | this.$message.warning('请å
设置æçæ¡ç '); |
| | | this.scanCode = ''; |
| | | this.lastKeyTime = null; |
| | | return; |
| | | } |
| | | |
| | | // æ«ç 宿ï¼èªå¨è§¦åæ¥è¯¢ |
| | | this.isScanning = false; |
| | |
| | | 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 = ''; |
| | | }, |
| | | |
| | | // åºå忢äºä»¶ï¼è¡¥å
å®ç°ï¼å代ç ç¼ºå¤±ï¼ |
| | | handleLocationChange() { |
| | | // 忢åºåæ¶æ¸
空æçç¸å
³ç¶æ |
| | | this.trayBarcode = ''; |
| | | this.barcode = ''; |
| | | this.materials = []; |
| | | this.error = ''; |
| | | } |
| | | } |
| | | } |