فهرست منبع

登录登出问题
模型上传

James 4 سال پیش
والد
کامیت
408d7b519f
4فایلهای تغییر یافته به همراه147 افزوده شده و 40 حذف شده
  1. 139 34
      src/pages/list/index.vue
  2. 1 1
      src/pages/login/index.vue
  3. 5 3
      src/router/index.js
  4. 2 2
      src/util/http.js

+ 139 - 34
src/pages/list/index.vue

@@ -15,16 +15,12 @@
             <el-button type="primary" v-on:click="search">查询</el-button>
           </el-form-item>
         </el-form>
-        <!-- <router-link :to="{ name: 'add' }" class="button">添加场景</router-link> -->
         <el-button type="primary" @click="downloadSceneData"
-          >下载MP场景数据</el-button
-        >
-        <!-- <div class="button">下载MP场景数据</div> -->
+          >下载MP场景数据</el-button>
       </el-row>
       <!-- 生成大场景someData -->
       <el-row type="flex" class="addScene">
-        <el-button type="warning" style="margin-right: 20px" @click="logout"
-          >登出</el-button
+        <el-button type="warning" style="margin-right: 20px" @click="logout">登出</el-button
         >
         <!-- <el-input placeholder="输入编码生成someData" v-model="url">
           <template slot="append">
@@ -34,11 +30,14 @@
       </el-row>
     </el-row>
     <!-- 表格 -->
-    <el-table :data="scenes" style="width: 100%">
+    <el-table :data="scenes" style="width: 100%" @selection-change="handleSelectionChange">
+      <el-table-column type="selection" width="50"></el-table-column>
+      <el-table-column prop="sceneTitle" width="200" label="场景名称">
+      </el-table-column>
       <el-table-column prop="sceneCode" width="200" label="MP场景码">
       </el-table-column>
       <el-table-column label="状态" width="200">
-        <template scope="scope">
+        <template slot-scope="scope">
           <span>{{ manage_scene_status[scope.row.status] }}</span>
         </template>
       </el-table-column>
@@ -61,7 +60,7 @@
         <template slot-scope="scope">
           <a :href="scope.row.webSite" target="_blank">查看</a>
           <a @click="handModelDownload(scope.row)">模型下载</a>
-          <a @click="handModelUpload">模型上传</a>
+          <a @click="handModelUpload(scope.row)">模型上传</a>
           <a @click="handPanoramaDownload">全景图下载</a>
           <a @click="handPanoramaUpload">全景图上传</a>
         </template>
@@ -78,7 +77,7 @@
       >
       </el-pagination>
     </div>
-
+    <!-- 场景码下载 -->
     <el-dialog title="下载MP场景数据" :visible.sync="dialogFormVisible">
       <el-form :model="form" ref="ruleForm" :rules="rules">
         <el-form-item
@@ -94,6 +93,19 @@
           ></el-input>
         </el-form-item>
         <br />
+        <el-form-item
+          label="场景名称"
+          :label-width="formLabelWidth"
+          prop="sceneTitle"
+        >
+          <el-input
+            type="sceneTitle"
+            v-model="form.sceneTitle"
+            autocomplete="off"
+            placeholder="请输入场景名称"
+          ></el-input>
+        </el-form-item>
+        <br />
         <el-form-item label="备注" :label-width="formLabelWidth">
           <el-input
             type="textarea"
@@ -111,6 +123,40 @@
         >
       </div>
     </el-dialog>
+
+    <!-- 文件上传 -->
+    <el-dialog title="上传模型" :visible.sync="dialogFilesVisible">
+      <el-form ref="form1" label-width="80px" class="add-frome">
+        <el-form-item label="全景图文件">
+          <el-upload
+            class="upload-demo"
+            :action="uploadUrl"
+            ref="upload"
+            accept=".zip"
+            :on-change="handleChange"
+            :on-remove="handleRemove"
+            :on-success="onSuccess"
+            :on-error="onError"
+            :file-list="fileList"
+            :auto-upload="false"
+          >
+            <el-button slot="trigger" size="small" type="primary"
+              >选取文件</el-button
+            >
+            <div slot="tip" class="el-upload__tip">只能上传zip文件</div>
+          </el-upload>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="dialogFilesVisible = false">取 消</el-button>
+        <el-button
+          type="primary"
+          v-loading.fullscreen.lock="fullscreenLoading"
+          @click="submitUpload"
+          >确 定</el-button
+        >
+      </div>
+    </el-dialog>
   </div>
 </template>
 
