Browse Source

打印标签修改

master
shenzhouyu 2 days ago
parent
commit
0edb797447
  1. 344
      src/views/modules/shipment/shipmentNotification.vue

344
src/views/modules/shipment/shipmentNotification.vue

@ -664,9 +664,6 @@
<el-button type="primary" :loading="shipmentLineLoading" @click="searchShipmentLineByDialog">查询</el-button> <el-button type="primary" :loading="shipmentLineLoading" @click="searchShipmentLineByDialog">查询</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div v-if="currentShipmentId" style="margin-bottom: 8px; font-size: 12px;">
当前SHIPMENTID{{ currentShipmentId }}
</div>
<el-table <el-table
:data="shipmentLineList" :data="shipmentLineList"
height="420" height="420"
@ -706,43 +703,48 @@
<el-dialog <el-dialog
title="标签打印设置" title="标签打印设置"
:visible.sync="shipmentLinePrintDialogVisible" :visible.sync="shipmentLinePrintDialogVisible"
width="480px"
width="620px"
:close-on-click-modal="false" :close-on-click-modal="false"
append-to-body append-to-body
@close="resetShipmentLinePrintForm" @close="resetShipmentLinePrintForm"
> >
<el-alert
type="info"
:closable="false"
show-icon
:title="`已选择 1 个标签,请配置打印参数`"
style="margin-bottom: 16px;"
/>
<el-form label-position="top" size="small" class="shipment-line-print-form"> <el-form label-position="top" size="small" class="shipment-line-print-form">
<div class="print-qty-row">
<div class="print-qty-item">
<span class="print-qty-label">打印份数</span>
<el-input
v-model="printForm.copies"
:min="1"
:max="99"
controls-position="right"
class="print-input-number"
/>
<div class="print-input-grid">
<div class="print-input-field">
<span class="print-qty-label">发货数量</span>
<el-input v-model="printForm.outerTotal" placeholder="请输入发货数量" />
</div> </div>
<div class="print-qty-item">
<span class="print-qty-label">分配数量</span>
<el-input
v-model="printForm.assignQty"
:min="0"
:precision="2"
:step="1"
controls-position="right"
class="print-input-number"
/>
<div class="print-input-field">
<span class="print-qty-label">内箱数量</span>
<el-input v-model="printForm.innerPackQty" placeholder="请输入内箱数量" />
</div> </div>
<div class="print-input-field">
<span class="print-qty-label">每箱内包数</span>
<el-input v-model="printForm.boxPackCount" placeholder="请输入每箱内包数" />
</div>
</div>
<div class="form-hint">
每张外箱标签数量 = 每箱内包数 × 内箱数量外箱/内箱余数均单独成张标签
</div> </div>
<div class="form-hint">此数量为打印到标签上的数量</div>
<div class="print-result-panel">
<div class="print-result-title">计算结果不可修改</div>
<div class="print-result-block">
<div class="print-result-header">
<span>外箱标签</span>
<span class="print-result-count"> {{ calculatedOuterQtyList.length }} </span>
</div>
<div class="print-result-text">{{ formatLabelQtySummary(calculatedOuterQtyList) }}</div>
</div>
<div class="print-result-block">
<div class="print-result-header">
<span>内箱标签</span>
<span class="print-result-count"> {{ calculatedInnerQtyList.length }} </span>
</div>
<div class="print-result-text">{{ formatLabelQtySummary(calculatedInnerQtyList) }}</div>
</div>
</div>
<!-- 红框部分标签类型 / 模板 / 打印机 改为按 receiverId 自动匹配以下注释保留 --> <!-- 红框部分标签类型 / 模板 / 打印机 改为按 receiverId 自动匹配以下注释保留 -->
<!-- <!--
<el-form-item label="标签类型"> <el-form-item label="标签类型">
@ -790,15 +792,15 @@
<div class="shipment-line-print-summary"> <div class="shipment-line-print-summary">
<div class="summary-item"> <div class="summary-item">
<span class="summary-label">打印总数</span> <span class="summary-label">打印总数</span>
<span class="summary-value">{{ printForm.copies }} </span>
<span class="summary-value">{{ shipmentLinePrintTotal }} </span>
</div> </div>
<div class="summary-item"> <div class="summary-item">
<span class="summary-label">物料数量</span>
<span class="summary-value">1 </span>
<span class="summary-label">外箱标签</span>
<span class="summary-value">{{ calculatedOuterQtyList.length }} </span>
</div> </div>
<div class="summary-item"> <div class="summary-item">
<span class="summary-label">每标签份数</span>
<span class="summary-value">{{ printForm.copies }} </span>
<span class="summary-label">内箱标签</span>
<span class="summary-value">{{ calculatedInnerQtyList.length }} </span>
</div> </div>
</div> </div>
</el-form> </el-form>
@ -2042,6 +2044,7 @@ export default {
shipmentLineLoading: false, shipmentLineLoading: false,
currentShipmentId: '', currentShipmentId: '',
currentReceiverId: '', currentReceiverId: '',
currentReceiverAddress: '',
shipmentLineQueryDialogVisible: false, shipmentLineQueryDialogVisible: false,
dialogShipmentId: '', dialogShipmentId: '',
shipmentLinePrintDialogVisible: false, shipmentLinePrintDialogVisible: false,
@ -2051,8 +2054,9 @@ export default {
// labelTemplateList: [], // labelTemplateList: [],
// printerList: [], // printerList: [],
printForm: { printForm: {
copies: 1,
assignQty: 0,
outerTotal: '',
innerPackQty: '',
boxPackCount: '',
labelType: '外箱标签', labelType: '外箱标签',
reportId: '', reportId: '',
printerName: '', printerName: '',
@ -2172,10 +2176,31 @@ export default {
}, },
computed: { computed: {
calculatedOuterQtyList() {
const outerTotal = Number(this.printForm.outerTotal)
const innerPackQty = Number(this.printForm.innerPackQty)
const boxPackCount = Number(this.printForm.boxPackCount)
if (!(outerTotal > 0) || !(innerPackQty > 0) || !(boxPackCount > 0)) {
return []
}
const outerPackQty = this.multiplyQty(innerPackQty, boxPackCount)
return this.splitQtyToLabels(outerTotal, outerPackQty)
},
calculatedInnerQtyList() {
const outerTotal = Number(this.printForm.outerTotal)
const innerPackQty = Number(this.printForm.innerPackQty)
if (!(outerTotal > 0) || !(innerPackQty > 0)) {
return []
}
return this.splitQtyToLabels(outerTotal, innerPackQty)
},
shipmentLinePrintTotal() {
return this.calculatedOuterQtyList.length + this.calculatedInnerQtyList.length
},
canStartShipmentLinePrint() { canStartShipmentLinePrint() {
return !!( return !!(
this.printForm.copies > 0 &&
this.printForm.assignQty > 0 &&
this.calculatedOuterQtyList.length > 0 &&
this.calculatedInnerQtyList.length > 0 &&
this.printShipmentLineRow && this.printShipmentLineRow &&
this.currentReceiverId this.currentReceiverId
) )
@ -3271,25 +3296,36 @@ export default {
} }
this.currentShipmentId = shipmentId this.currentShipmentId = shipmentId
this.currentReceiverId = '' this.currentReceiverId = ''
this.currentReceiverAddress = ''
let receiverId = row.receiverId || row.RECEIVER_ID let receiverId = row.receiverId || row.RECEIVER_ID
if (!receiverId) {
receiverId = await this.fetchReceiverIdByShipment(shipmentId, row.site)
let receiverAddress = row.receiverAddress || row.RECEIVER_ADDRESS || ''
if (!receiverId || !receiverAddress) {
const shipmentInfo = await this.fetchShipmentReceiverInfo(shipmentId, row.site)
receiverId = receiverId || shipmentInfo.receiverId
receiverAddress = receiverAddress || shipmentInfo.receiverAddress
} }
if (!receiverId) { if (!receiverId) {
this.$message.warning('未获取到receiverId') this.$message.warning('未获取到receiverId')
} }
this.currentReceiverId = receiverId || '' this.currentReceiverId = receiverId || ''
this.currentReceiverAddress = receiverAddress || ''
this.loadShipmentLineList(row, true) this.loadShipmentLineList(row, true)
}, },
openShipmentLineQueryDialog() { openShipmentLineQueryDialog() {
this.resetShipmentLineQueryDialog()
this.shipmentLineQueryDialogVisible = true this.shipmentLineQueryDialogVisible = true
}, },
resetShipmentLineQueryDialog() { resetShipmentLineQueryDialog() {
this.dialogShipmentId = '' this.dialogShipmentId = ''
this.shipmentLineList = []
this.currentShipmentId = ''
this.currentReceiverId = ''
this.currentReceiverAddress = ''
this.shipmentLineLoading = false
}, },
async searchShipmentLineByDialog() { async searchShipmentLineByDialog() {
@ -3300,17 +3336,27 @@ export default {
} }
this.currentShipmentId = shipmentId this.currentShipmentId = shipmentId
this.currentReceiverId = '' this.currentReceiverId = ''
this.currentReceiverAddress = ''
this.shipmentLineList = []
const site = (this.currentRow && this.currentRow.site) || this.$store.state.user.site const site = (this.currentRow && this.currentRow.site) || this.$store.state.user.site
const receiverId = await this.fetchReceiverIdByShipment(shipmentId, site)
if (!receiverId) {
this.$message.warning('未获取到receiverId')
this.shipmentLineLoading = true
try {
const shipmentInfo = await this.fetchShipmentReceiverInfo(shipmentId, site)
if (!shipmentInfo.receiverId) {
this.$message.warning('未获取到receiverId')
}
this.currentReceiverId = shipmentInfo.receiverId || ''
this.currentReceiverAddress = shipmentInfo.receiverAddress || ''
await this.loadShipmentLineList({ soorderNo: shipmentId, site }, false)
} catch (e) {
this.shipmentLineList = []
this.$message.error('查询Shipment失败')
this.shipmentLineLoading = false
} }
this.currentReceiverId = receiverId || ''
this.loadShipmentLineList({ soorderNo: shipmentId, site }, false)
}, },
async fetchReceiverIdByShipment(shipmentId, site) {
async fetchShipmentReceiverInfo(shipmentId, site) {
try { try {
const querySite = site || (this.currentRow && this.currentRow.site) || this.$store.state.user.site const querySite = site || (this.currentRow && this.currentRow.site) || this.$store.state.user.site
const { data } = await getShipmentListForIssure({ const { data } = await getShipmentListForIssure({
@ -3321,12 +3367,18 @@ export default {
const matched = data.rows.find(item => const matched = data.rows.find(item =>
String(item.SHIPMENT_ID || item.shipmentId) === String(shipmentId) String(item.SHIPMENT_ID || item.shipmentId) === String(shipmentId)
) || data.rows[0] ) || data.rows[0]
return matched.receiverId || matched.RECEIVER_ID || ''
return {
receiverId: matched.receiverId || matched.RECEIVER_ID || '',
receiverAddress: matched.receiverAddress || matched.RECEIVER_ADDRESS || '',
}
} }
} catch (e) { } catch (e) {
this.$message.error('获取shipment信息失败') this.$message.error('获取shipment信息失败')
} }
return ''
return {
receiverId: '',
receiverAddress: '',
}
}, },
normalizeShipmentLineRow(row) { normalizeShipmentLineRow(row) {
@ -3352,7 +3404,7 @@ export default {
orderNo: row.soorderNo, orderNo: row.soorderNo,
} }
this.shipmentLineLoading = true this.shipmentLineLoading = true
getShipmentLine(params)
return getShipmentLine(params)
.then(({ data }) => { .then(({ data }) => {
if (data && data.code === 0) { if (data && data.code === 0) {
this.shipmentLineList = (data.rows || []).map(item => this.normalizeShipmentLineRow(item)) this.shipmentLineList = (data.rows || []).map(item => this.normalizeShipmentLineRow(item))
@ -3383,20 +3435,69 @@ export default {
} }
this.printShipmentLineRow = row this.printShipmentLineRow = row
this.resetShipmentLinePrintForm() this.resetShipmentLinePrintForm()
this.printForm.assignQty = row.qtyAssigned != null ? row.qtyAssigned : 0
this.printForm.outerTotal = row.qtyAssigned != null ? String(row.qtyAssigned) : ''
this.shipmentLinePrintDialogVisible = true this.shipmentLinePrintDialogVisible = true
}, },
resetShipmentLinePrintForm() { resetShipmentLinePrintForm() {
this.printForm = { this.printForm = {
copies: 1,
assignQty: 0,
outerTotal: '',
innerPackQty: '',
boxPackCount: '',
labelType: '外箱标签', labelType: '外箱标签',
reportId: '', reportId: '',
printerName: '', printerName: '',
} }
}, },
multiplyQty(a, b) {
const precision = 10000
return Math.round(Number(a) * Number(b) * precision) / precision
},
formatQtyValue(value) {
const num = Number(value)
if (Number.isNaN(num)) {
return ''
}
if (Number.isInteger(num)) {
return String(num)
}
return String(parseFloat(num.toFixed(4)))
},
//
splitQtyToLabels(totalQty, packQty) {
const total = Number(totalQty)
const pack = Number(packQty)
if (!(total > 0) || !(pack > 0)) {
return []
}
const labels = []
const fullCount = Math.floor(total / pack)
const remainder = this.multiplyQty(total - this.multiplyQty(fullCount, pack), 1)
for (let i = 0; i < fullCount; i++) {
labels.push(this.formatQtyValue(pack))
}
if (remainder > 0) {
labels.push(this.formatQtyValue(remainder))
}
return labels
},
formatLabelQtySummary(qtyList) {
if (!qtyList || !qtyList.length) {
return '请先完整输入外箱总数、内箱数量、每箱内包数'
}
const countMap = {}
qtyList.forEach(qty => {
countMap[qty] = (countMap[qty] || 0) + 1
})
return Object.keys(countMap)
.map(qty => `${countMap[qty]}张×${qty}`)
.join(',')
},
// / customerId(receiverId) // / customerId(receiverId)
// loadShipmentLinePrintOptions(row) { ... } // loadShipmentLinePrintOptions(row) { ... }
// loadLabelTemplateList(row) { ... } // loadLabelTemplateList(row) { ... }
@ -3407,7 +3508,8 @@ export default {
buildShipmentLinePrintRequest() { buildShipmentLinePrintRequest() {
const row = this.printShipmentLineRow const row = this.printShipmentLineRow
const customFields = { const customFields = {
QTY: this.printForm.assignQty,
// QTY
QTY: this.calculatedOuterQtyList.slice(),
} }
if (row.inventoryPartNo) { if (row.inventoryPartNo) {
customFields.partNo = row.inventoryPartNo customFields.partNo = row.inventoryPartNo
@ -3416,11 +3518,9 @@ export default {
customFields.partDesc = row.sourcePartDescription customFields.partDesc = row.sourcePartDescription
} }
// PrintLabelRequest / printLabelCommon
const printRequest = { const printRequest = {
reportId: this.printForm.reportId,
labelType: this.printForm.labelType,
printerName: this.printForm.printerName,
copies: this.printForm.copies,
labelType: this.printForm.labelType || '外箱标签',
site: (this.currentRow && this.currentRow.site) || this.$store.state.user.site, site: (this.currentRow && this.currentRow.site) || this.$store.state.user.site,
userId: localStorage.getItem('userName'), userId: localStorage.getItem('userName'),
username: localStorage.getItem('userName'), username: localStorage.getItem('userName'),
@ -3429,13 +3529,26 @@ export default {
lineNo: String(row.sourceRef2 || ''), lineNo: String(row.sourceRef2 || ''),
relNo: String(row.sourceRef3 || ''), relNo: String(row.sourceRef3 || ''),
lineItemNo: 0, lineItemNo: 0,
// qty
innerBox: this.calculatedInnerQtyList.slice(),
customFields, customFields,
} }
// shipment receiverId customerId
// customerId
if (this.currentReceiverId) { if (this.currentReceiverId) {
printRequest.customerId = this.currentReceiverId printRequest.customerId = this.currentReceiverId
} }
// addressNo RECEIVER_ADDRESS+
if (this.currentReceiverAddress) {
printRequest.addressNo = this.currentReceiverAddress
}
// customerId
if (this.printForm.reportId) {
printRequest.reportId = this.printForm.reportId
}
if (this.printForm.printerName) {
printRequest.printerName = this.printForm.printerName
}
return printRequest return printRequest
}, },
@ -3455,8 +3568,24 @@ export default {
this.$message.warning('当前行缺少打印所需的IFS参数') this.$message.warning('当前行缺少打印所需的IFS参数')
return return
} }
if (!this.printForm.assignQty || this.printForm.assignQty <= 0) {
this.$message.warning('分配数量必须大于0')
const outerTotal = Number(this.printForm.outerTotal)
const innerPackQty = Number(this.printForm.innerPackQty)
const boxPackCount = Number(this.printForm.boxPackCount)
if (!(outerTotal > 0)) {
this.$message.warning('外箱总数必须大于0')
return
}
if (!(innerPackQty > 0)) {
this.$message.warning('内箱数量必须大于0')
return
}
if (!(boxPackCount > 0)) {
this.$message.warning('每箱内包数必须大于0')
return
}
if (!this.calculatedOuterQtyList.length || !this.calculatedInnerQtyList.length) {
this.$message.warning('标签数量计算失败,请检查输入参数')
return return
} }
@ -3488,83 +3617,74 @@ export default {
margin-bottom: 14px; margin-bottom: 14px;
} }
.print-qty-row {
display: flex;
align-items: center;
gap: 20px;
.print-input-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 12px;
margin-bottom: 6px; margin-bottom: 6px;
} }
.print-qty-item {
flex: 1;
.print-input-field {
display: flex; display: flex;
align-items: center;
flex-direction: column;
min-width: 0; min-width: 0;
} }
.print-qty-label { .print-qty-label {
flex-shrink: 0;
margin-right: 8px;
margin-bottom: 6px;
font-size: 13px; font-size: 13px;
font-weight: 600; font-weight: 600;
color: #303133; color: #303133;
white-space: nowrap; white-space: nowrap;
} }
.shipment-line-print-form .print-input-number {
flex: 1;
width: 0;
min-width: 110px;
}
.shipment-line-print-form .print-input-number /deep/ .el-input {
width: 100%;
}
.shipment-line-print-form .print-input-number /deep/ .el-input__inner {
height: 32px;
line-height: 32px;
padding-left: 10px;
padding-right: 40px;
text-align: left;
.shipment-line-print-form .form-hint {
margin: 0 0 14px;
font-size: 12px;
color: #909399;
line-height: 1.4;
} }
.shipment-line-print-form .print-input-number /deep/ .el-input-number__increase,
.shipment-line-print-form .print-input-number /deep/ .el-input-number__decrease {
width: 32px;
height: 16px;
line-height: 16px;
font-size: 12px;
.print-result-panel {
margin-bottom: 14px;
padding: 12px 14px;
background: #f5f7fa; background: #f5f7fa;
border-left: 1px solid #dcdfe6;
border: 1px solid #e4e7ed;
border-radius: 4px;
} }
.shipment-line-print-form .print-input-number /deep/ .el-input-number__increase {
border-bottom: 1px solid #dcdfe6;
border-radius: 0 4px 0 0;
.print-result-title {
margin-bottom: 10px;
font-size: 13px;
font-weight: 600;
color: #303133;
} }
.shipment-line-print-form .print-input-number /deep/ .el-input-number__decrease {
border-radius: 0 0 4px 0;
.print-result-block + .print-result-block {
margin-top: 10px;
padding-top: 10px;
border-top: 1px dashed #dcdfe6;
} }
.shipment-line-print-form .print-input-number /deep/ .el-input-number__increase:hover,
.shipment-line-print-form .print-input-number /deep/ .el-input-number__decrease:hover {
color: #409eff;
.print-result-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 4px;
font-size: 13px;
color: #606266;
} }
.shipment-line-print-form .el-form-item__label {
padding-bottom: 4px;
line-height: 20px;
.print-result-count {
color: #409eff;
font-weight: 600; font-weight: 600;
color: #303133;
} }
.shipment-line-print-form .form-hint {
margin: 0 0 14px;
font-size: 12px;
color: #909399;
line-height: 1.4;
.print-result-text {
font-size: 13px;
line-height: 1.5;
color: #303133;
word-break: break-all;
} }
.shipment-line-print-summary { .shipment-line-print-summary {

Loading…
Cancel
Save