|
|
<template> <div class="pda-container"> <div class="header-bar"> <div class="header-left" :class="{ 'header-action-disabled': interfaceBusy }" @click="handleBack"> <i class="el-icon-arrow-left"></i> <span>人工分拣组盘</span> </div> <div class="header-right" :class="{ 'header-action-disabled': interfaceBusy }" @click="goHome">首页</div> </div>
<div class="table-body" style="max-height: 500px; overflow-y: auto;"> <div class="main-content form-section"> <!-- 第一行:栈板扫描 + 结束分拣按钮,保持与原PDA页面一致 - rqrq --> <div class="input-group"> <label class="input-label">栈板编码</label> <div style="display: flex; gap: 8px;"> <el-input v-model="palletCode" placeholder="请扫描栈板编码" class="form-input" style="flex: 0.75;" clearable inputmode="none" autocomplete="off" autocorrect="off" spellcheck="false" @keyup.enter.native="handlePalletScan" ref="palletInput" /> <button class="action-btn secondary" style="flex: 0.25; margin: 0;" @click="submitFinishSorting" :disabled="interfaceBusy || finishSortingLoading || detailList.length === 0"> {{ finishSortingLoading ? '处理中...' : '结束分拣' }} </button> </div> </div>
<!-- 第二行:栈板类型和自动分拣,保持与原PDA页面一致 - rqrq --> <div v-if="palletScanned" class="input-group"> <div style="display: flex; gap: 8px; align-items: end;"> <div style="flex: 0.65;"> <label class="input-label">栈板类型</label> <el-select v-model="currentPalletType" placeholder="请选择栈板类型" style="width: 100%;" :disabled="palletTypeDisabled" @change="handlePalletTypeChange" > <el-option v-for="type in palletTypeOptions" :key="type.palletType" :label="`${type.palletType} - ${type.typeDesc}`" :value="type.palletType" /> </el-select> </div> <div style="flex: 0.35;"> <label class="input-label">自动分拣</label> <el-select v-model="currentAutoSort" placeholder="请选择" style="width: 100%;" :disabled="autoSortDisabled" @change="handleAutoSortChange" > <el-option label="是" value="Y"></el-option> <el-option label="否" value="N"></el-option> </el-select> </div> </div> </div>
<!-- 第2.5行:是否强制整托出库,保持与原PDA页面一致 - rqrq --> <div v-if="palletScanned" class="input-group"> <el-checkbox v-model="forceFullPalletOut" :disabled="palletTypeDisabled" @change="handleForceFullPalletOutChange" style="width: 100%;" > 是否强制整托出库 </el-checkbox> </div>
<!-- 第三行:当前站点 + 刷新,保持与原PDA页面一致 - rqrq --> <div v-if="palletScanned" class="input-group"> <label class="input-label">当前站点</label> <div style="display: flex; gap: 8px;"> <el-input v-model="currentPalletStation" placeholder="栈板当前站点" class="form-input" readonly style="flex: 0.75;" /> <button class="action-btn secondary" style="flex: 0.25; margin: 0; white-space: nowrap;" @click="refreshTable" :disabled="interfaceBusy" > 刷新 </button> </div> </div>
<!-- 第四行:扫进/扫回 + 扫描按钮,保持与原PDA页面一致 - rqrq --> <div v-if="palletScanned" class="input-group"> <div style="display: flex; gap: 8px; align-items: center;"> <div style="flex: 0.75;"> <el-radio-group v-model="operationType" style="display: flex;"> <el-radio label="in" style="margin-right: 0px; white-space: nowrap;">扫进</el-radio> <el-radio label="out" style="white-space: nowrap;">扫回</el-radio> </el-radio-group> </div> <button class="action-btn secondary" style="flex: 0.25; margin: 0; white-space: nowrap;" :disabled="interfaceBusy || currentPalletType === ''" @click="showScanModal" > 扫描条码 </button> </div> </div> </div>
<!-- 分拣明细区域,按钮排版与原PDA页面一致 - rqrq --> <div v-if="palletScanned" class="rma-list"> <div class="list-title-row" style="display: flex; gap: 8px; align-items: center; padding: 0;"> <div class="list-title" style="flex: 0.75; margin: 0;"> <button class="action-btn primary" style="flex: 0.25; margin: 0;" @click="showDetailModal" :disabled="interfaceBusy || submitSortingLoading"> 浏览明细 </button> <label style="margin-left: 5px;">条码数:{{ detailList.length }}</label> </div> <button class="action-btn primary" style="flex: 0.25; margin: 0;" @click="submitSorting" :disabled="interfaceBusy || submitSortingLoading"> {{ submitSortingLoading ? '处理中...' : '提交分拣' }} </button> </div> <div class="detail-table"> <div class="table-header"> <div class="col-position">位置</div> <div class="col-layer">层数</div> <div class="col-serial">标签号</div> </div> <div v-for="(item, index) in detailList" :key="index" class="table-row"> <div class="col-position">{{ item.position }}</div> <div class="col-layer">{{ item.layer }}</div> <div class="col-serial">{{ item.serialNo }}</div> </div> <div v-if="detailList.length === 0" class="table-row empty-row"> <div class="empty-hint">暂无分拣明细数据</div> </div> </div> </div> </div>
<!-- 浏览明细弹窗,保持与原PDA页面一致 - rqrq --> <el-dialog :title="'已扫描数量:' + detailList.length" :visible.sync="detailModalVisible" width="90%" :close-on-click-modal="false" :show-close="false" :append-to-body="true" > <div class="table-body" style="max-height: 240px; overflow-y: auto;"> <div class="detail-table"> <div class="table-header"> <div class="col-position">位置</div> <div class="col-layer">层数</div> <div class="col-serial">标签号</div> </div> <div v-for="(item, index) in detailList" :key="index" class="table-row"> <div class="col-position">{{ item.position }}</div> <div class="col-layer">{{ item.layer }}</div> <div class="col-serial">{{ item.serialNo }}</div> </div> <div v-if="detailList.length === 0" class="table-row empty-row"> <div class="empty-hint">暂无分拣明细数据</div> </div> </div> </div> <div slot="footer" class="dialog-footer"> <button class="action-btn secondary" style="margin-left: 10px;" @click="detailModalVisible = false" :disabled="interfaceBusy">取消</button> </div> </el-dialog>
<!-- 扫码模态框:网格层数与原PDA页面保持一致 - rqrq --> <el-dialog title="扫描标签" :visible.sync="scanModalVisible" width="90%" :close-on-click-modal="false" :show-close="false" :modal="true" :modal-append-to-body="true" :append-to-body="true" > <div class="scan-modal-content"> <!-- 扫进时显示层数选择和位置网格 - rqrq --> <div v-if="operationType === 'in'" class="modal-form"> <!-- 层数选择(混装托盘不显示) - rqrq --> <div v-if="!currentMixedMode && scanLayerOptions.length > 0" class="input-group"> <label class="input-label">层数(当前选择:第{{ scanLayer }}层)</label> <div class="layer-grid"> <div v-for="layer in scanLayerOptions" :key="layer" class="layer-item" :class="{ 'layer-selected': scanLayer === layer }" @click="handleLayerClick(layer)" > {{ layer }} </div> </div> </div>
<!-- 位置网格选择器 - rqrq --> <div class="input-group"> <label class="input-label"> 位置{{ currentSelectedPosition ? `(当前选择:${currentSelectedPosition})` : '' }} <span v-if="positionGridLoading" style="color: #909399; font-size: 12px;">(加载中...)</span> </label> <div class="position-grid" :class="[ {'position-grid-loading': positionGridLoading}, getPositionGridClass ]"> <div v-for="(item, index) in displayPositionGrid" :key="index" class="position-item" :class="{ 'position-disabled': positionGridLoading || !availablePositions.includes(item.position), 'position-selected': currentSelectedPosition === item.position, 'position-loading': positionGridLoading, 'position-placeholder': item.isPlaceholder }" @click="handlePositionClick(item.position)" > <template v-if="!item.isPlaceholder">{{ item.position }}({{ item.count }})</template> </div> </div> </div> </div>
<!-- 标签扫描 - rqrq --> <div class="input-group"> <label class="input-label">标签二维码</label> <el-input ref="scanInput" v-model="scanCode" placeholder="请扫描标签二维码" class="form-input" clearable :disabled="operationType === 'in' && !currentSelectedPosition" @keyup.enter.native="handleLabelScan" inputmode="none" autocomplete="off" autocorrect="off" spellcheck="false" /> </div> </div> <div slot="footer" class="dialog-footer"> <button class="action-btn secondary" style="margin-left: 10px;" @click="closeScanModal" :disabled="interfaceBusy">取消</button> </div> </el-dialog> </div></template>
<script>import { checkPalletExists, getPalletDetails, savePalletDetail, restorePalletDetail, getLabelInfo, getPalletInfo, getPalletTypeList, updatePalletTypeAndAutoSort, getAvailablePositionsForLayer, completePalletAssemblyForFenJian, finishSorting, getSortingList} from '../../../api/haianAutoWarehouse/palletPacking'
export default { name: 'haianPalletSorting', data() { return { site: this.$store.state.user.site, palletCode: '', palletScanned: false, operationType: 'in', detailModalVisible: false, currentPalletType: '', currentAutoSort: 'N', currentPalletStation: '', forceFullPalletOut: false, palletTypeDisabled: false, autoSortDisabled: false, currentWcsAutoSort: '', currentMaxLayer: 0, positionOptions: [], palletTypeOptions: [], detailList: [], sortingList: [], // 分拣扫回缓存:记录扫进前原位置信息,便于扫回恢复 - rqrq
originalDetailCache: {}, palletInfo: { palletType: '', autoSort: 'N', locationCode: '' }, // 扫码模态框字段:与原PDA页面保持一致,按网格位置 + 层数扫入 - rqrq
scanModalVisible: false, scanCode: '', scanPosition: '', scanLayer: 1, scanLayerOptions: [], needRefreshOnClose: false, positionGrid: [], availablePositions: [], currentSelectedPosition: '', currentMixedMode: false, positionGridLoading: false, submitSortingLoading: false, finishSortingLoading: false, // 接口防连点相关状态:接口处理中统一禁用按钮、回退与首页,等待返回后解锁 - rqrq
palletScanLoading: false, palletConfigLoading: false, scanRequestLoading: false, } }, computed: { // 根据位置数量决定网格布局,确保与原PDA扫码弹窗一致 - rqrq
getPositionGridClass() { const len = this.positionGrid.length if (len === 1) return 'position-grid-1' if (len === 2) return 'position-grid-4' if (len === 4) return 'position-grid-4' return 'position-grid-9' }, // 2宫格场景采用对角展示,其余按原位置顺序展示 - rqrq
displayPositionGrid() { const len = this.positionGrid.length if (len === 2) { const pos1 = this.positionGrid.find((p) => p.position === '1') || { position: '1', count: 0 } const pos2 = this.positionGrid.find((p) => p.position === '2') || { position: '2', count: 0 } return [ { ...pos1, isPlaceholder: false }, { position: '', count: 0, isPlaceholder: true }, { position: '', count: 0, isPlaceholder: true }, { ...pos2, isPlaceholder: false } ] } return this.positionGrid.map((p) => ({ ...p, isPlaceholder: false })) }, // 页面接口忙碌态:任一按钮触发接口未返回时视为忙碌,统一禁用关键入口 - rqrq
interfaceBusy() { return this.palletScanLoading || this.palletConfigLoading || this.scanRequestLoading || this.submitSortingLoading || this.finishSortingLoading } }, methods: { ensureSite() { if (!this.site) { this.$alert('当前用户缺少site,无法执行海安分拣业务', '提示', { confirmButtonText: '确定' }) return false } return true }, handleBack() { if (this.interfaceBusy) { return } // 返回上一页前先清空分拣页状态,避免keep-alive缓存导致二次进入残留旧数据 - rqrq
this.resetPage(false) this.$router.back() }, // 接口处理中禁用首页跳转,避免用户离开后重复触发或产生脏状态 - rqrq
goHome() { if (this.interfaceBusy) { return } this.$router.push({ path: '/' }) }, // 海安分拣页统一重置方法:退出和重进都走同一逻辑,避免状态漂移 - rqrq
resetPage(needFocus = true) { this.site = this.$store.state.user.site this.palletCode = '' this.palletScanned = false this.operationType = 'in' this.detailModalVisible = false this.currentPalletType = '' this.currentAutoSort = 'N' this.currentPalletStation = '' this.forceFullPalletOut = false this.palletTypeDisabled = false this.autoSortDisabled = false this.currentWcsAutoSort = '' this.currentMaxLayer = 0 this.positionOptions = [] this.detailList = [] this.sortingList = [] this.originalDetailCache = {} this.palletInfo = { palletType: '', autoSort: 'N', locationCode: '' } this.scanCode = '' this.scanPosition = '' this.scanLayer = 1 this.scanModalVisible = false this.scanLayerOptions = [] this.needRefreshOnClose = false this.positionGrid = [] this.availablePositions = [] this.currentSelectedPosition = '' this.currentMixedMode = false this.positionGridLoading = false this.submitSortingLoading = false this.finishSortingLoading = false this.palletScanLoading = false this.palletConfigLoading = false this.scanRequestLoading = false if (needFocus) { this.$nextTick(() => { if (this.$refs.palletInput) { this.$refs.palletInput.focus() } }) } }, handlePalletScan() { if (!this.ensureSite()) { return } if (this.interfaceBusy) { return } if (!this.palletCode || !this.palletCode.trim()) { this.$alert('请输入栈板编码', '提示', { confirmButtonText: '确定' }) return } this.palletScanLoading = true checkPalletExists({ site: this.site, palletId: this.palletCode.trim() }).then(({ data }) => { if (data && data.code === 0) { this.palletCode = data.palletId this.positionOptions = data.positions || [] this.palletScanned = true this.scanCode = '' this.scanPosition = '' this.scanLayer = 1 this.currentSelectedPosition = '' this.sortingList = [] this.originalDetailCache = {} this.loadPalletInfo() this.refreshTable() } else { this.$alert((data && data.msg) || '栈板校验失败', '错误', { confirmButtonText: '确定' }) } }).catch((error) => { this.$alert(error.message || '栈板校验失败', '错误', { confirmButtonText: '确定' }) }).finally(() => { this.palletScanLoading = false }) }, loadPalletInfo() { getPalletInfo({ site: this.site, palletId: this.palletCode }).then(({ data }) => { if (data && data.code === 0) { const row = data.row || {} this.currentPalletType = row.palletType || '' this.currentAutoSort = row.autoSort || 'N' this.currentPalletStation = row.locationCode || '' this.forceFullPalletOut = Number(row.soreType) === 3 this.palletInfo.palletType = this.currentPalletType this.palletInfo.autoSort = this.currentAutoSort this.palletInfo.locationCode = this.currentPalletStation this.loadPalletTypeList() } }) }, // 读取托盘类型清单并推导自动分拣能力,保证海安页面与原PDA页面交互一致 - rqrq
loadPalletTypeList() { getPalletTypeList({ site: this.site, palletFamily: '', active: 'Y' }).then(({ data }) => { if (data && data.code === 0) { this.palletTypeOptions = data.rows || [] const selectedType = this.palletTypeOptions.find((item) => item.palletType === this.currentPalletType) this.currentWcsAutoSort = selectedType ? (selectedType.wcsAutoSort || 'N') : '' this.currentMaxLayer = selectedType ? Number(selectedType.maxLayer || 0) : 0 this.updateAutoSortControl() } }) }, refreshTable() { getPalletDetails({ site: this.site, palletId: this.palletCode, position: '', layer: null }).then(({ data }) => { if (data && data.code === 0) { this.detailList = data.details || [] } else { this.detailList = [] } this.palletTypeDisabled = this.detailList.length > 0 this.updateAutoSortControl() }).catch(() => { this.detailList = [] this.palletTypeDisabled = false this.updateAutoSortControl() }) }, handlePalletTypeChange() { const selectedType = this.palletTypeOptions.find((item) => item.palletType === this.currentPalletType) this.currentWcsAutoSort = selectedType ? (selectedType.wcsAutoSort || 'N') : '' this.currentMaxLayer = selectedType ? Number(selectedType.maxLayer || 0) : 0 if (this.currentPalletType === 'A0103') { this.forceFullPalletOut = true } this.updateAutoSortControl() this.savePalletTypeConfig() }, handleAutoSortChange() { this.savePalletTypeConfig() }, handleForceFullPalletOutChange() { this.savePalletTypeConfig() }, // 统一自动分拣禁用策略:强制整托、类型不支持、已有明细三类场景锁定 - rqrq
updateAutoSortControl() { if (this.forceFullPalletOut || this.currentPalletType === 'A0103') { this.currentAutoSort = 'N' this.autoSortDisabled = true return } if (this.currentWcsAutoSort === 'N') { this.currentAutoSort = 'N' this.autoSortDisabled = true return } this.autoSortDisabled = this.detailList.length > 0 }, savePalletTypeConfig() { if (this.interfaceBusy) { return } this.palletConfigLoading = true updatePalletTypeAndAutoSort({ site: this.site, palletId: this.palletCode, palletType: this.currentPalletType, autoSort: this.currentAutoSort, forceFullPalletOut: this.forceFullPalletOut }).finally(() => { this.palletConfigLoading = false }) }, // 打开扫码弹窗并初始化网格数据,交互与原PDA页面一致 - rqrq
showScanModal() { this.scanModalVisible = true this.scanCode = '' this.currentSelectedPosition = '' this.needRefreshOnClose = false if (this.operationType === 'in') { this.scanLayer = 1 this.loadLayerOptions() } else { this.$nextTick(() => { if (this.$refs.scanInput) { this.$refs.scanInput.focus() } }) } }, showDetailModal() { this.detailModalVisible = true }, // 计算当前可选层数并刷新位置网格,保持“按层扫描”体验一致 - rqrq
loadLayerOptions() { getPalletDetails({ site: this.site, palletId: this.palletCode, position: '', layer: null }).then(({ data }) => { if (data && data.code === 0) { const details = data.details || [] let maxExistingLayer = 0 if (details.length > 0) { maxExistingLayer = Math.max(...details.map((d) => d.layer || 0)) } if (this.currentMaxLayer === 0) { this.currentMixedMode = false this.scanLayerOptions = Array.from({ length: maxExistingLayer + 1 }, (_, i) => i + 1) } else { this.currentMixedMode = false this.scanLayerOptions = Array.from({ length: this.currentMaxLayer }, (_, i) => i + 1) } this.loadAvailablePositions() } else { this.$alert((data && data.msg) || '获取栈板信息失败', '错误', { confirmButtonText: '确定' }) } }).catch(() => { this.$alert('获取栈板信息失败', '错误', { confirmButtonText: '确定' }) }) }, // 按层加载位置网格与可扫位置,确保禁用态/加载态与原页面一致 - rqrq
loadAvailablePositions() { this.positionGridLoading = true this.availablePositions = [] getPalletDetails({ site: this.site, palletId: this.palletCode, position: '', layer: this.scanLayer }).then(({ data: detailData }) => { const positionCountMap = {} if (detailData && detailData.code === 0) { const details = detailData.details || [] details.forEach((detail) => { const pos = detail.position positionCountMap[pos] = (positionCountMap[pos] || 0) + 1 }) } return getAvailablePositionsForLayer({ site: this.site, palletId: this.palletCode, layer: this.scanLayer }).then(({ data }) => { if (data && data.code === 0) { const result = data.data || {} const positions = result.positions || [] this.availablePositions = result.availablePositions || [] this.positionGrid = positions.map((position) => ({ position, count: positionCountMap[position] || 0 })) } else { this.availablePositions = [] this.positionGrid = [] this.$alert((data && data.msg) || '获取位置信息失败', '错误', { confirmButtonText: '确定' }) } }) }).catch(() => { this.availablePositions = [] this.positionGrid = [] this.$alert('获取位置信息失败', '错误', { confirmButtonText: '确定' }) }).finally(() => { this.positionGridLoading = false }) }, handleLayerClick(layer) { if (this.scanLayer === layer) { return } this.scanLayer = layer this.currentSelectedPosition = '' this.loadAvailablePositions() }, handlePositionClick(position) { if (this.positionGridLoading) { this.$message.warning('位置信息加载中,请稍候') return } if (!this.availablePositions.includes(position)) { this.$message.warning('该位置不可用') return } this.currentSelectedPosition = position this.scanPosition = position this.$nextTick(() => { if (this.$refs.scanInput) { this.$refs.scanInput.focus() } }) }, moveFocusToScanInput() { this.$nextTick(() => { if (this.$refs.scanInput) { this.$refs.scanInput.focus() } }) }, closeScanModal() { this.scanModalVisible = false if (this.needRefreshOnClose) { this.refreshTable() this.needRefreshOnClose = false } }, loadSortingListIfNeeded() { if (this.sortingList.length > 0) { return Promise.resolve(this.sortingList) } return getSortingList({ site: this.site, palletId: this.palletCode }).then(({ data }) => { if (data && data.code === 0) { this.sortingList = data.rfidList || [] return this.sortingList } throw new Error((data && data.msg) || '获取分拣清单失败') }) }, // 分拣扫码:扫进需命中分拣清单并缓存原位置,扫回需按缓存恢复 - rqrq
handleLabelScan() { if (!this.ensureSite()) { return } if (this.interfaceBusy) { return } if (!this.scanCode || !this.scanCode.trim()) { this.scanCode = '' this.$alert('请输入标签编码', '错误', { confirmButtonText: '确定' }) this.moveFocusToScanInput() return } if (this.operationType === 'in') { if (!this.scanPosition) { this.scanCode = '' this.$alert('请选择位置', '错误', { confirmButtonText: '确定' }) this.moveFocusToScanInput() return } if (!this.scanLayer) { this.scanCode = '' this.$alert('请选择层数', '错误', { confirmButtonText: '确定' }) this.moveFocusToScanInput() return } this.scanRequestLoading = true this.loadSortingListIfNeeded() .then((list) => { if (list.length === 0) { throw new Error('当前不存在分拣任务') } if (!list.includes(this.scanCode)) { throw new Error('该标签不在分拣清单中') } return getLabelInfo({ site: this.site, serialNo: this.scanCode }).then(({ data }) => { const original = data && data.code === 0 ? data.row : null return savePalletDetail({ site: this.site, palletId: this.palletCode, position: this.scanPosition, layer: this.scanLayer, serialNo: this.scanCode, sortFlag: 1 }).then(({ data: saveData }) => { if (saveData && saveData.code === 0) { if (original) { this.originalDetailCache[this.scanCode] = { palletId: original.palletId || '', position: original.position || '', layer: original.layer || 1, partNo: original.partNo || '', createDate: original.createDate, createBy: original.createBy || '', // 保留原始wcsFlag语义:当原值为0时不能被“|| 1”吞掉,否则扫回会错误变成增量 - rqrq
wcsFlag: original.wcsFlag === null || original.wcsFlag === undefined ? 0 : original.wcsFlag } } this.$message.success('分拣扫进成功') this.needRefreshOnClose = true this.scanCode = '' this.loadLayerOptions() this.moveFocusToScanInput() return } throw new Error((saveData && saveData.msg) || '分拣扫进失败') }) }) }) .catch((error) => { this.$alert(error.message || '分拣扫进失败', '错误', { confirmButtonText: '确定' }) this.scanCode = '' this.moveFocusToScanInput() }) .finally(() => { this.scanRequestLoading = false }) } else { const original = this.originalDetailCache[this.scanCode] if (!original) { this.$alert('未找到该标签原始位置缓存,无法扫回', '提示', { confirmButtonText: '确定' }) this.scanCode = '' this.moveFocusToScanInput() return } this.scanRequestLoading = true restorePalletDetail({ site: this.site, serialNo: this.scanCode, originalPalletId: original.palletId, originalPosition: original.position, originalLayer: original.layer, partNo: original.partNo, createDate: original.createDate, createBy: original.createBy, // 分拣扫回固定回写0:语义是“恢复到已推送基线”,不把扫回数据再次当增量 - rqrq
wcsFlag: 0 }).then(({ data }) => { if (data && data.code === 0) { delete this.originalDetailCache[this.scanCode] this.$message.success('分拣扫回成功') this.needRefreshOnClose = true this.scanCode = '' this.moveFocusToScanInput() } else { this.scanCode = '' this.$alert((data && data.msg) || '分拣扫回失败', '错误', { confirmButtonText: '确定' }) this.moveFocusToScanInput() } }).catch((error) => { this.scanCode = '' this.$alert(error.message || '分拣扫回失败', '错误', { confirmButtonText: '确定' }) this.moveFocusToScanInput() }).finally(() => { this.scanRequestLoading = false }) } }, submitSorting() { if (!this.ensureSite()) { return } if (this.interfaceBusy) { return } if (!this.palletScanned) { this.$alert('请先扫描栈板', '提示', { confirmButtonText: '确定' }) return } this.submitSortingLoading = true completePalletAssemblyForFenJian({ site: this.site, palletId: this.palletCode }).then(({ data }) => { if (data && data.code === 0) { this.sortingList = [] this.$message.success('分拣提交成功') } else { this.$alert((data && data.msg) || '分拣提交失败', '错误', { confirmButtonText: '确定' }) } }).catch((error) => { this.$alert(error.message || '分拣提交失败', '错误', { confirmButtonText: '确定' }) }).finally(() => { this.submitSortingLoading = false }) }, // 结束分拣动作仅走海安后端分流,不创建WMS运输任务 - rqrq
submitFinishSorting() { if (!this.ensureSite()) { return } if (this.interfaceBusy) { return } if (!this.palletScanned) { this.$alert('请先扫描栈板', '提示', { confirmButtonText: '确定' }) return } this.finishSortingLoading = true finishSorting({ site: this.site, palletId: this.palletCode }).then(({ data }) => { if (data && data.code === 0) { this.$message.success('结束分拣成功') this.resetPage() } else { this.$alert((data && data.msg) || '结束分拣失败', '错误', { confirmButtonText: '确定' }) } }).catch((error) => { this.$alert(error.message || '结束分拣失败', '错误', { confirmButtonText: '确定' }) }).finally(() => { this.finishSortingLoading = false }) } }, // keep-alive页面重新激活时统一重置,确保每次进入都是干净态 - rqrq
activated() { this.resetPage(true) }, // 离开页面时主动清空,避免返回菜单后二次进入看到上次分拣数据 - rqrq
beforeRouteLeave(to, from, next) { this.resetPage(false) next() }, mounted() { this.resetPage(true) }}</script>
<style scoped>.header-action-disabled { opacity: 0.5; pointer-events: none;}
.detail-table { background: white; border-radius: 6px; overflow: hidden; border: 1px solid #e0e0e0;}
.table-header,.table-row { display: flex; align-items: center; padding: 8px; border-bottom: 1px solid #e0e0e0;}
.table-header { background: #f5f5f5; font-weight: bold; font-size: 14px;}
.col-position { flex: 1; text-align: center;}
.col-layer { flex: 1; text-align: center;}
.col-serial { flex: 4; text-align: center; word-break: break-all;}
.empty-row { justify-content: center; align-items: center; padding: 20px; border-bottom: none;}
.empty-hint { text-align: center; color: #999; width: 100%;}
.scan-modal-content { padding: 10px 0;}
.modal-form { margin-bottom: 16px;}
.dialog-footer { text-align: center;}
.action-btn.warning { background-color: #E6A23C; border-color: #E6A23C; color: white;}
.action-btn:disabled { opacity: 0.6; cursor: not-allowed; background-color: #ccc !important; border-color: #ccc !important;}
::v-deep .el-dialog__wrapper { z-index: 2000 !important;}
::v-deep .el-overlay { z-index: 2000 !important;}
::v-deep .el-radio { margin-right: 8px !important;}
::v-deep .el-radio__label { font-size: 14px;}
/* 层数网格样式,保持与原PDA页面一致 - rqrq */.layer-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px;}
.layer-item { display: flex; align-items: center; justify-content: center; min-width: 50px; height: 45px; padding: 0 12px; background-color: #fff; border: 2px solid #dcdfe6; border-radius: 6px; font-size: 15px; font-weight: bold; cursor: pointer; transition: all 0.3s; user-select: none;}
.layer-item:hover { border-color: #409eff; background-color: #ecf5ff;}
.layer-item.layer-selected { border-color: #409eff; background-color: #409eff; color: #fff;}
/* 位置网格样式,保持与原PDA页面一致 - rqrq */.position-grid { display: grid; gap: 10px; margin-top: 8px; position: relative;}
.position-grid.position-grid-1 { grid-template-columns: 1fr; grid-template-rows: 1fr;}
.position-grid.position-grid-4 { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); grid-auto-flow: column;}
.position-grid.position-grid-9 { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); grid-auto-flow: row;}
.position-item.position-placeholder { background-color: #f0f0f0 !important; border: 1px dashed #d0d0d0 !important; color: transparent !important; cursor: not-allowed !important; pointer-events: none !important;}
.position-grid.position-grid-loading { opacity: 0.7; pointer-events: none;}
.position-item { display: flex; align-items: center; justify-content: center; height: 60px; background-color: #fff; border: 2px solid #dcdfe6; border-radius: 6px; font-size: 16px; font-weight: bold; cursor: pointer; transition: all 0.3s; user-select: none;}
.position-item:hover:not(.position-disabled) { border-color: #409eff; background-color: #ecf5ff;}
.position-item.position-selected { border-color: #409eff; background-color: #409eff; color: #fff;}
.position-item.position-disabled { background-color: #f5f7fa; color: #c0c4cc; cursor: not-allowed; opacity: 0.6;}
.position-item.position-loading { background: linear-gradient(90deg, #f5f7fa 25%, #e4e7ed 50%, #f5f7fa 75%); background-size: 200% 100%; animation: loading 1.5s ease-in-out infinite;}
@keyframes loading { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; }}</style>
|