Browse Source

打印按钮修改

master
shenzhouyu 2 weeks ago
parent
commit
65c0206d6e
  1. 153
      src/views/modules/shipment/shipmentNotification.vue

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

@ -248,7 +248,12 @@
</el-table-column> </el-table-column>
<el-table-column fixed="right" header-align="center" align="center" width="80" label="操作"> <el-table-column fixed="right" header-align="center" align="center" width="80" label="操作">
<template slot-scope="scope"> <template slot-scope="scope">
<el-link type="primary" style="cursor: pointer" @click="printShipmentLine(scope.row)">打印</el-link>
<el-link
type="primary"
style="cursor: pointer"
:disabled="printLoading"
@click="printShipmentLine(scope.row)"
>打印</el-link>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -636,7 +641,7 @@
<Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist> <Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>
<!-- shipmentline打印设置 -->
<!-- shipmentline打印设置标签类型/模板/打印机由后端按 customerId(receiverId) 自动匹配红框部分已注释 -->
<el-dialog <el-dialog
title="标签打印设置" title="标签打印设置"
:visible.sync="shipmentLinePrintDialogVisible" :visible.sync="shipmentLinePrintDialogVisible"
@ -676,6 +681,8 @@
</div> </div>
</div> </div>
<div class="form-hint">此数量为打印到标签上的数量</div> <div class="form-hint">此数量为打印到标签上的数量</div>
<!-- 红框部分标签类型 / 模板 / 打印机 改为按 receiverId 自动匹配以下注释保留 -->
<!--
<el-form-item label="标签类型"> <el-form-item label="标签类型">
<el-select <el-select
v-model="printForm.labelType" v-model="printForm.labelType"
@ -717,6 +724,7 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
-->
<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>
@ -764,7 +772,8 @@ import {
deleteNotifyUnissue, deleteNotifyUnissue,
saveShipmentMaterialDetail, saveShipmentMaterialDetail,
searchUnissueNotifyMaterialList, searchUnissueNotifyMaterialList,
getShipmentLine
getShipmentLine,
getShipmentListForIssure
} from '@/api/shipment/shipmentIssue.js' } from '@/api/shipment/shipmentIssue.js'
// rqrq - API // rqrq - API
import { searchMaterialListDetail } from '@/api/orderIssure/soIssueNotify.js' import { searchMaterialListDetail } from '@/api/orderIssure/soIssueNotify.js'
@ -775,8 +784,8 @@ import {
getTableUserListLanguage, getTableUserListLanguage,
} from '@/api/table.js' } from '@/api/table.js'
import { import {
getLabelSettingList,
getUserLabelPrinters,
// getLabelSettingList, //
// getUserLabelPrinters, //
printLabelCommon, printLabelCommon,
} from '@/api/labelSetting/label_setting.js' } from '@/api/labelSetting/label_setting.js'
export default { export default {
@ -1970,11 +1979,13 @@ export default {
shipmentLineList: [], shipmentLineList: [],
shipmentLineLoading: false, shipmentLineLoading: false,
currentShipmentId: '', currentShipmentId: '',
currentReceiverId: '',
shipmentLinePrintDialogVisible: false, shipmentLinePrintDialogVisible: false,
printLoading: false, printLoading: false,
printShipmentLineRow: null, printShipmentLineRow: null,
labelTemplateList: [],
printerList: [],
// labelTemplateList / printerList customerId
// labelTemplateList: [],
// printerList: [],
printForm: { printForm: {
copies: 1, copies: 1,
assignQty: 0, assignQty: 0,
@ -2098,13 +2109,11 @@ export default {
computed: { computed: {
canStartShipmentLinePrint() { canStartShipmentLinePrint() {
console.log("this.printForm",this.printForm.reportId,this.printForm.printerName,this.printForm.copies,this.printForm.assignQty,this.printShipmentLineRow);
return !!( return !!(
this.printForm.reportId &&
this.printForm.copies > 0 && this.printForm.copies > 0 &&
this.printForm.assignQty > 0 && this.printForm.assignQty > 0 &&
this.printShipmentLineRow
this.printShipmentLineRow &&
this.currentReceiverId
) )
}, },
}, },
@ -3190,13 +3199,38 @@ export default {
return {} return {}
}, },
handleShipmentRowDblClick(row) {
async handleShipmentRowDblClick(row) {
const shipmentId = row.soorderNo const shipmentId = row.soorderNo
if (!shipmentId) { if (!shipmentId) {
this.$message.warning('该行没有SHIPMENTID') this.$message.warning('该行没有SHIPMENTID')
return return
} }
this.currentShipmentId = shipmentId this.currentShipmentId = shipmentId
this.currentReceiverId = ''
let receiverId = row.receiverId || row.RECEIVER_ID
if (!receiverId) {
try {
const site = row.site || this.currentRow.site || this.$store.state.user.site
const { data } = await getShipmentListForIssure({
site,
orderNo: shipmentId,
})
if (data && data.code === 0 && data.rows && data.rows.length > 0) {
const matched = data.rows.find(item =>
String(item.SHIPMENT_ID || item.shipmentId) === String(shipmentId)
) || data.rows[0]
receiverId = matched.receiverId || matched.RECEIVER_ID
}
} catch (e) {
this.$message.error('获取shipment信息失败')
}
}
if (!receiverId) {
this.$message.warning('未获取到receiverId')
}
this.currentReceiverId = receiverId || ''
this.loadShipmentLineList(row) this.loadShipmentLineList(row)
}, },
@ -3246,11 +3280,14 @@ export default {
}, },
printShipmentLine(row) { printShipmentLine(row) {
if (!this.currentReceiverId) {
this.$message.warning('未获取到receiverId,请先双击已申请SHIPMENT')
return
}
this.printShipmentLineRow = row this.printShipmentLineRow = row
this.resetShipmentLinePrintForm() this.resetShipmentLinePrintForm()
this.printForm.assignQty = row.qtyAssigned != null ? row.qtyAssigned : 0 this.printForm.assignQty = row.qtyAssigned != null ? row.qtyAssigned : 0
this.shipmentLinePrintDialogVisible = true this.shipmentLinePrintDialogVisible = true
this.loadShipmentLinePrintOptions(row)
}, },
resetShipmentLinePrintForm() { resetShipmentLinePrintForm() {
@ -3261,83 +3298,14 @@ export default {
reportId: '', reportId: '',
printerName: '', printerName: '',
} }
this.labelTemplateList = []
this.printerList = []
},
async loadShipmentLinePrintOptions(row) {
await this.loadLabelTemplateList(row)
await this.loadPrinterList()
},
async loadLabelTemplateList(row) {
try {
const { data } = await getLabelSettingList({
searchFlag: 'Y',
labelType: this.printForm.labelType,
})
this.labelTemplateList = (data && data.rows) ? data.rows : []
if (this.labelTemplateList.length === 0) {
this.printForm.reportId = ''
return
}
const partNo = (row && row.inventoryPartNo) || ''
const matchedTemplate = this.labelTemplateList.find(item => {
const labelName = item.labelName || ''
return partNo && labelName.includes(partNo)
})
const selectedTemplate = matchedTemplate || this.labelTemplateList[0]
this.printForm.reportId = selectedTemplate.labelNo
this.printForm.labelType = selectedTemplate.labelType || this.printForm.labelType
} catch (error) {
this.labelTemplateList = []
this.printForm.reportId = ''
this.$message.error('获取标签模板失败')
}
},
async loadPrinterList() {
if (!this.printForm.reportId) {
this.printerList = []
this.printForm.printerName = ''
return
}
try {
const { data } = await getUserLabelPrinters({
userId: localStorage.getItem('userName'),
username: localStorage.getItem('userName'),
site: this.currentRow.site || this.$store.state.user.site,
searchFlag: 'Y',
labelNo: this.printForm.reportId,
})
this.printerList = (data && data.rows) ? data.rows : []
this.printForm.printerName = this.printerList.length > 0
? this.printerList[0].printerName
: ''
} catch (error) {
this.printerList = []
this.printForm.printerName = ''
this.$message.error('获取打印机列表失败')
}
}, },
async handlePrintLabelTypeChange() {
if (!this.printShipmentLineRow) {
return
}
await this.loadLabelTemplateList(this.printShipmentLineRow)
await this.loadPrinterList()
},
async handlePrintTemplateChange() {
const selectedTemplate = this.labelTemplateList.find(
item => item.labelNo === this.printForm.reportId
)
if (selectedTemplate && selectedTemplate.labelType) {
this.printForm.labelType = selectedTemplate.labelType
}
await this.loadPrinterList()
},
// / customerId(receiverId)
// loadShipmentLinePrintOptions(row) { ... }
// loadLabelTemplateList(row) { ... }
// loadPrinterList() { ... }
// handlePrintLabelTypeChange() { ... }
// handlePrintTemplateChange() { ... }
buildShipmentLinePrintRequest() { buildShipmentLinePrintRequest() {
const row = this.printShipmentLineRow const row = this.printShipmentLineRow
@ -3367,8 +3335,9 @@ export default {
customFields, customFields,
} }
if (this.currentRow && this.currentRow.receiver) {
printRequest.customerId = this.currentRow.receiver
// shipment receiverId customerId
if (this.currentReceiverId) {
printRequest.customerId = this.currentReceiverId
} }
return printRequest return printRequest
@ -3381,6 +3350,10 @@ export default {
} }
const row = this.printShipmentLineRow const row = this.printShipmentLineRow
if (!this.currentReceiverId) {
this.$message.warning('未获取到receiverId,无法打印')
return
}
if (!row.shipmentId || !row.sourceRef1 || row.sourceRef2 == null || row.sourceRef3 == null || row.shipmentLineNo == null) { if (!row.shipmentId || !row.sourceRef1 || row.sourceRef2 == null || row.sourceRef3 == null || row.shipmentLineNo == null) {
this.$message.warning('当前行缺少打印所需的IFS参数') this.$message.warning('当前行缺少打印所需的IFS参数')
return return

Loading…
Cancel
Save