Przeglądaj źródła

feat: 修复场景记录列表的显示,修复场景详情报错,增加loading优化显示效果

yanglzh 1 rok temu
rodzic
commit
016321072a

+ 13 - 9
src/views/iot/scene/list/index.vue

@@ -27,18 +27,21 @@
 			</el-form>
 			<el-table :data="tableData" style="width: 100%" row-key="id" v-loading="loading">
 				<el-table-column prop="id" label="ID" width="100" show-overflow-tooltip></el-table-column>
-				<el-table-column prop="name" label="场景名称" show-overflow-tooltip></el-table-column>
-				<el-table-column prop="name" label="场景类型" show-overflow-tooltip></el-table-column>
-				<el-table-column prop="name" label="执行状态" width="100" align="center">
+				<el-table-column prop="sceneId" label="场景ID" width="150" show-overflow-tooltip></el-table-column>
+				<el-table-column prop="runStatus" label="执行状态" width="150" align="center">
 					<template #default="scope">
-						<el-tag type="success" size="small" v-if="scope.row.status">成功</el-tag>
+						<el-tag type="success" size="small" v-if="scope.row.runStatus === '1'">成功</el-tag>
 						<el-tag type="info" size="small" v-else>失败</el-tag>
 					</template>
 				</el-table-column>
-				<el-table-column prop="createdAt" label="执行时间" min-width="100" align="center"></el-table-column>
-				<el-table-column label="操作" width="200" align="center">
+				<el-table-column prop="runTime" label="执行时间" width="170" align="center"></el-table-column>
+				<el-table-column prop="runResult" label="执行结果" align="center" show-overflow-tooltip>
+					<template #default="scope">
+						{{ scope.row.runResult }}
+					</template>
+				</el-table-column>
+				<el-table-column label="操作" width="100" align="center">
 					<template #default="scope">
-						<el-button size="small" text type="primary" v-if="!scope.row.folderName" @click="view(scope.row)">详情</el-button>
 						<el-button size="small" text type="info" v-auth="'del'" @click="del(scope.row)">删除</el-button>
 					</template>
 				</el-table-column>
@@ -54,14 +57,15 @@ import { useSearch } from '/@/hooks/useCommon';
 import { ElMessageBox, ElMessage } from 'element-plus';
 import { ref } from 'vue';
 const queryRef = ref();
