index.vue 5.07 KB
Newer Older
neogcg's avatar
neogcg committed
1 2 3 4
<template>
  <div class="leakage-cable">
    <!-- 设备维护历史 -->
    <div class="leakage-top">
neogcg's avatar
neogcg committed
5
      <div style="color: #666666"></div>
neogcg's avatar
neogcg committed
6
      <div class="operate-btn">
neogcg's avatar
neogcg committed
7
        <delids :multipleSelection2="multipleSelection" @del="deleteCable"
yanzhongrong's avatar
yanzhongrong committed
8
          >删除</delids
neogcg's avatar
neogcg 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
      </div>
    </div>
yanzhongrong's avatar
yanzhongrong committed
15
    <div v-if="isQuery">
neogcg's avatar
neogcg committed
16
      <search @search="search" ref="reset" />
yanzhongrong's avatar
yanzhongrong committed
17
    </div>
neogcg's avatar
neogcg committed
18
    <el-table
yanzhongrong's avatar
yanzhongrong committed
19
      :data="tableData"
neogcg's avatar
neogcg committed
20 21 22
      style="width: 100%"
      :cell-class-name="cellClassFn"
      :header-cell-style="{ background: '#EAF1FE', color: '#666666' }"
yanzhongrong's avatar
yanzhongrong committed
23
      @selection-change="handleSelectionChange"
neogcg's avatar
neogcg committed
24 25 26 27
    >
      <el-table-column type="selection" width="55" align="center" />

      <el-table-column
yanzhongrong's avatar
yanzhongrong committed
28
        prop="siteName"
neogcg's avatar
neogcg committed
29 30 31 32 33
        label="基站名称"
        width="180"
        align="center"
      />
      <el-table-column
yanzhongrong's avatar
yanzhongrong committed
34
        prop="alarmTarget"
neogcg's avatar
neogcg committed
35 36 37 38
        label="告警对象"
        width="180"
        align="center"
      />
neogcg's avatar
neogcg committed
39 40 41 42 43 44
      <el-table-column
        prop="alarmLevelName"
        label="告警级别"
        width="150"
        align="center"
      >
neogcg's avatar
neogcg committed
45
      </el-table-column>
yanzhongrong's avatar
yanzhongrong committed
46
      <el-table-column prop="alarmInfo" label="告警信息" align="center">
neogcg's avatar
neogcg committed
47
      </el-table-column>
neogcg's avatar
neogcg committed
48 49 50 51 52
      <el-table-column
        prop="alarmMaintainTime"
        label="告警维修时间"
        align="center"
      />
neogcg's avatar
neogcg committed
53
    </el-table>
yanzhongrong's avatar
yanzhongrong committed
54 55 56
    <Pagination
      :limit="params.size"
      :page="params.current"
neogcg's avatar
neogcg committed
57 58 59
      :total="total"
      class="pagination"
      @pagination="handlePageChange"
yanzhongrong's avatar
yanzhongrong committed
60
    />
neogcg's avatar
neogcg committed
61 62 63
  </div>
