alarm.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <scTable ref="xGridTable" batchDel :apiObj="$API.elevator.warning" :formConfig="formConfig" :paramsColums="paramsColums" :toolbarConfig="toolbarConfig" :columns="columns">
  3. <template #action="{ row }">
  4. <el-button type="primary" link @click="table_del(row)">
  5. <template #icon><sc-iconify icon="ant-design:delete-outlined"></sc-iconify></template>删除
  6. </el-button>
  7. </template>
  8. </scTable>
  9. </template>
  10. <script setup>
  11. import moment from "moment";
  12. import XEUtils from "xe-utils";
  13. import API from "@/api";
  14. import TOOL from "@/utils/tool";
  15. import { mapFormItemSelect, mapFormItemDatePicker } from "@/components/scTable/helper";
  16. import { dataSource, objectToArray } from "@/utils/basicDic";
  17. import { warningTypeDic } from "@/views/dataMock/tower/main";
  18. const proConfig = reactive({
  19. span: 5,
  20. storageKey: "PROJECT",
  21. resetValue: TOOL.data.get("PROJECT_ID"),
  22. optionProps: { label: "projectName", value: "fpiId" },
  23. events: {
  24. change: data => XEUtils.assign(formConfig.data, { ...data, mountedId: null })
  25. }
  26. })
  27. const mountedConfig = reactive({
  28. api: {
  29. key: "elevator.mounted",
  30. query: {
  31. projectId: computed(() => formConfig.data.projectId),
  32. projectIdNot: 1
  33. }
  34. },
  35. slot: {
  36. style: { float: "right", paddingLeft: "6px", color: "#8492a6" }
  37. },
  38. optionProps: { label: "mountedName", value: "id", slot: ({ data }) => XEUtils.get(XEUtils.find(TOOL.data.get("PROJECT"), item => item.fpiId === data.projectId), "projectName") },
  39. events: {
  40. change: data => XEUtils.assign(formConfig.data, data)
  41. }
  42. })
  43. const selectConfig = reactive({
  44. options: objectToArray(XEUtils.omit(warningTypeDic, "WARNING_MANY")),
  45. events: {
  46. change: data => XEUtils.merge(formConfig.data, data)
  47. }
  48. })
  49. const datetimerangeConfig = reactive({
  50. span: 7,
  51. resetValue: () => [moment().startOf("day").format("YYYY-MM-DD HH:mm:ss"), moment().format("YYYY-MM-DD HH:mm:ss")],
  52. props: {
  53. type: "datetimerange",
  54. startPlaceholder: "开始时间",
  55. endPlaceholder: "结束时间",
  56. format: "YYYY-MM-DD HH:mm"
  57. }
  58. })
  59. const toolbarConfig = reactive({
  60. enabled: true,
  61. print: false
  62. })
  63. const formConfig = reactive({
  64. data: {
  65. orderBy: "ew.createTime_desc",
  66. projectId: TOOL.data.get("PROJECT_ID"),
  67. projectIdNot: 1,
  68. createTime: [moment().startOf("day").format("YYYY-MM-DD HH:mm:ss"), moment().format("YYYY-MM-DD HH:mm:ss")]
  69. },
  70. items: [
  71. mapFormItemSelect("projectId", "所属项目", proConfig),
  72. mapFormItemSelect("mountedId", "设备安装点", mountedConfig),
  73. mapFormItemDatePicker("createTime", "监测时间", datetimerangeConfig),
  74. mapFormItemSelect("warningType", "告警类型", selectConfig)
  75. ]
  76. })
  77. const paramsColums = reactive([
  78. { column: "orderBy" },
  79. { column: "projectId" },
  80. { column: "projectIdNot" },
  81. { column: "mountedId" },
  82. { column: "warningType" },
  83. { column: "er.createTimeBegin", field: "createTime[0]" },
  84. { column: "er.createTimeEnd", field: "createTime[1]" }
  85. ])
  86. const columns = reactive([
  87. { type: "checkbox", fixed: "left", width: 40 },
  88. { type: "seq", fixed: "left", width: 60 },
  89. { type: "html", field: "projectName", title: "项目名称", minWidth: 160, sortable: true, formatter: ({ cellValue, row }) => cellValue || XEUtils.get(XEUtils.find(TOOL.data.get("PROJECT"), item => item.fpiId == row.projectId), "projectName") },
  90. { type: "html", field: "groundName", title: "工地场区", minWidth: 160, sortable: true },
  91. { type: "html", field: "mountedName", title: "设备安装点", minWidth: 160, sortable: true },
  92. { type: "html", field: "createTime", title: "告警时间", minWidth: 160, sortable: true },
  93. { type: "html", field: "warningType", title: "告警类型", minWidth: 100, sortable: true, formatter: ({ cellValue }) => XEUtils.get(warningTypeDic, cellValue, cellValue) },
  94. { type: "html", field: "dataSource", title: "数据来源", fixed: "right", minWidth: 100, sortable: true, formatter: ({ cellValue }) => XEUtils.get(dataSource, cellValue, cellValue) },
  95. { title: "操作", fixed: "right", width: 120, align: "center", slots: { default: "action" } }
  96. ])
  97. // 显示隐藏 筛选表单
  98. const xGridTable = ref();
  99. const toggleFormEnabled = () => xGridTable.value.toggleFormEnabled();
  100. const refreshTable = () => {
  101. xGridTable.value.reloadColumn(columns);
  102. xGridTable.value.searchData();
  103. }
  104. const table_del = ({ id }) => {
  105. ElMessageBox.confirm("是否确认删除该告警记录?", "删除警告", {
  106. type: "warning",
  107. confirmButtonText: "确定",
  108. cancelButtonText: "取消"
  109. }).then(() => {
  110. API.elevator.warning.del({ id }).then(() => {
  111. ElMessage.success("操作成功");
  112. refreshTable();
  113. });
  114. });
  115. }
  116. </script>