|
@ -77,11 +77,23 @@ export default { |
|
|
GuipToolTip |
|
|
GuipToolTip |
|
|
}, |
|
|
}, |
|
|
watch: { |
|
|
watch: { |
|
|
menuList(newVal) { |
|
|
menuList:{ |
|
|
let subtitle = this.renderKeyNew.subtitle; |
|
|
handler(newVal, oldVal) { |
|
|
this.activeFloor = newVal[this.curIndex]?.list?.[0][subtitle]; |
|
|
// 初次加载或强制刷新时,oldVal为空 |
|
|
this.componentsName = newVal[this.curIndex]?.list?.[0]?.componentsName || ''; |
|
|
if (!oldVal || oldVal.length === 0) { |
|
|
store.commit('SET_CURRENTMENUITEM', newVal[this.curIndex]?.list?.[0]); |
|
|
this.setDefaultActive(newVal); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
console.log(newVal,'newVal==='); |
|
|
|
|
|
// 检查当前高亮的菜单项是否仍然存在于新的menuList中 |
|
|
|
|
|
const currentItemExists = this.checkCurrentItem(newVal); |
|
|
|
|
|
console.log(currentItemExists,'currentItemExists--'); |
|
|
|
|
|
// 不存在默认高亮第一项 |
|
|
|
|
|
if (!currentItemExists) { |
|
|
|
|
|
this.setDefaultActive(newVal); |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
immediate: true |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
mounted() { |
|
|
mounted() { |
|
@ -105,6 +117,32 @@ export default { |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
|
|
|
checkCurrentItem(newMenuList) { |
|
|
|
|
|
const subtitle = this.renderKeyNew.subtitle; |
|
|
|
|
|
// 如果当前没有高亮的菜单项,返回 |
|
|
|
|
|
if (!this.activeFloor) return false; |
|
|
|
|
|
// 遍历新的menuList,先检查高亮的菜单项是否存在 |
|
|
|
|
|
for (const item of newMenuList) { |
|
|
|
|
|
if (item.list) { |
|
|
|
|
|
const found = item.list.some(subItem => |
|
|
|
|
|
subItem[subtitle] === this.activeFloor || |
|
|
|
|
|
subItem.componentsName === this.activeFloor |
|
|
|
|
|
); |
|
|
|
|
|
if (found) return true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return false; |
|
|
|
|
|
}, |
|
|
|
|
|
setDefaultActive(menuList) { |
|
|
|
|
|
// 设置默认高亮项 |
|
|
|
|
|
if (menuList && menuList.length > 0 && menuList[0].list && menuList[0].list.length > 0) { |
|
|
|
|
|
const subtitle = this.renderKeyNew.subtitle; |
|
|
|
|
|
this.activeFloor = menuList[0].list[0][subtitle] || menuList[0].list[0]?.componentsName || ''; |
|
|
|
|
|
this.componentsName = menuList[0].list[0]?.componentsName || ''; |
|
|
|
|
|
store.commit('SET_CURRENTMENUITEM', menuList[0].list[0]); |
|
|
|
|
|
this.curIndex = 0; |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
handleChange(val) { |
|
|
handleChange(val) { |
|
|
console.log("面板状态变化:", val); |
|
|
console.log("面板状态变化:", val); |
|
|
}, |
|
|
}, |
|
|