index.vue 5.81 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">
yanzhongrong's avatar
yanzhongrong committed
7
        <delids :multipleSelection2="multipleSelection" @del="deleteCable">删除</delids>
neogcg's avatar
neogcg committed
8
        <el-button type="primary" @click="refresh">刷新</el-button>
yanzhongrong's avatar
yanzhongrong committed
9
        <el-button type="primary" @click="isQuery = !isQuery">查询</el-button>
yanzhongrong's avatar
yanzhongrong committed
10
        <el-button type="primary" @click="toExport">导出</el-button>
neogcg's avatar
neogcg committed
11 12
      </div>
    </div>
yanzhongrong's avatar
yanzhongrong committed
13
    <div v-if="isQuery">
yanzhongrong's avatar
yanzhongrong committed
14
      <search ref="reset" @search="search" />
yanzhongrong's avatar
yanzhongrong committed
15
    </div>
neogcg's avatar
neogcg committed
16
    <el-table
yanzhongrong's avatar
yanzhongrong committed
17
      :data="tableData"
yanzhongrong's avatar
yanzhongrong committed
18
      height="calc(88vh - 150px)"
neogcg's avatar
neogcg committed
19 20 21
      style="width: 100%"
      :cell-class-name="cellClassFn"
      :header-cell-style="{ background: '#EAF1FE', color: '#666666' }"
yanzhongrong's avatar
yanzhongrong committed
22
      @selection-change="handleSelectionChange"
neogcg's avatar
neogcg committed
23 24 25 26
    >
      <el-table-column type="selection" width="55" align="center" />

      <el-table-column
yanzhongrong's avatar
yanzhongrong committed
27
        prop="siteName"
neogcg's avatar
neogcg committed
28 29 30 31 32
        label="基站名称"
        width="180"
        align="center"
      />
      <el-table-column
yanzhongrong's avatar
yanzhongrong committed
33
        prop="alarmTarget"
neogcg's avatar
neogcg committed
34 35 36 37
        label="告警对象"
        width="180"
        align="center"
      />
neogcg's avatar
neogcg committed
38 39 40 41 42
      <el-table-column
        prop="alarmLevelName"
        label="告警级别"
        width="150"
        align="center"
yanzhongrong's avatar
yanzhongrong committed
43
      />
yanzhongrong's avatar
yanzhongrong committed
44 45 46 47 48 49 50 51 52 53
      <el-table-column prop="alarmInfo" label="告警信息" align="center">
        <template slot-scope="scope">
          <div v-for="(item, index) in scope.row.alarmInfo" :key="index" :class="levelStyle[item.level]">
            <span>距离:{{ item.distance }}</span>&nbsp;&nbsp;
            <span>驻波比:{{ item.value }}</span><br/>
          </div>
          <div>漏缆百米损耗: {{  scope.row.lossValue }}</div>
        </template>
      </el-table-column>

neogcg's avatar
neogcg committed
54 55 56 57 58
      <el-table-column
        prop="alarmMaintainTime"
        label="告警维修时间"
        align="center"
      />
neogcg's avatar
neogcg committed
59
    </el-table>
yanzhongrong's avatar
yanzhongrong committed
60 61 62
    <Pagination
      :limit="params.size"
      :page="params.current"
neogcg's avatar
neogcg committed
63 64 65
      :total="total"
      class="pagination"
      @pagination="handlePageChange"
yanzhongrong's avatar
yanzhongrong committed
66
    />
neogcg's avatar
neogcg committed
67 68 69
  </div>
</template>
<script>
yanzhongrong's avatar
yanzhongrong committed
70 71 72 73 74 75 76
import { MonitorMaintainList, MonitorMaintainDelete } from '../api';
import search from './components/search.vue';
import download from '@/utils/download';
import { exportLeakyMaintainHistory } from '@/api/export';
import { successAlert, warningAlert } from '@/utils/alert';
import { levelStyle } from '@/const/index';

