Browse Source

添加个打印按钮

master
shenzhouyu 6 days ago
parent
commit
780ad5416a
  1. 125
      src/views/modules/shipment/shipmentNotification.vue

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

@ -36,6 +36,7 @@
</el-form-item>
<el-form-item :label="' '">
<el-button type="primary" :loading="searchLoading" @click="getDataList()">查询</el-button>
<el-button type="success" icon="el-icon-printer" @click="openShipmentLineQueryDialog">打印</el-button>
</el-form-item>
</el-form>
@ -641,12 +642,73 @@
<Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>
<!-- 通过输入SHIPMENT查询ShipmentLine并打印 -->
<el-dialog
title="ShipmentLine打印"
:visible.sync="shipmentLineQueryDialogVisible"
width="90%"
:close-on-click-modal="false"
@close="resetShipmentLineQueryDialog"
>
<el-form :inline="true" size="small" @submit.native.prevent>
<el-form-item label="SHIPMENT">
<el-input
v-model="dialogShipmentId"
clearable
placeholder="请输入SHIPMENT"
style="width: 220px"
@keyup.enter.native="searchShipmentLineByDialog"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" :loading="shipmentLineLoading" @click="searchShipmentLineByDialog">查询</el-button>
</el-form-item>
</el-form>
<div v-if="currentShipmentId" style="margin-bottom: 8px; font-size: 12px;">
当前SHIPMENTID{{ currentShipmentId }}
</div>
<el-table
:data="shipmentLineList"
height="420"
border
v-loading="shipmentLineLoading"
style="width: 100%;"
>
<el-table-column
v-for="(item,index) in columnShipmentLineList" :key="index"
:sortable="item.columnSortable"
:prop="item.columnProp"
:header-align="item.headerAlign"
:show-overflow-tooltip="item.showOverflowTooltip"
:align="item.align"
:fixed="item.fixed==''?false:item.fixed"
:min-width="item.columnWidth"
:label="item.columnLabel"
>
<template slot-scope="scope">
<span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
</template>
</el-table-column>
<el-table-column fixed="right" header-align="center" align="center" width="80" label="操作">
<template slot-scope="scope">
<el-link
type="primary"
style="cursor: pointer"
:disabled="printLoading"
@click="printShipmentLine(scope.row)"
>打印</el-link>
</template>
</el-table-column>
</el-table>
</el-dialog>
<!-- shipmentline打印设置标签类型/模板/打印机由后端按 customerId(receiverId) 自动匹配红框部分已注释 -->
<el-dialog
title="标签打印设置"
:visible.sync="shipmentLinePrintDialogVisible"
width="480px"
:close-on-click-modal="false"
append-to-body
@close="resetShipmentLinePrintForm"
>
<el-alert
@ -1980,6 +2042,8 @@ export default {
shipmentLineLoading: false,
currentShipmentId: '',
currentReceiverId: '',
shipmentLineQueryDialogVisible: false,
dialogShipmentId: '',
shipmentLinePrintDialogVisible: false,
printLoading: false,
printShipmentLineRow: null,
@ -3210,28 +3274,59 @@ export default {
let receiverId = row.receiverId || row.RECEIVER_ID
if (!receiverId) {
receiverId = await this.fetchReceiverIdByShipment(shipmentId, row.site)
}
if (!receiverId) {
this.$message.warning('未获取到receiverId')
}
this.currentReceiverId = receiverId || ''
this.loadShipmentLineList(row, true)
},
openShipmentLineQueryDialog() {
this.shipmentLineQueryDialogVisible = true
},
resetShipmentLineQueryDialog() {
this.dialogShipmentId = ''
},
async searchShipmentLineByDialog() {
const shipmentId = (this.dialogShipmentId || '').trim()
if (!shipmentId) {
this.$message.warning('请输入SHIPMENT')
return
}
this.currentShipmentId = shipmentId
this.currentReceiverId = ''
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.currentReceiverId = receiverId || ''
this.loadShipmentLineList({ soorderNo: shipmentId, site }, false)
},
async fetchReceiverIdByShipment(shipmentId, site) {
try {
const site = row.site || 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({
site,
site: querySite,
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
return matched.receiverId || matched.RECEIVER_ID || ''
}
} catch (e) {
this.$message.error('获取shipment信息失败')
}
}
if (!receiverId) {
this.$message.warning('未获取到receiverId')
}
this.currentReceiverId = receiverId || ''
this.loadShipmentLineList(row)
return ''
},
normalizeShipmentLineRow(row) {
@ -3251,9 +3346,9 @@ export default {
}
},
loadShipmentLineList(row) {
loadShipmentLineList(row, switchTab = true) {
const params = {
site: row.site || this.currentRow.site || this.$store.state.user.site,
site: row.site || (this.currentRow && this.currentRow.site) || this.$store.state.user.site,
orderNo: row.soorderNo,
}
this.shipmentLineLoading = true
@ -3261,7 +3356,9 @@ export default {
.then(({ data }) => {
if (data && data.code === 0) {
this.shipmentLineList = (data.rows || []).map(item => this.normalizeShipmentLineRow(item))
if (switchTab) {
this.activeTable = 'shipmentLinePrint'
}
if (this.shipmentLineList.length === 0) {
this.$message.warning('未查询到ShipmentLine数据')
}
@ -3281,7 +3378,7 @@ export default {
printShipmentLine(row) {
if (!this.currentReceiverId) {
this.$message.warning('未获取到receiverId,请先双击已申请SHIPMENT')
this.$message.warning('未获取到receiverId,请先查询SHIPMENT')
return
}
this.printShipmentLineRow = row
@ -3324,7 +3421,7 @@ export default {
labelType: this.printForm.labelType,
printerName: this.printForm.printerName,
copies: this.printForm.copies,
site: this.currentRow.site || this.$store.state.user.site,
site: (this.currentRow && this.currentRow.site) || this.$store.state.user.site,
userId: localStorage.getItem('userName'),
username: localStorage.getItem('userName'),
consignmentId: String(row.shipmentId || ''),

Loading…
Cancel
Save