@@ -119,13 +165,6 @@ import { MANAGE_SCENE_STATUS } from "@/config/data";
 export default {
   name: "list",
   data() {
-    var validateSceneCode = (rule, value, callback) => {
-      if (!value) {
-        return callback(new Error("场景码不能为空"));
-      } else {
-        callback();
-      }
-    };
     return {
       searchKey: "",
       scenes: [],
@@ -133,18 +172,24 @@ export default {
       currentPage: 1,
       total: 0,
       size: 15,
+      fileList: [],
+      uploadUrl: "",
+      fullscreenLoading: false,
+      targetObj: null,
       manage_scene_status: MANAGE_SCENE_STATUS,
       dialogFormVisible: false,
+      dialogFilesVisible: false,
       form: {
         sceneCode: "",
+        sceneTitle: "",
         description: "",
       },
       rules: {
         sceneCode: [
-          {
-            validator: validateSceneCode,
-            trigger: "blur",
-          },
+          { required: true, message: "场景码不能为空", trigger: "blur" },
+        ],
+        sceneTitle: [
+          { required: true, message: "场景名称不能为空", trigger: "blur" },
         ],
         description: [],
       },
@@ -160,13 +205,72 @@ export default {
     },
   },
   methods: {
+    handleSelectionChange(val){
+      console.log('val',val)
+    },
+    handleRemove(file) {
+      let index = this.fileList.findIndex((item) => {
+        return item.uid === file.uid;
+      });
+      this.fileList.splice(index, 1);
+    },
+    handleChange(file) {
+      this.fileList = this.fileList.length === 0 ? this.fileList : [];
+      this.fileList.push(file["raw"]);
+    },
+    onSuccess(res) {
+      this.$alert("上传成功", "提示", {
+        confirmButtonText: "确定",
+        callback: (action) => {
+          console.log("上传成功");
+          this.dialogFilesVisible = false;
+        },
+      });
+    },
+    onError(res) {
+      this.$alert("上传失败", "提示", {
+        confirmButtonText: "确定",
+        callback: (action) => {
+          console.log("上传失败");
+        },
+      });
+    },
+    async submitUpload() {
+      var that = this;
+      if (this.fileList.length === 0) {
+        this.$alert("请上传附件", "提示", {
+          confirmButtonText: "确定",
+          callback: (action) => {
+            console.log("上传失败");
+          },
+        });
+        return;
+      }
+      let formData = new FormData();
+      this.fileList.forEach((file) => {
+        formData.append("file", file);
+      });
+      this.fullscreenLoading = true;
+      let res = await this.$http.post(
+        `/manage/scene/upload/obj/${this.targetObj.sceneCode}`,
+        formData,
+        {
+          "Content-Type": "multipart/form-data",
+        }
+      );
+      if (res["code"] === 0) {
+        this.fullscreenLoading = false;
+        that.onSuccess(res);
+      } else {
+        this.fullscreenLoading = false;
+        that.onError(res);
+      }
+    },
     search() {
       this.currentPage === 1 ? this.getScenes() : (this.currentPage = 1);
     },
     sceneCodeSubmit(formName) {
-      console.log(this);
       this.$refs[formName].validate((valid) => {
-        console.log("valid", valid);
         if (valid) {
           this.sceneCodeSendHttp();
         }
@@ -176,19 +280,16 @@ export default {
       let { sceneCode, description } = this.form;
       let body = {
         description,
-        sceneCode
+        sceneCode,
       };
-      this.$http.post("/manage/scene/download",body).then(res=>{
-        console.log('res',res)
-        this.$message(res['msg']);
-        if(res['code'] === 0) {
-          console.log('下载成功')
+      this.$http.post("/manage/scene/download", body).then((res) => {
+        this.$message(res["msg"]);
+        if (res["code"] === 0) {
+          console.log("下载成功");
           this.dialogFormVisible = false;
-        }else {
-          
+        } else {
         }
-      })
-      
+      });
     },
     downloadSceneData() {
       this.dialogFormVisible = true;
@@ -220,7 +321,11 @@ export default {
         window.open(`http://${res["data"]}`);
       }
     },
-    handModelUpload() {},
+    handModelUpload(item) {
+      this.dialogFilesVisible = true;
+      this.targetObj = item;
+      this.fileList = [];
+    },
     handPanoramaDownload() {},
     handPanoramaUpload() {},
     async delScene(name) {

+ 1 - 1
src/pages/login/index.vue

@@ -143,7 +143,7 @@ export default {
           window.localStorage.setItem('cjt_phoneNum', '')
           window.localStorage.setItem('cjt_pass', '')
         }
-        this.$router.push('/')
+        this.$router.push('/list')
       } else {
         this.$notify.error({
           title: '错误',

+ 5 - 3
src/router/index.js

@@ -9,10 +9,12 @@ Vue.use(Router)
 let router = new Router({
   routes: [
     {
-      path: '/',
+      path: '/list',
       name: 'List',
       component: List
-    }, {
+    }, 
+
+    {
       path: '/add',
       name: 'add',
       component: Add
@@ -29,7 +31,7 @@ router.beforeEach((to, from, next) => {
   let token = window.localStorage.getItem('cjt_token')
   if (token) {
     if (to.path === '/login') {
-      next({ path: '/' })
+      next({ path: '/list' })
     } else {
       next()
     }

+ 2 - 2
src/util/http.js

@@ -54,8 +54,8 @@ axios.interceptors.response.use(
         }
         break
       case 5002:
-        if (window.localStorage.getItem('token')) {
-          window.localStorage.setItem('token', '')
+        if (window.localStorage.getItem('cjt_token')) {
+          window.localStorage.setItem('cjt_token', '')
           vue.$alert('登录状态失效,请重新登录', '提示', {
             confirmButtonText: '确定',
             callback: function () {