|
|
@@ -1,16 +1,15 @@
|
|
|
<template>
|
|
|
<app-view class="contract-goods-detail g-layout g-form" v-model:show="showModal">
|
|
|
<template #header>
|
|
|
- <app-navbar title="交易">
|
|
|
+ <app-navbar :title="quote ? `${quote.goodscode}/${quote.goodsname}` : '交易'">
|
|
|
<template #footer>
|
|
|
<Cell>
|
|
|
- <template #title>
|
|
|
- <b>{{ quote?.goodscode }}/{{ quote?.goodsname }}</b>
|
|
|
- </template>
|
|
|
- <template #label>
|
|
|
- <span>{{ quote?.presettle }}</span>
|
|
|
- <span>{{ parsePercent(quote?.change) }}</span>
|
|
|
- <span>{{ enumName }}</span>
|
|
|
+ <template #title v-if="quote">
|
|
|
+ <h3>
|
|
|
+ <span>{{ quote.presettle }}</span>
|
|
|
+ <span style="color: #999;font-size: 14px;margin-left: 2px;">{{ enumName }}</span>
|
|
|
+ </h3>
|
|
|
+ <span :class="quote.lastColor">{{ parsePercent(quote.change) }}</span>
|
|
|
</template>
|
|
|
<template #right-icon>
|
|
|
<span @click="routerToChart">图表</span>
|
|
|
@@ -19,44 +18,43 @@
|
|
|
</template>
|
|
|
</app-navbar>
|
|
|
</template>
|
|
|
+ <div class="contract-goods-detail__price g-layout-block g-layout-block--inset">
|
|
|
+ <h3 :class="quote?.askColor">{{ quote?.ask }}</h3>
|
|
|
+ <h3 :class="quote?.bidColor">{{ quote?.bid }}</h3>
|
|
|
+ </div>
|
|
|
<Row class="g-layout-block g-layout-block--inset" gutter="10">
|
|
|
<Col span="12">
|
|
|
- <span :class="quote?.askColor">{{ quote?.ask }}</span>
|
|
|
- </Col>
|
|
|
- <Col span="12">
|
|
|
- <span :class="quote?.bidColor">{{ quote?.bid }}</span>
|
|
|
- </Col>
|
|
|
- </Row>
|
|
|
- <Row class="g-layout-block g-layout-block--inset" gutter="10">
|
|
|
- <Col span="12">
|
|
|
- <Button :type="formData.BuyOrSell === BuyOrSell.Buy ? 'success' : 'default'" size="small" block @click="buyOrSell(BuyOrSell.Buy)">开多</Button>
|
|
|
+ <Button :type="formData.BuyOrSell === BuyOrSell.Buy ? 'success' : 'default'" size="small" block
|
|
|
+ @click="buyOrSell(BuyOrSell.Buy)">开多</Button>
|
|
|
</Col>
|
|
|
<Col span="12">
|
|
|
- <Button :type="formData.BuyOrSell === BuyOrSell.Sell ? 'danger' : 'default'" size="small" block @click="buyOrSell(BuyOrSell.Sell)">开空</Button>
|
|
|
+ <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" @submit="onSubmit" >
|
|
|
+ <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="'价格'+enumName">
|
|
|
+ <Field v-if="formData.PriceMode === EPriceMode.PRICEMODE_LIMIT" name="OrderPrice"
|
|
|
+ :rules="formRules.OrderPrice" :label="'价格' + enumName">
|
|
|
<template #input>
|
|
|
- <Stepper v-model="formData.OrderPrice" min="0.0" :decimal-length="quote?.decimalplace"
|
|
|
- :step="quote?.decimalvalue" :auto-fixed="false" />
|
|
|
+ <app-stepper v-model="formData.OrderPrice" :min="0" :decimal-length="quote?.decimalplace"
|
|
|
+ :step="quote?.decimalvalue" />
|
|
|
</template>
|
|
|
</Field>
|
|
|
<Cell v-else value="最优市价" />
|
|
|
<Field name="OrderQty" :rules="formRules.OrderQty" label="数量">
|
|
|
<template #input>
|
|
|
- <Stepper v-model="formData.OrderQty" min="0.0" :auto-fixed="false" integer theme="round" />
|
|
|
+ <app-stepper v-model="formData.OrderQty" :min="0" />
|
|
|
</template>
|
|
|
</Field>
|
|
|
- <Cell title="开仓价值" :value="formatDecimal(openAmount)+enumName" />
|
|
|
+ <Cell title="开仓价值" :value="formatDecimal(openAmount) + enumName" />
|
|
|
</CellGroup>
|
|
|
- <CellGroup>
|
|
|
+ <CellGroup inset>
|
|
|
<Cell title="可用余额" :value="calculations.availableBalance" />
|
|
|
<Cell title="可开数量" :value="calculations.sellQty" />
|
|
|
<Cell title="预估手续费" :value="formatDecimal(serivcefee)" />
|
|
|
@@ -118,7 +116,9 @@
|
|
|
</Form>
|
|
|
<Row class="g-layout-block g-layout-block--inset">
|
|
|
<Col span="24">
|
|
|
- <Button :type="formData.BuyOrSell === BuyOrSell.Buy ? 'success' : 'danger' " block @click="formRef?.submit">{{ 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">
|
|
|
@@ -136,7 +136,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { shallowRef, computed, onMounted } from 'vue'
|
|
|
+import { shallowRef, computed, onMounted, onActivated } from 'vue'
|
|
|
import { Form, FormInstance, Button, CellGroup, Field, Cell, Tab, Tabs, FieldRule, Col, Row, Slider, Checkbox } from 'vant'
|
|
|
import { EPriceMode, EValidType, EOrderOperateType, EBuildType } from '@/constants/client'
|
|
|
import { formatDecimal, parsePercent } from '@/filters'
|
|
|
@@ -146,12 +146,12 @@ import { fullloading, dialog } from '@/utils/vant'
|
|
|
import { useOrder } from '@/business/trade'
|
|
|
import { BuyOrSell, getGoodsCurrencyItemName } from '@/constants/order'
|
|
|
import AppSelect from '@mobile/components/base/select/index.vue'
|
|
|
+import AppStepper from '@mobile/components/base/stepper/index.vue'
|
|
|
import ContractPosition from '../../components/position/index.vue'
|
|
|
import ContractOrder from '../../components/order/index.vue'
|
|
|
import ContractAccount from '../../components/account/index.vue'
|
|
|
-import Stepper from '@mobile/components/base/stepper/index.vue'
|
|
|
|
|
|
-const { router, getQueryStringToNumber } = useNavigation()
|
|
|
+const { router, getQueryStringToNumber, getGlobalUrlParams } = useNavigation()
|
|
|
const goodsId = getQueryStringToNumber('id')
|
|
|
const futuresStore = useFuturesStore()
|
|
|
const tabIndex = shallowRef(0)
|
|
|
@@ -169,7 +169,7 @@ const sliderStep = 0.01 // 滑块步长
|
|
|
|
|
|
const { getSBYJMyOrders } = useSBYJOrderStore()
|
|
|
const quote = computed(() => futuresStore.getQuoteInfo({ goodsid: goodsId }))
|
|
|
-const goods = computed(() => futuresStore.getGoods(goodsId ?? 0 )) ?? {}
|
|
|
+const goods = computed(() => futuresStore.getGoods(goodsId ?? 0)) ?? {}
|
|
|
|
|
|
const options = computed(() => {
|
|
|
return [{
|
|
|
@@ -300,7 +300,7 @@ const serivcefee = computed(() => {
|
|
|
// 保证金设置(固定) 时:可开数量 = 可用余额 / (合约乘数 * 固定值)
|
|
|
// 保证金设置(比率) 时:可开数量 = 可用余额 / (价格 * 合约乘数 * 比率值)
|
|
|
const calculations = computed(() => {
|
|
|
-
|
|
|
+
|
|
|
const { last = 0, agreeunit = 0 } = quote.value ?? {}
|
|
|
const { OrderPrice = 0, OrderQty = 0 } = formData
|
|
|
|
|
|
@@ -351,14 +351,14 @@ const openAmount = computed(() => {
|
|
|
const orderQty = formData.OrderQty ?? 0.0
|
|
|
if (formData.PriceMode === EPriceMode.PRICEMODE_MARKET) {
|
|
|
const price = (formData.BuyOrSell === BuyOrSell.Buy ? quote.value?.ask : quote.value?.bid) ?? 0.0
|
|
|
- return price*orderQty*agreeunit
|
|
|
+ return price * orderQty * agreeunit
|
|
|
} else {
|
|
|
const price = formData.OrderPrice ?? 0.0
|
|
|
- return price*orderQty*agreeunit
|
|
|
+ return price * orderQty * agreeunit
|
|
|
}
|
|
|
})
|
|
|
|
|
|
-const buyOrSell = ( item: BuyOrSell) => {
|
|
|
+const buyOrSell = (item: BuyOrSell) => {
|
|
|
formData.BuyOrSell = item
|
|
|
}
|
|
|
|
|
|
@@ -448,6 +448,13 @@ onMounted(() => {
|
|
|
stopLossRatio.value = slratiodefault * 100
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ onActivated(() => {
|
|
|
+ const params = getGlobalUrlParams()
|
|
|
+ if (params.buyOrSell !== undefined) {
|
|
|
+ formData.BuyOrSell = params.buyOrSell
|
|
|
+ }
|
|
|
+ })
|
|
|
})
|
|
|
</script>
|
|
|
|