</template>
<script>
neogcg's avatar
neogcg committed
64 65 66 67
import { MonitorMaintainList, MonitorMaintainDelete } from "../api";
import search from "./components/search.vue";
import download from "@/utils/download";
import { exportLeakyMaintainHistory } from "@/api/export";
neogcg's avatar
neogcg committed
68
import { successAlert, warningAlert } from "@/utils/alert";
neogcg's avatar
neogcg committed
69 70 71 72 73
export default {
  props: [],
  data() {
    return {
      multipleSelection: [],
yanzhongrong's avatar
yanzhongrong committed
74 75 76
      params: {
        current: 1,
        size: 10,
neogcg's avatar
neogcg committed
77 78
      },
      total: 10,
yanzhongrong's avatar
yanzhongrong committed
79
      tableData: [],
yanzhongrong's avatar
yanzhongrong committed
80
      isQuery: false,
neogcg's avatar
neogcg committed
81
      istrue:0,
neogcg's avatar
neogcg committed
82 83 84
      searchOption: {},
      exids: [],
    };
neogcg's avatar
neogcg committed
85
  },
yanzhongrong's avatar
yanzhongrong committed
86
  components: {
neogcg's avatar
neogcg committed
87
    search,
yanzhongrong's avatar
yanzhongrong committed
88
  },
neogcg's avatar
neogcg committed
89 90
  methods: {
    handleSelectionChange(val) {
neogcg's avatar
neogcg committed
91 92
      let deleteIds = val.map((item) => item.id);
      this.multipleSelection = deleteIds;
neogcg's avatar
neogcg committed
93 94
    },
    handlePageChange(pageData) {
yanzhongrong's avatar
yanzhongrong committed
95 96
      this.params.size = pageData.size;
      this.params.current = pageData.page;
neogcg's avatar
neogcg committed
97
      this.getTableData();
neogcg's avatar
neogcg committed
98
    },
neogcg's avatar
neogcg committed
99
    refresh() {
neogcg's avatar
neogcg committed
100 101 102
      this.$refs.reset != undefined
        ? this.$refs.reset.reset()
        : this.getTableData();
neogcg's avatar
neogcg committed
103
    },
neogcg's avatar
neogcg committed
104 105 106 107 108 109
    search(option){
      this.istrue=1
      this.searchOption = option
      this.getTableData()
    },
    getTableData() {
yanzhongrong's avatar
yanzhongrong committed
110
      let params = {
neogcg's avatar
neogcg committed
111
        ...this.params,
neogcg's avatar
neogcg committed
112
        ...this.searchOption,
neogcg's avatar
neogcg committed
113 114 115 116 117 118
      };
      MonitorMaintainList(params).then((res) => {
        let list = res.records || [];
        this.tableData = list;
        this.total = res.total;
        this.exids = list.map((i) => i.id);
neogcg's avatar
neogcg committed
119 120
        if (this.istrue==1) {
           if (this.tableData.length != 0) {
yanzhongrong's avatar
yanzhongrong committed
121
            successAlert("操作成功");
neogcg's avatar
neogcg committed
122 123 124 125 126
          } else {
            warningAlert("查询结果为空");
          }
          this.istrue=0
        }
neogcg's avatar
neogcg committed
127
      });
yanzhongrong's avatar
yanzhongrong committed
128
    },
neogcg's avatar
neogcg committed
129 130 131 132 133
    deleteCable() {
      MonitorMaintainDelete({ ids: this.multipleSelection }).then((res) => {
        this.$message.success("删除成功!");
        this.getTableData();
      });
neogcg's avatar
neogcg committed
134
    },
yanzhongrong's avatar
yanzhongrong committed
135
    cellClassFn({ row, column, rowIndex, columnIndex }) {
neogcg's avatar
neogcg committed
136 137 138 139
      if (row.alarmLevelName == "紧急" && column.label == "告警级别") {
        return "emergency";
      } else if (row.alarmLevelName == "重要" && column.label == "告警级别") {
        return "important";
neogcg's avatar
neogcg committed
140 141
      } else if (row.alarmLevelName == "一般" && column.label == "告警级别") {
        return "common";
neogcg's avatar
neogcg committed
142
      }
yanzhongrong's avatar
yanzhongrong committed
143
      if (rowIndex % 2 == 1) {
neogcg's avatar
neogcg committed
144
        return "stripe";
neogcg's avatar
neogcg committed
145 146
      }
    },
yanzhongrong's avatar
yanzhongrong committed
147
    toExport() {
neogcg's avatar
neogcg committed
148 149 150 151 152 153 154 155
      if (this.exids.length == 0) {
        this.$message.warning("暂无数据");
        return false;
      } else {
        exportLeakyMaintainHistory({ ids: this.exids }).then((res) => {
          download(res, "vnd.ms-excel", `漏缆监测维修历史.xls`);
        });
      }
neogcg's avatar
neogcg committed
156 157 158 159
    },
  },
  mounted() {
    this.getTableData();
neogcg's avatar
neogcg committed
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
  },
};
</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 {
    line-height: 22px;
  }
  .red {
    color: red;
  }
  .green {
    color: green;
  }
  .black {
    color: black;
  }
  & ::v-deep .stripe {
yanzhongrong's avatar
yanzhongrong committed
187
    background-color: #eaf1fe;
neogcg's avatar
neogcg committed
188 189 190 191 192 193
  }
  & ::v-deep .emergency {
    background-color: #f00;
  }
  & ::v-deep .important {
    background-color: #f89850;
neogcg's avatar
neogcg committed
194
  }
neogcg's avatar
neogcg committed
195
  & ::v-deep .common {
neogcg's avatar
neogcg committed
196
    background-color: #ead906;
neogcg's avatar
neogcg committed
197 198 199 200 201 202
  }
  .page {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
yanzhongrong's avatar
yanzhongrong committed
203
    .current {
neogcg's avatar
neogcg committed
204 205 206 207 208
      margin: 0 20px;
    }
  }
}
</style>