liyangzheng 2 years ago
parent
commit
ef36e2ec5e

BIN
src/assets/images/elseFile.png


+ 35 - 9
src/views/myfile/MyFile.vue

@@ -42,7 +42,7 @@
                 </div>
                 <div>
                     <p>
-                        <span style="margin-left: 5px;">{{ useSpace + 'G' }}/{{ allSpace + "G" }}</span>
+                        <span style="margin-left: 5px;">{{ formatStorage(useSpace) }}/{{ allSpace + "G" }}</span>
                         <span style="margin-left: 5px;font-size: 12px;color: blue;cursor: pointer;"
                             @click="askApply">申请扩容</span>
                     </p>
@@ -122,7 +122,7 @@
                         <!-- 右侧 -->
                         <div>
                             <img :src="sort" alt="">
-                            <img :src="squre" alt="" >
+                            <img :src="squre" alt="">
                         </div>
                     </div>
                 </div>
@@ -131,9 +131,9 @@
                 <div class="detailBox file-jia" @click="mouseClick">
                     <el-collapse v-model="folder" accordion class="collapseSell">
                         <el-collapse-item title="文件夹" name="1" class="custom-collapse-item">
-                            <el-table :data="folderList" style="width: 100%" @selection-change="handleSelectionChange1"
-                                :single-select="true" @row-click="folderClick" @row-contextmenu="folderRClick"
-                                ref="taskTableRef">
+                            <el-table v-if="folderGrid" :data="folderList" style="width: 100%"
+                                @selection-change="handleSelectionChange1" :single-select="true" @row-click="folderClick"
+                                @row-contextmenu="folderRClick" ref="taskTableRef">
                                 <el-table-column type="selection" width="55" />
                                 <el-table-column label="名称" width="180">
                                     <template #default="scope">
@@ -159,6 +159,7 @@
                                 </el-table-column>
 
                             </el-table>
+                            <PlaceGridFolder v-else></PlaceGridFolder>
                         </el-collapse-item>
                     </el-collapse>
                     <!-- 右键唤出的菜单 -->
@@ -208,12 +209,12 @@
                                     </template>
                                 </el-table-column>
                             </el-table>
-                            <PalaceGridFile v-else></PalaceGridFile>
+                            <PalaceGridFile v-else @showFile="showFile"></PalaceGridFile>
                         </el-collapse-item>
                     </el-collapse>
                     <div class="setCli" v-if="cliCC" :style="{ left: xz + 'px', top: yz - 260 + 'px' }">
                         <template v-for="(item, index) in filterMouseCli()">
-                            <p @click="chooseSet(item, index,1)" class="chooseSet">
+                            <p @click="chooseSet(item, index, 1)" class="chooseSet">
                                 <img :src="item.img" alt="">
                                 {{ item.name }}
                                 <span v-if="item.name == '在线编辑' || item.name == '协作' ? true : false"
