index.vue 5.71 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="toDelete"
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
        <el-button type="primary" @click="delAll">清空数据</el-button>
neogcg's avatar
neogcg committed
14 15
      </div>
    </div>
yanzhongrong's avatar
yanzhongrong committed
16
    <div v-if="isQuery">
neogcg's avatar
neogcg committed
17
      <search @search="search" ref="reset" />
yanzhongrong's avatar
yanzhongrong committed
18
    </div>
neogcg's avatar
neogcg committed
19
    <el-table
yanzhongrong's avatar
yanzhongrong committed
20
      :data="tableData"
neogcg's avatar
neogcg committed
21 22 23 24 25 26
      style="width: 100%"
      :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
27 28 29 30 31
      <el-table-column
        prop="startPointDeviceName"
        label="网元设备"
        align="center"
      />
neogcg's avatar
neogcg committed
32
      <el-table-column
yanzhongrong's avatar
yanzhongrong committed
33
        prop="pointConnectStatus_text"
neogcg's avatar
neogcg committed
34 35 36 37 38
        label="连接状态"
        width="150"
        align="center"
      >
      </el-table-column>
neogcg's avatar
neogcg committed
39 40 41 42 43
      <el-table-column
        prop="endPointDeviceName"
        label="网元设备"
        align="center"
      >
neogcg's avatar
neogcg committed
44
      </el-table-column>
yanzhongrong's avatar
yanzhongrong committed
45 46
      <el-table-column prop="uploadTime" label="上传时间" align="center" />
      <el-table-column prop="cancelTime" label="取消时间" align="center" />
neogcg's avatar
neogcg committed
47
      <el-table-column
yanzhongrong's avatar
yanzhongrong committed
48
        prop="theInterruptTime"
neogcg's avatar
neogcg committed
49 50 51 52
        label="连接中断时长"
        align="center"
      />
    </el-table>
yanzhongrong's avatar
yanzhongrong committed
53 54 55
    <Pagination
      :limit="params.size"
      :page="params.current"
neogcg's avatar
neogcg committed
56 57 58
      :total="total"
      class="pagination"
      @pagination="handlePageChange"
yanzhongrong's avatar
yanzhongrong committed
59
    />
neogcg's avatar
neogcg committed
60 61 62
  </div>
