abnormal.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <script setup lang="ts">
  2. import { ref } from "vue"
  3. import moment from "moment"
  4. import router from "@/router"
  5. const cols = ref([
  6. {
  7. name: "设备名称",
  8. field: "device_name",
  9. },
  10. {
  11. name: "异常类型",
  12. field: "warn_type_name",
  13. },
  14. {
  15. name: "告警时间",
  16. field: "warn_time",
  17. },
  18. {
  19. name: "持续时间(分钟)",
  20. field: "continue_time",
  21. },
  22. {
  23. name: "操作",
  24. field: "action",
  25. width: 100,
  26. },
  27. ])
  28. const warnType = ref(null)
  29. const size = ref<any>("default")
  30. const dySearchSelectStyle = { width: "180px" }
  31. const dateRange = ref<any>([moment(new Date()).add(-1, "M").toDate(), new Date()])
  32. const queryParams = ref({
  33. warn_type: warnType.value,
  34. abnormal_state: null,
  35. query_start_time: moment(dateRange.value[0]).format("YYYYMMDD"),
  36. query_end_time: moment(dateRange.value[1]).format("YYYYMMDD"),
  37. })
  38. function query() {
  39. queryParams.value = {
  40. warn_type: warnType.value,
  41. abnormal_state: null,
  42. query_start_time: moment(dateRange.value[0]).format("YYYYMMDD"),
  43. query_end_time: moment(dateRange.value[1]).format("YYYYMMDD"),
  44. }
  45. }
  46. function reset() {
  47. warnType.value = null
  48. dateRange.value = [moment(new Date()).add(-1, "M").toDate(), new Date()]
  49. query()
  50. }
  51. function detail(row: any) {
  52. if (row.warn_type == "000100003" || row.warn_type == "000100005" || row.warn_type == "000100007") {
  53. router.push({
  54. path: "/AbnormalList/strongWarn",
  55. query: { back: 1, id: row.id, type: row.warn_type },
  56. })
  57. } else if (row.warn_type == "000100006") {
  58. router.push({
  59. path: "/AbnormalList/disConnect",
  60. query: { back: 1, id: row.id, type: row.warn_type },
  61. })
  62. } else {
  63. router.push({
  64. path: "/AbnormalList/overdueWarn",
  65. query: { back: 1, id: row.id, type: row.warn_type },
  66. })
  67. }
  68. }
  69. </script>
  70. <template>
  71. <VbDataTable
  72. ref="table"
  73. :header="cols"
  74. url="sys/companyDeclare/getCompanyWarnList"
  75. method="post"
  76. :query-params="queryParams"
  77. :has-checkbox="false"
  78. >
  79. <template v-slot:table-tool>
  80. <el-form class="align-items-center" :inline="true">
  81. <el-form-item class="mb-0 me-5 align-items-center" label="异常类型">
  82. <DySelect
  83. v-model="warnType"
  84. :url="'sys/dict/getList?code=000100001&key=temp'"
  85. :formatRemoteData="(v:any)=>{return v?.list}"
  86. :style="dySearchSelectStyle"
  87. :size="size"
  88. @clear="warnType = null"
  89. placeholder="请选择异常类型"
  90. ></DySelect>
  91. </el-form-item>
  92. <el-form-item class="mb-0 me-0 align-items-center" label="日期">
  93. <el-date-picker
  94. v-model="dateRange"
  95. type="daterange"
  96. range-separator="~"
  97. start-placeholder="开始时间"
  98. end-placeholder="结束时间"
  99. size="default"
  100. />
  101. </el-form-item>
  102. <el-form-item class="mb-0 me-0 align-items-center">
  103. <el-button class="ms-3 mt-0 btn btn-sm btn-primary" @click="query">查询</el-button>
  104. <el-button class="ms-3 mt-0 btn btn-sm btn-light-primary btn-outline" @click="reset">重置</el-button>
  105. </el-form-item>
  106. </el-form>
  107. </template>
  108. <template #action="{ row }">
  109. <span class="table-action" @click="detail(row)">查看</span>
  110. </template>
  111. </VbDataTable>
  112. </template>