Commit f51e3fe9 authored by tianhongyang's avatar tianhongyang

tab页签 以fullpath为基准打开页面

parent 363bcf08
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
<script> <script>
import iframeToggle from "./IframeToggle/index" import iframeToggle from "./IframeToggle/index"
export default { export default {
name: 'AppMain', name: 'AppMain',
components: { iframeToggle }, components: { iframeToggle },
...@@ -20,7 +19,7 @@ export default { ...@@ -20,7 +19,7 @@ export default {
return this.$store.state.tagsView.cachedViews return this.$store.state.tagsView.cachedViews
}, },
key() { key() {
return this.$route.path return this.$route.fullPath
} }
} }
} }
......
...@@ -3,72 +3,58 @@ ...@@ -3,72 +3,58 @@
<div id="getviews"> <div id="getviews">
<div class="alltags" v-if="visitedViews.length > 0"> <div class="alltags" v-if="visitedViews.length > 0">
<div class="imgs" @click="closeall"> <div class="imgs" @click="closeall">
<img src="@/assets/images/all.png" v-if="!showall"/> <img src="@/assets/images/all.png" v-if="!showall" />
<img src="@/assets/images/all_on.png" v-if="showall"/> <img src="@/assets/images/all_on.png" v-if="showall" />
<!--<i class="el-icon-arrow-down" v-if="!showall"></i> <i class="el-icon-arrow-up" v-if="showall"></i>--> <!--<i class="el-icon-arrow-down" v-if="!showall"></i> <i class="el-icon-arrow-up" v-if="showall"></i>-->
</div> </div>
<el-collapse-transition> <el-collapse-transition>
<div class="tagslist" :class="{'noshow':!showall}"> <div class="tagslist" :class="{'noshow':!showall}">
<router-link <router-link v-for="(tag, index) in visitedViews" ref="tag" :key="tag.fullPath" :class="isActive(tag)?'active':''"
v-for="(tag, index) in visitedViews" :to="{ path: tag.fullPath, query: tag.query, fullPath: tag.fullPath }" tag="span" class="tags-view-item"
ref="tag" @contextmenu.prevent.native="openMenu(tag,$event)">
:key="tag.path"
:class="isActive(tag)?'active':''"
:to="{ path: tag.path, query: tag.query, fullPath: tag.fullPath }"
tag="span"
class="tags-view-item"
@contextmenu.prevent.native="openMenu(tag,$event)"
>
<div @click="changetags"> <div @click="changetags">
<i class="el-icon-check"></i> <i class="el-icon-check"></i>
<span :id="isActive(tag)?'tagTitles':''">{{ tag.title }}</span> <span :id="isActive(tag)?'tagTitles':''">{{ tag.title }}</span>
</div> </div>
</router-link> </router-link>
<div class="clasall" @click="closeAllTag(selectedTag)">关闭全部标签</div> <div class="clasall" @click="closeAllTag(selectedTag)">关闭全部标签</div>
</div> </div>
</el-collapse-transition> </el-collapse-transition>
</div> </div>
<scroll-pane ref="scrollPane" class="tags-view-wrapper" @scroll="handleScroll"> <scroll-pane ref="scrollPane" class="tags-view-wrapper" @scroll="handleScroll">
<draggable v-model="visitedViews" :options="dragOptions" @end="end"> <draggable v-model="visitedViews" :options="dragOptions" @end="end">
<router-link <router-link v-for="(tag, index) in visitedViews" ref="tag" :key="tag.fullPath" :class="isActive(tag)?'active':''"
v-for="(tag, index) in visitedViews" :to="{ path: tag.fullPath, query: tag.query, fullPath: tag.fullPath }" tag="span" class="tags-view-item"
ref="tag" @click.middle.native="!isAffix(tag)?closeSelectedTag(tag):''" @contextmenu.prevent.native="openMenu(tag,$event)">
:key="tag.path"
:class="isActive(tag)?'active':''"
:to="{ path: tag.path, query: tag.query, fullPath: tag.fullPath }"
tag="span"
class="tags-view-item"
@click.middle.native="!isAffix(tag)?closeSelectedTag(tag):''"
@contextmenu.prevent.native="openMenu(tag,$event)"
>
<svg :class="isActive(tag)?'tags-icon tags-icon-active':'tags-icon'" aria-hidden="true"> <svg :class="isActive(tag)?'tags-icon tags-icon-active':'tags-icon'" aria-hidden="true">
<use :xlink:href="iconName(tag)" /> <use :xlink:href="iconName(tag)" />
</svg> </svg>
<span :id="isActive(tag)?'tagTitle':''">{{ tag.title.replace(/<[^>]+>/g, '') }}</span> <span :id="isActive(tag)?'tagTitle':''">{{ tag.title.replace(/<[^>]+>/g, '') }}</span>
<span v-if="!isAffix(tag)" class="el-icon-close" @click.prevent.stop="closeSelectedTag(tag)" /> <span v-if="!isAffix(tag)" class="el-icon-close" @click.prevent.stop="closeSelectedTag(tag)" />
<i :class="index!=visitedViews.length-1 && index != isActiveIndex() && index != isActiveIndex()-1?'tags-item-line':'tags-item-line item-color'" /> <i
:class="index!=visitedViews.length-1 && index != isActiveIndex() && index != isActiveIndex()-1?'tags-item-line':'tags-item-line item-color'" />
</router-link> </router-link>
</draggable> </draggable>
</scroll-pane> </scroll-pane>
<ul v-show="visible" :style="{left:left+'px',top:top+'px'}" class="contextmenu"> <ul v-show="visible" :style="{left:left+'px',top:top+'px'}" class="contextmenu">
<li @click="refreshSelectedTag(selectedTag)"><i class="el-icon-refresh-right"></i> 刷新页面</li> <li @click="refreshSelectedTag(selectedTag)"><i class="el-icon-refresh-right"></i> 刷新页面</li>
<li v-if="!isAffix(selectedTag)" @click="closeSelectedTag(selectedTag)"><i class="el-icon-close"></i> 关闭当前</li> <li v-if="!isAffix(selectedTag)" @click="closeSelectedTag(selectedTag)"><i class="el-icon-close"></i> 关闭当前</li>
<li @click="closeOthersTags"><i class="el-icon-circle-close"></i> 关闭其他</li> <li @click="closeOthersTags"><i class="el-icon-circle-close"></i> 关闭其他</li>
<li v-if="!isFirstView()" @click="closeLeftTags"><i class="el-icon-back"></i> 关闭左侧</li> <li v-if="!isFirstView()" @click="closeLeftTags"><i class="el-icon-back"></i> 关闭左侧</li>
<li v-if="!isLastView()" @click="closeRightTags"><i class="el-icon-right"></i> 关闭右侧</li> <li v-if="!isLastView()" @click="closeRightTags"><i class="el-icon-right"></i> 关闭右侧</li>
<li @click="closeAllTags(selectedTag)"><i class="el-icon-circle-close"></i> 全部关闭</li> <li @click="closeAllTags(selectedTag)"><i class="el-icon-circle-close"></i> 全部关闭</li>
</ul> </ul>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import draggable from 'vuedraggable' import draggable from 'vuedraggable';
import ScrollPane from './ScrollPane' import ScrollPane from './ScrollPane';
import path from 'path' import path from 'path';
export default { export default {
components: { ScrollPane,draggable }, components: { ScrollPane, draggable },
data() { data() {
return { return {
visible: false, visible: false,
...@@ -76,7 +62,7 @@ export default { ...@@ -76,7 +62,7 @@ export default {
left: 0, left: 0,
selectedTag: {}, selectedTag: {},
affixTags: [], affixTags: [],
showall:false, showall: false,
dragOptions: { dragOptions: {
animation: 200, // 动画时间,单位毫秒 animation: 200, // 动画时间,单位毫秒
group: 'items', // 分组,同一分组内的元素可以互相拖拽 group: 'items', // 分组,同一分组内的元素可以互相拖拽
...@@ -84,34 +70,34 @@ export default { ...@@ -84,34 +70,34 @@ export default {
sort: true, // 是否启用排序功能 sort: true, // 是否启用排序功能
draggable: '.tags-view-item', // 可拖拽元素的选择器 draggable: '.tags-view-item', // 可拖拽元素的选择器
} }
} };
}, },
computed: { computed: {
visitedViews:{ visitedViews: {
get() { get() {
return this.$store.state.tagsView.visitedViews return this.$store.state.tagsView.visitedViews;
}, },
set() {} set() { }
}, },
iconName() { iconName() {
return function(val) { return function (val) {
let svgIcon = val.meta && val.meta.icon, currentIcon = '' let svgIcon = val.meta && val.meta.icon, currentIcon = '';
let icon = this.isActive(val) ? svgIcon+'Tags' : svgIcon+'Tag' let icon = this.isActive(val) ? svgIcon + 'Tags' : svgIcon + 'Tag';
if (!svgIcon) { if (!svgIcon) {
const index = val.path.indexOf('/', val.path.indexOf('/') + 1) const index = val.path.indexOf('/', val.path.indexOf('/') + 1);
const parentPath = val.path.slice(0, index) const parentPath = val.path.slice(0, index);
const currentRoute = this.$router.options.routes.find(item => item.path === parentPath) const currentRoute = this.$router.options.routes.find(item => item.path === parentPath);
if(currentRoute){ if (currentRoute) {
currentIcon = currentRoute.meta && currentRoute.meta.icon currentIcon = currentRoute.meta && currentRoute.meta.icon;
icon = this.isActive(val) ? currentIcon+'Tags' : currentIcon+'Tag' icon = this.isActive(val) ? currentIcon + 'Tags' : currentIcon + 'Tag';
} }
} }
icon = (svgIcon && svgIcon != '#') || (currentIcon && svgIcon != '#') ? icon : this.isActive(val) ? 'defaultTags' : 'defaultTag' icon = (svgIcon && svgIcon != '#') || (currentIcon && svgIcon != '#') ? icon : this.isActive(val) ? 'defaultTags' : 'defaultTag';
return `#icon-${icon}` return `#icon-${icon}`;
} };
}, },
routes() { routes() {
return this.$store.state.permission.routes return this.$store.state.permission.routes;
}, },
theme() { theme() {
return this.$store.state.settings.theme; return this.$store.state.settings.theme;
...@@ -119,234 +105,235 @@ export default { ...@@ -119,234 +105,235 @@ export default {
}, },
watch: { watch: {
$route() { $route() {
this.addTags() // console.log(this.$route);
this.moveToCurrentTag() this.addTags();
this.getviews() this.moveToCurrentTag();
this.getviews();
}, },
visible(value) { visible(value) {
if (value) { if (value) {
document.body.addEventListener('click', this.closeMenu) document.body.addEventListener('click', this.closeMenu);
} else { } else {
document.body.removeEventListener('click', this.closeMenu) document.body.removeEventListener('click', this.closeMenu);
} }
}, },
}, },
mounted() { mounted() {
this.initTags() this.initTags();
this.addTags() this.addTags();
// this.getviews() // this.getviews()
}, },
methods: { methods: {
getviews(){ getviews() {
let viewlist = [] let viewlist = [];
let views = this.$store.state.tagsView.visitedViews let views = this.$store.state.tagsView.visitedViews;
views.forEach(view =>{ views.forEach(view => {
let li = {} let li = {};
li.fullPath = view.fullPath li.fullPath = view.fullPath;
li.hash = view.hash li.hash = view.hash;
li.meta = view.meta li.meta = view.meta;
li.name = view.name li.name = view.name;
li.params = view.params li.params = view.params;
li.path = view.path li.path = view.path;
li.query = view.query li.query = view.query;
li.title = view.title li.title = view.title;
// li.matched = view.matched //此条数据放出会报错 // li.matched = view.matched //此条数据放出会报错
viewlist.push(li) viewlist.push(li);
}) });
sessionStorage.setItem("views",JSON.stringify(viewlist)) sessionStorage.setItem("views", JSON.stringify(viewlist));
}, },
changetags(){ changetags() {
this.showall = false this.showall = false;
}, },
closeall(){ closeall() {
if(this.showall == true){ if (this.showall == true) {
this.showall = false this.showall = false;
}else{ } else {
this.showall = true this.showall = true;
} }
}, },
isActive(route) { isActive(route) {
return route.path.split("?")[0] === this.$route.path return route.fullPath == this.$route.fullPath;
}, },
isAffix(tag) { isAffix(tag) {
return tag.meta && tag.meta.affix return tag.meta && tag.meta.affix;
}, },
isActiveIndex() { isActiveIndex() {
const idx = this.visitedViews.findIndex(item => item.path === this.$route.path) || 0 const idx = this.visitedViews.findIndex(item => item.fullPath === this.$route.fullPath) || 0;
return idx return idx;
}, },
isFirstView() { isFirstView() {
try { try {
return this.selectedTag.fullPath === '/index' || this.selectedTag.fullPath === this.visitedViews[1].fullPath return this.selectedTag.fullPath === '/index' || this.selectedTag.fullPath === this.visitedViews[1].fullPath;
} catch (err) { } catch (err) {
return false return false;
} }
}, },
isLastView() { isLastView() {
try { try {
return this.selectedTag.fullPath === this.visitedViews[this.visitedViews.length - 1].fullPath return this.selectedTag.fullPath === this.visitedViews[this.visitedViews.length - 1].fullPath;
} catch (err) { } catch (err) {
return false return false;
} }
}, },
filterAffixTags(routes, basePath = '/') { filterAffixTags(routes, basePath = '/') {
let tags = [] let tags = [];
routes.forEach(route => { routes.forEach(route => {
if (route.meta && route.meta.affix) { if (route.meta && route.meta.affix) {
const tagPath = path.resolve(basePath, route.path) const tagPath = path.resolve(basePath, route.path);
tags.push({ tags.push({
fullPath: tagPath, fullPath: tagPath,
path: tagPath, path: tagPath,
name: route.name, name: route.name,
meta: { ...route.meta } meta: { ...route.meta }
}) });
} }
if (route.children) { if (route.children) {
const tempTags = this.filterAffixTags(route.children, route.path) const tempTags = this.filterAffixTags(route.children, route.fullPath);
if (tempTags.length >= 1) { if (tempTags.length >= 1) {
tags = [...tags, ...tempTags] tags = [...tags, ...tempTags];
} }
} }
}) });
return tags return tags;
}, },
initTags() { initTags() {
const affixTags = this.affixTags = this.filterAffixTags(this.routes) const affixTags = this.affixTags = this.filterAffixTags(this.routes);
for (const tag of affixTags) { for (const tag of affixTags) {
// Must have tag name // Must have tag name
if (tag.name) { if (tag.name) {
this.$store.dispatch('tagsView/addVisitedView', tag) this.$store.dispatch('tagsView/addVisitedView', tag);
} }
} }
}, },
addTags() { addTags() {
const { name } = this.$route const { name } = this.$route;
if (name) { if (name) {
this.$store.dispatch('tagsView/addView', this.$route) this.$store.dispatch('tagsView/addView', this.$route);
if (this.$route.meta.link) { if (this.$route.meta.link) {
this.$store.dispatch('tagsView/addIframeView', this.$route) this.$store.dispatch('tagsView/addIframeView', this.$route);
} }
} }
return false return false;
}, },
moveToCurrentTag() { moveToCurrentTag() {
const tags = this.$refs.tag const tags = this.$refs.tag;
this.$nextTick(() => { this.$nextTick(() => {
for (const tag of tags) { for (const tag of tags) {
if (tag.to.path === this.$route.path) { if (tag.to.fullPath === this.$route.fullPath) {
this.$refs.scrollPane.moveToTarget(tag) this.$refs.scrollPane.moveToTarget(tag);
// when query is different then update // when query is different then update
if (tag.to.fullPath !== this.$route.fullPath) { if (tag.to.fullPath !== this.$route.fullPath) {
this.$store.dispatch('tagsView/updateVisitedView', this.$route) this.$store.dispatch('tagsView/updateVisitedView', this.$route);
} }
break break;
} }
} }
}) });
}, },
refreshSelectedTag(view) { refreshSelectedTag(view) {
this.$tab.refreshPage(view); this.$tab.refreshPage(view);
if (this.$route.meta.link) { if (this.$route.meta.link) {
this.$store.dispatch('tagsView/delIframeView', this.$route) this.$store.dispatch('tagsView/delIframeView', this.$route);
} }
}, },
closeSelectedTag(view) { closeSelectedTag(view) {
this.$tab.closePage(view).then(({ visitedViews }) => { this.$tab.closePage(view).then(({ visitedViews }) => {
if (this.isActive(view)) { if (this.isActive(view)) {
this.toLastView(visitedViews, view) this.toLastView(visitedViews, view);
} }
}) });
}, },
closeRightTags() { closeRightTags() {
this.$tab.closeRightPage(this.selectedTag).then(visitedViews => { this.$tab.closeRightPage(this.selectedTag).then(visitedViews => {
if (!visitedViews.find(i => i.fullPath === this.$route.fullPath)) { if (!visitedViews.find(i => i.fullPath === this.$route.fullPath)) {
this.toLastView(visitedViews) this.toLastView(visitedViews);
} }
}) });
}, },
closeLeftTags() { closeLeftTags() {
this.$tab.closeLeftPage(this.selectedTag).then(visitedViews => { this.$tab.closeLeftPage(this.selectedTag).then(visitedViews => {
if (!visitedViews.find(i => i.fullPath === this.$route.fullPath)) { if (!visitedViews.find(i => i.fullPath === this.$route.fullPath)) {
this.toLastView(visitedViews) this.toLastView(visitedViews);
} }
}) });
}, },
closeOthersTags() { closeOthersTags() {
this.$router.push(this.selectedTag.fullPath).catch(()=>{}); this.$router.push(this.selectedTag.fullPath).catch(() => { });
this.$tab.closeOtherPage(this.selectedTag).then(() => { this.$tab.closeOtherPage(this.selectedTag).then(() => {
this.moveToCurrentTag() this.moveToCurrentTag();
}) });
}, },
closeAllTag(view){ closeAllTag(view) {
this.$nextTick(()=>{ this.$nextTick(() => {
this.showall = false this.showall = false;
this.closeAllTags(view) this.closeAllTags(view);
}) });
}, },
closeAllTags(view) { closeAllTags(view) {
this.$tab.closeAllPage().then(({ visitedViews }) => { this.$tab.closeAllPage().then(({ visitedViews }) => {
if (this.affixTags.some(tag => tag.path === this.$route.path)) { if (this.affixTags.some(tag => tag.fullPath === this.$route.fullPath)) {
return return;
} }
this.toLastView(visitedViews, view) this.toLastView(visitedViews, view);
}) });
}, },
toLastView(visitedViews, view) { toLastView(visitedViews, view) {
const latestView = visitedViews.slice(-1)[0] const latestView = visitedViews.slice(-1)[0];
if (latestView) { if (latestView) {
this.$router.push(latestView.fullPath) this.$router.push(latestView.fullPath);
} else { } else {
// now the default is to redirect to the home page if there is no tags-view, // now the default is to redirect to the home page if there is no tags-view,
// you can adjust it according to your needs. // you can adjust it according to your needs.
if (view.name === 'Dashboard') { if (view.name === 'Dashboard') {
// to reload home page // to reload home page
this.$router.replace({ path: '/redirect' + view.fullPath }) this.$router.replace({ path: '/redirect' + view.fullPath });
} else { } else {
this.$router.push('/') this.$router.push('/');
} }
} }
}, },
openMenu(tag, e) { openMenu(tag, e) {
const menuMinWidth = 105 const menuMinWidth = 105;
const offsetLeft = this.$el.getBoundingClientRect().left // container margin left const offsetLeft = this.$el.getBoundingClientRect().left; // container margin left
const offsetWidth = this.$el.offsetWidth // container width const offsetWidth = this.$el.offsetWidth; // container width
const maxLeft = offsetWidth - menuMinWidth // left boundary const maxLeft = offsetWidth - menuMinWidth; // left boundary
const left = e.clientX - offsetLeft + 15 // 15: margin right const left = e.clientX - offsetLeft + 15; // 15: margin right
if (left > maxLeft) { if (left > maxLeft) {
this.left = maxLeft this.left = maxLeft;
} else { } else {
this.left = left this.left = left;
} }
this.top = e.clientY this.top = e.clientY;
this.visible = true this.visible = true;
this.selectedTag = tag this.selectedTag = tag;
}, },
closeMenu() { closeMenu() {
this.visible = false this.visible = false;
}, },
handleScroll() { handleScroll() {
this.closeMenu() this.closeMenu();
}, },
end (event) { end(event) {
//调换顺序 //调换顺序
let oldIndex = event.oldIndex//移动初始位置 let oldIndex = event.oldIndex;//移动初始位置
let newIndex = event.newIndex//运动终止位置 let newIndex = event.newIndex;//运动终止位置
let diff = Math.abs(newIndex - oldIndex)//插值绝对值 let diff = Math.abs(newIndex - oldIndex);//插值绝对值
let index = this.visitedViews[oldIndex] let index = this.visitedViews[oldIndex];
if (eval(oldIndex) > eval(newIndex)) { if (eval(oldIndex) > eval(newIndex)) {
for (let i = 0; i < diff; i++) { for (let i = 0; i < diff; i++) {
this.visitedViews[oldIndex - i] = this.visitedViews[oldIndex - i - 1] this.visitedViews[oldIndex - i] = this.visitedViews[oldIndex - i - 1];
} }
this.visitedViews[newIndex] = index this.visitedViews[newIndex] = index;
} else { } else {
for (let i = 0; i < diff; i++) { for (let i = 0; i < diff; i++) {
this.visitedViews[oldIndex + i] = this.visitedViews[oldIndex + i + 1] this.visitedViews[oldIndex + i] = this.visitedViews[oldIndex + i + 1];
} }
this.visitedViews[newIndex] = index this.visitedViews[newIndex] = index;
} }
this.$forceUpdate() this.$forceUpdate();
}, },
} }
} }
...@@ -358,7 +345,7 @@ export default { ...@@ -358,7 +345,7 @@ export default {
width: 100%; width: 100%;
background: #fff; background: #fff;
position: relative; position: relative;
::v-deep .el-scrollbar__wrap{ ::v-deep .el-scrollbar__wrap {
margin-left: 64px; margin-left: 64px;
} }
.tags-view-wrapper { .tags-view-wrapper {
...@@ -373,45 +360,45 @@ export default { ...@@ -373,45 +360,45 @@ export default {
background: #fff; background: #fff;
padding: 0 20px 0 8px; padding: 0 20px 0 8px;
font-size: 12px; font-size: 12px;
.tags-icon{ .tags-icon {
width: 16px; width: 16px;
height: 16px; height: 16px;
fill: currentColor; fill: currentColor;
color: #5a5e66; color: #5a5e66;
margin: 8px 4px -3px 4px; margin: 8px 4px -3px 4px;
&.tags-icon-active{ &.tags-icon-active {
color: pink; color: pink;
} }
} }
.tags-item-line{ .tags-item-line {
display: block; display: block;
width: 1px; width: 1px;
height: 24px; height: 24px;
background: #D0D1D9; background: #d0d1d9;
position: absolute; position: absolute;
right: 0; right: 0;
top: 4px; top: 4px;
z-index: 2; z-index: 2;
&.item-color{ &.item-color {
background: #FFFFFF; background: #ffffff;
} }
} }
/*&:first-of-type {*/ /*&:first-of-type {*/
/*margin-left: 64px;*/ /*margin-left: 64px;*/
/*}*/ /*}*/
&:hover { &:hover {
.el-icon-close{ .el-icon-close {
background-color: rgba(153,153,153,0.3); background-color: rgba(153, 153, 153, 0.3);
color: #999999; color: #999999;
} }
} }
&.active { &.active {
background-color: #F5F5F5; background-color: #f5f5f5;
color: #232323; color: #232323;
border-top-left-radius: 10px; border-top-left-radius: 10px;
border-top-right-radius: 10px; border-top-right-radius: 10px;
&:hover { &:hover {
.el-icon-close{ .el-icon-close {
background-color: initial; background-color: initial;
color: initial; color: initial;
} }
...@@ -430,7 +417,7 @@ export default { ...@@ -430,7 +417,7 @@ export default {
font-size: 12px; font-size: 12px;
font-weight: 400; font-weight: 400;
color: #333; color: #333;
box-shadow: 2px 2px 3px 0 rgba(0, 0, 0, .3); box-shadow: 2px 2px 3px 0 rgba(0, 0, 0, 0.3);
li { li {
margin: 0; margin: 0;
padding: 7px 16px; padding: 7px 16px;
...@@ -440,7 +427,7 @@ export default { ...@@ -440,7 +427,7 @@ export default {
} }
} }
} }
.alltags{ .alltags {
position: absolute; position: absolute;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
...@@ -451,20 +438,20 @@ export default { ...@@ -451,20 +438,20 @@ export default {
cursor: pointer; cursor: pointer;
text-align: center; text-align: center;
z-index: 10; z-index: 10;
&::after{ &::after {
content: ' '; content: " ";
position: absolute; position: absolute;
border-right: 1px solid #EFEFEF; border-right: 1px solid #efefef;
height: 18px; height: 18px;
width: 0; width: 0;
top: 3px; top: 3px;
right: -8px; right: -8px;
} }
.imgs>img{ .imgs > img {
width: 24px; width: 24px;
height: 24px; height: 24px;
} }
.tagslist{ .tagslist {
transition: all 0.2s; transition: all 0.2s;
display: block; display: block;
position: absolute; position: absolute;
...@@ -482,46 +469,47 @@ export default { ...@@ -482,46 +469,47 @@ export default {
width: 146px; width: 146px;
text-align: left; text-align: left;
border-radius: 4px; border-radius: 4px;
box-shadow: 0 2px 9px 2px rgba(0,0,0,.09), 0 1px 2px -2px rgba(0,0,0,.16); box-shadow: 0 2px 9px 2px rgba(0, 0, 0, 0.09),
.tags-view-item{ 0 1px 2px -2px rgba(0, 0, 0, 0.16);
.tags-view-item {
display: block; display: block;
position: relative; position: relative;
>div{ > div {
padding: 8px 8px 8px 32px; padding: 8px 8px 8px 32px;
line-height: 20px; line-height: 20px;
white-space: nowrap; white-space: nowrap;
text-overflow: ellipsis; text-overflow: ellipsis;
overflow: hidden; overflow: hidden;
} }
&:hover{ &:hover {
background: rgba(0, 0, 0, 0.04); background: rgba(0, 0, 0, 0.04);
} }
.el-icon-check{ .el-icon-check {
display: none; display: none;
position: absolute; position: absolute;
left: 8px; left: 8px;
width: 16px; width: 16px;
font-size: 16px; font-size: 16px;
} }
&.active{ &.active {
background: rgba(0, 129, 255, 0.04); background: rgba(0, 129, 255, 0.04);
.el-icon-check{ .el-icon-check {
display: block; display: block;
color: #0081FF; color: #0081ff;
} }
} }
} }
.clasall{ .clasall {
border-top: 1px solid #EFEFEF; border-top: 1px solid #efefef;
padding: 10px 32px; padding: 10px 32px;
line-height: 20px; line-height: 20px;
color: #FF3C3C; color: #ff3c3c;
&:hover{ &:hover {
background: #FFECE8; background: #ffece8;
} }
} }
} }
.noshow{ .noshow {
display: none; display: none;
opacity: 0; opacity: 0;
/*height: 0;*/ /*height: 0;*/
...@@ -543,10 +531,10 @@ export default { ...@@ -543,10 +531,10 @@ export default {
vertical-align: 2px; vertical-align: 2px;
border-radius: 50%; border-radius: 50%;
text-align: center; text-align: center;
transition: all .3s cubic-bezier(.645, .045, .355, 1); transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
transform-origin: 100% 50%; transform-origin: 100% 50%;
&:before { &:before {
transform: scale(.95); transform: scale(0.95);
display: inline-block; display: inline-block;
vertical-align: -2.5px; vertical-align: -2.5px;
} }
......
...@@ -7,7 +7,7 @@ const state = { ...@@ -7,7 +7,7 @@ const state = {
const mutations = { const mutations = {
ADD_IFRAME_VIEW: (state, view) => { ADD_IFRAME_VIEW: (state, view) => {
if (state.iframeViews.some(v => v.path === view.path)) return if (state.iframeViews.some(v => v.fullPath === view.fullPath)) return
state.iframeViews.push( state.iframeViews.push(
Object.assign({}, view, { Object.assign({}, view, {
title: view.meta.title || 'no-name' title: view.meta.title || 'no-name'
...@@ -15,7 +15,7 @@ const mutations = { ...@@ -15,7 +15,7 @@ const mutations = {
) )
}, },
ADD_VISITED_VIEW: (state, view) => { ADD_VISITED_VIEW: (state, view) => {
if (state.visitedViews.some(v => v.path === view.path)) return if (state.visitedViews.some(v => v.fullPath === view.fullPath)) return
state.visitedViews.push( state.visitedViews.push(
Object.assign({}, view, { Object.assign({}, view, {
title: view.meta.title || 'no-name' title: view.meta.title || 'no-name'
...@@ -30,15 +30,15 @@ const mutations = { ...@@ -30,15 +30,15 @@ const mutations = {
}, },
DEL_VISITED_VIEW: (state, view) => { DEL_VISITED_VIEW: (state, view) => {
for (const [i, v] of state.visitedViews.entries()) { for (const [i, v] of state.visitedViews.entries()) {
if (v.path === view.path) { if (v.fullPath === view.fullPath) {
state.visitedViews.splice(i, 1) state.visitedViews.splice(i, 1)
break break
} }
} }
state.iframeViews = state.iframeViews.filter(item => item.path !== view.path) state.iframeViews = state.iframeViews.filter(item => item.fullPath !== view.fullPath)
}, },
DEL_IFRAME_VIEW: (state, view) => { DEL_IFRAME_VIEW: (state, view) => {
state.iframeViews = state.iframeViews.filter(item => item.path !== view.path) state.iframeViews = state.iframeViews.filter(item => item.fullPath !== view.fullPath)
}, },
DEL_CACHED_VIEW: (state, view) => { DEL_CACHED_VIEW: (state, view) => {
const index = state.cachedViews.indexOf(view.name) const index = state.cachedViews.indexOf(view.name)
...@@ -47,9 +47,9 @@ const mutations = { ...@@ -47,9 +47,9 @@ const mutations = {
DEL_OTHERS_VISITED_VIEWS: (state, view) => { DEL_OTHERS_VISITED_VIEWS: (state, view) => {
state.visitedViews = state.visitedViews.filter(v => { state.visitedViews = state.visitedViews.filter(v => {
return v.meta.affix || v.path === view.path return v.meta.affix || v.fullPath === view.fullPath
}) })
state.iframeViews = state.iframeViews.filter(item => item.path === view.path) state.iframeViews = state.iframeViews.filter(item => item.fullPath === view.fullPath)
}, },
DEL_OTHERS_CACHED_VIEWS: (state, view) => { DEL_OTHERS_CACHED_VIEWS: (state, view) => {
const index = state.cachedViews.indexOf(view.name) const index = state.cachedViews.indexOf(view.name)
...@@ -70,14 +70,14 @@ const mutations = { ...@@ -70,14 +70,14 @@ const mutations = {
}, },
UPDATE_VISITED_VIEW: (state, view) => { UPDATE_VISITED_VIEW: (state, view) => {
for (let v of state.visitedViews) { for (let v of state.visitedViews) {
if (v.path === view.path) { if (v.fullPath === view.fullPath) {
v = Object.assign(v, view) v = Object.assign(v, view)
break break
} }
} }
}, },
DEL_RIGHT_VIEWS: (state, view) => { DEL_RIGHT_VIEWS: (state, view) => {
const index = state.visitedViews.findIndex(v => v.path === view.path) const index = state.visitedViews.findIndex(v => v.fullPath === view.fullPath)
if (index === -1) { if (index === -1) {
return return
} }
...@@ -90,14 +90,14 @@ const mutations = { ...@@ -90,14 +90,14 @@ const mutations = {
state.cachedViews.splice(i, 1) state.cachedViews.splice(i, 1)
} }
if(item.meta.link) { if(item.meta.link) {
const fi = state.iframeViews.findIndex(v => v.path === item.path) const fi = state.iframeViews.findIndex(v => v.fullPath === item.fullPath)
state.iframeViews.splice(fi, 1) state.iframeViews.splice(fi, 1)
} }
return false return false
}) })
}, },
DEL_LEFT_VIEWS: (state, view) => { DEL_LEFT_VIEWS: (state, view) => {
const index = state.visitedViews.findIndex(v => v.path === view.path) const index = state.visitedViews.findIndex(v => v.fullPath === view.fullPath)
if (index === -1) { if (index === -1) {
return return
} }
...@@ -110,7 +110,7 @@ const mutations = { ...@@ -110,7 +110,7 @@ const mutations = {
state.cachedViews.splice(i, 1) state.cachedViews.splice(i, 1)
} }
if(item.meta.link) { if(item.meta.link) {
const fi = state.iframeViews.findIndex(v => v.path === item.path) const fi = state.iframeViews.findIndex(v => v.fullPath === item.fullPath)
state.iframeViews.splice(fi, 1) state.iframeViews.splice(fi, 1)
} }
return false return false
......
import { login, logout, getInfo } from '@/api/login' import { login, logout, getInfo } from '@/api/login';
import { getToken, setToken, removeToken ,setTenantid} from '@/utils/auth' import { getToken, setToken, removeToken, setTenantid } from '@/utils/auth';
const user = { const user = {
state: { state: {
...@@ -8,100 +8,100 @@ const user = { ...@@ -8,100 +8,100 @@ const user = {
avatar: '', avatar: '',
roles: [], roles: [],
permissions: [], permissions: [],
userId:'', userId: '',
phonenumber:'', phonenumber: '',
}, },
mutations: { mutations: {
SET_TOKEN: (state, token) => { SET_TOKEN: (state, token) => {
state.token = token state.token = token;
}, },
SET_NAME: (state, name) => { SET_NAME: (state, name) => {
state.name = name state.name = name;
}, },
SET_AVATAR: (state, avatar) => { SET_AVATAR: (state, avatar) => {
state.avatar = avatar state.avatar = avatar;
}, },
SET_ROLES: (state, roles) => { SET_ROLES: (state, roles) => {
state.roles = roles state.roles = roles;
}, },
SET_PERMISSIONS: (state, permissions) => { SET_PERMISSIONS: (state, permissions) => {
state.permissions = permissions state.permissions = permissions;
}, },
SET_USERID: (state, userId) => { SET_USERID: (state, userId) => {
state.userId = userId state.userId = userId;
}, },
SET_USERPHONE: (state, phonenumber) => { SET_USERPHONE: (state, phonenumber) => {
state.phonenumber = phonenumber state.phonenumber = phonenumber;
} }
}, },
actions: { actions: {
// 登录 // 登录
Login({ commit }, userInfo) { Login({ commit }, userInfo) {
const username = userInfo.username.trim() const username = userInfo.username.trim();
const password = userInfo.password const password = userInfo.password;
const code = userInfo.code const code = userInfo.code;
const uuid = userInfo.uuid const uuid = userInfo.uuid;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
login(username, password, code, uuid).then(res => { login(username, password, code, uuid).then(res => {
setToken(res.data.token) setToken(res.data.token);
commit('SET_TOKEN', res.data.token) commit('SET_TOKEN', res.data.token);
setTenantid(res.data.tenantId) setTenantid(res.data.tenantId);
resolve() resolve();
}).catch(error => { }).catch(error => {
reject(error) reject(error);
}) });
}) });
}, },
// 获取用户信息 // 获取用户信息
GetInfo({ commit, state }) { GetInfo({ commit, state }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
getInfo().then(res => { getInfo().then(res => {
const user = res.data.user const user = res.data.user;
const avatar = user.avatar ? process.env.VUE_APP_BASE_API + user.avatar : ''; const avatar = user.avatar ? user.avatar : '';
if (res.data.roles && res.data.roles.length > 0) { // 验证返回的roles是否是一个非空数组 if (res.data.roles && res.data.roles.length > 0) { // 验证返回的roles是否是一个非空数组
commit('SET_ROLES', res.data.roles) commit('SET_ROLES', res.data.roles);
commit('SET_PERMISSIONS', res.data.permissions) commit('SET_PERMISSIONS', res.data.permissions);
} else { } else {
commit('SET_ROLES', ['ROLE_DEFAULT']) commit('SET_ROLES', ['ROLE_DEFAULT']);
} }
commit('SET_NAME', user.nickName) commit('SET_NAME', user.nickName);
commit('SET_AVATAR', avatar) commit('SET_AVATAR', avatar);
commit('SET_USERID', user.userId) commit('SET_USERID', user.userId);
commit('SET_USERPHONE', user.phonenumber) commit('SET_USERPHONE', user.phonenumber);
resolve(res) resolve(res);
}).catch(error => { }).catch(error => {
reject(error) reject(error);
}) });
}) });
}, },
// 退出系统 // 退出系统
LogOut({ commit, state }) { LogOut({ commit, state }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
logout(state.token).then(() => { logout(state.token).then(() => {
commit('SET_TOKEN', '') commit('SET_TOKEN', '');
commit('SET_ROLES', []) commit('SET_ROLES', []);
commit('SET_PERMISSIONS', []) commit('SET_PERMISSIONS', []);
removeToken() removeToken();
resolve() resolve();
}).catch(error => { }).catch(error => {
reject(error) reject(error);
}) });
}) });
}, },
// 前端 登出 // 前端 登出
FedLogOut({ commit }) { FedLogOut({ commit }) {
return new Promise(resolve => { return new Promise(resolve => {
commit('SET_TOKEN', '') commit('SET_TOKEN', '');
removeToken() removeToken();
resolve() resolve();
}) });
} }
} }
} };
export default user export default user;
...@@ -401,6 +401,62 @@ export function isNumberStr(str) { ...@@ -401,6 +401,62 @@ export function isNumberStr(str) {
return /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g.test(str); return /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g.test(str);
} }
/**
*
* @param {string} originUrl 需要获取参数的url 默认当前url
* @param {RegExp} reg key需要剔除的特殊字符 默认过滤问号
* @returns {{[key : string] : any}} 查询对象 键值对
*/
export const getUrlSearchQuery = (originUrl = location.href, reg = new RegExp("\\?", "gi")) => {
const url = new URL(originUrl);
const params = url.searchParams.entries();
let _temp = {};
for (const [key, value] of params) {
_temp[key.replace(reg, "")] = (value ? decodeURIComponent(value) : "");
}
return _temp;
};
/**
* 对象转换为查询字符串
* @param {{[key:string] : any}} query
*/
export const paramsToQuery = (query) => {
try {
if (Object.prototype.toString.call(query) !== "[object Object]") return "";
const params = new URLSearchParams(query);
let searchStrArray = [];
params.forEach((value, key) => {
if (params.has(key)) {
searchStrArray.push(`${key}=${decodeURIComponent(value)}`);
}
});
searchStrArray = searchStrArray.join("&");
return searchStr;
} catch (error) {
console.log(error);
}
};
/**
* 查询字符串转对象
* @param {string} text
*/
export const searchTextToQuery = (text) => {
try {
if (text) {
const url = new URLSearchParams(text);
const _temp = {};
url.forEach((value, key) => {
_temp[key] = value;
});
return JSON.parse(JSON.stringify(_temp));
}
} catch (error) {
console.log(error);
}
};
// 甲方详情左侧菜单映射 // 甲方详情左侧菜单映射
export const detailSideBar = new Map([ export const detailSideBar = new Map([
// 企业速览 // 企业速览
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
<template slot="suffix"> <template slot="suffix">
<transition mode="out-in" appear name="fade"> <transition mode="out-in" appear name="fade">
<img src="@/assets/images/enterprise/search-input-clear-icon.svg" alt="" <img src="@/assets/images/enterprise/search-input-clear-icon.svg" alt=""
@click.stop="searchParam.companyName = '';handleSearch" v-show="showClearIcon"> @click.stop="searchParam.companyName = '';handleSearch()" v-show="showClearIcon">
</transition> </transition>
</template> </template>
</el-input> </el-input>
......
...@@ -194,9 +194,6 @@ export default { ...@@ -194,9 +194,6 @@ export default {
companyName: this.customerInfo.companyName companyName: this.customerInfo.companyName
}; };
document.getElementById('tagTitle').innerText = this.customerInfo.companyName; document.getElementById('tagTitle').innerText = this.customerInfo.companyName;
// let lists = this.$store.state.tagsView.visitedViews
// lists.forEach(item=>{
// if(item.fullPath == this.$route.fullPath){
let titlename = document.getElementById('tagTitles'); let titlename = document.getElementById('tagTitles');
if (titlename) { if (titlename) {
titlename.innerText = this.customerInfo.companyName; titlename.innerText = this.customerInfo.companyName;
......
<template> <template>
<div class="subsystem-iframe-container"> <div class="subsystem-iframe-container">
<div @click="$router.push({path : '/subsystem',query : ({id:1})})">11</div>
</div> </div>
</template> </template>
<script> <script>
import { getUrlSearchQuery } from "@/utils/";
export default { export default {
name: "", name: "subsystemIframeContainer",
data() { data() {
return { return {
...@@ -13,7 +14,8 @@ export default { ...@@ -13,7 +14,8 @@ export default {
}, },
//可访问data属性 //可访问data属性
created() { created() {
console.log(this.$route);
console.log(getUrlSearchQuery());
}, },
//计算集 //计算集
computed: { computed: {
...@@ -25,6 +27,7 @@ export default { ...@@ -25,6 +27,7 @@ export default {
}, },
// 渲染方法 // 渲染方法
render(createElement) { render(createElement) {
} }
} }
</script> </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