index.vue 4.88 KB
Newer Older
1
<template>
yanzhongrong's avatar
yanzhongrong committed
2
  <!-- 漏缆监测历史状态 -->
3 4
  <div class="leakage-cable">
    <div class="leakage-top">
yanzhongrong's avatar
yanzhongrong committed
5
      <div style="color: #666666"></div>
6
      <div class="operate-btn">
neogcg's avatar
neogcg committed
7
        <delids :multipleSelection2="multipleSelection" @del="deleteCable"
yanzhongrong's avatar
yanzhongrong committed
8
          >删除</delids
yanzhongrong's avatar
yanzhongrong committed
9
        >
neogcg's avatar
neogcg committed
10
        <el-button type="primary" @click="refresh">刷新</el-button>
yanzhongrong's avatar
yanzhongrong committed
11
        <el-button type="primary" @click="isQuery = !isQuery">查询</el-button>
yanzhongrong's avatar
yanzhongrong committed
12
        <el-button type="primary" @click="toExport">导出</el-button>
neogcg's avatar
neogcg committed
13 14 15 16
        <el-button
          :type="multipleSelection.length ? 'primary' : 'info'"
          :disabled="!multipleSelection.length"
          >图形报表
neogcg's avatar
neogcg committed
17
        </el-button>
18 19
      </div>
    </div>
yanzhongrong's avatar
yanzhongrong committed
20
    <div v-if="isQuery">
neogcg's avatar
neogcg committed
21
      <search @search="search" ref="reset" />
yanzhongrong's avatar
yanzhongrong committed
22
    </div>
23 24
    <el-table
      ref="multipleTable"
yanzhongrong's avatar
yanzhongrong committed
25
      :data="tableData"
26 27
      style="width: 100%"
      :cell-class-name="cellClassFn"
yanzhongrong's avatar
yanzhongrong committed
28
      :header-cell-style="{ background: '#EAF1FE', color: '#666666' }"
29 30 31
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
yanzhongrong's avatar
yanzhongrong committed
32 33 34
      <el-table-column prop="siteName" label="基站名称" align="center" />
      <el-table-column prop="alarmTarget" label="告警对象" align="center" />
      <el-table-column prop="alarmInfo" label="告警信息" align="center">
35
      </el-table-column>
yanzhongrong's avatar
yanzhongrong committed
36
      <el-table-column prop="uploadTime" label="上传日期" align="center" />
neogcg's avatar
neogcg committed
37 38 39
      <el-table-column label="图形分析" align="center">
        <el-button type="text">生成图表</el-button> </el-table-column
      >>
40
    </el-table>
yanzhongrong's avatar
yanzhongrong committed
41 42 43
    <Pagination
      :limit="params.size"
      :page="params.current"
44 45 46 47 48 49 50 51
      :total="total"
      class="pagination"
      @pagination="handlePageChange"
    />
  </div>
</template>

