index.vue 3.72 KB
Newer Older
renhanxue's avatar
renhanxue committed
1
<template>
yanzhongrong's avatar
yanzhongrong committed
2 3
  <div class="leakage-cable">
    <div class="leakage-top">
neogcg's avatar
neogcg committed
4
      <div style="color: #666666"></div>
neogcg's avatar
neogcg committed
5
      <div class="operate-btn">
6
        <el-button type="primary" @click="addUser">添加新用户</el-button>
neogcg's avatar
neogcg committed
7 8
      </div>
    </div>
renhanxue's avatar
renhanxue committed
9 10
    <el-table
      v-loading="loading"
yanzhongrong's avatar
yanzhongrong committed
11
      :data="tableData"
renhanxue's avatar
renhanxue committed
12
      class="statistics-table"
renhanxue's avatar
renhanxue committed
13 14
      style="width: 100%"
      :row-class-name="tableRowClassName"
yanzhongrong's avatar
yanzhongrong committed
15 16 17 18 19 20
      :header-cell-style="{
        background: '#eaf1fe',
        color: '#000',
        fontWeight: 700,
        height: '50px',
      }"
renhanxue's avatar
renhanxue committed
21
    >
yanzhongrong's avatar
yanzhongrong committed
22 23 24 25 26 27 28
      <el-table-column
        type="index"
        label="用户编号"
        align="center"
        width="100"
      />
      <el-table-column prop="userName" label="用户名" align="center" />
renhanxue's avatar
renhanxue committed
29
      <el-table-column prop="realName" label="真实姓名" align="center" />
30
      <el-table-column prop="deptName" label="用户部门" align="center" />
renhanxue's avatar
renhanxue committed
31 32 33
      <el-table-column prop="phone" label="电话号码" align="center" />
      <el-table-column prop="email" label="邮箱" align="center" />
      <el-table-column label="操作" align="center">
yanzhongrong's avatar
yanzhongrong committed
34 35 36
        <template slot-scope="scope">
          <el-button type="text" @click="toEditPwd(scope.row)">修改密码</el-button>
          <el-button type="text" @click="toEditInfo(scope.row)">修改基本信息</el-button>
renhanxue's avatar
renhanxue committed
37 38 39
        </template>
      </el-table-column>
    </el-table>
yanzhongrong's avatar
yanzhongrong committed
40 41 42
    <Pagination
      :limit="params.pageSize"
      :page="params.pageNum"
renhanxue's avatar
renhanxue committed
43 44 45 46
      :total="total"
      class="pagination"
      @pagination="handlePageChange"
    />
47 48 49
    <edit @reset="reset" :cur-info="curInfo" :flag="flag"></edit>
    <ediPwd @reset="reset" :cur-info="curInfo" :flag1="flag1"></ediPwd>

renhanxue's avatar
renhanxue committed
50
  </div>
renhanxue's avatar
renhanxue committed
51 52 53
</template>

<script>
54 55 56 57
import { list } from '../api'
import edit from './components/editInfo.vue'
import ediPwd from './components/editPwd.vue'

renhanxue's avatar
renhanxue committed
58 59 60
export default {
  data() {
    return {
yanzhongrong's avatar
yanzhongrong committed
61
      params: {
renhanxue's avatar
renhanxue committed
62 63 64
        pageNum: 1,
        pageSize: 10
      },
yanzhongrong's avatar
yanzhongrong committed
65
      tableData: [],
renhanxue's avatar
renhanxue committed
66
      total: 5,
67 68 69 70
      loading: false,
      curInfo: {},
      flag: 0,
      flag1: 0
renhanxue's avatar
renhanxue committed
71 72
    }
  },
73 74 75 76
  components: {
    edit,
    ediPwd
  },
renhanxue's avatar
renhanxue committed
77
  methods: {
renhanxue's avatar
renhanxue committed
78 79 80
    tableRowClassName({ row, rowIndex }) {
      return rowIndex % 2 === 0 ? '' : 'single-row'
    },
renhanxue's avatar
renhanxue committed
81
    handlePageChange(pageData) {
yanzhongrong's avatar
yanzhongrong committed
82 83 84
      this.params.pageSize = pageData.size
      this.params.pageNum = pageData.page
      this.getTableData()
neogcg's avatar
neogcg committed
85
    },
yanzhongrong's avatar
yanzhongrong committed
86 87 88 89 90 91 92
    getTableData() {
      let params = {
        current: this.params.pageNum,
        size: this.params.pageSize
      }
      list(params).then(res => {
        let list = res.records || []
yanzhongrong's avatar
yanzhongrong committed
93 94 95
        list.forEach(item => {
          item.userId = item.id
        })
yanzhongrong's avatar
yanzhongrong committed
96 97 98
        this.tableData = list
        this.total = res.total
      })
neogcg's avatar
neogcg committed
99
    },
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
    addUser() {
      this.curInfo = {}
      this.flag = 1
    },
    toEditInfo(row) {
      this.curInfo = row
      this.flag = 2
    },
    toEditPwd(row) {
      this.curInfo = row
      this.flag1 = 3
    },
    reset(needRefresh) {
      this.flag = 0
      this.flag1 = 0
      if(needRefresh) {
        this.getTableData()
      }
    }
neogcg's avatar
neogcg committed
119 120 121 122
  },
  mounted() {
    this.getTableData()
  },
renhanxue's avatar
renhanxue committed
123 124 125
}
</script>
<style lang="scss" scoped>
neogcg's avatar
neogcg committed
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
.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 .red {
    background-color: #f00;
  }
  & ::v-deep .green {
    background-color: green;
  }
  .page {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
    .pageNum {
      margin: 0 20px;
    }
  }
renhanxue's avatar
renhanxue committed
154
}
renhanxue's avatar
renhanxue committed
155
</style>
renhanxue's avatar
renhanxue committed
156 157 158 159 160 161 162 163 164
<style lang="scss">
.statistics-table {
  .single-row {
    background: #f1f6ff;
  }
  td {
    padding: 5px !important;
  }
}
neogcg's avatar
neogcg committed
165
</style>