chuwu 6 years ago
parent
commit
351439b209

+ 98 - 28
src/components/config_point/find_keyword.vue

@@ -1,31 +1,52 @@
 <template>
     <div class="view-find-word">
-        <div>
+        <div class="saga-border">
             <p class="center">请从下面的原始点位描述中选择"{{title == 'type' ? "设备类型" : "设备参数"}}"关键字</p>
             <div class="h10"></div>
-            <cut-string :string="Description" ref="cutString"></cut-string>
+            <div>
+                <cut-string v-if="!!Description" :string="Description" ref="cutString"></cut-string>
+                <p v-else class="center">已处理到最后一条</p>
+            </div>
+            <div class="h10"></div>
+            <div class="center">
+                <el-button :disabled="!Description" @click="getCutString">此条无法识别</el-button>
+                <el-button :disabled="!Description" @click="getCutString">继续发现关键字</el-button>
+            </div>
             <div class="h10"></div>
-            <el-button @click="getCutString">此条无法识别</el-button>
-            <el-button @click="getCutString">继续发现关键字</el-button>
         </div>
+        <div class="h10"></div>
         <div class="find-data">
-            <div class="left-view">
+            <div class="left-view saga-border">
                 <doughnut v-if="!!sum" width="200" height="200" :renderData="echartsData"></doughnut>
                 <div v-else class="center">暂无数据</div>
             </div>
             <div class="right-view saga-border">
-
+                <div class="find-tags" v-for="tag in tagList">
+                    <el-tag
+                        :key="title == 'type' ? tag.EquipmentType : tag.EquipmentType"
+                        @click="changeName(tag)"
+                        closable>
+                        {{title == 'type' ? tag.EquipmentType + "(" + tag.PointCount  + ")" : tag.EquipmentType + "(" + tag.PointCount  + ")"}}
+                    </el-tag>
+                </div>
             </div>
         </div>
+        <my-dialog :dialogVisible="reNameDialog" :footer="footer" @cancel="reNameDialog = false" title="重命名" :isAppendBody="true">
+            <h3 class="center">{{name}}</h3>
+            <el-input v-model="newName" placeholder="请输入新名称"></el-input>
+        </my-dialog>
     </div>
 </template>
 <script>
     import cutString from "components/config_point/cut_string"
     import doughnut from "components/echarts/doughnut"
+    import myDialog from "components/el_pack/dialog"
     import {
         findKeysWord,
         findKeysWordType,
-        queryDataSourceCount
+        queryDataSourceCount,
+        queryEqTypeList,
+        queryEqParamList
     } from "fetch/point_http"
     import {
         mapGetters,
@@ -45,14 +66,23 @@
         },
         components: {
             cutString,
-            doughnut
+            doughnut,
+            myDialog
         },
         data() {
             return {
                 title: "",
                 Description: "",
                 echartsData: [],
-                sum: 0
+                sum: 0,
+                tagList: [],
+                reNameDialog: false,
+                name: "",
+                newName: "",
+                footer:{
+                    cancel: "取消",
+                    confirm: "确定"
+                }
             }
         },
         created() {},
@@ -61,6 +91,18 @@
             getCutString() {
                 console.log(this.$refs.cutString.getData())
             },
+            //点击事件,重命名
+            changeName(tag){
+                console.log(tag,"tag")
+                this.reNameDialog = true
+                this.newName = ""
+                if(this.type == "type"){
+                    this.name = tag.EquipmentType
+                }else{
+                    this.name = tag.EquipmentType
+                }
+            },
+            //获取文字
             changeType() {
                 let queryFun
                 if (this.type == "type") {
@@ -75,39 +117,61 @@
                     },
                     type: this.protocolType
                 }, res => {
-                    this.Description = res.Content.Description
+                    if (!!res.Content) {
+                        this.Description = res.Content.Description
+                    } else {
+                        this.Description = ""
+                    }
                     console.log(res)
                 })
-                this.findDataForSource()
+                this.getDataForSource()
+                this.getbeenFoundList()
             },
             //查询数据源数据
