index.vue 5.94 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
        <delids :multipleSelection2="multipleSelection" @del="toDelete">删除</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>
yanzhongrong's avatar
yanzhongrong committed
11
        <el-button :type="isPermit==false ? 'primary' : 'info'" :disabled="isPermit" @click="delAll">清空数据</el-button>
neogcg's avatar
neogcg committed
12 13
      </div>
    </div>
yanzhongrong's avatar
yanzhongrong committed
14
    <div v-if="isQuery">
yanzhongrong's avatar
yanzhongrong committed
15
      <search ref="reset" @search="search" />
yanzhongrong's avatar
yanzhongrong committed
16
    </div>
neogcg's avatar
neogcg committed
17
    <el-table
yanzhongrong's avatar
yanzhongrong committed
18
      :data="tableData"
neogcg's avatar
neogcg committed
19
      style="width: 100%"
yanzhongrong's avatar
yanzhongrong committed
20
      height="calc(88vh - 150px)"
neogcg's avatar
neogcg committed
21 22 23 24 25
      :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
26 27 28 29 30
      <el-table-column
        prop="startPointDeviceName"
        label="网元设备"
        align="center"
      />
neogcg's avatar
neogcg committed
31
      <el-table-column
yanzhongrong's avatar
yanzhongrong committed
32
        prop="pointConnectStatus_text"
neogcg's avatar
neogcg committed
33 34 35
        label="连接状态"
        width="150"
        align="center"
yanzhongrong's avatar
yanzhongrong committed
36
      />
neogcg's avatar
neogcg committed
37 38 39 40
      <el-table-column
        prop="endPointDeviceName"
        label="网元设备"
        align="center"
yanzhongrong's avatar
yanzhongrong committed
41
      />
yanzhongrong's avatar
yanzhongrong committed
42 43
      <el-table-column prop="uploadTime" label="上传时间" align="center" />
      <el-table-column prop="cancelTime" label="取消时间" align="center" />
neogcg's avatar
neogcg committed
44
      <el-table-column
yanzhongrong's avatar
yanzhongrong committed
45
        prop="theInterruptTime"
neogcg's avatar
neogcg committed
46 47 48 49
        label="连接中断时长"
        align="center"
      />
    </el-table>
yanzhongrong's avatar
yanzhongrong committed
50 51 52
    <Pagination
      :limit="params.size"
      :page="params.current"
neogcg's avatar
neogcg committed
53 54 55
      :total="total"
      class="pagination"
      @pagination="handlePageChange"
yanzhongrong's avatar
yanzhongrong committed
56
    />
neogcg's avatar
neogcg committed
57 58 59
  </div>
</template>
<script>
neogcg's avatar
neogcg committed
60 61 62
import {
  ConnectStatusList,
  ConnectStatusDelete,
yanzhongrong's avatar
yanzhongrong committed
63 64 65 66 67 68 69 70 71
  ConnectStatusDeleteAll
} 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'

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

  .page {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
yanzhongrong's avatar
yanzhongrong committed
229
    .current {
neogcg's avatar
neogcg committed
230 231 232 233 234
      margin: 0 20px;
    }
  }
}
</style>