index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <div class="app-container">
  3. <search-form
  4. :list-loading="listLoading"
  5. @change="searchHandle"
  6. />
  7. <table-list
  8. :list-loading="listLoading"
  9. :data="tableData2"
  10. :columns="listConfig"
  11. :current-page="currentPage"
  12. :page-size="pageSize"
  13. :total-records="totalRecords"
  14. @currentChange="pageHandle"
  15. @sizeChange="sizeChange"
  16. :isAdd="true"
  17. @add="openPopup"
  18. />
  19. <popup-edit
  20. :isShow="isDtlShow"
  21. :curObj="curObj"
  22. @close="closePopup"
  23. />
  24. <pwd-reset
  25. :isShow="isPrShow"
  26. :curObj="curObj"
  27. @close="closePrPopup"
  28. />
  29. </div>
  30. </template>
  31. <script>
  32. import { arrToObj } from '@/utils'
  33. import SearchForm from './components/searchForm/Index'
  34. import PopupEdit from './components/popup/IndexEdit'
  35. import PwdReset from './components/popup/PwdReset'
  36. import baseTable from '_m/baseTable.js'
  37. import xData from './mixin'
  38. export default {
  39. name: 'index',
  40. components: {
  41. SearchForm,
  42. PopupEdit,
  43. PwdReset,
  44. },
  45. provide() {
  46. return {
  47. parentData: this
  48. }
  49. },
  50. mixins: [baseTable],
  51. data() {
  52. return {
  53. apiStr: 'user.admadminlist',
  54. searchForm: null,
  55. isDtlShow: false,
  56. isPrShow: false,
  57. curObj: {},
  58. ...xData
  59. }
  60. },
  61. computed: {
  62. tableData2() {
  63. const arr = [...this.tableData]
  64. arr.map(item => {
  65. })
  66. return arr
  67. }
  68. },
  69. created() {},
  70. mounted() {
  71. this.listConfig = {
  72. rows: [
  73. { label: 'id', prop: 'id' },
  74. { label: '昵称', prop: 'nickname' },
  75. { label: '账号', prop: 'username' },
  76. // { label: '头像', prop: 'avatar', type: 'img' },
  77. { label: '角色', prop: 'role_name' },
  78. { label: 'wxId', prop: 'wx_user_id' },
  79. { label: '更新人', prop: 'update_by' },
  80. { label: '更新时间', prop: 'update_at' },
  81. { label: '操作', width: 200, type: 'handle2', operations:
  82. [
  83. { label: '编辑', func: this.openPopup, btnType: 'primary' },
  84. { label: '重置密码', func: this.openPrPopup, btnType: 'success' },
  85. { label: '删除', func: this.delHandle, btnType: 'danger' },
  86. ]
  87. }
  88. ]
  89. }
  90. },
  91. methods: {
  92. delHandle(row) {
  93. this.$msg(`您确定要删除该用户吗?`, 'confirm', () => {
  94. this.$api.user.admadmindel({
  95. id: row.id
  96. }).then(data => {
  97. this.$msgs(`已删除!`)
  98. this.fetchData()
  99. })
  100. }, null, true)
  101. },
  102. openPopup(row) {
  103. if (row && row.id) {
  104. this.curObj = row
  105. } else {
  106. this.curObj = {}
  107. }
  108. this.isDtlShow = true
  109. },
  110. closePopup(obj) {
  111. if (obj) {
  112. const params = obj
  113. let apiStr = 'admadminadd'
  114. if (obj.id) apiStr = 'admadminedit'
  115. this.$api.user[apiStr]({
  116. ...params
  117. }).then(data => {
  118. this.$msgs(obj.id ? '编辑成功' : '新增成功')
  119. this.fetchData()
  120. this.isDtlShow = false
  121. })
  122. } else {
  123. this.isDtlShow = false
  124. }
  125. },
  126. openPrPopup(row) {
  127. if (row && row.id) {
  128. this.curObj = row
  129. } else {
  130. this.curObj = {}
  131. }
  132. this.isPrShow = true
  133. },
  134. closePrPopup(obj) {
  135. this.isPrShow = false
  136. if (obj) {
  137. this.fetchData()
  138. }
  139. }
  140. }
  141. }
  142. </script>