Commit 199152a0 by tangqy

调整

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