WalletTransactionList.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <ContentWrap>
  3. <el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
  4. <el-table-column align="center" label="编号" prop="id" />
  5. <el-table-column align="center" label="钱包编号" prop="walletId" />
  6. <el-table-column align="center" label="关联业务标题" prop="title" />
  7. <el-table-column align="center" label="交易金额" prop="price">
  8. <template #default="{ row }"> {{ fenToYuan(row.price) }} 元</template>
  9. </el-table-column>
  10. <el-table-column align="center" label="钱包余额" prop="balance">
  11. <template #default="{ row }"> {{ fenToYuan(row.balance) }} 元</template>
  12. </el-table-column>
  13. <el-table-column
  14. :formatter="dateFormatter"
  15. align="center"
  16. label="交易时间"
  17. prop="createTime"
  18. width="180px"
  19. />
  20. </el-table>
  21. <!-- 分页 -->
  22. <Pagination
  23. v-model:limit="queryParams.pageSize"
  24. v-model:page="queryParams.pageNo"
  25. :total="total"
  26. @pagination="getList"
  27. />
  28. </ContentWrap>
  29. </template>
  30. <script lang="ts" setup>
  31. import { dateFormatter } from '@/utils/formatTime'
  32. import * as WalletTransactionApi from '@/api/pay/wallet/transaction'
  33. import * as WalletApi from '@/api/pay/wallet/balance'
  34. import { fenToYuan } from '@/utils'
  35. defineOptions({ name: 'WalletTransactionList' })
  36. const props = defineProps({
  37. walletId: {
  38. type: Number,
  39. required: false
  40. },
  41. userId: {
  42. type: Number,
  43. required: false
  44. }
  45. })
  46. const loading = ref(true) // 列表的加载中
  47. const total = ref(0) // 列表的总页数
  48. const queryParams = reactive({
  49. pageNo: 1,
  50. pageSize: 10,
  51. walletId: null
  52. })
  53. const list = ref([]) // 列表的数据
  54. /** 查询列表 */
  55. const getList = async () => {
  56. loading.value = true
  57. try {
  58. if (props.userId) {
  59. const wallet = await WalletApi.getWallet({ userId: props.userId })
  60. queryParams.walletId = wallet.id as any
  61. } else {
  62. queryParams.walletId = props.walletId as any
  63. }
  64. const data = await WalletTransactionApi.getWalletTransactionPage(queryParams)
  65. list.value = data.list
  66. total.value = data.total
  67. } finally {
  68. loading.value = false
  69. }
  70. }
  71. /** 初始化 **/
  72. onMounted(() => {
  73. getList()
  74. })
  75. </script>
  76. <style lang="scss" scoped></style>