| | |
| | | <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 }, |
| | |
| | | |
| | | unpalletBarcodes: [], |
| | | unpalletBarcodesLoading: false, |
| | | unpalletMaterials: [], // æªç»çè¯¦ç»æ°æ®å表 |
| | | unpalletMaterials: [], |
| | | |
| | | // æ«ç æªç¸å
³åé |
| | | scanCode: '', |
| | | lastKeyTime: null, |
| | | isManualInput: false, |
| | | isScanning: false, |
| | | scanTimer: null, |
| | | manualInputTimer: null, |
| | | scanTarget: 'tray', // å½åæ«ç ç®æ : tray æ material |
| | | scanTarget: 'tray', |
| | | isSubmitting: false, |
| | | palletGroupedBarcodes: {}, |
| | | |
| | | // åºåç»è®¡ç¸å
³åé |
| | | totalStockSum: 0, |
| | | totalStockCount: 0, |
| | | uniqueUnit: '', |
| | | sumLoading: false, |
| | | sumError: '', |
| | | // ä»åºç¸å
³åé |
| | | warehouseTypes: [], |
| | | warehouseLoading: false, |
| | | // ä»åºåºåç¸å
³åé |
| | | locationTypes: [], |
| | | locationLoading: false, |
| | | form: { |
| | |
| | | }, |
| | | |
| | | computed: { |
| | | // å½åéæ©çä»åºåç§° |
| | | currentWarehouseName() { |
| | | const warehouse = this.warehouseTypes.find(item => item.warehouseType === this.form.warehouseType); |
| | | return warehouse ? warehouse.warehouseTypeDesc : ''; |
| | | }, |
| | | // å½åéæ©çä»åºåºåæè¿° |
| | | |
| | | currentLocationDesc() { |
| | | const location = this.locationTypes.find(item => item.locationType === this.form.locationType) |
| | | return location ? location.locationTypeDesc : '' |
| | | }, |
| | | |
| | | debounceHandleBarcodeSubmit() { |
| | | return debounce(this.handleBarcodeSubmit, 500); |
| | | } |
| | | }, |
| | | |
| | | watch: { |
| | | visible(newVal, oldVal) { |
| | | this.palletVisible = newVal; |
| | | |
| | | // å½ä» false å为 true æ¶ï¼è¡¨ç¤ºå¼¹æ¡æå¼ |
| | | if (newVal === true && oldVal === false) { |
| | | console.log('å¼¹æ¡æå¼ï¼éç½®æ°æ®'); |
| | | this.resetData(); |
| | |
| | | }); |
| | | } |
| | | |
| | | // å½ä» true å为 false æ¶ï¼è¡¨ç¤ºå¼¹æ¡å
³é |
| | | if (newVal === false && oldVal === true) { |
| | | console.log('å¼¹æ¡å
³éï¼éç½®æ°æ®'); |
| | | this.resetData(); |
| | | } |
| | | }, |
| | | |
| | | palletVisible(newVal) { |
| | | this.$emit('update:visible', newVal); |
| | | }, |
| | | |
| | | docNo(newVal) { |
| | | if (newVal) { |
| | | this.palletForm = { palletCode: '', barcode: '' }; |
| | |
| | | } |
| | | } |
| | | }, |
| | | |
| | | mounted() { |
| | | document.addEventListener('keypress', this.handleKeyPress); |
| | | }, |
| | | |
| | | beforeDestroy() { |
| | | document.removeEventListener('keypress', this.handleKeyPress); |
| | | this.clearAllTimers(); |
| | | }, |
| | | |
| | | methods: { |
| | | open() { |
| | | this.show = true; |
| | |
| | | this.initwarehouseTypes(); |
| | | this.fetchUnpalletMaterialDetails(); |
| | | }, |
| | | |
| | | validateLocationType(rule, value, callback) { |
| | | if (!this.form.warehouseType) { |
| | | callback(new Error('请å
éæ©ä»åº')); |
| | |
| | | } |
| | | }, |
| | | |
| | | // æ ¹æ®æ¡ç å表è·åè¯¦ç»æ°æ® |
| | | async fetchUnpalletMaterialDetails() { |
| | | try { |
| | | const response = await http.post('/api/InboundOrder/UnPalletGroupBarcode?orderNo=' + this.orderNo, {}); |
| | | if (response.status && Array.isArray(response.data)) { |
| | | this.unpalletMaterials = response.data; |
| | | this.unpalletBarcodes = response.data.map(item => item.barcode || ''); |
| | | this.totalStockCount = response.data.length; |
| | | } else { |
| | | this.unpalletMaterials = []; |
| | | } |
| | | } catch (err) { |
| | | this.unpalletMaterials = this.unpalletBarcodes.map(barcode => ({ |
| | | barcode: barcode, |
| | | materielCode: '-', |
| | | batchNo: '-', |
| | | stockQuantity: '-', |
| | | unit: '-', |
| | | supplyCode: '-', |
| | | warehouseType: '-' |
| | | })); |
| | | } |
| | | // è·åæªç»çç©æè¯¦æ
|
| | | fetchUnpalletMaterialDetails() { |
| | | this.unpalletBarcodesLoading = true; |
| | | |
| | | http.post('/api/InboundOrder/UnPalletGroupBarcode?orderNo=' + this.orderNo, {}) |
| | | .then(response => { |
| | | if (response.status && Array.isArray(response.data)) { |
| | | this.unpalletMaterials = response.data; |
| | | this.unpalletBarcodes = response.data.map(item => item.barcode || ''); |
| | | this.totalStockCount = response.data.length; |
| | | } else { |
| | | this.unpalletMaterials = []; |
| | | } |
| | | }) |
| | | .catch(err => { |
| | | console.error('è·åæªç»çç©æå¤±è´¥:', err); |
| | | this.unpalletMaterials = this.unpalletBarcodes.map(barcode => ({ |
| | | barcode: barcode, |
| | | materielCode: '-', |
| | | batchNo: '-', |
| | | stockQuantity: '-', |
| | | unit: '-', |
| | | supplyCode: '-', |
| | | warehouseType: '-' |
| | | })); |
| | | }) |
| | | .finally(() => { |
| | | this.unpalletBarcodesLoading = false; |
| | | }); |
| | | }, |
| | | async initLocationTypes() { |
| | | try { |
| | | const { data } = await this.http.post("api/LocationInfo/GetLocationTypes") |
| | | this.locationTypes = data |
| | | } catch (e) { |
| | | this.$message.error('è·ååºåç±»å失败') |
| | | } |
| | | |
| | | // åå§åä»åºåºåç±»å |
| | | initLocationTypes() { |
| | | this.locationLoading = true; |
| | | |
| | | this.http.post("api/LocationInfo/GetLocationTypes") |
| | | .then(({ data }) => { |
| | | this.locationTypes = data; |
| | | }) |
| | | .catch(e => { |
| | | console.error('è·ååºåç±»å失败:', e); |
| | | this.$message.error('è·ååºåç±»å失败'); |
| | | }) |
| | | .finally(() => { |
| | | this.locationLoading = false; |
| | | }); |
| | | }, |
| | | async initwarehouseTypes() { |
| | | try { |
| | | const { data } = await this.http.post("api/Warehouse/GetwarehouseTypes") |
| | | this.warehouseTypes = data |
| | | } catch (e) { |
| | | this.$message.error('è·ååºåç±»å失败') |
| | | } |
| | | |
| | | // åå§åä»åºç±»å |
| | | initwarehouseTypes() { |
| | | this.warehouseLoading = true; |
| | | |
| | | this.http.post("api/Warehouse/GetwarehouseTypes") |
| | | .then(({ data }) => { |
| | | this.warehouseTypes = data; |
| | | }) |
| | | .catch(e => { |
| | | console.error('è·åä»åºç±»å失败:', e); |
| | | this.$message.error('è·åä»åºç±»å失败'); |
| | | }) |
| | | .finally(() => { |
| | | this.warehouseLoading = false; |
| | | }); |
| | | }, |
| | | |
| | | async fetchStockStatistics(orderNo) { |
| | | // åæ®å·ä¸ºç©ºæ¶ä¸æ¥è¯¢ |
| | | // è·ååºåç»è®¡ |
| | | fetchStockStatistics(orderNo) { |
| | | if (!orderNo) { |
| | | this.sumError = 'åæ®å·ä¸ºç©ºï¼æ æ³ç»è®¡'; |
| | | return; |
| | | return Promise.resolve(null); |
| | | } |
| | | |
| | | this.sumLoading = true; |
| | | this.sumError = ''; |
| | | try { |
| | | const response = await http.post('/api/InboundOrder/UnPalletQuantity?orderNo=' + orderNo, {}); |
| | | if (response.data) { |
| | | this.totalStockSum = response.data.stockSumQuantity || 0; |
| | | this.totalStockCount = response.data.stockCount || 0; |
| | | this.uniqueUnit = response.data.uniqueUnit || ''; |
| | | } |
| | | } catch (err) { |
| | | this.sumError = 'ç»è®¡å 载失败'; |
| | | this.totalStockSum = 0; |
| | | this.totalStockCount = 0; |
| | | } finally { |
| | | this.sumLoading = false; |
| | | } |
| | | |
| | | return http.post('/api/InboundOrder/UnPalletQuantity?orderNo=' + orderNo, {}) |
| | | .then(response => { |
| | | if (response.data) { |
| | | this.totalStockSum = response.data.stockSumQuantity || 0; |
| | | this.totalStockCount = response.data.stockCount || 0; |
| | | this.uniqueUnit = response.data.uniqueUnit || ''; |
| | | } |
| | | return response.data; |
| | | }) |
| | | .catch(err => { |
| | | console.error('ç»è®¡å 载失败:', err); |
| | | this.sumError = 'ç»è®¡å 载失败'; |
| | | this.totalStockSum = 0; |
| | | this.totalStockCount = 0; |
| | | throw err; |
| | | }) |
| | | .finally(() => { |
| | | this.sumLoading = false; |
| | | }); |
| | | }, |
| | | |
| | | async validateForm() { |
| | | // 表åéªè¯ |
| | | validateForm() { |
| | | return new Promise((resolve) => { |
| | | if (!this.$refs.locationForm) { |
| | | this.error = 'è¡¨åæªåå§å'; |
| | |
| | | this.error = ''; |
| | | resolve(true); |
| | | } else { |
| | | if (!this.from.warehouseType) { |
| | | if (!this.form.warehouseType) { |
| | | this.error = '请å
éæ©ä»åº'; |
| | | } |
| | | else if (this.form.locationType === null || this.form.locationType === undefined || this.form.locationType === '') { |
| | | } else if (!this.form.locationType) { |
| | | this.error = '请å
éæ©ä»åºåºå'; |
| | | } else { |
| | | this.error = 'è¯·æ£æ¥è¡¨å填忝妿£ç¡®'; |
| | |
| | | }); |
| | | }); |
| | | }, |
| | | // èç¦å°æçè¾å
¥æ¡ |
| | | |
| | | focusTrayInput() { |
| | | if (this.$refs.trayInput && this.$refs.trayInput.$el) { |
| | | const inputEl = this.$refs.trayInput.$el.querySelector('input'); |
| | |
| | | } |
| | | }, |
| | | |
| | | // èç¦å°ç©æè¾å
¥æ¡ |
| | | focusBarcodeInput() { |
| | | if (this.$refs.barcodeInput && this.$refs.barcodeInput.$el) { |
| | | const inputEl = this.$refs.barcodeInput.$el.querySelector('input'); |
| | |
| | | } |
| | | } |
| | | }, |
| | | // éç½®æææ°æ® |
| | | |
| | | resetData() { |
| | | this.palletGroupedBarcodes = {}; |
| | | this.isSubmitting = false; |
| | | this.trayBarcode = ''; |
| | | this.barcode = ''; |
| | | this.materials = []; |
| | |
| | | this.form = { |
| | | warehouseType: null, |
| | | locationType: null |
| | | } |
| | | }; |
| | | this.warehouseTypes = []; |
| | | this.locationTypes = []; |
| | | // æ¸
é¤è¡¨åéªè¯ç¶æ |
| | | |
| | | this.$nextTick(() => { |
| | | if (this.$refs.locationForm) { |
| | | this.$refs.locationForm.clearValidate(); |
| | |
| | | }); |
| | | }, |
| | | |
| | | // æ¸
餿æè®¡æ¶å¨ |
| | | clearAllTimers() { |
| | | if (this.manualInputTimer) { |
| | | clearTimeout(this.manualInputTimer); |
| | |
| | | this.scanTimer = null; |
| | | } |
| | | }, |
| | | |
| | | handleDialogClose() { |
| | | this.show = false; |
| | | this.resetData(); |
| | | }, |
| | | |
| | | // 确认æé® |
| | | async handleConfirm() { |
| | | if (!await this.validateForm()) return; |
| | | handleConfirm() { |
| | | this.validateForm() |
| | | .then(valid => { |
| | | if (!valid) return; |
| | | |
| | | if (this.materials.length === 0) { |
| | | this.$message.warning('请è³å°æ·»å ä¸ä¸ªç©æ'); |
| | | return; |
| | | } |
| | | |
| | | if (this.materials.length === 0) { |
| | | this.$message.warning('请è³å°æ·»å ä¸ä¸ªç©æ'); |
| | | return; |
| | | } |
| | | if (!this.trayBarcode) { |
| | | this.$message.warning('请è¾å
¥æçæ¡ç '); |
| | | return; |
| | | } |
| | | |
| | | if (!this.trayBarcode) { |
| | | this.$message.warning('请è¾å
¥æçæ¡ç '); |
| | | return; |
| | | } |
| | | const result = { |
| | | warehouseType: this.form.warehouseType, |
| | | warehouseName: this.currentWarehouseName, |
| | | locationType: this.form.locationType, |
| | | locationDesc: this.currentLocationDesc, |
| | | trayBarcode: this.trayBarcode, |
| | | materials: this.materials, |
| | | docNo: this.docNo |
| | | }; |
| | | |
| | | const result = { |
| | | warehouseType: this.form.warehouseType, |
| | | warehouseName: this.currentWarehouseName, |
| | | locationType: this.form.locationType, |
| | | locationDesc: this.currentLocationDesc, |
| | | trayBarcode: this.trayBarcode, |
| | | materials: this.materials, |
| | | docNo: this.docNo |
| | | }; |
| | | |
| | | // 触åç¶ç»ä»¶ç back-success äºä»¶ |
| | | this.$emit('back-success', result); |
| | | this.palletVisible = false; |
| | | this.$emit('back-success', result); |
| | | this.palletVisible = false; |
| | | }); |
| | | }, |
| | | // å¤çæçè¾å
¥ |
| | | |
| | | handleTrayInput() { |
| | | // æ 记为æå¨è¾å
¥æ¨¡å¼ |
| | | this.isManualInput = true; |
| | | this.isScanning = false; |
| | | |
| | | // æ¸
é¤ä¹åç计æ¶å¨ |
| | | if (this.manualInputTimer) { |
| | | clearTimeout(this.manualInputTimer); |
| | | } |
| | | |
| | | // 设置计æ¶å¨ï¼å¦æä¸æ®µæ¶é´å
没æè¾å
¥ï¼åé置为æ«ç æ¨¡å¼ |
| | | this.manualInputTimer = setTimeout(() => { |
| | | this.isManualInput = false; |
| | | }, 1000); |
| | | }, |
| | | |
| | | // å¤çç©æè¾å
¥ |
| | | handleBarcodeInput() { |
| | | // æ 记为æå¨è¾å
¥æ¨¡å¼ |
| | | this.isManualInput = true; |
| | | this.isScanning = false; |
| | | |
| | | // æ¸
é¤ä¹åç计æ¶å¨ |
| | | if (this.manualInputTimer) { |
| | | clearTimeout(this.manualInputTimer); |
| | | } |
| | | |
| | | // 设置计æ¶å¨ï¼å¦æä¸æ®µæ¶é´å
没æè¾å
¥ï¼åé置为æ«ç æ¨¡å¼ |
| | | this.manualInputTimer = setTimeout(() => { |
| | | this.isManualInput = false; |
| | | }, 1000); |
| | | }, |
| | | |
| | | // å¤çæçæ¡ç æäº¤ |
| | | async handleTraySubmit() { |
| | | // å
ç´æ¥æ£æ¥locationTypeï¼é¿å
表åéªè¯ç弿¥é®é¢ |
| | | handleTraySubmit() { |
| | | this.barcode = ''; |
| | | this.materials = []; |
| | | this.error = ''; |
| | | |
| | | if (!this.form.warehouseType) { |
| | | this.error = '请å
éæ©ä»åº'; |
| | | return; |
| | | } |
| | | if (!this.form.locationType) { |
| | | this.error = '请å
éæ©ä»åºåºå'; |
| | | //this.$message.warning('请å
éæ©ä»åºåºå'); |
| | | return; |
| | | } |
| | | |
| | | // ç¶ååè¿è¡å®æ´ç表åéªè¯ |
| | | if (!await this.validateForm()) return; |
| | | this.validateForm() |
| | | .then(valid => { |
| | | if (!valid) return; |
| | | |
| | | const currentTrayBarcode = this.trayBarcode.trim(); |
| | | |
| | | const currentTrayBarcode = this.trayBarcode.trim(); |
| | | if (!currentTrayBarcode) { |
| | | this.error = '请è¾å
¥ææ«ææçæ¡ç '; |
| | | return; |
| | | } |
| | | |
| | | if (!currentTrayBarcode) { |
| | | this.error = '请è¾å
¥ææ«ææçæ¡ç '; |
| | | return; |
| | | } |
| | | this.error = ''; |
| | | |
| | | this.error = ''; |
| | | if (!this.trayBarcodeReg.test(currentTrayBarcode)) { |
| | | this.$message("æçå·æ ¼å¼é误"); |
| | | this.focusTrayInput(); |
| | | return; |
| | | } |
| | | |
| | | 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.focusBarcodeInput(); |
| | | this.$message.success(`æçæ¡ç 已设置: ${currentTrayBarcode}`); |
| | | }); |
| | | }, |
| | | |
| | | // æ¸
餿ç |
| | | clearTray() { |
| | | this.trayBarcode = ''; |
| | | this.materials = []; |
| | |
| | | }); |
| | | }, |
| | | |
| | | // æ¸
空æçè¾å
¥ |
| | | handleTrayClear() { |
| | | this.error = ''; |
| | | }, |
| | | |
| | | // æ¸
空è¾å
¥ |
| | | handleClear() { |
| | | this.error = ''; |
| | | this.scanCode = ''; |
| | |
| | | this.isScanning = false; |
| | | }, |
| | | |
| | | |
| | | // å¤çç©ææ¡ç æäº¤ |
| | | async handleBarcodeSubmit() { |
| | | if (!await this.validateForm()) return; |
| | | handleBarcodeSubmit() { |
| | | if (this.isSubmitting) { |
| | | this.$message.warning('æ£å¨å¤çä¸ï¼è¯·ç¨å'); |
| | | return; |
| | | } |
| | | |
| | | const currentBarcode = this.barcode.trim(); |
| | | |
| | | if (!this.trayBarcode) { |
| | | this.error = '请å
è¾å
¥æçæ¡ç '; |
| | | this.focusTrayInput(); |
| | | return; |
| | | } |
| | | |
| | | if (!currentBarcode) { |
| | | this.error = '请è¾å
¥ææ«æç©ææ¡ç '; |
| | | return; |
| | | } |
| | | |
| | | this.focusBarcodeInput(); |
| | | this.error = ''; |
| | | this.loading = true; |
| | | |
| | | try { |
| | | // è°ç¨APIæ¥è¯¢ç©æä¿¡æ¯ |
| | | const materialData = await this.fetchMaterialData(currentBarcode); |
| | | if (!materialData || materialData.length === 0) { |
| | | return; |
| | | } |
| | | |
| | | this.materials = []; |
| | | materialData.forEach(item => { |
| | | this.materials.push({ |
| | | ...item, |
| | | trayCode: this.trayBarcode, |
| | | locationType: this.form.locationType, |
| | | locationDesc: this.currentLocationDesc, |
| | | scanTime: this.formatTime(new Date()) |
| | | }); |
| | | }); |
| | | this.orderNo = materialData[0].orderNo; |
| | | await this.fetchStockStatistics(materialData[0].orderNo); |
| | | await this.fetchUnpalletMaterialDetails(); |
| | | // æ¸
ç©ºç©æè¾å
¥æ¡å¹¶ä¿æèç¦ |
| | | const currentTrayGrouped = this.palletGroupedBarcodes[this.trayBarcode] || []; |
| | | |
| | | if (currentTrayGrouped.includes(currentBarcode)) { |
| | | this.error = `æ¡ç ${currentBarcode} 已被å½åæçç»çï¼è¯·å¿é夿ä½`; |
| | | this.barcode = ''; |
| | | this.scanCode = ''; // æ¸
空æ«ç ç¼å |
| | | this.isScanning = false; |
| | | |
| | | setTimeout(() => { |
| | | this.focusBarcodeInput(); |
| | | }, 100); |
| | | } catch (err) { |
| | | this.error = err.message || 'æ¥è¯¢æ¡ç ä¿¡æ¯å¤±è´¥ï¼è¯·éè¯'; |
| | | this.focusBarcodeInput(); |
| | | setTimeout(() => { |
| | | // éä¸è¾å
¥æ¡å
çé误å
容ï¼ç¡®ä¿focus宿忧è¡ï¼ |
| | | const inputEl = this.$refs.barcodeInput?.$el?.querySelector('input'); |
| | | if (inputEl) inputEl.select(); |
| | | }, 100); |
| | | } finally { |
| | | this.loading = false; |
| | | return; |
| | | } |
| | | |
| | | this.isSubmitting = true; |
| | | |
| | | this.validateForm() |
| | | .then(valid => { |
| | | if (!valid) { |
| | | this.isSubmitting = false; |
| | | return; |
| | | } |
| | | |
| | | if (!this.trayBarcode) { |
| | | this.error = '请å
è¾å
¥æçæ¡ç '; |
| | | this.focusTrayInput(); |
| | | this.isSubmitting = false; |
| | | return; |
| | | } |
| | | |
| | | if (!currentBarcode) { |
| | | this.error = '请è¾å
¥ææ«æç©ææ¡ç '; |
| | | this.isSubmitting = false; |
| | | return; |
| | | } |
| | | |
| | | this.focusBarcodeInput(); |
| | | this.error = ''; |
| | | this.loading = true; |
| | | |
| | | console.log('ç»ç请æ±åæ°:', { |
| | | palletCode: this.trayBarcode, |
| | | barcode: currentBarcode, |
| | | locationTypeDesc: this.currentLocationDesc, |
| | | locationType: this.form.locationType, |
| | | warehouseType: this.form.warehouseType |
| | | }); |
| | | |
| | | return this.fetchMaterialData(currentBarcode); |
| | | }) |
| | | .then(materialData => { |
| | | if (!materialData || materialData.length === 0) { |
| | | return; |
| | | } |
| | | |
| | | this.materials = []; |
| | | const newBarcodes = []; |
| | | |
| | | materialData.forEach(item => { |
| | | this.materials.push({ |
| | | ...item, |
| | | trayCode: this.trayBarcode, |
| | | locationType: this.form.locationType, |
| | | locationDesc: this.currentLocationDesc, |
| | | scanTime: this.formatTime(new Date()) |
| | | }); |
| | | newBarcodes.push(item.barcode); |
| | | }); |
| | | |
| | | 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; |
| | | |
| | | return Promise.all([ |
| | | this.fetchStockStatistics(materialData[0].orderNo), |
| | | this.fetchUnpalletMaterialDetails() |
| | | ]); |
| | | }) |
| | | .then(() => { |
| | | this.barcode = ''; |
| | | this.scanCode = ''; |
| | | this.isScanning = false; |
| | | |
| | | setTimeout(() => { |
| | | this.focusBarcodeInput(); |
| | | }, 100); |
| | | }) |
| | | .catch(err => { |
| | | console.error('å¤çç©ææ¡ç 失败:', err); |
| | | this.error = err.message || 'æ¥è¯¢æ¡ç ä¿¡æ¯å¤±è´¥ï¼è¯·éè¯'; |
| | | this.focusBarcodeInput(); |
| | | setTimeout(() => { |
| | | const inputEl = this.$refs.barcodeInput?.$el?.querySelector('input'); |
| | | if (inputEl) inputEl.select(); |
| | | }, 100); |
| | | }) |
| | | .finally(() => { |
| | | this.loading = false; |
| | | this.isSubmitting = false; |
| | | }); |
| | | }, |
| | | |
| | | // APIè¯·æ± - æ¿æ¢ä¸ºå®é
çAPIè°ç¨ |
| | | async fetchMaterialData(barcode) { |
| | | try { |
| | | const response = await http.post('/api/Inbound/AllGroupPallet', |
| | | { |
| | | palletCode: this.trayBarcode, |
| | | barcode: barcode, |
| | | locationTypeDesc: this.currentLocationDesc, |
| | | locationType: this.form.locationType, // æ·»å ä»åºåºåä¿¡æ¯ |
| | | warehouseType: this.form.warehouseType |
| | | // APIè¯·æ± |
| | | fetchMaterialData(barcode) { |
| | | return http.post('/api/Inbound/AllGroupPallet', { |
| | | palletCode: this.trayBarcode, |
| | | barcode: barcode, |
| | | locationTypeDesc: this.currentLocationDesc, |
| | | locationType: this.form.locationType, |
| | | warehouseType: this.form.warehouseType |
| | | }) |
| | | .then(response => { |
| | | let materialData; |
| | | |
| | | if (typeof response.data === 'string') { |
| | | try { |
| | | materialData = JSON.parse(response.data); |
| | | } catch (e) { |
| | | console.error('è§£æååºæ°æ®å¤±è´¥:', e); |
| | | } |
| | | } else { |
| | | materialData = response.data; |
| | | } |
| | | ); |
| | | let materialData; |
| | | |
| | | if (typeof response.data === 'string') { |
| | | |
| | | try { |
| | | materialData = JSON.parse(response.data); |
| | | } catch (e) { |
| | | |
| | | |
| | | if (!response.status) { |
| | | this.error = response.message || 'æ¥è¯¢æ¡ç ä¿¡æ¯å¤±è´¥ï¼è¯·éè¯'; |
| | | return []; |
| | | } |
| | | } else { |
| | | materialData = response.data; |
| | | } |
| | | if (!response.status) { |
| | | this.error = response.message || 'æ¥è¯¢æ¡ç ä¿¡æ¯å¤±è´¥ï¼è¯·éè¯'; |
| | | } |
| | | |
| | | return materialData; |
| | | |
| | | } catch (error) { |
| | | console.error('APIè°ç¨å¤±è´¥:', error); |
| | | } |
| | | |
| | | return materialData || []; |
| | | }) |
| | | .catch(error => { |
| | | console.error('APIè°ç¨å¤±è´¥:', error); |
| | | this.$message.error('æ¥å£è¯·æ±å¤±è´¥ï¼è¯·è系管çå'); |
| | | throw error; |
| | | }); |
| | | }, |
| | | |
| | | // å¤çæ«ç æªè¾å
¥ |
| | | handleKeyPress(event) { |
| | | // å¦ææ¯æå¨è¾å
¥æ¨¡å¼ï¼ä¸å¤çæ«ç æªé»è¾ |
| | | if (this.isManualInput) { |
| | | if (this.isManualInput || this.isSubmitting) { |
| | | return; |
| | | } |
| | | |
| | | const key = event.key; |
| | | const currentTime = new Date().getTime(); |
| | | |
| | | // 忽ç¥ç´æ¥æä¸çå车é®ï¼ç±handleBarcodeSubmitå¤çï¼ |
| | | 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; |
| | | |
| | | // æ ¹æ®å½åæ«ç ç®æ 设置ç¸åºçè¾å
¥æ¡å¼ |
| | | if (this.scanTarget === 'tray') { |
| | | this.trayBarcode = this.scanCode; |
| | | this.handleTraySubmit(); |
| | |
| | | return; |
| | | } |
| | | |
| | | // æå»ºæ«ç å
容ï¼å¿«éè¿ç»è¾å
¥è§ä¸ºæ«ç ï¼ |
| | | if (this.lastKeyTime && currentTime - this.lastKeyTime < 50) { |
| | | this.scanCode += key; |
| | | this.isScanning = true; |
| | |
| | | this.isScanning = true; |
| | | } |
| | | |
| | | // 设置计æ¶å¨ï¼å¦æä¸æ®µæ¶é´å
没æè¾å
¥ï¼åéç½®æ«æç¶æ |
| | | if (this.scanTimer) { |
| | | clearTimeout(this.scanTimer); |
| | | } |
| | |
| | | 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 = ''; |
| | | } |
| | | } |
| | | } |