index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <!-- 合约 - 合约明细 -->
  2. <template>
  3. <app-view class="contract-detail g-form">
  4. <template #header>
  5. <app-navbar title="合约明细" />
  6. </template>
  7. <Grid :border="false" :column-num="quotes.length ? 2 : 1">
  8. <GridItem icon="peer-pay" :text="$t('digital.wallet-transfer')"
  9. :to="{ name: 'wallet-transfer', query: { id: accountid } }" />
  10. <GridItem icon="chart-trending-o" :text="$t('digital.spot-goods-detail')"
  11. @click="navigateToContractDetail()" v-if="quotes.length" />
  12. </Grid>
  13. <div class="g-detail-table" v-if="accountItem">
  14. <table cellspacing="0" cellpadding="0">
  15. <tbody>
  16. <tr>
  17. <td>
  18. <span class="text-small">{{
  19. $t('digital.currencydecimalplace') + `(${currency(accountItem.currencyid)})` }}</span>
  20. <span>{{ accountItem.balance.toFixed(accountItem.currencydecimalplace) }}</span>
  21. </td>
  22. <td>
  23. <span class="text-small">{{ $t('account.profitLoss') }}</span>
  24. <span :class="handlePriceColor(accountItem.profitLoss)">{{
  25. accountItem.profitLoss.toFixed(accountItem.currencydecimalplace) }}</span>
  26. </td>
  27. <td>
  28. <span class="text-small">{{ $t('account.riskRate') }}</span>
  29. <span :class="accountItem.hazardRatioColor">
  30. {{ parsePercent(accountItem.hazardRatio) }}
  31. </span>
  32. </td>
  33. </tr>
  34. <tr>
  35. <td>
  36. <span class="text-small">{{
  37. $t('mine.availableFunds') + `(${currency(accountItem.currencyid)})`
  38. }}</span>
  39. <span>{{ accountItem.avaiableBalance.toFixed(accountItem.currencydecimalplace) }}</span>
  40. </td>
  41. <td>
  42. <span class="text-small">{{ $t('account.usedMargin') +
  43. `(${currency(accountItem.currencyid)})`
  44. }}</span>
  45. <span>{{ accountItem.usedmargin.toFixed(accountItem.currencydecimalplace) }}</span>
  46. </td>
  47. <td>
  48. <span class="text-small">{{ $t('account.freeze') + `(${currency(accountItem.currencyid)})`
  49. }}</span>
  50. <span>{{ accountItem.freezeMargin.toFixed(accountItem.currencydecimalplace) }}</span>
  51. </td>
  52. </tr>
  53. </tbody>
  54. </table>
  55. </div>
  56. <Tabs>
  57. <Tab :title="t('digital.position')">
  58. <contract-position :params="{ accids: accountid.toString() }" />
  59. </Tab>
  60. <Tab :title="t('digital.order')">
  61. <contract-order v-bind="{ accountid }" />
  62. </Tab>
  63. <Tab :title="t('digital.trade')">
  64. <contract-trade v-bind="{ accountid }" />
  65. </Tab>
  66. <Tab :title="t('digital.funds')">
  67. <contract-statement v-bind="{ accountid }" />
  68. </Tab>
  69. </Tabs>
  70. <ActionSheet v-model:show="showSheet" :title="t('common.choice')">
  71. <CellGroup style="min-height: 200px;">
  72. <template v-for="(item, index) in quotes" :key="index">
  73. <Cell :title="item.goodsname" :value="item.goodscode" :border="false" is-link clickable
  74. @click="navigateToContractDetail(item.goodsid)" />
  75. </template>
  76. </CellGroup>
  77. </ActionSheet>
  78. </app-view>
  79. </template>
  80. <script lang="ts" setup>
  81. import { shallowRef, computed } from 'vue'
  82. import { Cell, CellGroup, Tab, Tabs, Grid, GridItem, ActionSheet } from 'vant'
  83. import { handlePriceColor, parsePercent } from '@/filters'
  84. import { useNavigation } from '@mobile/router/navigation'
  85. import { i18n, useAccountStore, useFuturesStore } from '@/stores'
  86. import ContractOrder from '../components/order/index.vue'
  87. import ContractTrade from '../components/trade/index.vue'
  88. import ContractPosition from '../components/position/detail/index.vue'
  89. import ContractStatement from '../components/statement/index.vue'
  90. import { getGoodsCurrencyItemName } from '@/constants/order'
  91. const { router, getQueryStringToNumber } = useNavigation()
  92. const { global: { t } } = i18n
  93. const futuresStore = useFuturesStore()
  94. const accountStore = useAccountStore()
  95. const accountid = getQueryStringToNumber('id')
  96. const showSheet = shallowRef(false)
  97. const currency = (id: number) => {
  98. return getGoodsCurrencyItemName(id)
  99. }
  100. // 合约账户
  101. const accountItem = computed(() => accountStore.getAccountItem({ accountid }))
  102. const quotes = computed(() => futuresStore.quotationList.filter((e) => e.trademode === 10 && (e.goodscurrencyid === accountItem.value?.currencyid || e.currencyid === accountItem.value?.currencyid)))
  103. const navigateToContractDetail = (goodsid?: number) => {
  104. showSheet.value = false
  105. // 多个商品弹出列表选择,单个商品直接跳转
  106. if (quotes.value.length > 1 && !goodsid) {
  107. showSheet.value = true
  108. } else {
  109. router.push({
  110. name: 'contract-goods-detail',
  111. query: {
  112. id: goodsid ?? quotes.value[0].goodsid
  113. }
  114. })
  115. }
  116. }
  117. </script>