ソースを参照

添加关键字部分接口

chuwu 6 年 前
コミット
6cd343422d

+ 85 - 3
src/components/config_point/find_keyword.vue

@@ -25,13 +25,14 @@
                     <el-tag
                         :key="title == 'type' ? tag.EquipmentType : tag.EquipmentType"
                         @click="changeName(tag)"
+                        @close="closeTag(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">
+        <my-dialog :dialogVisible="reNameDialog" @confirm="reNameConfirm" :footer="footer" @cancel="cancel" title="重命名" :isAppendBody="true">
             <h3 class="center">{{name}}</h3>
             <el-input v-model="newName" placeholder="请输入新名称"></el-input>
         </my-dialog>
@@ -46,7 +47,13 @@
         findKeysWordType,
         queryDataSourceCount,
         queryEqTypeList,
-        queryEqParamList
+        queryEqParamList,
+        renameType,
+        renameParam,
+        setParamTer,
+        setTypeTer,
+        delParamTer,
+        delTypeTer
     } from "fetch/point_http"
     import {
         mapGetters,
@@ -88,8 +95,63 @@
         created() {},
         mounted() {},
         methods: {
+            //继续发现关键字
             getCutString() {
                 console.log(this.$refs.cutString.getData())
+                if(!this.$refs.cutString.getData()){
+                    this.$message.error("请确定当前有选择关键字")
+                    return false
+                }
+                let setNameFun;
+                if (this.type == "type") {
+                    setNameFun = setTypeTer
+                } else {
+                    setNameFun = setParamTer
+                }
+                setNameFun({
+                    data: {
+                        DataSourceId: this.datasourceId,
+                        Key: this.$refs.cutString.getData()
+                    },
+                    type: this.protocolType
+                },res => {
+                    this.$message.success("添加成功")
+                    this.changeType()
+                })
+            },
+            //取消
+            cancel(){
+                this.reNameDialog = false
+            },
+
+            //关闭标签(删除)
+            closeTag(tag){
+                console.log(tag)
+                let delFun;
+                 if (this.type == "type") {
+                    delFun = delTypeTer
+                } else {
+                    delFun = delParamTer
+                }
+                let param = {
+                    data: {
+                        DataSourceId: this.datasourceId,
+                        Key: this.type == "type" ? tag.EquipmentType : tag.EquipmentType
+                    },
+                    type: this.protocolType
+                }
+                this.$confirm("你确定删除该标签?").then(_ =>{
+                    this.delAjax(param,delFun)
+                }).catch(_ =>{
+
+                })
+            },
+
+            delAjax(param,fun){
+                fun(param,res => {
+                    this.$message.success("删除标签成功")
+                    this.changeType()
+                })
             },
             //点击事件,重命名
             changeName(tag){
@@ -102,6 +164,27 @@
                     this.name = tag.EquipmentType
                 }
             },
+            //确定修改名字
+            reNameConfirm(){
+                let reNameFun;
+                if (this.type == "type") {
+                    reNameFun = renameType
+                } else {
+                    reNameFun = renameParam
+                }
+                reNameFun({
+                    data: {
+                        DataSourceId: this.datasourceId,
+                        KeyNew: this.newName,
+                        KeyOld: this.name
+                    },
+                    type: this.protocolType
+                },res => {
+                    this.$message.success("修改成功")
+                    this.changeType()
+                    this.cancel()
+                })
+            },
             //获取文字
             changeType() {
                 let queryFun
@@ -134,7 +217,6 @@
                         Id: this.datasourceId
                     }
                 }, res => {
-                    console.log(res, "res")
                     let data = res.Content[0]
                     this.echartsData = [{
                             name: "无法识别-" + data.Ignorestandard,

+ 35 - 0
src/fetch/point_http.js

@@ -100,4 +100,39 @@ export function queryAllEqParamList(param, success) {
 export function queryEqParamList(param, success) {
     let data = param.data
     return post(`${point}/point/${param.type}/group-equipment-parameter`, data, success)
+}
+
+///重命名关键字(设备参数)
+export function renameParam(param, success) {
+    let data = param.data
+    return post(`${point}/point/${param.type}/rename-equipment-parameter`, data, success)
+}
+
+///重命名关键字(设备类型)
+export function renameType(param, success) {
+    let data = param.data
+    return post(`${point}/point/${param.type}/rename-equipment-type`, data, success)
+}
+
+//设定关键字(设备参数)
+export function setParamTer(param, success) {
+    let data = param.data
+    return post(`${point}/point/${param.type}/set-equipment-parameter`, data, success)
+}
+
+//设定关键字(设备类型)
+export function setTypeTer(param, success) {
+    let data = param.data
+    return post(`${point}/point/${param.type}/set-equipment-type`, data, success)
+}
+
+//删除关键字(设备参数)
+export function delParamTer(param, success) {
+    let data = param.data
+    return post(`${point}/point/${param.type}/delete-equipment-parameter`, data, success)
+}
+//删除关键字(设备类型)
+export function delTypeTer(param, success) {
+    let data = param.data
+    return post(`${point}/point/${param.type}/delete-equipment-type`, data, success)
 }

+ 2 - 2
src/store/common/project.js

@@ -2,8 +2,8 @@ const project_mess = {
     namespaced: true,
     state: {
         projectId: "", //项目id
-        datasourceId: "", //数据源id
-        protocolType: "", //数据源类型
+        datasourceId: "4", //数据源id
+        protocolType: "amqp", //数据源类型
     },
     mutations: {
         set_project(state, val) {

+ 63 - 8
src/views/config_point/steps/step2.vue

@@ -6,13 +6,13 @@
             <el-button @click="discern(2)">批量识别设备参数关键字</el-button>
             <el-button @click="examine">检查&微调</el-button>
             <el-button>刷新</el-button>
-            <el-button>保存</el-button>
+            <el-button @click="saveData">保存</el-button>
         </div>
         <div id="handsontableSteps1">
             <handsontable-component ref="handsontable"></handsontable-component>
         </div>
         <own-dialog :width="'60%'" :title="title" :dialogVisible="isDialogShow" @cancel="close">
-            <find-keyword ref="findKeyword" :type="type"></find-keyword>
+            <find-keyword ref="findKeyword" :type="type" @change="changeHand"></find-keyword>
         </own-dialog>
         <own-dialog :width="'1000px'" :index="true" title="关键内容设别——检查&微调" :dialogVisible="examineDialog" @cancel="close">
             <!-- <find-keyword ref="findKeyword" :type="type"></find-keyword> -->
@@ -34,7 +34,8 @@
         mapActions
     } from "vuex";
     import {
-        queryPoint
+        queryPoint,
+        updatePoint
     } from "fetch/point_http"
     import findKeyword from "components/config_point/find_keyword"
     export default {
@@ -47,7 +48,8 @@
                 hot: null,
                 title: "",
                 type: "",
-                examineDialog: false
+                examineDialog: false,
+                changeFlag: true,
             }
         },
         created() {
@@ -80,6 +82,7 @@
                     this.title = "关键内同识别——批量识别设备参数关键字"
                     this.type = "arguments"
                 }
+                this.isChangeData()
                 this.isDialogShow = true
                 this.$nextTick(() => {
                     this.$refs.findKeyword.changeType()
@@ -88,12 +91,64 @@
             close() {
                 this.isDialogShow = false
                 this.examineDialog = false
+                this.isChangeData()
+            },
+
+            //判断是否修改,修改调用修改接口,否则调用获取最新数据
+            isChangeData(){
+                if (!this.changeFlag) {
+                    this.saveData(false)
+                } else {
+                    this.getData()
+                }
             },
             //点击检查按钮
-            examine(){
+            examine() {
+                this.isChangeData()
                 this.examineDialog = true
             },
-
+            //保存
+            saveData(falg) {
+                if (!!this.hot) {
+                    console.log(this.hot.getSourceData())
+                    let data = this.hot.getSourceData(),
+                        changeData;
+                    changeData = data.map(item => {
+                        return {
+                            Id: item.Id,
+                            DatasourceId: item.DatasourceId,
+                            ProjectId: item.ProjectId,
+                            Description: item.Description || null,
+                            KeyEquipmentParameter: item.KeyEquipmentParameter || null,
+                            Remarks: item.Remarks || null,
+                            LocationFlag: item.LocationFlag || null,
+                            KeyEquipmentType: item.KeyEquipmentType || null
+                        }
+                    })
+                    console.log(changeData)
+                    updatePoint({
+                        data: {
+                            Content: changeData
+                        },
+                        type: this.protocolType
+                    }, res => {
+                        console.log(res)
+                        if (!falg) {
+                            this.$message.success("保存成功")
+                        }
+                        this.getData()
+                    })
+                } else {
+                    this.$message.error("请确保存在数据")
+                }
+            },
+            //发生更改
+            changeHand(changeData, source) {
+                if (!!changeData) {
+                    this.changeFlag = false
+                }
+                return false
+            },
             //获取初始数据
             getData() {
                 let width, param, settings
@@ -122,8 +177,8 @@
                     console.log(this.hot)
                 })
             },
-            noSaveData(){
-                return true
+            noSaveData() {
+                return this.changeFlag
             }
         },
         components: {