-            findDataForSource() {
+            getDataForSource() {
                 queryDataSourceCount({
                     Filters: {
-                        projectId: this.projectId,
                         Id: this.datasourceId
                     }
                 }, res => {
                     console.log(res, "res")
                     let data = res.Content[0]
-                    this.echartsData = [
+                    this.echartsData = [{
+                            name: "无法识别-" + data.Ignorestandard,
+                            value: data.Ignorestandard
+                        },
                         {
-                        name: "无法识别-" + data.Ignorestandard,
-                        value: data.Ignorestandard
-                    },
-                    {
-                        name: "未识别-" + data.Notstandard,
-                        value: data.Notstandard
-                    },
-                    {
-                        name: "已识别-" + data.Notrelated,
-                        value: data.Notrelated
-                    }
+                            name: "未识别-" + data.Notstandard,
+                            value: data.Notstandard
+                        },
+                        {
+                            name: "已识别-" + data.Notrelated,
+                            value: data.Notrelated
+                        }
                     ]
                     this.sum = data.Sum
                 })
             },
-            
+            //查询标签列表
+            getbeenFoundList() {
+                let getListFetch;
+                if (this.type == "type") {
+                    getListFetch = queryEqTypeList
+                } else {
+                    getListFetch = queryEqParamList
+                }
+                console.log(getListFetch)
+                getListFetch({
+                    data: {
+                        ProjectId: this.projectId,
+                        DataSourceId: this.datasourceId
+                    },
+                    type: this.protocolType
+                }, res => {
+                    console.log(res, 'getListFetch')
+                    this.tagList = res.Content
+                })
+            }
         }
     }
 </script>
@@ -120,15 +184,21 @@
                 height: 300px;
                 display: inline-block;
             }
-            .right-view{
+            .right-view {
                 width: calc(100% - 305px);
+                padding: 5px;
+                box-sizing: border-box;
                 height: 300px;
                 overflow-y: auto;
-                display: inline-block;
+                float: right;
             }
         }
         .h10 {
             height: 10px;
         }
+        .find-tags{
+            display: inline-block;
+            margin: 8px;
+        }
     }
 </style>

+ 6 - 1
src/components/el_pack/dialog.vue

@@ -1,7 +1,7 @@
 
 
 <template>
-    <el-dialog :title="title" :close-on-press-escape="escape" :close-on-click-modal="isModel" :visible.sync="dialogVisible" :width="width" :before-close="cancel">
+    <el-dialog :append-to-body="isAppendBody" :title="title" :close-on-press-escape="escape" :close-on-click-modal="isModel" :visible.sync="dialogVisible" :width="width" :before-close="cancel">
         <slot></slot>
         <span v-if="!!footer" slot="footer" class="dialog-footer">
           <el-button @click="cancel">{{footer.cancel ? footer.cancel : "取 消"}}</el-button>
@@ -19,6 +19,7 @@
          * @param isModel  model层点击隐藏dialog,非必填,默认true
          * @param escape  键盘点击esc隐藏dialog,非必填,默认true
          * @param title  表头文案,默认‘必填’
+         * @param isAppendBody 是否嵌入到body
          * 
          * @event cancel 取消事件,父组件必填
          * @event confirm 确定事件,非必填
