Parcourir la source

fix: 修复删除iot中规则引擎和规则引擎 中对应流的逻辑,如果规则引擎中不存在这个流可以直接删除

yanglzh il y a 2 ans
Parent
commit
2c73d73322
2 fichiers modifiés avec 30 ajouts et 36 suppressions
  1. 15 18
      src/views/iot/rule-engine/index.vue
  2. 15 18
      src/views/iot/rule-engine/send.vue

+ 15 - 18
src/views/iot/rule-engine/index.vue

@@ -119,26 +119,23 @@ const onDel = (row: any) => {
 
 		const flowIndex = flows.findIndex((item: any) => item.id === row.flowId);
 
-		if (flowIndex === -1) {
-			ElMessage.error('规则不存在');
-			return;
+		if (flowIndex >= 0) {
+			// 删除指定规则
+			flows.splice(flowIndex, 1);
+
+			// 删除当前规则下的各个节点信息
+			const newFlows = flows.filter((item: any) => {
+				if (item.z === row.flowId) {
+					return false;
+				} else {
+					return true;
+				}
+			});
+
+			// 设置规则状态
+			await axios.post(flowsUrl, newFlows, { headers });
 		}
 
-		// 删除指定规则
-		flows.splice(flowIndex, 1);
-
-		// 删除当前规则下的各个节点信息
-		const newFlows = flows.filter((item: any) => {
-			if (item.z === row.flowId) {
-				return false;
-			} else {
-				return true;
-			}
-		});
-
-		// 设置规则状态
-		await axios.post(flowsUrl, newFlows, { headers });
-
 		await api.del([row.id as string]);
 		ElMessage.success('删除成功');
 		getList();

+ 15 - 18
src/views/iot/rule-engine/send.vue

@@ -117,26 +117,23 @@ const onDel = (row: any) => {
 
     const flowIndex = flows.findIndex((item: any) => item.id === row.flowId);
 
-    if (flowIndex === -1) {
-      ElMessage.error('规则不存在');
-      return;
+    if (flowIndex >= 0) {
+      // 删除指定规则
+      flows.splice(flowIndex, 1);
+
+      // 删除当前规则下的各个节点信息
+      const newFlows = flows.filter((item: any) => {
+        if (item.z === row.flowId) {
+          return false;
+        } else {
+          return true;
+        }
+      });
+
+      // 设置规则状态
+      await axios.post(flowsUrl, newFlows, { headers });
     }
 
-    // 删除指定规则
-    flows.splice(flowIndex, 1);
-
-    // 删除当前规则下的各个节点信息
-    const newFlows = flows.filter((item: any) => {
-      if (item.z === row.flowId) {
-        return false;
-      } else {
-        return true;
-      }
-    });
-
-    // 设置规则状态
-    await axios.post(flowsUrl, newFlows, { headers });
-
     await api.del([row.id as string]);
     ElMessage.success('删除成功');
     getList();