Răsfoiți Sursa

文件切换

liuQiang 2 ani în urmă
părinte
comite
3d83572917

+ 8 - 0
src/api/biz/info.js

@@ -17,6 +17,14 @@ export function getInfo(docId) {
   })
 }
 
+// 根据目录id查询文件列表
+export function getInfoByDirId(dirId) {
+  return request({
+    url: '/biz/info/list/' + dirId,
+    method: 'get'
+  })
+}
+
 // 新增文件基本信息表
 export function addInfo(data) {
   return request({

+ 38 - 31
src/layout/indexCommon.vue

@@ -95,8 +95,6 @@
               v-model="editableTabsValue"
               @tab-change="clickTab"
               @tab-add="addTab"
-              :value="JSON.stringify(item)"
-              :data-item="JSON.stringify(item)"
               type="card"
               class="common-tabs"
             >
@@ -122,8 +120,7 @@
             </el-tabs>
           </div>
           <router-view v-slot="{ Component }" v-if="isAlive">
-            <!-- TODO文件缓存 点进文件掉createtabs生成tab -->
-            <KeepAlive exclude="search">
+            <KeepAlive :exclude="'fileEdit'">
               <component :is="Component" />
             </KeepAlive>
           </router-view>
@@ -374,32 +371,40 @@ const clickPath = (index, items) => {
 };
 const clickTab = (item) => {
   // console.log("item", toRaw(item));
-  if (toFileData.value) {
-    router.push({
-      path: toFileData.value.path,
-      query: {
-        row:toFileData.value.row
-      },
-    });
-    return;
-  }
-  let regExp = new RegExp(/^\//);
-  let regFile = new RegExp(/^tofile/);
-  if (!regExp.test(toRaw(item))) {
-    const data = JSON.parse(toRaw(item));
-    console.log("data", data);
-    router.push({
-      path: "/fileEdit",
-      query: {
-        clickRowId: data.docId,
-        copyRow: JSON.stringify(data),
-      },
-    });
-  } else {
-    router.push({
-      path: item,
-    });
-  }
+  setTimeout(() => {
+    if (toFileData.value) {
+      router.push({
+        path: toFileData.value.path,
+        query: {
+          row: toFileData.value.row,
+        },
+      });
+      // router.push({
+      //   path: toFileData.value.path,
+      //   query: {
+      //     row: toFileData.value.row,
+      //   },
+      // });
+      return;
+    }
+    let regExp = new RegExp(/^\//);
+    let regFile = new RegExp(/^tofile/);
+    if (!regExp.test(toRaw(item))) {
+      const data = JSON.parse(toRaw(item));
+      console.log("data", data);
+      router.push({
+        path: "/fileEdit",
+        query: {
+          clickRowId: data.docId,
+          // copyRow: JSON.stringify(data),
+        },
+      });
+    } else {
+      router.push({
+        path: item,
+      });
+    }
+  }, 100);
 };
 const paneClick = (item) => {
   // 可以拿到当前的标签对象
@@ -413,6 +418,7 @@ const paneClick = (item) => {
 };
 //创建tab标签事件
 const addTab = (data) => {
+  console.log("addTab", data);
   const arr = toRaw(editableTabs.value);
   if (!arr.some((item) => item.label == data.fileName)) {
     editableTabs.value.push({
@@ -421,6 +427,7 @@ const addTab = (data) => {
     });
     //需要jSON去转 否则页面无变化 离谱得很
     editableTabs.value = JSON.parse(JSON.stringify(editableTabs.value));
+    // editableTabsValue.value = data.path;
   }
 };
 const addFolderAdd = (data) => {
@@ -428,7 +435,7 @@ const addFolderAdd = (data) => {
   const arr = toRaw(editableTabs.value);
   if (!arr.some((item) => item.label == data.row.dirName)) {
     editableTabs.value.push({
-      label: data.row.dirName,
+      label: data.name,
       path: data.path,
       row: JSON.stringify(data.row),
     });

+ 2 - 1
src/router/index.js

@@ -186,7 +186,8 @@ export const constantRoutes = [{
 				name: "fileEdit",
 				meta: {
 					title: "文件预览",
-					icon: "department"
+					icon: "department",
+					keepAlive: true
 				}
 			},{
 				path: "/allback",

+ 17 - 50
src/views/biz/recent/index.vue

@@ -220,7 +220,8 @@
 import { onMounted, ref, toRaw, inject } from "vue";
 // import TopTabs from "@/components/TopTabs/index.vue"
 import { listRecent, getRecent } from "@/api/biz/recent";
-import { getInfo } from "@/api/biz/info";
+import { getInfo, getInfoByDirId } from "@/api/biz/info";
+import { getSpace } from "@/api/biz/space";
 import { getDir } from "@/api/biz/dir";
 import documents from "@/api/document/document";
 import ImgFile from "@/views/myfile/jsComponents/ImgFile";
@@ -269,6 +270,7 @@ const backFolder = ref();
 const copyFolderName = ref();
 const addFolderAdd = inject("addFolderAdd");
 let collects = ref(false);
+const spacePath = ref()
 let menuList = ref([
   {
     name: "我的空间",
@@ -446,51 +448,22 @@ async function chooseSet(row, index, num) {
   }
   console.log("chooseSetrow", row);
   console.log("chooseSetnum", num);
-  if (row.name == "在线编辑" || row.name == "协作") {
-    cliCC.value = true;
-  }
-  if (row.name == "分享") {
-    workOrEdit.value = num;
-    thanks.value = true;
-  } else {
-    thanks.value = false;
-  }
-  if (row.name == "协作") {
-    workOrEdit.value = num;
-    if (anyP.value) {
-      anyP.value = false;
-    } else {
-      anyP.value = true;
-    }
-  } else {
-    anyP.value = false;
-  }
-  if (row.name == "删除") {
-    myfile.delMenu(clickRowId.value).then((res) => {
-      if (res.code === 200) {
-        ElMessage({
-          type: "success",
-          message: "删除成功",
-        });
-        getAllTop();
-      }
-    });
-  }
-  if (row.name === "复制到...") {
-    copyOrMove.value = 0;
-    fileTrees.value = true;
-  }
-  if (row.name === "移动到...") {
-    copyOrMove.value = 1;
-    fileTrees.value = true;
-  }
   if (row.name === "打开文件所在位置") {
-    documents.getALLdocument(({parentId: clickRow.value.dirId - 0, spaceId: clickRow.value.spaceId - 0})).then((res)=>{
-      console.log('rowres',res);
-    })
+    const dirData = await getDir(clickRow.value.dirId);
+    const spaceData = await getSpace(clickRow.value.spaceId);
+    console.log("getInfoByDirId", dirData.data);
+    console.log("spaceData", spaceData.data);
+    if (spaceData.data.spaceType == "3") {
+      spacePath.value = "/myfile";
+    } else if (spaceData.data.spaceType == "1") {
+      spacePath.value = "/publicment";
+    }else{
+      spacePath.value = "/department";
+    }
     const addData = {
-      path: "/myfile",
-      row: toRaw(clickRow.value),
+      path: spacePath.value,
+      name: dirData.data.dirName,
+      row: toRaw(dirData.data),
     };
     console.log("addData", addData);
     addFolderAdd(addData);
@@ -520,12 +493,6 @@ async function chooseSet(row, index, num) {
     // const res = await preview(copyFileId.value)
     // showPreview.value = true
     // previewData.value = URL.createObjectURL(res)
-  } else if (row.name === "历史版本") {
-    const resHistory = await listVersion({ docId: clickRowId.value });
-    console.log("resHistory", resHistory);
-    historyTotal.value = resHistory.total;
-    fileUserTreeData.data = resHistory.rows;
-    openForwardFile.value = true;
   }
 }
 function chooseSet1(num) {

+ 19 - 4
src/views/department/MyFile.vue

@@ -366,7 +366,7 @@
 </template>
 
 <script>
-import { ref, toRaw, onMounted } from 'vue'
+import { ref, toRaw, onMounted,onActivated ,inject} from 'vue'
 import myfile from '../../api/myfile/myfile'
 import { delFavorite } from '@/api/biz/favorite.js'
 import documents from '../../api/document/document'
@@ -579,6 +579,7 @@ export default {
         const showPreview = ref(false)//控制图片预览组件显示
         const previewData = ref()//需要预览的文件的数据
         const router = useRouter(); //注册路由
+        const route = useRoute(); //注册路由
         const folderVisible = ref(false); //显示文件夹右键菜单
         const foldertop = ref(0);
         const folderleft = ref(0);
@@ -598,6 +599,7 @@ export default {
         const chooseNum = ref()
         const loadingPreview = ref(false)
         const noMenuItem = ref(false)
+        const addTab = inject("addTab");
         // 获取文件夹,中栏,文件
         function getAllTop() {
             documents.getTop(2).then(res => {
@@ -836,11 +838,13 @@ export default {
                 loadingPreview.value = true
                 const filePreview = canPreviewFile(copyFileType.value)
                 if (filePreview) {
+                    loadingPreview.value = false
+                    addTab(clickRow.value);
                     onlyView.value = true
-                    editOnline.value = false
+                    // editOnline.value = false
                     cliCC.value = false
                 } else {
-                    const res = await preview(copyFileId.value)
+                    const res = await preview(copyRow.value.docId)
                     showPreview.value = true
                     previewData.value = URL.createObjectURL(res)
                 }
@@ -1472,6 +1476,16 @@ export default {
             window.addEventListener("click", closeRMenu, true);
             window.addEventListener("click", mouseClick, true);
         })
+         onActivated(()=>{
+            // console.log('route.query',route.query);
+            if(route.query.row){
+            const newRow = JSON.parse(route.query.row)
+            console.log('newRow',newRow);
+            thisFolder.value = newRow
+            refreshFile()
+            }
+
+        })
         return {
             getSpaceList,
             folderList,//文件夹的数据
@@ -1635,7 +1649,8 @@ export default {
             loadingPreview,
             thisRole,
             noMenuItem,
-            downLoadfile
+            downLoadfile,
+            addTab
         }
     },
     watch: {

+ 4 - 2
src/views/myfile/MyFile.vue

@@ -667,6 +667,7 @@ export default {
            
             const addData = {
                 path:route.path,
+                name:row.dirName,
                 row:toRaw(row)
             }
             addFolderAdd(addData)
@@ -903,7 +904,7 @@ export default {
                     // editOnline.value = false
                     cliCC.value = false
                 } else {
-                    const res = await preview(clickRowId.value)
+                    const res = await preview(copyRow.value.docId)
                     showPreview.value = true
                     previewData.value = URL.createObjectURL(res)
                 }
@@ -1524,9 +1525,10 @@ export default {
             window.addEventListener("click", mouseClick, true);
         })
         onActivated(()=>{
-            console.log('route.query',route.query);
+            // console.log('route.query',route.query);
             if(route.query.row){
             const newRow = JSON.parse(route.query.row)
+            console.log('newRow',newRow);
             thisFolder.value = newRow
             refreshFile()
             }

+ 11 - 2
src/views/myfile/components/FileEdit.vue

@@ -8,7 +8,7 @@
 
 <script>
 import { ref, onMounted, defineEmits } from "vue";
-import { useRouter, useRoute } from "vue-router";
+import { useRouter, useRoute ,onBeforeRouteUpdate} from "vue-router";
 import jjtOnlyOffice from "@/components/OnlyOffice/index.vue";
 import useUserStore from "@/store/modules/user";
 // import ClassicEditor from '@ckeditor/ckeditor5-build-classic';
@@ -118,7 +118,7 @@ export default {
       console.log('route',route.query);
       if(route.query.clickRowId){
           docId = route.query.clickRowId
-          copyRow = JSON.parse(route.query.copyRow)
+          // copyRow = JSON.parse(route.query.copyRow)
       }
       console.log(docId, "doc");
       console.log(copyRow, "row");
@@ -126,6 +126,15 @@ export default {
       // let row = JSON.parse(newObj.value)
       // console.log(row, '852');
     });
+    onBeforeRouteUpdate((to,from)=>{
+      console.log('to',to);
+      console.log('from',from);
+     docId = to.query.clickRowId
+      // console.log(docId, "doc");
+      // console.log(copyRow, "row");
+      // edit();
+    edit();
+    })
     return {
       option,
       show,

+ 14 - 3
src/views/publicment/MyFile.vue

@@ -366,7 +366,7 @@
 </template>
 
 <script>
-import { ref, toRaw, onMounted } from 'vue'
+import { ref, toRaw, onMounted ,onActivated} from 'vue'
 import myfile from '../../api/myfile/myfile'
 import { delFavorite } from '@/api/biz/favorite.js'
 import documents from '../../api/document/document'
@@ -461,6 +461,8 @@ export default {
         const historyPrew = ref(false)
         let xz = ref(0)
         let yz = ref(0)
+        const router = useRouter(); //注册路由
+        const route = useRoute(); //注册路由
         const fileUserTreeData = reactive({ data: {} });
         let fileList = ref()
         let menuList = ref([
@@ -578,7 +580,6 @@ export default {
         let workOrEdit = ref(0)
         const showPreview = ref(false)//控制图片预览组件显示
         const previewData = ref()//需要预览的文件的数据
-        const router = useRouter(); //注册路由
         const folderVisible = ref(false); //显示文件夹右键菜单
         const foldertop = ref(0);
         const folderleft = ref(0);
@@ -844,7 +845,7 @@ export default {
                     editOnline.value = false
                     cliCC.value = false
                 } else {
-                    const res = await preview(copyFileId.value)
+                    const res = await preview(copyRow.value.docId)
                     showPreview.value = true
                     previewData.value = URL.createObjectURL(res)
                 }
@@ -1476,6 +1477,16 @@ export default {
             window.addEventListener("click", closeRMenu, true);
             window.addEventListener("click", mouseClick, true);
         })
+         onActivated(()=>{
+            // console.log('route.query',route.query);
+            if(route.query.row){
+            const newRow = JSON.parse(route.query.row)
+            console.log('newRow',newRow);
+            thisFolder.value = newRow
+            refreshFile()
+            }
+
+        })
         return {
             getSpaceList,
             folderList,//文件夹的数据