Преглед на файлове

feat: 增加场景详情的防抖设置功能

yanglzh преди 1 година
родител
ревизия
2cef8b7def
променени са 3 файла, в които са добавени 37 реда и са изтрити 11 реда
  1. 17 2
      src/views/iot/scene/manage/component/sceneItem.vue
  2. 19 8
      src/views/iot/scene/manage/detail.vue
  3. 1 1
      src/views/iot/scene/manage/index.vue

+ 17 - 2
src/views/iot/scene/manage/component/sceneItem.vue

@@ -49,6 +49,15 @@
         <div class="icon"></div> 触发条件 <div class="ml10"> <el-switch v-model="item.triggerSwitch" @change="EditPen(index)" />
         </div>
       </div>
+      <div class="title flex">
+        <div class="icon"></div> 防抖设置
+        <div class="ml10"></div>
+        <el-switch v-model="item.enableStabilization" @change="EditPen(index)" />
+        <template v-if="item.enableStabilization">
+          <el-input v-model="item.stabilization.timeWindow" @change="EditPen(index)" style="width: 100px;margin: 0 12px"></el-input>秒内发送
+          <el-input v-model="item.stabilization.threshold" @change="EditPen(index)" style="width: 100px;margin: 0 12px"></el-input>次及以上,执行以下动作
+        </template>
+      </div>
       <Condition :condition="item.condition" :operate_index="index" :columnList="columnList" v-if="item.triggerSwitch && columnList.length > 0" @EditPen="EditPen">
       </Condition>
     </div>
@@ -94,6 +103,8 @@ interface IValueType {
   triggerSwitch?: boolean;
   timer?: string;
   condition?: IConditionItem[][]; // 更新这里的类型定义
+  enableStabilization: boolean;
+  stabilization: any
 }
 interface testIValueType {
   id: string;
@@ -206,8 +217,12 @@ const addScene = () => {
       'parameter': '',
       'operator': '',
       'value': ''
-
-    }]]
+    }]],
+    "enableStabilization": false,
+    "stabilization": {
+      "timeWindow": 1,
+      "threshold": 1
+    }
   });
   emit('addScenesDetail', 'definition');
 };

+ 19 - 8
src/views/iot/scene/manage/detail.vue

@@ -20,15 +20,14 @@
 			<div class="font20">场景定义</div>
 			<SceneItem v-if="showstatus && sourceData.length > 0" :sceneList="sceneList" :sourceData="sourceData" :sceneType="detail.sceneType" @addScenesDetail="addScenesDetail" @delScenesDetail="delScenesDetail" @editScenesDetail="editScenesDetail"></SceneItem>
 		</el-card>
-		<el-card style="  margin-top: 15px;" v-if="detail.sceneType === 'timer'">
-			<el-form-item label="定时触发">
+		<el-card shadow="nover" style="  margin-top: 15px;" v-if="detail.sceneType === 'timer'">
+			<el-form-item label="定时触发" style="margin-bottom: 0;">
 				<div style="display:flex">
 					<el-input v-model="timerData.timer" placeholder="请输入cron表达式" />
 					<el-dialog v-model="dialogVisible" title="选择Cron规则" width="60%">
 						<vue3cron @handlelisten="handlelisten" @close="cronclose"></vue3cron>
 					</el-dialog>
 					<el-button type="success" @click="showCron()" style="margin-left: 5px;">设置</el-button>
-
 				</div>
 			</el-form-item>
 		</el-card>
@@ -63,8 +62,12 @@ const sceneList = {
 		'parameter': '',
 		'operator': '',
 		'value': ''
-
-	}]]
+	}]],
+	"enableStabilization": false,
+	"stabilization": {
+		"timeWindow": 1,
+		"threshold": 1
+	}
 };
 const originalSceneList = ref([{
 	id: 0
@@ -116,10 +119,13 @@ export default defineComponent({
 					'parameter': '',
 					'operator': '',
 					'value': ''
-
-				}]]
+				}]],
+				"enableStabilization": false,
+				"stabilization": {
+					"timeWindow": 1,
+					"threshold": 1
+				}
 			}],
-
 		});
 
 		const handlelisten = (e: any) => {
@@ -163,6 +169,11 @@ export default defineComponent({
 					const scenes = res.map((scene: any) => {
 						const parsedBodyJson = JSON.parse(scene.bodyjson);
 						return {
+							"enableStabilization": false,
+							"stabilization": {
+								"timeWindow": 1,
+								"threshold": 1
+							},
 							...parsedBodyJson
 						};
 					});

+ 1 - 1
src/views/iot/scene/manage/index.vue

@@ -60,7 +60,7 @@
 						<el-button size="small" text type="warning" v-auth="'edit'" @click="addOrEdit(scope.row)">编辑</el-button>
 						<el-button size="small" text type="success" @click="onActionStatus(scope.row)" v-if="scope.row.status == 0" v-auth="'startOrStop'">启用</el-button>
 						<el-button size="small" text type="primary" @click="onActionStatus(scope.row)" v-if="scope.row.status > 0" v-auth="'startOrStop'">停用</el-button>
-						<el-button size="small" text type="danger" @click="run(scope.row)" v-if="scope.row.status > 0" v-auth="'startOrStop'">手动触发</el-button>
+						<el-button size="small" text type="danger" @click="run(scope.row)" v-if="scope.row.status > 0 && scope.row.sceneType == 'manual'" v-auth="'startOrStop'">手动触发</el-button>
 						<el-button size="small" text type="info" v-auth="'del'" @click="del(scope.row)">删除</el-button>
 					</template>
 				</el-table-column>