Jelajahi Sumber

获取解冻解冻时长相关数据

LiuShu_0203 5 bulan lalu
induk
melakukan
105ec413df
2 mengubah file dengan 23 tambahan dan 17 penghapusan
  1. 21 16
      src/App.vue
  2. 2 1
      vite.config.ts

+ 21 - 16
src/App.vue

@@ -303,6 +303,7 @@ const selectTab = (item: any, index: number) => {
     unsubscribes();
     // 添加当前选中的 topic
     mqttTopics.value = ['warn', item.topic];
+    usemeterialParamlist(item.id);
     // 重新启动 MQTT 连接
     startMqtt(mqttTopics.value, handleMqttMessage);
 };
@@ -439,7 +440,7 @@ const progressbar = (datalist: any) => {
                         }
                     },
                     barWidth: 20,
-                    data: [datalist.toFixed(2)],
+                    data: [Number(datalist.runTime).toFixed(2)],
                     label: {
                         show: true,
                         position: 'insideTop',
@@ -455,7 +456,7 @@ const progressbar = (datalist: any) => {
                     type: 'bar',
                     barWidth: 20,
                     barGap: '-100%',
-                    data: [40],
+                    data: [Number(datalist.jdTime).toFixed(2)],
                     itemStyle: {
                         normal: {
                             color: {
@@ -479,7 +480,7 @@ const progressbar = (datalist: any) => {
                         show: true,
                         position: 'right',
                         formatter(params: any) {
-                            const total = 40; // 假设总条数为20
+                            const total = Number(datalist.jdTime).toFixed(2); // 假设总条数为20
                             return `${total}h`;
                         },
                         fontSize: 16,
@@ -826,6 +827,23 @@ const uselistData = () => {
                 tabsdata.value = res.data;
                 mqttTopics.value = ['warn', res.data[0].topic];
                 startMqtt(mqttTopics.value, handleMqttMessage);
+                usemeterialParamlist(res.data[0].id);
+            } else {
+                console.log('获取数据失败');
+            }
+        })
+        .catch((err: any) => {
+            console.log(err);
+        });
+};
+
+const usemeterialParamlist = (item: any) => {
+    const meterialId = Number(item);
+    meterialParamlist(meterialId)
+        .then((res: any) => {
+            if (res && res.code === 200) {
+                console.log(res.data, 'res.data');
+                progressbar(res.data);
             } else {
                 console.log('获取数据失败');
             }
@@ -891,19 +909,6 @@ const handleMqttMessage = (topic: string, message: any) => {
 onMounted(() => {
     updateTime(); // 初始化时立即更新一次时间
     const interval = setInterval(updateTime, 1000);
-    const meterialId = 1;
-    meterialParamlist(meterialId)
-        .then((res: any) => {
-            if (res && res.code === 200) {
-                console.log(res.data, 'res.data');
-                progressbar(res.data);
-            } else {
-                console.log('获取数据失败');
-            }
-        })
-        .catch((err: any) => {
-            console.log(err);
-        });
 
     uselistData();
     // 连接 MQTT

+ 2 - 1
vite.config.ts

@@ -115,7 +115,8 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
             proxy: {
                 // 这里的意思是 以/api开头发送的请求都会被转发到 http://xxx:9000
                 [env.VITE_APP_API_BASEURL]: {
-                    target: 'http://192.168.50.122:9999',
+                    // target: 'http://192.168.50.133:9999',
+                    target: 'http://localhost:9001',
                     // 改变 Host Header
                     changeOrigin: true,
                     rewrite: (path) => path.replace(new RegExp(`^${env.VITE_APP_API_BASEURL}`), '')