diff --git a/src/components/Preview/fun.js b/src/components/Preview/fun.js new file mode 100644 index 00000000..370657d7 --- /dev/null +++ b/src/components/Preview/fun.js @@ -0,0 +1,22 @@ +import Vue from "vue"; +import Preview from "./index.vue"; + +const PreviewConstructor = Vue.extend(Preview); + +const preview = options => { + const { path, type, title } = options; + if (!path) throw `path is requred.but ${path}` + const id = `Preview_${new Date().getTime()}`; + const instance = new PreviewConstructor(); + instance.id = id; + instance.vm = instance.$mount(); + if (instance.vm.visible) return; + document.body.appendChild(instance.vm.$el); + instance.vm.open(path, type, title); + instance.vm.$on("closed", () => { + document.body.removeChild(instance.vm.$el); + instance.vm.$destroy(); + }); + return instance.vm; +} +export default preview; \ No newline at end of file diff --git a/src/components/Preview/index.js b/src/components/Preview/index.js new file mode 100644 index 00000000..94a6d8b8 --- /dev/null +++ b/src/components/Preview/index.js @@ -0,0 +1,7 @@ +import Preview from "./index.vue"; +import preview from "./fun"; + +export default Vue => { + Vue.component(Preview.name, Preview); + Vue.prototype.$preview = preview; +}; \ No newline at end of file diff --git a/src/components/Preview/index.vue b/src/components/Preview/index.vue new file mode 100644 index 00000000..c44b0194 --- /dev/null +++ b/src/components/Preview/index.vue @@ -0,0 +1,41 @@ + + \ No newline at end of file diff --git a/src/main.js b/src/main.js index 70230303..cc88f482 100644 --- a/src/main.js +++ b/src/main.js @@ -56,6 +56,8 @@ Vue.use(hasPermi) // Vue.use(ElementUI, { locale, size: 'medium' }) import upload from '@/components/element-ui/upload' Vue.use(upload) +import Preview from '@/components/Preview/index' +Vue.use(Preview) import adaptive from '@/directive/adaptive/index' // 表格自适应指令 Vue.use(adaptive) diff --git a/src/views/trials/trials-panel/trial-summary/trial-information/index.vue b/src/views/trials/trials-panel/trial-summary/trial-information/index.vue index f55db101..cf6f5248 100644 --- a/src/views/trials/trials-panel/trial-summary/trial-information/index.vue +++ b/src/views/trials/trials-panel/trial-summary/trial-information/index.vue @@ -130,7 +130,7 @@ export default {