|
@@ -20,17 +20,20 @@
|
|
|
<CellGroup inset>
|
|
<CellGroup inset>
|
|
|
<Field label="限单价">
|
|
<Field label="限单价">
|
|
|
<template #input>
|
|
<template #input>
|
|
|
- <app-select :options="[]" />
|
|
|
|
|
|
|
+ <app-select v-model="formData.PriceMode" :options="options" />
|
|
|
</template>
|
|
</template>
|
|
|
</Field>
|
|
</Field>
|
|
|
- <Field label="价格">
|
|
|
|
|
|
|
+ <Field name="OrderPrice" :rules="formRules.OrderPrice" label="价格">
|
|
|
<template #input>
|
|
<template #input>
|
|
|
- <app-stepper theme="round" />
|
|
|
|
|
|
|
+ <Stepper v-model="formData.OrderPrice" theme="round" min="0.0"
|
|
|
|
|
+ :decimal-length="quote?.decimalplace" :step="quote?.decimalvalue" :auto-fixed="false"
|
|
|
|
|
+ button-size="22" />
|
|
|
</template>
|
|
</template>
|
|
|
</Field>
|
|
</Field>
|
|
|
- <Field label="数量">
|
|
|
|
|
|
|
+ <Field name="OrderQty" :rules="formRules.OrderQty" label="数量">
|
|
|
<template #input>
|
|
<template #input>
|
|
|
- <app-stepper theme="round" />
|
|
|
|
|
|
|
+ <Stepper v-model="formData.OrderQty" theme="round" min="0.0" button-size="22"
|
|
|
|
|
+ :auto-fixed="false" integer />
|
|
|
</template>
|
|
</template>
|
|
|
</Field>
|
|
</Field>
|
|
|
<Field label="开仓价值">
|
|
<Field label="开仓价值">
|
|
@@ -42,7 +45,7 @@
|
|
|
<Cell title="预估手续费" value="0" />
|
|
<Cell title="预估手续费" value="0" />
|
|
|
</CellGroup>
|
|
</CellGroup>
|
|
|
</Form>
|
|
</Form>
|
|
|
- <Button type="danger">开多</Button>
|
|
|
|
|
|
|
+ <Button type="danger" @click="onSubmit">开多</Button>
|
|
|
<Tabs v-model:active="tabIndex">
|
|
<Tabs v-model:active="tabIndex">
|
|
|
<Tab title="持仓">
|
|
<Tab title="持仓">
|
|
|
<contract-position v-bind="{ goodsId }" />
|
|
<contract-position v-bind="{ goodsId }" />
|
|
@@ -58,24 +61,38 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
-import { shallowRef, computed } from 'vue'
|
|
|
|
|
-import { Form, Button, CellGroup, Field, Cell, Tab, Tabs, } from 'vant'
|
|
|
|
|
|
|
+import { shallowRef, computed, onMounted } from 'vue'
|
|
|
|
|
+import { Form, Button, CellGroup, Field, Cell, Tab, Tabs, FieldRule } from 'vant'
|
|
|
|
|
+import { EPriceMode, EValidType, EOrderOperateType, EBuildType } from '@/constants/client'
|
|
|
import { parsePercent } from '@/filters'
|
|
import { parsePercent } from '@/filters'
|
|
|
import { useNavigation } from '@mobile/router/navigation'
|
|
import { useNavigation } from '@mobile/router/navigation'
|
|
|
import { useFuturesStore } from '@/stores'
|
|
import { useFuturesStore } from '@/stores'
|
|
|
|
|
+import { fullloading, dialog } from '@/utils/vant'
|
|
|
|
|
+import { useOrder } from '@/business/trade'
|
|
|
|
|
+import Stepper from '@mobile/components/base/stepper/index.vue'
|
|
|
import AppSelect from '@mobile/components/base/select/index.vue'
|
|
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 ContractPosition from '../../components/position/index.vue'
|
|
|
import ContractOrder from '../../components/order/index.vue'
|
|
import ContractOrder from '../../components/order/index.vue'
|
|
|
import ContractAccount from '../../components/account/index.vue'
|
|
import ContractAccount from '../../components/account/index.vue'
|
|
|
|
|
+import { BuyOrSell } from '@/constants/order'
|
|
|
|
|
|
|
|
const { router, getQueryStringToNumber } = useNavigation()
|
|
const { router, getQueryStringToNumber } = useNavigation()
|
|
|
const goodsId = getQueryStringToNumber('id')
|
|
const goodsId = getQueryStringToNumber('id')
|
|
|
const futuresStore = useFuturesStore()
|
|
const futuresStore = useFuturesStore()
|
|
|
const tabIndex = shallowRef(0)
|
|
const tabIndex = shallowRef(0)
|
|
|
|
|
|
|
|
|
|
+const { formData, formSubmit } = useOrder()
|
|
|
|
|
+
|
|
|
const quote = computed(() => futuresStore.getQuoteInfo({ goodsid: goodsId }))
|
|
const quote = computed(() => futuresStore.getQuoteInfo({ goodsid: goodsId }))
|
|
|
|
|
|
|
|
|
|
+const options = computed(() => {
|
|
|
|
|
+ return [{
|
|
|
|
|
+ label: '限价单', value: EPriceMode.PRICEMODE_LIMIT
|
|
|
|
|
+ }, {
|
|
|
|
|
+ label: '市价单', value: EPriceMode.PRICEMODE_MARKET
|
|
|
|
|
+ }]
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
const routerToChart = () => {
|
|
const routerToChart = () => {
|
|
|
router.push({
|
|
router.push({
|
|
|
name: 'contract-goods-chart',
|
|
name: 'contract-goods-chart',
|
|
@@ -84,6 +101,66 @@ const routerToChart = () => {
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+// 表单验证规则
|
|
|
|
|
+const formRules: { [key: string]: FieldRule[] } = {
|
|
|
|
|
+ OrderPrice: [{
|
|
|
|
|
+ message:'请输入价格',
|
|
|
|
|
+ validator: () => {
|
|
|
|
|
+ return !!formData.OrderPrice
|
|
|
|
|
+ }
|
|
|
|
|
+ }],
|
|
|
|
|
+ OrderQty: [{
|
|
|
|
|
+ message: '请输入数量',
|
|
|
|
|
+ validator: () => {
|
|
|
|
|
+ return !!formData.OrderQty
|
|
|
|
|
+ }
|
|
|
|
|
+ }],
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 下单
|
|
|
|
|
+const onSubmit = () => {
|
|
|
|
|
+ // 计算提示信息
|
|
|
|
|
+ // const { marketid = 0, goodsid = 0, goodunitid = 0 } = quote.value ?? {}
|
|
|
|
|
+ // const { marginalgorithm = 0, transferdepositratio = 0.0 } = goods ?? {}
|
|
|
|
|
+ // const totalamount = orderQty.value*(formData.OrderPrice ?? 0)
|
|
|
|
|
+ // const orderPrice = `定价价格:${formData.OrderPrice ?? 0}\n`
|
|
|
|
|
+ // const qty = `订单数量:${orderQty.value}${getGoodsUnitName(goodunitid)}\n`
|
|
|
|
|
+ // const orderamount = `订单总额:${formatDecimal(totalamount)}\n`
|
|
|
|
|
+ // console.log(marginalgorithm, transferdepositratio)
|
|
|
|
|
+ // const margin = `预付定金:${formatDecimal(marginalgorithm === 1 ? totalamount*transferdepositratio : orderQty.value*transferdepositratio)}\n`
|
|
|
|
|
+ // const message = orderPrice + qty + orderamount + margin
|
|
|
|
|
+
|
|
|
|
|
+ const { marketid = 0, goodsid = 0 } = quote.value ?? {}
|
|
|
|
|
+ dialog({
|
|
|
|
|
+ message: '确认要提交吗?',
|
|
|
|
|
+ showCancelButton: true,
|
|
|
|
|
+ }).then(() => {
|
|
|
|
|
+ /// 获取对应的市场ID
|
|
|
|
|
+ formData.MarketID = marketid
|
|
|
|
|
+ formData.GoodsID = goodsid
|
|
|
|
|
+ formData.TimevalidType = EValidType.VALIDTYPE_DR
|
|
|
|
|
+ formData.OperateType = EOrderOperateType.ORDEROPERATETYPE_NORMAL
|
|
|
|
|
+ formData.BuildType = EBuildType.BUILDTYPE_OPEN
|
|
|
|
|
+
|
|
|
|
|
+ fullloading((hideLoading) => {
|
|
|
|
|
+ formSubmit().then(() => {
|
|
|
|
|
+ hideLoading('提交成功。', 'success')
|
|
|
|
|
+ // 刷新订单列表
|
|
|
|
|
+ // getSBYJMyOrders()
|
|
|
|
|
+ }).catch((err) => {
|
|
|
|
|
+ hideLoading(err, 'fail')
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+onMounted(() => {
|
|
|
|
|
+ if(quote.value) {
|
|
|
|
|
+ formData.BuyOrSell = BuyOrSell.Buy
|
|
|
|
|
+ formData.PriceMode = EPriceMode.PRICEMODE_MARKET
|
|
|
|
|
+ }
|
|
|
|
|
+})
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="less">
|
|
<style lang="less">
|