neogcg's avatar
neogcg committed
77
export default {
yanzhongrong's avatar
yanzhongrong committed
78 79 80
  components: {
    search
  },
neogcg's avatar
neogcg committed
81 82 83 84
  props: [],
  data() {
    return {
      multipleSelection: [],
yanzhongrong's avatar
yanzhongrong committed
85 86
      params: {
        current: 1,
yanzhongrong's avatar
yanzhongrong committed
87
        size: 10
neogcg's avatar
neogcg committed
88 89
      },
      total: 10,
yanzhongrong's avatar
yanzhongrong committed
90
      tableData: [],
yanzhongrong's avatar
yanzhongrong committed
91
      isQuery: false,
yanzhongrong's avatar
yanzhongrong committed
92
      istrue: 0,
neogcg's avatar
neogcg committed
93
      searchOption: {},
yanzhongrong's avatar
yanzhongrong committed
94 95
      exids: [],
      levelStyle
yanzhongrong's avatar
yanzhongrong committed
96
    }
neogcg's avatar
neogcg committed
97
  },
yanzhongrong's avatar
yanzhongrong committed
98
  mounted() {
yanzhongrong's avatar
yanzhongrong committed
99
    this.getTableData();
yanzhongrong's avatar
yanzhongrong committed
100
  },
neogcg's avatar
neogcg committed
101
  methods: {
yanzhongrong's avatar
yanzhongrong committed
102
    // 多选操作
neogcg's avatar
neogcg committed
103
    handleSelectionChange(val) {
yanzhongrong's avatar
yanzhongrong committed
104 105
      let deleteIds = val.map((item) => item.id);
      this.multipleSelection = deleteIds;
neogcg's avatar
neogcg committed
106
    },
yanzhongrong's avatar
yanzhongrong committed
107
    // 分页更改
neogcg's avatar
neogcg committed
108
    handlePageChange(pageData) {
yanzhongrong's avatar
yanzhongrong committed
109 110 111
      this.params.size = pageData.size;
      this.params.current = pageData.page;
      this.getTableData();
neogcg's avatar
neogcg committed
112
    },
yanzhongrong's avatar
yanzhongrong committed
113
    // 刷新
neogcg's avatar
neogcg committed
114
    refresh() {
yanzhongrong's avatar
yanzhongrong committed
115
      this.$refs.reset !== undefined
neogcg's avatar
neogcg committed
116
        ? this.$refs.reset.reset()
yanzhongrong's avatar
yanzhongrong committed
117
        : this.getTableData();
neogcg's avatar
neogcg committed
118
    },
yanzhongrong's avatar
yanzhongrong committed
119
    // 查询
yanzhongrong's avatar
yanzhongrong committed
120
    search(option) {
yanzhongrong's avatar
yanzhongrong committed
121 122 123
      this.istrue = 1;
      this.searchOption = option;
      this.getTableData();
neogcg's avatar
neogcg committed
124
    },
yanzhongrong's avatar
yanzhongrong committed
125
    // 获取数据
neogcg's avatar
neogcg committed
126
    getTableData() {
yanzhongrong's avatar
yanzhongrong committed
127
      let params = {
neogcg's avatar
neogcg committed
128
        ...this.params,
yanzhongrong's avatar
yanzhongrong committed
129 130
        ...this.searchOption
      }
neogcg's avatar
neogcg committed
131
      MonitorMaintainList(params).then((res) => {
yanzhongrong's avatar
yanzhongrong committed
132
        let list = res.records || [];
yanzhongrong's avatar
yanzhongrong committed
133
        list.forEach(item => {
yanzhongrong's avatar
yanzhongrong committed
134 135
          item.alarmInfo = JSON.parse(item.alarmInfo);
          item.lossValue = eval(item.alarmInfo.map(k => k.lossValue).join('+'));
yanzhongrong's avatar
yanzhongrong committed
136
        })
yanzhongrong's avatar
yanzhongrong committed
137 138 139
        this.tableData = list;
        this.total = res.total;
        this.exids = list.map((i) => i.id);
yanzhongrong's avatar
yanzhongrong committed
140 141
        if (this.istrue === 1) {
          if (this.tableData.length !== 0) {
yanzhongrong's avatar
yanzhongrong committed
142
            successAlert('操作成功');
neogcg's avatar
neogcg committed
143
          } else {
yanzhongrong's avatar
yanzhongrong committed
144
            warningAlert('查询结果为空');
neogcg's avatar
neogcg committed
145
          }
yanzhongrong's avatar
yanzhongrong committed
146
          this.istrue = 0;
neogcg's avatar
neogcg committed
147
        }
yanzhongrong's avatar
yanzhongrong committed
148
      })
yanzhongrong's avatar
yanzhongrong committed
149
    },
yanzhongrong's avatar
yanzhongrong committed
150
    // 删除
neogcg's avatar
neogcg committed
151 152
    deleteCable() {
      MonitorMaintainDelete({ ids: this.multipleSelection }).then((res) => {
yanzhongrong's avatar
yanzhongrong committed
153 154
        this.$message.success('删除成功!');
        this.getTableData();
yanzhongrong's avatar
yanzhongrong committed
155
      })
neogcg's avatar
neogcg committed
156
    },
yanzhongrong's avatar
yanzhongrong committed
157
    // 表格背景
yanzhongrong's avatar
yanzhongrong committed
158
    cellClassFn({ row, column, rowIndex, columnIndex }) {
yanzhongrong's avatar
yanzhongrong committed
159
      if (row.alarmLevelName === '紧急' && column.label === '告警级别') {
yanzhongrong's avatar
yanzhongrong committed
160
        return 'emergency';
yanzhongrong's avatar
yanzhongrong committed
161
      } else if (row.alarmLevelName === '重要' && column.label === '告警级别') {
yanzhongrong's avatar
yanzhongrong committed
162
        return 'important';
yanzhongrong's avatar
yanzhongrong committed
163
      } else if (row.alarmLevelName === '一般' && column.label === '告警级别') {
yanzhongrong's avatar
yanzhongrong committed
164
        return 'common';
neogcg's avatar
neogcg committed
165
      }
yanzhongrong's avatar
yanzhongrong committed
166
      if (rowIndex % 2 === 1) {
yanzhongrong's avatar
yanzhongrong committed
167
        return 'stripe';
neogcg's avatar
neogcg committed
168 169
      }
    },
yanzhongrong's avatar
yanzhongrong committed
170
    // 导出
yanzhongrong's avatar
yanzhongrong committed
171
    toExport() {
yanzhongrong's avatar
yanzhongrong committed
172
      if (this.exids.length === 0) {
yanzhongrong's avatar
yanzhongrong committed
173 174
        this.$message.warning('暂无数据');
        return false;
neogcg's avatar
neogcg committed
175 176
      } else {
        exportLeakyMaintainHistory({ ids: this.exids }).then((res) => {
yanzhongrong's avatar
yanzhongrong committed
177
          download(res, 'vnd.ms-excel', `漏缆监测维修历史.xls`);
yanzhongrong's avatar
yanzhongrong committed
178
        })
neogcg's avatar
neogcg committed
179
      }
yanzhongrong's avatar
yanzhongrong committed
180 181 182
    }
  }
}
neogcg's avatar
neogcg committed
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
</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
208
    background-color: #eaf1fe;
neogcg's avatar
neogcg committed
209 210 211 212 213 214
  }
  & ::v-deep .emergency {
    background-color: #f00;
  }
  & ::v-deep .important {
    background-color: #f89850;
neogcg's avatar
neogcg committed
215
  }
neogcg's avatar
neogcg committed
216
  & ::v-deep .common {
neogcg's avatar
neogcg committed
217
    background-color: #ead906;
neogcg's avatar
neogcg committed
218 219 220 221 222 223
  }
  .page {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
yanzhongrong's avatar
yanzhongrong committed
224
    .current {
neogcg's avatar
neogcg committed
225 226 227 228 229
      margin: 0 20px;
    }
  }
}
</style>