schangxiang@126.com
2025-09-19 9be9c3784b2881a3fa25e93ae2033dc2803c0ed0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<template>
  <!-- 面包屑导航区 -->
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>系统设置</el-breadcrumb-item>
      <el-breadcrumb-item>人员管理</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片视图区 -->
    <el-card>
      <!-- 搜索与添加 -->
 
      <el-row>
        <el-col :span="8">
 
          <el-input v-model="input" placeholder="请输入内容" clearable>
            <el-button slot="append" icon="el-icon-search"></el-button>
          </el-input>
        </el-col>
        <el-col :span="4">
          <el-button type="success" plain>添加人员</el-button>
        </el-col>
      </el-row>
      <!-- 显示人员列表 -->
      <el-table :data="userlist" border stripe>
        <el-table-column label="ID" prop="id"></el-table-column>
        <el-table-column label="登录账号" prop="UserName"></el-table-column>
        <el-table-column label="名称" prop="Name"></el-table-column>
        <el-table-column label="工号" prop="WorkNo"></el-table-column>
        <el-table-column label="职位" prop="Position"></el-table-column>
        <el-table-column label="电话" prop="Tel"></el-table-column>
        <el-table-column label="状态" prop="Status">
          <template slot-scope="scope">
            <el-switch v-model="scope.row.Status" @change="userStatusChange(scope.row)">
            </el-switch>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="200px">
          <template slot-scope="scope">
            <!-- 修改按钮 -->
            <el-button type="primary" icon="el-icon-edit" size="mini"></el-button>
            <!-- 删除按钮 -->
 
            <el-button type="danger" icon="el-icon-delete" size="mini"></el-button>
            <!-- 分配角色按钮 -->
 
            <el-tooltip :enterable="false" effect="dark" content="分配角色" placement="top">
              <el-button type="warning" icon="el-icon-setting" size="mini"></el-button>
            </el-tooltip>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination :total="total" :page-sizes="[5, 10, 15, 20]" :page-size="queryInfo.pagesize" :current-page="queryInfo.pagenum" layout="total, sizes, prev, pager, next, jumper" @size-change="handleSizeChange" @current-change="handleCurrentChange">
      </el-pagination>
    </el-card>
  </div>
</template>
<script>
export default {
  data() {
    return {
      input: "",
      queryInfo: {
        query: "",
        // 当前页
        pagenum: 1,
        // 每页显示多少条信息
        pagesize: 10
      },
      userlist: [],
      total: 0
    };
  },
  created() {},
  mounted() {
    this.getUserList();
  },
  methods: {
    async getUserList() {
      const { data: res } = await this.$http.get("getuser", {
        params: this.queryInfo
      });
      if (res.mssg.status !== 200) return this.$message.error("人员为空");
      this.userlist = res.data;
      this.total = res.mssg.total;
    },
    // 监听 pagesize 改变
    handleSizeChange(newSizd) {
      this.queryInfo.pagesize = newSizd;
      this.queryInfo.pagenum = 1;
      this.getUserList();
    },
    // 监听 页码值改变
    handleCurrentChange(newpage) {
      this.queryInfo.pagenum = newpage;
 
      this.getUserList();
    },
    userStatusChange(userinfo) {
      console.log(userinfo);
    }
  }
};
</script>
<style lang="postcss" scoped>
.el-table {
  margin-top: 10px;
  line-height: 30px;
}
.el-col {
  line-height: 30px;
}
</style>