From d1ac4de7a592863f653433bef1707f121441a1ac Mon Sep 17 00:00:00 2001 From: zhoushihao <zsh19950802@163.com> Date: 星期五, 24 五月 2024 12:01:49 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- UI-Project/src/views/Returns/returns.vue | 91 ++++++++++++++++++++++++++++++++++++--------- 1 files changed, 73 insertions(+), 18 deletions(-) diff --git a/UI-Project/src/views/Returns/returns.vue b/UI-Project/src/views/Returns/returns.vue index bbd6c52..eddab30 100644 --- a/UI-Project/src/views/Returns/returns.vue +++ b/UI-Project/src/views/Returns/returns.vue @@ -26,7 +26,7 @@ // number.value = ''; import request from "@/utils/request" const ida = ref(null); -import { ref, onMounted } from "vue"; +import { ref, onMounted, onUnmounted } from "vue"; // import http from "@/http/index"; let ruleForm = ref({ @@ -69,25 +69,79 @@ // ElMessage.error('鑾峰彇琛ㄦ牸鏁版嵁澶辫触锛岃閲嶈瘯'); } }; - request.get("/loadGlass/LoadGlass/list").then((res) => { - if (res.code === 200) { - console.log(res.data); - tableDataa.value = res.data; +onMounted(async () => { + await fetchTableData(); + + // 璁剧疆瀹氭椂鍣ㄦ潵瀹氭湡鍒锋柊鏁版嵁 + const intervalId = setInterval(async () => { + await fetchTableData(); + }, 1000); // 姣�1绉掑埛鏂颁竴娆� + + // 缁勪欢鍗歌浇鏃舵竻闄ゅ畾鏃跺櫒 + onUnmounted(() => { + clearInterval(intervalId); + }); +}); +onMounted(async () => { + await fetchTableDataa(); + + // 璁剧疆瀹氭椂鍣ㄦ潵瀹氭湡鍒锋柊鏁版嵁 + const intervalId = setInterval(async () => { + await fetchTableDataa(); + }, 1000); // 姣�1绉掑埛鏂颁竴娆� + + // 缁勪欢鍗歌浇鏃舵竻闄ゅ畾鏃跺櫒 + onUnmounted(() => { + clearInterval(intervalId); + }); +}); + // request.get("/loadGlass/LoadGlass/list").then((res) => { + // if (res.code === 200) { + // console.log(res.data); + // tableDataa.value = res.data; - if (tableDataa.value.length === 2) { - if (tableDataa.value[0].patternWidth > 0) { - flake.value = true; - } + // if (tableDataa.value.length === 2) { + // if (tableDataa.value[0].patternWidth > 0) { + // flake.value = true; + // } - if (tableDataa.value[1].patternWidth > 0) { - flakea.value = true; - } - } - } else { - ElMessage.warning(res.msg); - // router.push("/login"); - } - }); + // if (tableDataa.value[1].patternWidth > 0) { + // flakea.value = true; + // } + // } + // } else { + // ElMessage.warning(res.msg); + // // router.push("/login"); + // } + // }); + async function fetchTableDataa() { + try { + const res = await request.get("/loadGlass/LoadGlass/list"); + if (res.code === 200) { + tableDataa.value = res.data; + + // 鏍规嵁鏁版嵁鏇存柊 flake 鍜� flakea 鐨勫�� + if (res.data.length >= 2) { + if (res.data[0].patternWidth > 0) { + flake.value = true; + } else { + flake.value = false; + } + + if (res.data[1].patternWidth > 0) { + flakea.value = true; + } else { + flakea.value = false; + } + } + } else { + ElMessage.warning(res.msg); + } + } catch (error) { + console.error('鑾峰彇琛ㄦ牸鏁版嵁澶辫触', error); + // 鍙互鍦ㄨ繖閲屾坊鍔犻澶栫殑閿欒澶勭悊閫昏緫 + } +} // request.get("/loadGlass/LoadGlass/list").then((res) => { // window.localStorage.setItem('patternWidth', res.data.patternWidth) // window.localStorage.setItem('workstationId', res.data.workstationId) @@ -468,6 +522,7 @@ } } onMounted(fetchTableData); +onMounted(fetchTableDataa); function getStatusText(state: number) { switch (state) { case 0: -- Gitblit v1.8.0