liuQiang 1 年之前
父节点
当前提交
cf1ef4f897
共有 1 个文件被更改,包括 36 次插入1 次删除
  1. 36 1
      src/layout/indexCommon.vue

+ 36 - 1
src/layout/indexCommon.vue

@@ -589,6 +589,7 @@ const filePaneClick = (item) => {
       const inIframe =
         outIframe.contentDocument.getElementsByTagName("iframe")[0];
       setTimeout(() => {
+        console.log('outIframe',outIframe.parentElement);
         console.error(outIframe.parentElement);
         inIframe.style.height = outIframe.style.height =
           outIframe.parentElement.offsetHeight + "px";
@@ -619,11 +620,12 @@ const addFileTab = (data) => {
   const hasThis = oldIFrameData.find((par) => par.docId == data.docId);//是否已存在
   if (hasThis){
     const thisPane = toRaw(hasThis)
-    console.log('hasThis',thisPane);
+    // console.log('hasThis',thisPane);
     const arr = oldIFrameData.map((par) => {
     if (par.id == thisPane.id) {
       par.show = true
       editableTabsValue.value = par.id// 标签跳转
+      // iframeSize(par.id)
     }else{
 		par.show = false
 	}
@@ -643,6 +645,7 @@ const addFileTab = (data) => {
         par.show = true
         thisData.docId = "";
         editableTabsValue.value = par.id// 新建时标签跳转
+        // iframeSize(par.id)
       }
     }else{
 		par.show = false
@@ -651,6 +654,20 @@ const addFileTab = (data) => {
   });
   iFrameData.value = arr;
   isAlive.value = false;
+  //  const outIframe = document.getElementById("iframe" + par.id);
+  // const inIframe =
+  //   outIframe.contentDocument.getElementsByTagName("iframe")[0];
+  // setTimeout(() => {
+  //   console.log('outIframe',outIframe.parentElement);
+  //   console.error(outIframe.parentElement);
+  //   inIframe.style.height = outIframe.style.height =
+  //     outIframe.parentElement.offsetHeight + "px";
+  //   inIframe.style.width = outIframe.style.width =
+  //     outIframe.parentElement.offsetWidth + "px";
+
+  //   // console.log('dom',outIframe.parentElement.offsetWidth);
+  //   // console.log('inIframe',inIframe);
+  // }, 500);
   console.log("addFileTab", arr);
 };
 //创建tab标签事件
@@ -748,6 +765,24 @@ const closeFileTab = (item, index, e) => {
   // console.log("index", index);
   console.log("iFrameData", iFrameData.value);
 };
+// 控制iframe大小
+const iframeSize = (id)=>{
+   const outIframe = document.getElementById("iframe" + id);
+  const inIframe =
+    outIframe.contentDocument.getElementsByTagName("iframe")[0];
+  setTimeout(() => {
+    console.log('outIframe',outIframe.parentElement);
+    console.error(outIframe.parentElement);
+    inIframe.style.height = outIframe.style.height =
+      outIframe.parentElement.offsetHeight + "px";
+    inIframe.style.width = outIframe.style.width =
+      outIframe.parentElement.offsetWidth + "px";
+
+    // console.log('dom',outIframe.parentElement.offsetWidth);
+    // console.log('inIframe',inIframe);
+  }, 500);
+}
+// 监听和保存标签信息
 const setTabLocal = (data)=>{
   // console.log('setTabLocal',data);
   sessionStorage.setItem('tabData', JSON.stringify(data))