index.vue 3.9 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
        <el-button type="primary" @click="refresh">刷新</el-button>
yanzhongrong's avatar
yanzhongrong committed
8
        <el-button type="primary" @click="isQuery = !isQuery">查询</el-button>
9
        <el-button type="primary" @click="exportLog">导出</el-button>
neogcg's avatar
neogcg committed
10 11
      </div>
    </div>
yanzhongrong's avatar
yanzhongrong committed
12
    <div v-if="isQuery">
neogcg's avatar
neogcg committed
13
      <search @search="search" ref="reset" />
yanzhongrong's avatar
yanzhongrong committed
14
    </div>
neogcg's avatar
neogcg committed
15
    <el-table
16 17 18 19 20
      :data="tableData"
      style="width: 100%"
      class="statistics-table"
      :row-class-name="tableRowClassName"
      :row-style="{ height: '50px' }"
neogcg's avatar
neogcg committed
21 22
      :header-cell-style="{ background: '#EAF1FE', color: '#666666' }"
    >
23
      <el-table-column prop="userName" label="用户名" align="center" />
neogcg's avatar
neogcg committed
24 25
      <el-table-column prop="operateTypeName" label="操作类别" align="center" />
      <el-table-column prop="operateObjName" label="操作对象" align="center" />
neogcg's avatar
neogcg committed
26
      <el-table-column prop="objectName" label="对象名称" align="center" />
neogcg's avatar
neogcg committed
27
      <el-table-column prop="operateContent" label="操作内容" align="center" />
neogcg's avatar
neogcg committed
28
      <el-table-column
neogcg's avatar
neogcg committed
29 30
        prop="operateResultName"
        label="操作结果"
neogcg's avatar
neogcg committed
31 32
        align="center"
      />
33
      <el-table-column prop="creationTime" label="操作时间" align="center" />
neogcg's avatar
neogcg committed
34
    </el-table>
35
    <Pagination
yanzhongrong's avatar
yanzhongrong committed
36 37
      :limit="params.size"
      :page="params.current"
neogcg's avatar
neogcg committed
38 39 40 41 42 43 44
      :total="total"
      class="pagination"
      @pagination="handlePageChange"
    />
  </div>
</template>
<script>
neogcg's avatar
neogcg committed
45 46 47 48 49
import { logList } from "../api";
import search from "./components/search.vue";
import { exportLog } from "@/api/export";
import download from "@/utils/download";
import { successAlert, warningAlert } from "@/utils/alert";
yanzhongrong's avatar
yanzhongrong committed
50

neogcg's avatar
neogcg committed
51 52 53
export default {
  data() {
    return {
54
      params: {
yanzhongrong's avatar
yanzhongrong committed
55 56
        current: 1,
        size: 10,
neogcg's avatar
neogcg committed
57 58
      },
      total: 10,
59
      tableData: [],
yanzhongrong's avatar
yanzhongrong committed
60
      isQuery: false,
yanzhongrong's avatar
yanzhongrong committed
61
      istrue: 0,
neogcg's avatar
neogcg committed
62
      searchOption: {},
neogcg's avatar
neogcg committed
63
      exids: [],
neogcg's avatar
neogcg committed
64 65
    };
  },
yanzhongrong's avatar
yanzhongrong committed
66
  components: {
neogcg's avatar
neogcg committed
67
    search,
yanzhongrong's avatar
yanzhongrong committed
68
  },
neogcg's avatar
neogcg committed
69 70
  methods: {
    handlePageChange(pageData) {
yanzhongrong's avatar
yanzhongrong committed
71 72
      this.params.size = pageData.size;
      this.params.current = pageData.page;
neogcg's avatar
neogcg committed
73
      this.getTableData();
neogcg's avatar
neogcg committed
74
    },
neogcg's avatar
neogcg committed
75 76 77 78
    refresh() {
      this.$refs.reset != undefined
        ? this.$refs.reset.reset()
        : this.getTableData();
neogcg's avatar
neogcg committed
79
    },
yanzhongrong's avatar
yanzhongrong committed
80 81 82 83 84
    search(option) {
      this.params.current = 1;
      this.istrue = 1;
      this.searchOption = option;
      this.getTableData();
neogcg's avatar
neogcg committed
85 86
    },
    getTableData() {
yanzhongrong's avatar
yanzhongrong committed
87

88
      let params = {
neogcg's avatar
neogcg committed
89 90 91 92 93 94 95 96
        ...this.params,
        ...this.searchOption,
      };
      logList(params).then((res) => {
        let list = res.records || [];
        this.tableData = list;
        this.total = res.total;
        this.exids = list.map((i) => i.id);
yanzhongrong's avatar
yanzhongrong committed
97 98
        if (this.istrue == 1) {
          if (this.tableData.length != 0) {
yanzhongrong's avatar
yanzhongrong committed
99
            successAlert("操作成功");
neogcg's avatar
neogcg committed
100 101 102
          } else {
            warningAlert("查询结果为空");
          }
yanzhongrong's avatar
yanzhongrong committed
103
          this.istrue = 0;
neogcg's avatar
neogcg committed
104 105
        }
      });
neogcg's avatar
neogcg committed
106
    },
107
    tableRowClassName({ row, rowIndex }) {
neogcg's avatar
neogcg committed
108
      return rowIndex % 2 === 0 ? "" : "single-row";
neogcg's avatar
neogcg committed
109
    },
110
    exportLog() {
neogcg's avatar
neogcg committed
111 112 113 114 115 116 117 118 119 120 121 122
      if (this.exids.length == 0) {
        this.$message.warning("暂无数据");
        return false;
      } else {
        exportLog({ ids: this.exids }).then((res) => {
          download(res, "vnd.ms-excel", `用户日志.xls`);
        });
      }
    },
  },
  mounted() {
    this.getTableData();
neogcg's avatar
neogcg committed
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
  },
};
</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;
  }
  .page {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
yanzhongrong's avatar
yanzhongrong committed
142
    .current {
neogcg's avatar
neogcg committed
143 144 145 146
      margin: 0 20px;
    }
  }
}
neogcg's avatar
neogcg committed
147 148 149 150 151 152 153 154 155 156
</style>
<style lang="scss">
.statistics-table {
  .single-row {
    background: #f1f6ff;
  }
  td {
    padding: 5px !important;
  }
}
neogcg's avatar
neogcg committed
157
</style>