市北互联平台前端仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
3.4 KiB

4 years ago
<template>
<main :class="['aui-content']">
3 years ago
<!-- tab展示内容 -->
4 years ago
<template>
3 years ago
<template v-if="tabIsIframe($router.currentRoute.meta.iframeURL)">
<iframe
:src="
$router.currentRoute.meta.iframeURL +
'?token=' +
token +
'&customerId=' +
customerId
"
3 years ago
ref="iframe"
3 years ago
class="m-iframe"
3 years ago
id="iframe"
3 years ago
width="100%"
height="100%"
frameborder="0"
scrolling="yes"
3 years ago
/>
3 years ago
</template>
3 years ago
<keep-alive v-show="!tabIsIframe($router.currentRoute.meta.iframeURL)">
3 years ago
<router-view @changeCustomerName="changeCustomerName" />
4 years ago
</keep-alive>
</template>
</main>
</template>
<script>
3 years ago
import { isURL } from "@/utils/validate";
import Cookie from "js-cookie";
4 years ago
export default {
3 years ago
data() {
4 years ago
return {
3 years ago
iframeUrl: "",
token: "",
customerId: "",
};
4 years ago
},
3 years ago
watch: {
// "$router.currentRoute.name": function () {
// console.log($router.currentRoute);
// },
},
3 years ago
created() {
this.token = localStorage.getItem("token");
this.customerId = localStorage.getItem("customerId");
4 years ago
},
methods: {
3 years ago
changeCustomerName(customerName) {
this.$emit("changeCustomerName", customerName);
4 years ago
},
// tabs, 是否通过iframe展示
3 years ago
tabIsIframe(url) {
4 years ago
// this.appendIframe(url)
3 years ago
// this.iframeUrl =
// url +
// "?token=" +
// localStorage.getItem("token") +
// "&customerId=" +
// localStorage.getItem("customerId");
// return /^http[s]?:\/\/.*/.test(url);
return isURL(url);
4 years ago
},
// tabs, 选中tab
3 years ago
tabSelectedHandle(tab) {
tab = this.$store.state.contentTabs.filter(
(item) => item.name === tab.name
)[0];
4 years ago
if (tab) {
this.$router.push({
3 years ago
name: tab.name,
params: { ...tab.params },
query: { ...tab.query },
});
4 years ago
}
},
// tabs, 删除tab
3 years ago
tabRemoveHandle(tabName) {
if (tabName === "home") {
return false;
4 years ago
}
3 years ago
this.$store.state.contentTabs = this.$store.state.contentTabs.filter(
(item) => item.name !== tabName
);
4 years ago
if (this.$store.state.contentTabs.length <= 0) {
3 years ago
this.$store.state.sidebarMenuActiveName =
this.$store.state.contentTabsActiveName = "home";
return false;
4 years ago
}
// 当前选中tab被删除
if (tabName === this.$store.state.contentTabsActiveName) {
3 years ago
let tab =
this.$store.state.contentTabs[
this.$store.state.contentTabs.length - 1
];
4 years ago
this.$router.push({
name: tab.name,
params: { ...tab.params },
3 years ago
query: { ...tab.query },
});
4 years ago
}
},
// tabs, 关闭其它
3 years ago
tabsCloseOtherHandle() {
this.$store.state.contentTabs = this.$store.state.contentTabs.filter(
(item) => {
return (
item.name === "home" ||
item.name === this.$store.state.contentTabsActiveName
);
}
);
4 years ago
},
// tabs, 关闭全部
3 years ago
tabsCloseAllHandle() {
this.$store.state.contentTabs = this.$store.state.contentTabs.filter(
(item) => item.name === "home"
);
this.$router.push({ name: "home" });
4 years ago
},
3 years ago
},
};
4 years ago
</script>
4 years ago
<style lang="scss" src="@/assets/scss/main-shuju.scss" scoped></style>