浏览代码

一级目录便签跳转

liuQiang 2 年之前
父节点
当前提交
1efd57f170

+ 27 - 8
src/layout/indexCommon.vue

@@ -106,9 +106,10 @@
                 :label="item.label"
                 :name="item.path"
                 :data-item="JSON.stringify(item)"
+                @click="paneClick(item)"
               >
                 <template #label>
-                  <div class="tab_pane">
+                  <div class="tab_pane" @click="paneClick(item)">
                     <div class="tab_text">{{ item.label }}</div>
                     <img
                       src="@/assets/images/close.png"
@@ -175,6 +176,7 @@ const searchText = ref(""); //搜索ipt的值
 const selectValue = ref(1); //文档空间类型
 const wangzhi = import.meta.env.VITE_APP_BASE_API;
 const isAlive = ref(true);
+const toFileData = ref();
 //--------tabs-----------------
 let tabIndex = 2;
 const editableTabsValue = ref("/index");
@@ -370,10 +372,17 @@ const clickPath = (index, items) => {
   editableTabsValue.value = items.path;
   // console.log("editableTabs", editableTabs.value);
 };
-const clickTab = (item,el,e) => {
-  console.log("item", toRaw(item));
-  console.log("el", el);
-  console.log("e", e);
+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))) {
@@ -392,6 +401,16 @@ const clickTab = (item,el,e) => {
     });
   }
 };
