Commit f343ba10 by 无尘

add: 增加排序

parent 38565929
......@@ -101,3 +101,9 @@ methods: {
}
```
## logs
- 20190110
- 增加菜单排序
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -2,7 +2,7 @@
"name": "@gic-test/vue-office-aside",
"description": "vue-office-aside Plugin",
"author": "fairyly <498745097@qq.com>",
"version": "1.0.25",
"version": "1.0.26",
"license": "MIT",
"private": false,
"main": "dist/vue-office-aside.js",
......
......@@ -28,9 +28,7 @@
</div>
</div>
</template>
<script>
// import { getRequest } from './api';
import qs from 'qs';
export default {
name: 'vue-office-aside',
......@@ -38,26 +36,21 @@
data () {
return {
repProjectName: 'haoban-manage-web', // 项目名
// 高度
asideHeight: '0px',
asideHeight: '0px', // 高度
pathName: '', // 路由名
leftCollapse: false,// 是否收起左侧
leftCollapse: false, // 是否收起左侧
leftModuleName: '',
// defaultSub: ['1','2','3','4','5','6','7','8','9'], // 默认打开子菜单
menuLeftRouter: [
],
menuLeftRouter: [],
// 获取 location origin
baseUrl: '',
//已选菜单
selectMenu: '',
}
},
beforeMount() {
var that = this
var host = window.location.origin;
console.log("当前host:",host)
const that = this
let host = window.location.origin;
if (host.indexOf('localhost') != '-1') {
that.baseUrl = 'http://www.gicdev.com';
}else {
......@@ -71,7 +64,7 @@
},
handleSelect(key, keyPath){
var that = this
const that = this
console.log(key, keyPath);
that.selectMenu = key
},
......@@ -79,39 +72,31 @@
// 设置新数据
setNewData(newData) {
const that = this;
console.log("左侧菜单:that.pathName:",that.pathName,"that.selectMenu:",that.selectMenu )
// 处理成需要的路由
// var list = [],lists = [];
newData.forEach(function(ele,index){
// 设置 url
ele.url = '/'+ ele.url;
ele.levelFlag = false; // 有子级
if (!!ele.children && !!ele.children.length) {
let displayList = ele.children.map(item=>item.display)
// console.log('displayList:',displayList)
if (displayList.includes(1)) {
ele.levelFlag = false; // 有子级
}else {
ele.levelFlag = true; // 有子级,单独路由
}
ele.children.forEach(function(el,key){
// 设置 url
el.url = '/'+ el.url;
})
}
})
that.menuLeftRouter = newData;
that.setSelectMenu(newData)
console.log("处理后的左侧菜单 list:",newData,that.selectMenu )
that.setSelectMenu(newData);
},
setSelectMenu(data) {
const that = this;
data.forEach(function(ele,index){
console.log(that.pathName, ele.url)
if (('/' + that.pathName) == ele.url) {
that.selectMenu = '/' + that.pathName
}else {
......@@ -126,13 +111,13 @@
// 触发父组件路由
toRouter(path) {
var that = this;
const that = this;
that.$emit('toLeftRouterView', '/'+path)
},
// 刷新路由
refreshRoute() {
var that = this
const that = this
//获取项目名 pathname (路由的hash)
that.routePathName = window.location.hash.split('/')[1];
if (that.routePathName.indexOf('?')!= -1) {
......@@ -141,7 +126,6 @@
if (that.routePathName.indexOf('/')!= -1) {
that.routePathName = that.routePathName.split('/')[0]
}
console.log("routePathname:",that.routePathName)
that.pathName = that.routePathName
that.getLeftMenu()
},
......@@ -161,22 +145,25 @@
}
return father.level == 1; //返回第一层
});
tree.sort(function(a,b){
return a.sort - b.sort
});
return tree;
},
// 获取左侧菜单
/**
* 获取左侧菜单
*/
getLeftMenu() {
var that = this
var para = {
const that = this;
let para = {
project: that.repProjectName,
router: that.pathName,
requestProject: that.repProjectName
}
that.axios.post(that.baseUrl+'/haoban-manage-web/menu-detail',qs.stringify(para))
.then((res) => {
// console.log(res,res.data,res.data.errorCode)
var resData = res.data
let resData = res.data;
if (resData.errorCode == 1) {
if (!resData.result) {
that.$message.error({
......@@ -185,29 +172,15 @@
})
return;
}
that.setNewData(that.treeData(resData.result.leftMenu))
// if (!!resData.result.level4) {
// that.selectMenu = '/'+resData.result.level4.menuUrl
// return;
// }
// if (!!resData.result.level3) {
// that.selectMenu = '/'+resData.result.level3.menuUrl
// }
// sessionStorage.setItem('activeHead',resData.result.level2.menuCode)
return;
}
that.$message.error({
duration: 1000,
message: resData.message
})
})
.catch(function (error) {
console.log(error);
// that.toLogin()
that.$message.error({
duration: 1000,
message: error.message
......@@ -218,50 +191,39 @@
watch: {
$route: {
handler: function(val, oldVal){
console.log("左侧菜单插件获取当前路由:",val);
},
// 深度观察监听
deep: true
},
collapseFlag: function(newData,oldData){
var that = this;
// console.log("左侧新数据:",newData,oldData)
const that = this;
that.leftCollapse = newData;
},
projectName: function(newData,oldData){
var that = this;
// console.log("新数据:",newData,oldData)
const that = this;
that.repProjectName = newData || 'haoban-manage-web';
},
},
/* 接收数据 */
mounted(){
console.log("传递的左侧菜单参数:",this.projectName,this.$route)
var that = this;
// 项目名
that.repProjectName = that.projectName || 'haoban-manage-web';
const that = this;
that.repProjectName = that.projectName || 'haoban-manage-web'; // 获取项目名
// 获取高度
that.asideHeight = (document.documentElement.clientHeight || document.body.clientHeight) - 64 +'px';
//获取项目名 pathname (路由的hash)
that.pathName = window.location.hash.split('/')[1];
if (that.pathName.indexOf('?')!= -1) {
that.pathName = that.pathName.split('?')[0]
}
// 获取菜单
that.getLeftMenu();
//折叠参数
that.leftCollapse = that.collapseFlag;
},
}
}
</script>
......
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