Commit 199152a0 by tangqy

调整

parent c0eceec1
......@@ -4,7 +4,7 @@
.sidebar('@mouseover'="showUnfoldBtn()",'@mouseout'="hiddenUnfoldBtn()")
.logo
img(':src'="logo")
.item('v-if'="menus.length",'v-for'="(item,itemIndex) in menus" ,':key'="item.id",'@click'='choseMenu(item,itemIndex)',':class'="{active:currentMainMenuIndex === itemIndex}")
.item('v-if'="menus.length",'v-for'="(item,itemIndex) in menus" ,':key'="item.id",'@click'='choseMenu(item,itemIndex)',':class'="{active:firstIndex === itemIndex}")
sidebar-item&attributes({
':icon':'item.ico',
':link':'item.link',
......@@ -20,7 +20,6 @@
.children-item
el-menu&attributes({
'ref':"menu",
'default-active':"2",
'class':"el-menu-vertical",
'background-color':"#374A5E",
'text-color':"#fff",
......@@ -55,8 +54,11 @@ export default {
collapse: false,
logo,
// unfold: false, // 水平展开
unfoldBtn: false, // 展开按钮
currentMainMenuIndex: 0, //mainIndex
unfoldBtn: false, // 展开按钮
firstIndex: 0,
secondIndex: 0,
thirdIndex: 0,
currentMenus: []
}
},
filters: {
......@@ -77,47 +79,25 @@ export default {
currentPath: 'getCurrentPath',
project: 'getProjectInfo',
sidebarUnfoldInfo: 'getSidebarUnfoldInfo',
}),
currentMenusIndex() {
let res = -1
if (this.currentPath && this.currentPath.length) {
res = this.currentPath[0]
this.$nextTick(() => {
this.handleOpen()
})
}
return res
},
currentMenus: {
get() {
// const currentIndex = this.currentMenusIndex
const currentIndex = this.currentMainMenuIndex
const currentMenus = currentIndex === -1 ? this.getCurrentMenus(0) : this.getCurrentMenus(currentIndex)
this.$nextTick(() => {
if (this.currentMenus) {
this.handleOpen()
// console.log('---', this.currentMenus)
}
})
return currentMenus
},
},
})
},
mounted() {},
methods: {
handleOpen() {
const menus = this.$refs.menu
const openIndex = this.currentPath.length === 3 ? this.currentPath[1] : 0
console.log('openIndex', openIndex)
menus.open(openIndex)
},
// calcRouter(menus) {
// const currentRoute = location.href
// const indexPath = calcIndexPathByCurrentRouter(menus, currentRoute)
// this.selectIndexPath = indexPath
// console.log(this.selectIndexPath)
// },
const currentIndexPath = [this.firstIndex, this.secondIndex, this.thirdIndex]
console.log(currentIndexPath)
const menus = this.$refs.menu
console.log(menus)
this.$nextTick(() => {
if (currentIndexPath.join('-') === this.currentPath.join('-')) {
menus.open(this.secondIndex)
console.log('open')
} else {
menus.close(this.secondIndex)
console.log('close')
}
})
},
// 隐藏边侧栏,边侧栏最小化
handerNoSidebar() {
console.log('handerNoSidebar')
......@@ -127,7 +107,9 @@ export default {
* 选择边测菜单主菜单
*/
choseMenu(selectItem, selectItemIndex) {
this.currentMainMenuIndex = selectItemIndex
console.log('--', selectItem, selectItemIndex)
this.firstIndex = selectItemIndex
console.log('current', this.firstIndex)
if (!this.sidebarUnfoldInfo) {
this.toggleUnfold(true)
}
......@@ -148,10 +130,10 @@ export default {
**/
selectItemMenu(item) {
console.log(item)
const currentMenusIndex = this.currentMenusIndex
if (currentMenusIndex > -1) {
const firstIndex = this.firstIndex
if (firstIndex > -1) {
const [idx1, idx2] = item.split('-').reverse()
const historyItemName = this.menus[currentMenusIndex].children[idx1].children[idx2].name
const historyItemName = this.menus[firstIndex].children[idx1].children[idx2].name
const time = this.$moment().format('YYYY-MM-DD hh:mm:ss')
const storeId = this.project.store_id
const menuHistoryJson = localStorage.getItem('menuHistoryJson' + storeId)
......@@ -160,7 +142,7 @@ export default {
menuHistoryJson.push({
name: historyItemName,
time,
index: `${(currentMenusIndex, idx1, idx2)}`,
index: `${(firstIndex, idx1, idx2)}`,
})
localStorage.setItem('menuHistoryJson' + storeId, JSON.stringify(menuHistoryJson))
crossStorage.onConnect().then(function() {
......@@ -191,7 +173,24 @@ export default {
return this.menus[index]
},
...mapActions(['setSidebarUnfold']),
},
},
watch: {
firstIndex(val) {
this.currentMenus = this.getCurrentMenus(val)
this.$nextTick(() => {
this.handleOpen()
})
},
currentPath (val) {
if (val.length) {
const [first, second, third] = [...val]
this.firstIndex = first
this.secondIndex = second
this.thirdIndex = third
}
console.log('currentPath is %o',val)
}
}
}
</script>
<style lang="stylus" scoped>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment