wallet-history.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <cwg-page-wrapper class="create-page" :isHeaderFixed="true">
  3. <cwg-header :title="t('wallet.item57')" />
  4. <view class="info-card">
  5. <cwg-complex-search :fields="filterFields" v-model="searchParams" @search="handleSearch"
  6. @reset="handleReset" />
  7. <cwg-tabel ref="tableRef" :columns="columns" :immediate="false" :mobilePrimaryFields="mobilePrimaryFields"
  8. :queryParams="search" :api="listApi" :show-operation="false">
  9. <template #source="{ row }">
  10. <text v-if="row.source == 'RAFFLE'" v-t="'wallet.item49_5'"></text>
  11. <text v-if="row.source == 'TRANSFER'" v-t="'wallet.item49_4'"></text>
  12. <text v-if="row.source == 'MANAGER'" v-t="'wallet.item49_1'"></text>
  13. <text v-if="row.source == 'INTERESTRATE'" v-t="'news_add_field1.NewYear24.itemW1'"></text>
  14. <text v-if="row.source == 'CASHBACK'" v-t="'news_add_field1.NewYear24.itemW2'"></text>
  15. </template>
  16. <template #amount="{ row }">
  17. <text>{{ numberFormat(row.amount || 0) }}</text>
  18. </template>
  19. </cwg-tabel>
  20. </view>
  21. </cwg-page-wrapper>
  22. </template>
  23. <script setup lang="ts">
  24. import { computed, ref, nextTick, reactive } from 'vue';
  25. import { useI18n } from 'vue-i18n';
  26. const { t, locale } = useI18n();
  27. import { onLoad } from '@dcloudio/uni-app'
  28. import { customApi } from '@/service/custom';
  29. import { useFilters } from '@/composables/useFilters'
  30. const { numberFormat, numberDecimal } = useFilters()
  31. const search = reactive({
  32. startDate: '',
  33. endDate: ''
  34. })
  35. // 表格列配置
  36. const columns = computed(() => [
  37. {
  38. prop: 'serial',
  39. label: t('wallet.item58'),
  40. align: 'left'
  41. },
  42. {
  43. prop: 'addTime',
  44. label: t('wallet.item59'),
  45. align: 'left'
  46. },
  47. {
  48. prop: 'source',
  49. label: t('wallet.item60'),
  50. slot: 'source',
  51. align: 'left'
  52. },
  53. {
  54. prop: 'amount',
  55. label: t('wallet.item61'),
  56. slot: 'amount',
  57. align: 'center'
  58. }
  59. ])
  60. const mobilePrimaryFields = computed(() => [
  61. {
  62. prop: 'serial',
  63. label: t('wallet.item58'),
  64. align: 'left'
  65. },
  66. {
  67. prop: 'source',
  68. label: t('wallet.item60'),
  69. slot: 'source',
  70. align: 'left'
  71. },
  72. {
  73. prop: 'amount',
  74. label: t('wallet.item61'),
  75. slot: 'amount',
  76. align: 'right'
  77. }
  78. ])
  79. // 动态传入筛选字段配置
  80. const filterFields = computed(() => [
  81. { key: 'date', label: t('placeholder.Start') + ' - ' + t('placeholder.End'), type: 'daterange' }
  82. ])
  83. const searchParams = ref({})
  84. const tableRef = ref(null)
  85. const handleSearch = (params) => {
  86. Object.assign(search, params)
  87. if (params.date && params.date.length === 2) {
  88. search.startDate = params.date[0]
  89. search.endDate = params.date[1]
  90. } else {
  91. search.startDate = ''
  92. search.endDate = ''
  93. }
  94. nextTick(() => {
  95. tableRef.value.refreshTable()
  96. })
  97. }
  98. const handleReset = (params) => {
  99. Object.assign(search, params)
  100. search.startDate = ''
  101. search.endDate = ''
  102. nextTick(() => {
  103. tableRef.value.refreshTable()
  104. })
  105. }
  106. const listApi = ref(null)
  107. listApi.value = customApi.walletHistoryList
  108. onLoad((e) => {
  109. nextTick(() => {
  110. tableRef.value.refreshTable()
  111. })
  112. })
  113. </script>
  114. <style scoped lang="scss">
  115. @import "@/uni.scss";
  116. .search-bar {
  117. display: flex;
  118. align-items: center;
  119. justify-content: flex-start;
  120. flex-wrap: wrap;
  121. gap: px2rpx(16);
  122. margin: px2rpx(16) 0;
  123. .cwg-combox,
  124. .uni-easyinput,
  125. .uni-date {
  126. width: px2rpx(240) !important;
  127. flex: none;
  128. }
  129. }
  130. </style>