-const { params, tableData, getList, loading } = useSearch<any[]>(api.log.getList, 'data', { keyWord: '' });
+const { params, tableData, getList, loading } = useSearch<any[]>(api.log.getList, 'Data', { keyWord: '' });
+
 getList();
 
 const view = (row: any) => {
 };
 
 const del = (row: any) => {
-	ElMessageBox.confirm(`此操作将删除场景:“${row.name}”,是否继续?`, '提示', {
+	ElMessageBox.confirm(`此操作将删除日志ID为“${row.id}”的记录,是否继续?`, '提示', {
 		confirmButtonText: '确认',
 		cancelButtonText: '取消',
 		type: 'warning',

+ 6 - 4
src/views/iot/scene/manage/component/actionItem.vue

@@ -1,5 +1,5 @@
 <template>
-  <div class="type-item">
+  <div class="type-item" v-loading="loading">
     <div v-for="(item, index) in actionList" :key="index" class="item " :class="index > 0 ? 'biankang' : ''">
       <div class="conicon" style="width: 100%; text-align: right; position: relative; right: -8px; top: -8px; color: red" v-if="index > 0">
         <el-icon @click="delAction(index)">
@@ -37,7 +37,7 @@ import ActionSerialItem from './actionSerialItem.vue';
 import ActionParallelItem from './actionParallelItem.vue';
 import api from '/@/api/scene';
 
-
+const loading = ref(false)
 //初始化数据
 const actionList_temp = ref([{
   serial: [{}],
@@ -68,6 +68,7 @@ const props = defineProps({
 })
 
 const getOneDetail = () => {
+  loading.value = true
   api.manage.getOneDetail({ "sceneId": props.scene_id, 'group': 'action' }).then((res: any) => {
     if (!res) {
       addActionDetail();
@@ -92,7 +93,9 @@ const getOneDetail = () => {
       }
     });
     actionList.value = combinedArray;
-  })
+  }).finally(() => {
+    loading.value = false;
+  });
 };
 getOneDetail();
 
@@ -195,4 +198,3 @@ const delAction = (index: number) => {
 
 }
 </style>
-

+ 25 - 29
src/views/iot/scene/manage/component/actionParallelItem.vue

@@ -1,14 +1,12 @@
-
 <template>
   <div class="type-item">
     <div v-for="(item, index) in parallel" :key="index" class="item " :class="index > 0 ? 'biankang' : ''">
-      <div class="conicon" style="width: 100%; text-align: right; position: relative; right: -8px; top: -8px; color: red"
-        v-if="index > 0">
+      <div class="conicon" style="width: 100%; text-align: right; position: relative; right: -8px; top: -8px; color: red" v-if="index > 0">
         <el-icon @click="delScene(index)">
           <CircleClose />
         </el-icon>
       </div>
-      <div class="product flex flex-warp">
+      <div class="product flex flex-warp" v-if="item?.actionType">
         <el-form-item label="动作类型:" prop="actionType">
           <el-select v-model="item.actionType" filterable clearable placeholder="请选择动作类型" @change="saveData">
             <el-option v-for="it in sence_action_type" :key="it.value" :label="it.label" :value="it.value">
@@ -17,25 +15,24 @@
             </el-option>
           </el-select>
         </el-form-item>
-        <DeviceOut :index="index" :data="parallel[index]" :sourceData="sourceData" v-if="item.actionType==='deviceOutput' && parallel[index] && sourceData.length>0" @SetSaveData="SetSaveData"></DeviceOut>
-        <SendNotice  :index="index" :data="parallel[index]" v-if="item.actionType==='sendNotice'  && parallel[index]"  @SetSaveData="SetSaveData"></SendNotice>
-        <CallWebService :index="index" :data="parallel[index]"  v-if="item.actionType==='callWebService'  && parallel[index]"  @SetSaveData="SetSaveData"></CallWebService>
-        <TriggerAlarm :index="index" :data="parallel[index]"  v-if="item.actionType==='triggerAlarm'  && parallel[index]"  @SetSaveData="SetSaveData"></TriggerAlarm>
-        <DelayExecution  :index="index" :data="parallel[index]" v-if="item.actionType==='delayExecution'  && parallel[index]"  @SetSaveData="SetSaveData"></DelayExecution>
-        <TriggerCustomEvent :index="index" :data="parallel[index]"  v-if="item.actionType==='triggerCustomEvent'  && parallel[index]"  @SetSaveData="SetSaveData"></TriggerCustomEvent>
+        <DeviceOut :index="index" :data="parallel[index]" :sourceData="sourceData" v-if="item.actionType === 'deviceOutput' && parallel[index] && sourceData.length > 0" @SetSaveData="SetSaveData"></DeviceOut>
+        <SendNotice :index="index" :data="parallel[index]" v-else-if="item.actionType === 'sendNotice' && parallel[index]" @SetSaveData="SetSaveData"></SendNotice>
+        <CallWebService :index="index" :data="parallel[index]" v-else-if="item.actionType === 'callWebService' && parallel[index]" @SetSaveData="SetSaveData"></CallWebService>
+        <TriggerAlarm :index="index" :data="parallel[index]" v-else-if="item.actionType === 'triggerAlarm' && parallel[index]" @SetSaveData="SetSaveData"></TriggerAlarm>
+        <DelayExecution :index="index" :data="parallel[index]" v-else-if="item.actionType === 'delayExecution' && parallel[index]" @SetSaveData="SetSaveData"></DelayExecution>
+        <TriggerCustomEvent :index="index" :data="parallel[index]" v-else-if="item.actionType === 'triggerCustomEvent' && parallel[index]" @SetSaveData="SetSaveData"></TriggerCustomEvent>
       </div>
     </div>
     <div>
       <div class=" flex-center">
-        <el-button :icon="DocumentAdd" @click="addScene()"
-          style="border: 1px solid #409eff;color: #409eff;">新增串行动作</el-button>
+        <el-button :icon="DocumentAdd" @click="addScene()" style="border: 1px solid #409eff;color: #409eff;">新增串行动作</el-button>
       </div>
     </div>
   </div>
 </template>
 
 <script lang="ts" setup>
-import { PropType, ref, watch, getCurrentInstance  } from 'vue'
+import { PropType, ref, watch, getCurrentInstance } from 'vue'
 import { DocumentAdd, CircleClose } from '@element-plus/icons-vue';
 import DeviceOut from './actionType/deviceOut.vue';
 import SendNotice from './actionType/sendNotice.vue';
@@ -49,7 +46,7 @@ const { proxy } = getCurrentInstance() as any;
 const { sence_action_type } = proxy.useDict('sence_action_type');
 
 interface IValueType {
-  actionType?:string;
+  actionType?: string;
 }
 interface testIValueType {
   key?: string;
@@ -67,18 +64,18 @@ const props = defineProps({
     default: () => []
   },
   index: {
-    type: Number ,
+    type: Number,
     default: () => []
   }
 })
 const parallelValue = ref(props.parallel);
 
-const saveData=()=>{
-  let newData={
-    index:props.index,
-    data:props.parallel,
+const saveData = () => {
+  let newData = {
+    index: props.index,
+    data: props.parallel,
   }
-  emit('saveData',newData);
+  emit('saveData', newData);
 }
 watch(() => props.parallel, (newSerial) => {
   parallelValue.value = newSerial;
@@ -87,11 +84,11 @@ watch(() => props.parallel, (newSerial) => {
 
 
 
-const SetSaveData = (data:any) => {
+const SetSaveData = (data: any) => {
   parallelValue.value[data.index] = data.data;
-  let newData={
-    index:props.index,
-    data:parallelValue.value,
+  let newData = {
+    index: props.index,
+    data: parallelValue.value,
   }
   emit('saveData', newData);
 }
@@ -102,11 +99,11 @@ const addScene = () => {
 };
 const delScene = (index: number) => {
   props.parallel.splice(index, 1);
-  let newData={
-    index:props.index,
-    data:props.parallel,
+  let newData = {
+    index: props.index,
+    data: props.parallel,
   }
-  emit('saveData',newData);
+  emit('saveData', newData);
 }
 
 
@@ -164,4 +161,3 @@ const delScene = (index: number) => {
 
 }
 </style>
-

+ 25 - 29
src/views/iot/scene/manage/component/actionSerialItem.vue

@@ -1,14 +1,12 @@
-
 <template>
   <div class="type-item">
     <div v-for="(item, index) in serial" :key="index" class="item " :class="index > 0 ? 'biankang' : ''">
-      <div class="conicon" style="width: 100%; text-align: right; position: relative; right: -8px; top: -8px; color: red"
-        v-if="index > 0">
+      <div class="conicon" style="width: 100%; text-align: right; position: relative; right: -8px; top: -8px; color: red" v-if="index > 0">
         <el-icon @click="delScene(index)">
           <CircleClose />
         </el-icon>
       </div>
-      <div class="product flex flex-warp">
+      <div class="product flex flex-warp" v-if="item?.actionType">
         <el-form-item label="动作类型:" prop="actionType">
           <el-select v-model="item.actionType" filterable clearable placeholder="请选择动作类型" @change="saveData">
             <el-option v-for="it in sence_action_type" :key="it.value" :label="it.label" :value="it.value">
@@ -17,25 +15,24 @@
             </el-option>
           </el-select>
         </el-form-item>
-        <DeviceOut :index="index" :data="serial[index]" :sourceData="sourceData" v-if="item.actionType==='deviceOutput' && serial[index] && sourceData.length>0" @SetSaveData="SetSaveData"></DeviceOut>
-        <SendNotice  :index="index" :data="serial[index]" v-if="item.actionType==='sendNotice'  && serial[index]"  @SetSaveData="SetSaveData"></SendNotice>
-        <CallWebService :index="index" :data="serial[index]"  v-if="item.actionType==='callWebService'  && serial[index]"  @SetSaveData="SetSaveData"></CallWebService>
-        <TriggerAlarm :index="index" :data="serial[index]"  v-if="item.actionType==='triggerAlarm'  && serial[index]"  @SetSaveData="SetSaveData"></TriggerAlarm>
-        <DelayExecution  :index="index" :data="serial[index]" v-if="item.actionType==='delayExecution'  && serial[index]"  @SetSaveData="SetSaveData"></DelayExecution>
-        <TriggerCustomEvent :index="index" :data="serial[index]"  v-if="item.actionType==='triggerCustomEvent'  && serial[index]"  @SetSaveData="SetSaveData"></TriggerCustomEvent>
+        <DeviceOut :index="index" :data="serial[index]" :sourceData="sourceData" v-if="item.actionType === 'deviceOutput' && serial[index] && sourceData.length > 0" @SetSaveData="SetSaveData"></DeviceOut>
+        <SendNotice :index="index" :data="serial[index]" v-else-if="item.actionType === 'sendNotice' && serial[index]" @SetSaveData="SetSaveData"></SendNotice>
+        <CallWebService :index="index" :data="serial[index]" v-else-if="item.actionType === 'callWebService' && serial[index]" @SetSaveData="SetSaveData"></CallWebService>
+        <TriggerAlarm :index="index" :data="serial[index]" v-else-if="item.actionType === 'triggerAlarm' && serial[index]" @SetSaveData="SetSaveData"></TriggerAlarm>
+        <DelayExecution :index="index" :data="serial[index]" v-else-if="item.actionType === 'delayExecution' && serial[index]" @SetSaveData="SetSaveData"></DelayExecution>
+        <TriggerCustomEvent :index="index" :data="serial[index]" v-else-if="item.actionType === 'triggerCustomEvent' && serial[index]" @SetSaveData="SetSaveData"></TriggerCustomEvent>
       </div>
     </div>
     <div>
       <div class=" flex-center">
-        <el-button :icon="DocumentAdd" @click="addScene()"
-          style="border: 1px solid #409eff;color: #409eff;">新增串行动作</el-button>
+        <el-button :icon="DocumentAdd" @click="addScene()" style="border: 1px solid #409eff;color: #409eff;">新增串行动作</el-button>
       </div>
     </div>
   </div>
 </template>
 
 <script lang="ts" setup>
-import { PropType, ref, watch, getCurrentInstance  } from 'vue'
+import { PropType, ref, watch, getCurrentInstance } from 'vue'
 import { DocumentAdd, CircleClose } from '@element-plus/icons-vue';
 import DeviceOut from './actionType/deviceOut.vue';
 import SendNotice from './actionType/sendNotice.vue';
@@ -49,7 +46,7 @@ const { proxy } = getCurrentInstance() as any;
 const { sence_action_type } = proxy.useDict('sence_action_type');
 
 interface IValueType {
-  actionType?:string;
+  actionType?: string;
 }
 interface testIValueType {
   key?: string;
@@ -68,28 +65,28 @@ const props = defineProps({
     default: () => []
   },
   index: {
-    type: Number ,
+    type: Number,
     default: () => []
   }
 })
 const serialValue = ref(props.serial);
 
-const saveData=()=>{
-  let newData={
-    index:props.index,
-    data:props.serial,
+const saveData = () => {
+  let newData = {
+    index: props.index,
+    data: props.serial,
   }
-  emit('saveData',newData);
+  emit('saveData', newData);
 }
 watch(() => props.serial, (newSerial) => {
   serialValue.value = newSerial;
 });
 
-const SetSaveData = (data:any) => {
+const SetSaveData = (data: any) => {
   serialValue.value[data.index] = data.data;
-  let newData={
-    index:props.index,
-    data:serialValue.value,
+  let newData = {
+    index: props.index,
+    data: serialValue.value,
   }
   emit('saveData', newData);
 }
@@ -100,11 +97,11 @@ const addScene = () => {
 };
 const delScene = (index: number) => {
   props.serial.splice(index, 1);
-  let newData={
-    index:props.index,
-    data:props.serial,
+  let newData = {
+    index: props.index,
+    data: props.serial,
   }
-  emit('saveData',newData);
+  emit('saveData', newData);
 }
 
 </script>
@@ -160,4 +157,3 @@ const delScene = (index: number) => {
 
 }
 </style>
-

+ 7 - 4
src/views/iot/scene/manage/component/sceneItem.vue

@@ -1,5 +1,5 @@
 <template>
-  <div class="type-item">
+  <div class="type-item" v-loading="loading">
     <div v-for="(item, index) in sceneList" :key="index" class="item " :class="index > 0 ? 'biankang' : ''">
       <div class="conicon" style="width: 100%; text-align: right; position: relative; right: -8px; top: -8px; color: red" v-if="index > 0">
         <el-icon @click="delScene(index)">
@@ -61,8 +61,8 @@
 </template>
 
 <script lang="ts" setup>
-import { PropType, ref, unref, reactive, getCurrentInstance } from 'vue'
-import { DocumentAdd, CircleClose, Right } from '@element-plus/icons-vue';
+import { PropType, ref, getCurrentInstance } from 'vue'
+import { DocumentAdd, CircleClose } from '@element-plus/icons-vue';
 import vue3cron from '/@/components/vue3cron/vue3cron.vue';
 import api from '/@/api/scene';
 import product from '/@/api/device';
@@ -76,6 +76,7 @@ const { sence_source_type } = proxy.useDict('sence_source_type');
 
 const emit = defineEmits(['addScenesDetail', 'delScenesDetail', 'editScenesDetail']);
 const dialogVisible = ref();
+const loading = ref(false);
 const deviceListData = ref<testIValueType[]>([]);
 const functionCallList = ref<testIValueType[]>([]);
 const propertyCallList = ref<testIValueType[]>([]);
@@ -185,10 +186,13 @@ const getcolumns = (index: number, val: string) => {
   getcolumnsList(where);
 }
 const getcolumnsList = (where: any) => {
+  loading.value = true
   api.manage.getColumns(where).then((res: any) => {
     if (res) {
       columnList.value = res;
     }
+  }).finally(() => {
+    loading.value = false
   })
 }
 const addScene = () => {
@@ -297,4 +301,3 @@ intScenel();
   }
 }
 </style>
-

+ 7 - 6
src/views/iot/scene/manage/detail.vue

@@ -1,5 +1,5 @@
 <template>
-	<div>
+	<div v-loading="loading">
 		<el-card class="system-dic-container" shadow="nover" style="position: relative;">
 			<div class="content">
 				<div class="flex cont_box">
@@ -80,6 +80,7 @@ export default defineComponent({
 			dialogVisible: false,
 			developer_status: 2,
 			showstatus: false,
+			loading: false,
 			typeList: {
 				'device': '设备触发',
 				'manual': '手动触发',
@@ -133,11 +134,13 @@ export default defineComponent({
 		}
 		const activeName = ref('first')
 		const getDetail = () => {
+			state.loading = true
 			const id = route.params && route.params.id;
 			api.manage.getDetail({ "id": id }).then((res: any) => {
 				state.detail = res
 				getOneDetail();
-
+			}).catch(() => {
+				state.loading = false
 			})
 		};
 		const getProductList = () => {
@@ -164,6 +167,8 @@ export default defineComponent({
 					});
 					state.sceneList = scenes;
 					state.showstatus = true;
+				}).finally(() => {
+					state.loading = false
 				})
 			}
 			//定时触发
@@ -185,11 +190,7 @@ export default defineComponent({
 
 				})
 			}
-
 			getProductList();
-
-
-
 		};
 		//新增一条场景定义
 		const addScenesDetail = (type: String) => {