zhangyu 5 년 전
부모
커밋
be5e5fa0b2
2개의 변경된 파일35개의 추가작업 그리고 12개의 파일을 삭제
  1. 13 10
      src/components/globaluploader/index.vue
  2. 22 2
      src/views/model/file/index.vue

+ 13 - 10
src/components/globaluploader/index.vue

@@ -82,6 +82,7 @@ export default {
         // headers: {
           // Authorization: Ticket.get() && "Bearer " + Ticket.get().access_token
         // },
+        method: 'octet',
         query() {}
       },
       attrs: {
@@ -210,13 +211,15 @@ export default {
 
     computeMD5Success(md5, file) {
       // 将自定义参数直接加载uploader实例的opts上
+      console.log(this.uploader)
       Object.assign(this.uploader.opts, {
         query: {
             ...this.params,
+            Md5: md5
         }
       })
 
-      file.uniqueIdentifier = md5;
+      file.uniqueIdentifier = this.params.id;
       file.resume();
       this.statusRemove(file.id);
     },
@@ -397,15 +400,15 @@ export default {
       content: '' !important;
     }
 
-    &[icon=image] {
-      // background: url(./images/image-icon.png);
-    }
-    &[icon=video] {
-      // background: url(./images/video-icon.png);
-    }
-    &[icon=document] {
-      // background: url(./images/text-icon.png);
-    }
+    // &[icon=image] {
+    //   background: url(./images/image-icon.png);
+    // }
+    // &[icon=video] {
+    //   background: url(./images/video-icon.png);
+    // }
+    // &[icon=document] {
+    //   background: url(./images/text-icon.png);
+    // }
   }
 
   /deep/ .uploader-file-actions > span {

+ 22 - 2
src/views/model/file/index.vue

@@ -43,6 +43,7 @@
         <div class="top_hand right_top_hand">
           <el-button @click="addFloorFile">添加楼层文件</el-button>
           <el-button @click="queryFloorFile(currentFolderId)">刷新</el-button>
+          <el-button @click="addDemo">添加文件</el-button>
         </div>
         <!-- 列表 -->
         <floorTable ref="floorTable" :tableData="tableData" :modelFolderName="currentFolderName" @openModelLog="queryModelLog"
@@ -151,14 +152,33 @@ export default {
       isJump: true //是否可以调整页面
     };
   },
-  // mounted() {
+  mounted() {
   //   window.addEventListener('beforeunload', e => {
   //     if (this.uploadClassList.length) {
   //       window.localStorage.removeItem("当前页有下载内容,关闭或刷新页面下载将会失败。您确定要继续吗?")
   //     }
   //   })
-  // },
+
+    // 文件选择后的回调
+    Bus.$on('fileAdded', () => {
+      console.log('文件已选择')
+    });
+    // 文件上传成功的回调
+    Bus.$on('fileSuccess', () => {
+      console.log('文件上传成功')
+    });
+  },
+  destroyed() {
+    Bus.$off('fileAdded');
+    Bus.$off('fileSuccess');
+  },
   methods: {
+    addDemo(){
+      // 打开文件选择框
+      Bus.$emit('openUploader', {
+        id: '1111'  // 传入的参数
+      })
+    },
     // 以下是模型文件夹
 
     // 打开模型文件夹