Quellcode durchsuchen

文件上传限制,路径跳转bug

liuQiang vor 2 Jahren
Ursprung
Commit
955f2c64ad

+ 1 - 1
src/components/PathLabel/index.vue

@@ -24,7 +24,7 @@ const emit = defineEmits(["folderClick"]);
 watch(
   () => props.pathLabelData,
   (newValue) => {
-    console.log(111, newValue);
+    // console.log(111, newValue);
   }
 );
 const clickItem = async (dirId,index) => {

+ 23 - 6
src/views/department/MyFile.vue

@@ -334,7 +334,7 @@
             <!-- 文件上传 -->
             <div>
                 <el-dialog :close-on-click-modal="false" v-model="uploadModal" title="文件上传" width="30%" @close="closeUpload">
-                    <el-upload class="upload-demo" :file-list="fileArr"  drag :http-request="onSuccess" multiple
+                    <el-upload class="upload-demo" :file-list="fileArr" :before-upload="upBefore" drag :http-request="onSuccess" multiple
                     :on-remove="handleRemove"  
                     element-loading-text="上传中..."
                     element-loading-background="rgba(255, 255, 255, 0.8)"
@@ -454,6 +454,7 @@ import fileBox from "@/assets/images/fileBox.png";
 import { getLevel } from '@/api/level/level.js';
 import Cookies from "js-cookie";
 import elTableInfiniteScroll from 'el-table-infinite-scroll'
+import { getConfigKey } from "@/api/system/config.js"
 
 export default {
     directives: {
@@ -660,6 +661,7 @@ export default {
         const spaceName = ref()
         const isDept = ref(false)// 是否管理员
         const loadingUpload = ref(false);//文件上传加载
+        const maxFileSize = ref()//能上传的最大size
         const pathLabelData = ref([
         ])
         //控制宫格展示
@@ -1181,7 +1183,7 @@ export default {
             if(!pathLabelData.value[0]){
                  // 创建标签
                 const addData = {
-                    path: '/myfile' + row.dirId,
+                    path: '/department' + row.dirId,
                     name: row.dirName,
                     clickRowId: toRaw(row)
                 }
@@ -1199,7 +1201,7 @@ export default {
                 if(pathLabelData.value[0]){
                     // 有值就说明是二级及以后的数据
                     const oldArr = toRaw(pathLabelData.value)
-                    // console.log('oldArr',oldArr);
+                    console.log('oldArr',oldArr);
                     let newArr
                     console.log('jump',jump);
                     if(jump == undefined){
@@ -1359,10 +1361,10 @@ export default {
         }
         //对mouseCli数组进行筛选,实现菜单的区分显示
         const filterMouseCli = () => {
-            const canPreviewArray = ['.doc','.wps', '.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 canPreviewArray = ['.doc','dps','et','.wps', '.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','.doc', '.docm', '.docx', '.dot', '.dotm', '.dotx', '.epub', '.fodt', '.htm', '.html', '.mht', '.odt', '.ott', '.rtf', '.txt', '.djvu', '.xps', '.wps','.pptx']
+            const canEditArr = ['.doc', 'dps','et','.docm', '.docx', '.dot', '.dotm', '.dotx', '.txt', '.djvu', '.xps', '.csv', '.fods', '.ods', '.ots', '.xls', '.xlsm', '.xlsx', '.xlt', '.xltm', '.xltx', '.fodp', '.odp', '.otp','.doc', '.docm', '.docx', '.dot', '.dotm', '.dotx', '.epub', '.fodt', '.htm', '.html', '.mht', '.odt', '.ott', '.rtf', '.txt', '.djvu', '.xps', '.wps','.pptx']
             let arr = []
             if (!(typeArr.includes(copyFileType.value) || canPreviewArray.includes(copyFileType.value))) {
                 arr = mouseCli.value.filter(item => item.name !== "预览")
@@ -1717,11 +1719,24 @@ export default {
             oneOrTwo.value = 1
             folderCase.value = true
         }
+        const upBefore = (file)=>{
+            // console.log('file',file.size);
+            const maxSize = (maxFileSize.value-0)*1024*1024
+            // console.log('maxSize',maxSize);
+            if(file.size>maxSize){
+                ElMessage({ message: '上传文件大小最大为'+maxFileSize.value+'M', type: 'error' })
+            return false
+            }
+        }
         onMounted(() => {
             getAllTop()
             getSpaceList()
             getUserInfo()
             getLevelList()
+            getConfigKey("file.size.limit").then(response => {
+                // console.log('response',response);
+                maxFileSize.value = response.msg
+            });  
             // 添加监听,点击其他地方关闭文件夹右键菜单
             window.addEventListener("click", closeRMenu, true);
             window.addEventListener("click", mouseClick, true);
@@ -1965,7 +1980,9 @@ export default {
             loadingUpload,
             fileBlur,
             pathLabelData,
-            backTopPath
+            backTopPath,
+            maxFileSize,
+            upBefore
 
         }
     },

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

@@ -363,7 +363,7 @@
             <!-- 文件上传 -->
             <div>
                 <el-dialog v-model="uploadModal" title="文件上传" :close-on-click-modal="false" width="30%" @close="closeUpload">
-                    <el-upload class="upload-demo" :file-list="fileArr"  drag :http-request="onSuccess" multiple :on-remove="handleRemove"  
+                    <el-upload class="upload-demo" :file-list="fileArr" :before-upload="upBefore"  drag :http-request="onSuccess" multiple :on-remove="handleRemove"  
                     element-loading-text="上传中..."
                     element-loading-background="rgba(255, 255, 255, 0.8)"
                     v-loading="loadingUpload" >
@@ -484,6 +484,7 @@ import { encrypt, decrypt } from "@/utils/jsencrypt";
 import Cookies from "js-cookie";
 import elTableInfiniteScroll from 'el-table-infinite-scroll'
 import { getLevel } from '@/api/level/level.js';
+import { getConfigKey } from "@/api/system/config.js"
 
 export default {
     directives: {
@@ -683,6 +684,7 @@ export default {
         const tableTotal = ref(0)//表格数据总数
         const clickFileData = ref(null);
         let fileBig = ref(0);
+        const maxFileSize = ref()//能上传的最大size
         const pathLabelData = ref([
         ])
          //控制宫格展示
@@ -1514,10 +1516,10 @@ export default {
         }
         //对mouseCli数组进行筛选,实现菜单的区分显示
         const filterMouseCli = () => {
-            const canPreviewArray = ['.doc', '.wps', '.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 canPreviewArray = ['.doc','dps','et', '.wps', '.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','.PNG']
-            const canEditArr = ['.doc', '.docm', '.docx', '.dot', '.dotm', '.dotx', '.txt', '.djvu', '.xps', '.csv', '.fods', '.ods', '.ots', '.xls', '.xlsm', '.xlsx', '.xlt', '.xltm', '.xltx', '.fodp', '.odp', '.otp', '.doc', '.docm', '.docx', '.dot', '.dotm', '.dotx', '.epub', '.fodt', '.htm', '.html', '.mht', '.odt', '.ott', '.rtf', '.txt', '.djvu', '.xps', '.wps', '.pptx']
+            const canEditArr = ['.doc', '.docm', '.docx', '.dot', '.dotm', '.dotx', '.txt', '.djvu', '.xps', '.csv', '.fods', '.ods', '.ots', '.xls', '.xlsm', '.xlsx', '.xlt', '.xltm', '.xltx', '.fodp', '.odp', '.otp', '.doc', '.docm', '.docx', '.dot', '.dotm', '.dotx', '.epub', '.fodt', '.htm', '.html', '.mht', '.odt', '.ott', '.rtf', '.txt', '.djvu', '.xps', '.wps','dps','et', '.pptx']
             let arr = []
             if (!(typeArr.includes(copyFileType.value) || canPreviewArray.includes(copyFileType.value))) {
                 arr = mouseCli.value.filter(item => item.name !== "预览")
@@ -1843,12 +1845,25 @@ export default {
             pathLabelData.value = ([])
             getAllTop()
         }
+        const upBefore = (file)=>{
+            // console.log('file',file.size);
+            const maxSize = (maxFileSize.value-0)*1024*1024
+            // console.log('maxSize',maxSize);
+            if(file.size>maxSize){
+                ElMessage({ message: '上传文件大小最大为'+maxFileSize.value+'M', type: 'error' })
+            return false
+            }
+        }
         onMounted(() => {
             // if(!thisFolder.value){
             getAllTop()
             // }
             getSpaceList()
             getLevelList()
+            getConfigKey("file.size.limit").then(response => {
+                // console.log('response',response);
+                maxFileSize.value = response.msg
+            });     
             // console.log('!thisFolder.value',thisFolder.value);
             // refreshFile()
             // 添加监听,点击其他地方关闭文件夹右键菜单
@@ -2102,7 +2117,9 @@ export default {
             levelList,
             setTablelevel,
             pathLabelData,
-            backTopPath
+            backTopPath,
+            maxFileSize,
+            upBefore
         }
     },
     watch: {

+ 22 - 5
src/views/publicment/MyFile.vue

@@ -331,7 +331,7 @@
             <!-- 文件上传 -->
             <div>
                 <el-dialog v-model="uploadModal" :close-on-click-modal="false" title="文件上传" width="30%" @close="closeUpload">
-                    <el-upload class="upload-demo" :file-list="fileArr"  drag :http-request="onSuccess" multiple
+                    <el-upload class="upload-demo" :before-upload="upBefore" :file-list="fileArr"  drag :http-request="onSuccess" multiple
                     :on-remove="handleRemove"  
                     element-loading-text="上传中..."
                     element-loading-background="rgba(255, 255, 255, 0.8)"
@@ -451,6 +451,7 @@ import fileBox from "@/assets/images/fileBox.png";
 import Cookies from "js-cookie";
 import { getLevel } from '@/api/level/level.js';
 import elTableInfiniteScroll from 'el-table-infinite-scroll'
+import { getConfigKey } from "@/api/system/config.js"
 
 export default {
     directives: {
@@ -669,6 +670,7 @@ export default {
         const tableBeEnd = ref(true)//控制下拉是否到底
         const tableTotal = ref(0)//表格数据总数
         const isDept = ref(false)// 是否管理员
+        const maxFileSize = ref()//能上传的最大size
         const pathLabelData = ref([
         ])
         //控制宫格展示
@@ -1183,7 +1185,7 @@ export default {
             if(!pathLabelData.value[0]){
                  // 创建标签
                 const addData = {
-                    path: '/myfile' + row.dirId,
+                    path: '/publicment' + row.dirId,
                     name: row.dirName,
                     clickRowId: toRaw(row)
                 }
@@ -1360,10 +1362,10 @@ export default {
         }
         //对mouseCli数组进行筛选,实现菜单的区分显示
         const filterMouseCli = () => {
-            const canPreviewArray = ['.doc','.wps', '.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 canPreviewArray = ['.doc','dps','et','.wps', '.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','.doc', '.docm', '.docx', '.dot', '.dotm', '.dotx', '.epub', '.fodt', '.htm', '.html', '.mht', '.odt', '.ott', '.rtf', '.txt', '.djvu', '.xps', '.wps','.pptx']
+            const canEditArr = ['.doc', 'dps','et','.docm', '.docx', '.dot', '.dotm', '.dotx', '.txt', '.djvu', '.xps', '.csv', '.fods', '.ods', '.ots', '.xls', '.xlsm', '.xlsx', '.xlt', '.xltm', '.xltx', '.fodp', '.odp', '.otp','.doc', '.docm', '.docx', '.dot', '.dotm', '.dotx', '.epub', '.fodt', '.htm', '.html', '.mht', '.odt', '.ott', '.rtf', '.txt', '.djvu', '.xps', '.wps','.pptx']
             let arr = []
             if (!(typeArr.includes(copyFileType.value) || canPreviewArray.includes(copyFileType.value))) {
                 arr = mouseCli.value.filter(item => item.name !== "预览")
@@ -1733,11 +1735,24 @@ export default {
             pathLabelData.value = ([])
             getAllTop()
         }
+        const upBefore = (file)=>{
+            // console.log('file',file.size);
+            const maxSize = (maxFileSize.value-0)*1024*1024
+            // console.log('maxSize',maxSize);
+            if(file.size>maxSize){
+                ElMessage({ message: '上传文件大小最大为'+maxFileSize.value+'M', type: 'error' })
+            return false
+            }
+        }
         onMounted(() => {
             getAllTop()
             getSpaceList()
             getUserInfo()
             getLevelList()
+            getConfigKey("file.size.limit").then(response => {
+                // console.log('response',response);
+                maxFileSize.value = response.msg
+            });  
             // 添加监听,点击其他地方关闭文件夹右键菜单
             window.addEventListener("click", closeRMenu, true);
             window.addEventListener("click", mouseClick, true);
@@ -1982,7 +1997,9 @@ export default {
             fileBlur,
             pathLabelData,
             fileBlur,
-            backTopPath
+            backTopPath,
+            maxFileSize,
+            upBefore
         }
     },
     watch: {