Преглед изворни кода

文件预览功能,文件限制功能

duy пре 2 година
родитељ
комит
488ad59da2
1 измењених фајлова са 42 додато и 2 уклоњено
  1. 42 2
      src/views/system/menu.vue

+ 42 - 2
src/views/system/menu.vue

@@ -18,7 +18,10 @@
                @size-change="sizeChange"
                @refresh-change="refreshChange"
                @on-load="onLoad"
-               @tree-load="treeLoad">
+               @tree-load="treeLoad"
+               :uploadExceed="uploadExceed"
+                :upload-preview="uploadPreview"
+               >
       <template slot="menuLeft">
         <el-button type="danger"
                    size="small"
@@ -52,6 +55,14 @@
           <i :class="row.source"/>
         </div>
       </template>
+       <template slot="excelUrl" slot-scope="scope" >
+        
+         <el-link type="primary" :href="scope.row.excelUrl" target="_blank">
+            <avue-text-ellipsis :text="scope.row.excelUrl" :height="100" >
+              <small slot="more">...</small>
+            </avue-text-ellipsis>
+         </el-link>
+      </template>
     </avue-crud>
   </basic-container>
 </template>
@@ -288,6 +299,7 @@
               propsHttp: {
                 url:'data'
               },
+              limit:1,
               tip: '只能上传MP4格式,且不能用QQ录屏,推荐使用win10自带录屏录制,文件大小限制50兆',
                 // tip: '只能上传jpg/png用户头像,且不超过500kb',
               action: "/api/blade-resource/oss/endpoint/put-file2"
@@ -297,13 +309,29 @@
               prop: 'excelUrl',
               type: 'upload',
               span: 12,
+              multiple:false,
+              dataType: "string",  
               loadText: '模板上传中,请稍等',
               propsHttp: {
-                url:'data'
+                url:'data', 
+
               },
+            
+              limit:1,
               tip: '上传文档说明',
               action: "/api/blade-resource/oss/endpoint/upload-file2"
             },
+            // {
+            //   label: "文档信息",
+            //   prop: "excelUrl",
+            //   type: "url",
+            //   span: 24,
+            //   minRows: 2,
+            //   propsHttp: {
+            //     url:'data'
+            //   }
+              
+            // },
           ]
         },
         data: []
@@ -359,6 +387,18 @@
       }
     },
     methods: {
+      uploadExceed(limit, files, fileList, column){
+        this.$message.warning('只允许上传1个文件,请先删除原文件再次点击上传')
+      },
+        //上传后进行点击预览
+      uploadPreview(file, column, done) {
+          //默认执行打开方法
+          window.open(file.url, 'baidu').then(()=>{
+            done();
+          })
+          
+      },
+    
       initData() {
         getMenuTree().then(res => {
           const column = this.findObject(this.option.column, "parentId");