浏览代码

设备详情中设备功能没有列表时候增加空提示

yanglzh 2 年之前
父节点
当前提交
78e8dd2524
共有 2 个文件被更改,包括 14 次插入5 次删除
  1. 13 4
      src/views/iot/device/instance/component/function.vue
  2. 1 1
      src/views/iot/device/instance/detail.vue

+ 13 - 4
src/views/iot/device/instance/component/function.vue

@@ -1,5 +1,6 @@
 <template>
 	<div class="device-function">
+		<el-empty description="暂无功能列表,请先在物模型的功能定义中添加" v-if="!loading && !list.length"></el-empty>
 		<el-tabs tab-position="left">
 			<el-tab-pane :label="item.name" v-for="item in list" :key="item.key">
 				<div class="table-wrapper">
@@ -47,11 +48,19 @@ interface IListItem {
 }
 
 const list = ref<IListItem[]>([])
+const loading = ref(true)
+
+getData()
+
+function getData() {
+	loading.value = true
+	api.tabDeviceFucntion.getList({ key: props.productKey }).then((res: IListItem[]) => {
+		if (!res) return
+		res.forEach((item) => (item.result = ''))
+		list.value = res
+	}).finally(() => loading.value = false)
+}
 
-api.tabDeviceFucntion.getList({ key: props.productKey }).then((res: IListItem[]) => {
-	res.forEach((item) => (item.result = ''))
-	list.value = res
-})
 
 function run(row: IListItem) {
 	row.result = ''

+ 1 - 1
src/views/iot/device/instance/detail.vue

@@ -239,7 +239,7 @@
           </div>
         </el-tab-pane>
         <el-tab-pane label="设备功能" name="5">
-          <functionCom :device-key="detail.key" :product-key="prodetail.key"  v-if="detail.key && prodetail.key"></functionCom>
+          <functionCom :device-key="detail.key" :product-key="prodetail.key"  v-if="detail.key && prodetail.key && activeName==='5'"></functionCom>
         </el-tab-pane>
         <el-tab-pane label="日志管理" name="4">
           <div class="system-user-search mb15">