Handy_Cao vor 1 Monat
Ursprung
Commit
0cdaee9d4b

+ 1 - 1
oem/digital/config/appconfig.json

@@ -3,7 +3,7 @@
   "appName": "Digital",
   "version": "1.0.0",
   "versionCode": "100000",
-  "apiUrl": "http://192.168.31.204:8080/cfg?key=test_204",
+  "apiUrl": "http://192.168.31.158:19240/cfg?key=dev_104",
   "tradeChannel": "ws",
   "modules": [
     "register"

+ 10 - 1
src/constants/order.ts

@@ -1,6 +1,6 @@
 import { useEnumStore, i18n } from '@/stores'
 
-const { getEnumTypeList, getEnumTypeName, getEnumTypeBankMappedValue } = useEnumStore()
+const { getEnumTypeList, getEnumTypeName, getEnumTypeBankMappedValue, getEnumTypeItemValue } = useEnumStore()
 
 /**
  * 买卖方向
@@ -623,6 +623,15 @@ export function getGoodsCurrencyName(value: number) {
 }
 
 /**
+ * 获取币种符号名称
+ * @returns 
+ */
+export function getGoodsCurrencyItemName(value: number) {
+    const enums = getGoodsCurrencyList()
+    return getEnumTypeItemValue(enums, value)
+}
+
+/**
  * 获取数字币种列表
  * @returns 
  */

+ 8 - 6
src/packages/digital/views/contract/components/position/index.vue

@@ -26,7 +26,7 @@
                     </tr>
                     <tr>
                         <td colspan="2">
-                            <span class="text-small">浮动盈亏( {{ getCurrencyName(item.currencyid) }})</span>
+                            <span class="text-small">浮动盈亏( {{ enumName(item.currencyid) }})</span>
                             <span :class="item.closeplColor">
                                 {{ formatDecimal(item.tHDetailEx.floatPL, item.decimalPlace) }}
                             </span>
@@ -42,7 +42,7 @@
                             <span>{{ item.tHDetailEx.holderQty }}</span>
                         </td>
                         <td>
-                            <span class="text-small">保证金( {{ getCurrencyName(item.currencyid) }} )</span>
+                            <span class="text-small">保证金( {{ enumName(item.currencyid) }} )</span>
                             <span>{{ formatAmount(calUseMargin(item)) }}</span>
                         </td>
                         <td>
@@ -56,11 +56,11 @@
                             <span>{{ item.tHDetailEx.freezeQty }}</span>
                         </td>
                         <td>
-                            <span class="text-small">持仓价格( {{ getCurrencyName(item.currencyid) }})</span>
+                            <span class="text-small">持仓价格( {{ enumName(item.currencyid) }})</span>
                             <span>{{ formatDecimal(item.tHDetailEx.holderPrice, item.decimalPlace) }}</span>
                         </td>
                         <td>
-                            <span class="text-small">持金额( {{ getCurrencyName(item.currencyid) }} )</span>
+                            <span class="text-small">持金额( {{ enumName(item.currencyid) }} )</span>
                             <span>{{ formatAmount(item.tHDetailEx.holderAmount) }}</span>
                         </td>
                     </tr>
@@ -85,11 +85,10 @@
 <script lang="ts" setup>
 import { shallowRef, defineAsyncComponent, onUnmounted } from 'vue'
 import { Button } from 'vant'
-import { getBuyOrSellName } from '@/constants/order'
+import { getBuyOrSellName, getGoodsCurrencyItemName } from '@/constants/order'
 import { useComponent } from '@/hooks/component'
 import { useSBYJOrderStore } from '@/stores'
 import { formatDate, formatDecimal, formatAmount, parsePercent } from '@/filters'
-import { getCurrencyName } from '@/constants/order'
 import AppPullRefresh from '@mobile/components/base/pull-refresh/index.vue'
 import AppSelect from '@mobile/components/base/select/index.vue'
 import eventBus from '@/services/bus'
@@ -120,6 +119,9 @@ const { componentRef, componentId, openComponent, closeComponent } = useComponen
 
 const dataList = props.goodsId ? getOrderListByGoodsId(props.goodsId) : orderComputedList
 
+const enumName = (id: number) => {
+    return getGoodsCurrencyItemName(id)
+}
 // 平仓
 const closePosition = (row: Model.SBYJMyOrderRsp) => {
     selectedRow.value = row

+ 39 - 21
src/packages/digital/views/contract/goods/detail/index.vue

@@ -1,5 +1,5 @@
 <template>
-    <app-view class="contract-goods-detail g-layout g-form">
+    <app-view class="contract-goods-detail g-layout g-form" v-model:show="showModal">
         <template #header>
             <app-navbar title="交易">
                 <template #footer>
@@ -10,7 +10,7 @@
                         <template #label>
                             <span>{{ quote?.presettle }}</span>
                             <span>{{ parsePercent(quote?.change) }}</span>
-                            <span>{{ getGoodsCurrencyName(goods?.currencyid) }}</span>
+                            <span>{{ enumName }}</span>
                         </template>
                         <template #right-icon>
                             <span @click="routerToChart">图表</span>
@@ -35,36 +35,36 @@
             <Button :type="formData.BuyOrSell === BuyOrSell.Sell ? 'danger' : 'default'" size="small" block @click="buyOrSell(BuyOrSell.Sell)">开空</Button>
             </Col>
         </Row>
-        <Form ref="formRef" class="g-form__container">
+        <Form ref="formRef" class="g-form__container" @submit="onSubmit" >
             <CellGroup inset>
                 <Field label="方式" is-link>
                     <template #input>
                         <app-select v-model="formData.PriceMode" :options="options" />
                     </template>
                 </Field>
-                <Field v-if="formData.PriceMode === EPriceMode.PRICEMODE_LIMIT" name="OrderPrice" :rules="formRules.OrderPrice" label="价格">
+                <Field v-if="formData.PriceMode === EPriceMode.PRICEMODE_LIMIT" name="OrderPrice" :rules="formRules.OrderPrice" :label="'价格'+enumName">
                     <template #input>
-                        <app-stepper v-model="formData.OrderPrice" min="0.0" :decimal-length="quote?.decimalplace"
+                        <Stepper v-model="formData.OrderPrice" min="0.0" :decimal-length="quote?.decimalplace"
                             :step="quote?.decimalvalue" :auto-fixed="false" />
                     </template>
                 </Field>
                 <Cell v-else value="最优市价" />
                 <Field name="OrderQty" :rules="formRules.OrderQty" label="数量">
                     <template #input>
-                        <app-stepper v-model="formData.OrderQty" min="0.0" :auto-fixed="false" integer />
+                        <Stepper v-model="formData.OrderQty" min="0.0" :auto-fixed="false" integer theme="round" />
                     </template>
                 </Field>
-                <Cell title="开仓价值" :value="formatDecimal(openAmount)" />
+                <Cell title="开仓价值" :value="formatDecimal(openAmount)+enumName" />
             </CellGroup>
             <CellGroup>
                 <Cell title="可用余额" :value="calculations.availableBalance" />
                 <Cell title="可开数量" :value="calculations.sellQty" />
-                <Cell title="预估手续费" :value="serivcefee" />
+                <Cell title="预估手续费" :value="formatDecimal(serivcefee)" />
             </CellGroup>
         </Form>
         <Row class="g-layout-block g-layout-block--inset">
             <Col span="24">
-            <Button :type="formData.BuyOrSell === BuyOrSell.Buy ? 'success' : 'danger' " block @click="onSubmit">{{ formData.BuyOrSell === BuyOrSell.Buy ? '开多' : '开空' }}{{ goods?.goodscode }}</Button>
+            <Button :type="formData.BuyOrSell === BuyOrSell.Buy ? 'success' : 'danger' " block @click="formRef?.submit">{{ formData.BuyOrSell === BuyOrSell.Buy ? '开多' : '开空' }}{{ goods?.goodscode }}</Button>
             </Col>
         </Row>
         <Tabs v-model:active="tabIndex">
@@ -83,27 +83,31 @@
 
 <script lang="ts" setup>
 import { shallowRef, computed, onMounted } from 'vue'
-import { Form, Button, CellGroup, Field, Cell, Tab, Tabs, FieldRule, Col, Row } from 'vant'
+import { Form, FormInstance, Button, CellGroup, Field, Cell, Tab, Tabs, FieldRule, Col, Row } from 'vant'
 import { EPriceMode, EValidType, EOrderOperateType, EBuildType } from '@/constants/client'
 import { formatDecimal, parsePercent } from '@/filters'
 import { useNavigation } from '@mobile/router/navigation'
-import { useFuturesStore, useSBYJOrderStore, useUserStore } from '@/stores'
+import { useFuturesStore, useSBYJOrderStore, useUserStore, useAccountStore } from '@/stores'
 import { fullloading, dialog } from '@/utils/vant'
 import { useOrder } from '@/business/trade'
-import { useSpotAccountStore } from '../../../wallet/components/spot/composables'
-import AppStepper from '@mobile/components/base/stepper/index.vue'
+import { BuyOrSell, getGoodsCurrencyItemName } from '@/constants/order'
 import AppSelect from '@mobile/components/base/select/index.vue'
 import ContractPosition from '../../components/position/index.vue'
 import ContractOrder from '../../components/order/index.vue'
 import ContractAccount from '../../components/account/index.vue'
-import { BuyOrSell, getGoodsCurrencyName } from '@/constants/order'
+import Stepper from '@mobile/components/base/stepper/index.vue'
 
 const { router, getQueryStringToNumber } = useNavigation()
 const goodsId = getQueryStringToNumber('id')
 const futuresStore = useFuturesStore()
 const tabIndex = shallowRef(0)
 
+const formRef = shallowRef<FormInstance>()
+const showModal = shallowRef(true)
+
 const userStore = useUserStore()
+const taAccountStore = useAccountStore()
+
 const { formData, formSubmit } = useOrder()
 const { getSBYJMyOrders } = useSBYJOrderStore()
 const quote = computed(() => futuresStore.getQuoteInfo({ goodsid: goodsId }))
@@ -117,9 +121,13 @@ const options = computed(() => {
     }]
 })
 
