zhangliang2 3 anni fa
parent
commit
47c6e2bfa7

+ 3 - 1
src/api/algorithmsLibrary.js

@@ -8,6 +8,7 @@ const shareAlgorithm = basePart + '/algorithm/shareAlgorithm'; // 分享算法
 
 const addOrUpdate = basePart + '/algorithm/addOrUpdate'; // 私有算法新增
 const selectDetailsById = basePart + '/algorithm/selectDetailsById'; // 查询算法详情
+const getProgress = basePart + '/file/getProgress'; // 获取上传进度接口
 
 
 export default {
@@ -18,5 +19,6 @@ export default {
     shareAlgorithm,
 
     addOrUpdate,
-    selectDetailsById
+    selectDetailsById,
+    getProgress
 }

+ 50 - 1
src/axios/filter.js

@@ -35,6 +35,7 @@ export function tryHideFullScreenLoading() {
 }
 
 
+
 //axios配置和处理
 Vue.use(VueAxios, axios);
 axios.defaults.baseURL = ''; //项目的的基础url
@@ -67,7 +68,54 @@ axios.interceptors.response.use(function (response) {
             });
         }
         return response.data;
+    }
+    return response;
+}, function (error) {
+    tryHideFullScreenLoading();
+    console.log('网络异常');
+    ElementUI.Message.error("网络异常");
+    return Promise.reject(error);
+});
+
+Vue.prototype.$axios = axios; //定义调用方式
 
