You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

921 lines
23 KiB

<template>
<div class="pda-container">
<!-- 头部栏 -->
<div class="header-bar">
<div class="header-left" @click="handleBack">
<i class="el-icon-arrow-left"></i>
<span>直接领料</span>
</div>
<div class="header-right" @click="$router.push({ path: '/' })">
首页
</div>
</div>
<!-- 扫描框 -->
<div class="search-container">
<el-input clearable class="compact-input" v-model="scanCode" placeholder="请扫描材料纸质标签" prefix-icon="el-icon-search"
@keyup.enter.native="handleScan" ref="scanInput" />
<div class="mode-switch">
<el-switch class="custom-switch" v-model="isRemoveMode" active-color="#ff4949" inactive-color="#13ce66">
</el-switch>
<span v-if="isRemoveMode" class="switch-text">{{ '移除' }}</span>
<span v-else class="switch-text2">{{ '添加' }}</span>
</div>
</div>
<!-- 是否部分勾选框 -->
<div class="partial-checkbox-container">
<el-checkbox v-model="isPartial" :disabled="scannedLabels.length > 0">是否部分领料</el-checkbox>
</div>
<!-- 统一滚动容器 -->
<div class="scrollable-content">
<!-- 工单物料信息 -->
<div class="work-order-list" v-if="workOrderNo && componentPartNo">
<div class="work-order-card">
<div class="card-title">
<span class="title-label">工单号:{{ workOrderNo }}&nbsp;&nbsp;行号:{{itemNo}}</span>
</div>
<!-- 物料描述单独一行 -->
<div class="part-desc-row">
<span class="desc-text">物料编码:{{ componentPartNo }}</span>
</div>
<div class="part-desc-row">
<span class="desc-text">物料名称:{{ componentPartDesc }}</span>
</div>
<div class="card-details">
<div class="detail-item">
<div class="detail-label">需求数量</div>
<div class="detail-value">{{ requiredQty }}</div>
</div>
<div class="detail-item">
<div class="detail-label">已发数量</div>
<div class="detail-value">{{ issuedQty }}</div>
</div>
<div class="detail-item">
<div class="detail-label">本次</div>
<div class="detail-value">{{ totalScannedQty }}</div>
</div>
</div>
</div>
</div>
<div class="section-title">
<div class="title-left">
<i class="el-icon-circle-check"></i>
<span>出库信息确认</span>
</div>
</div>
<!-- 标签列表 -->
<div class="label-list">
<div class="list-header">
<div class="col-no">NO.</div>
<div class="col-label">标签条码</div>
<div class="col-batch">库位</div>
<div class="col-batch">批次号</div>
<div v-if="isPartial" class="col-qty">剩余高</div>
<div class="col-qty">数量</div>
</div>
<div class="list-body">
<div v-for="(label, index) in scannedLabels" :key="label.id" class="list-item"
:class="{ 'clickable': isPartial }" @click="isPartial ? handleLabelClick(label, index) : null">
<div class="col-no">{{ index+1 }}</div>
<div class="col-label">{{ label.labelCode }}</div>
<div class="col-batch">{{label.locationId}}</div>
<div class="col-batch">{{ label.batchNo }}</div>
<div v-if="isPartial" class="col-qty">{{ label.height.toFixed(3) }}</div>
<div class="col-qty">
<span class="quantity-display">{{ label.quantity }}</span>
<i v-if="isPartial" class="el-icon-edit edit-icon"></i>
</div>
</div>
<div v-if="scannedLabels.length === 0" class="empty-labels">
<p>暂无扫描标签</p>
</div>
</div>
</div>
</div>
<!-- 底部操作按钮 -->
<div class="bottom-actions">
<el-button class="action-btn secondary" :loading="loading" @click="confirmIssue">
确定
</el-button>
<!-- <button class="action-btn secondary" style="margin-left: 10px;">
打印
</button> -->
<button class="action-btn secondary" style="margin-left: 10px;" @click="clearScannedLabels">
取消
</button>
</div>
<!-- 修改数量弹框 -->
<div v-if="quantityDialogVisible" class="edit-overlay" @click.self="quantityDialogVisible = false">
<div class="edit-modal">
<div class="modal-header">
<span class="modal-title">修改数量</span>
<i class="el-icon-close close-btn" @click="quantityDialogVisible = false"></i>
</div>
<div class="modal-body">
<div class="form-group">
<label class="form-label">标签条码</label>
<el-input v-model="currentEditLabel.labelCode" disabled class="form-input" />
</div>
<div class="form-group">
<label class="form-label">当前数量</label>
<el-input v-model="currentEditLabel.quantity" disabled class="form-input" />
</div>
<div class="form-group">
<label class="form-label">剩余高度(mm) <span class="required">*</span></label>
<el-input-number v-model="editHeight" :min="0.001" :precision="3" :step="0.001" class="form-input"
style="width: 100%;" :controls="false">
</el-input-number>
</div>
<div class="form-group">
<label class="form-label">需要发料数量 <span class="required">*</span></label>
<el-input-number v-model="editQuantity" :min="0.0001" :precision="4" :step="0.0001" class="form-input"
style="width: 100%;" :controls="false">
</el-input-number>
</div>
</div>
<div class="modal-footer">
<button class="btn-cancel" @click="quantityDialogVisible = false">取消</button>
<button class="btn-confirm" @click="confirmQuantityChange">确定</button>
</div>
</div>
</div>
</div>
</template>
<script>
import {
scanMaterialLabelIssue,
confirmDirectIssue,
} from '@/api/production/production-issue'
import moment from 'moment'
export default {
data() {
return {
scanCode: '',
isRemoveMode: false,
isPartial: true,
scannedLabels: [],
workOrderNo: '',
componentPartNo: '',
componentPartDesc: '',
requiredQty: 0,
issuedQty: 0,
itemNo: '',
site: '',
loading: false,
issueInfo: {},
quantityDialogVisible: false,
currentEditLabel: {},
currentEditIndex: -1,
editQuantity: 0,
editHeight: 0,
}
},
computed: {
totalScannedQty() {
const total = this.scannedLabels.reduce((sum, l) => sum + (l.quantity || 0), 0)
// 处理浮点数精度问题,保留4位小数
return Math.round(total * 10000) / 10000
},
},
methods: {
formatDate(date) {
return date ? moment(date).format('YYYY-MM-DD') : ''
},
handleScan() {
if (!this.scanCode.trim()) return
if (this.isRemoveMode) {
this.removeLabelByCode(this.scanCode.trim())
} else {
this.validateAndAddLabel(this.scanCode.trim())
}
this.scanCode = ''
},
validateAndAddLabel(labelCode) {
const params = {
scannedLabel: labelCode,
workOrderNo: this.workOrderNo,
componentPartNo: this.componentPartNo,
site: this.site,
}
scanMaterialLabelIssue(params)
.then(({ data }) => {
if (data && data.code === 0) {
const exists = this.scannedLabels.find(
(item) => item.labelCode === labelCode
)
if (exists) {
this.$message.warning('该标签已扫描,请勿重复扫描')
return
}
/* if (data.labelInfo.materialCode !== this.materialCode) {
this.$message.error('标签物料编码与选择的材料不匹配')
return
} */
const newLabel = {
id: Date.now(),
labelCode,
componentPartNo: data.labelInfo.partNo,
quantity: data.labelInfo.availableQty,
batchNo: data.labelInfo.batchNo,
warehouseId: data.labelInfo.warehouseId,
locationId: data.labelInfo.locationId,
height: data.labelInfo.height || 0,
wdrNo: data.labelInfo.wdrNo,
engChgLevel: data.labelInfo.engChgLevel,
}
this.scannedLabels.push(newLabel)
console.log(this.scannedLabels)
this.$message.success('扫描成功')
// 如果勾选了"是否部分",添加后直接弹出修改数量弹框
if (this.isPartial) {
const newIndex = this.scannedLabels.length - 1
this.$nextTick(() => {
this.handleLabelClick(newLabel, newIndex)
})
}
} else {
this.$message.error(data.msg || '标签验证失败')
}
})
.catch(() => {
this.$message.error('扫描失败')
})
},
removeLabelByCode(labelCode) {
const index = this.scannedLabels.findIndex(
(item) => item.labelCode === labelCode
)
if (index !== -1) {
this.scannedLabels.splice(index, 1)
this.$message.success('移除成功')
} else {
this.$message.warning('未找到该标签')
}
},
clearScannedLabels() {
if (this.scannedLabels.length > 0) {
this.$confirm('确定清空所有已扫描的标签吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
this.scannedLabels = []
// 设置标记,表示需要恢复directIssue页面的状态
sessionStorage.setItem('directIssue_shouldRestore', 'true')
this.$router.back()
this.$message.success('已清空')
})
.catch(() => {})
} else {
// 设置标记,表示需要恢复directIssue页面的状态
sessionStorage.setItem('directIssue_shouldRestore', 'true')
this.$router.back()
}
},
confirmIssue() {
console.log('1231', localStorage.getItem('userName'))
if (this.scannedLabels.length === 0) {
this.$message.warning('请先扫描材料标签')
return
}
const params = {
site: this.site,
workOrderNo: this.workOrderNo,
componentPartNo: this.componentPartNo,
operatorName: localStorage.getItem('userName'),
itemNo: this.itemNo,
releaseNo: this.issueInfo.releaseNo,
sequenceNo: this.issueInfo.sequenceNo,
isPartial: this.isPartial,
selectedMaterials: this.scannedLabels.map((l, i) => ({
labelCode: l.labelCode,
issueQty: l.quantity,
batchNo: l.batchNo,
warehouseId: l.warehouseId,
locationId: l.locationId,
materialCode: l.materialCode,
wdrNo: l.wdrNo,
height: l.height,
engChgLevel: l.engChgLevel,
})),
}
this.loading = true
confirmDirectIssue(params)
.then(({ data }) => {
if (data && data.code === 0) {
this.$message.success('发料成功')
// 设置标记,表示需要恢复directIssue页面的状态,并刷新材料列表
sessionStorage.setItem('directIssue_shouldRestore', 'true')
sessionStorage.setItem('directIssue_needRefresh', 'true')
this.$router.back()
} else {
this.$message.error(data.msg || '发料失败')
}
})
.catch(() => {
this.$message.error('发料失败')
})
.finally(() => {
this.loading = false
})
},
initFromRoute() {
this.workOrderNo = this.$route.query.workOrderNo
this.componentPartNo = this.$route.query.partNo
this.componentPartDesc = this.$route.query.partDesc || ''
this.requiredQty = Number(this.$route.query.requiredQty || 0)
this.issuedQty = Number(this.$route.query.issuedQty || 0)
this.itemNo = this.$route.query.itemNo || ''
this.site = this.$route.query.site || ''
this.issueInfo = {
releaseNo: this.$route.query.releaseNo,
sequenceNo: this.$route.query.sequenceNo,
requiredQty: Number(this.$route.query.requiredQty || 0),
issuedQty: Number(this.$route.query.issuedQty || 0),
partDesc: this.$route.query.partDesc || '',
}
/* if (!this.workOrderNo || !this.materialCode) {
this.$message.error('参数错误')
this.$router.back()
} */
},
// 处理返回操作(头部返回按钮)
handleBack() {
// 设置标记,表示需要恢复directIssue页面的状态
sessionStorage.setItem('directIssue_shouldRestore', 'true')
this.$router.back()
},
// 处理标签点击事件
handleLabelClick(label, index) {
if (!this.isPartial) return
this.currentEditLabel = { ...label }
this.currentEditIndex = index
this.editHeight = label.height
this.editQuantity = label.quantity
this.quantityDialogVisible = true
},
// 确认修改数量
confirmQuantityChange() {
if (this.editHeight < 0) {
this.$message.warning('高度不能小于0')
return
}
if (this.editQuantity <= 0) {
this.$message.warning('数量必须大于0')
return
}
if (
this.currentEditIndex >= 0 &&
this.currentEditIndex < this.scannedLabels.length
) {
this.scannedLabels[this.currentEditIndex].quantity = this.editQuantity
this.scannedLabels[this.currentEditIndex].height = this.editHeight
this.$message.success('数量修改成功')
this.quantityDialogVisible = false
}
},
},
mounted() {
this.initFromRoute()
this.$nextTick(() => {
if (this.$refs.scanInput) {
this.$refs.scanInput.focus()
}
})
},
}
</script>
<style scoped>
.pda-container {
width: 100vw;
height: 100vh;
display: flex;
flex-direction: column;
background: #f5f5f5;
}
.header-bar {
display: flex;
justify-content: space-between;
align-items: center;
padding: 8px 16px;
background: #17b3a3;
color: white;
height: 40px;
min-height: 40px;
}
.header-left {
display: flex;
align-items: center;
cursor: pointer;
font-size: 16px;
font-weight: 500;
}
.header-left i {
margin-right: 8px;
font-size: 18px;
}
.header-right {
cursor: pointer;
font-size: 16px;
font-weight: 500;
}
.search-container {
padding: 12px 16px;
background: white;
display: flex;
align-items: center;
gap: 12px;
}
.search-container .el-input {
width: 240px;
margin-right: 12px;
}
.compact-input ::v-deep .el-input__inner {
height: 36px;
padding: 0 12px 0 35px;
font-size: 14px;
}
.compact-input ::v-deep .el-input__prefix {
left: 10px;
}
.compact-input ::v-deep .el-input__suffix {
right: 30px;
}
.mode-switch {
position: relative;
display: inline-block;
}
.custom-switch {
transform: scale(1.3);
}
.partial-checkbox-container {
padding: 8px 16px;
background: white;
border-top: 1px solid #f0f0f0;
display: flex;
align-items: center;
}
.partial-checkbox-container ::v-deep .el-checkbox__label {
font-size: 14px;
color: #333;
}
.switch-text {
position: absolute;
left: 25%;
transform: translateX(-50%);
top: 50%;
transform: translateY(-50%) translateX(-50%);
font-size: 12px;
font-weight: 500;
color: #606266;
white-space: nowrap;
pointer-events: none;
z-index: 1;
top: 53%;
transform: translate(-50%, -50%);
font-size: 12px;
font-weight: bold;
color: white;
pointer-events: none;
z-index: 2;
}
.switch-text2 {
position: absolute;
left: 75%;
transform: translateX(-50%);
top: 50%;
transform: translateY(-50%) translateX(-50%);
font-size: 12px;
font-weight: 500;
color: #606266;
white-space: nowrap;
pointer-events: none;
z-index: 1;
top: 53%;
transform: translate(-50%, -50%);
font-size: 12px;
font-weight: bold;
color: white;
pointer-events: none;
z-index: 2;
}
/* 调整 switch 尺寸以便容纳文字 */
.custom-switch ::v-deep .el-switch__core {
width: 60px;
height: 28px;
}
/* 统一滚动容器 */
.scrollable-content {
flex: 1;
overflow-y: auto;
min-height: 0;
}
/* 工单列表 */
.work-order-list {
padding: 12px 16px;
}
/* 工单卡片 */
.work-order-card {
background: white;
border-radius: 8px;
padding: 16px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
cursor: pointer;
transition: all 0.2s ease;
border: 2px solid transparent;
}
.work-order-card:hover {
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
transform: translateY(-1px);
}
.work-order-card.selected {
border-color: #17b3a3;
background: #f0fffe;
}
.work-order-card:active {
transform: translateY(0);
}
/* 卡片标题 */
.card-title {
margin-bottom: 12px;
}
.title-label {
font-size: 12px;
color: #666;
display: block;
margin-bottom: 4px;
}
.title-value {
font-size: 16px;
font-weight: bold;
color: #333;
margin-left: 20px;
}
.section-title {
display: flex;
align-items: center;
justify-content: space-between;
padding: 6px 8px;
background: white;
margin: 0 8px;
margin-top: 4px;
border-radius: 8px 8px 0 0;
border-bottom: 2px solid #17b3a3;
}
/* 物料描述行 */
.part-desc-row {
margin-bottom: 12px;
padding: 0 4px;
}
.desc-text {
font-size: 12px;
color: #666;
line-height: 1.3;
word-break: break-all;
}
/* 卡片详情 */
.card-details {
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 4px;
}
.detail-item {
flex: 1;
text-align: center;
min-width: 50px;
max-width: 70px;
}
.detail-label {
font-size: 11px;
color: #666;
margin-bottom: 4px;
line-height: 1.2;
margin-left: -12px;
}
.detail-value {
font-size: 13px;
color: #333;
line-height: 1.2;
margin-left: -12px;
}
.label-list {
background: white;
margin: 0 16px 12px;
border-radius: 8px;
overflow: hidden;
display: flex;
flex-direction: column;
}
.list-header {
display: flex;
background: #f8f9fa;
padding: 12px 8px;
border-bottom: 1px solid #e0e0e0;
font-size: 12px;
color: #666;
font-weight: 500;
flex-shrink: 0;
}
.list-body {
flex: 1;
min-height: 0;
}
.list-item {
display: flex;
padding: 12px 8px;
border-bottom: 1px solid #f0f0f0;
font-size: 12px;
color: #333;
align-items: flex-start;
min-height: 40px;
transition: background-color 0.2s;
}
.list-item:last-child {
border-bottom: none;
}
.list-item.clickable {
cursor: pointer;
}
.list-item.clickable:hover {
background-color: #f5f5f5;
}
.list-item.clickable:active {
background-color: #e8e8e8;
}
.col-no {
width: 10px;
text-align: center;
}
.col-label {
flex: 1;
text-align: center;
word-break: break-all;
white-space: normal;
line-height: 1.2;
}
.col-batch {
flex: 1;
text-align: center;
}
.col-qty {
flex: 0.6;
width: 60px;
text-align: center;
}
.empty-labels {
padding: 40px 20px;
text-align: center;
color: #999;
}
.bottom-actions {
display: flex;
padding: 16px;
gap: 20px;
background: white;
margin-top: auto;
}
.action-btn {
flex: 1;
padding: 12px;
border: 1px solid #17b3a3;
background: white;
color: #17b3a3;
border-radius: 20px;
font-size: 14px;
cursor: pointer;
transition: all 0.2s ease;
}
.action-btn:hover {
background: #17b3a3;
color: white;
}
.action-btn:active {
transform: scale(0.98);
}
/* 编辑弹框样式 */
.edit-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
.edit-modal {
background: white;
border-radius: 12px;
width: 100%;
max-width: 400px;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
overflow: hidden;
display: flex;
flex-direction: column;
}
.edit-modal .modal-header {
background: #17b3a3;
color: white;
padding: 12px 16px;
display: flex;
justify-content: space-between;
align-items: center;
}
.edit-modal .modal-title {
font-size: 16px;
font-weight: 500;
margin: 0;
}
.edit-modal .close-btn {
font-size: 16px;
cursor: pointer;
color: white;
transition: color 0.2s ease;
padding: 4px;
display: flex;
align-items: center;
justify-content: center;
}
.edit-modal .close-btn:hover {
color: #e0e0e0;
}
.edit-modal .modal-body {
padding: 20px;
}
.edit-modal .form-group {
margin-bottom: 16px;
}
.edit-modal .form-group:last-child {
margin-bottom: 0;
}
.edit-modal .form-label {
display: block;
font-size: 14px;
color: #333;
margin-bottom: 6px;
font-weight: 500;
}
.edit-modal .required {
color: #ff4949;
}
.edit-modal .form-input {
width: 100%;
}
.edit-modal .form-input ::v-deep .el-input__inner {
height: 40px;
border: 2px solid #dcdfe6;
border-radius: 6px;
font-size: 14px;
padding: 0 12px;
}
.edit-modal .form-input ::v-deep .el-input__inner:focus {
border-color: #17b3a3;
outline: none;
}
.edit-modal .form-input ::v-deep .el-input__inner:disabled {
background: #f5f7fa;
color: #c0c4cc;
border-color: #e4e7ed;
}
.edit-modal .form-input ::v-deep .el-input-number {
width: 100%;
}
.edit-modal .form-input ::v-deep .el-input-number .el-input__inner {
height: 40px;
border: 2px solid #dcdfe6;
border-radius: 6px;
font-size: 14px;
padding: 0 12px;
}
.edit-modal .form-input ::v-deep .el-input-number .el-input__inner:focus {
border-color: #17b3a3;
outline: none;
}
.edit-modal .modal-footer {
padding: 16px 20px;
display: flex;
gap: 12px;
justify-content: flex-end;
border-top: 1px solid #f0f0f0;
}
.edit-modal .btn-cancel {
padding: 10px 20px;
border-radius: 6px;
font-size: 14px;
cursor: pointer;
transition: all 0.2s;
border: 1px solid #dcdfe6;
background: white;
color: #606266;
}
.edit-modal .btn-cancel:hover {
background: #f5f7fa;
border-color: #c0c4cc;
}
.edit-modal .btn-confirm {
padding: 10px 20px;
border-radius: 6px;
font-size: 14px;
cursor: pointer;
transition: all 0.2s;
border: 1px solid #17b3a3;
background: #17b3a3;
color: white;
}
.edit-modal .btn-confirm:hover {
background: #13998c;
border-color: #13998c;
}
@media (max-width: 360px) {
.header-bar {
padding: 8px 12px;
}
.search-container {
padding: 8px 12px;
}
.work-order-list {
padding: 8px 12px;
}
.work-order-card {
padding: 12px;
}
.card-details {
flex-wrap: wrap;
gap: 6px;
}
.detail-item {
flex: 0 0 48%;
margin-bottom: 6px;
min-width: 50px;
}
.label-list {
margin: 0 8px 8px;
}
}
</style>