diff --git a/src/views/modules/shipment/shipmentNotification.vue b/src/views/modules/shipment/shipmentNotification.vue index e30e507..3466890 100644 --- a/src/views/modules/shipment/shipmentNotification.vue +++ b/src/views/modules/shipment/shipmentNotification.vue @@ -36,6 +36,7 @@ 查询 + 打印 @@ -641,12 +642,73 @@ + + + + + + + + 查询 + + +
+ 当前SHIPMENTID:{{ currentShipmentId }} +
+ + + + + + + + +
+ 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信息失败') - } + receiverId = await this.fetchReceiverIdByShipment(shipmentId, row.site) } if (!receiverId) { this.$message.warning('未获取到receiverId') } this.currentReceiverId = receiverId || '' - this.loadShipmentLineList(row) + 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 querySite = site || (this.currentRow && this.currentRow.site) || this.$store.state.user.site + const { data } = await getShipmentListForIssure({ + 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] + return matched.receiverId || matched.RECEIVER_ID || '' + } + } catch (e) { + this.$message.error('获取shipment信息失败') + } + 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)) - this.activeTable = 'shipmentLinePrint' + 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 || ''),