index.vue 6.19 KB
Newer Older
neogcg's avatar
neogcg committed
1 2 3 4
<template>
  <div class="leakage-cable">
    <!-- 设备连接状态 -->
    <div class="leakage-top">
yanzhongrong's avatar
yanzhongrong committed
5
      <div style="color: #666666" />
neogcg's avatar
neogcg committed
6
      <div class="operate-btn">
yanzhongrong's avatar
yanzhongrong committed
7 8 9
        <delids :multipleSelection2="multipleSelection" @del="toDelete"
          >删除</delids
        >
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>
yanzhongrong's avatar
yanzhongrong committed
13 14 15 16 17 18
        <el-button
          :type="isPermit == false ? 'primary' : 'info'"
          :disabled="isPermit"
          @click="delAll"
          >清空数据</el-button
        >
neogcg's avatar
neogcg committed
19 20
      </div>
    </div>
yanzhongrong's avatar
yanzhongrong committed
21
    <div v-if="isQuery">
yanzhongrong's avatar
yanzhongrong committed
22
      <search ref="reset" @search="search" />
yanzhongrong's avatar
yanzhongrong committed
23
    </div>
neogcg's avatar
neogcg committed
24
    <el-table
yanzhongrong's avatar
yanzhongrong committed
25
      :data="tableData"
neogcg's avatar
neogcg committed
26
      style="width: 100%"
yanzhongrong's avatar
yanzhongrong committed
27
      height="calc(88vh - 150px)"
neogcg's avatar
neogcg committed
28 29 30 31 32
      :cell-class-name="cellClassFn"
      :header-cell-style="{ background: '#EAF1FE', color: '#666666' }"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
neogcg's avatar
neogcg committed
33 34 35 36 37
      <el-table-column
        prop="startPointDeviceName"
        label="网元设备"
        align="center"
      />
neogcg's avatar
neogcg committed
38
      <el-table-column
yanzhongrong's avatar
yanzhongrong committed
39
        prop="pointConnectStatus_text"
neogcg's avatar
neogcg committed
40 41 42
        label="连接状态"
        width="150"
        align="center"
yanzhongrong's avatar
yanzhongrong committed
43
      />
neogcg's avatar
neogcg committed
44 45 46 47
      <el-table-column
        prop="endPointDeviceName"
        label="网元设备"
        align="center"
yanzhongrong's avatar
yanzhongrong committed
48
      />
yanzhongrong's avatar
yanzhongrong committed
49 50
      <el-table-column prop="uploadTime" label="上传时间" align="center" />
      <el-table-column prop="cancelTime" label="取消时间" align="center" />
neogcg's avatar
neogcg committed
51
      <el-table-column
yanzhongrong's avatar
yanzhongrong committed
52
        prop="theInterruptTime"
neogcg's avatar
neogcg committed
53 54 55 56
        label="连接中断时长"
        align="center"
      />
    </el-table>
yanzhongrong's avatar
yanzhongrong committed
57 58 59
    <Pagination
      :limit="params.size"
      :page="params.current"
neogcg's avatar
neogcg committed
60 61 62
      :total="total"
      class="pagination"
      @pagination="handlePageChange"
yanzhongrong's avatar
yanzhongrong committed
63
    />
neogcg's avatar
neogcg committed
64 65 66
  </div>
</template>
<script>
neogcg's avatar
neogcg committed
67 68 69
import {
  ConnectStatusList,
  ConnectStatusDelete,
yanzhongrong's avatar
yanzhongrong committed
70
  ConnectStatusDeleteAll
yanzhongrong's avatar
yanzhongrong committed
71 72 73 74 75 76 77
} from '../api';
import { ConnectStatusEnum } from '@/const/index';
import search from './components/search.vue';
import { exportConnectStatusHistory } from '@/api/export';
import download from '@/utils/download';
import { successAlert, warningAlert } from '@/utils/alert';
import { mapState } from 'vuex';
yanzhongrong's avatar
yanzhongrong committed
78

