li.shaoyi 13 часов назад
Родитель
Сommit
1dd261f3a6

+ 2 - 1
src/filters/index.ts

@@ -2,6 +2,7 @@ import CryptoJS from 'crypto-js'
 import service from '@/services'
 import Long from 'long'
 import moment from 'moment'
+import { Decimal } from 'decimal.js'
 import { currencyConfigMap } from '@/constants/currency'
 import { useUserStore, i18n } from '@/stores'
 import { FormatCurrencyOptions } from './types'
@@ -446,7 +447,7 @@ export function numberToChinese(num: undefined | string) {
  * @returns 
  */
 export function formatNumber(num: number, decimals = 2) {
-    return (num > 0 ? '+' : '') + num.toFixed(decimals)
+    return (num > 0 ? '+' : '') + Decimal(num).toFixed(decimals)
 }
 
 /**

+ 1 - 1
src/packages/digital/views/spot/components/account/index.vue

@@ -5,8 +5,8 @@
             <tbody>
                 <tr>
                     <th>
-                        <span>{{ item.currencycode }}</span>
                         <span class="text-small">{{ getDigitalCurrencyName(item.currencyid) }}</span>
+                        <span>{{ item.currencycode }}</span>
                     </th>
                     <td>
                         <span class="text-small">{{ t('mine.availableFunds') }}({{ item.currencycode }})</span>

+ 11 - 6
src/packages/digital/views/spot/components/order/index.vue

@@ -30,12 +30,16 @@
                     </tr>
                     <tr>
                         <td>
-                            <span class="text-small">{{ `${t('order.goodsorder.orderprice')}(${item.quotecurrencycode})` }}</span>
-                            <span>{{ item.orderprice }}</span>
+                            <span class="text-small">
+                                {{ `${t('order.goodsorder.orderprice')}(${item.quotecurrencycode})` }}
+                            </span>
+                            <span>{{ formatDecimal(item.orderprice, item.quotedecimalplace) }}</span>
                         </td>
                         <td>
-                            <span class="text-small">{{ `${t('order.goodsorder.orderqty')}(${item.basecurrencycode})` }}</span>
-                            <span>{{ item.ordervolume-item.tradevolume }}</span>
+                            <span class="text-small">
+                                {{ `${t('order.goodsorder.orderqty')}(${item.basecurrencycode})` }}
+                            </span>
+                            <span>{{ item.ordervolume - item.tradevolume }}</span>
                         </td>
                     </tr>
                     <!-- <tr>
@@ -62,7 +66,7 @@
 <script lang="ts" setup>
 import { shallowRef, defineAsyncComponent, PropType, computed, onUnmounted } from 'vue'
 import { Button } from 'vant'
-import { formatDate } from '@/filters'
+import { formatDate, formatDecimal } from '@/filters'
 import { useComponent } from '@/hooks/component'
 import { useRequest } from '@/hooks/request'
 import { getBuyOrSellName, getOrderStatusName } from '@/constants/order'
@@ -119,7 +123,8 @@ const tableList = computed(() => dataList.value.map((e) => {
         goodsname: quoteItem?.goodsname || e.goodsid,
         basecurrencycode: quoteItem?.basecurrencycode,
         quotecurrencycode: quoteItem?.quotecurrencycode,
-        goodscode: quoteItem?.goodscode
+        goodscode: quoteItem?.goodscode,
+        quotedecimalplace: quoteItem?.quotedecimalplace
     }
 }))
 

+ 5 - 3
src/packages/digital/views/spot/components/trade/index.vue

@@ -10,7 +10,7 @@
                     <tr>
                         <th>
                             <span>{{ item.goodsname }}</span>
-                            <time class="text-small">{{ item.tradetime }}</time>
+                            <time class="text-small">{{ formatDate(item.tradetime) }}</time>
                         </th>
                         <th>
                             <span class="g-price-down">{{ getBuyOrSellName(item.buyorsell) }}</span>
@@ -31,7 +31,7 @@
                     <tr>
                         <td>
                             <span class="text-small">成交价格({{ item.quotecurrencycode }})</span>
-                            <span>{{ item.tradeprice }}</span>
+                            <span>{{ formatDecimal(item.tradeprice, item.quotedecimalplace) }}</span>
                         </td>
                         <td>
                             <span class="text-small">成交数量({{ item.quotecurrencycode }})</span>
@@ -52,6 +52,7 @@
 
 <script lang="ts" setup>
 import { shallowRef, PropType, computed } from 'vue'
+import { formatDate, formatDecimal } from '@/filters'
 import { useRequest } from '@/hooks/request'
 import { getBuyOrSellName } from '@/constants/order'
 import { queryDigitalTradeTradeDetails } from '@/services/api/digital'
@@ -94,7 +95,8 @@ const tableList = computed(() => dataList.value.map((e) => {
         ...e,
         goodsname: quoteItem?.goodsname || e.goodsid,
         basecurrencycode: quoteItem?.basecurrencycode,
-        quotecurrencycode: quoteItem?.quotecurrencycode
+        quotecurrencycode: quoteItem?.quotecurrencycode,
+        quotedecimalplace: quoteItem?.quotedecimalplace
     }
 }))
 

+ 2 - 2
src/stores/modules/futures.ts

@@ -531,9 +531,9 @@ export const useFuturesStore = defineStore(() => {
     const handleQuotation = (quote: Proto.Quote): Partial<Model.QuoteDayRsp> => {
         const goods = state.goodsList.find((e) => e.goodscode.toUpperCase() === quote.goodscode?.toUpperCase())
         // 处理报价小数位
-        const handleDecimalPlace = (value?: number, decimals?: number) => {
+        const handleDecimalPlace = (value?: number) => {
             if (goods && value) {
-                const decimal = Math.pow(10, decimals ?? goods.decimalplace)
+                const decimal = Math.pow(10, goods.decimalplace)
                 return value / decimal
             }
             return value