|
|
@ -26,46 +26,53 @@ export default { |
|
|
|
created() { |
|
|
|
// 此处请求后端,获取一个ticket票据 |
|
|
|
http.get("/auth/sso/getTicket") |
|
|
|
.then(({data: res}) => { |
|
|
|
let ticket = res.data |
|
|
|
console.log('ticket:', ticket) |
|
|
|
this.iframeSrc = "../../../epmet-voluntary-mall-admin/pms/productCategory?target=_blank&ticket=" + ticket |
|
|
|
}) |
|
|
|
.then(({ data: res }) => { |
|
|
|
let ticket = res.data; |
|
|
|
console.log('ticket:', ticket); |
|
|
|
this.iframeSrc = "../../../epmet-voluntary-mall-admin/pms/productCategory?ticket=" + ticket; |
|
|
|
}); |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// 监听 iframe 加载完成事件 |
|
|
|
onIframeLoad() { |
|
|
|
// 获取 iframe 的内容窗口 |
|
|
|
|
|
|
|
if(this.iframeSrc==''){ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const iframe = this.$refs.childIframe; |
|
|
|
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document; |
|
|
|
|
|
|
|
if (iframeDocument) { |
|
|
|
const styleElement = iframeDocument.createElement('style'); |
|
|
|
styleElement.type = 'text/css'; |
|
|
|
if (this.iframeSrc.indexOf("ticket")!== -1) { |
|
|
|
// 将 iframeSrc 设置为新的 URL(去掉了 ticket 参数) |
|
|
|
this.iframeSrc = "../../../epmet-voluntary-mall-admin/pms/productCategory"; |
|
|
|
}else{ |
|
|
|
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document; |
|
|
|
|
|
|
|
const newStyles = ` |
|
|
|
#app .main-container { |
|
|
|
margin-left: 0px !important; |
|
|
|
} |
|
|
|
#app .sidebar-container { |
|
|
|
display: none !important; |
|
|
|
} |
|
|
|
.navbar { |
|
|
|
display: none !important; |
|
|
|
} |
|
|
|
`; |
|
|
|
if (iframeDocument) { |
|
|
|
const styleElement = iframeDocument.createElement('style'); |
|
|
|
styleElement.type = 'text/css'; |
|
|
|
|
|
|
|
styleElement.appendChild(iframeDocument.createTextNode(newStyles)); |
|
|
|
const newStyles = ` |
|
|
|
#app .main-container { |
|
|
|
margin-left: 0px !important; |
|
|
|
} |
|
|
|
#app .sidebar-container { |
|
|
|
display: none !important; |
|
|
|
} |
|
|
|
.navbar { |
|
|
|
display: none !important; |
|
|
|
} |
|
|
|
`; |
|
|
|
|
|
|
|
iframeDocument.head.appendChild(styleElement); |
|
|
|
styleElement.appendChild(iframeDocument.createTextNode(newStyles)); |
|
|
|
iframeDocument.head.appendChild(styleElement); |
|
|
|
|
|
|
|
// 显示 iframe |
|
|
|
iframe.style.display = 'block'; |
|
|
|
// 显示 iframe |
|
|
|
iframe.style.display = 'block'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
</script> |
|
|
|
|
|
|
|
<style scoped> |
|
|
|
</style> |
|
|
|