+
+
+
+
+// 针对上传大文件
+const instance = axios.create({
+    baseURL: '',
+});
+
+instance.defaults.headers.common['Authorization'] = ""; //请求token信息配置
+instance.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; //请求type设置
+instance.defaults.timeout = 1000 * 60 * 30; //在超时前,所有请求都会等待
+instance.defaults.withCredentials = true;
+
+instance.interceptors.request.use(function (config) {
+    // 在发送请求之前处理
+    // 判断token在前台session中是否存在
+    config.headers.common['Authorization'] = localStorage.getItem('Authorization');
+    showFullScreenLoading();
+    return config;
+}, function (error) {
+    // 对请求错误做处理
+    return Promise.reject(error);
+});
+// 添加响应拦截器
+instance.interceptors.response.use(function (response) {
+    // 对响应数据处理
+    tryHideFullScreenLoading();
+    if (response && (response.status == 200)) {
+        if (response.data.exceptionMes) {
+            ElementUI.MessageBox({
+                type: 'info',
+                title: response.data.exceptionMes,
+                message: '网络错误,请稍后再试!'
+            });
+        }
+        return response.data;
     }
     return response;
 }, function (error) {
@@ -77,4 +125,5 @@ axios.interceptors.response.use(function (response) {
     return Promise.reject(error);
 });
 
-Vue.prototype.$axios = axios; //定义调用方式
+Vue.use(VueAxios, instance);
+Vue.prototype.$instance = instance; //定义调用方式

+ 29 - 1
src/components/upload/upload.vue

@@ -6,6 +6,7 @@
             :on-change="handleChange"
             :on-remove="handleRemove"
             :on-preview="preview"
+            :on-progress="progress"
             :on-success="success"
             :on-error="error"
             :http-request="toUpload"
@@ -38,6 +39,11 @@ export default {
             type: String,
             default: "1",
         },
+        // 是否需要处理大文件上传
+        needInstance: {
+            type: Boolean,
+            default: false,
+        },
     },
     data() {
         return {
@@ -75,7 +81,13 @@ export default {
             this.attachmentList.splice(removeIndex, 1);
             this.$emit("attachmentChange", this.attachmentList);
         },
+        progress(event, file, fileList){
+            console.log(event);
+            console.log(file);
+            console.log(fileList);
+        },
         async toUpload(file) {
+            console.log(file);
             let _this = this;
             // 获取MD5值
             /* await this.$md5(file.file).then((res) => {
@@ -92,7 +104,17 @@ export default {
                 await formData.append("objectPath", this.objectPath);
                 // await formData.append("md5", _this.defaultParam.md5);
                 await formData.append("file", file.file);
-                await this.$axios({
+
+                let axios = this.$axios;
+                // 处理大文件上传
+                if(this.needInstance) {
+                    axios = this.$instance;
+                }
+
+                // 上传前进行通知
+                this.$emit("willUpload");
+
+                await axios({
                     method: "post",
                     url: this.$api.common.uploadWj,
                     data: formData,
@@ -114,9 +136,15 @@ export default {
                             });
                             resolve("成功");
                             this.$emit("attachmentChange", this.attachmentList);
+                            // 上传完成后进行通知
+                            this.$emit("didUpload", "success");
+                        }else {
+                            this.$message.error(res.message || "上传失败");
+                            this.$emit("didUpload", "fail");
                         }
                     })
                     .catch((err) => {
+                        this.$emit("didUpload", "error");
                         reject(err);
                     });
             });

+ 8 - 1
src/lib/util.js

@@ -115,7 +115,7 @@ Vue.prototype.$dicsTreesInit = function (selectList) {
  * @param chunkSize 分片大小
  * @returns Promise
  */
- function md5(file, chunkSize) {
+function md5(file, chunkSize) {
     // element 中组件对 file 进行加工,这里使用未加工的对象,只有未加工的对象才能在 blobSlice.call() 中正常操作
     let fileRaw = file
 
@@ -156,4 +156,11 @@ Vue.prototype.$dicsTreesInit = function (selectList) {
     });
 }
 
+// 获取objectPath,由于截取去掉的'0.'后的字符串位数为15-17位不等(不一定是16位),所以采取拼接的方式
+Vue.prototype.$getObjectPathByRandom = function () {
+    let a = Math.random().toString().slice(2, 10);
+    let b = Math.random().toString().slice(2, 10);
+    return a + b;
+}
+
 Vue.prototype.$md5 = md5

+ 6 - 3
src/router/algorithmsLibrary.js

@@ -2,7 +2,8 @@ export default [{
         path: "/algorithmsLibraryList",
         name: "algorithmsLibraryList",
         meta: {
-            tabname: "算法库列表"
+            tabname: "算法库列表",
+            menuKind: "algorithmsLibrary"
         },
         component: () => import("@/views/algorithmsLibrary/algorithmsLibraryList")
     },
@@ -10,7 +11,8 @@ export default [{
         path: "/gitAlgorithms",
         name: "gitAlgorithms",
         meta: {
-            tabname: "仓库算法"
+            tabname: "仓库算法",
+            menuKind: "algorithmsLibrary"
         },
         component: () => import("@/views/algorithmsLibrary/gitAlgorithms")
     },
@@ -18,7 +20,8 @@ export default [{
         path: "/exportAlgorithms",
         name: "exportAlgorithms",
         meta: {
-            tabname: "导入算法"
+            tabname: "导入算法",
+            menuKind: "algorithmsLibrary"
         },
         component: () => import("@/views/algorithmsLibrary/exportAlgorithms")
     },

+ 8 - 4
src/router/modelLibrary.js

@@ -2,7 +2,8 @@ export default [{
         path: "/vehicleConfigurationList",
         name: "vehicleConfigurationList",
         meta: {
-            tabname: "车辆配置列表"
+            tabname: "车辆配置列表",
+            menuKind: "modelLibrary"
         },
         component: () => import("@/views/modelLibrary/vehicleConfigurationList")
     },
@@ -10,7 +11,8 @@ export default [{
         path: "/vehicleConfigurationDetail",
         name: "vehicleConfigurationDetail",
         meta: {
-            tabname: "车辆配置详情"
+            tabname: "车辆配置详情",
+            menuKind: "modelLibrary"
         },
         component: () => import("@/views/modelLibrary/vehicleConfigurationDetail")
     },
@@ -18,7 +20,8 @@ export default [{
         path: "/sensorModel",
         name: "sensorModel",
         meta: {
-            tabname: "传感器模型"
+            tabname: "传感器模型",
+            menuKind: "modelLibrary"
         },
         component: () => import("@/views/modelLibrary/sensorModel")
     },
@@ -26,7 +29,8 @@ export default [{
         path: "/vehicleModel",
         name: "vehicleModel",
         meta: {
-            tabname: "车辆模型"
+            tabname: "车辆模型",
+            menuKind: "modelLibrary"
         },
         component: () => import("@/views/modelLibrary/vehicleModel")
     },

+ 18 - 10
src/router/sceneLibrary.js

@@ -2,7 +2,8 @@ export default [{
         path: "/naturalDrivingScenarioList",
         name: "naturalDrivingScenarioList",
         meta: {
-            tabname: "自然驾驶场景"
+            tabname: "自然驾驶场景",
+            menuKind: "sceneLibrary"
         },
         component: () => import("@/views/sceneLibrary/naturalDrivingScenarioList")
     },
@@ -10,7 +11,8 @@ export default [{
         path: "/standardRegulationSimulationScenarioList",
         name: "standardRegulationSimulationScenarioList",
         meta: {
-            tabname: "标准法规仿真场景"
+            tabname: "标准法规仿真场景",
+            menuKind: "sceneLibrary"
         },
         component: () => import("@/views/sceneLibrary/standardRegulationSimulationScenarioList")
     },
@@ -18,7 +20,8 @@ export default [{
         path: "/trafficAccidentSimulationScenarioList",
         name: "trafficAccidentSimulationScenarioList",
         meta: {
-            tabname: "交通事故仿真场景"
+            tabname: "交通事故仿真场景",
+            menuKind: "sceneLibrary"
         },
         component: () => import("@/views/sceneLibrary/trafficAccidentSimulationScenarioList")
     },
@@ -26,7 +29,8 @@ export default [{
         path: "/scenarioTestPackageManagementList",
         name: "scenarioTestPackageManagementList",
         meta: {
-            tabname: "场景测试包管理"
+            tabname: "场景测试包管理",
+            menuKind: "sceneLibrary"
         },
         component: () => import("@/views/sceneLibrary/scenarioTestPackageManagementList")
     },
@@ -34,7 +38,8 @@ export default [{
         path: "/scenePacketList",
         name: "scenePacketList",
         meta: {
-            tabname: "场景数据包"
+            tabname: "场景数据包",
+            menuKind: "sceneLibrary"
         },
         component: () => import("@/views/sceneLibrary/scenePacketList")
     },
@@ -42,7 +47,8 @@ export default [{
         path: "/gradingRulesList",
         name: "gradingRulesList",
         meta: {
-            tabname: "评分规则列表"
+            tabname: "评分规则列表",
+            menuKind: "sceneLibrary"
         },
         component: () => import("@/views/sceneLibrary/gradingRulesList")
     },
@@ -50,16 +56,18 @@ export default [{
         path: "/gradingRule",
         name: "gradingRule",
         meta: {
-            tabname: "评分规则"
+            tabname: "评分规则",
+            menuKind: "sceneLibrary"
         },
         component: () => import("@/views/sceneLibrary/gradingRule")
     },
-    {
+    /* {
         path: "/templateView",
         name: "templateView",
         meta: {
-            tabname: "模板预览"
+            tabname: "模板预览",
+            menuKind: "sceneLibrary"
         },
         component: () => import("@/views/sceneLibrary/templateView")
-    },
+    }, */
 ]

+ 10 - 5
src/router/workManagement.js

@@ -2,7 +2,8 @@ export default [{
         path: "/manualRunProjectList",
         name: "manualRunProjectList",
         meta: {
-            tabname: "手动运行项目列表"
+            tabname: "手动运行项目列表",
+            menuKind: "workManagement"
         },
         component: () => import("@/views/workManagement/manualRunProjectList")
     },
@@ -10,7 +11,8 @@ export default [{
         path: "/manualRunProjectDetail",
         name: "manualRunProjectDetail",
         meta: {
-            tabname: "手动运行项目"
+            tabname: "手动运行项目",
+            menuKind: "workManagement"
         },
         component: () => import("@/views/workManagement/manualRunProjectDetail")
     },
@@ -18,7 +20,8 @@ export default [{
         path: "/projectInfo",
         name: "projectInfo",
         meta: {
-            tabname: "项目详情"
+            tabname: "项目详情",
+            menuKind: "workManagement"
         },
         component: () => import("@/views/workManagement/projectInfo")
     },
@@ -26,7 +29,8 @@ export default [{
         path: "/taskInfo",
         name: "taskInfo",
         meta: {
-            tabname: "任务详情"
+            tabname: "任务详情",
+            menuKind: "workManagement"
         },
         component: () => import("@/views/workManagement/taskInfo")
     },
@@ -34,7 +38,8 @@ export default [{
         path: "/evaluationReport",
         name: "evaluationReport",
         meta: {
-            tabname: "评价报告"
+            tabname: "评价报告",
+            menuKind: "workManagement"
         },
         component: () => import("@/views/workManagement/evaluationReport")
     },

+ 31 - 0
src/views/algorithmsLibrary/exportAlgorithms.vue

@@ -41,7 +41,11 @@
                             ref="upload"
                             :limit="1"
                             type="algorithmFile"
+                            :objectPath="objectPath"
+                            :needInstance="true"
                             @attachmentChange="attachmentChange"
+                            @willUpload="willUpload"
+                            @didUpload="didUpload"
                         ></upload>
                     </el-form-item>
                 </el-form>
@@ -96,6 +100,8 @@ export default {
                 ],
             },
             // attachmentList: [],
+            objectPath: "",
+            isUploading: false,
         };
     },
 
@@ -137,9 +143,34 @@ export default {
         cancel() {
             this.$router.replace({ path: "/algorithmsLibraryList" });
         },
+        onProgress() {
+            this.$axios({
+                method: "post",
+                url: this.$api.algorithmsLibrary.getProgress,
+                data: {
+                    objectPath: this.objectPath,
+                },
+            }).then((res) => {
+                // console.log(res);
+                if (res.code == 200) {
+                    
+                } else {
+                    this.$message.error(res.message || "获取进度信息失败");
+                }
+            });
+        },
+        willUpload() {
+            setTimeout(() => {
+                this.isUploading = true;
+                // this.onProgress();
+            }, 0);
+        },
+        didUpload(state) {},
     },
 
     mounted() {
+        this.objectPath = this.$getObjectPathByRandom();
+
         let id = this.$route.query.id;
         if (id) {
             this.form.id = id;

+ 14 - 8
src/views/page/pageMenu.vue

@@ -55,7 +55,7 @@
             <div class="menuList" v-show="!menuFold">
                 <el-menu
                     ref="menu"
-                    default-active="mainPage"
+                    :default-active="activeMenu"
                     class="el-menu-vertical-demo"
                     background-color="#3397FF"
                     :unique-opened="true"
@@ -159,6 +159,7 @@ export default {
                 "sceneLibrary",
                 "workManagement",
             ],
+            activeMenu: "mainPage", // 当前menu
         };
     },
     methods: {
@@ -174,6 +175,8 @@ export default {
             // console.log(index, indexPath);
             this.opened = indexPath[0];
 
+            console.log(this.activeMenu);
+
             // 如果是首页 手动关闭其他菜单
             if (index === this.menus[0]) {
                 this.menus.forEach((i) => {
@@ -188,11 +191,6 @@ export default {
         //     "Bearer 9882c634-9af6-4647-89dc-8ad53c04a56b"
         // );
 
-
-
-        // document.cookie = 'Authorization=Bearer 52de2c22-c2f9-4307-b49d-5b5593792352'
-        // console.log(this.$route);
-
         let { code, ticket } = this.$route.query;
         if (code && ticket) {
             this.$axios({
@@ -209,8 +207,16 @@ export default {
                     alert(res);
                 }
             });
-        } else {
-            console.log(66);
+        }
+    },
+
+    mounted() {
+        console.log(this.$route);
+
+        let menuKind = this.$route.meta.menuKind;
+
+        if (menuKind && menuKind !== "mainPage") {
+            this.$refs.menu.open(menuKind);
         }
     },
 };

+ 1 - 0
src/views/sceneLibrary/components/fileDialog.vue

@@ -13,6 +13,7 @@
                     ref="upload"
                     :limit="limit"
                     :type="type"
+                    :needInstance="true"
                     :objectPath="objectPath"
                     @attachmentChange="attachmentChange"
                 ></upload>

+ 0 - 3
src/views/sceneLibrary/naturalDrivingScenarioList.vue

@@ -264,9 +264,6 @@ export default {
             videoSrc: "",
             objectPath: "",
             videoDiaTitle: "",
-            //abc: "http://10.15.12.72:8001/simulation/resource/common/minio/preview?objectName=
-            // 自然驾驶场景/20220314/0.2378730429515783/simulation.mp4&access_token
-            // =9882c634-9af6-4647-89dc-8ad53c04a56b",
         };
     },
 

+ 2 - 2
vue.config.js

@@ -100,8 +100,8 @@ module.exports = {
                 }
             },
             '/simulation/resource/server': {
-                target: 'http://10.15.12.73:7003', // 王志强
-                // target: 'http://10.15.12.88:7003',  // 王耀栋
+                // target: 'http://10.15.12.73:7003', // 王志强
+                target: 'http://10.15.12.88:7003',  // 王耀栋
                 // target: 'http://10.15.12.72:7003',  // 王晓峰
                 // target: 'http://10.15.12.87:7003',  // 赵艳
                 // target: 'http://10.15.12.70',  // windowstest