| | |
| | | <template> |
| | | <vol-box v-model="groupPalletVisible" :title="'ç»çæä½ - åæ®å·ï¼' + currentDocNo" :height="1000" :width="1100" :padding="20" |
| | | :modal="true" @open="handleDialogOpen" @close="handleDialogClose"> |
| | | <vol-box v-model="show" :title="'ç»çæä½ - åæ®å·ï¼' + orderNo" :height="1000" :width="1100" :padding="20" :modal="true"> |
| | | <div class="barcode-scanner-container"> |
| | | |
| | | <!-- ä»åºéæ© - ç´§åå¸å± --> |
| | | <div class="location-section compact"> |
| | | <el-form :model="form" :rules="rules" ref="locationForm" class="compact-form"> |
| | | <el-form-item label="ä»åº" prop="warehouseType" class="location-select compact-item"> |
| | | <el-form-item label="å
¥åºä»åº" prop="warehouseType" class="location-select compact-item"> |
| | | <el-select v-model="form.warehouseType" placeholder="è¯·éæ©ä»åº" clearable filterable |
| | | @change="handleWarehouseChange" style="width: 100%" :loading="warehouseLoading" size="medium"> |
| | | <el-option v-for="item in warehouseTypes" :key="item.warehouseType" :label="item.warehouseTypeDesc" |
| | |
| | | |
| | | <!-- æçæ¡ç è¾å
¥ --> |
| | | <div class="input-wrapper custom-input-group compact-input"> |
| | | <div class="input-label">æç®±ç </div> |
| | | <div class="input-label">æçæ¡ç </div> |
| | | <el-input ref="trayInput" v-model="trayBarcode" placeholder="è¯·æ«ææè¾å
¥æç®±ç åæå车é®" clearable |
| | | :disabled="!form.locationType || !form.warehouseType" @keyup.enter.native="handleTraySubmit" |
| | | @clear="handleTrayClear" @input="handleTrayInput" class="custom-input" size="medium"> |
| | |
| | | <el-alert :title="error" type="error" show-icon closable @close="error = ''" /> |
| | | </div> |
| | | |
| | | <!-- æªç»çå表 --> |
| | | <div class="unpallet-section compact"> |
| | | <el-card shadow="hover" class="compact-card unpallet-card"> |
| | | <div slot="header" class="compact-header"> |
| | | <span><i class="el-icon-tickets"></i> æªç»çæ¡ç </span> |
| | | <span class="list-actions"> |
| | | <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" |
| | | v-loading="unpalletBarcodesLoading"> |
| | | <el-table-column type="index" label="åºå·" width="60" align="center"></el-table-column> |
| | | <el-table-column prop="barcode" label="æ¡ç " min-width="140" show-overflow-tooltip></el-table-column> |
| | | <el-table-column prop="materielCode" label="ç©æç¼ç " min-width="150" show-overflow-tooltip></el-table-column> |
| | | <el-table-column prop="batchNo" label="æ¹æ¬¡" min-width="150" show-overflow-tooltip></el-table-column> |
| | | <el-table-column prop="orderQuantity" label="æ°é" min-width="130" align="right"></el-table-column> |
| | | <el-table-column prop="unit" label="åä½" width="80" align="center"></el-table-column> |
| | | <el-table-column prop="supplyCode" label="ä¾åºå" min-width="130" show-overflow-tooltip></el-table-column> |
| | | </el-table> |
| | | </div> |
| | | </el-card> |
| | | |
| | | </div> |
| | | |
| | | <!-- ç©æå表 - åºå®é«åº¦å¸¦æ»å¨æ¡ --> |
| | | <div class="material-list compact"> |
| | | <el-card shadow="hover" class="compact-card"> |
| | |
| | | <span><i class="el-icon-tickets"></i> ç»çæ°æ®</span> |
| | | <span class="list-actions"> |
| | | <el-tag type="primary" size="small">å
± {{ materials.length }} æ¡</el-tag> |
| | | <el-tag type="primary" size="small">æªç»ç {{ totalStockCount }}</el-tag> |
| | | <el-tag type="primary" size="small">æªå
¥åºæ°é {{ totalStockSum }}{{ uniqueUnit }}</el-tag> |
| | | <el-tag v-if="trayBarcode" type="success" size="small">æç: {{ trayBarcode }}</el-tag> |
| | | <el-tag v-if="form.warehouseType" type="info" size="small">ä»åº: {{ currentWarehouseName }}</el-tag> |
| | |
| | | </el-card> |
| | | </div> |
| | | </div> |
| | | |
| | | <!-- <div slot="footer" class="dialog-footer"> |
| | | <el-button @click="handleCancel">åæ¶</el-button> |
| | | <el-button type="primary" @click="handleConfirm">确认</el-button> |
| | | </div> --> |
| | | <template #footer> |
| | | <el-button type="danger" size="small" @click="handleDialogClose()">å
³é</el-button> |
| | | </template> |
| | | </vol-box> |
| | | </template> |
| | | <script> |
| | | import http from '@/api/http.js'; |
| | | import VolBox from '@/components/basic/VolBox.vue'; |
| | | import VolForm from '@/components/basic/VolForm.vue'; |
| | | import VolTable from '@/components/basic/VolTable.vue'; |
| | | import { ElLoading, ElMessage, ElMessageBox } from 'element-plus'; |
| | | import { ref, onMounted, onUnmounted } from 'vue' |
| | | import InboundOrder from '../../../views/inbound/inboundOrder.vue'; |
| | | import { th } from 'element-plus/es/locales.mjs'; |
| | | |
| | | export default { |
| | | name: 'BarcodeScanner', |
| | | components: { VolBox, VolForm, VolTable }, |
| | | props: { |
| | | docNo: { type: String, required: true, default: '' }, |
| | | visible: { type: Boolean, required: true, default: false } |
| | | }, |
| | | |
| | | components: { VolBox }, |
| | | data() { |
| | | return { |
| | | show: false, |
| | | orderNo: "", |
| | | palletVisible: this.visible, |
| | | trayBarcodeReg:/^[A-Z]\d{9}$/, |
| | | trayBarcodeReg: /^[A-Z]\d{9}$/, |
| | | trayBarcode: '', |
| | | barcode: '', |
| | | materials: [], |
| | |
| | | error: '', |
| | | debugMode: false, |
| | | currentFocus: 'warehouse', |
| | | |
| | | unpalletBarcodes: [], |
| | | unpalletBarcodesLoading: false, |
| | | unpalletMaterials: [], // æªç»çè¯¦ç»æ°æ®å表 |
| | | |
| | | // æ«ç æªç¸å
³åé |
| | | scanCode: '', |
| | |
| | | trigger: 'change' |
| | | } |
| | | ], |
| | | trayBarcode:[ |
| | | trayBarcode: [ |
| | | { |
| | | pattern: this.trayBarcodeReg, |
| | | message: 'æçå·æ ¼å¼é误ï¼é为1个大å忝+9个æ°åï¼å¦A000008024ï¼', |
| | | trigger: 'blur' |
| | | } |
| | | } |
| | | ], |
| | | warehouseType: [ |
| | | { |
| | |
| | | } |
| | | } |
| | | }, |
| | | |
| | | computed: { |
| | | groupPalletVisible: { |
| | | get() { return this.visible; }, |
| | | set(newVal) { this.$emit('update:visible', newVal); } |
| | | }, |
| | | currentDocNo() { return this.docNo; }, |
| | | // å½åéæ©çä»åºåç§° |
| | | currentWarehouseName() { |
| | | const warehouse = this.warehouseTypes.find(item => item.warehouseType === this.form.warehouseType); |
| | |
| | | this.resetData(); |
| | | this.$nextTick(() => { |
| | | setTimeout(() => { |
| | | // this.focusTrayInput(); |
| | | this.initwarehouseTypes(); // åå§åä»åº |
| | | this.initLocationTypes(); // åå§åä»åºåºå |
| | | this.fetchStockStatistics(); // å è½½ç»è®¡æ°æ® |
| | | this.fetchUnpalletMaterialDetails(); |
| | | }, 300); |
| | | }); |
| | | } |
| | |
| | | this.palletForm = { palletCode: '', barcode: '' }; |
| | | this.backData = []; |
| | | this.$refs.palletForm?.reset(); |
| | | this.fetchStockStatistics(); // åæ®å·åäºï¼å·æ°ç»è®¡ |
| | | this.fetchUnpalletMaterialDetails(); |
| | | } |
| | | } |
| | | }, |
| | | 'form.warehouseType'(newVal) { |
| | | if (newVal) { |
| | | this.form.locationType = null; |
| | | } else { |
| | | this.locationTypes = []; |
| | | } |
| | | }, |
| | | |
| | | mounted() { |
| | | |
| | | // æ·»å å
¨å±é®ççå¬ |
| | | document.addEventListener('keypress', this.handleKeyPress); |
| | | |
| | | // 使ç¨setTimeoutç¡®ä¿DOMå®å
¨æ¸²æååèç¦ |
| | | setTimeout(() => { |
| | | // this.focusTrayInput(); |
| | | this.focusLocationSelect(); |
| | | }, 300); |
| | | }, |
| | | beforeDestroy() { |
| | | // æ¸
çäºä»¶çå¬ |
| | | document.removeEventListener('keypress', this.handleKeyPress); |
| | | this.clearAllTimers(); |
| | | }, |
| | | methods: { |
| | | /** |
| | | * èªå®ä¹ä»åºåºåéªè¯ |
| | | * å
许å¼ä¸º0ï¼å 为0æ¯åæ³çlocationType |
| | | */ |
| | | open() { |
| | | this.show = true; |
| | | this.orderNo = ""; |
| | | this.resetData(); |
| | | this.initLocationTypes(); |
| | | this.initwarehouseTypes(); |
| | | this.fetchUnpalletMaterialDetails(); |
| | | }, |
| | | validateLocationType(rule, value, callback) { |
| | | // æ£æ¥å¼æ¯å¦ä¸ºnullãundefinedæç©ºå符串ï¼ä½å
许æ°å0 |
| | | if (!this.form.warehouseType) { |
| | | callback(new Error('请å
éæ©ä»åº')); |
| | | } else if (value === null || value === undefined || value === '') { |
| | |
| | | callback(); |
| | | } |
| | | }, |
| | | /** |
| | | * åå§åä»åºåºåæ°æ® |
| | | */ |
| | | |
| | | // æ ¹æ®æ¡ç å表è·åè¯¦ç»æ°æ® |
| | | 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: '-' |
| | | })); |
| | | } |
| | | }, |
| | | async initLocationTypes() { |
| | | this.locationLoading = true; |
| | | this.error = ''; |
| | | |
| | | try { |
| | | const response = await http.post('/api/LocationInfo/GetLocationTypes'); |
| | | |
| | | if (response.status && Array.isArray(response.data)) { |
| | | this.locationTypes = response.data; |
| | | if (this.locationTypes.length === 0) { |
| | | this.error = 'æªè·åå°ä»åºåºåæ°æ®'; |
| | | } else { |
| | | // 妿æé»è®¤åºåï¼å¯ä»¥å¨è¿é设置 |
| | | // this.form.locationType = this.locationTypes[0].locationType; |
| | | } |
| | | } else { |
| | | this.error = 'è·åä»åºåºåæ°æ®å¤±è´¥'; |
| | | } |
| | | } catch (error) { |
| | | console.error('è·åä»åºåºå失败:', error); |
| | | this.error = `è·åä»åºåºå失败: ${error.message || 'ç½ç»é误'}`; |
| | | } finally { |
| | | this.locationLoading = false; |
| | | const { data } = await this.http.post("api/LocationInfo/GetLocationTypes") |
| | | this.locationTypes = data |
| | | } catch (e) { |
| | | this.$message.error('è·ååºåç±»å失败') |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * åå§åä»åºæ°æ® |
| | | */ |
| | | async initwarehouseTypes() { |
| | | this.warehouseLoading = true; |
| | | this.error = ''; |
| | | |
| | | try { |
| | | const response = await http.post('/api/Warehouse/GetwarehouseTypes'); |
| | | |
| | | if (response.status && Array.isArray(response.data)) { |
| | | this.warehouseTypes = response.data; |
| | | if (this.warehouseTypes.length === 0) { |
| | | this.error = 'æªè·åå°ä»åºæ°æ®'; |
| | | } else { |
| | | // 妿æé»è®¤åºåï¼å¯ä»¥å¨è¿é设置 |
| | | // this.form.locationType = this.locationTypes[0].locationType; |
| | | } |
| | | } else { |
| | | this.error = 'è·åä»åºæ°æ®å¤±è´¥'; |
| | | } |
| | | } catch (error) { |
| | | console.error('è·åä»åºå¤±è´¥:', error); |
| | | this.error = `è·åä»åºå¤±è´¥: ${error.message || 'ç½ç»é误'}`; |
| | | } finally { |
| | | this.warehouseLoading = false; |
| | | const { data } = await this.http.post("api/Warehouse/GetwarehouseTypes") |
| | | this.warehouseTypes = data |
| | | } catch (e) { |
| | | this.$message.error('è·ååºåç±»å失败') |
| | | } |
| | | }, |
| | | |
| | | |
| | | /** |
| | | * ä»åºåºååæ´å¤ç |
| | | */ |
| | | handleLocationChange(value) { |
| | | console.log('éæ©ä»åºåºå:', value, 'ç±»å:', typeof value, this.currentLocationDesc); |
| | | |
| | | // ç«å³æ¸
é¤éè¯¯ä¿¡æ¯ |
| | | this.error = ''; |
| | | |
| | | // æå¨è§¦å表åéªè¯æ´æ° |
| | | this.$nextTick(() => { |
| | | if (this.$refs.locationForm) { |
| | | // æ¸
é¤è¯¥å段çéªè¯ç¶æï¼ç¶åéæ°éªè¯ |
| | | this.$refs.locationForm.clearValidate('locationType'); |
| | | |
| | | // çæå»¶è¿åéæ°éªè¯ï¼ç¡®ä¿DOMå·²æ´æ° |
| | | setTimeout(() => { |
| | | this.$refs.locationForm.validateField('locationType', (errorMsg) => { |
| | | if (!errorMsg && (value === 0 || value)) { |
| | | console.log('ä»åºåºåéªè¯éè¿:', value); |
| | | // åºåéæ©åï¼èªå¨èç¦å°æçè¾å
¥æ¡ |
| | | this.focusLocationSelect(); |
| | | } |
| | | }); |
| | | }, 100); |
| | | } |
| | | }); |
| | | }, |
| | | |
| | | /** |
| | | * ä»åºåæ´å¤ç |
| | | */ |
| | | handleWarehouseChange(value) { |
| | | console.log('éæ©ä»åº:', value, 'ç±»å:', typeof value, this.currentWarehouseName); |
| | | |
| | | // ç«å³æ¸
é¤éè¯¯ä¿¡æ¯ |
| | | this.error = ''; |
| | | |
| | | // æå¨è§¦å表åéªè¯æ´æ° |
| | | this.$nextTick(() => { |
| | | if (this.$refs.locationForm) { |
| | | // æ¸
é¤è¯¥å段çéªè¯ç¶æï¼ç¶åéæ°éªè¯ |
| | | this.$refs.locationForm.clearValidate('warehouseType'); |
| | | |
| | | // çæå»¶è¿åéæ°éªè¯ï¼ç¡®ä¿DOMå·²æ´æ° |
| | | setTimeout(() => { |
| | | this.$refs.locationForm.validateField('warehouseType', (errorMsg) => { |
| | | if (!errorMsg && (value === 0 || value)) { |
| | | console.log('ä»åºéªè¯éè¿:', value); |
| | | this.focusLocationSelect(); |
| | | } |
| | | }); |
| | | }, 100); |
| | | } |
| | | }); |
| | | }, |
| | | |
| | | async fetchStockStatistics() { |
| | | async fetchStockStatistics(orderNo) { |
| | | // åæ®å·ä¸ºç©ºæ¶ä¸æ¥è¯¢ |
| | | if (!this.docNo) { |
| | | if (!orderNo) { |
| | | this.sumError = 'åæ®å·ä¸ºç©ºï¼æ æ³ç»è®¡'; |
| | | return; |
| | | } |
| | |
| | | this.sumLoading = true; |
| | | this.sumError = ''; |
| | | try { |
| | | // è°ç¨å端ç»è®¡æ¥å£ï¼æ¿æ¢ä¸ºä½ çå®é
æ¥å£è·¯å¾ï¼ |
| | | const response = await http.post('/api/InboundOrder/UnPalletQuantity?orderNo=' + this.docNo, { |
| | | |
| | | }); |
| | | |
| | | // ç»å®æ°æ®ï¼å¹é
PalletSumQuantityDTO ç»æï¼ |
| | | 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 || ''; // 计éåä½ |
| | | 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; |
| | | console.error('åºåç»è®¡æ¥è¯¢å¼å¸¸ï¼', err); |
| | | } finally { |
| | | this.sumLoading = false; |
| | | } |
| | | }, |
| | | /** |
| | | * 表åéªè¯ |
| | | */ |
| | | |
| | | async validateForm() { |
| | | return new Promise((resolve) => { |
| | | if (!this.$refs.locationForm) { |
| | |
| | | this.error = ''; |
| | | resolve(true); |
| | | } else { |
| | | // æå¨æ£æ¥locationTypeï¼æ£ç¡®å¤çå¼ä¸º0çæ
åµ |
| | | if (!this.from.warehouseType) { |
| | | this.error = '请å
éæ©ä»åº'; |
| | | } |
| | | else if (this.form.locationType === null || this.form.locationType === undefined || this.form.locationType === '') { |
| | | this.error = '请å
éæ©ä»åºåºå'; |
| | | //this.$message.warning('请å
éæ©ä»åºåºå'); |
| | | } else { |
| | | // 妿å¼åå¨ï¼å
æ¬0ï¼ï¼ä½éªè¯ä¸éè¿ï¼å¯è½æ¯å
¶ä»éªè¯é误 |
| | | this.error = 'è¯·æ£æ¥è¡¨å填忝妿£ç¡®'; |
| | | } |
| | | resolve(false); |
| | | } |
| | | }); |
| | | }); |
| | | }, |
| | | focusWarehouseSelect() { |
| | | if (this.$refs.locationForm) { |
| | | const selectEl = this.$el.querySelector('.location-select:first-child .el-input__inner'); |
| | | if (selectEl) { |
| | | selectEl.focus(); |
| | | this.currentFocus = 'warehouse'; |
| | | } |
| | | } |
| | | }, |
| | | // èç¦å°ä»åºåºåéæ© |
| | | focusLocationSelect() { |
| | | if (this.$refs.locationForm) { |
| | | const selectEl = this.$el.querySelector('.location-select:nth-child(2) .el-input__inner'); |
| | | if (selectEl) { |
| | | selectEl.focus(); |
| | | this.currentFocus = 'location'; |
| | | } |
| | | } |
| | | }, |
| | | // èç¦å°æçè¾å
¥æ¡ |
| | | focusTrayInput() { |
| | |
| | | inputEl.focus(); |
| | | this.currentFocus = 'material'; |
| | | this.scanTarget = 'material'; |
| | | |
| | | |
| | | inputEl.select(); |
| | | console.log('ç©æè¾å
¥æ¡å
容已éä¸'); |
| | | |
| | | inputEl.select(); |
| | | } |
| | | } |
| | | }, |
| | | |
| | | |
| | | |
| | | |
| | | // éç½®æææ°æ® |
| | | resetData() { |
| | | console.log('éç½®å¼¹æ¡æ°æ®'); |
| | | this.trayBarcode = ''; |
| | | this.barcode = ''; |
| | | this.materials = []; |
| | | this.unpalletBarcodes = []; |
| | | this.unpalletMaterials = []; |
| | | this.loading = false; |
| | | this.error = ''; |
| | | this.scanCode = ''; |
| | |
| | | this.scanTimer = null; |
| | | } |
| | | }, |
| | | |
| | | // å¼¹æ¡æå¼æ¶éç½®æ°æ® |
| | | handleDialogOpen() { |
| | | console.log('å¼¹æ¡æå¼ï¼éç½®æ°æ®'); |
| | | this.resetData(); |
| | | // 使ç¨setTimeoutç¡®ä¿DOMå®å
¨æ¸²æååèç¦ |
| | | this.$nextTick(() => { |
| | | setTimeout(() => { |
| | | this.initwarehouseTypes(); |
| | | this.initLocationTypes(); // åå§åä»åºåºå |
| | | // ç¡®ä¿è¡¨åå¼ç¨åå¨ååèç¦ |
| | | if (this.$refs.locationForm) { |
| | | this.focusWarehouseSelect(); |
| | | } else { |
| | | // å¦æè¡¨åå¼ç¨è¿ä¸åå¨ï¼ç¨åéè¯ |
| | | setTimeout(() => { |
| | | this.focusWarehouseSelect(); |
| | | }, 500); |
| | | } |
| | | }, 300); |
| | | }); |
| | | }, |
| | | |
| | | // å¼¹æ¡å
³éæ¶éç½®æ°æ® |
| | | handleDialogClose() { |
| | | console.log('å¼¹æ¡å
³éï¼éç½®æ°æ®'); |
| | | this.show = false; |
| | | this.resetData(); |
| | | }, |
| | | |
| | | // åæ¶æé® |
| | | handleCancel() { |
| | | this.palletVisible = false; |
| | | }, |
| | | |
| | | // 确认æé® |
| | |
| | | |
| | | this.error = ''; |
| | | |
| | | if(!this.trayBarcodeReg.test(currentTrayBarcode)){ |
| | | ElMessage.warning({ |
| | | message: 'æçå·æ ¼å¼é误', |
| | | type: 'warning', |
| | | duration: 3000 |
| | | }) |
| | | 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({ |
| | | // message: `æçæ¡ç 已设置: ${currentTrayBarcode}`, |
| | | // type: 'success', |
| | | // duration: 2000 |
| | | // }); |
| | | this.$message.success(`æçæ¡ç 已设置: ${currentTrayBarcode}`); |
| | | }, |
| | | |
| | | // æ¸
餿ç |
| | |
| | | this.isManualInput = false; |
| | | this.isScanning = false; |
| | | }, |
| | | |
| | | |
| | | |
| | | // å¤çç©ææ¡ç æäº¤ |
| | | async handleBarcodeSubmit() { |
| | |
| | | // è°ç¨APIæ¥è¯¢ç©æä¿¡æ¯ |
| | | const materialData = await this.fetchMaterialData(currentBarcode); |
| | | if (!materialData || materialData.length === 0) { |
| | | |
| | | |
| | | return; |
| | | } |
| | | // æ£æ¥æ¯å¦å·²åå¨ç¸åç©æç¼ç çè®°å½ |
| | | const exists = this.materials.some(item => |
| | | item.barcode === this.trayBarcode |
| | | ); |
| | | console.log('API:', materialData) |
| | | if (exists) { |
| | | this.$message({ |
| | | message: '该æ¡ç å·²åå¨å½åæççå表ä¸', |
| | | type: 'warning', |
| | | duration: 2000 |
| | | |
| | | this.materials = []; |
| | | materialData.forEach(item => { |
| | | this.materials.push({ |
| | | ...item, |
| | | trayCode: this.trayBarcode, |
| | | locationType: this.form.locationType, |
| | | locationDesc: this.currentLocationDesc, |
| | | scanTime: this.formatTime(new Date()) |
| | | }); |
| | | |
| | | } else { |
| | | }); |
| | | this.orderNo = materialData[0].orderNo; |
| | | await this.fetchStockStatistics(materialData[0].orderNo); |
| | | await this.fetchUnpalletMaterialDetails(); |
| | | // æ¸
ç©ºç©æè¾å
¥æ¡å¹¶ä¿æèç¦ |
| | | this.barcode = ''; |
| | | this.scanCode = ''; // æ¸
空æ«ç ç¼å |
| | | this.isScanning = false; |
| | | |
| | | materialData.forEach(item => { |
| | | |
| | | // 妿ä¸åå¨ï¼æ·»å æ°ç©æ |
| | | this.materials.push({ |
| | | ...item, |
| | | trayCode: this.trayBarcode, |
| | | locationType: this.form.locationType, |
| | | locationDesc: this.currentLocationDesc, |
| | | scanTime: this.formatTime(new Date()) |
| | | }); |
| | | }); |
| | | |
| | | this.$message({ |
| | | message: `æåæ·»å æ¡ç : ${currentBarcode}`, |
| | | type: 'success', |
| | | duration: 2000 |
| | | }); |
| | | |
| | | this.fetchStockStatistics(); |
| | | // æ¸
ç©ºç©æè¾å
¥æ¡å¹¶ä¿æèç¦ |
| | | this.barcode = ''; |
| | | this.scanCode = ''; // æ¸
空æ«ç ç¼å |
| | | this.isScanning = false; |
| | | |
| | | setTimeout(() => { |
| | | this.focusBarcodeInput(); |
| | | }, 100); |
| | | } |
| | | 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); |
| | | // éä¸è¾å
¥æ¡å
çé误å
容ï¼ç¡®ä¿focus宿忧è¡ï¼ |
| | | const inputEl = this.$refs.barcodeInput?.$el?.querySelector('input'); |
| | | if (inputEl) inputEl.select(); |
| | | }, 100); |
| | | } finally { |
| | | this.loading = false; |
| | | } |
| | |
| | | // APIè¯·æ± - æ¿æ¢ä¸ºå®é
çAPIè°ç¨ |
| | | async fetchMaterialData(barcode) { |
| | | try { |
| | | const response = await http.post('/api/InboundOrder/BarcodeMaterielGroup', |
| | | const response = await http.post('/api/Inbound/GroupPallet', |
| | | { |
| | | palletCode: this.trayBarcode, |
| | | orderNo: this.docNo, |
| | | barcodes: barcode, |
| | | barcode: barcode, |
| | | locationTypeDesc: this.currentLocationDesc, |
| | | locationType: this.form.locationType, // æ·»å ä»åºåºåä¿¡æ¯ |
| | | warehouseType: this.form.warehouseType |
| | | } |
| | | ); |
| | | |
| | | |
| | | let materialData; |
| | | |
| | | if (typeof response.data === 'string') { |
| | |
| | | |
| | | } |
| | | } else { |
| | | // 妿è¿åçæ¯JSON对象ï¼ç´æ¥ä½¿ç¨ |
| | | materialData = response.data; |
| | | } |
| | | if (!response.status) { |
| | |
| | | |
| | | } catch (error) { |
| | | console.error('APIè°ç¨å¤±è´¥:', error); |
| | | |
| | | |
| | | } |
| | | }, |
| | | |
| | |
| | | }, 100); |
| | | |
| | | this.lastKeyTime = currentTime; |
| | | }, |
| | | |
| | | // å é¤ç©æ |
| | | removeMaterial(index) { |
| | | this.$confirm('ç¡®å®è¦å é¤è¿æ¡ç©æè®°å½å?', 'æç¤º', { |
| | | confirmButtonText: 'ç¡®å®', |
| | | cancelButtonText: 'åæ¶', |
| | | type: 'warning' |
| | | }).then(() => { |
| | | this.materials.splice(index, 1); |
| | | this.$message({ |
| | | type: 'success', |
| | | message: 'å 餿å!' |
| | | }); |
| | | this.fetchStockStatistics(); |
| | | |
| | | }).catch(() => { |
| | | // åæ¶å é¤ |
| | | }); |
| | | }, |
| | | |
| | | // æ¸
空ææç©æ |
| | | clearAllMaterials() { |
| | | if (this.materials.length === 0) return; |
| | | |
| | | this.$confirm('ç¡®å®è¦æ¸
空ææç©æè®°å½å?', 'æç¤º', { |
| | | confirmButtonText: 'ç¡®å®', |
| | | cancelButtonText: 'åæ¶', |
| | | type: 'warning' |
| | | }).then(() => { |
| | | this.materials = []; |
| | | this.$message({ |
| | | type: 'success', |
| | | message: 'å·²æ¸
空ææè®°å½!' |
| | | }); |
| | | }).catch(() => { |
| | | // åæ¶æ¸
空 |
| | | }); |
| | | }, |
| | | |
| | | // æ ¼å¼åæ¶é´ |
| | |
| | | border: 1px solid #DCDFE6; |
| | | border-radius: 4px; |
| | | } |
| | | |
| | | .unpallet-section.compact { |
| | | margin-bottom: 8px; |
| | | flex-shrink: 0; |
| | | } |
| | | |
| | | .unpallet-card { |
| | | flex-shrink: 0; |
| | | } |
| | | |
| | | .unpallet-barcode-list { |
| | | display: flex; |
| | | flex-wrap: wrap; |
| | | gap: 6px; |
| | | padding: 8px 0; |
| | | max-height: 180px; |
| | | overflow-y: auto; |
| | | } |
| | | |
| | | .unpallet-barcode-list>>>.el-tag { |
| | | cursor: pointer; |
| | | max-width: calc(33.333% - 4px); |
| | | overflow: hidden; |
| | | text-overflow: ellipsis; |
| | | white-space: nowrap; |
| | | } |
| | | |
| | | @media (max-width: 768px) { |
| | | .unpallet-barcode-list>>>.el-tag { |
| | | max-width: calc(50% - 4px); |
| | | } |
| | | } |
| | | } |
| | | </style> |