<template>
  <modulen>
    <template #title>机电数据监测</template>
    <template v-if="true">
      <div class="data-content">
        <TableTem :tableData="tableData" :tableColums="tableColums" />
      </div>
    </template>
  </modulen>
</template>
<script>
import TableTem from '@/components/tableTem/index.vue'
import { ref, onMounted, inject, watch } from 'vue'
import { elec_tableColums } from './config'
import { getElecDataMonitor } from '@/api/dataMonitor'
export default {
  components: { TableTem },
  setup() {
    const tableData = ref([])
    const tableColums = elec_tableColums
    const selectRoadId = inject('selectRoadId')
    const searchParams = inject('searchParams')
    const getElecData = async () => {
      const  { msgState, msgContent } = await getElecDataMonitor(searchParams.value)
      if (msgState === 'SUCCESS' && msgContent) {
        tableData.value = msgContent
      }
    }
    onMounted(() => {
      getElecData()
    })
    watch(selectRoadId, () => {
      getElecData()
    }, {deep: true})
    return {
      tableData,
      tableColums
    }
  }
}
</script>