From 98630dcede24699dbb530a0d6298b61abad3712f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=90=8C=E6=B5=B7?= <963808678@qq.com> Date: Fri, 2 Dec 2022 17:28:17 +0800 Subject: [PATCH] 12/2 --- src/components/MultiTab/MultiTab.vue | 37 ++++++++++++------- src/views/main/BookingLedger/detail/index.vue | 14 ++++++- src/views/main/BookingLedger/list/index.vue | 5 +-- 3 files changed, 38 insertions(+), 18 deletions(-) diff --git a/src/components/MultiTab/MultiTab.vue b/src/components/MultiTab/MultiTab.vue index 7fc1706..c8cd4f8 100644 --- a/src/components/MultiTab/MultiTab.vue +++ b/src/components/MultiTab/MultiTab.vue @@ -42,20 +42,29 @@ export default { }, methods: { onEdit(targetKey, action) { - // let _that = this - // if (targetKey.split('?')[0] == '/BookingDetail') { - // this.$confirm({ - // title: '请确认无未保存数据!', - // content: '当点击确定按钮时,此页面 将会关闭。', - // onOk() { - // _that[action](targetKey) - // }, - // onCancel() {} - // }) - // } else { - // this[action](targetKey) - // } - this[action](targetKey) + let _that = this + let data = Object.fromEntries(new URLSearchParams(targetKey.split('?')[1])) + console.log(targetKey.split('?')[0] == '/BookingDetail') + 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({ + title: '请确认无未保存数据!', + content: '当点击确定按钮时,此页面 将会关闭。', + onOk() { + _that[action](targetKey) + localStorage.removeItem(data.id) + }, + onCancel() {} + }) + } else { + this[action](targetKey) + localStorage.removeItem(data.id) + } console.log('关闭?', targetKey, action) }, remove(targetKey) { diff --git a/src/views/main/BookingLedger/detail/index.vue b/src/views/main/BookingLedger/detail/index.vue index 1d9f22f..8d4341c 100644 --- a/src/views/main/BookingLedger/detail/index.vue +++ b/src/views/main/BookingLedger/detail/index.vue @@ -158,7 +158,8 @@ export default { watch: { bookingDetails: { handler(nval, oval) { - // console.log('父级 -- 数据改变', nval) + console.log('改了', nval, oval) + localStorage.setItem(`${this.id}`, true) }, deep: true } @@ -166,7 +167,11 @@ export default { created() { this.init() }, + updated() { + localStorage.setItem(`${this.id}`, false) + }, beforeRouteUpdate(to, from, next) { + console.log('beforeRouteUpdate') if (!Object.keys(this.historyData).includes(this.$route.query.id)) { const hisData = { bookingDetails: this.bookingDetails, @@ -184,6 +189,7 @@ export default { this.getRouterHis() }, beforeRouteLeave(to, from, next) { + console.log('beforeRouteLeave') if (!Object.keys(this.historyData).includes(this.id)) { const hisData = { bookingDetails: this.bookingDetails, @@ -210,6 +216,7 @@ export default { }, methods: { getRouterHis() { + console.log('getRouterHis') const newId = this.$route.query.id if (Object.keys(this.historyData).includes(newId)) { // const newType = this.$route.query.type @@ -236,6 +243,7 @@ export default { } }, init() { + console.log('addSedList') this.bookingDetails = {} if (this.id) { this.isAdd = false @@ -373,6 +381,7 @@ export default { }, getDetail() { + console.log('getDetail') if (this.inPageLoading) { return false } @@ -399,6 +408,7 @@ export default { } this.$set(this, 'bookingDetails', res.data) this.$forceUpdate() + console.log('bookingDetails', this.bookingDetails) }) .catch(err => { console.log(err) @@ -406,6 +416,7 @@ export default { }, changeDetailFun(data) { + console.log('changeDetailFun') const { detail, type } = data this.bookingDetails = detail }, @@ -521,6 +532,7 @@ export default { }) }, addSedList() { + console.log('addSedList') if (this.isAdd) { this.$message.error('请先保存主单') return false diff --git a/src/views/main/BookingLedger/list/index.vue b/src/views/main/BookingLedger/list/index.vue index 4629d44..fb85997 100644 --- a/src/views/main/BookingLedger/list/index.vue +++ b/src/views/main/BookingLedger/list/index.vue @@ -380,7 +380,6 @@ export default { Object.keys(this.formRes).map((item, index) => { this.formRes[item] = '' }) - debugger this.init() }, @@ -551,7 +550,7 @@ export default { this.moreNumVisible = false }, - resizableChange () { + resizableChange() { console.log('==== 列宽拖动 =====') } } @@ -596,7 +595,7 @@ export default {