ManageUser.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <div>
  3. <div class="operation">
  4. <el-button type="primary" @click="goAddMUser" size="mini">添加管理用户</el-button>
  5. </div>
  6. <el-table :data="items">
  7. <el-table-column label="用户名称" prop="uname"></el-table-column>
  8. <el-table-column label="用户手机号" prop="uphone"></el-table-column>
  9. <el-table-column label="状态">
  10. <template slot-scope="scope">
  11. <template v-if="scope.row.status === 1">
  12. <p class="online">启用</p>
  13. </template>
  14. <template v-else>
  15. <p class="offline">禁用</p>
  16. </template>
  17. </template>
  18. </el-table-column>
  19. <el-table-column label="创建者" prop="cuname"></el-table-column>
  20. <el-table-column label="操作">
  21. <template slot-scope="scope">
  22. <template v-if="scope.row.status == 0">
  23. <el-button type="success" @click="setStatus(scope.row)" size="mini">启用</el-button>
  24. </template>
  25. <template v-else>
  26. <el-button type="danger" @click="setStatus(scope.row)" size="mini">禁用</el-button>
  27. </template>
  28. </template>
  29. </el-table-column>
  30. </el-table>
  31. </div>
  32. </template>
  33. <script>
  34. export default {
  35. data() {
  36. return {
  37. items: []
  38. };
  39. },
  40. methods: {
  41. getMUsers: function() {
  42. this.$http.queryAllMUsers({}, this).then(res => {
  43. if (res.code == 0) {
  44. this.items = res.obj;
  45. }
  46. });
  47. },
  48. setStatus: function(row) {
  49. var status = row.status === 1 ? 0 : 1;
  50. this.$http
  51. .setMUserStatus({ id: row.id, status: status }, this)
  52. .then(res => {
  53. if (res.code === 0) {
  54. this.$message({
  55. message: "操作成功",
  56. type: "success"
  57. });
  58. row.status = status;
  59. }
  60. });
  61. },
  62. goAddMUser() {
  63. this.$router.push("/addManageUser");
  64. }
  65. },
  66. mounted: function() {
  67. this.getMUsers();
  68. }
  69. };
  70. </script>
  71. <style scoped>
  72. .online {
  73. color: #67c23a;
  74. }
  75. .offline {
  76. color: #f56c6c;
  77. }
  78. .operation {
  79. height: 50px;
  80. border-bottom: 1px solid #e6e6e6;
  81. margin-bottom: 10px;
  82. }
  83. </style>