</template>
<script>
neogcg's avatar
neogcg committed
63 64 65 66 67
import {
  ConnectStatusList,
  ConnectStatusDelete,
  ConnectStatusDeleteAll,
} from "../api";
neogcg's avatar
neogcg committed
68 69 70 71
import { ConnectStatusEnum } from "@/const/index";
import search from "./components/search.vue";
import { exportConnectStatusHistory } from "@/api/export";
import download from "@/utils/download";
neogcg's avatar
neogcg committed
72
import { successAlert, warningAlert } from "@/utils/alert";
neogcg's avatar
neogcg committed
73 74 75 76 77
export default {
  props: [],
  data() {
    return {
      multipleSelection: [],
yanzhongrong's avatar
yanzhongrong committed
78 79 80 81
      ConnectStatusEnum,
      params: {
        current: 1,
        size: 10,
neogcg's avatar
neogcg committed
82 83
      },
      total: 10,
yanzhongrong's avatar
yanzhongrong committed
84
      tableData: [],
yanzhongrong's avatar
yanzhongrong committed
85
      isQuery: false,
neogcg's avatar
neogcg committed
86
      istrue: 0,
neogcg's avatar
neogcg committed
87 88 89
      searchOption: {},
      exids: [],
    };
yanzhongrong's avatar
yanzhongrong committed
90 91
  },
  components: {
neogcg's avatar
neogcg committed
92
    search,
neogcg's avatar
neogcg committed
93 94 95
  },
  methods: {
    handleSelectionChange(val) {
neogcg's avatar
neogcg committed
96 97
      let deleteIds = val.map((item) => item.id);
      this.multipleSelection = deleteIds;
neogcg's avatar
neogcg committed
98 99
    },
    handlePageChange(pageData) {
neogcg's avatar
neogcg committed
100 101 102
      this.params.size = pageData.size;
      this.params.current = pageData.page;
      this.getTableData();
yanzhongrong's avatar
yanzhongrong committed
103
    },
neogcg's avatar
neogcg committed
104
    refresh() {
neogcg's avatar
neogcg committed
105 106 107
      this.$refs.reset != undefined
        ? this.$refs.reset.reset()
        : this.getTableData();
neogcg's avatar
neogcg committed
108
    },
neogcg's avatar
neogcg committed
109 110
    search(option) {
      this.istrue = 1;
neogcg's avatar
neogcg committed
111
      this.searchOption = option;
neogcg's avatar
neogcg committed
112 113 114
      this.getTableData();
    },
    getTableData() {
neogcg's avatar
neogcg committed
115
      let params = {
yanzhongrong's avatar
yanzhongrong committed
116
        ...this.params,
neogcg's avatar
neogcg committed
117
        ...this.searchOption,
neogcg's avatar
neogcg committed
118 119 120 121 122 123 124 125 126 127
      };
      ConnectStatusList(params).then((res) => {
        let list = res.records || [];
        list.forEach((item) => {
          item.pointConnectStatus_text =
            this.ConnectStatusEnum[item.pointConnectStatus];
        });
        this.tableData = list;
        this.total = res.total;
        this.exids = list.map((i) => i.id);
neogcg's avatar
neogcg committed
128 129
        if (this.istrue == 1) {
          if (this.tableData.length != 0) {
yanzhongrong's avatar
yanzhongrong committed
130
            successAlert("操作成功");
neogcg's avatar
neogcg committed
131 132 133 134 135
          } else {
            warningAlert("查询结果为空");
          }
          this.istrue = 0;
        }
neogcg's avatar
neogcg committed
136
      });
neogcg's avatar
neogcg committed
137
    },
yanzhongrong's avatar
yanzhongrong committed
138
    toDelete() {
neogcg's avatar
neogcg committed
139 140 141 142
      ConnectStatusDelete({ ids: this.multipleSelection }).then((res) => {
        this.$message.success("删除成功!");
        this.getTableData();
      });
neogcg's avatar
neogcg committed
143
    },
neogcg's avatar
neogcg committed
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
    delAll() {
        this.$confirm('继续操作将永久删除, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
         ConnectStatusDeleteAll().then((res)=>{
      this.$message.success("清空成功!");
         this.getTableData();
      });
      }).catch(() => {
        warningAlert("取消删除")
      });
    
    },
neogcg's avatar
neogcg committed
159
    cellClassFn({ row, column, rowIndex, columnIndex }) {
neogcg's avatar
neogcg committed
160 161 162 163
      if (
        row.pointConnectStatus_text == "连接异常" &&
        column.label == "连接状态"
      ) {
neogcg's avatar
neogcg committed
164
        return "emergency";
neogcg's avatar
neogcg committed
165 166 167 168
      } else if (
        row.pointConnectStatus_text == "连接正常" &&
        column.label == "连接状态"
      ) {
neogcg's avatar
neogcg committed
169 170 171 172 173 174
        return "normal";
      }
      if (rowIndex % 2 == 1) {
        return "stripe";
      }
    },
yanzhongrong's avatar
yanzhongrong committed
175
    toExport() {
neogcg's avatar
neogcg committed
176 177 178 179 180 181 182 183
      if (this.exids.length == 0) {
        this.$message.warning("暂无数据");
        return false;
      } else {
        exportConnectStatusHistory({ ids: this.exids }).then((res) => {
          download(res, "vnd.ms-excel", `设备连接历史状态.xls`);
        });
      }
neogcg's avatar
neogcg committed
184
    },
neogcg's avatar
neogcg committed
185
  },
neogcg's avatar
neogcg committed
186
  mounted() {
neogcg's avatar
neogcg committed
187
    this.getTableData();
neogcg's avatar
neogcg committed
188
  },
neogcg's avatar
neogcg committed
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
};
</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 {
    background-color: #f00;
  }
  & ::v-deep .important {
    background-color: #f89850;
  }
  & ::v-deep .normal {
    background-color: green;
  }

  .page {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
yanzhongrong's avatar
yanzhongrong committed
221
    .current {
neogcg's avatar
neogcg committed
222 223 224 225 226
      margin: 0 20px;
    }
  }
}
</style>