Browse Source

Merge remote-tracking branch 'origin/master'

onlyh 3 years ago
parent
commit
cd8224d7b0
4 changed files with 69 additions and 16 deletions
  1. 5 0
      src/api/datacenter.ts
  2. 30 1
      src/api/httputils.ts
  3. 24 5
      src/views/scene/tiepoint/components/equipTab/index.vue
  4. 10 10
      vue.config.js

+ 5 - 0
src/api/datacenter.ts

@@ -72,6 +72,11 @@ export function updateEquip(postParams: any): any {
     return httputils.postJson(`${baseApi}/object/equip/update`, postParams)
 }
 
+// 导出设备
+export function exportEquip(getParams: any): any {
+    return httputils.getDownload(`${baseApi}/object/equip/export`, getParams)
+}
+
 // 查询系统信息
 export function querySystem(postParams: any): any {
     return httputils.postJson(`${baseApi}/object/system/query`, postParams)

+ 30 - 1
src/api/httputils.ts

@@ -138,7 +138,36 @@ export default {
             throw err;
         }
     },
-    download(url: string, requestData: any) {
+    getDownload(url: string, requestData: any) {
+        // 响应类型:arraybuffer, blob
+        axiosservice
+            .get(url, {params: requestData, responseType: 'blob'})
+            .then((resp) => {
+                const headers = resp.headers;
+                const contentType = headers["content-type"];
+
+                console.log("响应头信息", headers);
+                if (!resp.data) {
+                    console.error("响应异常:", resp);
+                    return false;
+                } else {
+                    console.log("下载文件:", resp);
+                    const blob = new Blob([resp.data], { type: contentType });
+
+                    const contentDisposition = resp.headers["content-disposition"];
+                    let fileName = "unknown";
+                    if (contentDisposition) {
+                        fileName = window.decodeURI(resp.headers["content-disposition"].split("=")[1]);
+                    }
+                    console.log("文件名称:", fileName);
+                    downFile(blob, fileName);
+                }
+            })
+            .catch(function (error) {
+                console.log(error);
+            });
+    },
+    postDownload(url: string, requestData: any) {
         // 响应类型:arraybuffer, blob
         axiosservice
             .post(url, requestData, { responseType: "blob" })

+ 24 - 5
src/views/scene/tiepoint/components/equipTab/index.vue

@@ -12,13 +12,18 @@
             <admSearch @SearchValue="searchValue" class="item"/>
             <el-upload
                 style="float: right"
-                action="https://jsonplaceholder.typicode.com/posts/"
+                action="/datacenter/object/equip/import"
+                :disabled="true"
+                :headers="{ projectId: projectId, groupCode: 'WD' }"
+                :data="{ projectId: projectId, classCode: deviceType }"
                 :show-file-list="false"
                 multiple
             >
-                <el-button>上传Excle</el-button>
+                <el-button :disabled="!deviceType">上传Excle</el-button>
             </el-upload>
-            <el-button style="float: right; margin-right: 12px" @click="handleClickDownload">下载模板</el-button>
+            <el-tooltip effect="dark" content="请选择设备类型" placement="top">
+                <el-button style="float: right; margin-right: 12px" :disabled="!deviceType" @click="handleClickDownload">下载模板</el-button>
+            </el-tooltip>
         </div>
         <div v-loading="loading" style="height: calc(100% - 100px); padding: 0 12px; position: relative">
             <template style="height: 100%" v-if="tableData.length">
@@ -58,7 +63,7 @@
 <script lang="ts">
 import { Vue, Component, Ref } from "vue-property-decorator";
 import { allDevice, dictInfo } from "@/api/equipComponent";
-import { queryEquip, updateEquip } from "@/api/datacenter";
+import { queryEquip, updateEquip, exportEquip } from "@/api/datacenter";
 import { AdmMultiTable, AdmSearch, Pagination, baseDataForm } from "@/views/maintain/components/index";
 import { UserModule } from "@/store/modules/user";
 import tools from "@/utils/maintain";
@@ -274,8 +279,22 @@ export default class EquipTab extends Vue {
     /**
      * 下载模板
      */
-    private handleClickDownload() {
+    private async handleClickDownload() {
         console.log("下载模板");
+        /**
+         * TODO:下载模板代码
+         */
+        // if (!this.projectId) {
+        //     this.$message.info("请选择项目");
+        // } else if (!this.deviceType) {
+        //     this.$message.info("请选择设备类型");
+        // } else {
+        //     const getParams = {
+        //         projectId: this.projectId,
+        //         classCode: this.deviceType
+        //     }
+        //     exportEquip(getParams);
+        // }
     }
 
     /**

+ 10 - 10
vue.config.js

@@ -28,26 +28,26 @@ module.exports = {
                 }
             },
             "/datacenter": {
-                // target: "http://192.168.64.17:28890",
-                target: "http://192.168.0.72:8080",
+                target: "http://192.168.64.17:28890",
+                // target: "http://192.168.0.72:8080",
                 changeOrigin: true
             },
             "/equip-component": {
-                // target: "http://192.168.64.17:28890",
-                target: "http://192.168.0.72:8080",
+                target: "http://192.168.64.17:28890",
+                // target: "http://192.168.0.72:8080",
                 changeOrigin: true
             },
             "/schedulerapi": {
-                // target: "http://192.168.64.17:28890",
-                target: "http://192.168.0.72:8080",
+                target: "http://192.168.64.17:28890",
+                // target: "http://192.168.0.72:8080",
                 changeOrigin: true,
                 pathRewrite: {
                     "^/schedulerapi": "/scheduler"
                 }
             },
             "/modelapi": {
-                // target: "http://192.168.64.17:28890",
-                target: "http://192.168.0.72:8080",
+                target: "http://192.168.64.17:28890",
+                // target: "http://192.168.0.72:8080",
                 changeOrigin: true,
                 pathRewrite: {
                     "^/modelapi": "/revit-algorithm"
@@ -61,8 +61,8 @@ module.exports = {
             //     }
             // },
             "/message-center": {
-                // target: "http://192.168.64.17:28890",
-                target: "http://192.168.0.72:8080",
+                target: "http://192.168.64.17:28890",
+                // target: "http://192.168.0.72:8080",
                 changeOrigin: true
             },
             "/rwd": {