+const paneClick = (item) => {
+  // 可以拿到当前的标签对象
+  console.log("paneItem", item);
+  if (item.row) {
+    // 判断是菜单还是目录
+    toFileData.value = item;
+  } else {
+    toFileData.value = null;
+  }
+};
 //创建tab标签事件
 const addTab = (data) => {
   const arr = toRaw(editableTabs.value);
@@ -409,14 +428,14 @@ const addFolderAdd = (data) => {
   const arr = toRaw(editableTabs.value);
   if (!arr.some((item) => item.label == data.row.dirName)) {
     editableTabs.value.push({
-      label: 'tofile'+data.row.dirName,
-      path:data.path,
+      label: data.row.dirName,
+      path: data.path,
       row: JSON.stringify(data.row),
     });
     //需要jSON去转 否则页面无变化 离谱得很
     editableTabs.value = JSON.parse(JSON.stringify(editableTabs.value));
   }
-  console.log('editableTabs',editableTabs.value);
+  console.log("editableTabs", editableTabs.value);
 };
 provide("addTab", addTab);
 provide("addFolderAdd", addFolderAdd);

+ 51 - 87
src/views/biz/recent/index.vue

@@ -49,7 +49,7 @@
           >
             <el-table-column fixed prop="date" label="名称" width="500">
               <template #default="scope">
-                <!-- <div>
+                <div>
                   <img
                     class="table_icon"
                     :src="setIcon(scope.row.fileType)"
@@ -57,8 +57,8 @@
                     style=""
                   />
                   {{ scope.row.fileName }}
-                </div> -->
-                <span
+                </div>
+                <!-- <span
                   style="
                     white-space: nowrap;
                     overflow: hidden;
@@ -66,7 +66,7 @@
                   "
                 >
                   <el-icon
-                    v-if="scope.row.isFavorite == 'N'"
+                    v-if="scope.row.isFavorite == 'N' || !scope.row.isFavorite"
                     @click.stop="collectByStar(scope.row, false)"
                   >
                     <Star />
@@ -74,10 +74,14 @@
                   <img
                     v-else
                     @click.stop="delCollect(scope.row, false)"
-                    src="../../assets/images/yellowstar.png"
+                    src="../../../assets/images/yellowstar.png"
+                    alt=""
+                  />
+                  <img
+                    :src="setIcon(scope.row.fileType)"
+                    class="table_icon"
                     alt=""
                   />
-                  <img :src="setIcon(scope.row.fileType)" alt="" />
                   <el-tooltip
                     class="box-item"
                     effect="dark"
@@ -87,7 +91,7 @@
                   >
                     {{ scope.row.fileName }}
                   </el-tooltip>
-                </span>
+                </span> -->
               </template>
             </el-table-column>
             <el-table-column prop="createTime" label="时间" width="200" />
@@ -104,7 +108,7 @@
         <div
           class="setCli"
           v-if="cliCC"
-          :style="{ left: xz + 'px', top: yz - 260 + 'px' }"
+          :style="{ left: xz + 'px', top: yz + 'px' }"
         >
           <template v-for="(item, index) in filterMouseCli()" :key="index">
             <p @click="chooseSet(item, index, 1)" class="chooseSet">
@@ -127,11 +131,11 @@
           :style="{ left: xz + 155 + 'px', top: yz + 'px' }"
         >
           <p @click="chooseSet1(0)" class="chooseSet">
-            <img src="../../assets/images/user.png" alt="" />
+            <img src="../../../assets/images/user.png" alt="" />
             选择人员
           </p>
           <p class="chooseSet" @click="goLock">
-            <img src="../../assets/images/archiveTray.png" alt="" />
+            <img src="../../../assets/images/archiveTray.png" alt="" />
             归档
           </p>
         </div>
@@ -226,7 +230,7 @@ import myfile from "@/api/myfile/myfile";
 import { getLeveldetail } from "@/api/level/level";
 import { canPreviewFile, rightMenuRole } from "@/utils/index.js";
 import { preview } from "@/api/common/common.js";
-import { delFavorite } from '@/api/biz/favorite.js'
+import { delFavorite } from "@/api/biz/favorite.js";
 import ImgPreview from "@/components/ImgPreview/ImgPreview.vue";
 const activeNames = ref(["folder", "file"]);
 const isList = ref(true); //控制显示方式
@@ -263,6 +267,7 @@ const fileTrees = ref(false);
 const copyOrMove = ref();
 const backFolder = ref();
 const copyFolderName = ref();
+const addFolderAdd = inject("addFolderAdd");
 let collects = ref(false);
 let menuList = ref([
   {
@@ -279,52 +284,12 @@ let mouseCli = ref([
     name: "预览",
   },
   {
-    img: ImgFile.addolder,
-    name: "移动到...",
-  },
-  {
-    img: ImgFile.copy,
-    name: "复制到...",
-  },
-  // {
-  //     img: ImgFile.clipboard,
-  //     name: "粘贴"
-  // },
-  {
-    img: ImgFile.collect,
-    name: "收藏",
-  },
-  {
     img: ImgFile.downLoad,
     name: "下载",
   },
   {
-    img: ImgFile.textbox,
-    name: "重命名",
-  },
-  // {
-  //     img: ImgFile.goon,
-  //     name: "发送"
-  // },
-  {
-    img: ImgFile.share,
-    name: "分享",
-  },
-  {
-    img: ImgFile.notePencil,
-    name: "在线编辑",
-  },
-  {
-    img: ImgFile.togger,
-    name: "协作",
-  },
-  {
-    img: ImgFile.icc,
-    name: "文字识别",
-  },
-  {
-    img: ImgFile.history,
-    name: "历史版本",
+    img: ImgFile.addolder,
+    name: "打开文件所在位置",
   },
 ]);
 const addTab = inject("addTab");
@@ -519,44 +484,18 @@ async function chooseSet(row, index, num) {
     copyOrMove.value = 1;
     fileTrees.value = true;
   }
-  if (row.name === "重命名") {
-    fileNameChange.value = true;
+  if (row.name === "打开文件所在位置") {
+    const addData = {
+      path: "/myfile",
+      row: toRaw(clickRow.value),
+    };
+    console.log("addData", addData);
+    addFolderAdd(addData);
   }
   if (row.name === "下载") {
     // location.href = `${import.meta.env.VITE_APP_BASE_API}/biz/info/download/${copyFileId.value}`;
     downLoadfile();
   }
-  if (row.name === "收藏") {
-    collects.value = true;
-  }
-  if (row.name === "在线编辑") {
-    editOnline.value = false;
-    cliCC.value = false;
-    const newItem = {
-      name: copyFileName.value,
-      choose: copyFileId.value,
-      dirIds: copyDirId.value,
-      spaceIds: copySpaceId.value,
-    };
-    // 检查 newItem 是否已存在于 menuList 中
-    const isItemExist = menuList.value.some(
-      (item) => item.choose === newItem.choose
-    );
-    // 如果不存在,则添加它
-    if (!isItemExist) {
-      menuList.value.push(newItem);
-    }
-    selectedIndex.value = selectedIndex.value + 1;
-  }
-  if (row.name === "文字识别") {
-    router.push({
-      path: "/identifyFont",
-      query: {
-        fileId: copyFileId.value,
-        fileType: copyFileType.value,
-      },
-    });
-  }
   if (row.name === "预览") {
     loadingPreview.value = true;
     const filePreview = canPreviewFile(copyFileType.value);
@@ -822,7 +761,7 @@ const delCollect = async (row, isfolder) => {
 //刷新文件
 const refreshFile = () => {
   // console.log('ref',toRaw(thisFolder.value));
-  if (toRaw(thisFolder.value).isFavorite) {
+  if (toRaw(thisFolder.value) && toRaw(thisFolder.value).isFavorite) {
     //如果点开了文件夹
     // console.log(111);
     folderClick();
@@ -840,6 +779,31 @@ const getLeveldetailFn = async (data) => {
   }
   // console.log('thisFolderRole',thisFolderRole.value);
 };
+// 文件下载
+const downLoadfile = () => {
+  myfile.fileDown(clickRow.value.fileId).then((res) => {
+    var reader = new FileReader();
+    reader.onloadend = function (event) {
+      //event 就是你要的返回内容
+      //因为返回的报错格式是字符串,手动转换成对象,转换成功表示请求失败
+      //转换失败就意味着你拿到的result是文件流,那么直接手动下载就好
+      try {
+        let data = JSON.parse(event.target.result);
+      } catch (err) {
+        const link = document.createElement("a"); // 创建a标签
+        let blob = new Blob([res]);
+        link.style.display = "none";
+        link.href = URL.createObjectURL(blob); // 创建下载的链接
+        link.setAttribute("download", clickRow.value.fileName); // 给下载后的文件命名
+        document.body.appendChild(link);
+        link.click(); // 点击下载
+        document.body.removeChild(link); //  完成移除元素
+        window.URL.revokeObjectURL(link.href); // 释放blob对象
+      }
+    };
+    reader.readAsText(res);
+  });
+};
 </script>
 
 <style lang="scss" scoped>

+ 1 - 1
src/views/department/MyFile.vue

@@ -1452,7 +1452,7 @@ export default {
                     let data = JSON.parse(event.target.result)
                 }catch(err){
                     const link = document.createElement('a');  // 创建a标签
-                    let blob = new Blob([res.data]);     
+                    let blob = new Blob([res]);     
                     link.style.display = 'none';
                     link.href = URL.createObjectURL(blob);   // 创建下载的链接
                     link.setAttribute('download',clickRow.value.fileName);  // 给下载后的文件命名

+ 12 - 3
src/views/myfile/MyFile.vue

@@ -383,7 +383,7 @@
 </template>
 
 <script>
-import { ref, toRaw, onMounted ,inject} from 'vue'
+import { ref, toRaw, onMounted ,inject,onActivated} from 'vue'
 import myfile from '../../api/myfile/myfile'
 import { delFavorite } from '@/api/biz/favorite.js'
 import documents from '../../api/document/document'
@@ -664,7 +664,7 @@ export default {
         }
         function changeFile(row, num) {
             // 创建标签
-            console.log('route',route.path);
+           
             const addData = {
                 path:route.path,
                 row:toRaw(row)
@@ -1503,7 +1503,7 @@ export default {
                     let data = JSON.parse(event.target.result)
                 }catch(err){
                     const link = document.createElement('a');  // 创建a标签
-                    let blob = new Blob([res.data]);     
+                    let blob = new Blob([res]);     
                     link.style.display = 'none';
                     link.href = URL.createObjectURL(blob);   // 创建下载的链接
                     link.setAttribute('download',clickRow.value.fileName);  // 给下载后的文件命名
@@ -1523,6 +1523,15 @@ 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)
+            thisFolder.value = newRow
+            refreshFile()
+            }
+
+        })
         return {
             getSpaceList,
             folderList,//文件夹的数据

+ 1 - 1
src/views/publicment/MyFile.vue

@@ -1456,7 +1456,7 @@ export default {
                     let data = JSON.parse(event.target.result)
                 }catch(err){
                     const link = document.createElement('a');  // 创建a标签
-                    let blob = new Blob([res.data]);     
+                    let blob = new Blob([res]);     
                     link.style.display = 'none';
                     link.href = URL.createObjectURL(blob);   // 创建下载的链接
                     link.setAttribute('download',clickRow.value.fileName);  // 给下载后的文件命名