浏览代码

点位配置 添加 导入 导出模板

haojianlong 5 年之前
父节点
当前提交
cac2fd7ecc
共有 2 个文件被更改,包括 42 次插入11 次删除
  1. 6 0
      src/fetch/point_http.js
  2. 36 11
      src/views/point/config_point/steps/step1.vue

+ 6 - 0
src/fetch/point_http.js

@@ -318,6 +318,12 @@ export function uploadPointFile(param, success) {
     return post(`${point}/point/${param.type}/point-import`, data, success)
 }
 
+//上传2
+export function uploadPointFile2(param, success) {
+    let data = param.data
+    return post(`${point}/point/${param.type}/point-import2`, data, success)
+}
+
 //根据id批量删除对应关系
 export function deleteRelationList(param, success) {
     let data = param

+ 36 - 11
src/views/point/config_point/steps/step1.vue

@@ -19,14 +19,24 @@
         <own-dialog :width="'500px'" :index="true" title="位置标签" :dialogVisible="localtionDialog" @cancel="closeFalg">
             <localtion-falg :renderData="renderData" @changeTag="changeLoc"></localtion-falg>
         </own-dialog>
-        <own-dialog :width="'300px'" :index="true" title="导出excel模板" :dialogVisible="downloadExcel" @cancel="close">
-            <div class="center">
-                <el-button type="text" @click="download">下载模板</el-button>
-            </div>
+        <own-dialog :width="'500px'" :index="true" title="导出excel模板" :dialogVisible="downloadExcel" :footer="footer" @cancel="close" @confirm="download">
+            <span>请选择要导出的模板</span>
+            <el-select v-model="exportTemplate" placeholder="请选择模板">
+                <el-option label="模板一" value="0"></el-option>
+                <el-option label="模板二" value="1"></el-option>
+            </el-select>
         </own-dialog>
         <own-dialog :width="'500px'" :index="true" :footer="footer" title="导入excel" :dialogVisible="updateExcel" @confirm="sureOfUpload" @cancel="close">
             <div class="center" style="height:100px;">
                 <upload-file accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" @change="changeFile"></upload-file>
+                <p style="font-size:12px;">上传文件大小在1M以内</p>
+            </div>
+            <div>
+                <span>请选择要导入的模板</span>
+                <el-select v-model="importTemplate" placeholder="请选择模板">
+                    <el-option label="模板一" value="0"></el-option>
+                    <el-option label="模板二" value="1"></el-option>
+                </el-select>
             </div>
             <div>
                 <el-radio class="radio-left" v-model="radio" label="1">默认使用导入的全部原始点位</el-radio>
@@ -62,6 +72,7 @@
         createPoint,
         downloadTemplete,
         uploadPointFile,
+        uploadPointFile2,
         deletePoint,
         getPointValue
     } from "@/fetch/point_http"
@@ -96,7 +107,9 @@
                 footer: {
                     cancel: '取消',
                     confirm: '确定'
-                }
+                },
+                exportTemplate:'0',
+                importTemplate:'0'
             }
         },
         computed: {
@@ -224,9 +237,13 @@
             },
             //下载excel模板
             download() {
+                let url = `/pointconfig/point/${this.protocolType}/template-export`
+                if(this.exportTemplate=='1'){
+                    url += '2'
+                }
                 axios({
                     method: 'post',
-                    url: `/pointconfig/point/${this.protocolType}/template-export`,
+                    url: url,
                     data: {
                         DataSourceId: this.datasourceId
                     },
@@ -523,11 +540,19 @@
                     param.data.set('DataSourceId', this.datasourceId)
                     param.data.set('Used', this.radio == 1 ? true : false)
                     param.data.set('multipartFile', this.file.raw)
-                    uploadPointFile(param, res => {
-                        this.$message.success("上传成功")
-                        this.getData()
-                        this.updateExcel = false
-                    })
+                    if(this.importTemplate=='1'){
+                        uploadPointFile2(param, res => {
+                            this.$message.success("上传成功")
+                            this.getData()
+                            this.updateExcel = false
+                        })
+                    } else {
+                        uploadPointFile(param, res => {
+                            this.$message.success("上传成功")
+                            this.getData()
+                            this.updateExcel = false
+                        })
+                    }
                 } else {
                     this.$message.info("请选择文件")
                 }