|
|
@@ -5,45 +5,51 @@
|
|
|
<template #header>
|
|
|
<app-navbar title="转让" @back="closed" />
|
|
|
</template>
|
|
|
- <component :is="Price" v-bind="{ goodsCode }" />
|
|
|
- <component :is="Forex" v-bind="{ goodsCode, showMore: false }" @price-click="onPriceClick" />
|
|
|
- <Form ref="formRef" class="g-form__container" @submit="onSubmit">
|
|
|
+ <Form ref="formRef" :label-width="100" class="g-form__container" @submit="onSubmit">
|
|
|
<CellGroup inset>
|
|
|
- <Field name="OrderPrice" :rules="formRules.OrderPrice" label="价格">
|
|
|
+ <Field label="商品代码/名称">
|
|
|
<template #input>
|
|
|
- <Stepper v-model="formData.OrderPrice" theme="round" button-size="22" :min="0"
|
|
|
- :auto-fixed="false" :decimal-length="quote?.decimalplace" :step="priceStep" />
|
|
|
+ <span>{{ selectedRow.goodscode }}/{{ selectedRow.goodsname }}</span>
|
|
|
</template>
|
|
|
</Field>
|
|
|
- <Field name="OrderQty" :rules="formRules.OrderQty" label="数量">
|
|
|
+ <Field label="预售价">
|
|
|
<template #input>
|
|
|
- <div class="goods-listing__stepper">
|
|
|
- <Stepper v-model="formData.OrderQty" theme="round" button-size="22" :min="0" :step="qtyStep"
|
|
|
- integer />
|
|
|
- <RadioGroup v-model="qtyStep" direction="horizontal" @change="onRadioChange">
|
|
|
- <Radio v-for="(value, index) in qtyStepList" :key="index" :name="value">{{ value }}
|
|
|
- </Radio>
|
|
|
- </RadioGroup>
|
|
|
- </div>
|
|
|
+ <span>{{ selectedRow.presaleprice }}</span>
|
|
|
</template>
|
|
|
</Field>
|
|
|
- <Field label="可用资金">
|
|
|
+ <Field label="可用量">
|
|
|
<template #input>
|
|
|
- <span>{{ accountStore.currentAccount.avaiableMoney?.toFixed(2) }}</span>
|
|
|
+ <span>{{ enableqty }}</span>
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ <Field label="涨停">
|
|
|
+ <template #input>
|
|
|
+ <span>{{ handleNumberValue(quote?.limitup) }}</span>
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ <Field label="跌停">
|
|
|
+ <template #input>
|
|
|
+ <span>{{ handleNumberValue(quote?.limitdown) }}</span>
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ <Field name="OrderPrice" :rules="formRules.OrderPrice" label="转让价">
|
|
|
+ <template #input>
|
|
|
+ <Stepper v-model="formData.OrderPrice" theme="round" :min="quote?.limitdown"
|
|
|
+ :max="quote?.limitup" :step="Math.pow(10, -selectedRow.decimalplace)"
|
|
|
+ :decimal-length="selectedRow.decimalplace" :auto-fixed="false" button-size="22" />
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ <Field name="OrderQty" :rules="formRules.OrderQty" label="转让数量">
|
|
|
+ <template #input>
|
|
|
+ <Stepper v-model="formData.OrderQty" theme="round" :max="enableqty" button-size="22"
|
|
|
+ :auto-fixed="false" integer />
|
|
|
</template>
|
|
|
</Field>
|
|
|
</CellGroup>
|
|
|
</Form>
|
|
|
<template #footer>
|
|
|
<div class="g-form__footer">
|
|
|
- <Button block square type="danger" @click="formRef?.submit"
|
|
|
- v-if="buyOrSell === BuyOrSell.Buy">订立买入</Button>
|
|
|
- <Button block square type="primary"
|
|
|
- :disabled="!formData.OrderQty || !enableqty || (formData.OrderQty > enableqty)"
|
|
|
- @click="formRef?.submit" v-if="buyOrSell === BuyOrSell.Sell">
|
|
|
- <span>转让卖出</span>
|
|
|
- <span v-if="enableqty">(≤{{ enableqty }})</span>
|
|
|
- </Button>
|
|
|
+ <Button block square type="danger" @click="formRef?.submit">提交</Button>
|
|
|
</div>
|
|
|
</template>
|
|
|
</app-view>
|
|
|
@@ -51,63 +57,29 @@
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { shallowRef, defineAsyncComponent, computed, onMounted } from 'vue'
|
|
|
-import { CellGroup, Form, Field, Stepper, Button, FieldRule, FormInstance, RadioGroup, Radio } from 'vant'
|
|
|
+import { shallowRef, PropType, computed, onMounted } from 'vue'
|
|
|
+import { CellGroup, Form, Field, Stepper, Button, FieldRule, FormInstance } from 'vant'
|
|
|
import { fullloading, dialog } from '@/utils/vant'
|
|
|
-import { useRequest } from '@/hooks/request'
|
|
|
-import { queryMineTradePositionExs } from '@/services/api/transfer'
|
|
|
+import { handleNumberValue } from '@/filters'
|
|
|
import { useOrder } from '@/business/trade'
|
|
|
-import { useAccountStore, useFuturesStore } from '@/stores'
|
|
|
+import { useFuturesStore } from '@/stores'
|
|
|
import AppModal from '@/components/base/modal/index.vue'
|
|
|
import { BuyOrSell } from '@/constants/order'
|
|
|
import { EPriceMode, EValidType, EListingSelectType, EBuildType } from '@/constants/client'
|
|
|
|
|
|
-const Price = defineAsyncComponent(() => import('../../../../../../components/modules/quote/price/index.vue'))
|
|
|
-const Forex = defineAsyncComponent(() => import('../../../../../../components/modules/quote/forex/index.vue'))
|
|
|
-
|
|
|
const props = defineProps({
|
|
|
- goodsCode: {
|
|
|
- type: String,
|
|
|
+ selectedRow: {
|
|
|
+ type: Object as PropType<Model.MineTradePositionExsRsp>,
|
|
|
required: true
|
|
|
},
|
|
|
- buyOrSell: {
|
|
|
- type: Number,
|
|
|
- required: true
|
|
|
- }
|
|
|
})
|
|
|
|
|
|
const { formData, formSubmit } = useOrder()
|
|
|
-const accountStore = useAccountStore()
|
|
|
-const futuresStore = useFuturesStore()
|
|
|
+const { getGoodsQuote } = useFuturesStore()
|
|
|
const formRef = shallowRef<FormInstance>()
|
|
|
const refresh = shallowRef(false) // 是否刷新父组件数据
|
|
|
const showModal = shallowRef(true)
|
|
|
-const quote = futuresStore.getGoodsQuote(props.goodsCode)
|
|
|
-const qtyStepList = [1, 5, 10, 20, 30, 50] // 数量步长列表
|
|
|
-const qtyStep = shallowRef(qtyStepList[0]) // 数量步长
|
|
|
-
|
|
|
-// 获取转让持仓
|
|
|
-const { dataList: positionList, run: getMineTradePositionExs } = useRequest(queryMineTradePositionExs, {
|
|
|
- manual: true,
|
|
|
- params: {
|
|
|
- goodsid: quote.value?.goodsid,
|
|
|
- },
|
|
|
- onSuccess: (res) => {
|
|
|
- const [firstItem] = res.data
|
|
|
- if (firstItem) {
|
|
|
- formData.OrderPrice = firstItem.presaleprice
|
|
|
- }
|
|
|
- }
|
|
|
-})
|
|
|
-
|
|
|
-// 价格步长
|
|
|
-const priceStep = computed(() => {
|
|
|
- const { quoteminunit = 0, decimalplace = 0 } = quote.value ?? {}
|
|
|
- if (quoteminunit) {
|
|
|
- return quoteminunit * Math.pow(10, decimalplace * -1)
|
|
|
- }
|
|
|
- return 1
|
|
|
-})
|
|
|
+const quote = getGoodsQuote(props.selectedRow.goodscode)
|
|
|
|
|
|
// 表单验证规则
|
|
|
const formRules: { [key in keyof Proto.OrderReq]?: FieldRule[] } = {
|
|
|
@@ -126,29 +98,24 @@ const formRules: { [key in keyof Proto.OrderReq]?: FieldRule[] } = {
|
|
|
}
|
|
|
|
|
|
// 可用数量
|
|
|
-const enableqty = computed(() => {
|
|
|
- const [firstItem] = positionList.value
|
|
|
- return firstItem ? firstItem.buycurpositionqty - firstItem.buyfrozenqty : 0
|
|
|
-})
|
|
|
+const enableqty = computed(() => props.selectedRow.buycurpositionqty - props.selectedRow.buyfrozenqty)
|
|
|
|
|
|
-const onPriceClick = (buyorsell: BuyOrSell, value: number) => {
|
|
|
- formData.OrderPrice = value
|
|
|
-}
|
|
|
-
|
|
|
-const onRadioChange = (value: number) => {
|
|
|
- formData.OrderQty = value
|
|
|
+// 关闭弹窗
|
|
|
+const closed = (isRefresh = false) => {
|
|
|
+ refresh.value = isRefresh
|
|
|
+ showModal.value = false
|
|
|
}
|
|
|
|
|
|
// 提交挂牌
|
|
|
const onSubmit = () => {
|
|
|
- const { marketid = 0, goodsid = 0 } = quote.value ?? {}
|
|
|
- formData.MarketID = marketid
|
|
|
+ const { goodsid } = props.selectedRow
|
|
|
formData.GoodsID = goodsid
|
|
|
- formData.BuyOrSell = props.buyOrSell
|
|
|
+ formData.MarketID = 49201
|
|
|
+ formData.BuyOrSell = BuyOrSell.Sell
|
|
|
formData.TimevalidType = EValidType.VALIDTYPE_YZ
|
|
|
formData.PriceMode = EPriceMode.PRICEMODE_LIMIT
|
|
|
- formData.ListingSelectType = EListingSelectType.LISTINGSELECTTYPE_DELISTINGTHENLISTING
|
|
|
- formData.BuildType = props.buyOrSell === BuyOrSell.Sell ? EBuildType.BUILDTYPE_CLOSE : EBuildType.BUILDTYPE_OPEN
|
|
|
+ formData.ListingSelectType = EListingSelectType.LISTINGSELECTTYPE_LISTING
|
|
|
+ formData.BuildType = EBuildType.BUILDTYPE_CLOSE
|
|
|
|
|
|
fullloading((hideLoading) => {
|
|
|
formSubmit().then(() => {
|
|
|
@@ -161,20 +128,9 @@ const onSubmit = () => {
|
|
|
}
|
|
|
|
|
|
onMounted(() => {
|
|
|
- const { last = 0, presettle = 0 } = quote.value ?? {}
|
|
|
- formData.OrderPrice = last || presettle
|
|
|
-
|
|
|
- if (props.buyOrSell === BuyOrSell.Sell) {
|
|
|
- getMineTradePositionExs()
|
|
|
- }
|
|
|
+ formData.OrderPrice = props.selectedRow.presaleprice
|
|
|
})
|
|
|
|
|
|
-// 关闭弹窗
|
|
|
-const closed = (isRefresh = false) => {
|
|
|
- refresh.value = isRefresh
|
|
|
- showModal.value = false
|
|
|
-}
|
|
|
-
|
|
|
// 暴露组件属性给父组件调用
|
|
|
defineExpose({
|
|
|
closed,
|