Browse Source

定时添加

123 1 year ago
parent
commit
8fea7a0a80

+ 19 - 1
src/views/logs/index.vue

@@ -48,6 +48,12 @@
       </t-form-item>
     </t-form>
     <vxe-grid v-bind="gridOptions" class="mt-10px">
+      <template #status="{ row }">
+        <t-tag v-if="row.status === '1'" theme="primary" variant="light"
+          >成功</t-tag
+        >
+        <t-tag v-else theme="danger" variant="light">失败</t-tag>
+      </template>
       <template #pager>
         <!--使用 pager 插槽-->
         <vxe-pager
@@ -118,7 +124,7 @@ const gridOptions = reactive<VxeGridProps>({
     },
     {
       field: 'energyStationName',
-      title: '所属锅炉房',
+      title: '换热站',
     },
     {
       field: 'date',
@@ -144,6 +150,18 @@ const gridOptions = reactive<VxeGridProps>({
         }
       },
     },
+    {
+      field: 'status',
+      title: '状态',
+      slots: { default: 'status' },
+      //   formatter: ({ cellValue }) => {
+      //     if (cellValue === '1') {
+      //       return '成功';
+      //     } else {
+      //       return '失败';
+      //     }
+      //   },
+    },
     {
       field: 'dataName',
       title: '数据名称',

+ 2 - 2
src/views/runData/components/systemData/constants.ts

@@ -8,8 +8,8 @@ export interface RowVO {
 
 export const tableCloumn = [
     { field: 'sysName', title: '系统名称', width: 120, fixed: 'left' },
-    { field: '_id', title: '系统编号', width: 100, visible: false },
-    { field: 'energyStationName', title: '所属锅炉房', width: 120 },
+    { field: '_id', title: '系统编号', width: 100 },
+    { field: 'energyStationName', title: '换热站', width: 120 },
     {
         field: 'controlModel', title: '控制模式', width: 100, formatter: ({ cellValue, row }) => {
             if (!cellValue) return null

+ 1 - 1
src/views/runData/components/systemData/index.vue

@@ -50,7 +50,7 @@
   </div>
 </template>
 <script lang="ts" setup>
-import { ref, reactive } from 'vue';
+import { ref, reactive, onUnmounted } from 'vue';
 import { RefreshIcon } from 'tdesign-icons-vue-next';
 import { VxeGridProps } from 'vxe-table';
 import { EditDialog, HistoryDialog } from './components';

+ 15 - 2
src/views/runData/index.vue

@@ -5,10 +5,11 @@
   </div>
 </template>
 <script lang="ts" setup>
-import { ref, onMounted, computed } from 'vue';
+import { ref, onMounted, onUnmounted, computed } from 'vue';
 import { systemData, boilerData } from './components';
 const activeValue = ref('system');
 const componentRef = ref(null);
+const timer = ref(null);
 const tabList = ref([
   {
     label: '系统数据',
@@ -21,7 +22,15 @@ const tabList = ref([
 ]);
 onMounted(() => {
   setTimeout(() => {
-    componentRef.value.init();
+    if (activeValue.value === 'system') {
+      componentRef.value.init();
+      timer.value = setInterval(() => {
+        //定时刷新
+        componentRef.value.init();
+      }, 30000);
+    } else {
+      componentRef.value.init();
+    }
   }, 500);
 });
 const dynamicComponent = computed(() => {
@@ -37,6 +46,10 @@ const handleTabChange = (val) => {
     componentRef.value.init();
   }, 500);
 };
+onUnmounted(() => {
+  clearInterval(timer.value);
+  timer.value = null;
+});
 </script>
 <style lang="less" scoped>
 .runData {