Bladeren bron

点位配置bug修改

zhangyu 5 jaren geleden
bovenliggende
commit
8fa259cb4d

+ 17 - 5
src/components/config_point/cut_string.vue

@@ -6,11 +6,11 @@
             @click="checkItem(item,index)"
             ref="span"
             :class="{
-                'saga-warning': isWarning(item)
+                'saga-warning': isWarning(index)
             } "
             class="cut-string saga-border pointer border-hover"
           >{{item}}</span>
-</template>
+        </template>
   </div>
 </template>
 <script>
@@ -29,20 +29,30 @@
             return {
                 stringArr: this.string.split(""),
                 obj: {},
-                arr: []
+                arr: [],
+                keywordIndexArr: []
             }
         },
-        created() {},
+        created() {this.recursiveGetIndex(0)},
         mounted() {},
         methods: {
             //是否在危险状态
             isWarning(val){
-                if(this.closedStr.indexOf(val) > -1){
+                if(this.keywordIndexArr.indexOf(val) > -1){
                     return true
                 }else{
                     return false
                 }
             },
+            recursiveGetIndex(start){ //递归获取满足关键字的索引值
+                let index = this.string.indexOf(this.closedStr,start)
+                if(index != -1){
+                    for(let i = 0; i < this.closedStr.length; i++){
+                        this.keywordIndexArr.push(index + i)
+                    }
+                    this.recursiveGetIndex(index + this.closedStr.length)
+                }
+            },
             checkItem(item, index) {
                 if(this.obj.hasOwnProperty(index)){
                     delete this.obj[index]
@@ -90,6 +100,8 @@
         },
         watch: {
             string: function() {
+                this.keywordIndexArr = []
+                this.recursiveGetIndex(0)
                 this.clear()
             }
         }

+ 1 - 1
src/components/config_point/step3_edit/auto_handle.vue

@@ -114,7 +114,7 @@ export default {
             immediate: true,
             handler(val) {
                 if(val){
-                    this.form = val;
+                    this.form = JSON.parse(JSON.stringify(val))
                 }
             }
         }

+ 1 - 1
src/components/config_point/step3_edit/enum_handle.vue

@@ -84,7 +84,7 @@ export default {
             immediate: true,
             handler(val) {
                 if(val) {
-                    this.form = val
+                    this.form = JSON.parse(JSON.stringify(val))
                 }
                 
             }

+ 1 - 1
src/components/config_point/step3_edit/formula_handle.vue

@@ -129,7 +129,7 @@ export default {
             immediate: true,
             handler(val) {
                 if (val) {
-                    this.form = val
+                    this.form = JSON.parse(JSON.stringify(val))
                     if (this.form.cut) {
                         this.subStrVal = true
                         this.from = this.form.cut.from

+ 49 - 11
src/components/config_point/step3_edit/index.vue

@@ -111,7 +111,7 @@ import splitHandle from './split_handle'
 import { mapGetters, mapActions } from 'vuex'
 //api
 import { getEquipmentAll, getQueryProperty } from '@/fetch/data_plat'
-import { batchCreate } from '@/fetch/point_http'
+import { updatePoint, batchCreate } from '@/fetch/point_http'
 export default {
     name: 'point_config_step3_edit',
     computed: {
@@ -161,11 +161,11 @@ export default {
                 }
             ],
             /**值回显******* */
-            noHandleShow: null,
-            autoHandleShow: null,
-            enumHandleShow: null,
-            formulaHandleShow: null,
-            splitHandleShow: null
+            noHandleShow: {},
+            autoHandleShow: {},
+            enumHandleShow: {},
+            formulaHandleShow: {},
+            splitHandleShow: {}
         }
     },
     props: {
@@ -262,12 +262,19 @@ export default {
                 DataSourceId: this.datasourceId,
                 PointId: this.editData.Point.Id //点位ID
             }
+            let updateParams = {
+                data: {
+                    Content:[{ Id: this.editData.Point.Id }]
+                },
+                type: this.protocolType
+            }
             let otherParams = {}
             switch (type) {
                 case '无需处理,直接使用':
                     otherParams = {
                         EquipmentMark: other.EquipmentMark
                     }
+                    updateParams.data.Content[0].EquipmentMark = other.EquipmentMark
                     break
                 case '需自动单位转换':
                     let DataRuleContent1 = JSON.stringify([
@@ -286,6 +293,7 @@ export default {
                         DataRuleContent: DataRuleContent1,
                         EquipmentMark: other.EquipmentMark
                     }
+                    updateParams.data.Content[0].EquipmentMark = other.EquipmentMark
                     break
                 case '需按设置枚举转换':
                     let DataRuleContent2 = other.pointArr.length
@@ -295,6 +303,7 @@ export default {
                         EquipmentMark: other.EquipmentMark,
                         DataRuleContent: DataRuleContent2
                     }
+                    updateParams.data.Content[0].EquipmentMark = other.EquipmentMark
                     break
                 case '需按公式转换':
                     let subRule = other.from
@@ -346,6 +355,7 @@ export default {
                         EquipmentMark: other.EquipmentMark,
                         DataRuleContent: DataRuleContent3
                     }
+                    updateParams.data.Content[0].EquipmentMark = other.EquipmentMark
                     break
                 case '需拆分处理':
                     let SplitPoints = other.devArr.length ? other.devArr : undefined
@@ -372,10 +382,11 @@ export default {
                     otherParams = {
                         SplitPoints: SplitPoints
                     }
+                    updateParams.data.Content[0].EquipmentMark = other.eqMark
                     break
             }
             let params = [Object.assign(basicParams, otherParams)]
-            this.create(params)
+            updatePoint(updateParams, res => { this.create(params) })
         },
         create(params) {
             batchCreate(params, res => {
@@ -503,14 +514,14 @@ export default {
                     switch (flag) {
                         case '无需处理,直接使用':
                             this.noHandleShow = {
-                                EquipmentMark: data.EquipmentMark
+                                EquipmentMark: eqMark
                             }
                             break
                         case '需自动单位转换':
                             dataRules = JSON.parse(data.DataRuleContent)
                             let auto = dataRules[0].content[0].from.split('-')
                             this.autoHandleShow = {
-                                EquipmentMark: data.EquipmentMark,
+                                EquipmentMark: eqMark,
                                 unit: auto
                             }
                             break
@@ -518,7 +529,7 @@ export default {
                             dataRules = JSON.parse(data.DataRuleContent)
                             let pointArr = dataRules[0].content
                             this.enumHandleShow = {
-                                EquipmentMark: data.EquipmentMark,
+                                EquipmentMark: eqMark,
                                 pointArr: pointArr
                             }
                             break
@@ -533,12 +544,30 @@ export default {
                                 count = dataRules[2].content[0]
                             }
                             this.formulaHandleShow = {
-                                EquipmentMark: data.EquipmentMark,
+                                EquipmentMark: eqMark,
                                 cut: cut,
                                 count: count,
                                 extractArr: extractArr
                             }
                             break
+                        case '需拆分处理':
+                            let dataRules = JSON.parse(data.DataRuleContent)
+                            let devArr = val.RelationList.map(ele => {
+                                let arr = JSON.parse(ele.DataRuleContent)
+                                return {
+                                    EquipmentMark: ele.EquipmentMark,
+                                    SplitStart: arr[0].content[0].from,
+                                    SplitEnd: arr[0].content[0].to
+                                }
+                            })
+                            var pointArr = dataRules[1].content
+                            this.splitHandleShow = {
+                                eqMark: eqMark,
+                                EquipmentMark: data.EquipmentMark,
+                                pointArr: pointArr,
+                                devArr: devArr
+                            }
+                            break
                     }
                 } else {
                     let dataRules = JSON.parse(data.DataRuleContent)
@@ -553,6 +582,7 @@ export default {
                     })
                     let pointArr = dataRules[1].content
                     this.splitHandleShow = {
+                        eqMark: eqMark,
                         EquipmentMark: data.EquipmentMark,
                         pointArr: pointArr,
                         devArr: devArr
@@ -563,6 +593,14 @@ export default {
                     EquipmentMark: eqMark
                 }
             }
+            this.noHandleShow.EquipmentMark = eqMark
+            this.autoHandleShow.EquipmentMark = eqMark
+            this.enumHandleShow.EquipmentMark = eqMark
+            this.enumHandleShow.pointArr = this.enumHandleShow.pointArr?this.enumHandleShow.pointArr:[{from: '',to: ''}]
+            this.formulaHandleShow.EquipmentMark = eqMark
+            this.splitHandleShow.eqMark = eqMark
+            this.splitHandleShow.devArr = this.splitHandleShow.devArr?this.splitHandleShow.devArr:[{EquipmentMark: '',SplitStart: 1,SplitEnd: 1}]
+            this.splitHandleShow.pointArr = this.splitHandleShow.pointArr?this.splitHandleShow.pointArr:[{from: '',to: ''}]
         }
     },
     mounted() {

+ 1 - 1
src/components/config_point/step3_edit/no_handle.vue

@@ -43,7 +43,7 @@ export default {
             immediate: true,
             handler(val) {
                 if(val) {
-                    this.form = val
+                    this.form = JSON.parse(JSON.stringify(val))
                 }
                 
             }

+ 5 - 5
src/components/config_point/step3_edit/split_handle.vue

@@ -1,15 +1,15 @@
 <template>
     <div class='edit-box'>
         <el-form v-if='form.devArr.length' class='form' ref='form' :model='form' label-width='140px'>
+            <el-form-item v-if='devFlag' label='原设备标识' prop="eqMark">
+                <el-input v-model='form.eqMark' :disabled="true"></el-input>
+            </el-form-item>
             <div class='dev-know' v-for='(item,index) in form.devArr' :key='index'>
                 <el-form-item
                     v-if='devFlag'
                     label='设备标识'
                     :prop='"devArr." + index + ".EquipmentMark"'
-                    :rules='{
-          required: true, message: "设备标识不能为空", trigger: "blur"
-        }'
-                >
+                    :rules='{required: true, message: "设备标识不能为空", trigger: "blur"}'>
                     <el-input v-model='item.EquipmentMark'></el-input>
                 </el-form-item>
                 <p class='strsub'>
@@ -141,7 +141,7 @@ export default {
             deep: true,
             handler(val) {
                 if (val) {
-                    this.form = val
+                    this.form = JSON.parse(JSON.stringify(val))
                     // console.log(this.form)
                 } else {
                     this.init()

+ 3 - 5
src/components/config_point/step3_point/3_temps.vue

@@ -220,17 +220,15 @@
                         }
                     })
                 })
-                if (magFalg) {
-                    this.confirm("点位中存在空的设备标识", params)
-                } else if (sameFalg) {
-                    this.confirm("点位中存在设备标识相同的点位", params)
+                if (sameFalg) {
+                    this.confirm("点位中存在设备标识相同的点位,确认保存吗?", params)
                 } else {
                     this.createParam(params)
                 }
                 console.log(params)
             },
             confirm(assage, params) {
-                this.$confirm(assage).then(_ => {
+                this.$confirm(assage,{type: 'warning'}).then(_ => {
                     this.createParam(params)
                 }).catch(_ => {})
             },

+ 1 - 1
src/components/dialogs/addDialog/dialogDevice.vue

@@ -26,7 +26,7 @@
               >
                 <i class="el-icon-fa  el-icon-fa-compass"></i>
               </span>
-              <span>当前选择的设备:{{deviceType.facility}}</span>
+              <span>当前选择的设备类型:{{deviceType.facility}}</span>
               <!-- 增加 -->
               <div style="float:right;overflow:hidden;">
                 <span>增加</span>

+ 57 - 10
src/views/point/config_point/steps/step1.vue

@@ -399,22 +399,68 @@
                         }
                     })
                     console.log(updateList,createList, arr1, "updateList")
-                    if (updateList.length) {
-                        this.update(updateList)
-                    }
-                    if (createList.length) {
-                        this.createList(createList)
+                    if (createList.length || updateList.length) {
+                        let flag = true
+                        if (createList.length) {
+                          for (let i = 0; i < createList.length; i++) {
+                            if (!(
+                                (createList[i].hasOwnProperty("SlaveId") &&
+                                 createList[i].SlaveId &&
+                                 createList[i].hasOwnProperty("RegistersAddress") &&
+                                 createList[i].RegistersAddress &&
+                                 createList[i].hasOwnProperty("RegistersQuality") &&
+                                 createList[i].RegistersQuality &&
+                                 createList[i].hasOwnProperty("ConvertType") &&
+                                 createList[i].ConvertType
+                                ) ||
+                                (createList[i].hasOwnProperty("DeviceId") &&
+                                 createList[i].DeviceId &&
+                                 createList[i].hasOwnProperty("InstanceNumber") &&
+                                 createList[i].InstanceNumber &&
+                                 createList[i].hasOwnProperty("DataType") &&
+                                 createList[i].DataType
+                                ) ||
+                                (createList[i].hasOwnProperty("Item") &&
+                                 createList[i].Item
+                                ) ||
+                                (createList[i].hasOwnProperty("GroupAddress") &&
+                                 createList[i].GroupAddress
+                                ) ||
+                                (createList[i].hasOwnProperty("Topic") &&
+                                 createList[i].Topic
+                                ) ||
+                                (createList[i].hasOwnProperty("Exchange") &&
+                                 createList[i].Exchange &&
+                                 createList[i].hasOwnProperty("Type") &&
+                                 createList[i].Type &&
+                                 createList[i].hasOwnProperty("RoutingKey") &&
+                                 createList[i].RoutingKey
+                                )
+                              )) {
+                                this.$message("请输入所有必填字段(带“*”列为必填列)")
+                                flag = false
+                                return false
+                            } else if (!(createList[i].hasOwnProperty("Description") && createList[i].Description)) {
+                               this.$message("请输入全部的原始点位描述")
+                               flag = false
+                               return false
+                            }
+                          } 
+                        }
+                        if (flag) {
+                            this.createList(createList)
+                            if (updateList.length) {
+                                this.update(updateList)
+                            }
+                        }
                     }
                 } else {
                     this.$message.error("请确保存在数据")
                 }
             },
             async createList(createList) {
-                let i = 0;
-                for (i; i < createList.length; i++) {
-                    if (createList[i].hasOwnProperty("Description")) {
-                        await this.create(createList[i])
-                    }
+                for (let i = 0; i < createList.length; i++) {
+                    await this.create(createList[i])
                 }
                 this.changeFlag = true
             },
@@ -500,6 +546,7 @@
         flex: 1;
         display: flex;
         flex-flow: column;
+        padding-bottom: 10px;
         .btns-view {
             height: 40px;
             line-height: 40px;

+ 1 - 0
src/views/point/config_point/steps/step2.vue

@@ -421,6 +421,7 @@
         flex: 1;
         display: flex;
         flex-flow: column;
+        padding-bottom: 10px;
         .btns-view {
             height: 40px;
             line-height: 40px;

+ 2 - 1
src/views/point/config_point/steps/step3.vue

@@ -140,7 +140,7 @@
             },
             closeEdit() {
                 this.isEditDialogShow = false;
-                THIS.getData()
+                this.getData()
             },
             //初始化表格实例
             getData() {
@@ -204,6 +204,7 @@
         flex: 1;
         display: flex;
         flex-flow: column;
+        padding-bottom: 10px;
         .btns-view {
             height: 40px;
             line-height: 40px;