修改上一票下一票,分单保存等

dev
lilu 2 years ago
parent 1a03bb85bf
commit 59fe94dfea

@ -1,6 +1,7 @@
<script> <script>
import events from './events' import events from './events'
import { BookingOrderGet } from '@/api/modular/main/BookingLedger' import { BookingOrderGet } from '@/api/modular/main/BookingLedger'
import { mapActions, mapGetters } from 'vuex'
export default { export default {
name: 'MultiTab', name: 'MultiTab',
data() { data() {
@ -11,6 +12,9 @@ export default {
newTabIndex: 0 newTabIndex: 0
} }
}, },
computed: {
...mapGetters(['needSavePages'])
},
created() { created() {
// bind event // bind event
events events
@ -41,29 +45,30 @@ export default {
this.selectedLastPath() this.selectedLastPath()
}, },
methods: { methods: {
...mapActions(['setNeedSavePages']),
onEdit(targetKey, action) { onEdit(targetKey, action) {
let _that = this const _that = this
let data = Object.fromEntries(new URLSearchParams(targetKey.split('?')[1])) console.log(this.needSavePages[targetKey])
console.log(targetKey.split('?')[0] == '/BookingDetail') if (this.needSavePages[targetKey].details || this.needSavePages[targetKey].hbList) {
console.log(localStorage.getItem(data.id))
console.log(localStorage.getItem(data.id) == 'true')
console.log(data.id != null)
console.log(
targetKey.split('?')[0] == '/BookingDetail' && data.id != null && localStorage.getItem(data.id) == 'true'
)
if (targetKey.split('?')[0] == '/BookingDetail' && data.id != null && localStorage.getItem(data.id) == 'true') {
this.$confirm({ this.$confirm({
title: '请确认无未保存数据!', title: '请确认无未保存数据!',
content: '当点击确定按钮时,此页面 将会关闭。', content: '当点击确定按钮时,此页面 将会关闭。',
cancelText: targetKey === _that.activeKey ? '取消' : '前往保存',
onOk() { onOk() {
_that[action](targetKey) _that[action](targetKey)
localStorage.removeItem(data.id) const $data = _that.needSavePages
delete $data[targetKey]
_that.setNeedSavePages($data)
}, },
onCancel() {} onCancel() {
_that.activeKey = targetKey
}
}) })
} else { } else {
this[action](targetKey) this[action](targetKey)
localStorage.removeItem(data.id) const $data = this.needSavePages
delete $data[targetKey]
this.setNeedSavePages($data)
} }
console.log('关闭?', targetKey, action) console.log('关闭?', targetKey, action)
}, },
@ -167,10 +172,19 @@ export default {
}, },
watch: { watch: {
$route: function(newVal) { $route: function(newVal) {
this.activeKey = newVal.fullPath if (!newVal.query.noOpenTab) {
if (this.fullPathList.indexOf(newVal.fullPath) < 0) { this.activeKey = newVal.fullPath
this.fullPathList.push(newVal.fullPath) if (this.fullPathList.indexOf(newVal.fullPath) < 0) {
this.pages.push(newVal) this.fullPathList.push(newVal.fullPath)
this.pages.push(newVal)
}
} else {
this.pages.map((item, index) => {
if (item.fullPath === this.activeKey) {
this.pages[index] = newVal
}
})
this.activeKey = newVal.fullPath
} }
}, },
activeKey: function(newPathKey) { activeKey: function(newPathKey) {

@ -40,7 +40,7 @@ const user = {
info: {}, info: {},
notices: [], // 接收的通知公告 notices: [], // 接收的通知公告
bookingList: {}, // 订舱台账列表 bookingList: {}, // 订舱台账列表
needSavePages: [] // 需要保存的页面 needSavePages: {} // 需要保存的页面
}, },
mutations: { mutations: {

@ -108,30 +108,35 @@ export default {
} }
}, },
watch: { watch: {
sedOrderList (nval, oval) { sedOrderList: {
if (nval.length > 0) { handler (nval, oval) {
console.log(nval) if (nval.length > 0) {
if (!nval[this.editIndex].bookingEDIExt) { console.log(nval)
nval[this.editIndex].bookingEDIExt = { if (!nval[this.editIndex].bookingEDIExt) {
weiTuoFang: '', nval[this.editIndex].bookingEDIExt = {
ediAttn: '', weiTuoFang: '',
ediAttnTel: '', ediAttn: '',
ediAttnMail: '' ediAttnTel: '',
ediAttnMail: ''
}
} }
} this.editDetails = nval[this.editIndex]
this.editDetails = nval[this.editIndex] } else {
} else { this.editDetails = null
this.editDetails = null }
} },
deep: true
}, },
editDetails: { editDetails: {
handler (nval, oval) { handler (nval, oval) {
console.log('分单更新', nval) this.$emit('changeHB', this.sedOrderList)
if (nval !== oval && oval) { if (nval !== oval) {
// localStorage.setItem(`${this.id}`, true)
// this.sedOrderList[this.editIndex].isNoSave = true // this.sedOrderList[this.editIndex].isNoSave = true
// console.log(this.editIndex, this.sedOrderList[this.editIndex].isNoSave) // console.log(this.editIndex, this.sedOrderList[this.editIndex].isNoSave)
} }
} },
deep: true
} }
}, },
created() { created() {
@ -313,6 +318,7 @@ export default {
this.sedOrderList[this.editIndex].isNoSave = false this.sedOrderList[this.editIndex].isNoSave = false
this.editDetails.isNoSave = false this.editDetails.isNoSave = false
this.$message.success('保存成功') this.$message.success('保存成功')
this.$emit('changeHB', this.sedOrderList)
this.$forceUpdate() this.$forceUpdate()
} else { } else {
this.$message.error(res.message) this.$message.error(res.message)
@ -338,6 +344,7 @@ export default {
this.editDetails.isNoSave = false this.editDetails.isNoSave = false
this.sedOrderList[this.editIndex].id = res.data this.sedOrderList[this.editIndex].id = res.data
this.$message.success('保存成功') this.$message.success('保存成功')
this.$emit('changeHB', this.sedOrderList)
this.$forceUpdate() this.$forceUpdate()
} else { } else {
this.$message.error(res.message) this.$message.error(res.message)

@ -82,6 +82,7 @@
:details="bookingDetails" :details="bookingDetails"
:sedOrderList="bookingDetails.hbList" :sedOrderList="bookingDetails.hbList"
:isAdd="isAdd" :isAdd="isAdd"
@changeHB="changeHBFun"
></sedOrder> ></sedOrder>
</a-tab-pane> </a-tab-pane>
</a-tabs> </a-tabs>
@ -107,6 +108,109 @@ import {
BookingOrderAddOrUpdate BookingOrderAddOrUpdate
} from '@/api/modular/main/BookingLedger' } from '@/api/modular/main/BookingLedger'
import { mapActions, mapGetters } from 'vuex' import { mapActions, mapGetters } from 'vuex'
const initDetail = {
id: 0,
parentId: 0,
//
customername: '',
customerid: '',
carrier: '',
carrierid: '',
forwarder: '',
pono: '',
mblno: '',
hblno: '',
bookingno: '',
contractno: '',
vessel: '',
voyno: '',
voynoinner: '',
lanecode: '',
etd: '',
atd: '',
lanename: '',
shipagency: '',
sale: '',
op: '',
doc: '',
custservice: '',
//
shipper: '',
consignee: '',
notifyparty: '',
yard: '',
customser: '',
trucker: '',
agentid: '',
eta: '',
closingdate: '',
closedocdate: '',
closevgmdate: '',
portload: '',
portloadid: '',
transport: '',
transportid: '',
portdischarge: '',
portdischargeid: '',
destination: '',
destinationid: '',
placedelivery: '',
placedeliveryid: '',
placereceipt: '',
placereceiptid: '',
pkgs: 0,
kindpkgs: '',
kgs: 0,
cbm: 0,
//
marks: '',
cargoid: '',
hscode: '',
description: '',
totalno: '',
//
issuetype: '',
issuedate: '',
issueplace: '',
issueplaceid: '',
nobill: 'THREE',
copynobilll: 'THREE',
prepardat: '',
payableat: '',
blfrt: '',
thirdpayaddr: '',
service: '',
reeferf: '',
tempset: '',
tempid: '',
tempmin: '',
tempmax: '',
humidity: '',
dclass: '',
dunno: '',
dpage: '',
dlabel: '',
linkman: '',
//
soremark: '',
siremark: '',
//
ctnInputs: [],
// edi (edi)
weituo: '',
freightpayer: '',
scaccode: '',
itncode: '',
iscontainersoc: 0,
bookingEDIExt: {
weiTuoFang: '',
ediAttn: '',
ediAttnTel: '',
ediAttnMail: ''
},
//
hbList: []
}
export default { export default {
name: 'BookingDetail', name: 'BookingDetail',
inject: ['reload'], inject: ['reload'],
@ -129,7 +233,8 @@ export default {
id: this.$route.query.id, id: this.$route.query.id,
isCopy: this.$route.query.isCopy || false, isCopy: this.$route.query.isCopy || false,
inPageLoading: false, inPageLoading: false,
bookingDetails: {}, // bookingDetails: {},
bookingDetails: initDetail,
tabBarStyle: { tabBarStyle: {
background: '#fff', background: '#fff',
padding: '0 20px' padding: '0 20px'
@ -157,7 +262,7 @@ export default {
watch: { watch: {
bookingDetails: { bookingDetails: {
handler(nval, oval) { handler(nval, oval) {
localStorage.setItem(`${this.id}`, true) this.checkSaveFun({ type: 'details', hasChange: true })
}, },
deep: true deep: true
} }
@ -165,9 +270,6 @@ export default {
created() { created() {
this.init() this.init()
}, },
updated() {
localStorage.setItem(`${this.id}`, false)
},
beforeRouteUpdate(to, from, next) { beforeRouteUpdate(to, from, next) {
if (!Object.keys(this.historyData).includes(this.$route.query.id)) { if (!Object.keys(this.historyData).includes(this.$route.query.id)) {
const hisData = { const hisData = {
@ -230,7 +332,8 @@ export default {
} }
}, },
init() { init() {
this.bookingDetails = {} // this.bookingDetails = {}
this.bookingDetails = initDetail
if (this.id) { if (this.id) {
this.isAdd = false this.isAdd = false
this.getDetail() this.getDetail()
@ -367,10 +470,11 @@ export default {
}, },
getDetail() { getDetail() {
if (this.inPageLoading) { this.inPageLoading = false
return false // if (this.inPageLoading) {
} // return false
this.inPageLoading = true // }
// this.inPageLoading = true
// this.$message.loading({ content: '...' }); // this.$message.loading({ content: '...' });
BookingOrderGet({ BookingOrderGet({
id: this.id id: this.id
@ -392,6 +496,9 @@ export default {
} }
} }
this.$set(this, 'bookingDetails', res.data) this.$set(this, 'bookingDetails', res.data)
setTimeout(() => {
this.checkSaveFun({ type: 'details', hasChange: false })
}, 600)
this.$forceUpdate() this.$forceUpdate()
}) })
.catch(err => { .catch(err => {
@ -443,7 +550,7 @@ export default {
this.$message.success('保存成功') this.$message.success('保存成功')
this.$router.replace({ this.$router.replace({
name: 'BookingDetail', name: 'BookingDetail',
query: { id: res.data, type: this.bookingDetails.carrierid } query: { id: res.data, type: this.bookingDetails.carrierid, noOpenTab: true }
}) })
this.$forceUpdate() this.$forceUpdate()
} else { } else {
@ -480,6 +587,25 @@ export default {
this.excuteRulesType = type this.excuteRulesType = type
}, },
changePageFun(type) { changePageFun(type) {
const _this = this
const key = this.$route.fullPath
if (this.needSavePages[key].details || this.needSavePages[key].hbList) {
this.$confirm({
title: '请确认无未保存数据!',
content: '当点击确定按钮时,此页面 将会关闭。',
onOk() {
_this.changePage()
const $data = _this.needSavePages
delete $data[key]
_this.setNeedSavePages($data)
},
onCancel() {}
})
} else {
this.changePage()
}
},
changePage (type) {
const nowId = this.$route.query.id const nowId = this.$route.query.id
const arr = Object.keys(this.bookingList) const arr = Object.keys(this.bookingList)
const index = arr.indexOf(nowId.toString()) const index = arr.indexOf(nowId.toString())
@ -492,7 +618,7 @@ export default {
const prevType = this.bookingList[prevId].carrierid const prevType = this.bookingList[prevId].carrierid
this.$router.replace({ this.$router.replace({
name: 'BookingDetail', name: 'BookingDetail',
query: { id: prevId, type: prevType, mblno: this.bookingList[prevId].mblno } query: { id: prevId, type: prevType, mblno: this.bookingList[prevId].mblno, noOpenTab: true }
}) })
// this.$route.query.id = 1123 // this.$route.query.id = 1123
} else { } else {
@ -504,7 +630,7 @@ export default {
const nextType = this.bookingList[nextId].carrierid const nextType = this.bookingList[nextId].carrierid
this.$router.replace({ this.$router.replace({
name: 'BookingDetail', name: 'BookingDetail',
query: { id: nextId, type: nextType, mblno: this.bookingList[nextId].mblno } query: { id: nextId, type: nextType, mblno: this.bookingList[nextId].mblno, noOpenTab: true }
}) })
} }
}, },
@ -527,6 +653,31 @@ export default {
data.hblno = '' data.hblno = ''
this.bookingDetails.hbList = [data] this.bookingDetails.hbList = [data]
this.tabActiveKey = '2' this.tabActiveKey = '2'
},
changeHBFun (data) {
const arr = data.map((item, index) => {
return item.isNoSave
})
if (arr.includes(true)) {
this.checkSaveFun({ type: 'hbList', hasChange: true })
} else {
this.checkSaveFun({ type: 'hbList', hasChange: false })
}
},
checkSaveFun (data) {
const lastPages = this.needSavePages
const $data = this.needSavePages[this.id] || {}
if (data.type === 'details') {
this.$set($data, 'details', data.hasChange)
} else if (data.type === 'hbList') {
this.$set($data, 'hbList', data.hasChange)
}
// const key = this.id
const key = this.$route.fullPath
this.$set(lastPages, key, $data)
this.setNeedSavePages(lastPages)
console.log(' ==== > 父组件监听到总数据改变: ', key, $data, lastPages, this.needSavePages)
} }
} }
} }

Loading…
Cancel
Save