<script>
neogcg's avatar
neogcg committed
52 53 54 55
import { MonitorStatusList, MonitorStatusDelete } from "../api";
import search from "./components/search.vue";
import download from "@/utils/download";
import { exportLeakyStatusHistory } from "@/api/export";
neogcg's avatar
neogcg committed
56
import { successAlert, warningAlert } from "@/utils/alert";
57 58 59
export default {
  data() {
    return {
yanzhongrong's avatar
yanzhongrong committed
60 61
      params: {
        current: 1,
neogcg's avatar
neogcg committed
62
        size: 10,
63 64
      },
      total: 10,
yanzhongrong's avatar
yanzhongrong committed
65
      tableData: [],
yanzhongrong's avatar
yanzhongrong committed
66
      multipleSelection: [],
yanzhongrong's avatar
yanzhongrong committed
67
      isQuery: false,
neogcg's avatar
neogcg committed
68
      istrue:0,
neogcg's avatar
neogcg committed
69 70 71
      searchOption: {},
      exids: [],
    };
72
  },
yanzhongrong's avatar
yanzhongrong committed
73
  components: {
neogcg's avatar
neogcg committed
74
    search,
yanzhongrong's avatar
yanzhongrong committed
75
  },
76 77 78
  methods: {
    // 表格背景图颜色
    cellClassFn({ row, column, rowIndex, columnIndex }) {
neogcg's avatar
neogcg committed
79 80 81 82
      if (row.level === "紧急" && column.label === "告警级别") {
        return "emergency";
      } else if (row.level === "重要" && column.label === "告警级别") {
        return "important";
neogcg's avatar
neogcg committed
83 84
      } else if (row.level == "一般" && column.label == "告警级别") {
        return "common";
85 86
      }
      if (rowIndex % 2 === 1) {
neogcg's avatar
neogcg committed
87
        return "stripe";
88 89 90
      }
    },
    handlePageChange(pageData) {
neogcg's avatar
neogcg committed
91 92 93
      this.params.size = pageData.size;
      this.params.current = pageData.page;
      this.getTableData();
neogcg's avatar
neogcg committed
94
    },
neogcg's avatar
neogcg committed
95
    refresh() {
neogcg's avatar
neogcg committed
96 97 98
      this.$refs.reset != undefined
        ? this.$refs.reset.reset()
        : this.getTableData();
neogcg's avatar
neogcg committed
99
    },
neogcg's avatar
neogcg committed
100 101 102 103 104 105
    search(option){
      this.istrue=1
      this.searchOption = option
      this.getTableData()
    },
    getTableData() {
yanzhongrong's avatar
yanzhongrong committed
106 107
      let params = {
        ...this.params,
neogcg's avatar
neogcg committed
108
        ...this.searchOption,
neogcg's avatar
neogcg committed
109 110 111 112 113 114 115
      };
      MonitorStatusList(params).then((res) => {
        let list = res.records || [];
        this.tableData = list;
        this.total = res.total;
        this.exids = list.map((i) => i.id);
      });
116 117
    },
    handleSelectionChange(val) {
neogcg's avatar
neogcg committed
118 119
      let deleteIds = val.map((item) => item.id);
      this.multipleSelection = deleteIds;
yanzhongrong's avatar
yanzhongrong committed
120 121
    },
    deleteCable() {
neogcg's avatar
neogcg committed
122 123 124 125
      MonitorStatusDelete({ ids: this.multipleSelection }).then((res) => {
        this.$message.success("删除成功!");
        this.getTableData();
      });
yanzhongrong's avatar
yanzhongrong committed
126 127
    },
    toExport() {
neogcg's avatar
neogcg committed
128 129 130 131 132 133 134 135
      if (this.exids.length == 0) {
        this.$message.warning("暂无数据");
        return false;
      } else {
        exportLeakyStatusHistory({ ids: this.exids }).then((res) => {
          download(res, "vnd.ms-excel", `漏缆监测历史状态.xls`);
        });
      }
neogcg's avatar
neogcg committed
136
    },
neogcg's avatar
neogcg committed
137
  },
yanzhongrong's avatar
yanzhongrong committed
138
  mounted() {
neogcg's avatar
neogcg committed
139 140 141
    this.getTableData();
  },
};
142 143 144 145 146 147 148 149 150 151 152 153 154 155
</script>

<style lang="scss" scoped>
.leakage-cable {
  .leakage-top {
    margin-bottom: 20px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
  }
  & ::v-deep .cell {
    color: #333333;
  }
  .message {
yanzhongrong's avatar
yanzhongrong committed
156
    line-height: 22px;
157 158 159 160 161 162 163 164 165 166 167
  }
  .red {
    color: red;
  }
  .green {
    color: green;
  }
  .black {
    color: black;
  }
  & ::v-deep .stripe {
yanzhongrong's avatar
yanzhongrong committed
168
    background-color: #eaf1fe;
169 170 171 172 173 174 175
  }
  & ::v-deep .emergency {
    background-color: #f00;
  }
  & ::v-deep .important {
    background-color: #f89850;
  }
neogcg's avatar
neogcg committed
176 177 178
  & ::v-deep .common {
    background-color: #ead906;
  }
179 180 181 182 183 184 185 186 187 188 189
  .page {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
    .pageNum {
      margin: 0 20px;
    }
  }
}
</style>