From fa541dda36e58de1d491b3ff4073c51b16606515 Mon Sep 17 00:00:00 2001 From: wangjuncheng <1> Date: 星期三, 25 六月 2025 17:29:42 +0800 Subject: [PATCH] 2 --- src/components/monifangzhen/schemeCard.vue | 55 ++++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 38 insertions(+), 17 deletions(-) diff --git a/src/components/monifangzhen/schemeCard.vue b/src/components/monifangzhen/schemeCard.vue index a25acd1..92c915a 100644 --- a/src/components/monifangzhen/schemeCard.vue +++ b/src/components/monifangzhen/schemeCard.vue @@ -74,7 +74,6 @@ selectedId.value = id; } - function formatTime(time) { return dayjs(time).format("YYYY-MM-DD HH:mm:ss"); } @@ -93,6 +92,9 @@ function close() { messageShow.value = false; } + +// 瀹炴椂妯℃嫙浜斿垎閽熻姹備竴娆$殑瀹氭椂鍣� +const realTimeSimInterval = ref(null); async function startPlay(item) { if (item.status === 2) { @@ -127,7 +129,7 @@ return; } - // 璋冪敤姹傝В鍣紙涓嶅湪瀹炴椂妯℃嫙鐨勬儏鍐典笅锛� + // 鏂板缓鏂规锛屾病鏈� status 鍜� serviceName 涓� type != 2 if (!item.status && !item.serviceName && item.type !== 2) { try { await getSimStart(item.id); @@ -143,23 +145,21 @@ return; } - // 瀹炴椂妯℃嫙 + // 澶勭悊 type == 2 鐨勬儏鍐碉紙瀹炴椂妯℃嫙锛� if (item.type === 2) { - try { - // 瀹炴椂妯℃嫙璋冪敤姹傝В鍣ㄤ細鐩存帴鍦ㄦ帴鍙d腑杩斿洖缁撴灉 - const ress = await getSimStart(item.id); - const res = await getSimDataById(item.id); - item.serviceName = res.data[0]?.serviceName || null; - simStore.setSelectedScheme(item); - getScheme(); - - if (ress.code === 200) { - initeWaterPrimitiveView(); - emit("start"); - } - } catch (e) { - console.error("瀹炴椂妯℃嫙鑾峰彇妯℃嫙鏁版嵁澶辫触锛�", e); + // 娓呴櫎宸叉湁瀹氭椂鍣紝闃叉閲嶅鍚姩 + if (realTimeSimInterval.value) { + clearInterval(realTimeSimInterval.value); } + + // 鍗冲埢鎵ц涓�娆� + await executeRealTimeSimulation(item); + + // 姣忛殧 5 鍒嗛挓鎵ц涓�娆� + realTimeSimInterval.value = setInterval(() => { + executeRealTimeSimulation(item); + }, 5 * 60 * 1000); // 5鍒嗛挓 + return; } @@ -167,7 +167,28 @@ simStore.setSelectedScheme(item); } +// 灏佽瀹炴椂妯℃嫙鐨勫紓姝ユ搷浣� +async function executeRealTimeSimulation(item) { + try { + const ress = await getSimStart(item.id); + console.log(ress, "resssssssss"); + const res = await getSimDataById(item.id); + + item.serviceName = res.data[0]?.serviceName || null; + simStore.setSelectedScheme(item); + getScheme(); + + if (ress.code === 200) { + simStore.layerDate = ress.data; + console.log(simStore.layerDate,'aaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbb') + initeWaterPrimitiveView(); + emit("start"); + } + } catch (e) { + console.error("瀹炴椂妯℃嫙鑾峰彇妯℃嫙鏁版嵁澶辫触锛�", e); + } +} function handleBack(value) { if (value === false) { -- Gitblit v1.9.3