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.
554 lines
14 KiB
554 lines
14 KiB
<template>
|
|
<div class="pda-container">
|
|
<!-- 头部栏 -->
|
|
<div class="header-bar">
|
|
<div class="header-left" @click="$router.back()">
|
|
<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="work-order-list" v-if="outsourcingNo && componentPartNo">
|
|
<div class="work-order-card">
|
|
<div class="card-title">
|
|
<span class="title-label">委外订单号:{{ outsourcingNo }}</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 class="col-qty">数量</div>
|
|
</div>
|
|
|
|
<div v-for="(label, index) in scannedLabels" :key="label.id" class="list-item">
|
|
<div class="col-no">{{ index+1 }}</div>
|
|
<div class="col-label">{{ label.labelCode }}</div>
|
|
<div class="col-batch">{{label.warehouseId}}</div>
|
|
<div class="col-batch">{{ label.batchNo || '-' }}</div>
|
|
<div class="col-qty">{{ label.quantity }}</div>
|
|
</div>
|
|
|
|
<div v-if="scannedLabels.length === 0" class="empty-labels">
|
|
<p>暂无扫描标签</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 底部操作按钮 -->
|
|
<div class="bottom-actions">
|
|
<el-button class="action-btn secondary" :loading="loading" @click="confirmIssue" :disabled="scannedLabels.length === 0">
|
|
确定
|
|
</el-button>
|
|
<button class="action-btn secondary" style="margin-left: 10px;" @click="clearScannedLabels">
|
|
取消
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
import moment from 'moment'
|
|
import {
|
|
scanOutsourcingMaterialLabel,
|
|
confirmOutsourcingDirectIssue,
|
|
} from '@/api/outsourcing/outsourcing-issue'
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
scanCode: '',
|
|
isRemoveMode: false,
|
|
scannedLabels: [],
|
|
outsourcingNo: '',
|
|
componentPartNo: '',
|
|
componentPartDesc: '',
|
|
requiredQty: 0,
|
|
issuedQty: 0,
|
|
itemNo: '',
|
|
loading: false,
|
|
partNo:'',
|
|
releaseNo:'',
|
|
lineNo:''
|
|
}
|
|
},
|
|
computed: {
|
|
totalScannedQty() {
|
|
return this.scannedLabels.reduce((sum, l) => sum + (l.quantity || 0), 0)
|
|
},
|
|
},
|
|
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,
|
|
outsourcingNo: this.outsourcingNo,
|
|
componentPartNo: this.componentPartNo,
|
|
site: localStorage.getItem('site'),
|
|
}
|
|
scanOutsourcingMaterialLabel(params)
|
|
.then(({ data }) => {
|
|
if (data && data.code === 0) {
|
|
const exists = this.scannedLabels.find(
|
|
(item) => item.labelCode === labelCode
|
|
)
|
|
if (exists) {
|
|
this.$message.warning('该标签已扫描,请勿重复扫描')
|
|
return
|
|
}
|
|
this.scannedLabels.push({
|
|
id: Date.now(),
|
|
labelCode,
|
|
componentPartNo: data.labelInfo.partNo,
|
|
quantity: data.labelInfo.availableQty,
|
|
batchNo: data.labelInfo.batchNo,
|
|
warehouseId: data.labelInfo.warehouseId,
|
|
locationId: data.labelInfo.locationId,
|
|
})
|
|
this.$message.success('扫描成功')
|
|
} 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 = []
|
|
this.$router.back()
|
|
this.$message.success('已清空')
|
|
})
|
|
.catch(() => {})
|
|
} else {
|
|
this.$router.back()
|
|
}
|
|
},
|
|
confirmIssue() {
|
|
if (this.scannedLabels.length === 0) {
|
|
this.$message.warning('请先扫描材料标签')
|
|
return
|
|
}
|
|
|
|
const params = {
|
|
site: localStorage.getItem('site'),
|
|
orderNo: this.outsourcingNo,
|
|
componentPartNo: this.componentPartNo,
|
|
operatorName: localStorage.getItem('userName'),
|
|
itemNo: this.itemNo,
|
|
releaseNo: this.releaseNo,
|
|
lineNo: this.lineNo,
|
|
selectedMaterials: this.scannedLabels.map((l, i) => ({
|
|
labelCode: l.labelCode,
|
|
issueQty: l.quantity,
|
|
batchNo: l.batchNo,
|
|
warehouseId: l.warehouseId,
|
|
locationId: l.locationId,
|
|
materialCode: l.componentPartNo,
|
|
wdrNo: l.wdr
|
|
})),
|
|
}
|
|
this.loading = true
|
|
confirmOutsourcingDirectIssue(params)
|
|
.then(({ data }) => {
|
|
if (data && data.code === 0) {
|
|
this.$message.success('委外发料成功')
|
|
this.$router.back()
|
|
} else {
|
|
this.$message.error(data.msg || '委外发料失败')
|
|
}
|
|
})
|
|
.catch(() => {
|
|
this.$message.error('委外发料失败')
|
|
}).finally(()=>{
|
|
this.loading = false
|
|
})
|
|
},
|
|
initFromRoute() {
|
|
this.outsourcingNo = this.$route.params.outsourcingNo
|
|
this.partNo = this.$route.params.partNo
|
|
|
|
// 如果存在发料记录信息,从中获取详细信息
|
|
const issueRecord = this.$route.params.issueRecord
|
|
if (issueRecord) {
|
|
this.componentPartNo = issueRecord.componentPartNo
|
|
this.componentPartDesc = issueRecord.componentPartDescription || ''
|
|
this.requiredQty = Number(issueRecord.requiredQty || this.$route.params.requiredQty || 0)
|
|
this.issuedQty = Number(issueRecord.issuedQty || 0)
|
|
this.releaseNo = issueRecord.releaseNo
|
|
this.lineNo = issueRecord.lineNo
|
|
this.itemNo = issueRecord.lineItemNo
|
|
} else {
|
|
// 兼容旧的参数结构
|
|
this.componentPartNo = issueRecord.componentPartNo
|
|
this.componentPartDesc = this.$route.params.componentPartDescription || ''
|
|
this.requiredQty = Number(this.$route.params.requiredQty || 0)
|
|
this.issuedQty = Number(this.$route.params.issuedQty || 0)
|
|
this.releaseNo = this.$route.params.releaseNo
|
|
this.lineNo = this.$route.params.lineNo
|
|
this.itemNo = this.$route.params.lineItemNo
|
|
}
|
|
},
|
|
},
|
|
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);
|
|
}
|
|
.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;
|
|
}
|
|
.custom-switch ::v-deep .el-switch__core {
|
|
width: 60px;
|
|
height: 28px;
|
|
}
|
|
.work-order-list {
|
|
overflow-y: auto;
|
|
padding: 12px 16px;
|
|
}
|
|
.work-order-card {
|
|
background: white;
|
|
border-radius: 8px;
|
|
margin-bottom: 12px;
|
|
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 10px;
|
|
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 10px 12px;
|
|
border-radius: 8px;
|
|
overflow: hidden;
|
|
}
|
|
.list-header {
|
|
display: flex;
|
|
background: #f8f9fa;
|
|
padding: 12px 8px;
|
|
border-bottom: 1px solid #e0e0e0;
|
|
font-size: 12px;
|
|
color: #666;
|
|
font-weight: 500;
|
|
}
|
|
.list-item {
|
|
display: flex;
|
|
padding: 12px 8px;
|
|
border-bottom: 1px solid #f0f0f0;
|
|
font-size: 12px;
|
|
color: #333;
|
|
}
|
|
.list-item:last-child {
|
|
border-bottom: none;
|
|
}
|
|
.col-no {
|
|
width: 20px;
|
|
text-align: center;
|
|
}
|
|
.col-label {
|
|
flex: 2;
|
|
text-align: center;
|
|
}
|
|
.col-batch {
|
|
flex: 1;
|
|
text-align: center;
|
|
}
|
|
.col-qty {
|
|
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);
|
|
}
|
|
@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 12px 8px; }
|
|
}
|
|
</style>
|
|
|
|
|