neogcg's avatar
neogcg committed
79
export default {
yanzhongrong's avatar
yanzhongrong committed
80 81 82
  components: {
    search
  },
neogcg's avatar
neogcg committed
83 84 85 86
  props: [],
  data() {
    return {
      multipleSelection: [],
yanzhongrong's avatar
yanzhongrong committed
87 88 89
      ConnectStatusEnum,
      params: {
        current: 1,
yanzhongrong's avatar
yanzhongrong committed
90
        size: 10
neogcg's avatar
neogcg committed
91 92
      },
      total: 10,
yanzhongrong's avatar
yanzhongrong committed
93
      tableData: [],
yanzhongrong's avatar
yanzhongrong committed
94
      isQuery: false,
neogcg's avatar
neogcg committed
95
      istrue: 0,
neogcg's avatar
neogcg committed
96
      searchOption: {},
yanzhongrong's avatar
yanzhongrong committed
97 98
      exids: []
    }
yanzhongrong's avatar
yanzhongrong committed
99
  },
yanzhongrong's avatar
yanzhongrong committed
100 101 102 103
  computed: {
    ...mapState('user', ['userBaseInfo']),
    isPermit() {
      if (this.userBaseInfo.userId === 1) {
yanzhongrong's avatar
yanzhongrong committed
104
        return false;
yanzhongrong's avatar
yanzhongrong committed
105
      } else {
yanzhongrong's avatar
yanzhongrong committed
106
        return true;
yanzhongrong's avatar
yanzhongrong committed
107 108 109 110
      }
    }
  },
  mounted() {
yanzhongrong's avatar
yanzhongrong committed
111
    this.getTableData();
neogcg's avatar
neogcg committed
112 113
  },
  methods: {
yanzhongrong's avatar
yanzhongrong committed
114
    // 多选操作
neogcg's avatar
neogcg committed
115
    handleSelectionChange(val) {
yanzhongrong's avatar
yanzhongrong committed
116 117
      let deleteIds = val.map((item) => item.id);
      this.multipleSelection = deleteIds;
neogcg's avatar
neogcg committed
118
    },
yanzhongrong's avatar
yanzhongrong committed
119
    // 分页更改
neogcg's avatar
neogcg committed
120
    handlePageChange(pageData) {
yanzhongrong's avatar
yanzhongrong committed
121 122 123
      this.params.size = pageData.size;
      this.params.current = pageData.page;
      this.getTableData();
yanzhongrong's avatar
yanzhongrong committed
124
    },
yanzhongrong's avatar
yanzhongrong committed
125
    // 刷新
neogcg's avatar
neogcg committed
126
    refresh() {
yanzhongrong's avatar
yanzhongrong committed
127
      this.$refs.reset !== undefined
neogcg's avatar
neogcg committed
128
        ? this.$refs.reset.reset()
yanzhongrong's avatar
yanzhongrong committed
129
        : this.getTableData();
neogcg's avatar
neogcg committed
130
    },
yanzhongrong's avatar
yanzhongrong committed
131
    // 查询
neogcg's avatar
neogcg committed
132
    search(option) {
yanzhongrong's avatar
yanzhongrong committed
133 134 135
      this.istrue = 1;
      this.searchOption = option;
      this.getTableData();
neogcg's avatar
neogcg committed
136
    },
yanzhongrong's avatar
yanzhongrong committed
137
    // 获取数据
neogcg's avatar
neogcg committed
138
    getTableData() {
neogcg's avatar
neogcg committed
139
      let params = {
yanzhongrong's avatar
yanzhongrong committed
140
        ...this.params,
yanzhongrong's avatar
yanzhongrong committed
141 142
        ...this.searchOption
      }
neogcg's avatar
neogcg committed
143
      ConnectStatusList(params).then((res) => {
yanzhongrong's avatar
yanzhongrong committed
144
        let list = res.records || []
neogcg's avatar
neogcg committed
145 146
        list.forEach((item) => {
          item.pointConnectStatus_text =
yanzhongrong's avatar
yanzhongrong committed
147
            this.ConnectStatusEnum[item.pointConnectStatus];
yanzhongrong's avatar
yanzhongrong committed
148
        })
yanzhongrong's avatar
yanzhongrong committed
149 150
        this.tableData = list;
        this.total = res.total;
yanzhongrong's avatar
yanzhongrong committed
151 152 153
        this.exids = list.map((i) => i.id)
        if (this.istrue === 1) {
          if (this.tableData.length !== 0) {
yanzhongrong's avatar
yanzhongrong committed
154
            successAlert('操作成功');
neogcg's avatar
neogcg committed
155
          } else {
yanzhongrong's avatar
yanzhongrong committed
156
            warningAlert('查询结果为空');
neogcg's avatar
neogcg committed
157
          }
yanzhongrong's avatar
yanzhongrong committed
158
          this.istrue = 0;
neogcg's avatar
neogcg committed
159
        }
yanzhongrong's avatar
yanzhongrong committed
160
      })
neogcg's avatar
neogcg committed
161
    },
yanzhongrong's avatar
yanzhongrong committed
162
    // 删除
yanzhongrong's avatar
yanzhongrong committed
163
    toDelete() {
neogcg's avatar
neogcg committed
164
      ConnectStatusDelete({ ids: this.multipleSelection }).then((res) => {
yanzhongrong's avatar
yanzhongrong committed
165 166
        this.$message.success('删除成功!');
        this.getTableData();
yanzhongrong's avatar
yanzhongrong committed
167
      })
neogcg's avatar
neogcg committed
168
    },
yanzhongrong's avatar
yanzhongrong committed
169
    // 清空
neogcg's avatar
neogcg committed
170
    delAll() {
yanzhongrong's avatar
yanzhongrong committed
171
      this.$confirm('继续操作将永久删除, 是否继续?', '提示', {
neogcg's avatar
neogcg committed
172 173 174 175
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
yanzhongrong's avatar
yanzhongrong committed
176
        ConnectStatusDeleteAll().then((res) => {
yanzhongrong's avatar
yanzhongrong committed
177 178
          this.$message.success('清空成功!');
          this.getTableData();
yanzhongrong's avatar
yanzhongrong committed
179
        })
neogcg's avatar
neogcg committed
180
      }).catch(() => {
yanzhongrong's avatar
yanzhongrong committed
181
        warningAlert('取消删除');
yanzhongrong's avatar
yanzhongrong committed
182
      })
neogcg's avatar
neogcg committed
183
    },
yanzhongrong's avatar
yanzhongrong committed
184
    // 表格背景
neogcg's avatar
neogcg committed
185
    cellClassFn({ row, column, rowIndex, columnIndex }) {
neogcg's avatar
neogcg committed
186
      if (
yanzhongrong's avatar
yanzhongrong committed
187 188
        row.pointConnectStatus_text === '连接异常' &&
        column.label === '连接状态'
neogcg's avatar
neogcg committed
189
      ) {
yanzhongrong's avatar
yanzhongrong committed
190
        return 'emergency';
neogcg's avatar
neogcg committed
191
      } else if (
yanzhongrong's avatar
yanzhongrong committed
192 193
        row.pointConnectStatus_text === '连接正常' &&
        column.label === '连接状态'
neogcg's avatar
neogcg committed
194
      ) {
yanzhongrong's avatar
yanzhongrong committed
195
        return 'normal';
neogcg's avatar
neogcg committed
196
      }
yanzhongrong's avatar
yanzhongrong committed
197
      if (rowIndex % 2 === 1) {
yanzhongrong's avatar
yanzhongrong committed
198
        return 'stripe';
neogcg's avatar
neogcg committed
199 200
      }
    },
yanzhongrong's avatar
yanzhongrong committed
201
    // 导出
yanzhongrong's avatar
yanzhongrong committed
202
    toExport() {
yanzhongrong's avatar
yanzhongrong committed
203
      if (this.exids.length === 0) {
yanzhongrong's avatar
yanzhongrong committed
204 205
        this.$message.warning('暂无数据');
        return false;
neogcg's avatar
neogcg committed
206 207
      } else {
        exportConnectStatusHistory({ ids: this.exids }).then((res) => {
yanzhongrong's avatar
yanzhongrong committed
208
          download(res, 'vnd.ms-excel', `设备连接历史状态.xls`);
yanzhongrong's avatar
yanzhongrong committed
209
        })
neogcg's avatar
neogcg committed
210
      }
yanzhongrong's avatar
yanzhongrong committed
211 212 213
    }
  }
}
neogcg's avatar
neogcg committed
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
</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;
  }
  & ::v-deep .stripe {
    background-color: #eaf1fe;
  }
  & ::v-deep .emergency {
yanzhongrong's avatar
yanzhongrong committed
230
    background-color: #f00 !important;
neogcg's avatar
neogcg committed
231 232
  }
  & ::v-deep .important {
yanzhongrong's avatar
yanzhongrong committed
233
    background-color: #f89850 !important;
neogcg's avatar
neogcg committed
234 235
  }
  & ::v-deep .normal {
yanzhongrong's avatar
yanzhongrong committed
236
    background-color: green !important;
neogcg's avatar
neogcg committed
237 238 239 240 241 242
  }
  .page {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
yanzhongrong's avatar
yanzhongrong committed
243
    .current {
neogcg's avatar
neogcg committed
244 245 246 247 248
      margin: 0 20px;
    }
  }
}
</style>