mirror of
https://gitee.com/java110/MicroCommunityWeb.git
synced 2026-02-24 05:46:03 +08:00
优化代码
This commit is contained in:
parent
25a072a45b
commit
bf22867fb4
@ -57,11 +57,11 @@
|
||||
<div class="border-bottom">
|
||||
<vc:create path="frame/nav"></vc:create>
|
||||
</div>
|
||||
<div class="vc-wrapper vc-content" style="padding-bottom: 0px;">
|
||||
<div class="vc-wrapper vc-content padding-top-xs" style="padding-bottom: 0px;">
|
||||
<vc:create path="frame/breadcrumb"></vc:create>
|
||||
</div>
|
||||
<!-- -->
|
||||
<div id="component" class="vc-wrapper vc-content animated fadeInRight"
|
||||
<div id="component" class="vc-wrapper vc-content padding-top-xs animated fadeInRight"
|
||||
vc-path="/common/chooseEnterCommunity">
|
||||
<vc:create path="/pages/common/enterCommunity"></vc:create>
|
||||
</div>
|
||||
|
||||
@ -1,19 +1,9 @@
|
||||
<div id="breadcrumb" class="border-bottom white-bg page-heading" v-if="breadCrumbs.length > 0">
|
||||
<div class="row">
|
||||
<div class="col-lg-12" style="margin-left: 5px;">
|
||||
<h2>{{breadCrumbs.length > 0 ? breadCrumbs[breadCrumbs.length-1].pageName : ''}}</h2>
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item">
|
||||
<a href="/">首页</a>
|
||||
</li>
|
||||
<li class="breadcrumb-item" v-for="breadCrumb in breadCrumbs">
|
||||
<span v-if="breadCrumb.parentPageName == ''">
|
||||
{{breadCrumb.pageName}}
|
||||
</span>
|
||||
<strong v-if="breadCrumb.parentPageName != ''">{{breadCrumb.pageName}}</strong>
|
||||
</li>
|
||||
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
<div id="breadcrumb" class="border-bottom white-bg" v-if="breadCrumbs.length > 0">
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="nav-item" v-for="(item,index) in breadCrumbs">
|
||||
<span class="nav-link active" aria-current="page" @click="_changeSmallTab(item)">{{item.pageName}}
|
||||
<i class="fa fa-remove margin-left-sm"></i>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@ -19,49 +19,36 @@
|
||||
methods:{
|
||||
_freshBreadCrumbByUrl:function(){
|
||||
|
||||
var _tmpMenus = vc.getMenus();
|
||||
var _path = location.hash;
|
||||
if(location.hash.indexOf('?') != -1){
|
||||
_path = location.hash.substring(0,location.hash.indexOf('?'));
|
||||
}
|
||||
var _url = vc.getUrl()+_path;
|
||||
/**
|
||||
正常情况下是走不到这里的,
|
||||
因为系统登录时,就已经加载菜单信息缓存到本地了
|
||||
let tabs = vc.getTabFromLocal();
|
||||
|
||||
let _tmpMenus = vc.getMenus();
|
||||
|
||||
**/
|
||||
if(_tmpMenus == null || _tmpMenus == undefined){
|
||||
return ;
|
||||
}
|
||||
for(var menuIndex =0 ; menuIndex < _tmpMenus.length;menuIndex ++){
|
||||
//两层结构的情况
|
||||
if(_tmpMenus[menuIndex].hasOwnProperty('childs')){
|
||||
var _childs = _tmpMenus[menuIndex].childs;
|
||||
for(var _childIndex = 0; _childIndex < _childs.length; _childIndex ++){
|
||||
if(this._getRealUrl(_childs[_childIndex].href) == _url){
|
||||
var _tmpBreadCrumbInf = {
|
||||
parentPageName: "",
|
||||
pageName: _tmpMenus[menuIndex].name
|
||||
};
|
||||
this.breadCrumbs.push(_tmpBreadCrumbInf);
|
||||
|
||||
tabs.forEach(item => {
|
||||
let _path = item;
|
||||
if(_path.indexOf('?') != -1){
|
||||
_path = _path.substring(0,_path.indexOf('?'));
|
||||
}
|
||||
let _url = vc.getUrl()+_path;
|
||||
|
||||
_tmpMenus.forEach(_menu =>{
|
||||
_menu.childs.forEach(child=>{
|
||||
console.log(_url,child.href)
|
||||
if(_url == child.href){
|
||||
_tmpBreadCrumbInf = {
|
||||
parentPageName: _tmpMenus[menuIndex].name,
|
||||
pageName: _childs[_childIndex].name
|
||||
href: child.href,
|
||||
pageName: child.name,
|
||||
active:'0'
|
||||
};
|
||||
this.breadCrumbs.push(_tmpBreadCrumbInf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(this._getRealUrl(_tmpMenus[menuIndex].href) == url){
|
||||
var _tmpBreadCrumbInf = {
|
||||
parentPageName: "首页",
|
||||
pageName: _tmpMenus[menuIndex].name
|
||||
};
|
||||
this.breadCrumbs.push(_tmpBreadCrumbInf);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
});
|
||||
},
|
||||
|
||||
_getRealUrl:function(_url){
|
||||
@ -69,6 +56,9 @@
|
||||
return _url.substring(0, _url.indexOf('?'));
|
||||
}
|
||||
return _url;
|
||||
},
|
||||
_changeSmallTab:function(){
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -940,7 +940,7 @@ ul.nav-second-level {
|
||||
}
|
||||
|
||||
.vc-content {
|
||||
padding: 20px 20px 40px;
|
||||
padding: 20px 10px 20px;
|
||||
}
|
||||
|
||||
.white-bg {
|
||||
|
||||
@ -32,17 +32,17 @@
|
||||
<tbody>
|
||||
<tr v-for="community in communityInfo.enterCommunityInfo">
|
||||
<td class="text-center">
|
||||
<div class="vc-tr-td">
|
||||
<div class="">
|
||||
{{community.provName}}
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<div class="vc-tr-td">
|
||||
<div class="">
|
||||
{{community.cityName}}
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<div class="vc-tr-td">
|
||||
<div class="">
|
||||
{{community.areaName}}
|
||||
</div>
|
||||
</td>
|
||||
@ -55,7 +55,7 @@
|
||||
{{community.address}}
|
||||
</td> -->
|
||||
<td class="text-center">
|
||||
<div class="vc-tr-td">
|
||||
<div class="">
|
||||
{{community.communityId}}
|
||||
</div>
|
||||
</td>
|
||||
@ -70,12 +70,12 @@
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<div class="vc-tr-td">
|
||||
<div class="">
|
||||
{{community.startTime}}
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<div class="vc-tr-td">
|
||||
<div class="">
|
||||
{{community.endTime}}
|
||||
</div>
|
||||
</td>
|
||||
@ -86,7 +86,7 @@
|
||||
{{community.cityCode}}
|
||||
</td> -->
|
||||
<td class="text-center">
|
||||
<div class="vc-tr-td">
|
||||
<div class="">
|
||||
{{_showCommunityStatus(community.auditStatusCd)}}
|
||||
</div>
|
||||
</td>
|
||||
|
||||
@ -1998,6 +1998,12 @@
|
||||
if (!vcFramework.notNull(_componentUrl)) {
|
||||
return;
|
||||
}
|
||||
//获取参数
|
||||
let _tab = vc.getParam('tab')
|
||||
|
||||
if(_tab){
|
||||
vcFramework.setTabToLocal(_componentUrl);
|
||||
}
|
||||
refreshVcFramework();
|
||||
vcFramework.reBuilderVcTree();
|
||||
}, false);
|
||||
@ -2619,6 +2625,22 @@
|
||||
|
||||
vcFramework.setPageRouteToLocal = function(_obj) {
|
||||
let routes = vcFramework.getPageRouteFromLocal();
|
||||
|
||||
//判断是否已经有 如果有则删除
|
||||
let loction = 0;
|
||||
for (let routeIndex = 0; routeIndex < routes.length; routeIndex++) {
|
||||
_tmpRoute = routes[routeIndex];
|
||||
if (!_tmpRoute.pagePath || _tmpRoute.pagePath != _obj.pagePath) {
|
||||
continue;
|
||||
}
|
||||
loction = routeIndex;
|
||||
routes.splice(loction, 1);
|
||||
}
|
||||
|
||||
if(routes.length > 20){
|
||||
routes.shift();
|
||||
}
|
||||
|
||||
routes.push(_obj);
|
||||
window.localStorage.setItem('vcPageRoute', JSON.stringify(routes));
|
||||
}
|
||||
@ -2678,10 +2700,10 @@
|
||||
}
|
||||
|
||||
for (_key in _component) {
|
||||
if (_key.startsWith('$') || typeof key == 'function') {
|
||||
if (_key.startsWith('$') || _key.startsWith('_') || typeof _key == 'function') {
|
||||
continue;
|
||||
}
|
||||
_pageData.pageData[key] = _component[key];
|
||||
_pageData.pageData[_key] = _component[_key];
|
||||
}
|
||||
vcFramework.setPageRouteToLocal(_pageData);
|
||||
}
|
||||
@ -2690,4 +2712,47 @@
|
||||
//寻找当前页面是否在路由中 如果有恢复下数据,并做弹出
|
||||
vcFramework.recoverComponentByPageRoute();
|
||||
}, false);
|
||||
|
||||
|
||||
vcFramework.getTabFromLocal = function() {
|
||||
let tabStr = window.localStorage.getItem('vcTab');
|
||||
|
||||
let tabs = [];
|
||||
|
||||
if (!tabStr) {
|
||||
window.localStorage.setItem('vcTab', JSON.stringify(tabs))
|
||||
} else {
|
||||
tabs = JSON.parse(tabStr);
|
||||
}
|
||||
|
||||
return tabs;
|
||||
}
|
||||
|
||||
vcFramework.setTabToLocal = function(_obj) {
|
||||
let tabs = vcFramework.getTabFromLocal();
|
||||
|
||||
//判断是否已经有 如果有则删除
|
||||
for (let tabIndex = 0; tabIndex < tabs.length; tabIndex++) {
|
||||
_tmpTab = tabs[tabIndex];
|
||||
if (_tmpTab[tabIndex] == _obj) {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
if(tabs.length > 20){
|
||||
tabs.shift();
|
||||
}
|
||||
tabs.push(_obj);
|
||||
window.localStorage.setItem('vcTab', JSON.stringify(tabs));
|
||||
}
|
||||
|
||||
vcFramework.deleteTabToLocal = function(_obj) {
|
||||
let routes = vcFramework.getPageRouteFromLocal();
|
||||
for (let tabIndex = 0; tabIndex < tabs.length; tabIndex++) {
|
||||
_tmpTab = tabs[tabIndex];
|
||||
if (_tmpTab[tabIndex] == _obj) {
|
||||
tabs.splice(tabIndex,1);
|
||||
}
|
||||
}
|
||||
window.localStorage.setItem('vcPageRoute', JSON.stringify(routes));
|
||||
}
|
||||
})(window.vcFramework);
|
||||
Loading…
Reference in New Issue
Block a user