|
|
|
@ -348,7 +348,7 @@ |
|
|
|
</el-tabs> |
|
|
|
|
|
|
|
<!-- 盒清单新增对话框 --> |
|
|
|
<el-dialog title="装盒扫描" :visible.sync="caseDialogVisible" width="70%" :close-on-click-modal="false" @close="closeCaseDialog"> |
|
|
|
<el-dialog title="装盒扫描" :visible.sync="caseDialogVisible" width="70%" :close-on-click-modal="false" :before-close="handleCaseDialogBeforeClose" @close="closeCaseDialog"> |
|
|
|
<el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;" @submit.native.prevent> |
|
|
|
<el-form-item label="卷标签"> |
|
|
|
<el-input ref="rollNoInput" v-model="caseForm.rollNo" @keyup.enter.native="scanCaseRoll" placeholder="请扫描卷标签" style="width: 200px"></el-input> |
|
|
|
@ -373,19 +373,22 @@ |
|
|
|
<!-- 中部分:扫描列表 --> |
|
|
|
<el-table |
|
|
|
ref="caseRollTable" |
|
|
|
:data="caseRollList" |
|
|
|
:data="caseRollPageData" |
|
|
|
:row-key="getCaseRollTableRowKey" |
|
|
|
border |
|
|
|
height="300" |
|
|
|
@selection-change="handleCaseRollSelectionChange" |
|
|
|
style="width: 100%; margin-top: 10px;"> |
|
|
|
<el-table-column |
|
|
|
type="selection" |
|
|
|
:reserve-selection="true" |
|
|
|
width="55" |
|
|
|
header-align="center" |
|
|
|
align="center"> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column |
|
|
|
type="index" |
|
|
|
:index="getCaseRollIndex" |
|
|
|
label="序号" |
|
|
|
width="50" |
|
|
|
header-align="center" |
|
|
|
@ -451,11 +454,22 @@ |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
</el-table> |
|
|
|
<div style="margin-top: 10px; text-align: right;"> |
|
|
|
<el-pagination |
|
|
|
@size-change="handleCaseDialogSizeChange" |
|
|
|
@current-change="handleCaseDialogCurrentChange" |
|
|
|
:current-page="caseDialogPageIndex" |
|
|
|
:page-sizes="caseDialogPageSizes" |
|
|
|
:page-size="caseDialogPageSize" |
|
|
|
layout="total, sizes, prev, pager, next, jumper" |
|
|
|
:total="caseRollList.length"> |
|
|
|
</el-pagination> |
|
|
|
</div> |
|
|
|
<el-footer style="height:35px;margin-top: 15px;text-align:center"> |
|
|
|
<el-button type="primary" :loading="printLoading" @click="printCaseRolls">打印</el-button> |
|
|
|
<el-button type="primary" @click="applyCaseScan">应用</el-button> |
|
|
|
<el-button type="success" @click="saveCaseScan">保存</el-button> |
|
|
|
<el-button @click="closeCaseDialog">关闭</el-button> |
|
|
|
<el-button type="primary" :loading="caseSaving" :disabled="caseSaving" @click="applyCaseScan">应用</el-button> |
|
|
|
<el-button type="success" :loading="caseSaving" :disabled="caseSaving" @click="saveCaseScan">保存</el-button> |
|
|
|
<el-button :disabled="caseSaving" @click="closeCaseDialog">关闭</el-button> |
|
|
|
</el-footer> |
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
@ -495,8 +509,10 @@ export default { |
|
|
|
searchExpanded: true, |
|
|
|
currentRow: {}, |
|
|
|
selectedCaseRolls: [], // 装盒对话框中选中的卷标签 |
|
|
|
selectedCaseRollMap: {}, // 装盒对话框中跨页选中的卷标签 |
|
|
|
printLoading: false, // 打印loading |
|
|
|
printCasesLoading: false, // 扫描装盒页签打印loading |
|
|
|
caseSaving: false, // 装盒保存中 |
|
|
|
searchData:{ |
|
|
|
orderNo:'', |
|
|
|
customerId:'', |
|
|
|
@ -540,12 +556,16 @@ export default { |
|
|
|
partNo: '' |
|
|
|
}, |
|
|
|
caseRollList: [], |
|
|
|
caseRollKeyMap: {}, |
|
|
|
caseStatistics: { |
|
|
|
casesCount: 0, |
|
|
|
rollCount: 0, |
|
|
|
totalQty: 0 |
|
|
|
}, |
|
|
|
selectedCaseRecords: [], |
|
|
|
caseDialogPageIndex: 1, |
|
|
|
caseDialogPageSize: 100, |
|
|
|
caseDialogPageSizes: [50, 100, 200], |
|
|
|
// 扫描装盒分页 |
|
|
|
casesPageIndex: 1, |
|
|
|
casesPageSize: 50, |
|
|
|
@ -903,6 +923,14 @@ export default { |
|
|
|
pallet |
|
|
|
}, |
|
|
|
|
|
|
|
computed: { |
|
|
|
caseRollPageData(){ |
|
|
|
const start = (this.caseDialogPageIndex - 1) * this.caseDialogPageSize |
|
|
|
const end = start + this.caseDialogPageSize |
|
|
|
return this.caseRollList.slice(start, end) |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
mounted() { |
|
|
|
this.$nextTick(() => { |
|
|
|
this.calculateTableHeight(); |
|
|
|
@ -929,6 +957,51 @@ export default { |
|
|
|
this.calculateTableHeight(); |
|
|
|
}, |
|
|
|
|
|
|
|
buildCaseRollKey(site, rollNo){ |
|
|
|
return `${site || ''}|${rollNo || ''}` |
|
|
|
}, |
|
|
|
|
|
|
|
getCaseRollTableRowKey(row){ |
|
|
|
return this.buildCaseRollKey(row.site, row.rollNo) |
|
|
|
}, |
|
|
|
|
|
|
|
getCaseRollIndex(index){ |
|
|
|
return (this.caseDialogPageIndex - 1) * this.caseDialogPageSize + index + 1 |
|
|
|
}, |
|
|
|
|
|
|
|
rebuildSelectedCaseRolls(){ |
|
|
|
this.selectedCaseRolls = Object.keys(this.selectedCaseRollMap).map(key => this.selectedCaseRollMap[key]).filter(item => !!item) |
|
|
|
}, |
|
|
|
|
|
|
|
syncCaseRollPageSelection(){ |
|
|
|
this.$nextTick(() => { |
|
|
|
if (!this.$refs.caseRollTable || typeof this.$refs.caseRollTable.clearSelection !== 'function') { |
|
|
|
return |
|
|
|
} |
|
|
|
this.$refs.caseRollTable.clearSelection() |
|
|
|
if (typeof this.$refs.caseRollTable.toggleRowSelection !== 'function') { |
|
|
|
return |
|
|
|
} |
|
|
|
this.caseRollPageData.forEach(row => { |
|
|
|
const rowKey = this.buildCaseRollKey(row.site, row.rollNo) |
|
|
|
if (this.selectedCaseRollMap[rowKey]) { |
|
|
|
this.$refs.caseRollTable.toggleRowSelection(row, true) |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
handleCaseDialogSizeChange(val){ |
|
|
|
this.caseDialogPageSize = val |
|
|
|
this.caseDialogPageIndex = 1 |
|
|
|
this.syncCaseRollPageSelection() |
|
|
|
}, |
|
|
|
|
|
|
|
handleCaseDialogCurrentChange(val){ |
|
|
|
this.caseDialogPageIndex = val |
|
|
|
this.syncCaseRollPageSelection() |
|
|
|
}, |
|
|
|
|
|
|
|
getMainData(){ |
|
|
|
this.dataListLoading = true |
|
|
|
this.searchData.limit = this.pageSize |
|
|
|
@ -1149,7 +1222,10 @@ export default { |
|
|
|
partNo: '' |
|
|
|
} |
|
|
|
this.caseRollList = [] |
|
|
|
this.caseRollKeyMap = {} |
|
|
|
this.selectedCaseRolls = [] |
|
|
|
this.selectedCaseRollMap = {} |
|
|
|
this.caseDialogPageIndex = 1 |
|
|
|
this.updateCaseStatistics() |
|
|
|
}, |
|
|
|
|
|
|
|
@ -1185,26 +1261,13 @@ export default { |
|
|
|
const newRolls = [] |
|
|
|
|
|
|
|
rollList.forEach(rollInfo => { |
|
|
|
// 检查当前列表中是否已存在相同 site 和 rollNo 的记录 |
|
|
|
const isDuplicate = this.caseRollList.some(item => |
|
|
|
item.site === this.caseForm.site && item.rollNo === rollInfo.rollNo |
|
|
|
) |
|
|
|
const rollKey = this.buildCaseRollKey(this.caseForm.site, rollInfo.rollNo) |
|
|
|
const isDuplicate = !!this.caseRollKeyMap[rollKey] |
|
|
|
|
|
|
|
if (isDuplicate) { |
|
|
|
duplicateRolls.push(rollInfo.rollNo) |
|
|
|
} else { |
|
|
|
newRolls.push(rollInfo) |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
// 如果有重复的卷标签,提示用户 |
|
|
|
if (duplicateRolls.length > 0) { |
|
|
|
this.$message.warning(`以下卷标签已存在,不能重复添加:${duplicateRolls.join(', ')}`) |
|
|
|
} |
|
|
|
|
|
|
|
// 只添加不重复的卷到列表最前面(后扫描的在上面) |
|
|
|
newRolls.forEach(rollInfo => { |
|
|
|
this.caseRollList.unshift({ |
|
|
|
newRolls.push({ |
|
|
|
casesNo: this.caseForm.casesNo, |
|
|
|
rollNo: rollInfo.rollNo, |
|
|
|
packingList: rollInfo.packingList || '', |
|
|
|
@ -1216,8 +1279,26 @@ export default { |
|
|
|
site: this.caseForm.site, |
|
|
|
buNo: this.caseForm.buNo |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
// 如果有重复的卷标签,提示用户 |
|
|
|
if (duplicateRolls.length > 0) { |
|
|
|
this.$message.warning(`以下卷标签已存在,不能重复添加:${duplicateRolls.join(', ')}`) |
|
|
|
} |
|
|
|
|
|
|
|
// 只添加不重复的卷到列表最前面(后扫描的在上面) |
|
|
|
newRolls.forEach(rollInfo => { |
|
|
|
this.caseRollList.unshift(rollInfo) |
|
|
|
const rollKey = this.buildCaseRollKey(rollInfo.site, rollInfo.rollNo) |
|
|
|
this.caseRollKeyMap[rollKey] = true |
|
|
|
}) |
|
|
|
|
|
|
|
if (newRolls.length > 0) { |
|
|
|
this.caseDialogPageIndex = 1 |
|
|
|
this.syncCaseRollPageSelection() |
|
|
|
} |
|
|
|
|
|
|
|
// 更新统计信息 |
|
|
|
this.updateCaseStatistics() |
|
|
|
|
|
|
|
@ -1266,13 +1347,29 @@ export default { |
|
|
|
cancelButtonText: '取消', |
|
|
|
type: 'warning' |
|
|
|
}).then(() => { |
|
|
|
this.caseRollList.splice(index, 1) |
|
|
|
const actualIndex = (this.caseDialogPageIndex - 1) * this.caseDialogPageSize + index |
|
|
|
const deletedRow = this.caseRollList[actualIndex] |
|
|
|
if (deletedRow) { |
|
|
|
const rollKey = this.buildCaseRollKey(deletedRow.site, deletedRow.rollNo) |
|
|
|
delete this.caseRollKeyMap[rollKey] |
|
|
|
delete this.selectedCaseRollMap[rollKey] |
|
|
|
this.caseRollList.splice(actualIndex, 1) |
|
|
|
} |
|
|
|
const maxPage = Math.max(1, Math.ceil(this.caseRollList.length / this.caseDialogPageSize)) |
|
|
|
if (this.caseDialogPageIndex > maxPage) { |
|
|
|
this.caseDialogPageIndex = maxPage |
|
|
|
} |
|
|
|
this.rebuildSelectedCaseRolls() |
|
|
|
this.syncCaseRollPageSelection() |
|
|
|
this.updateCaseStatistics() |
|
|
|
this.$message.success('删除成功') |
|
|
|
}).catch(() => {}) |
|
|
|
}, |
|
|
|
|
|
|
|
async applyCaseScan(){ |
|
|
|
if (this.caseSaving) { |
|
|
|
return |
|
|
|
} |
|
|
|
if(this.caseRollList.length === 0){ |
|
|
|
this.$message.warning('请先扫描卷标签') |
|
|
|
return |
|
|
|
@ -1284,10 +1381,13 @@ export default { |
|
|
|
} |
|
|
|
|
|
|
|
// 应用:保存但不关闭对话框,重置输入框、计数和列表 |
|
|
|
this.saveCaseData(false) |
|
|
|
await this.saveCaseData(false) |
|
|
|
}, |
|
|
|
|
|
|
|
async saveCaseScan(){ |
|
|
|
if (this.caseSaving) { |
|
|
|
return |
|
|
|
} |
|
|
|
if(this.caseRollList.length === 0){ |
|
|
|
this.$message.warning('请先扫描卷标签') |
|
|
|
return |
|
|
|
@ -1299,7 +1399,7 @@ export default { |
|
|
|
} |
|
|
|
|
|
|
|
// 保存:保存后关闭对话框 |
|
|
|
this.saveCaseData(true) |
|
|
|
await this.saveCaseData(true) |
|
|
|
}, |
|
|
|
|
|
|
|
// 校验盒清单数量不能超过要求发货数量 |
|
|
|
@ -1348,6 +1448,10 @@ export default { |
|
|
|
}, |
|
|
|
|
|
|
|
async saveCaseData(closeDialog){ |
|
|
|
if (this.caseSaving) { |
|
|
|
return |
|
|
|
} |
|
|
|
this.caseSaving = true |
|
|
|
try { |
|
|
|
const {data} = await saveCaseRollList(this.caseRollList) |
|
|
|
if(data && data.code === 0){ |
|
|
|
@ -1360,7 +1464,9 @@ export default { |
|
|
|
// 应用:重置表单继续扫描 |
|
|
|
this.resetCaseForm() |
|
|
|
this.$nextTick(() => { |
|
|
|
this.$refs.caseNoInput.focus() |
|
|
|
if (this.$refs.rollNoInput) { |
|
|
|
this.$refs.rollNoInput.focus() |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
@ -1370,22 +1476,48 @@ export default { |
|
|
|
this.$message.error(data.msg || '保存失败') |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
this.$message.error(error.msg || '保存失败') |
|
|
|
const errMsg = (error && error.response && error.response.data && error.response.data.msg) |
|
|
|
|| error.msg |
|
|
|
|| error.message |
|
|
|
|| '保存失败' |
|
|
|
this.$message.error(errMsg) |
|
|
|
} finally { |
|
|
|
this.caseSaving = false |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
closeCaseDialog(){ |
|
|
|
if (this.caseSaving) { |
|
|
|
this.$message.warning('正在保存,请稍后') |
|
|
|
return |
|
|
|
} |
|
|
|
this.caseDialogVisible = false |
|
|
|
this.resetCaseForm() |
|
|
|
}, |
|
|
|
|
|
|
|
handleCaseDialogBeforeClose(done){ |
|
|
|
if (this.caseSaving) { |
|
|
|
this.$message.warning('正在保存,请稍后') |
|
|
|
return |
|
|
|
} |
|
|
|
done() |
|
|
|
}, |
|
|
|
|
|
|
|
handleCaseSelectionChange(selection){ |
|
|
|
this.selectedCaseRecords = selection |
|
|
|
}, |
|
|
|
|
|
|
|
// 装盒对话框中卷标签选择变化 |
|
|
|
handleCaseRollSelectionChange(selection){ |
|
|
|
this.selectedCaseRolls = selection |
|
|
|
const currentPageKeyList = this.caseRollPageData.map(item => this.buildCaseRollKey(item.site, item.rollNo)) |
|
|
|
currentPageKeyList.forEach(key => { |
|
|
|
delete this.selectedCaseRollMap[key] |
|
|
|
}) |
|
|
|
selection.forEach(item => { |
|
|
|
const key = this.buildCaseRollKey(item.site, item.rollNo) |
|
|
|
this.selectedCaseRollMap[key] = item |
|
|
|
}) |
|
|
|
this.rebuildSelectedCaseRolls() |
|
|
|
}, |
|
|
|
|
|
|
|
// 打印选中的卷标签 |
|
|
|
|