Commit 390ec659 by 无尘

fix: 修改原有文档菜单加载

parent 2b633734
<!DOCTYPE html><html><head><meta charset=utf-8><link rel="shortcut icon" href=./favicon.ico><title>达摩开放平台</title><link href=./static/css/app.a76a61d480038ed1715deea26a7efc66.css rel=stylesheet></head><body class=damolish><div id=app></div><script src=//web-1251519181.file.myqcloud.com/lib/vue/2.6.6/vue.min.js></script><script src=//web-1251519181.file.myqcloud.com/lib/vue-router/3.0.2/vue-router.min.js></script><script src=//web-1251519181.file.myqcloud.com/lib/vuex/3.1.0/vuex.min.js></script><script src=//web-1251519181.file.myqcloud.com/components/img-preview.2.0.00.js></script><script>// Raven.config('https://3715a345910d4c768e7a1ec14619c2d5@sentry.io/1413672').install();</script><script type=text/javascript src=./static/js/manifest.6a10a7e5909ed56d83e3.js></script><script type=text/javascript src=./static/js/vendor.0f5b275d4a227ad49647.js></script><script type=text/javascript src=./static/js/app.9c50334119061bcb2895.js></script></body></html>
\ No newline at end of file
<!DOCTYPE html><html><head><meta charset=utf-8><link rel="shortcut icon" href=./favicon.ico><title>达摩开放平台</title><link href=./static/css/app.2a9168a186ef7e2d0005a4fe7d38ca63.css rel=stylesheet></head><body class=damolish><div id=app></div><script src=//web-1251519181.file.myqcloud.com/lib/vue/2.6.6/vue.min.js></script><script src=//web-1251519181.file.myqcloud.com/lib/vue-router/3.0.2/vue-router.min.js></script><script src=//web-1251519181.file.myqcloud.com/lib/vuex/3.1.0/vuex.min.js></script><script src=//web-1251519181.file.myqcloud.com/components/img-preview.2.0.00.js></script><script>// Raven.config('https://3715a345910d4c768e7a1ec14619c2d5@sentry.io/1413672').install();</script><script type=text/javascript src=./static/js/manifest.4dd517ee0531de752b70.js></script><script type=text/javascript src=./static/js/vendor.0f5b275d4a227ad49647.js></script><script type=text/javascript src=./static/js/app.9c50334119061bcb2895.js></script></body></html>
\ No newline at end of file
!function(e){var n=window.webpackJsonp;window.webpackJsonp=function(r,a,c){for(var f,i,u,d=0,s=[];d<r.length;d++)i=r[d],t[i]&&s.push(t[i][0]),t[i]=0;for(f in a)Object.prototype.hasOwnProperty.call(a,f)&&(e[f]=a[f]);for(n&&n(r,a,c);s.length;)s.shift()();if(c)for(d=0;d<c.length;d++)u=o(o.s=c[d]);return u};var r={},t={13:0};function o(n){if(r[n])return r[n].exports;var t=r[n]={i:n,l:!1,exports:{}};return e[n].call(t.exports,t,t.exports,o),t.l=!0,t.exports}o.e=function(e){var n=t[e];if(0===n)return new Promise(function(e){e()});if(n)return n[2];var r=new Promise(function(r,o){n=t[e]=[r,o]});n[2]=r;var a=document.getElementsByTagName("head")[0],c=document.createElement("script");c.type="text/javascript",c.charset="utf-8",c.async=!0,c.timeout=12e4,o.nc&&c.setAttribute("nonce",o.nc),c.src=o.p+"static/js/"+e+"."+{0:"dc5820857959176b1da4",1:"adba71f29a9630854db5",2:"5ea71994ffb9873345e3",3:"2acdb0bfe14d02f22e32",4:"f07289269c5e84a9902a",5:"b3cf76f8c670cd2efb7e",6:"737da25334f9daa2d713",7:"ef03f48583a47962948c",8:"5e787f5eb2f4bd7cfb7b",9:"9caad4c0ba5b8b4813ee",10:"63807a09986add449f8a"}[e]+".js";var f=setTimeout(i,12e4);function i(){c.onerror=c.onload=null,clearTimeout(f);var n=t[e];0!==n&&(n&&n[1](new Error("Loading chunk "+e+" failed.")),t[e]=void 0)}return c.onerror=c.onload=i,a.appendChild(c),r},o.m=e,o.c=r,o.d=function(e,n,r){o.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},o.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(n,"a",n),n},o.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},o.p="./",o.oe=function(e){throw console.error(e),e}}([]);
\ No newline at end of file
!function(e){var n=window.webpackJsonp;window.webpackJsonp=function(r,a,c){for(var f,i,u,d=0,s=[];d<r.length;d++)i=r[d],t[i]&&s.push(t[i][0]),t[i]=0;for(f in a)Object.prototype.hasOwnProperty.call(a,f)&&(e[f]=a[f]);for(n&&n(r,a,c);s.length;)s.shift()();if(c)for(d=0;d<c.length;d++)u=o(o.s=c[d]);return u};var r={},t={13:0};function o(n){if(r[n])return r[n].exports;var t=r[n]={i:n,l:!1,exports:{}};return e[n].call(t.exports,t,t.exports,o),t.l=!0,t.exports}o.e=function(e){var n=t[e];if(0===n)return new Promise(function(e){e()});if(n)return n[2];var r=new Promise(function(r,o){n=t[e]=[r,o]});n[2]=r;var a=document.getElementsByTagName("head")[0],c=document.createElement("script");c.type="text/javascript",c.charset="utf-8",c.async=!0,c.timeout=12e4,o.nc&&c.setAttribute("nonce",o.nc),c.src=o.p+"static/js/"+e+"."+{0:"e1d089808563a1dca4d0",1:"adba71f29a9630854db5",2:"5ea71994ffb9873345e3",3:"2acdb0bfe14d02f22e32",4:"7c2a7394dc56bb340dee",5:"b3cf76f8c670cd2efb7e",6:"737da25334f9daa2d713",7:"ef03f48583a47962948c",8:"5e787f5eb2f4bd7cfb7b",9:"9caad4c0ba5b8b4813ee",10:"63807a09986add449f8a"}[e]+".js";var f=setTimeout(i,12e4);function i(){c.onerror=c.onload=null,clearTimeout(f);var n=t[e];0!==n&&(n&&n[1](new Error("Loading chunk "+e+" failed.")),t[e]=void 0)}return c.onerror=c.onload=i,a.appendChild(c),r},o.m=e,o.c=r,o.d=function(e,n,r){o.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},o.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(n,"a",n),n},o.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},o.p="./",o.oe=function(e){throw console.error(e),e}}([]);
\ No newline at end of file
<!--
* @Descripttion: 当前组件信息
* @version: 1.0.0
* @Author: 无尘
* @Date: 2019-09-11 16:35:07
* @LastEditors: 无尘
* @LastEditTime: 2019-10-18 14:12:42
-->
<!--
<open-doc-left :currentTab="currentTab" @changeDoc="changeDoc"></open-doc-left>
import openDocLeft from '@/components/open-doc-left.vue';
-->
......@@ -9,24 +17,24 @@
<li :key="index + 'level1'">
<div :class="['li-cell flex flex-space-between', activeId == item.menuId ? 'active-menu' : '']" @click="changeMenu(item)">
<span class="li-cell-name">{{ item.menuName }}</span>
<span v-if="item.children && item.children.length" :class="['li-cell-icon font_family icon-arrow_right', item.expanded ? 'rotate-icon' : '']"></span>
<span v-if="!item.children || !item.children.length" class="li-cell-icon icon-round"></span>
<span v-if="!item.leaf" :class="['li-cell-icon font_family icon-arrow_right', item.expanded ? 'rotate-icon' : '']"></span>
<span v-if="item.leaf" class="li-cell-icon icon-round"></span>
</div>
<ul v-if="item.children && item.children.length && item.expanded">
<template v-for="(levelTwo, two) in item.children">
<li :key="two + 'level1'">
<div :class="['li-cell flex flex-space-between', activeId == levelTwo.menuId ? 'active-menu' : '']" @click="changeMenu(levelTwo)">
<span class="p-l-15 li-cell-name border-box">{{ levelTwo.menuName }}</span>
<span v-if="levelTwo.children && levelTwo.children.length" :class="['li-cell-icon font_family icon-arrow_right', levelTwo.expanded ? 'rotate-icon' : '']"></span>
<span v-if="!levelTwo.children || !levelTwo.children.length" class="li-cell-icon icon-round"></span>
<span v-if="!levelTwo.leaf" :class="['li-cell-icon font_family icon-arrow_right', levelTwo.expanded ? 'rotate-icon' : '']"></span>
<span v-if="levelTwo.leaf" class="li-cell-icon icon-round"></span>
</div>
<ul v-if="levelTwo.children && levelTwo.children.length && levelTwo.expanded">
<template v-for="(levelThree, three) in levelTwo.children">
<li :key="three + 'level1'">
<div :class="['li-cell flex flex-space-between', activeId == levelThree.menuId ? 'active-menu' : '']" @click="changeMenu(levelThree)">
<span class="li-cell-name border-box p-l-30">{{ levelThree.menuName }}</span>
<span v-if="levelThree.children && levelThree.children.length" :class="['li-cell-icon font_family icon-arrow_right', levelThree.expanded ? 'rotate-icon' : '']"></span>
<span v-if="!levelThree.children || !levelThree.children.length" class="li-cell-icon icon-round"></span>
<span v-if="!levelThree.leaf" :class="['li-cell-icon font_family icon-arrow_right', levelThree.expanded ? 'rotate-icon' : '']"></span>
<span v-if="levelThree.leaf" class="li-cell-icon icon-round"></span>
</div>
<ul v-if="levelThree.children && levelThree.children.length && levelThree.expanded">
<template v-for="(levelFour, four) in levelThree.children">
......@@ -76,6 +84,7 @@ export default {
parentId: '1',
relationData: '',
seq: 0,
leaf: true,
subType: 1,
updateFlag: 1,
expanded: false, // 新增展开
......@@ -88,19 +97,40 @@ export default {
/**
* 菜单切换
*/
changeMenu(item) {
async changeMenu(item) {
const that = this;
// 注意:这里要判断是否有子级,是否展开,是否关联
that.activeId = item.menuId;
// 如果有子级,展开或者折叠显示
if (item.children && item.children.length) {
item.expanded = !item.expanded;
return false;
}
if (!item.leaf && !item.children.length) {
item.expanded = !item.expanded;
that.getMenuData(item.menuId, item);
// that.$emit('changeDoc', {});
} else {
// 没有子级先加载看看是否有子级
that.$emit('changeDoc', item);
}
},
/**
* 处理递归判断
*/
handleResultData(itemData) {
const that = this;
if (itemData.children && itemData.children.length) {
itemData.children.forEach(child => {
child.expanded = false;
if (child.menuId == that.activeId) {
child.expanded = true;
that.$emit('changeDoc', child);
}
that.handleResultData(child);
});
}
},
getMenuData(parentId, node) {
const that = this;
let para = {
......@@ -111,52 +141,27 @@ export default {
.then(res => {
let resData = res.data;
if (resData.code == '0000') {
if (!!resData.result && resData.result.length) {
if (!!resData.result && resData.result.length && !node) {
resData.result.forEach(ele => {
ele.expanded = false;
ele.children = [];
if (ele.menuId == that.activeId) {
that.$emit('changeDoc', ele);
}
if (ele.children && ele.children.length) {
ele.children.forEach(child => {
child.expanded = false;
if (child.menuId == that.activeId) {
ele.expanded = true;
that.$emit('changeDoc', child);
}
if (child.children && child.children.length) {
child.children.forEach(key => {
key.expanded = false;
if (key.menuId == that.activeId) {
child.expanded = true;
that.$emit('changeDoc', key);
}
key.children.forEach(el => {
if (el.menuId == that.activeId) {
key.expanded = true;
that.$emit('changeDoc', el);
}
});
});
}
});
}
});
if (!that.$route.query.menuId) {
that.activeId = resData.result[0].menuId;
that.$emit('changeDoc', resData.result[0]);
}
}
/* if (node) {
node.children = resData.result || [];
that.$forceUpdate();
if (!!resData.result && resData.result.length && node) {
resData.result.forEach(ele => {
ele.expanded = false;
ele.children = [];
})
node.children = resData.result;
return false;
}
// 没有子级,返回当前菜单数据
if (node && !resData.result.length) {
that.$emit('changeDoc', node);
return false;
} */
that.menuData = resData.result || [];
return;
}
......
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