index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <div class="">
  3. <div class="m-10 bg-w p-20 br-10 f-sa-s">
  4. <div class="f-fs-c f-col">
  5. <div style="font-size: 16px;">总量</div>
  6. <div class="mt-4" style="font-weight: bold; font-size: 18px;">
  7. {{ statistics.all }}
  8. </div>
  9. </div>
  10. <div class="f-fs-c f-col">
  11. <div style="font-size: 16px;">月新增</div>
  12. <div class="mt-4" style="font-weight: bold; font-size: 18px;">
  13. {{ statistics.month }}
  14. </div>
  15. </div>
  16. <div class="f-fs-c f-col">
  17. <div style="font-size: 16px;">周新增</div>
  18. <div class="mt-4" style="font-weight: bold; font-size: 18px;">
  19. {{ statistics.week }}
  20. </div>
  21. </div>
  22. </div>
  23. <toolbar @on-filter="filterData" @on-reset="filterData" />
  24. <div class="m-10 bg-w p-20 br-10">
  25. <!-- <el-button type="primary" icon="el-icon-plus" @click="handleSubmit"
  26. >新增</el-button
  27. > -->
  28. <base-table
  29. :columns="columns"
  30. :items="items"
  31. :pagination="pagination"
  32. :page-change="pageChange"
  33. />
  34. </div>
  35. </div>
  36. </template>
  37. <script>
  38. import toolbar from './toolbar';
  39. import mxFilterList from '@/mixins/filterList';
  40. import { getPage, getCount } from '@/api/system/account';
  41. export default {
  42. name: 'AccountManagement',
  43. components: { toolbar },
  44. mixins: [
  45. mxFilterList({
  46. fetchList: getPage, // 在下方data再声明一个 fetchList: iGetList 同等效果
  47. internalFilterObj: {
  48. isDel: false
  49. }
  50. })
  51. ],
  52. data() {
  53. return {
  54. statistics: {},
  55. columns: [
  56. {
  57. key: 'id',
  58. name: '#',
  59. width: this.$col.b
  60. },
  61. {
  62. key: 'nickname',
  63. name: '昵称',
  64. minWidth: this.$col.b
  65. },
  66. {
  67. key: 'mobileNumber',
  68. name: '手机号码',
  69. minWidth: this.$col.b
  70. },
  71. {
  72. key: 'avatarUrl',
  73. name: '头像',
  74. width: '120',
  75. render: (h, { row }) => {
  76. if (!row.avatarUrl) {
  77. return h('span', '-');
  78. }
  79. return h('img', {
  80. style: {
  81. width: '160px',
  82. height: '90px'
  83. },
  84. class: 'pre-img',
  85. attrs: {
  86. src: row.avatarUrl
  87. },
  88. on: {
  89. click: () =>
  90. this.$AdvanceViewImageModal({
  91. items: [{ src: row.avatarUrl }]
  92. })
  93. }
  94. });
  95. }
  96. },
  97. {
  98. key: 'gender',
  99. name: '性别',
  100. width: '120',
  101. type: 'tag',
  102. fetchTagType: val => 'info',
  103. tagName: row => row.gender === 0 ? '未知' : row.gender === 1 ? '男' : '女'
  104. },
  105. {
  106. key: 'createAt',
  107. name: '注册时间',
  108. width: this.$col.b
  109. },
  110. {
  111. key: 'isLocked',
  112. name: '封锁状态',
  113. width: '80',
  114. type: 'tag',
  115. fetchTagType: val => (val ? 'danger' : 'info'),
  116. tagName: row => (row.isLocked ? '是' : '否')
  117. }
  118. // {
  119. // key: 'action',
  120. // name: '操作',
  121. // width: '120'
  122. // }
  123. ]
  124. };
  125. },
  126. methods: {
  127. async pageChange(page) {
  128. this.pagination.page = page;
  129. const inParams = {
  130. ...this.filter,
  131. ...this.internalFilterObj,
  132. start: this.pagination.page,
  133. limit: this.pagination.pageSize
  134. };
  135. const { data, msg } = await this.apiList(inParams);
  136. const res2 = await getCount(inParams);
  137. this.statistics = res2.data;
  138. if ('data' in data) {
  139. const items = data.data;
  140. if (items.length === 0 && this.pagination.page > 1) {
  141. this.pageChange(1);
  142. } else {
  143. this.items = items;
  144. this.pagination.total = data.total;
  145. }
  146. this.loadCallBack(data);
  147. }
  148. }
  149. }
  150. };
  151. </script>
  152. <style type="scss" scoped></style>