Commit f51e3fe9 authored by tianhongyang's avatar tianhongyang

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

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