<script setup lang="ts">
import configs from "@/core/config/Index"
import { ref } from "vue"
import router from "@/router"
import { useRoute } from "vue-router"
const route = useRoute()
const companyName = ref(route.query.name)
const queryParams = ref({
  company_id: route.query.company_id,
  time_type: route.query.time_type,
  warn_type: route.query.warn_type,
  query_start_time: route.query.query_start_time,
  query_end_time: route.query.query_end_time,
})
const cols = ref([
  {
    name: "序号",
    width: 60,
    field: configs.TABLE_INDEX_FIELD,
  },
  {
    name: "净化设施",
    field: "device_name",
  },
  {
    name: "告警类型",
    field: "warn_type_name",
  },
  {
    name: "报警时间",
    field: "warn_starttime",
  },
  {
    name: "操作",
    width: 120,
    field: "action",
  },
])

function detail(row: any) {
  router.push({
    path: "/analysisInfo/overdue/warn",
    query: {
      back: 1,
      id: row.id,
      type: row.warn_type,
    },
  })
}
</script>

<template>
  <VbDataTable
    ref="table"
    :header="cols"
    url="sys/overdueCompany/getWarnForPage"
    method="post"
    :query-params="queryParams"
    :has-checkbox="false"
    :pagination="false"
  >
    <template v-slot:table-tool>
      <h2>{{ companyName }}</h2>
    </template>

    <template #action="{ row }">
      <span class="table-action" @click="detail(row)">查看详情</span>
    </template>
  </VbDataTable>
</template>
