|
|
@@ -15,15 +15,15 @@
|
|
|
</el-radio-group>
|
|
|
</el-form-item>
|
|
|
<el-form-item v-if="priceMove === 2" prop="OrderPrice" label="挂牌价格">
|
|
|
- <el-input-number placeholder="请输入" :min="0" :precision="2" v-model="formData.OrderPrice" />
|
|
|
+ <el-input-number placeholder="请输入" :min="0" :precision="2" v-model="formData.OrderPrice" @change="calculateListingAmount"/>
|
|
|
</el-form-item>
|
|
|
<el-form-item v-if="priceMove === 3" prop="MarketMaxSub" label="点差">
|
|
|
- <el-input-number placeholder="请输入" :min="0" :precision="2" v-model="formData.MarketMaxSub" />
|
|
|
+ <el-input-number placeholder="请输入" :min="minBasis" :maxBasis="maxBasis" :precision="2" v-model="formData.MarketMaxSub" @change="calculateListingAmount" />
|
|
|
</el-form-item>
|
|
|
<el-form-item prop="OrderQty" label="挂牌数量">
|
|
|
<div class="g-qty-group">
|
|
|
<el-input-number placeholder="请输入" :min="0" :precision="0" :step="qtyStep"
|
|
|
- v-model="formData.OrderQty" />
|
|
|
+ v-model="formData.OrderQty" @change="calculateListingAmount" />
|
|
|
<el-radio-group size="small" v-model="qtyStep" @change="onRadioChange">
|
|
|
<el-radio v-for="(value, index) in qtyStepList" :key="index" :label="value" border />
|
|
|
</el-radio-group>
|
|
|
@@ -36,12 +36,9 @@
|
|
|
<span :class="quote?.lastColor">{{ quote?.last ?? 0.0 }}</span>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="估算价格" v-if="priceMove === 3">
|
|
|
- <span>0.0</span>
|
|
|
+ <span>{{ estimateprice.toFixed(goods?.decimalplace) }}</span>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="挂牌金额" v-if="priceMove === 2">
|
|
|
- <span>{{ amount.toFixed(2) }}</span>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="估算金额" v-if="priceMove === 3">
|
|
|
+ <el-form-item :label="priceMove === 2 ? '挂牌金额' : '估算金额'">
|
|
|
<span>{{ amount.toFixed(2) }}</span>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="履约保证金">
|
|
|
@@ -59,15 +56,18 @@
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { shallowRef, PropType } from 'vue'
|
|
|
+import { shallowRef, PropType, computed } from 'vue'
|
|
|
import { ElMessage, FormInstance, FormRules, ElMessageBox } from 'element-plus'
|
|
|
import { EBuildType, EDelistingType, EListingSelectType, EOrderOperateType, EPriceMode, EValidType } from '@/constants/client'
|
|
|
import { useOrder } from '@/business/trade'
|
|
|
import { useAccountStore, useFuturesStore, useUserStore } from '@/stores'
|
|
|
+import { useRequest } from '@/hooks/request'
|
|
|
+import { queryTjmdTodayAccountMargin } from '@/services/api/swap'
|
|
|
import AppDrawer from '@pc/components/base/drawer/index.vue'
|
|
|
+import { queryWrMarketTradeConfig } from '@/services/api/goods'
|
|
|
|
|
|
const props = defineProps({
|
|
|
- selectedRow: {
|
|
|
+ quoteGoods: {
|
|
|
type: Object as PropType<Model.QuoteGoodsListRsp>,
|
|
|
required: true
|
|
|
}
|
|
|
@@ -83,6 +83,12 @@ const priceMove = shallowRef(EPriceMode.PRICEMODE_LIMIT)
|
|
|
const amount = shallowRef(0.0)
|
|
|
/// 履约保证金
|
|
|
const permargin = shallowRef(0.0)
|
|
|
+/// 最大基差范围上限
|
|
|
+const maxBasis = shallowRef(0.0)
|
|
|
+/// 最小基差范围下限
|
|
|
+const minBasis = shallowRef(0.0)
|
|
|
+/// 估算价
|
|
|
+const estimateprice = shallowRef(0.0)
|
|
|
|
|
|
const { formData, formSubmit, loading } = useOrder()
|
|
|
const show = shallowRef(true)
|
|
|
@@ -91,8 +97,47 @@ const formRef = shallowRef<FormInstance>()
|
|
|
const qtyStepList = [1, 5, 10, 20, 30, 50] // 数量步长列表
|
|
|
const qtyStep = shallowRef(qtyStepList[0]) // 数量步长
|
|
|
|
|
|
+
|
|
|
// 商品盘面
|
|
|
-const quote = futuresStore.getGoodsQuote(props.selectedRow.refgoodsid)
|
|
|
+const quote = futuresStore.getGoodsQuote(props.quoteGoods.refgoodsid) ?? {}
|
|
|
+/// 保证金参数设置
|
|
|
+const margin = shallowRef<Model.TjmdTodayAccountMarginRsp>()
|
|
|
+/// 商品信息
|
|
|
+const goods = computed(() => futuresStore.getGoods(props.quoteGoods.goodsid) )
|
|
|
+/// 市场交易参数配置
|
|
|
+const config = shallowRef<Model.WrMarketTradeConfigRsp>()
|
|
|
+
|
|
|
+/// 查询交易保证金信息
|
|
|
+useRequest(queryTjmdTodayAccountMargin, {
|
|
|
+ params: {
|
|
|
+ goodsid: props.quoteGoods.goodsid.toString(),
|
|
|
+ accountid: accountStore.currentAccountId.toString()
|
|
|
+ },
|
|
|
+ onSuccess: (res) => {
|
|
|
+ /// 数据赋值
|
|
|
+ if (res.data.length != 0) {
|
|
|
+ margin.value = res.data[0]
|
|
|
+ /// 计算摘牌金额
|
|
|
+ calculateListingAmount()
|
|
|
+ }
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+/// 查询市场交易参数配置
|
|
|
+useRequest(queryWrMarketTradeConfig, {
|
|
|
+ params: {
|
|
|
+ marketid: userStore.getMarketId('TRADEMODE_TJMD')
|
|
|
+ },
|
|
|
+ onSuccess: (res) => {
|
|
|
+ /// 数据赋值
|
|
|
+ if (res.data.length != 0) {
|
|
|
+ /// 获取参数
|
|
|
+ config.value = res.data[0]
|
|
|
+ /// 计算基差范围
|
|
|
+ calculateBasis()
|
|
|
+ }
|
|
|
+ }
|
|
|
+})
|
|
|
|
|
|
const formRules: FormRules = {
|
|
|
OrderPrice: [{
|
|
|
@@ -115,10 +160,74 @@ const formRules: FormRules = {
|
|
|
}
|
|
|
}
|
|
|
}],
|
|
|
+ MarketMaxSub: [{
|
|
|
+ required: true,
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
+ if (value) {
|
|
|
+ callback()
|
|
|
+ } else {
|
|
|
+ callback(new Error('请输入基差'))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }],
|
|
|
}
|
|
|
|
|
|
const onRadioChange = (value: number) => {
|
|
|
+ /// 设置
|
|
|
formData.OrderQty = value
|
|
|
+ /// 计算挂牌金额
|
|
|
+ calculateListingAmount()
|
|
|
+}
|
|
|
+
|
|
|
+/// 计算挂牌金额
|
|
|
+const calculateListingAmount = () => {
|
|
|
+ /// 如果保证金配置存在的情况下
|
|
|
+ if (margin.value?.infoc) {
|
|
|
+ if (priceMove.value === 2) { /// 一口价
|
|
|
+ const { MarginAlgorithm, MarketMarginValue } = margin.value?.infoc
|
|
|
+ const { OrderQty = 0, OrderPrice = 0 } = formData
|
|
|
+ const { agreeunit = 0 } = goods.value ?? {}
|
|
|
+ /// 按比例
|
|
|
+ if (MarginAlgorithm === 1) {
|
|
|
+ permargin.value = OrderPrice*OrderQty*agreeunit*MarketMarginValue
|
|
|
+ } else {
|
|
|
+ permargin.value = OrderQty*MarketMarginValue
|
|
|
+ }
|
|
|
+ amount.value = OrderQty*OrderPrice*agreeunit
|
|
|
+ } else {
|
|
|
+ const last = futuresStore.getQuotePrice(props.quoteGoods.refgoodscode)
|
|
|
+ const basic = formData.MarketMaxSub ?? 0.0
|
|
|
+ /// 浮动估算价价
|
|
|
+ estimateprice.value = basic+last.value
|
|
|
+ const { MarginAlgorithm, MarketMarginValue } = margin.value?.infoc
|
|
|
+ const { OrderQty = 0 } = formData
|
|
|
+ const { agreeunit = 0 } = goods.value ?? {}
|
|
|
+ /// 按比例
|
|
|
+ if (MarginAlgorithm === 1) {
|
|
|
+ permargin.value = estimateprice.value*OrderQty*agreeunit*MarketMarginValue
|
|
|
+ } else {
|
|
|
+ permargin.value = OrderQty*MarketMarginValue
|
|
|
+ }
|
|
|
+ amount.value = OrderQty*estimateprice.value*agreeunit
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/// 计算基差范围
|
|
|
+const calculateBasis = () => {
|
|
|
+ /// 获取配置
|
|
|
+ if (config.value) {
|
|
|
+ const { basisdownratio, basisupratio} = config.value
|
|
|
+ const { preclose = 0 } = quote.value ?? {}
|
|
|
+ console.log(basisdownratio, basisupratio, preclose)
|
|
|
+ /* 基差范围大小
|
|
|
+ 基差价格可以为负或为0
|
|
|
+ 基差范围:
|
|
|
+ 最大值=基差取值上限百分比*关联期货合约昨收价
|
|
|
+ 最小值= -1 * 基差取值下限百分比*关联期货合约昨收价 */
|
|
|
+ maxBasis.value = basisupratio*preclose
|
|
|
+ minBasis.value = -1.0*basisdownratio*preclose
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
const onCancel = (isRefresh = false) => {
|
|
|
@@ -134,7 +243,7 @@ const onSubmit = () => {
|
|
|
'是否立即挂牌?'
|
|
|
).then(() => {
|
|
|
/// 买卖方向
|
|
|
- const { goodsid } = props.selectedRow?? {}
|
|
|
+ const { goodsid } = props.quoteGoods?? {}
|
|
|
/// 获取对应的市场ID
|
|
|
formData.MarketID = futuresStore.getGoodsMarket(goodsid)
|
|
|
formData.OrderPrice = priceMove.value === EPriceMode.PRICEMODE_LIMIT ? formData.OrderPrice : 0.0
|