index.vue 4.0 KB

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