-const spotAccountStore = useSpotAccountStore()
-const baseAccount = computed(() => spotAccountStore.getAccountItem({ currencyid: quote.value?.goodscurrencyid })) // 基础货币账户
-const quoteAccount = computed(() => spotAccountStore.getAccountItem({ currencyid: quote.value?.currencyid })) // 计价货币账户
+const enumName = computed(() => {
+    return getGoodsCurrencyItemName(quote.value?.currencyid ?? 0)
+})
+
+// const spotAccountStore = useSpotAccountStore()
+// const baseAccount = computed(() => spotAccountStore.getAccountItem({ currencyid: quote.value?.goodscurrencyid })) // 基础货币账户
+// const quoteAccount = computed(() => spotAccountStore.getAccountItem({ currencyid: quote.value?.currencyid })) // 计价货币账户
 
 // 预估手续费(小数位根据币种小数位格式化):
 // 手续费设置(固定) 时:预估手续费 = 数量 * 合约乘数 * 固定值
@@ -140,23 +148,26 @@ const serivcefee = computed(() => {
 // 保证金设置(固定) 时:可开数量 = 可用余额 / (合约乘数 * 固定值)
 // 保证金设置(比率) 时:可开数量 = 可用余额 / (价格 * 合约乘数 * 比率值)
 const calculations = computed(() => {
+    
     const { last = 0, agreeunit = 0 } = quote.value ?? {}
     const { OrderPrice = 0, OrderQty = 0 } = formData
 
+    const { balance = 0.0 } = taAccountStore.currentAccount
+
     const price = formData.PriceMode === EPriceMode.PRICEMODE_MARKET ? last : OrderPrice
 
     // 预估金额
     const estimatedAmount = price * OrderQty * agreeunit
 
     // 可用余额
-    const availableBalance = spotAccountStore.getAvailableBalance(quoteAccount.value)
+    const availableBalance = balance
     // 可用数量
     const availableQty = availableBalance / agreeunit
     // 预估手续费
     const buyEstimatedFee = 0
 
     // 可卖数量
-    const sellQty = spotAccountStore.getAvailableBalance(baseAccount.value)
+    const sellQty = 0
     // 可获金额
     const availableAmount = price * sellQty * agreeunit
     // 预估手续费
@@ -209,8 +220,15 @@ const formRules: { [key: string]: FieldRule[] } = {
     }],
     OrderQty: [{
         message: '请输入数量',
-        validator: () => {
-            return !!formData.OrderQty
+        validator: (val) => {
+            if (val) {
+                console.log(val)
+                if (val > 0) {
+                    return true
+                }
+                return '数量必须大于0'
+            }
+            return false
         }
     }],
 }

+ 10 - 1
src/stores/modules/enum.ts

@@ -12,6 +12,7 @@ export interface EnumType {
     value: number;
     disabled?: boolean;
     bankmappedvalue?: string
+    enumitemvalue?: string
 }
 
 const enumMap = new Map<string, ShallowRef<Model.EnumRsp[]>>()
@@ -93,7 +94,8 @@ export const useEnumStore = defineStore(() => {
                     ...e, // 待优化
                     label: props?.length ? props.join('-') : enumdicname.value,
                     value: e.enumitemname,
-                    bankmappedvalue: e.bankmappedvalue
+                    bankmappedvalue: e.bankmappedvalue,
+                    enumitemvalue: e.enumitemvalue
                 }
             })
         }
@@ -113,6 +115,12 @@ export const useEnumStore = defineStore(() => {
     }
 
     // 根据枚举名称获取对应的值
+    const getEnumTypeItemValue = (enums: EnumType[], value?: number) => {
+        const item = enums.find((e) => e.value === value)
+        return item?.enumitemvalue ?? value
+    }
+
+    // 根据枚举名称获取对应的值
     const getBankMappedValue = (enums: EnumType[], bankmappedvalue?: string) => {
         const item = enums.find((e) => e.bankmappedvalue === bankmappedvalue)
         return item?.label ?? bankmappedvalue
@@ -135,6 +143,7 @@ export const useEnumStore = defineStore(() => {
         getEnumTypeName,
         getEnumTypeValue,
         getBankMappedValue,
+        getEnumTypeItemValue,
         getEnumTypeBankMappedValue
     }
 })

+ 1 - 1
src/types/model/order.d.ts

@@ -1559,7 +1559,7 @@ declare namespace Model {
         goodsUnit: string;
         // 缩略图片(1:1)(逗号分隔)
         thumurls: string;
-        currencyid: number; 货币ID
+        currencyid: number; // 货币ID
     }
 
     /* 查询我的交收 请求*/