Explorar o código

设备属性列表

Signed-off-by: hsshuxian <3049816743@qq.com>
hsshuxian hai 4 meses
pai
achega
b61e148fcb

+ 37 - 19
ems-ui-cloud/src/views/basecfg/device/index.vue

@@ -365,17 +365,20 @@
                 <div slot="header" class="clearfix">
                   <span class="section-title">设备参数</span>
                 </div>
-                <el-table :data="attrData" style="width: 100%" :show-header="true" :empty-text="'暂无数据'">
-                  <el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
-                  <el-table-column label="属性名称" prop="attrName"></el-table-column>
-                  <el-table-column label="属性标识" prop="attrKey"></el-table-column>
-                  <el-table-column label="属性值" prop="attrValue"></el-table-column>
-                  <el-table-column label="属性值描述" prop="attrValueName"></el-table-column>
-                </el-table>
+                <div v-for="(tableData, tableName) in attrTables" :key="tableName">
+                  <p class="section-title">{{ tableData.title }}</p>
+                  <el-table :data="tableData.data" style="width: 100%" :show-header="true" :empty-text="'暂无数据'">
+                    <el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
+                    <el-table-column label="属性名称" prop="attrName"></el-table-column>
+                    <el-table-column label="属性标识" prop="attrKey"></el-table-column>
+                    <el-table-column label="属性值" prop="attrValue"></el-table-column>
+                    <el-table-column label="属性值描述" prop="attrValueName"></el-table-column>
+                  </el-table>
+                </div>
               </el-card>
             </div>
 
-            <!-- 能力定义 -->
+            <!-- 设备能力-->
             <div v-if="activeTab === 'ability'">
               <el-card class="box-card">
                 <div slot="header" class="clearfix">
@@ -391,7 +394,7 @@
               </el-card>
             </div>
 
-            <!-- 事件定义 -->
+            <!-- 设备事件= -->
             <div v-if="activeTab === 'event'">
               <el-card class="box-card">
                 <div slot="header" class="clearfix">
@@ -435,7 +438,8 @@ export default {
       ComponentRow: [],
       componentForm: {},
       subcategoryCode: '',
-      attrList: [], // 属性模板数组
+      // 属性模板数组
+      attrList: [],
       attrValues: [],
       ComponentList: [],
       attrValuesMap: {},
@@ -504,10 +508,18 @@ export default {
 
       ],
       curRow: {},
-      attrData: [],
       abilityData: [],
       eventData: [],
-
+      BaseData: [],
+      ProtocolData: [],
+      StateData: [],
+      MeasureData: [],
+      attrTables: {
+        Base: { title: '基础属性', data: [] },
+        Protocol: { title: '协议属性', data: [] },
+        State: { title: '状态属性', data: [] },
+        Measure: { title: '测量属性', data: [] }
+      },
       // 表单参数
       form: {
         customAttrs: []
@@ -673,7 +685,7 @@ export default {
     componentReset() {
       this.componentForm = {
         id: null,
-        deviceCode: this.ComponentRow.deviceCode || '', // 使用ComponentRow的deviceCode,或者空字符串
+        deviceCode: this.ComponentRow.deviceCode || '',
         compoCode: null,
         compoTag: null,
         psCode: null,
@@ -738,9 +750,11 @@ export default {
         this.abilityData = response.data?.abilityList || [];
       })
       getObjAttr(2, this.curRow.deviceCode).then(response => {
-        this.attrData = response.data.attrs
-
-      })
+        this.attrTables.Base.data = response.data?.Base || [];
+        this.attrTables.Protocol.data = response.data?.Protocol || [];
+        this.attrTables.State.data = response.data?.State || [];
+        this.attrTables.Measure.data = response.data?.Measure || [];
+      });
       this.activeTab = 'basic';
     },
     /** 修改按钮操作 */
@@ -844,8 +858,6 @@ export default {
                     this.$message.error('属性添加失败')
                   }
                 })
-            } else {
-              // this.$message.info('没有属性需要添加');
             }
           }
         }
