user.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <div class="mod-user">
  3. <avue-crud ref="crud" :page="page" :data="dataList" :option="tableOption" @search-change="searchChange"
  4. @selection-change="selectionChange" @on-load="getDataList"
  5. @row-del="deleteUser">
  6. <!-- <template slot="menuLeft">-->
  7. <!-- <el-button type="danger"-->
  8. <!-- @click="deleteHandle()"-->
  9. <!-- v-if="isAuth('admin:user:delete')"-->
  10. <!-- size="small"-->
  11. <!-- :disabled="dataListSelections.length <= 0">批量删除</el-button>-->
  12. <!-- </template>-->
  13. <template slot-scope="scope" slot="pic">
  14. <span class="avue-crud__img" v-if="scope.row.pic">
  15. <i :src="scope.row.pic" class="el-icon-document"></i>
  16. </span>
  17. <span v-else>-</span>
  18. </template>
  19. <template slot-scope="scope" slot="status">
  20. <el-tag v-if="scope.row.status === 0" size="small" type="danger">禁用</el-tag>
  21. <el-tag v-else size="small">正常</el-tag>
  22. </template>
  23. </avue-crud>
  24. <!-- 弹窗, 新增 / 修改 -->
  25. <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
  26. </div>
  27. </template>
  28. <script>
  29. import { tableOption } from '@/crud/user/user'
  30. import AddOrUpdate from './user-add-or-update'
  31. import Axios from 'axios'
  32. export default {
  33. data() {
  34. return {
  35. dataList: [],
  36. dataListLoading: false,
  37. dataListSelections: [],
  38. addOrUpdateVisible: false,
  39. tableOption: tableOption,
  40. page: {
  41. total: 1, // 总页数
  42. currentPage: 1, // 当前页数
  43. pageSize: 10 // 每页显示多少条
  44. }
  45. }
  46. },
  47. components: {
  48. AddOrUpdate
  49. },
  50. methods: {
  51. deleteUser(user){
  52. this.$confirm(`确定进行删除操作?`, '提示', {
  53. confirmButtonText: '确定',
  54. cancelButtonText: '取消',
  55. type: 'warning'
  56. }).then(() => {
  57. console.log(user.id)
  58. Axios.post("/user/deleteUser", {id: user.id}
  59. ).then(({ data }) => {
  60. console.log(data)
  61. this.$message({
  62. message: '操作成功',
  63. type: 'success',
  64. duration: 1500,
  65. onClose: () => {
  66. this.getDataList()
  67. }
  68. })
  69. })
  70. })
  71. },
  72. // 获取数据列表
  73. getDataList(page, params, done) {
  74. this.dataListLoading = true
  75. Axios.post(this.$http.adornUrl('/user/queryUserList'),
  76. Object.assign({
  77. phone: "",
  78. nickName: "",
  79. limit: page == null ? this.page.pageSize : page.pageSize,
  80. page: page == null ? this.page.currentPage : page.currentPage,
  81. },params)).then(({data})=>{
  82. this.dataList = data.data.userList
  83. this.page.total = data.data.total
  84. this.dataListLoading = false
  85. if (done) {
  86. done()
  87. }
  88. })
  89. },
  90. // 新增 / 修改
  91. addOrUpdateHandle(id) {
  92. this.addOrUpdateVisible = true
  93. this.$nextTick(() => {
  94. this.$refs.addOrUpdate.init(id)
  95. })
  96. },
  97. // 条件查询
  98. searchChange(params, done) {
  99. this.getDataList(this.page, params, done)
  100. },
  101. // 多选变化
  102. selectionChange(val) {
  103. this.dataListSelections = val
  104. }
  105. }
  106. }
  107. </script>