Browse Source

Merge branch 'dev' of http://39.106.8.246:3003/web/ibms into dev

shaun-sheep 5 years ago
parent
commit
28b6018704

+ 1 - 0
config/index.js

@@ -90,6 +90,7 @@ module.exports = {
             },
             '/modelapi': {
                 target: 'http://192.168.20.225:8082',
+                // target: 'http://192.168.20.218:8082',//景灏
                 changeOrigin: true,
                 pathRewrite: {
                     "^/modelapi": "/"

+ 2 - 0
package.json

@@ -63,11 +63,13 @@
         "sass-loader": "^7.1.0",
         "semver": "^5.3.0",
         "shelljs": "^0.7.6",
+        "spark-md5": "^3.0.0",
         "stompjs": "^2.3.3",
         "swiper": "^4.0.0",
         "uglifyjs-webpack-plugin": "^1.1.1",
         "url-loader": "^0.5.8",
         "vue-loader": "^13.3.0",
+        "vue-simple-uploader": "^0.7.2",
         "vue-style-loader": "^3.0.1",
         "vue-template-compiler": "^2.5.2",
         "webpack": "^3.6.0",

+ 7 - 1
src/App.vue

@@ -1,11 +1,17 @@
 <template>
     <div id='app'>
         <router-view/>
+        <global-uploader></global-uploader>
     </div>
 </template>
 
 <script>
+import globalUploader from '@/components/globaluploader'
+
 export default {
-    name: 'App'
+    name: 'App',
+    components: {
+        globalUploader
+    },
 }
 </script>

+ 148 - 138
src/api/model/file.js

@@ -102,87 +102,87 @@ let api = {
         return httputils.postJson(`${baseUrl}/model-floor/query`, params, success)
     },
     // 创建楼层
-    createFloor(params) {
-        // 判断该楼层是否存在
+    // createFloor(params) {
+    //     // 判断该楼层是否存在
 
-        let data = {
-            Content: [{
-                FolderId: params.FolderId,
-                FloorName: params.FloorName,
-                ProjectId: params.ProjectId,      //项目id
-            }]
-        };
-        return new Promise((resolve, preject) => {
-            this.queryFloorItem(params, (res) => {
-                if (res.Total == 0) {
-                    // 创建楼层
-                    httputils.postJson(`${baseUrl}/model-floor/create`, data, (res) => {
-                        let modelFile = {
-                            Content: [{
-                                // ProjectId: params.ProjectId,      //项目id
-                                FloorModelId: res.EntityList[0].Id, //模型所属楼层(FloorModel外键)
-                                ModelName: params.Form.file.name,        //模型文件名
-                                UserName: params.userName,
-                                UserId: params.userId,
-                                Note: params.Form.desc
-                                // ReplaceReason: 0
-                            }]
-                        }
-                        //创建模型文件
-                        this.createModelFile(modelFile, (createModelRes) => {
-                            // 与此楼文件进行绑定
-                            let upDateModelData = {
-                                Content: [{
-                                    Id: res.EntityList[0].Id, //id
-                                    CurrentModelId: createModelRes.EntityList[0].Id //该楼层当前的模型id
-                                }]
-                            }
-                            this.updateFloorName(upDateModelData, (upDateModelSucess) => {
-                                if (upDateModelSucess.Result == "success") {
-                                    resolve({
-                                        Result: 'success',
-                                        FloorModelId: res.EntityList[0].Id,   //楼层模型文件
-                                        CurrentModelId: createModelRes.EntityList[0].Id //模型文件id
-                                    })
-                                }
-                            })
-                        })
-                    })
-                } else {
-                    let modelFile = {
-                        Content: [{
-                            // ProjectId: params.ProjectId,      //项目id
-                            FloorModelId: res.Content[0].Id, //模型所属楼层(FloorModel外键)
-                            ModelName: params.Form.file.name,        //模型文件名
-                            UserName: params.userName,
-                            UserId: params.userId,
-                            Note: params.Form.desc
-                            // ReplaceReason: 0
-                        }]
-                    }
-                    //创建模型文件
-                    this.createModelFile(modelFile, (createModelRes) => {
-                        // 与此楼文件进行绑定
-                        let upDateModelData = {
-                            Content: [{
-                                Id: res.Content[0].Id, //id
-                                CurrentModelId: createModelRes.EntityList[0].Id //该楼层当前的模型id
-                            }]
-                        }
-                        this.updateFloorName(upDateModelData, (upDateModelSucess) => {
-                            if (upDateModelSucess.Result == "success") {
-                                resolve({
-                                    Result: 'success',
-                                    FloorModelId: res.Content[0].Id,   //楼层模型文件
-                                    CurrentModelId: createModelRes.EntityList[0].Id //模型文件id
-                                })
-                            }
-                        })
-                    })
-                }
-            })
-        })
-    },
+    //     let data = {
+    //         Content: [{
+    //             FolderId: params.FolderId,
+    //             FloorName: params.FloorName,
+    //             ProjectId: params.ProjectId,      //项目id
+    //         }]
+    //     };
+    //     return new Promise((resolve, preject) => {
+    //         this.queryFloorItem(params, (res) => {
+    //             if (res.Total == 0) {
+    //                 // 创建楼层
+    //                 httputils.postJson(`${baseUrl}/model-floor/create`, data, (res) => {
+    //                     let modelFile = {
+    //                         Content: [{
+    //                             // ProjectId: params.ProjectId,      //项目id
+    //                             FloorModelId: res.EntityList[0].Id, //模型所属楼层(FloorModel外键)
+    //                             ModelName: params.Form.file.name,        //模型文件名
+    //                             UserName: params.userName,
+    //                             UserId: params.userId,
+    //                             Note: params.Form.desc
+    //                             // ReplaceReason: 0
+    //                         }]
+    //                     }
+    //                     //创建模型文件
+    //                     this.createModelFile(modelFile, (createModelRes) => {
+    //                         // 与此楼文件进行绑定
+    //                         let upDateModelData = {
+    //                             Content: [{
+    //                                 Id: res.EntityList[0].Id, //id
+    //                                 CurrentModelId: createModelRes.EntityList[0].Id //该楼层当前的模型id
+    //                             }]
+    //                         }
+    //                         this.updateFloorName(upDateModelData, (upDateModelSucess) => {
+    //                             if (upDateModelSucess.Result == "success") {
+    //                                 resolve({
+    //                                     Result: 'success',
+    //                                     FloorModelId: res.EntityList[0].Id,   //楼层模型文件
+    //                                     CurrentModelId: createModelRes.EntityList[0].Id //模型文件id
+    //                                 })
+    //                             }
+    //                         })
+    //                     })
+    //                 })
+    //             } else {
+    //                 let modelFile = {
+    //                     Content: [{
+    //                         // ProjectId: params.ProjectId,      //项目id
+    //                         FloorModelId: res.Content[0].Id, //模型所属楼层(FloorModel外键)
+    //                         ModelName: params.Form.file.name,        //模型文件名
+    //                         UserName: params.userName,
+    //                         UserId: params.userId,
+    //                         Note: params.Form.desc
+    //                         // ReplaceReason: 0
+    //                     }]
+    //                 }
+    //                 //创建模型文件
+    //                 this.createModelFile(modelFile, (createModelRes) => {
+    //                     // 与此楼文件进行绑定
+    //                     let upDateModelData = {
+    //                         Content: [{
+    //                             Id: res.Content[0].Id, //id
+    //                             CurrentModelId: createModelRes.EntityList[0].Id //该楼层当前的模型id
+    //                         }]
+    //                     }
+    //                     this.updateFloorName(upDateModelData, (upDateModelSucess) => {
+    //                         if (upDateModelSucess.Result == "success") {
+    //                             resolve({
+    //                                 Result: 'success',
+    //                                 FloorModelId: res.Content[0].Id,   //楼层模型文件
+    //                                 CurrentModelId: createModelRes.EntityList[0].Id //模型文件id
+    //                             })
+    //                         }
+    //                     })
+    //                 })
+    //             }
+    //         })
+    //     })
+    // },
     // 删除楼层文件
     deleteFloor(data) {
         return httputils.postJson(`${baseUrl}/model-floor/delete`, data)
@@ -223,67 +223,77 @@ let api = {
         return httputils.postJson(`${baseUrl}/model-file/query`, params, success)
     },
     // 上传模型文件
-    uploadModelFile(payload, ProjectId,callback1, callback2) {
-        axios({
-            url: baseUrl + '/model-file/upload',
-            method: 'post',
-            headers: {
-                ProjectId: ProjectId
-            },
-            onUploadProgress: function (progressEvent) { //原生获取上传进度的事件
-                if (progressEvent.lengthComputable) {
-                    //属性lengthComputable主要表明总共需要完成的工作量和已经完成的工作是否可以被测量
-                    //如果lengthComputable为false,就获取不到progressEvent.total和progressEvent.loaded
-                    callback1(progressEvent);
-                }
-            },
-            data: payload
-        }).then(res => {
-            callback2(res);
-        }).catch(error => {
-            console.log('this is a catch')
-            console.log(error)
-        })
+    // uploadModelFile(payload, ProjectId,callback1, callback2) {
+    //     axios({
+    //         url: baseUrl + '/model-file/upload',
+    //         method: 'post',
+    //         headers: {
+    //             ProjectId: ProjectId
+    //         },
+    //         onUploadProgress: function (progressEvent) { //原生获取上传进度的事件
+    //             if (progressEvent.lengthComputable) {
+    //                 //属性lengthComputable主要表明总共需要完成的工作量和已经完成的工作是否可以被测量
+    //                 //如果lengthComputable为false,就获取不到progressEvent.total和progressEvent.loaded
+    //                 callback1(progressEvent);
+    //             }
+    //         },
+    //         data: payload
+    //     }).then(res => {
+    //         callback2(res);
+    //     }).catch(error => {
+    //         console.log('this is a catch')
+    //         console.log(error)
+    //     })
+    // },
+
+    //准备分片上传模型文件接口
+    modelFileUpload(data, success) {
+        return httputils.postJson(`${baseUrl}/model-file/upload`, data, success)
     },
-    // 更新模型文件
-    upDateModelFile(data, ProjectId, UserName, UserId, callback1, callback2) {
-        let modelFile = {
-            Content: [{
-                FloorModelId:data.replaceModelItem.Id, //模型id
-                ModelName: data.Form.file.name,        //模型名字
-                UserName: UserName,
-                UserId: UserId,
-                Note: data.replaceModelItem.Note,
-                ReplaceReason: data.Form.ReplaceReason
-            }]
-        }
-        // //创建模型文件
-        this.createModelFile(modelFile, (createModelRes) => {
-            // 与此楼文件进行绑定
-            let upDateModelData = {
-                Content: [{
-                    Id:data.replaceModelItem.Id, //楼层
-                    CurrentModelId: createModelRes.EntityList[0].Id
-                }]
-            }
-            this.updateFloorName(upDateModelData, (upDateModelSucess) => {
-                if (upDateModelSucess.Result == "success") {
-                    // 处理数据
-                    let formData = new FormData();
-                    formData.append(
-                      "model",
-                      JSON.stringify({
-                        FloorModelId: data.replaceModelItem.Id,
-                        Id:createModelRes.EntityList[0].Id
-                      })
-                    );
-                    formData.append("file", data.Form.file.raw);
-                    this.uploadModelFile(formData,ProjectId,callback1,callback2)
-                }
-            })
-        })
+
+    mergeModelFile(data, success) {
+        return httputils.postJson(`${baseUrl}/model-file/merge`, data, success)
     }
 
+    // 更新模型文件
+    // upDateModelFile(data, ProjectId, UserName, UserId, callback1, callback2) {
+    //     let modelFile = {
+    //         Content: [{
+    //             FloorModelId:data.replaceModelItem.Id, //模型id
+    //             ModelName: data.Form.file.name,        //模型名字
+    //             UserName: UserName,
+    //             UserId: UserId,
+    //             Note: data.replaceModelItem.Note,
+    //             ReplaceReason: data.Form.ReplaceReason
+    //         }]
+    //     }
+    //     // //创建模型文件
+    //     this.createModelFile(modelFile, (createModelRes) => {
+    //         // 与此楼文件进行绑定
+    //         let upDateModelData = {
+    //             Content: [{
+    //                 Id:data.replaceModelItem.Id, //楼层
+    //                 CurrentModelId: createModelRes.EntityList[0].Id
+    //             }]
+    //         }
+    //         this.updateFloorName(upDateModelData, (upDateModelSucess) => {
+    //             if (upDateModelSucess.Result == "success") {
+    //                 // 处理数据
+    //                 let formData = new FormData();
+    //                 formData.append(
+    //                   "model",
+    //                   JSON.stringify({
+    //                     FloorModelId: data.replaceModelItem.Id,
+    //                     Id:createModelRes.EntityList[0].Id
+    //                   })
+    //                 );
+    //                 formData.append("file", data.Form.file.raw);
+    //                 this.uploadModelFile(formData,ProjectId,callback1,callback2)
+    //             }
+    //         })
+    //     })
+    // }
+
 }
 export default api
 

+ 30 - 0
src/api/uploader/index.js

@@ -0,0 +1,30 @@
+import http from '../scan/httpUtil'
+
+const baseUrl = '/image-service'
+
+//分片上传文件接口
+
+/**
+ * info: 申请分片上传接口(获取上传UploadId)
+ * @param {systemId:string} param 系统的名称
+ * @param {secret:string} param 系统的密码
+ * @param {key:string} param  成功的回上传的文件名(可以包含文件路径)
+ * @param {overwrite:boolean} param 表示是否覆盖已有的文件(如果存在) 注:overwrite有一定风险, 只在注册分片时校验, 合并时候如果key被占用, 会覆盖掉之前文件
+ * 
+ */
+export function getUploadId(param, success) {
+  let url = ` ${baseUrl}/common/register_multipart_upload?systemId=${param.systemId}&secret=${param.secret}&key=${param.key}&overwrite=${param.overwrite}`
+  http.postJson(url, {}, success)
+}
+
+/**
+ * info: 合并分片的接口
+ * @param {systemId:string} param 系统的名称
+ * @param {secret:string} param 系统的密码
+ * @param {uploadId:string} param  需要合并的上传文件的uploadId
+ * 
+ */
+export function mergeMultipart(param, success) {
+  let url = ` ${baseUrl}/common/merge_multipart?systemId=${param.systemId}&secret=${param.secret}&uploadId=${param.uploadId}`
+  http.postJson(url, {}, success)
+}

BIN
src/assets/house.jpg


+ 483 - 0
src/components/globaluploader/index.vue

@@ -0,0 +1,483 @@
+<!--
+ * @Author: zhangyu
+ * @Date: 2019-11-28 10:05:28
+ * @Info: 
+ * @LastEditTime: 2019-11-30 18:28:18
+ -->
+<template>
+  <div id="global-uploader">
+
+    <!-- 上传 -->
+    <uploader
+        ref="uploader"
+        :options="options"
+        :autoStart="false"
+        @file-added="onFileAdded"
+        @file-success="onFileSuccess"
+        @file-progress="onFileProgress"
+        @file-error="onFileError"
+        class="uploader-app">
+      <uploader-unsupport></uploader-unsupport>
+
+      <uploader-btn id="global-uploader-btn" :attrs="attrs" ref="uploadBtn">选择文件</uploader-btn>
+
+      <uploader-list v-show="panelShow">
+        <div class="file-panel" slot-scope="props" :class="{'collapse': collapse}">
+          <div class="file-title">
+            <h2>文件列表</h2>
+            <div class="operate">
+              <el-button @click="fileListShow" style="color:#999;" type="text" :title="collapse ? '展开':'折叠' ">
+                <i class="iconfont" :class="collapse ? 'icon-shenglvehao': 'icon-shenglvehao'"></i>
+              </el-button>
+              <el-button @click="close" style="color:#999;" type="text" title="关闭">
+                <i class="iconfont icon-guanbi"></i>
+              </el-button>
+            </div>
+          </div>
+
+          <ul class="file-list" v-show="collapse">
+            <el-scrollbar style="height:100%;">
+              <li v-for="file in props.fileList" :key="file.id">
+                <uploader-file :class="'file_' + file.id" ref="files" :file="file" :list="true"></uploader-file>
+              </li>
+              <div class="no-file" v-if="!props.fileList.length"><i class="iconfont icon-wushuju"></i> 暂无待上传文件</div>
+            </el-scrollbar>
+          </ul>
+        </div>
+      </uploader-list>
+
+    </uploader>
+
+  </div>
+</template>
+
+<script>
+/**
+ *   全局上传插件
+ *   调用方法:Bus.$emit('openUploader', {}) 打开文件选择框,参数为需要传递的额外参数
+ *   监听函数:Bus.$on('fileAdded', fn); 文件选择后的回调
+ *            Bus.$on('fileSuccess', fn); 文件上传成功的回调
+ */
+
+import Bus from '@/utils/bus.js';
+import SparkMD5 from 'spark-md5';
+import { getUploadId, mergeMultipart } from '@/api/uploader';
+import request from "@/api/model/file.js";
+
+export default {
+  data() {
+    return {
+      options: {
+        target: '/image-service/common/multipart_upload',
+        chunkSize: 1*1024*1024,
+        fileParameterName: 'file',
+        maxChunkRetries: 5,
+        testChunks: false,   //是否开启服务器分片校验
+        // 服务器分片校验函数,秒传及断点续传基础
+        // checkChunkUploadedByResponse: function (chunk, message) {
+        //   let objMessage = JSON.parse(message);
+        //   if (objMessage.skipUpload) {
+        //     return true;
+        //   }
+
+        //   return (objMessage.uploaded || []).indexOf(chunk.offset + 1) >= 0
+        // },
+        // headers: {
+          // Authorization: Ticket.get() && "Bearer " + Ticket.get().access_token
+        // },
+        query: this.getFileQuery
+      },
+      attrs: {
+        // accept: ACCEPT_CONFIG.getAll()
+      },
+      panelShow: false,   //选择文件后,展示上传panel
+      collapse: false,
+    }
+  },   
+  mounted() {
+    Bus.$on('openUploader', (query, file) => {
+      if(query.uploadId){
+        // this.params = query || {};
+        file.uploadId = query.uploadId
+        file.modelId = query.modelId? query.modelId: ''
+        this.uploader.addFile(file)
+      } else {
+        getUploadId({
+          systemId: query.systemId?query.systemId:'revit', 
+          secret: query.secret?query.secret:'63afbef6906c342b', 
+          overwrite: query.overwrite? query.overwrite: false,
+          key: file.name
+        }, res => {
+          if(res.UploadId){
+            // this.params = Object.assign(query, { uploadId: res.UploadId }) || {};
+            file = Object.assign(file, {
+              ...query,
+              uploadId: res.UploadId 
+            })
+            this.uploader.addFile(file)
+          } else {
+            this.$message.error(`请求分片上传接口失败!`);
+          }
+        })
+      }
+
+      // if (this.$refs.uploadBtn) {
+      //   document.getElementById('global-uploader-btn').click();
+      //   // $('#global-uploader-btn').click();
+      // }
+    });
+  },
+  computed: {
+    //Uploader实例
+    uploader() {
+      return this.$refs.uploader.uploader;
+    }
+  },
+  methods: {
+    onFileAdded(file) {
+      this.panelShow = true;
+      this.collapse = true;
+      this.computeMD5(file);
+
+      Bus.$emit('fileAdded');
+    },
+    onFileProgress(rootFile, file, chunk) {
+      console.log(`上传中 ${file.name},chunk:${chunk.startByte / 1024 / 1024} ~ ${chunk.endByte / 1024 / 1024}`)
+    },
+    onFileSuccess(rootFile, file, response, chunk) {
+      let res = JSON.parse(response);
+
+      // 服务器自定义的错误(即虽返回200,但是是错误的情况),这种错误是Uploader无法拦截的
+      if (!res.Result || res.Result != 'success') {
+        this.$message({ message: res.ResultMsg?res.ResultMsg:'上传失败!', type: 'error' });
+        // 文件状态设为“失败”
+        this.statusSet(file.id, 'failed');
+        return
+      }
+      // 如果服务端返回需要合并
+      console.log('获取分片数',file.chunks.length)
+      if (parseInt(res.TotalCount) >= file.chunks.length) {
+        // 文件状态设为“合并中”
+        this.statusSet(file.id, 'merging');
+        if(file.file.modelId){
+          //模型文件合并专用接口
+          request.mergeModelFile({ ModelId: file.file.modelId, UploadId: file.file.uploadId }, res => {
+            Bus.$emit('modelStatusChange')
+            // 文件合并成功
+            Bus.$emit('fileSuccess');
+            this.statusRemove(file.id);
+          })
+        } else {
+          mergeMultipart({
+            systemId: file.file.systemId?file.file.systemId:'revit', 
+            secret: file.file.secret?file.file.secret:'63afbef6906c342b', 
+            uploadId: file.file.uploadId
+          }, res => {
+            // 文件合并成功
+            Bus.$emit('fileSuccess');
+            this.statusRemove(file.id);
+          })
+        }
+
+      // 不需要合并
+      } else {
+        Bus.$emit('fileSuccess');
+        console.log('上传成功');
+      }
+    },
+    onFileError(rootFile, file, response, chunk) {
+      this.$message({
+        message: response,
+        type: 'error'
+      })
+    },
+
+    /**
+     * 计算md5,实现断点续传及秒传
+     * @param file
+     */
+    computeMD5(file) {
+      let fileReader = new FileReader();
+      let time = new Date().getTime();
+      let blobSlice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice;
+      let currentChunk = 0;
+      const chunkSize = 1 * 1024 * 1024;
+      let chunks = Math.floor(file.size / chunkSize);
+      let spark = new SparkMD5.ArrayBuffer();
+
+      // 文件状态设为"计算MD5"
+      this.statusSet(file.id, 'md5');
+      file.pause();
+
+      loadNext();
+
+      fileReader.onload = (e => {
+        spark.append(e.target.result);
+
+        if (currentChunk < chunks) {
+          currentChunk++;
+          loadNext();
+
+          // 实时展示MD5的计算进度
+          this.$nextTick(() => {
+            document.getElementsByClassName(`myStatus_${file.id}`)[0].innerText = '校验MD5 '+ ((currentChunk/chunks)*100).toFixed(0)+'%'
+            // $(`.myStatus_${file.id}`).text('校验MD5 '+ ((currentChunk/chunks)*100).toFixed(0)+'%')
+          })
+        } else {
+          let md5 = spark.end();
+          file.file.md5 = md5;
+          this.computeMD5Success(md5, file);
+          console.log(`MD5计算完毕:${file.name} \nMD5:${md5} \n分片:${chunks} 大小:${file.size} 用时:${new Date().getTime() - time} ms`);
+        }
+      });
+
+      fileReader.onerror = function () {
+        this.error(`文件${file.name}读取出错,请检查该文件`)
+        file.cancel();
+      };
+
+      function loadNext() {
+        let start = currentChunk * chunkSize;
+        let end = ((start + chunkSize) >= file.size) ? file.size : start + chunkSize;
+
+        fileReader.readAsArrayBuffer(blobSlice.call(file.file, start, end));
+      }
+    },
+
+    computeMD5Success(md5, file) {
+      // 将自定义参数直接加载uploader实例的opts上
+      console.log(this.uploader)
+      // Object.assign(this.uploader.opts, {
+      //   query: {
+      //     uploadId: file.file.uploadId,
+      //     md5
+      //   }
+      // })
+
+      // file.uniqueIdentifier = this.params.uploadId;
+      file.resume();
+      this.statusRemove(file.id);
+    },
+
+    //获取文件参数
+    getFileQuery(file, chunk) {
+      return {
+        uploadId: file.file.uploadId,
+        md5: file.file.md5
+      }
+    },
+
+    fileListShow() {
+      this.collapse = this.collapse? false: true;
+
+      // let $list = $('#global-uploader .file-list');
+      // let $list = document.querySelector('#global-uploader .file-list')
+
+      // if ($list.style.display == '' && $list.style.display == 'none') {
+      //   $list.style.display == 'block';//显示
+      //   this.collapse = false;
+      //   // $list.slideUp();//隐藏
+      //   // this.collapse = true;
+      // } else {
+      //   $list.style.display == 'none';//隐藏
+      //   this.collapse = true;
+      //   // $list.slideDown();//显示
+      //   // this.collapse = false;
+      // }
+    },
+    close() {
+      if(this.uploader.isUploading()) {
+        this.$alert(
+          "您有文件正在上传,关闭会中断上传,是否继续?",
+          "提示",
+          {
+            confirmButtonText: "确定",
+            callback: action => {
+              console.log(action);
+              if (action == "confirm") {
+                this.uploader.cancel();
+                this.panelShow = false;
+                Bus.$emit('modelStatusChange')
+              } else { }
+            }
+          }
+        );
+      } else {
+        this.uploader.cancel();
+        this.panelShow = false;
+      }
+    },
+
+    /**
+     * 新增的自定义的状态: 'md5'、'transcoding'、'failed'
+     * @param id
+     * @param status
+     */
+    statusSet(id, status) {
+      let statusMap = {
+        md5: {
+          text: '校验MD5',
+          bgc: '#fff'
+        },
+        merging: {
+          text: '合并中',
+          bgc: '#e2eeff'
+        },
+        transcoding: {
+          text: '转码中',
+          bgc: '#e2eeff'
+        },
+        failed: {
+          text: '上传失败',
+          bgc: '#e2eeff'
+        }
+      }
+
+      this.$nextTick(() => {
+        let node = document.createElement("P");
+        let att = document.createAttribute("class");
+        att.value = `status_style myStatus_${id}`;
+        let text = document.createTextNode(`${statusMap[status].text}`);
+	      node.appendChild(text);
+        node.setAttributeNode(att);
+        node.style.backgroundColor = `${statusMap[status].bgc}`
+        document.querySelector(`.file_${id} .uploader-file-status`).appendChild(node);
+
+        // $(`<p class="myStatus_${id}"></p>`).appendTo(`.file_${id} .uploader-file-status`).css({
+        //   'position': 'absolute',
+        //   'top': '0',
+        //   'left': '0',
+        //   'right': '0',
+        //   'bottom': '0',
+        //   'zIndex': '1',
+        //   'backgroundColor': statusMap[status].bgc
+        // }).text(statusMap[status].text);
+      })
+    },
+    statusRemove(id) {
+      this.$nextTick(() => {
+        let dom = document.getElementsByClassName(`myStatus_${id}`)[0];
+        dom.parentNode.removeChild(dom);
+      })
+    },
+
+    error(msg) {
+      this.$notify({
+        title: '错误',
+        message: msg,
+        type: 'error',
+        duration: 2000
+      })
+    }
+  },
+  watch: {},
+  destroyed() {
+    Bus.$off('openUploader');
+  },
+  components: {}
+}
+</script>
+
+<style scoped lang="scss">
+#global-uploader {
+  position: fixed;
+  z-index: 20;
+  top: auto;
+  right: 15px;
+  bottom: 0;
+
+  .uploader-app {
+    width: 633px;
+  }
+
+  .file-panel {
+    background-color: #fff;
+    border: 1px solid #e2e2e2;
+    border-radius: 7px 7px 0 0;
+    box-shadow: 0 0 10px rgba(0, 0, 0, .2);
+
+    .file-title {
+      display: flex;
+      height: 40px;
+      line-height: 40px;
+      padding: 0 15px;
+      border-bottom: 1px solid #ddd;
+      h2{
+        font-size: 14px;
+        font-style: normal;
+        cursor: text;
+        font-weight: 200;
+        color: #666;
+      }
+
+      .operate {
+        flex: 1;
+        text-align: right;
+      }
+    }
+
+    .file-list {
+      position: relative;
+      height: 350px;
+      overflow-x: hidden;
+      overflow-y: auto;
+      background-color: #fff;
+      /deep/ .el-scrollbar__wrap{
+        overflow-x: hidden;
+      }
+
+      > li {
+        background-color: #fff;
+      }
+      /deep/ .status_style{
+        position: absolute;
+        top: 0;
+        left: 0;
+        right: 0;
+        bottom: 0;
+        z-index: 1;
+      }
+    }
+
+    // &.collapse {
+    //   .file-title {
+    //     background-color: #E7ECF2;
+    //   }
+    // }
+  }
+
+  .no-file {
+    position: absolute;
+    top: 50%;
+    left: 50%;
+    transform: translate(-50%, -50%);
+    font-size: 16px;
+    text-align: center;
+  }
+
+  /deep/.uploader-file-icon {
+    &:before {
+      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);
+    // }
+  }
+
+  /deep/ .uploader-file-actions > span {
+    margin-right: 6px;
+  }
+}
+/* 隐藏上传按钮 */
+#global-uploader-btn {
+  position: absolute;
+  clip: rect(0, 0, 0, 0);
+}
+</style>

+ 17 - 16
src/components/model/file/addFloorDialog.vue

@@ -158,24 +158,25 @@ export default {
           this.$message.error('该楼层名称已存在,请勿重复创建!');
         } else {
           let data = {
-            ProjectId: this.projectId,
-            FolderId: this.FolderId,
+            FileName: this.form.file.name,
             FloorName: FloorName,
-            Form: this.form,
-            userName: this.userInfo.userName,
-            userId: this.userInfo.userId
+            FolderId: this.FolderId,
+            Note: this.form.desc,
+            ProjectId: this.projectId,
+            ReplaceReason: null,
+            Size: this.form.file.size,
+            UserName: this.userInfo.userName,
+            UserId: this.userInfo.userId
           };
-          request.createFloor(data).then(res => {
-            if (res.Result == "success") {
-              //  创建成功
-              this.$emit("finishCreateFloor", {
-                FloorModelId: res.FloorModelId,
-                CurrentModelId:res.CurrentModelId,
-                Form: this.form
-              });
-              this.handleClose();
-              // this.submitUpload(res.FloorModelId);
-            }
+          request.modelFileUpload(data, res => {
+            //  创建成功
+            this.$emit("finishCreateFloor", {
+              modelId: res.ModelId,
+              uploadId: res.UploadId,
+              floorId: res.floorId, 
+              file: this.form.file
+            });
+            this.handleClose();
           });
         }
       }

+ 0 - 7
src/components/model/file/floorTable.vue

@@ -28,13 +28,6 @@
                 :color="scope.row.Status == 1 || scope.row.Status == 10 || scope.row.Status == 11?'#909399':'#67C23A'"></el-progress>
             </div>
             <div class="progress-right">
-              <!-- <el-button
-              v-show="!scope.row.Status"
-              type="danger"
-              class="iconfont icon-termination"
-              @click="closeUpdate(scope.row)"
-              circle
-            ></el-button>-->
               <span v-show="!scope.row.Status && scope.row.precent == 100">上传中</span>
               <span v-show="scope.row.Status == 1">等待检查...</span>
               <span v-show="scope.row.Status == 10">模型检查中</span>

+ 1 - 1
src/components/model/file/replaceModelDialog.vue

@@ -72,7 +72,7 @@ export default {
         this.$message.error("模型文件不能为空!");
       } else {
         this.$emit("updataModel", {
-          Form: this.form,
+          file: this.form.file,
           replaceModelItem: this.replaceModelItem
         });
         this.handleClose();

+ 2 - 0
src/main.js

@@ -7,8 +7,10 @@ import store from './store'
 import 'element-ui/lib/theme-chalk/base.css';
 import CollapseTransition from 'element-ui/lib/transitions/collapse-transition';
 import ElementUI from 'element-ui'
+import uploader from 'vue-simple-uploader'
 import 'element-ui/lib/theme-chalk/index.css'
 import './framework/style/awesome.less'
+Vue.use(uploader)
 Vue.use(ElementUI, { size: "small", zIndex: 1000 })
 
 Vue.component(CollapseTransition.name, CollapseTransition)

+ 1 - 0
src/views/data_admin/buildGraphy/locationPointMsg.vue

@@ -52,6 +52,7 @@ export default {
     clearImg(){
       this.choImg = [];
       this.isIndeterminate = false;
+      this.checkAll = false;
     }
   }
 }

+ 55 - 248
src/views/model/file/index.vue

@@ -46,7 +46,7 @@
         </div>
         <!-- 列表 -->
         <floorTable ref="floorTable" :tableData="tableData" :modelFolderName="currentFolderName" @openModelLog="queryModelLog"
-          @replaceModel="repliaceModel" @closeUpdateFile="removePersentList" @percentFinish="queryFloorFile(currentFolderId)"
+          @replaceModel="repliaceModel" @percentFinish="queryFloorFile(currentFolderId)"
           :persentList="persentList"></floorTable>
       </el-card>
     </el-col>
@@ -82,29 +82,6 @@ import addFolder from "@/components/model/file/addFolder"; //新增文件夹
 import changeFolderName from "@/components/model/file/changeFolderName"; //编辑名字
 import floorTable from "@/components/model/file/floorTable"; //右侧list表
 export default {
-  // 离开此页面前要判断是是否有下载
-  beforeRouteLeave: function (to, from, next) {
-    console.log(this.uploadClassList);
-    if (this.uploadClassList.length) {
-      this.$alert(
-        "您有正在上传的模型文件,切换菜单会中断上传,是否继续?",
-        "提示",
-        {
-          confirmButtonText: "确定",
-          callback: action => {
-            console.log(action);
-            if (action == "confirm") {
-              next();
-            } else {
-              next(false);
-            }
-          }
-        }
-      );
-    } else {
-      next();
-    }
-  },
   computed: {
     ...mapGetters("layout", ["projectId", "userInfo", "userId", "secret"])
   },
@@ -147,17 +124,23 @@ export default {
         model: {}
       },
       persentList: [], //请求进度列表
-      uploadClassList: [], //请求list 用与缓存多个请求问题
       isJump: true //是否可以调整页面
     };
   },
-  // mounted() {
-  //   window.addEventListener('beforeunload', e => {
-  //     if (this.uploadClassList.length) {
-  //       window.localStorage.removeItem("当前页有下载内容,关闭或刷新页面下载将会失败。您确定要继续吗?")
-  //     }
-  //   })
-  // },
+  mounted() {
+    // // 文件选择后的回调
+    // Bus.$on('fileAdded', () => {
+    //   console.log('文件已选择')
+    // });
+    // // 文件上传成功的回调
+    // Bus.$on('fileSuccess', () => {
+    //   console.log('文件上传成功')
+    // });
+  },
+  destroyed() {
+    // Bus.$off('fileAdded');
+    // Bus.$off('fileSuccess');
+  },
   methods: {
     // 以下是模型文件夹
 
@@ -281,202 +264,54 @@ export default {
     },
     // 上传模型文件
     uploadModelFIle(data) {
+      Bus.$emit('openUploader', { 
+        uploadId: data.uploadId, 
+        modelId: data.modelId,
+        systemId: 'revit', //系统名称
+        secret: '63afbef6906c342b', //系统密码
+      }, data.file.raw)
       // 在列表中添加
       this.persentList.push({
-        Id: data.FloorModelId,
+        Id: data.floorId,
         precent: 0
       });
-      let uploadClass = this.uploadClass();
-      this.uploadClassList.push({
-        obj: new uploadClass(data),
-        Id: data.FloorModelId
-      });
-    },
-    // 上传文件的类
-    uploadClass() {
-      let that = this;
-      return class {
-        constructor(data) {
-          this.upload(data);
-        }
-        upload(data) {
-          that.queryFloorFile(that.currentFolderId).then(() => {
-            // 开始上传文件
-            // 开始处理数据
-            let formData = new FormData();
-            formData.append(
-              "model",
-              JSON.stringify({
-                FloorModelId: data.FloorModelId,
-                Id: data.CurrentModelId
-              })
-            );
-            formData.append("file", data.Form.file.raw);
-            // 处理数据结束
-
-            // 修改isdown得值
-            that.tableData.map(item => {
-              if (item.Id == data.FloorModelId) {
-                item.isDown = true;
-                item.precent = 0;
-              }
-            });
-
-            // 开始上传
-            request.uploadModelFile(
-              formData,
-              that.projectId,
-              res => {
-                let loaded = res.loaded, //加载量
-                  total = res.total; //文件大小
-                that.$nextTick(() => {
-                  let precent = Math.round((loaded / total) * 100);
-                  // this.$refs.floorTable.filterTag(data.FloorModelId, precent);
-                  if (that.persentList.length != 0) {
-                    that.persentList.map(item => {
-                      if (item.Id == data.FloorModelId) {
-                        item.precent = precent;
-                      }
-                    });
-                  }
-                });
-              },
-              val => {
-                if (val.data.Result === "success") {
-                  if (that.persentList.length != 0) {
-                    //深拷贝
-                    let persentListCopy = JSON.parse(JSON.stringify(that.persentList))
-                    persentListCopy.forEach((item, index) => {
-                      if (item.Id == data.FloorModelId) {
-                        // item.precent = 101;
-                        that.persentList.splice(index, 1);
-                        that.uploadClassList.splice(index, 1);
-                        return;
-                      }
-                    });
-                  }
-                  that.$message({ message: "文件上传成功", type: "success" });
-                  //  刷新list列表
-                  that.queryFloorFile(that.currentFolderId);
-                } else {
-                  if (that.persentList.length != 0) {
-                    //深拷贝
-                    let persentListCopy = JSON.parse(JSON.stringify(that.persentList))
-                    persentListCopy.forEach((item, index) => {
-                      if (item.Id == data.FloorModelId) {
-                        // item.precent = 101;
-                        that.persentList.splice(index, 1);
-                        that.uploadClassList.splice(index, 1);
-                        return;
-                      }
-                    });
-                  }
-                  that.$message({
-                    message: val.data.Message,
-                    type: "error"
-                  });
-                  //  刷新list列表
-                  that.queryFloorFile(that.currentFolderId);
-                }
-              }
-            );
-          });
-        }
-      };
+      this.queryFloorFile(this.currentFolderId);
     },
     //更新模型文件;
     updateModelFile(data) {
-      this.persentList.push({
-        Id: data.replaceModelItem.Id,
-        precent: 0
-      });
-      // 修改isdown得值
-      this.tableData.map(item => {
-        if (item.Id == data.replaceModelItem.Id) {
-          item.isDown = true;
-          item.precent = 0;
-        }
-      });
-      // 开始上传
-      let updataclass = this.updateModelClass();
-      this.uploadClassList.push({
-        obj: new updataclass(data),
-        Id: data.replaceModelItem.Id
-      });
-    },
-    // 更新文件的类
-    updateModelClass() {
-      let that = this;
-      // 开始上传
-      return class {
-        constructor(data) {
-          this.upDateModel(data);
-        }
-        upDateModel(data) {
-          request.upDateModelFile(
-            data,
-            that.projectId,
-            that.userInfo.userName,
-            that.userInfo.userId,
-            res => {
-              let loaded = res.loaded, //加载量
-                total = res.total; //文件大小
-              that.$nextTick(() => {
-                let precent = Math.round((loaded / total) * 100);
-                // this.$refs.floorTable.filterTag(data.FloorModelId, precent);
-                if (that.persentList.length != 0) {
-                  that.persentList.map(item => {
-                    if (item.Id == data.replaceModelItem.Id) {
-                      item.precent = precent;
-                    }
-                  });
-                }
-              });
-            },
-            val => {
-              if (val.data.Result === "success") {
-                if (that.persentList.length != 0) {
-                  //深拷贝
-                  let persentListCopy = JSON.parse(JSON.stringify(that.persentList))
-                  persentListCopy.forEach((item, index) => {
-                    if (item.Id == data.replaceModelItem.Id) {
-                      // item.precent = 101;
-                      that.persentList.splice(index, 1);
-                      that.uploadClassList.splice(index, 1);
-                      return;
-                    }
-                  });
-                }
-                that.$message({
-                  message: "文件上传成功",
-                  type: "success"
-                });
-                //  刷新list列表
-                that.queryFloorFile(that.currentFolderId);
-              } else {
-                if (that.persentList.length != 0) {
-                  //深拷贝
-                  let persentListCopy = JSON.parse(JSON.stringify(that.persentList))
-                  persentListCopy.forEach((item, index) => {
-                    if (item.Id == data.FloorModelId) {
-                      // item.precent = 101;
-                      that.persentList.splice(index, 1);
-                      that.uploadClassList.splice(index, 1);
-                      return;
-                    }
-                  });
-                }
-                that.$message({
-                  message: val.data.Message,
-                  type: "error"
-                });
-                //  刷新list列表
-                that.queryFloorFile(that.currentFolderId);
-              }
-            }
-          );
-        }
+      let params = {
+        FileName: data.file.name,
+        FloorName: data.replaceModelItem.FloorName,
+        FolderId: data.replaceModelItem.FolderId,
+        Note: data.replaceModelItem.Note,
+        ProjectId: this.projectId,
+        ReplaceReason: 0,
+        Size: data.file.size,
+        UserName: this.userInfo.userName,
+        UserId: this.userInfo.userId
       };
+      //  替换模型文件
+      request.modelFileUpload(params, res => {
+        //  上传
+        this.persentList.push({
+          Id: data.replaceModelItem.Id,
+          precent: 0
+        });
+        // 修改isdown得值
+        this.tableData.map(item => {
+          if (item.Id == data.replaceModelItem.Id) {
+            item.isDown = true;
+            item.precent = 0;
+          }
+        });
+        this.queryFloorFile(this.currentFolderId);
+        Bus.$emit('openUploader', { 
+          uploadId: res.uploadId, 
+          modelId: res.modelId,
+          systemId: 'revit', //系统名称
+          secret: '63afbef6906c342b', //系统密码
+        }, data.file.raw)
+      });
     },
     //查看模型日志
     queryModelLog(item) {
@@ -492,36 +327,8 @@ export default {
         this.logData = res.Content;
       });
     },
-    // 删除上传列表item
-    removePersentList(item) {
-      this.uploadClassList.forEach((i, index) => {
-        if (item.Id == i.Id) {
-          // this.$delete(this.uploadClassList, index);
-          this.uploadClassList.splice(index, 1);
-          return;
-        }
-      });
-      this.persentList.forEach((i, index) => {
-        if (item.Id == i.Id) {
-          this.$delete(this.persentList, index);
-          return;
-        }
-      });
-      this.$message({
-        message: "中止上传!",
-        type: "success"
-      });
-      //  刷新list列表
-      that.queryFloorFile(that.currentFolderId);
-    }
   },
   watch: {
-    uploadClassList: {
-      deep: true,
-      handler: function (val) {
-        console.log(val);
-      }
-    },
     projectId() {
       this.queryModel()
     }

+ 23 - 19
src/views/screen/splitscreen/spaceledger/index.vue

@@ -1,11 +1,8 @@
 
 <template>
   <div class="box">
-    <el-container>
+    <el-container style="height:100%">
       <el-header>
-        <div class="boxName">
-          第二屏详情
-        </div>
         <div class="spaceName">
           <b>空间名称:</b>{{spaceDetails.RoomLocalName?spaceDetails.RoomLocalName:"-"}}
         </div>
@@ -24,10 +21,12 @@
                   v-if="spaceDetails.RoomQRCode">
               </div>
             </div>
-            <div v-show="spaceDetails.Outline && spaceDetails.Outline[0] && spaceDetails.Outline[0].length" id="graphy" ref="graphy"
-              style="width:400px;height:400px;" v-loading="canvasLoading">
+            <div>
               <p><b>位置图片:</b></p>
-              <canvas id="floorCanvas" :width="canvasWidth" :height="canvasHeight" ref="canvas" tabindex="0"></canvas>
+              <div v-show="spaceDetails.Outline && spaceDetails.Outline[0] && spaceDetails.Outline[0].length" id="graphy" ref="graphy"
+              style="width:400px;height:400px;" v-loading="canvasLoading">
+                <canvas id="floorCanvas" :width="canvasWidth" :height="canvasHeight" ref="canvas" tabindex="0"></canvas>
+              </div>
             </div>
             <div v-show="spaceDetails.Outline && !spaceDetails.Outline[0] || !spaceDetails.Outline"
               style="height: 400px;transform: translateY(50%);textAlign:center;">
@@ -36,10 +35,12 @@
             </div>
             <div class="space-img" v-if="spaceDetails.Pic">
               <div class="img-box" v-for="(item) in spaceDetails.Pic" :key='`${item.Id}+${item.key}`'>
+                <p><b>空间照片:</b></p>
                 <img :src="`/image-service/common/image_get?systemId=dataPlatform&key=${item.key}`" alt="空间图片">
               </div>
             </div>
-            <!-- <div class="space-img" v-if="!spaceDetails.Pic">
+            <div class="space-img" v-if="!spaceDetails.Pic">
+              <p><b>空间照片:</b></p>
               <div class="img-box">
                 <img src="https://hbimg.huabanimg.com/2787ad434fc2bc819a5d7deda3855d897a99d528ab4a-e3HRgR_fw658" alt="空间图片">
               </div>
@@ -52,7 +53,7 @@
               <div class="img-box">
                 <img src="https://hbimg.huabanimg.com/2ea712954c75ff1b1e13329e7e4209f0691b88945c73-JCmkXX_fw658" alt="空间图片">
               </div>
-            </div> -->
+            </div>
           </el-scrollbar>
         </el-aside>
         <el-main style="height:100%">
@@ -297,12 +298,18 @@ export default {
 </script>
 
 <style lang="less" scoped>
-#screenBox .screen-router[data-v-6c06ede0] {
+.box.screen-router {
   padding: 0;
+  section {
+    .el-container {
+      padding: 0;
+    }
+  }
 }
 .el-header {
   padding: 0;
-  height: 80px !important;
+  height: 30px !important;
+  margin-top: -10px;
   .boxName {
     color: #fff;
     font-size: 16px;
@@ -314,7 +321,6 @@ export default {
   .spaceName {
     font-size: 14px;
     line-height: 30px;
-    margin: 0 10px;
     border-bottom: 1px solid #e4e7ed;
     box-sizing: border-box;
   }
@@ -322,10 +328,10 @@ export default {
 .el-aside {
   color: #333;
   border: 1px solid #e4e7ed;
-  margin: 10px 0 0 10px;
-  padding: 20px;
+  margin-top: 10px;
+  padding: 10px;
   box-sizing: border-box;
-  height: calc(100% - 20px);
+  height: calc(100% - 10px);
   overflow: hidden;
   .el-scrollbar {
     height: 100%;
@@ -373,10 +379,9 @@ export default {
 .el-main {
   color: #333;
   text-align: center;
-  margin: -10px;
-  padding-bottom: 0;
   overflow: hidden;
   width: 100%;
+  padding: 10px 0 0 10px;
 }
 .el-tabs.el-tabs--card.el-tabs--top {
   height: 100% !important;
@@ -402,7 +407,6 @@ export default {
   height: 100%;
 }
 #pane-staticData {
-  height: 750px;
   div {
     height: 100%;
   }
@@ -421,6 +425,6 @@ export default {
   overflow-y: auto !important;
 }
 .el-tabs__content {
-  height: calc(100% - 47px) !important;
+  height: calc(100% - 46px) !important;
 }
 </style>