Browse Source

点位配置代码已提交

chuwu 5 years ago
parent
commit
023700acdd

+ 1 - 1
src/components/common/handsontable.vue

@@ -171,7 +171,7 @@
                     afterFilter: this.trimmedRows, //排序
                     afterDocumentKeyDown: this.afterDocumentKeyDown, //鼠标单击
                 }, settings);
-                console.log(hotSettings, settings)
+                console.log(hotSettings, settings,this.hot,'hot')
                 if(!!this.hot){
                     this.hot.destroy();
                     this.hot = null

+ 44 - 0
src/components/common/uploadFile.vue

@@ -0,0 +1,44 @@
+<template>
+    <div>
+        <el-upload
+        class="upload-demo"
+        ref="upload"
+        action=""
+        :auto-upload="true"
+        :on-change="upload"
+        :http-request="uploadFile"
+        :accept="accept"
+        :limit="limit"
+        >
+        <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
+        </el-upload>
+    </div>
+</template>
+<script>
+export default {
+    props:{
+        accept: {
+            type: String,
+            default: ""
+        },
+        limit: {
+            type: [String,Number],
+            default: 1
+        }
+    },
+    data(){ return {}},
+    created(){},
+    mounted(){},
+    methods:{
+        upload(file,fileList){
+            console.log(file,fileList,'fileList')
+            this.$emit("change",fileList)
+        },
+        uploadFile(file){
+            console.log(file)
+        }
+    }
+}
+</script>
+<style lang="scss">
+</style>

+ 20 - 6
src/components/config_point/cut_string.vue

@@ -1,5 +1,5 @@
 <template>
-    <div class="flex">
+    <div class="center">
         <template v-for="(item,index) in stringArr">
           <span
             :key="index"
@@ -16,6 +16,10 @@
             string: {
                 type: String,
                 default: ""
+            },
+            closedStr: {
+                type: String,
+                default: ""
             }
         },
         data() {
@@ -42,7 +46,6 @@
                 for (let key in this.obj) {
                     string += this.obj[key]
                 }
-                console.log(string)
                 return string
             }
         },
@@ -55,12 +58,23 @@
 </script>
 <style lang="scss" scoped>
     .cut-string {
-        width: 50px;
-        height: 50px;
+        width: 30px;
+        height: 30px;
         text-align: center;
-        line-height: 50px;
+        line-height: 30px;
+        font-size: 14px;
+        display: inline-block;
+        box-sizing: border-box;
+        margin: 0 5px;
     }
     .bg {
-        background: red;
+        background: #409EFF;
+        color: #fff;
+        border-color: #409EFF;
+    }
+    .saga-warning{
+        color: #fff;
+        background-color: #e6a23c;
+        border-color: #e6a23c;
     }
 </style>

+ 2 - 2
src/components/config_point/find_keyword.vue

@@ -9,8 +9,8 @@
             </div>
             <div class="h10"></div>
             <div class="center">
-                <el-button :disabled="!Description" @click="getCutString">此条无法识别</el-button>
-                <el-button :disabled="!Description" @click="getCutString">继续发现关键字</el-button>
+                <el-button type="primary" :disabled="!Description" @click="getCutString">此条无法识别</el-button>
+                <el-button type="primary" :disabled="!Description" @click="getCutString">继续发现关键字</el-button>
             </div>
             <div class="h10"></div>
         </div>

+ 6 - 0
src/fetch/point_http.js