@@ -894,7 +906,6 @@ export default {
     },
     deviceCategoryChange() {
       this.queryParams.deviceSubCategory = ''
-      //this.queryParams.psCode = null; // 重置设备工艺选择
       if (this.queryParams.deviceCategory === 'E' || this.queryParams.deviceCategory === 'W'
         || this.queryParams.deviceCategory === 'T' || this.queryParams.deviceCategory === 'C') {
         this.getAreaTree('0', false)
@@ -1039,4 +1050,11 @@ export default {
 .detail-dialog .el-dialog {
   width: 80%;
 }
+.section-title {
+  font-size: 16px;
+  font-weight: bold;
+  margin: 10px 0;
+  padding: 5px 0;
+  border-bottom: 1px solid #ebeef5;
+}
 </style>

+ 8 - 5
ems-ui-cloud/src/views/basecfg/device/model.vue

@@ -178,8 +178,8 @@
                 <el-form-item label="属性标识" prop="attrKey">
                   <el-input v-model="attrForm.attrKey" placeholder="请输入属性标识"/>
                 </el-form-item>
-                <el-form-item label="属性类型" prop="attrType">
-                  <el-radio-group v-model="attrForm.attrType" size="medium">
+                <el-form-item label="属性分组" prop="attrGroup">
+                  <el-radio-group v-model="attrForm.attrGroup" size="medium">
                     <el-radio v-for="(item, index) in attrTypeOptions" :key="index" :label="item.value"
                               :disabled="item.disabled">{{item.label}}</el-radio>
                   </el-radio-group>
@@ -411,8 +411,11 @@ export default {
         { code: 2, name: '异常警告' },
       ],
       attrTypeOptions: [
-        { "label": "静态属性", "value": 0},
-        { "label": "动态属性", "value": 1 }
+        { "label": "基础信息", "value":'Base'},
+        { "label": "状态信息", "value": 'State' },
+        { "label": "计量信息", "value": 'Measure'},
+        { "label": "协议信息", "value": 'Protocol'}
+
       ],
       // 查询参数
       queryEventParams: {
@@ -626,7 +629,7 @@ export default {
         id: null,
         modelCode:  this.curRow.modelCode || '',
         attrKey: null,
-        attrType: null,
+        attrGroup: null,
         attrName: null,
         attrValue: null,
         attrUnit: null,

+ 55 - 55
ems-ui-cloud/src/views/devmgr/attr/index.vue

@@ -72,7 +72,21 @@
           <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
             <template slot-scope="scope">
               <el-button size="mini" type="text" icon="el-icon-info" @click="handleDetail(scope.row)">详情</el-button>
-
+              <!-- 下拉菜单 -->
+              <el-dropdown @command="handleOperate(scope.row)">
+                <el-button type="text" size="mini">
+                  操作<i class="el-icon-arrow-down el-icon--right"></i>
+                </el-button>
+                <el-dropdown-menu slot="dropdown">
+                  <el-dropdown-item
+                    v-for="ability in abilityData"
+                    :key="ability.abilityKey"
+                    :command="ability"
+                  >
+                    {{ ability.abilityName }}
+                  </el-dropdown-item>
+                </el-dropdown-menu>
+              </el-dropdown>
             </template>
           </el-table-column>
         </el-table>
@@ -117,16 +131,19 @@
                 <div slot="header" class="clearfix">
                   <span class="section-title">设备参数</span>
                 </div>
-                <el-table :data="attrData" style="width: 100%" :show-header="true" :empty-text="'暂无数据'">
-                  <el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
-                  <el-table-column label="属性名称" prop="attrName"></el-table-column>
-                  <el-table-column label="属性标识" prop="attrKey"></el-table-column>
-                  <el-table-column label="属性值" prop="attrValue"></el-table-column>
-                  <el-table-column label="属性值描述" prop="attrValueName"></el-table-column>
-                </el-table>
+                <div v-for="(tableData, tableName) in attrTables" :key="tableName">
+                  <p class="section-title">{{ tableData.title }}</p>
+                  <el-table :data="tableData.data" style="width: 100%" :show-header="true" :empty-text="'暂无数据'">
+                    <el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
+                    <el-table-column label="属性名称" prop="attrName"></el-table-column>
+                    <el-table-column label="属性标识" prop="attrKey"></el-table-column>
+                    <el-table-column label="属性值" prop="attrValue"></el-table-column>
+                    <el-table-column label="属性值描述" prop="attrValueName"></el-table-column>
+                  </el-table>
+                </div>
               </el-card>
             </div>
-            <!--能力-->
+            <!--设备能力-->
             <div v-if="activeTab === 'ability'">
               <el-card class="box-card">
                 <div slot="header" class="clearfix">
@@ -135,31 +152,16 @@
                 <el-table :data="abilityData" style="width: 100%" :show-header="true" :empty-text="'暂无数据'">
                   <el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
                   <el-table-column label="能力名称" prop="abilityName"></el-table-column>
-                  <el-table-column label="能力键" prop="abilityKey"></el-table-column>
-                  <el-table-column label="能力参数" prop="abilityParam"></el-table-column>
                   <el-table-column label="能力描述" prop="abilityDesc"></el-table-column>
                   <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
-
-
-                      <template slot-scope="scope">
-<!--                       <el-button size="mini" type="text" icon="el-icon-info" @click="handleOpenOperate(scope.row)">开启</el-button>
-                           <el-button size="mini" type="text" icon="el-icon-info" @click="handleColseOperate(scope.row)">关闭</el-button> -->
-                        <el-dropdown size="mini" split-button type="primary" icon="el-icon-info" @command="handleCommand">
-                          操作
-                          <el-dropdown-menu slot="dropdown">
-                            <el-dropdown-item icon="el-icon-plus" command="open" :data="scope.row">执行</el-dropdown-item>
-                            <el-dropdown-item icon="el-icon-circle-plus" command="close" :data="scope.row">关闭</el-dropdown-item>
-                            <el-dropdown-item icon="el-icon-circle-plus-outline">锁定</el-dropdown-item>
-                            <el-dropdown-item icon="el-icon-check">开启</el-dropdown-item>
-                            <el-dropdown-item icon="el-icon-circle-check">执行日志</el-dropdown-item>
-                          </el-dropdown-menu>
-                        </el-dropdown>
+                    <template slot-scope="scope">
+                      <el-button size="mini" type="text" icon="el-icon-info" @click="handleOperate(scope.row)">执行</el-button>
                     </template>
                   </el-table-column>
                 </el-table>
               </el-card>
             </div>
-          <!--事件-->
+          <!--设备事件-->
             <div v-if="activeTab === 'event'">
               <el-card class="box-card">
                 <div slot="header" class="clearfix">
@@ -235,6 +237,16 @@ export default {
       attrData: [],
       abilityData: [],
       eventData: [],
+      BaseData: [],
+      ProtocolData: [],
+      StateData: [],
+      MeasureData: [],
+      attrTables: {
+        Base: { title: '基础属性', data: [] },
+        Protocol: { title: '协议属性', data: [] },
+        State: { title: '状态属性', data: [] },
+        Measure: { title: '测量属性', data: [] }
+      },
       // 查询参数
       queryParams: {
         pageNum: 1,
@@ -255,34 +267,16 @@ export default {
     this.getSubCategorygetByCode()
   },
   methods: {
-    handleCommand(command, row) {
-      if (command === 'open') {
-        this.handleOpenOperate(row);
-      } else if (command === 'close') {
-        this.handleCloseOperate(row);
-      }
-    },
-    /**设备能力-操作按钮*/
-    handleOpenOperate(row) {
-        // 调用接口
-        listcallAbility({
-          abilityKey: 'event-1',
-          objCode: this.curRow.deviceCode,
-          objType:'2',
-          modeCode:this.curRow.modeCode,
-          abilityParam:'{\"type\":\"event\",\"key\":1}',
-        }).then(response => {
-          this.$message({ message: '设备能力执行成功', type: 'success' });
 
-        })
-      },
-    handleCloseOperate(row) {
+    /**设备能力-执行按钮*/
+    handleOperate(row) {
+      console.log("row",row)
       listcallAbility({
-        abilityKey: 'event-0',
+        abilityKey:row.abilityKey,
         objCode: this.curRow.deviceCode,
         objType:'2',
-        modeCode:this.curRow.modeCode,
-        abilityParam:'{\"type\":\"event\",\"key\":0}',
+        modeCode:row.modeCode,
+        abilityParam:row.abilityParam,
       }).then(response => {
         this.$message({ message: '设备能力执行成功', type: 'success' });
 
@@ -323,8 +317,10 @@ export default {
       this.loading = true
       listDevRecursionByArea(this.queryParams).then(response => {
         this.deviceList = response.rows
+        console.log("this.deviceList",this.deviceList)
         this.total = response.total
         this.loading = false
+
       })
     },
     /** 查询区域树结构 */
@@ -366,18 +362,22 @@ export default {
     handleDetail (row) {
       this.reset()
       this.curRow = row
-      console.log('设备data', this.curRow)
+      console.log('设备this.curRow', this.curRow)
       getModelByCode(this.curRow.deviceModel).then(response => {
         this.open = true
         const code = response.data
         console.log('code', code)
         this.eventData = response.data?.eventList || [];
         // 过滤
-        this.abilityData = response.data.abilityList.filter(item => item.hiddenFlag === 1)||[]
+        this.abilityData = response.data?.abilityList.filter(item => item.hiddenFlag === 1) || [];
+        this.attrData=response.data?.attrList || [];
       })
       getObjAttr(2, this.curRow.deviceCode).then(response => {
-        this.attrData = response.data.attrs
-      })
+        this.attrTables.Base.data = response.data?.Base || [];
+        this.attrTables.Protocol.data = response.data?.Protocol || [];
+        this.attrTables.State.data = response.data?.State || [];
+        this.attrTables.Measure.data = response.data?.Measure || [];
+      });
       this.activeTab = 'basic';
     },
     getFacsOptions () {