UserList.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <div class="app-container">
  3. <a-card :bordered="false">
  4. <SearchForm ref="searchForm" @reloadData="reloadData"/>
  5. <s-table
  6. ref="table"
  7. size="default"
  8. rowKey="id"
  9. :scroll="{ x: 1300 }"
  10. :columns="columns"
  11. :data="loadData"
  12. :alert="options.alert"
  13. :rowSelection="options.rowSelection"
  14. showPagination="true"
  15. >
  16. <span slot="introduction" slot-scope="text">
  17. <ellipsis :length="10" tooltip>{{ text }}</ellipsis>
  18. </span>
  19. <span slot="role" slot-scope="text">
  20. <template>
  21. <a v-if="text === 1">用户</a>
  22. <a v-if="text === 2">管理员</a>
  23. </template>
  24. </span>
  25. <span slot="status" slot-scope="text">
  26. <template>
  27. <a v-if="text === 0">正常</a>
  28. <a v-if="text === 1">锁定</a>
  29. </template>
  30. </span>
  31. </s-table>
  32. </a-card>
  33. </div>
  34. </template>
  35. <script>
  36. import { getUserList, updateStatus, deleteUser } from '@/api/user'
  37. import { STable, Ellipsis } from '@/components'
  38. import SearchForm from './modules/SearchForm'
  39. import { filters, table } from './auth-constants'
  40. export default {
  41. name: 'AuthList',
  42. components: {
  43. STable,
  44. Ellipsis,
  45. SearchForm
  46. },
  47. filters: filters,
  48. data () {
  49. return {
  50. queryParam: {},
  51. loadData: parameter => {
  52. return getUserList(Object.assign(parameter, this.queryParam)).then(res => {
  53. return res
  54. })
  55. },
  56. options: {
  57. alert: {
  58. show: true,
  59. clear: () => {
  60. this.selectedRowKeys = []
  61. }
  62. },
  63. rowSelection: {
  64. selectedRowKeys: this.selectedRowKeys,
  65. onChange: this.onSelectChange
  66. }
  67. },
  68. columns: table.columns,
  69. visible: false,
  70. formType: 'create'
  71. }
  72. },
  73. created () {},
  74. methods: {
  75. createHandler () {
  76. this.formType = 'create'
  77. this.visible = true
  78. this.$refs.createUserForm.resetForm()
  79. },
  80. handleEditStatus (record, status) {
  81. record.status = status
  82. updateStatus(record).then(res => {
  83. this.$notification.success({
  84. message: status ? '锁定成功' : '解锁成功'
  85. })
  86. this.$refs.table.refresh()
  87. })
  88. },
  89. handleDelete (record) {
  90. deleteUser(record.id).then(res => {
  91. this.$notification.success({
  92. message: '删除成功'
  93. })
  94. this.$refs.table.refresh()
  95. })
  96. },
  97. resetData (flag) {
  98. this.visible = flag
  99. this.record = null
  100. },
  101. refreshTable () {
  102. this.$refs.table.refresh()
  103. },
  104. reloadData (queryParam) {
  105. this.queryParam = queryParam
  106. this.refreshTable()
  107. },
  108. cancel () { }
  109. }
  110. }
  111. </script>
  112. <style scoped>
  113. .edit-input {
  114. padding-right: 100px;
  115. }
  116. .cancel-btn {
  117. position: absolute;
  118. right: 15px;
  119. top: 10px;
  120. }
  121. .ant-upload-select-picture-card i {
  122. font-size: 32px;
  123. color: #999;
  124. }
  125. .ant-upload-select-picture-card .ant-upload-text {
  126. margin-top: 8px;
  127. color: #666;
  128. }
  129. </style>