|
@@ -153,29 +153,39 @@ export default {
|
|
|
watch: {
|
|
|
'$route': function (newVal, oldVal) {
|
|
|
if (newVal.name == oldVal.name) { return }
|
|
|
- console.log(newVal, oldVal)
|
|
|
+ // console.log(newVal, oldVal, this.pages)
|
|
|
// 解决页面地址相同参数不同时打开多个页签问题(例 详情页id或sn不同时)
|
|
|
const index = this.tabsList.indexOf(newVal.name)
|
|
|
+
|
|
|
// 是否时同一个父级菜单下的页面
|
|
|
const mnlen = newVal.matched.length < 3
|
|
|
- const molen = oldVal.matched.length < 3
|
|
|
- const hasChildren = newVal.matched[mnlen ? 1 : 2].name == oldVal.matched[molen ? 1 : 2].name
|
|
|
- // console.log(newVal.matched[mnlen ? 1 : 2].name, oldVal.matched[molen ? 1 : 2].name, hasChildren)
|
|
|
+ const newMatched = newVal.matched[mnlen ? 1 : 2]
|
|
|
+
|
|
|
+ // 是否已存在同级菜单
|
|
|
+ const hasEqChild = this.pages.find(item => {
|
|
|
+ const alen = item.matched.length < 3
|
|
|
+ return item.matched[alen ? 1 : 2].name == newMatched.name
|
|
|
+ })
|
|
|
+ // console.log(hasEqChild, 'hasEqChild')
|
|
|
+ const oldMenu = hasEqChild || oldVal
|
|
|
+ const molen = oldMenu.matched.length < 3
|
|
|
+ const oldMatched = oldMenu.matched[molen ? 1 : 2]
|
|
|
+ const hasChildren = newMatched.name == oldMatched.name
|
|
|
|
|
|
if (index < 0) { // 不存在
|
|
|
- console.log(1, '不存在')
|
|
|
+ // console.log(1, hasChildren, '不存在')
|
|
|
// 判断是否是新增,编辑,详情页
|
|
|
const na = newVal.meta.title.indexOf('详情') >= 0
|
|
|
const nb = newVal.meta.title.indexOf('新增') >= 0
|
|
|
const nc = newVal.meta.title.indexOf('编辑') >= 0
|
|
|
const nxt = newVal.meta.title.indexOf('下推销售单') >= 0
|
|
|
- const oa = oldVal.meta.title.indexOf('详情') >= 0
|
|
|
- const ob = oldVal.meta.title.indexOf('新增') >= 0
|
|
|
- const oc = oldVal.meta.title.indexOf('编辑') >= 0
|
|
|
- const oxt = oldVal.meta.title.indexOf('下推销售单') >= 0
|
|
|
+ const oa = oldMenu.meta.title.indexOf('详情') >= 0
|
|
|
+ const ob = oldMenu.meta.title.indexOf('新增') >= 0
|
|
|
+ const oc = oldMenu.meta.title.indexOf('编辑') >= 0
|
|
|
+ const oxt = oldMenu.meta.title.indexOf('下推销售单') >= 0
|
|
|
if ((na || nb || nc || nxt || oa || ob || oc || oxt) && hasChildren) {
|
|
|
// 替换当前页签
|
|
|
- this.replaceTab(newVal, oldVal)
|
|
|
+ this.replaceTab(newVal, oldMenu)
|
|
|
// 从列表打开新增,编辑
|
|
|
this.$store.state.app.isNewTab = na || nb || nc
|
|
|
// 从编辑,新增返回列表,刷新列表
|
|
@@ -196,17 +206,19 @@ export default {
|
|
|
this.$warning({
|
|
|
title: '提示',
|
|
|
content: '您当前打开窗口太多,请关闭一些,窗口不能超过' + this.maxTabNums + '个',
|
|
|
- onOk () {
|
|
|
- _this.$router.go(-1)
|
|
|
- }
|
|
|
+ onOk () {}
|
|
|
})
|
|
|
+ _this.$router.go(-1)
|
|
|
}
|
|
|
}
|
|
|
} else { // 已存在
|
|
|
- console.log(1, '已存在')
|
|
|
this.pages.splice(index, 1, newVal)
|
|
|
this.tabsList.splice(index, 1, newVal.name)
|
|
|
this.$store.state.app.isNewTab = false
|
|
|
+ if (hasEqChild) {
|
|
|
+ this.$store.state.app.updateList = hasEqChild.name == oldVal.name
|
|
|
+ }
|
|
|
+ // console.log(1, this.$store.state.app.updateList, '已存在')
|
|
|
this.activeKey = newVal.name
|
|
|
}
|
|
|
},
|