@@ -630,7 +631,6 @@ export default {
         }
         // 文件名表格每一行点击事件
         function handleRowClick(row, col, e) {
-            console.log('row',row);
             isFolder.value = "N"
             clickRow.value = row
             e.preventDefault();
@@ -999,6 +999,12 @@ export default {
         function getSpaceC(data) {
             spaces.value = data
         }
+        function showFile(data,e,a) {
+            // console.log(data,e,a,'data');
+            editOnline.value = data
+            clickRowId.value = e
+            copyRow = a
+        }
         //历史版本
         const forwardTreeData = reactive({ data: {} });
         const historycopyRow = ref({})
@@ -1097,12 +1103,30 @@ export default {
                 return fileSize + 'B';
             }
         }
+        function formatStorage(sizeInGB) {
+            if (sizeInGB >= 1) {
+                return sizeInGB.toFixed(2) + 'GB';
+            } else {
+                const sizeInMB = sizeInGB * 1024;
+                if (sizeInMB >= 1) {
+                    return sizeInMB.toFixed(2) + 'MB';
+                } else {
+                    const sizeInKB = sizeInMB * 1024;
+                    return sizeInKB.toFixed(2) + 'KB';
+                }
+            }
+        }
         function gridChange() {
             if (fileGrid.value) {
                 fileGrid.value = false
             } else {
                 fileGrid.value = true
             }
+            if (folderGrid.value) {
+                folderGrid.value = false
+            } else {
+                folderGrid.value = true
+            }
         }
         onMounted(() => {
             getAllTop()
@@ -1248,7 +1272,9 @@ export default {
             folderGrid,
             gridChange,
             collectFolder,
-            arrowLift
+            arrowLift,
+            formatStorage,
+            showFile,
         }
     },
     watch: {

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

@@ -98,8 +98,8 @@ export default {
             oo(docId, true);
         }
         onMounted(() => {
-            // console.log(docId, 'doc');
-            // console.log(copyRow, 'row');
+            console.log(docId, 'doc');
+            console.log(copyRow, 'row');
             edit()
             // let row = JSON.parse(newObj.value)
             // console.log(row, '852');

+ 1 - 1
src/views/myfile/components/FileTree.vue

@@ -28,7 +28,7 @@ export default {
             required: true
         },
         fileId: {
-            type: String,
+            type: Number,
             required: true
         },
         copyOrMove: {

+ 431 - 11
src/views/myfile/components/PalaceGridFile.vue

@@ -2,19 +2,56 @@
     <div>
         <!-- flex盒子 -->
         <div class="bigBox">
-            <template v-for="(item,index) in fileList">
+            <template v-for="(item, index) in fileList">
                 <!-- 循环盒子 -->
-                <div>
+                <div class="flexBox" @contextmenu="rightClick(item, $event)">
                     <!-- 图片 -->
-                    <div>
-                        <img :src="getImage(item.fileType)" alt="">
+                    <div class="imgBox">
+                        <img :src="getImage(item.fileType)" alt="" style="vertical-align: middle;">
                     </div>
                     <!-- 名称 -->
-                    <div>
-                        <p>{{ item.fileName }}</p>
+                    <div class="nameBox">
+                        <p class="nameName">{{ item.fileName }}</p>
                     </div>
                 </div>
             </template>
+            <div class="setCli" v-if="cliCC" :style="{ left: xz + 'px', top: (yz - 330) + 'px' }">
+                <template v-for="(item, index) in filterMouseCli()">
+                    <p @click="chooseSet(item, index, 1)" class="chooseSet">
+                        <img :src="item.img" alt="">
+                        {{ item.name }}
+                        <span v-if="item.name == '在线编辑' || item.name == '协作' ? true : false"
+                            style="color: #7084B4;float: right;position: relative;" class="arrow">></span>
+                    </p>
+                </template>
+            </div>
+            <div class="setCli1" v-if="anyP">
+                <p @click="chooseSet1(0)" class="chooseSet">
+                    <img src="../../../assets/images/user.png" alt="">
+                    选择人员
+                </p>
+                <p class="chooseSet" @click="goLock">
+                    <img src="../../../assets/images/archiveTray.png" alt="">
+                    归档
+                </p>
+            </div>
+            <div>
+                <TransferModal v-if="thanks" :thanks="thanks" :clickRowId="clickRowId" :workOrEdit="workOrEdit"
+                    @getCback="getCback"></TransferModal>
+            </div>
+            <!-- 复制粘贴 -->
+            <div>
+                <FileTree v-if="fileTrees" :fileTrees="fileTrees" :newSpaceId="newSpaceId" :fileId="clickRowId"
+                    @getChildren="getChildren" :copyOrMove="copyOrMove"></FileTree>
+            </div>
+            <div>
+                <ImgPreview :previewData="previewData" :copyFileType="copyFileType" :showPreview="showPreview"
+                    @closeImgPreview="closeImgPreview"></ImgPreview>
+            </div>
+            <!-- <div>
+                <FileEdit v-if="editOnline" :docId="clickRowId" :copyRow="copyRow" :historyPrew="historyPrew" :historycopyRow="historycopyRow"
+                    :onlyView="onlyView" @cancleHistoryPrew="cancleHistoryPrew"></FileEdit>
+            </div> -->
         </div>
     </div>
 </template>
@@ -24,10 +61,16 @@ import { ref, onMounted } from "vue"
 import { ElMessage } from "element-plus";
 import myfile from "../../../api/myfile/myfile";
 import documents from "../../../api/document/document";
+import TransferModal from '../modalComponebts/Transfer.vue'
+import ImgPreview from '@/components/ImgPreview/ImgPreview.vue'
+import FileEdit from './FileEdit.vue'
+import FileTree from './FileTree.vue'
 import ImgFile from "../jsComponents/ImgFile";
-// import bigFolder from '../../../assets/images/folderBig.png'
+import { canPreviewFile } from "@/utils/index.js"
+import { preview } from "@/api/common/common.js";
+import { listVersion } from "@/api/biz/version";
 export default {
-    setup() {
+    setup(props, { emit }) {
         let impDirId = ref(0)
         let impSpaceId = ref(0)
         let newSpaceId = ref(0)
@@ -37,6 +80,85 @@ export default {
         let folderList = ref([])
         let fileTotal = ref(0)
         let fileMenu = ref([])
+        let isFolder = ref("")
+        let clickRow = ref({})
+        let copyRow = ref("")
+        let clickRowId = ref("")
+        let copyDirId = ref("")
+        let copySpaceId = ref("")
+        let copyFileId = ref("")
+        let copyFileSize = ref("")
+        let copyFileType = ref("")
+        let workOrEdit = ref(0)
+        let copyOrMove = ref(0)
+        let nameForm = ref({
+            name: ""
+        })
+        const historycopyRow = ref({})
+        let copyFileName = ref("")
+        let yz = ref(0)
+        let xz = ref(0)
+        let cliCC = ref(false)
+        let anyP = ref(false)
+        let thanks = ref(false)
+        let fileTrees = ref(false)
+        let onlyView = ref(false)
+        let editOnline = ref(false)
+        let showPreview = ref(false)
+        let historyPrew = ref(false)
+        let historyTotal = ref(0)
+        const fileUserTreeData = reactive({ data: {} });
+        let previewData = ref()
+        let mouseCli = ref([
+            {
+                img: ImgFile.previewIcon,
+                name: "预览"
+            },
+            {
+                img: ImgFile.addolder,
+                name: "移动到...",
+            },
+            {
+                img: ImgFile.copy,
+                name: "复制到...",
+            },
+            {
+                img: ImgFile.collect,
+                name: "收藏"
+            },
+            {
+                img: ImgFile.downLoad,
+                name: "下载"
+            },
+            {
+                img: ImgFile.textbox,
+                name: "重命名"
+            },
+            {
+                img: ImgFile.share,
+                name: "分享"
+            },
+            {
+                img: ImgFile.notePencil,
+                name: "在线编辑"
+            },
+            {
+                img: ImgFile.togger,
+                name: "协作"
+            },
+            {
+                img: ImgFile.icc,
+                name: "文字识别"
+            },
+            {
+                img: ImgFile.history,
+                name: "历史版本"
+            },
+            {
+                img: ImgFile.trash,
+                name: "删除"
+            }
+        ])
         // 获取文件夹,中栏,文件
         function getAllTop() {
             documents.getTop(3).then(res => {
@@ -79,10 +201,9 @@ export default {
         }
         // 筛选后缀图片
         function getImage(file) {
-            console.log(file,'file');
             if (file === '.txt') {
                 return ImgFile.bigTxt
-            } else if (file === '.xlxs' || file === '.docx') {
+            } else if (file === '.xlxs' || file === '.docx' || file === '.xls') {
                 return ImgFile.bigxlsx
             } else if (file === '.pptx') {
                 return ImgFile.bigpptx
@@ -90,10 +211,181 @@ export default {
                 return ImgFile.bigdoc
             } else if (file === '.pdf') {
                 return ImgFile.bigpdf
+            } else if (file === ".mp3") {
+                return ImgFile.audio
+            } else if (file === '.mp4') {
+                return ImgFile.video
+            } else if (file === ".png" || file === ".jpg") {
+                return ImgFile.pic
+            } else {
+                return ImgFile.elseFile
+            }
+        }
+        function rightClick(row, event) {
+            event.preventDefault()
+            isFolder.value = "N"
+            clickRow.value = row
+            xz.value = event.pageX
+            yz.value = event.pageY
+            copyRow.value = row
+            clickRowId.value = row.docId
+            copyDirId.value = row.dirId
+            copySpaceId.value = row.spaceId
+            copyFileId.value = row.fileId
+            copyFileSize.value = row.fileSize
+            copyFileType.value = row.fileType
+            nameForm.value.name = row.fileName
+            copyFileName.value = row.fileName
+            if (cliCC.value === true) {
+                cliCC.value = false
+            } else {
+                cliCC.value = true
+            }
+        }
+        //对mouseCli数组进行筛选,实现菜单的区分显示
+        const filterMouseCli = () => {
+            const canPreviewArray = ['.doc', '.docm', '.docx', '.dot', '.dotm', '.dotx', '.epub', '.fodt', '.htm', '.html', '.mht', '.odt', '.ott', '.pdf', '.rtf', '.txt', '.djvu', '.xps', 'csv', 'fods', 'ods', 'ots', 'xls', 'xlsm', 'xlsx', 'xlt', 'xltm', 'xltx', 'fodp', 'odp', 'otp', 'pot', 'potm', 'potx', 'pps', 'ppsm', 'ppsx', 'ppt', 'pptm', 'pptx']
+            const typeArr = ['.png', '.jpg', '.jpeg', '.JPG', '.mp3', '.mp4']
+            const imgTypeArr = ['.png', '.jpg', '.jpeg', '.JPG']
+            const canEditArr = ['.doc', '.docm', '.docx', '.dot', '.dotm', '.dotx', '.txt', '.djvu', '.xps', 'csv', 'fods', 'ods', 'ots', 'xls', 'xlsm', 'xlsx', 'xlt', 'xltm', 'xltx', 'fodp', 'odp', 'otp']
+            let arr = []
+            if (!(typeArr.includes(copyFileType.value) || canPreviewArray.includes(copyFileType.value))) {
+                arr = mouseCli.value.filter(item => item.name !== "预览")
+            } else {
+                arr = toRaw(mouseCli.value)
+            }
+            if (!canEditArr.includes(copyFileType.value)) {
+                arr = arr.filter(item => item.name !== "在线编辑" && item.name !== "协作" && item.name !== "历史版本")
+            }
+            if (!imgTypeArr.includes(copyFileType.value)) {
+                arr = arr.filter(item => item.name !== "文字识别")
             }
+            return arr
+        }
+        function mouseClick() {
+            if (cliCC.value) {
+                cliCC.value = false
+            }
+            if (anyP) {
+                anyP.value = false
+            }
+        }
+        async function chooseSet(row, index, num) {
+            if (row.name == '在线编辑' || row.name == '协作') {
+                cliCC.value = true
+            } else {
+                cliCC.value = false
+            }
+            if (row.name == '分享') {
+                workOrEdit.value = num
+                thanks.value = true
+            } else {
+                thanks.value = false
+            }
+            if (row.name == '协作') {
+                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 === '重命名') {
+                fileNameChange.value = true
+            }
+            if (row.name === "下载") {
+                location.href = `${import.meta.env.VITE_APP_BASE_API}/api/download/${copyFileId.value}`;
+            }
+            if (row.name === '收藏') {
+                collects.value = true
+            }
+            if (row.name === '在线编辑') {
+                editOnline.value = false
+                cliCC.value = false
+            }
+            if (row.name === '文字识别') {
+                router.push({
+                    path: '/identifyFont',
+                    query: {
+                        fileId: copyFileId.value,
+                        fileType: copyFileType.value
+                    }
+                })
+            }
+            if (row.name === '预览') {
+                // editOnline.value = true
+                // emit("showFile", false)
+                const filePreview = canPreviewFile(copyFileType.value)
+                if (filePreview) {
+                    onlyView.value = true
+                    emit("showFile", false, clickRowId.value, copyRow.value)
+                    cliCC.value = false
+                } else {
+                    showPreview.value = true
+                    const res = await preview(copyFileId.value)
+                    previewData.value = URL.createObjectURL(res)
+                    console.log(888);
+                }
+                showPreview.value = true
+                const res = await preview(copyFileId.value)
+                previewData.value = URL.createObjectURL(res)
+            } else if (row.name === "历史版本") {
+                const resHistory = await listVersion({ docId: clickRowId.value })
+                historyTotal.value = resHistory.total
+                fileUserTreeData.data = resHistory.rows;
+                openForwardFile.value = true
+            }
+        }
+        function changeMsgClose(val, item) {
+            if (val) {
+                historycopyRow.value = item
+                editOnline.value = false
+                cliCC.value = false
+                historyPrew.value = true
+            }
+            openForwardFile.value = val
+        }
+
+        function chooseSet1(num) {
+            workOrEdit.value = num
+            thanks.value = true
+            anyP.value = false
+        }
+        function getChildren(data) {
+            fileTrees.value = data
+        }
+        function getCback(data) {
+            thanks.value = data
+        }
+        function closeImgPreview(data) {
+            showPreview.value = data
+        }
+        function cancleHistoryPrew(data) {
+            historyPrew.value = false
         }
         onMounted(() => {
             getAllTop()
+            window.addEventListener("click", mouseClick);
         })
         return {
             getAllTop,
@@ -106,9 +398,137 @@ export default {
             folderList,
             fileTotal,
             getImage,
+            rightClick,
+            filterMouseCli,
+            copyRow,
+            clickRow,
+            clickRowId,
+            copyDirId,
+            copySpaceId,
+            copyFileId,
+            copyFileSize,
+            copyFileType,
+            nameForm,
+            copyFileName,
+            cliCC,
+            mouseClick,
+            anyP,
+            xz,
+            yz,
+            chooseSet,
+            chooseSet1,
+            thanks,
+            FileTree,
+            fileTrees,
+            getCback,
+            getChildren,
+            copyOrMove,
+            onlyView,
+            editOnline,
+            showPreview,
+            ImgPreview,
+            previewData,
+            closeImgPreview,
+            FileEdit,
+            cancleHistoryPrew,
+            historycopyRow,
+            changeMsgClose,
+            historyPrew,
         }
+    },
+    components: {
+        TransferModal,
+        FileTree,
+        ImgPreview,
+        FileEdit
     }
 }
 </script>
 
-<style lang="scss" scoped></style>
+<style scoped>
+.bigBox {
+    width: 100%;
+    height: 100%;
+    display: flex;
+    justify-content: flex-start;
+    align-items: center;
+    flex-wrap: wrap;
+}
+
+.imgBox {
+    width: 88px;
+    height: 88px;
+    text-align: center;
+    line-height: 88px;
+}
+
+.flexBox {
+    width: 104px;
+    height: 148px;
+    position: relative;
+}
+
+.nameName {
+    width: 100%;
+    white-space: nowrap;
+    /* 禁止文本换行 */
+    overflow: hidden;
+    /* 隐藏溢出部分文本 */
+    text-overflow: ellipsis;
+    /* 显示省略号 */
+}
+
+.setCli {
+    width: 156px;
+    max-height: auto;
+    position: absolute;
+    flex-wrap: 400;
+    background-color: white;
+    border: 1px solid gray;
+    border-radius: 4px;
+    z-index: 3;
+    overflow-y: auto;
+    /* // font-size: 16px; */
+}
+
+.setCli1 {
+    width: 156px;
+    height: auto;
+    position: absolute;
+    top: 185px;
+    left: 455px;
+    background-color: white;
+    border: 1px solid gray;
+    border-radius: 4px;
+    z-index: 2;
+    overflow-y: auto;
+}
+
+.chooseSet {
+    width: 140px;
+    height: 30px;
+    line-height: 30px;
+    margin: 5px auto;
+    font-size: 13px;
+    /* 
+    display: flex;
+    align-items: center;
+    position: relative; */
+
+}
+
+.chooseSet img {
+    margin-right: 4px;
+    vertical-align: middle;
+}
+
+.chooseSet:hover {
+    width: 140px;
+    height: 30px;
+    line-height: 30px;
+    margin: 5px auto;
+    font-size: 13px;
+    background-color: #F5F7F9;
+    /* color: white; */
+}
+</style>

+ 75 - 6
src/views/myfile/components/PlaceGridFolder.vue

@@ -1,14 +1,43 @@
 <template>
     <div>
-
+        <div>
+            <!-- flex盒子 -->
+            <div class="bigBox">
+                <template v-for="(item, index) in folderList">
+                    <!-- 循环盒子 -->
+                    <div class="flexBox">
+                        <!-- 图片 -->
+                        <div class="imgBox">
+                            <img src="../../../assets/images/folderBig.png" alt="" style="vertical-align: middle;">
+                        </div>
+                        <!-- 名称 -->
+                        <div class="nameBox">
+                            <p class="nameName">{{ item.dirName }}</p>
+                        </div>
+                    </div>
+                </template>
+            </div>
+        </div>
     </div>
 </template>
 
 <script>
-import {ref,onMounted} from "vue"
+import { ref, onMounted } from "vue"
 import { ElMessage } from "element-plus";
+import myfile from "../../../api/myfile/myfile";
+import documents from "../../../api/document/document";
+import ImgFile from "../jsComponents/ImgFile";
 export default {
-    setup () {
+    setup() {
+        let impDirId = ref(0)
+        let impSpaceId = ref(0)
+        let newSpaceId = ref(0)
+        let newDirId = ref(0)
+        let topPath = ref("")
+        let fileList = ref([])
+        let folderList = ref([])
+        let fileTotal = ref(0)
+        let fileMenu = ref([])
         // 获取文件夹,中栏,文件
         function getAllTop() {
             documents.getTop(3).then(res => {
@@ -47,14 +76,54 @@ export default {
                 })
             })
         }
-
+        onMounted(()=>{
+            getAllTop()
+        })
         return {
-
+            getAllTop,
+            impDirId,
+            impSpaceId,
+            newDirId,
+            newSpaceId,
+            fileList,
+            fileMenu,
+            folderList,
+            fileTotal,
         }
     }
 }
 </script>
 
-<style lang="scss" scoped>
+<style scoped>
+.bigBox {
+    width: 100%;
+    height: 100%;
+    display: flex;
+    justify-content: flex-start;
+    align-items: center;
+    flex-wrap: wrap;
+}
 
+.imgBox {
+    width: 88px;
+    height: 88px;
+    text-align: center;
+    line-height: 88px;
+}
+
+.flexBox {
+    width: 104px;
+    height: 148px;
+}
+
+.nameName {
+    width: 100%;
+    text-align: center;
+    white-space: nowrap;
+    /* 禁止文本换行 */
+    overflow: hidden;
+    /* 隐藏溢出部分文本 */
+    text-overflow: ellipsis;
+    /* 显示省略号 */
+}
 </style>

+ 8 - 0
src/views/myfile/jsComponents/ImgFile.js

@@ -35,6 +35,10 @@ import bigxlsx from '../../../assets/images/xlsxBig.png'
 import bigpdf from '../../../assets/images/pdfBig.png'
 import bigdoc from '../../../assets/images/docBig.png'
 import bigpptx from '../../../assets/images/pptxBig.png'
+import audio from '../../../assets/images/audio.png'
+import video from '../../../assets/images/video.png'
+import pic from '../../../assets/images/pic.png'
+import elseFile from '../../../assets/images/elseFile.png'
 export default {
     copy,
     clipboard,
@@ -72,4 +76,8 @@ export default {
     bigpdf,
     bigpptx,
     bigxlsx,
+    audio,
+    video,
+    pic,
+    elseFile,
 }