ManageUser.vue 2.2 KB

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