|
|
|
@ -16,7 +16,6 @@ |
|
|
|
<div class="main-content form-section"> |
|
|
|
<!-- 标签扫描输入框 --> |
|
|
|
<div class="input-group"> |
|
|
|
<label class="input-label">标签编码</label> |
|
|
|
<el-input |
|
|
|
v-model="labelCode" |
|
|
|
placeholder="请扫描标签编码" |
|
|
|
@ -36,6 +35,14 @@ |
|
|
|
<div class="info-title"> |
|
|
|
<i class="el-icon-document"></i> |
|
|
|
<span>标签信息</span> |
|
|
|
<button |
|
|
|
class="print-btn" |
|
|
|
@click="handlePrint" |
|
|
|
:disabled="printLoading" |
|
|
|
> |
|
|
|
<i :class="printLoading ? 'el-icon-loading' : 'el-icon-printer'"></i> |
|
|
|
{{ printLoading ? '打印中...' : '打印' }} |
|
|
|
</button> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="info-row"> |
|
|
|
@ -97,6 +104,7 @@ |
|
|
|
|
|
|
|
<script> |
|
|
|
import { queryLabelInfo } from '@/api/inventory/label' |
|
|
|
import { printLabelCommon } from '@/api/production/production-inbound.js' |
|
|
|
|
|
|
|
export default { |
|
|
|
name: 'LabelQuery', |
|
|
|
@ -106,7 +114,8 @@ export default { |
|
|
|
site: localStorage.getItem('site'), |
|
|
|
labelCode: '', |
|
|
|
labelInfo: null, |
|
|
|
loading: false |
|
|
|
loading: false, |
|
|
|
printLoading: false |
|
|
|
}; |
|
|
|
}, |
|
|
|
|
|
|
|
@ -195,6 +204,62 @@ export default { |
|
|
|
*/ |
|
|
|
getStatusType(inStockFlag) { |
|
|
|
return inStockFlag === 'Y' ? 'success' : 'danger'; |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 处理打印 |
|
|
|
*/ |
|
|
|
handlePrint() { |
|
|
|
if (!this.labelInfo || !this.labelInfo.unitId) { |
|
|
|
this.$message.error('没有可打印的标签信息'); |
|
|
|
return; |
|
|
|
} |
|
|
|
let printLabelType; |
|
|
|
if (this.labelInfo.partNo && this.labelInfo.partNo.startsWith("80")) { |
|
|
|
printLabelType = '库存成品标签'; |
|
|
|
} else { |
|
|
|
printLabelType = 'BIL标签'; |
|
|
|
} |
|
|
|
// 调用打印方法,传入unitId数组和标签类型 |
|
|
|
this.printViaServer([this.labelInfo.unitId], printLabelType); |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 通过服务器打印 |
|
|
|
* @param {Array} unitIds - HU unitId列表 |
|
|
|
* @param {String} printLabelType - 标签类型 |
|
|
|
*/ |
|
|
|
async printViaServer(unitIds, printLabelType) { |
|
|
|
if (!unitIds || unitIds.length === 0) { |
|
|
|
console.warn('没有可打印的标签'); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
this.printLoading = true; |
|
|
|
|
|
|
|
try { |
|
|
|
const printRequest = { |
|
|
|
userId: localStorage.getItem('userName'), |
|
|
|
username: localStorage.getItem('userName'), |
|
|
|
site: localStorage.getItem('site'), |
|
|
|
unitIds: unitIds, |
|
|
|
labelType: printLabelType |
|
|
|
}; |
|
|
|
console.log('打印请求:', printRequest); |
|
|
|
|
|
|
|
const { data } = await printLabelCommon(printRequest); |
|
|
|
|
|
|
|
if (data.code === 200 || data.code === 0) { |
|
|
|
this.$message.success(`打印任务已发送!`); |
|
|
|
} else { |
|
|
|
this.$message.error(data.msg || '打印失败'); |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.error('服务器打印失败:', error); |
|
|
|
this.$message.error(`打印失败: ${error.message || error}`); |
|
|
|
} finally { |
|
|
|
this.printLoading = false; |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
@ -288,6 +353,7 @@ export default { |
|
|
|
.info-title { |
|
|
|
display: flex; |
|
|
|
align-items: center; |
|
|
|
justify-content: space-between; |
|
|
|
font-size: 16px; |
|
|
|
font-weight: bold; |
|
|
|
color: #17B3A3; |
|
|
|
@ -301,6 +367,43 @@ export default { |
|
|
|
font-size: 18px; |
|
|
|
} |
|
|
|
|
|
|
|
/* 打印按钮 */ |
|
|
|
.print-btn { |
|
|
|
display: flex; |
|
|
|
align-items: center; |
|
|
|
gap: 4px; |
|
|
|
padding: 6px 12px; |
|
|
|
background: #17B3A3; |
|
|
|
color: white; |
|
|
|
border: none; |
|
|
|
border-radius: 4px; |
|
|
|
font-size: 14px; |
|
|
|
cursor: pointer; |
|
|
|
transition: all 0.2s; |
|
|
|
white-space: nowrap; |
|
|
|
} |
|
|
|
|
|
|
|
.print-btn:hover:not(:disabled) { |
|
|
|
background: #15a394; |
|
|
|
transform: translateY(-1px); |
|
|
|
box-shadow: 0 2px 8px rgba(23, 179, 163, 0.3); |
|
|
|
} |
|
|
|
|
|
|
|
.print-btn:active:not(:disabled) { |
|
|
|
transform: translateY(0); |
|
|
|
} |
|
|
|
|
|
|
|
.print-btn:disabled { |
|
|
|
background: #ccc; |
|
|
|
cursor: not-allowed; |
|
|
|
opacity: 0.6; |
|
|
|
} |
|
|
|
|
|
|
|
.print-btn i { |
|
|
|
margin-right: 0; |
|
|
|
font-size: 16px; |
|
|
|
} |
|
|
|
|
|
|
|
.info-row { |
|
|
|
display: flex; |
|
|
|
justify-content: space-between; |
|
|
|
|