@@ -48,6 +49,10 @@
             title: {
                 type: String,
                 default: "提示"
+            },
+            isAppendBody: {
+                type: Boolean,
+                default: false
             }
         },
         data() {

+ 4 - 0
src/fetch/fetch.js

@@ -13,9 +13,13 @@ const instance = axios.create({
 instance.interceptors.request.use(config => {
     // 在发送请求之前做些什么,比如传token
     const token = localStorage.getItem('token');
+    const projectId = localStorage.getItem('projectId');
     if (token) {
         config.headers.Authorization = token;
     }
+    if (projectId) {
+        config.headers.ProjectId = projectId;
+    }
     //config.data = JSON.stringify(config.data);
     return config
 }, error => {

+ 12 - 6
src/fetch/point_http.js

@@ -78,20 +78,26 @@ export function findKeysWordType(param, success) {
     return post(`${point}/point/${param.type}/next-equipment-type`, data, success)
 }
 
-//查询设备类型分组列表(涉及点位数)
-export function queryEqTypeList(param, success) {
-    let data = param.data
-    return post(`${point}/point/${param.type}/group-equipment-type-statis`, data, success)
-}
-
 //查询设备类型分组列表(涉及点位数,包含空)
 export function queryAllEqTypeList(param, success) {
     let data = param.data
     return post(`${point}/point/${param.type}/group-equipment-type-statis-all`, data, success)
 }
 
+//查询设备类型分组列表(涉及点位数)
+export function queryEqTypeList(param, success) {
+    let data = param.data
+    return post(`${point}/point/${param.type}/group-equipment-type-statis`, data, success)
+}
+
 //查询设备参数分组列表(含空参数)
 export function queryAllEqParamList(param, success) {
     let data = param.data
     return post(`${point}/point/${param.type}/group-equipment-parameter-all`, data, success)
+}
+
+//查询设备参数分组列表(涉及点位数)
+export function queryEqParamList(param, success) {
+    let data = param.data
+    return post(`${point}/point/${param.type}/group-equipment-parameter`, data, success)
 }

+ 9 - 1
src/store/common/project.js

@@ -1,7 +1,7 @@
 const project_mess = {
     namespaced: true,
     state: {
-        projectId: "1234567890", //项目id
+        projectId: "", //项目id
         datasourceId: "", //数据源id
         protocolType: "", //数据源类型
     },
@@ -26,4 +26,12 @@ const project_mess = {
     }
 }
 
+let projectId = localStorage.getItem('projectId')
+if (!projectId) {
+    localStorage.setItem('projectId', '1234567890')
+    project_mess.state.projectId = '1234567890'
+} else {
+    project_mess.state.projectId = projectId
+}
+
 export default project_mess

+ 0 - 1
src/views/config_point/index.vue

@@ -48,7 +48,6 @@
         methods: {
             getList(){
                 let param = {
-                    Filters: {ProjectId: this.projectId}
                 }
                 queryDataSourceCount(param,res => {
                     console.log(res)

+ 27 - 25
src/views/config_point/steps/step1.vue

@@ -45,26 +45,26 @@
                 "protocolType"
             ])
         },
-        created() {
+        created() {},
+        mounted() {
+            console.log(this.datasourceId, this.protocolType)
             if (!this.protocolType) {
                 this.$router.push({
                     path: "/configPoint"
                 })
+            } else {
+                this.getData()
             }
         },
-        mounted() {
-            console.log(this.datasourceId, this.protocolType)
-            this.getData()
-        },
         methods: {
-            addRow(){
+            addRow() {
                 let data = this.hot.getSourceData()
                 data.unshift({})
                 this.hot.loadData(data)
                 this.hot.updateSettings({
                     maxRows: data.length
                 })
-                console.log(data,this.hot,"data")
+                console.log(data, this.hot, "data")
             },
             getData() {
                 let header, width, param, settings
@@ -96,7 +96,7 @@
             },
             //修改提示
             changeHand(changeData, source) {
-                if(!!changeData){
+                if (!!changeData) {
                     this.changeFlag = false
                 }
                 return false
@@ -105,47 +105,47 @@
             saveData() {
                 if (!!this.hot) {
                     console.log(this.hot.getSourceData())
-                    let data = this.hot.getSourceData(),updateList = [],createList = [];
+                    let data = this.hot.getSourceData(),
+                        updateList = [],
+                        createList = [];
                     data.map(item => {
-                        if(!!item.Id){
+                        if (!!item.Id) {
                             delete item.CreateTime
                             delete item.LastUpdate
                             updateList.push(item)
-                        }else{
+                        } else {
                             createList.push(item)
                         }
                     })
-                    console.log(updateList,"updateList")
-                    if(updateList.length){
+                    console.log(updateList, "updateList")
+                    if (updateList.length) {
                         this.update(updateList)
                     }
-
-                    if(createList.length){
+                    if (createList.length) {
                         this.createList(createList)
                     }
                 } else {
                     this.$message.error("请确保存在数据")
                 }
             },
-            async createList(createList){
+            async createList(createList) {
                 console.log(createList)
                 let i = 0;
-                for(i;i < createList.length;i++){
-                    if(createList[i].hasOwnProperty("Description")){
+                for (i; i < createList.length; i++) {
+                    if (createList[i].hasOwnProperty("Description")) {
                         await this.create(createList[i])
                     }
                 }
                 this.changeFlag = true
             },
-
-            async create(obj){
+            async create(obj) {
                 console.log(obj)
                 obj.DatasourceId = this.datasourceId
                 obj.ProjectId = this.projectId
                 await createPoint({
-                    data:obj,
+                    data: obj,
                     type: this.protocolType
-                    },res => {
+                }, res => {
                     console.log(res)
                     obj.Id = res.Id
                 })
@@ -155,11 +155,13 @@
              * 
              * 更新点位
              */
-            update(updateList){
+            update(updateList) {
                 updatePoint({
-                    data:{Content:updateList},
+                    data: {
+                        Content: updateList
+                    },
                     type: this.protocolType
-                },res => {
+                }, res => {
                     console.log(res)
                 })
             },