TransactionDialogs.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <cwg-popup :title="t('Tips.TransactionRecord')" :visible="props.visible" :showFooters="false"
  3. @update:visible="$emit('update:visible', $event)">
  4. <scroll-view scroll-y class="account-list" :style="{ maxHeight: '40vh' }">
  5. <view v-if="loading" class="loading-state">
  6. <uni-load-more :status="loading ? 'loading' : 'noMore'" />
  7. </view>
  8. </scroll-view>
  9. <view class="search-bar">
  10. <uni-datetime-picker type="daterange" v-model="search.date"
  11. :placeholder="t('placeholder.Start') + ' - ' + t('placeholder.End')" @change="handleDateChange"
  12. class="date-picker" />
  13. </view>
  14. <cwg-tabel ref="tableRef" :columns="columns" :queryParams="search" :api="listApi" />
  15. </cwg-popup>
  16. </template>
  17. <script setup>
  18. import { ref, computed, watch } from 'vue'
  19. import { useI18n } from 'vue-i18n'
  20. import { customApi } from '@/service/custom'
  21. const { t } = useI18n()
  22. const props = defineProps({
  23. // 是否显示弹窗
  24. visible: {
  25. type: Boolean,
  26. default: false
  27. },
  28. loginInfo: {
  29. type: Object,
  30. default: () => ({})
  31. }
  32. })
  33. // 表格列配置
  34. const columns = ref([
  35. {
  36. prop: 'login',
  37. label: t('Label.TradingAccount'),
  38. align: 'left'
  39. },
  40. {
  41. prop: 'openPrice',
  42. label: t('Label.OpenPrice'),
  43. align: 'left'
  44. },
  45. {
  46. prop: 'closePrice',
  47. label: t('Label.ClosePrice'),
  48. align: 'left',
  49. },
  50. {
  51. prop: 'openTime',
  52. label: t('Label.OpenTime'),
  53. align: 'left'
  54. },
  55. {
  56. props: 'closeTime',
  57. label: t('Label.CloseTime'),
  58. align: 'left'
  59. }
  60. ])
  61. const loading = ref(false)
  62. const handleDateChange = (val) => {
  63. search.value.startDate = val[0]
  64. search.value.endDate = val[1]
  65. getChart()
  66. }
  67. const search = ref({})
  68. // 监听 visible 变化
  69. watch(() => props.visible, (val) => {
  70. if (val) {
  71. search.value = {}
  72. search.value.date = []
  73. // 使用 setTimeout 确保在下一个事件循环赋值
  74. const { login, platform } = props.loginInfo
  75. const now = new Date();
  76. const firstDay = new Date(now.getFullYear(), now.getMonth(), 1);
  77. const lastDay = new Date(now.getFullYear(), now.getMonth() + 1, 0);
  78. const transactionDate = [
  79. firstDay.toISOString().split('T')[0],
  80. lastDay.toISOString().split('T')[0]
  81. ];
  82. const startDate = transactionDate[0]
  83. const endDate = transactionDate[1]
  84. search.value = { login, platform, startDate, endDate }
  85. setTimeout(() => {
  86. search.value.date = [startDate, endDate];
  87. }, 0)
  88. } else {
  89. search.value = {}
  90. }
  91. })
  92. const listApi = ref(null)
  93. listApi.value = customApi.historyList
  94. </script>
  95. <style scoped lang="scss">
  96. @import "@/uni.scss";
  97. .delete-account-dialog {
  98. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  99. border-radius: px2rpx(8);
  100. overflow: hidden;
  101. @media (min-width: 768px) {
  102. width: px2rpx(800);
  103. }
  104. }
  105. .dialog-content {
  106. padding: px2rpx(20);
  107. }
  108. .empty-state {
  109. display: flex;
  110. flex-direction: column;
  111. align-items: center;
  112. justify-content: center;
  113. padding: px2rpx(60) 0;
  114. .empty-text {
  115. margin-top: px2rpx(20);
  116. font-size: px2rpx(18);
  117. color: var(--bs-heading-color);
  118. }
  119. }
  120. .date-picker {
  121. margin-left: px2rpx(20);
  122. width: px2rpx(300) !important;
  123. }
  124. </style>