|
@@ -1,10 +1,6 @@
|
|
|
<template>
|
|
|
<div id="tags-view-container" class="tags-view-container">
|
|
|
- <scroll-pane
|
|
|
- ref="scrollPane"
|
|
|
- class="tags-view-wrapper"
|
|
|
- @scroll="handleScroll"
|
|
|
- >
|
|
|
+ <scroll-pane ref="scrollPane" class="tags-view-wrapper" @scroll="handleScroll">
|
|
|
<router-link
|
|
|
v-for="tag in visitedViews"
|
|
|
ref="tag"
|
|
@@ -30,9 +26,7 @@
|
|
|
class="contextmenu"
|
|
|
>
|
|
|
<li @click="refreshSelectedTag(selectedTag)">Refresh</li>
|
|
|
- <li v-if="!isAffix(selectedTag)" @click="closeSelectedTag(selectedTag)">
|
|
|
- Close
|
|
|
- </li>
|
|
|
+ <li v-if="!isAffix(selectedTag)" @click="closeSelectedTag(selectedTag)">Close</li>
|
|
|
<li @click="closeOthersTags">Close Others</li>
|
|
|
<li @click="closeAllTags(selectedTag)">Close All</li>
|
|
|
</ul>
|
|
@@ -40,9 +34,9 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import ScrollPane from './ScrollPane'
|
|
|
-import path from 'path'
|
|
|
-
|
|
|
+import ScrollPane from "./ScrollPane";
|
|
|
+import path from "path";
|
|
|
+import { mapGetters } from "vuex";
|
|
|
export default {
|
|
|
components: { ScrollPane },
|
|
|
data() {
|
|
@@ -51,168 +45,180 @@ export default {
|
|
|
top: 0,
|
|
|
left: 0,
|
|
|
selectedTag: {},
|
|
|
- affixTags: []
|
|
|
- }
|
|
|
+ affixTags: [],
|
|
|
+ fallPathConfig: [
|
|
|
+ { value: "1", path: "caixiao" },
|
|
|
+ { value: "2", path: "aold" },
|
|
|
+ ],
|
|
|
+ };
|
|
|
},
|
|
|
computed: {
|
|
|
+ ...mapGetters(["size", "business_companyNo"]),
|
|
|
visitedViews() {
|
|
|
- return this.$store.state.tagsView.visitedViews
|
|
|
+ return this.$store.state.tagsView.visitedViews;
|
|
|
},
|
|
|
routes() {
|
|
|
- return this.$store.state.user.btnList
|
|
|
- }
|
|
|
+ return this.$store.state.user.btnList;
|
|
|
+ },
|
|
|
+ maxNo() {
|
|
|
+ return this.business_companyNo;
|
|
|
+ },
|
|
|
},
|
|
|
watch: {
|
|
|
+ maxNo(val, oldval) {
|
|
|
+ // this.$notify({
|
|
|
+ // title: "供应商已发生变化",
|
|
|
+ // dangerouslyUseHTMLString: true,
|
|
|
+ // message: "1秒后,跳转至招标工作台页面!",
|
|
|
+ // });
|
|
|
+ this.closeOthersTags()
|
|
|
+ },
|
|
|
$route() {
|
|
|
- this.addTags()
|
|
|
- this.moveToCurrentTag()
|
|
|
+ this.addTags();
|
|
|
+ this.moveToCurrentTag();
|
|
|
},
|
|
|
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();
|
|
|
},
|
|
|
methods: {
|
|
|
isActive(route) {
|
|
|
- return route.path === this.$route.path
|
|
|
+ return route.path === this.$route.path;
|
|
|
},
|
|
|
isAffix(tag) {
|
|
|
- return tag.meta && tag.meta.affix
|
|
|
+ return tag.meta && tag.meta.affix;
|
|
|
},
|
|
|
- filterAffixTags(routes, basePath = '/') {
|
|
|
- let tags = []
|
|
|
- routes.forEach(route => {
|
|
|
+ filterAffixTags(routes, basePath = "/") {
|
|
|
+ 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 }
|
|
|
- })
|
|
|
+ meta: { ...route.meta },
|
|
|
+ });
|
|
|
}
|
|
|
if (route.children) {
|
|
|
- const tempTags = this.filterAffixTags(route.children, route.path)
|
|
|
+ const tempTags = this.filterAffixTags(route.children, route.path);
|
|
|
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);
|
|
|
}
|
|
|
- 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)
|
|
|
+ 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.$store.dispatch('tagsView/delCachedView', view).then(() => {
|
|
|
- const { fullPath } = view
|
|
|
+ this.$store.dispatch("tagsView/delCachedView", view).then(() => {
|
|
|
+ const { fullPath } = view;
|
|
|
this.$nextTick(() => {
|
|
|
this.$router.replace({
|
|
|
- path: '/redirect' + fullPath
|
|
|
- })
|
|
|
- })
|
|
|
- })
|
|
|
+ path: "/redirect" + fullPath,
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
},
|
|
|
closeSelectedTag(view) {
|
|
|
- this.$store
|
|
|
- .dispatch('tagsView/delView', view)
|
|
|
- .then(({ visitedViews }) => {
|
|
|
- if (this.isActive(view)) {
|
|
|
- this.toLastView(visitedViews, view)
|
|
|
- }
|
|
|
- })
|
|
|
+ this.$store.dispatch("tagsView/delView", view).then(({ visitedViews }) => {
|
|
|
+ if (this.isActive(view)) {
|
|
|
+ this.toLastView(visitedViews, view);
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
closeOthersTags() {
|
|
|
- window.vm.$router.push(this.selectedTag)
|
|
|
- this.$store
|
|
|
- .dispatch('tagsView/delOthersViews', this.selectedTag)
|
|
|
- .then(() => {
|
|
|
- this.moveToCurrentTag()
|
|
|
- })
|
|
|
+ window.vm.$router.push(this.selectedTag);
|
|
|
+ this.$store.dispatch("tagsView/delOthersViews", this.selectedTag).then(() => {
|
|
|
+ this.moveToCurrentTag();
|
|
|
+ });
|
|
|
},
|
|
|
closeAllTags(view) {
|
|
|
- this.$store.dispatch('tagsView/delAllViews').then(({ visitedViews }) => {
|
|
|
- if (this.affixTags.some(tag => tag.path === view.path)) {
|
|
|
- return
|
|
|
+ this.$store.dispatch("tagsView/delAllViews").then(({ visitedViews }) => {
|
|
|
+ if (this.affixTags.some((tag) => tag.path === view.path)) {
|
|
|
+ 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) {
|
|
|
- window.vm.$router.push(latestView.fullPath)
|
|
|
+ window.vm.$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') {
|
|
|
+ if (view.name === "Dashboard") {
|
|
|
// to reload home page
|
|
|
- this.$router.replace({ path: '/redirect' + view.fullPath })
|
|
|
+ this.$router.replace({ path: "/redirect" + view.fullPath });
|
|
|
} else {
|
|
|
- window.vm.$router.push('/welcome/dashboard')
|
|
|
+ window.vm.$router.push("/welcome/dashboard");
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
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();
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|