@@ -291,4 +291,10 @@ export function batchQueryUnit(param, success) {
 export function batchCreate(param, success) {
     let data = param
     return post(`${point}/relation//batch-create`, data, success)
+}
+
+//上传
+export function uploadPointFile(param, success) {
+    let data = param.data
+    return post(`${point}/point/${param.type}/point-import`, data, success)
 }

+ 29 - 16
src/views/point/config_point/index.vue

@@ -1,18 +1,27 @@
 <template>
     <div class="saga-config-point">
-        <h3 class="center">{{projectName}}</h3>
-        <p class="center">此项目包括{{list.length}}个数据源</p>
-        <div class="saga-origin-list dcenter w">
-            <div class="disIne border-hover saga-list-item margin5" v-for="(item,index) in list" :key="index">
-                <data-origin :id="'origin' + index" :renderData="item">
-                    <el-button @click="maintenance(item)" type="text">维护点位</el-button>
-                    <el-button @click="goEdit(item)" type="text">编辑数据源</el-button>
-                </data-origin>
-            </div>
-            <div class="disIne saga-list-item margin5 center pointer" @click="addItem">
-                <i class="add-icon margin50">+</i>
+        <div style="line-height:32px;">
+            <span>此项目包括<i style="color:#409EFF;">{{list.length}}</i>个数据源</span>
+            <div style="float:right;">
+                <el-button type="primary">同步配置文件到云端</el-button>
+                <el-button type="primary">添加数据源</el-button>
             </div>
         </div>
+        <div class="saga-origin-list" v-loading="isLoading">
+            <el-scrollbar>
+                <div class="disIne border-hover saga-list-item margin5" v-for="(item,index) in list" :key="index">
+                    <data-origin :id="'origin' + index" :renderData="item">
+                        <div class="center">
+                            <el-button @click="maintenance(item)" type="text">维护点位</el-button>
+                            <el-button @click="goEdit(item)" type="text">编辑数据源</el-button>
+                        </div>
+                    </data-origin>
+                </div>
+                <!-- <div class="disIne saga-list-item margin5 center pointer" @click="addItem">
+                    <i class="add-icon margin50">+</i>
+                </div> -->
+            </el-scrollbar>
+        </div>
     </div>
 </template>
 <script>
@@ -31,7 +40,8 @@
         data() {
             return {
                 projectName: "项目名称",
-                list: []
+                list: [],
+                isLoading: false
             }
         },
         computed: {
@@ -46,7 +56,9 @@
         },
         methods: {
             getList(){
+                this.isLoading = true
                 queryDataSourceCount({},res => {
+                    this.isLoading = false
                     console.log(res)
                     this.list = res.Content
                 })
@@ -79,8 +91,8 @@
 </script>
 <style lang="scss" scoped>
     .saga-config-point {
-        height: 100%;
-        overflow-y: auto;
+        display: flex;
+        flex-flow: column;
         .add-icon {
             font-size: 40px;
         }
@@ -90,9 +102,10 @@
             line-height: 8;
         }
         .saga-origin-list {
+            flex: 1;
             display: flex;
-            flex-wrap: wrap; // justify-content: space-around;
-            height: calc(100% - 90px);
+            flex-wrap: wrap;  
+            justify-content: space-around;
             .saga-list-item {
                 background-color: #fff;
                 width: 345px;

+ 74 - 13
src/views/point/config_point/steps/step1.vue

@@ -6,22 +6,29 @@
             <el-button style="float:right;margin-top:4px;" type="primary" @click="downData">下载数据</el-button>
             <el-button style="float:right;margin-top:4px;" type="primary" @click="updateExcel = true">导入Excel</el-button>
             <el-button style="float:right;margin-top:4px;" type="primary" @click="downloadExcel = true">导出Excel模板</el-button>
-            <el-checkbox style="float:right;line-height:40px;" v-model="checked">只显示使用的原始点位</el-checkbox>
+            <el-checkbox style="float:right;line-height:40px;" @change="getData" v-model="checked">只显示使用的原始点位</el-checkbox>
             <el-button type="primary">获取原始点位当前值</el-button>
         </div>
         <div id="handsontableSteps1" v-loading="isLoading">
             <handsontable-component v-if="!!allData.length" ref="handsontable" @mouseDown="clickTable" @change="changeHand"></handsontable-component>
             <div v-else class="center">暂无数据</div>
         </div>
-        <own-dialog :width="'580px'" :index="true" title="位置标签" :dialogVisible="localtionDialog" @cancel="close">
+        <own-dialog :width="'500px'" :index="true" title="位置标签" :dialogVisible="localtionDialog" @cancel="close">
             <localtion-falg :renderData="renderData"></localtion-falg>
         </own-dialog>
-        <own-dialog :width="'580px'" :index="true" title="导出excel模板" :dialogVisible="downloadExcel" @cancel="close">
+        <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>
-        <own-dialog :width="'580px'" :index="true" title="导出excel模板" :dialogVisible="updateExcel" @cancel="close">
+        <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>
+            </div>
+            <div>
+                <el-radio class="radio-left" v-model="radio" label="1">默认使用导入的全部原始点位</el-radio>
+                <el-radio class="radio-left" v-model="radio" label="2">默认不使用导入的全部原始点位</el-radio>
+            </div>
         </own-dialog>
         <div class="center">
             <pagination :page="pages" @change="changePage"></pagination>
@@ -46,8 +53,10 @@
         queryPoint,
         updatePoint,
         createPoint,
-        downloadTemplete
+        downloadTemplete,
+        uploadPointFile
     } from "@/fetch/point_http"
+    import uploadFile from "@/components/common/uploadFile"
     import axios from 'axios'
     export default {
         data() {
@@ -72,6 +81,12 @@
                 downloadExcel: false,
                 isLoading: false,
                 updateExcel: false,
+                radio: '1',
+                file: "", //上传的文件
+                footer: {
+                    cancel: '取消',
+                    confirm: '确定'
+                }
             }
         },
         computed: {
@@ -99,13 +114,19 @@
                 this.updateExcel = false
             },
             downData() {
-                axios({
+                let param = {
                     method: 'post',
                     url: `/pointconfig/point/${this.protocolType}/pointlist-export`,
-                    data: {DataSourceId: this.datasourceId},
+                    data: {
+                        DataSourceId: this.datasourceId
+                    },
                     responseType: 'blob',
-                    headers:{ProjectId: this.projectId}
-                }).then(function(res) {
+                    headers: {
+                        ProjectId: this.projectId
+                    }
+                }
+                console.log(param, 'param')
+                axios(param).then(function(res) {
                     var blob = new Blob([res.data], {
                         type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
                     });
@@ -128,12 +149,18 @@
                     console.dirxml(err);
                 })
             },
+
             //下载excel模板
             download() {
                 axios({
                     method: 'post',
                     url: `/pointconfig/point/${this.protocolType}/template-export`,
-                    data: {},
+                    data: {
+                        DataSourceId: this.datasourceId
+                    },
+                    headers: {
+                        ProjectId: this.projectId
+                    },
                     responseType: 'blob'
                 }).then(function(res) {
                     var blob = new Blob([res.data], {
@@ -189,7 +216,7 @@
             clickTable(info, row) {
                 let activeCell = this.hot.getActiveEditor()
                 this.renderData = info
-                console.log(activeCell,'activeCell')
+                console.log(activeCell, 'activeCell')
                 if (activeCell.prop == "LocationFlag") {
                     this.localtionDialog = true
                 }
@@ -239,6 +266,9 @@
                         "PageSize": this.pages.size,
                     }
                 }
+                if(this.checked){
+                    param.data.Filters.Used = true
+                }
                 this.oldPage = {
                     size: this.pages.size,
                     currentPage: this.pages.currentPage
@@ -362,21 +392,52 @@
             //没有保存的时候弹窗
             noSaveData() {
                 return this.changeFlag
+            },
+            //上传文件
+            changeFile(file) {
+                this.file = file[0] || ''
+                console.log(file, 'file')
+            },
+            //确定上传
+            sureOfUpload() {
+                if (!!this.file) {
+                    //有文件进行上传
+                    let param = {
+                        data: new FormData(),
+                        type: this.protocolType
+                    };
+                    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
+                    })
+                } else {
+                    this.$message.info("请选择文件")
+                }
             }
         },
         components: {
             handsontableComponent,
             ownDialog,
             localtionFalg,
-            pagination
+            pagination,
+            uploadFile
         },
     }
 </script>
 <style lang="scss" scoped>
+    .radio-left {
+        display: block;
+        line-height: 30px;
+        margin-left: 100px;
+    }
     #handsonStep1 {
         flex: 1;
         display: flex;
-        flex-flow:column;
+        flex-flow: column;
         .btns-view {
             height: 40px;
             line-height: 40px;