|
|
@@ -6,15 +6,18 @@
|
|
|
<div class="futures_trade__form">
|
|
|
<a-form class="inlineForm" ref="formRef" :model="formData" :rules="rules">
|
|
|
<a-form-item label="账号">
|
|
|
- <a-select class="inlineFormSelect" placeholder="请选择" v-model:value="formData.AccountID">
|
|
|
+ <a-select class="inlineFormSelect" placeholder="请选择" v-model:value="formData.AccountID" @change="getPositionList">
|
|
|
<a-select-option v-for="item in accountList" :value="item.accountid" :key="item.accountid">{{ item.accountname }} - {{item.accountid}}</a-select-option>
|
|
|
</a-select>
|
|
|
</a-form-item>
|
|
|
<a-form-item label="合约">
|
|
|
- <a-select class="inlineFormSelect" placeholder="请选择" :filterOption="filterOption" show-search v-model:value="formData.GoodsID" @change="goodsChange">
|
|
|
+ <a-select class="inlineFormSelect" placeholder="请选择" :disabled="isHedging" :filterOption="filterOption" v-model:value="formData.GoodsID" @change="goodsChange" show-search>
|
|
|
<a-select-option v-for="item in goodsList" :value="item.goodsid" :key="item.goodsid">{{ item.goodsname }}</a-select-option>
|
|
|
</a-select>
|
|
|
</a-form-item>
|
|
|
+ <a-form-item label="现货合同" v-if="isHedging">
|
|
|
+ <span class="white">{{ selectedRow.spotcontractid }}</span>
|
|
|
+ </a-form-item>
|
|
|
<a-form-item label="价格类型">
|
|
|
<a-select class="inlineFormSelect" placeholder="请选择" v-model:value="selectedPriceType" @change="priceTypeChange">
|
|
|
<a-select-option v-for="item in priceTypeList" :value="item.priceType" :key="item.priceType">{{ item.priceName }}</a-select-option>
|
|
|
@@ -32,7 +35,7 @@
|
|
|
</template>
|
|
|
</a-form-item>
|
|
|
<a-form-item class="inputIconBox" label="交易数量" name="OrderQty">
|
|
|
- <a-input-number class="commonInput" :min="1" v-model:value="formData.OrderQty" style="width:100%" />
|
|
|
+ <a-input-number class="commonInput" decimalSeparator="0" :min="1" v-model:value="formData.OrderQty" style="width:100%" />
|
|
|
<MinusOutlined @click="minusQty" />
|
|
|
<PlusOutlined @click="plusQty" />
|
|
|
</a-form-item>
|
|
|
@@ -48,11 +51,11 @@
|
|
|
<span>卖出</span>
|
|
|
</a-button>
|
|
|
<!--如果有持仓则显示按钮-->
|
|
|
- <a-button :loading="loading" @click="submit('close')" v-show="positionList.length">
|
|
|
+ <a-button :loading="loading" @click="submit('close')" v-show="positionList.length && !isHedging">
|
|
|
<span>平仓</span>
|
|
|
</a-button>
|
|
|
</div>
|
|
|
- <div class="futures_trade__table tableDatas" v-show="positionList.length">
|
|
|
+ <div class="futures_trade__table tableDatas" v-show="positionList.length && !isHedging">
|
|
|
<a-table class="dialogTable" :columns="getColumns()" :data-source="positionList" :rowKey="(record,index)=>index" :pagination="false" :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange, type:'radio' }"></a-table>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -68,13 +71,15 @@ import { Des } from '@/common/components/commonDes';
|
|
|
import Drawer from '@/common/components/drawer/index.vue';
|
|
|
import { _closeModal } from '@/common/setup/modal/modal';
|
|
|
import { MinusOutlined, PlusOutlined } from '@ant-design/icons-vue';
|
|
|
-import { defineComponent, ref, computed } from 'vue';
|
|
|
+import { defineComponent, ref, computed, PropType } from 'vue';
|
|
|
import { handleForm, getColumns } from './setup';
|
|
|
import { channelOrderReq } from '@/services/proto/futures';
|
|
|
import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
|
|
|
import { BuyOrSell, BuildType, PriceType } from '@/common/constants/enumCommon';
|
|
|
import { validateAction } from '@/common/setup/form';
|
|
|
import { GoodsQuote } from '@/services/go/ermcp/goodsInfo/interface';
|
|
|
+import { QueryErmcpTradePositionRsp } from '@/services/go/ermcp/futures/interface';
|
|
|
+import { Ermcp3SellBuyContract } from '@/services/go/ermcp/purchase/interface';
|
|
|
import { getGoodsQuoteList } from '@/services/bus/goods';
|
|
|
import { message } from 'ant-design-vue';
|
|
|
|
|
|
@@ -83,25 +88,22 @@ export default defineComponent({
|
|
|
name: 'trader',
|
|
|
components: { Des, Drawer, PlusOutlined, MinusOutlined },
|
|
|
props: {
|
|
|
- // 商品ID
|
|
|
- goodsId: {
|
|
|
- type: Number,
|
|
|
- default: 0,
|
|
|
- },
|
|
|
- // 交易所ID
|
|
|
- exchangeId: {
|
|
|
- type: Number,
|
|
|
- default: 0,
|
|
|
+ selectedRow: {
|
|
|
+ type: Object as PropType<GoodsQuote & QueryErmcpTradePositionRsp & Ermcp3SellBuyContract>,
|
|
|
+ default: () => {},
|
|
|
},
|
|
|
},
|
|
|
setup(props, context) {
|
|
|
+ // 是否套保交易 (根据参数 spotcontractid 来判断)
|
|
|
+ const isHedging = Boolean(props.selectedRow.spotcontractid);
|
|
|
+
|
|
|
const goodsList = getGoodsQuoteList();
|
|
|
const getGoods = (id: number) => goodsList.find((item) => item.goodsid === id)!;
|
|
|
// 当前选中的商品合约
|
|
|
- const selectedGoods = ref<GoodsQuote>(getGoods(props.goodsId));
|
|
|
+ const selectedGoods = ref<GoodsQuote>(getGoods(props.selectedRow.goodsid));
|
|
|
|
|
|
const { visible, cancel } = _closeModal(context);
|
|
|
- const { rules, formData, accountList, allPositionList } = handleForm(selectedGoods.value);
|
|
|
+ const { rules, formData, accountList, allPositionList, getPositionList } = handleForm(selectedGoods.value);
|
|
|
const formRef = ref();
|
|
|
const loading = ref<boolean>(false);
|
|
|
|
|
|
@@ -111,10 +113,10 @@ export default defineComponent({
|
|
|
selectedRowKeys.value = keys;
|
|
|
// 选中的单据数据
|
|
|
const { enableqty, positionaverageprice } = positionList.value[keys[0]];
|
|
|
+ // 更新价格和数量
|
|
|
formData.OrderPrice = positionaverageprice;
|
|
|
formData.OrderQty = enableqty;
|
|
|
-
|
|
|
- // 限价
|
|
|
+ // 指定价格类型显示为限价
|
|
|
selectedPriceType.value = 3;
|
|
|
};
|
|
|
|
|
|
@@ -224,6 +226,15 @@ export default defineComponent({
|
|
|
let successMsg = '成功';
|
|
|
let failMsg = '失败';
|
|
|
|
|
|
+ const { saleuserid, spotcontractid, bizsubjectid } = props.selectedRow;
|
|
|
+ // 判断是否套保交易
|
|
|
+ if (isHedging) {
|
|
|
+ formData.HedgeFlag = 4;
|
|
|
+ formData.SaleUserID = saleuserid;
|
|
|
+ formData.SpotContractID = Number(spotcontractid);
|
|
|
+ formData.BizSubjectID = bizsubjectid;
|
|
|
+ }
|
|
|
+
|
|
|
// 按钮提交类型
|
|
|
switch (submitType) {
|
|
|
case 'buy': {
|
|
|
@@ -257,7 +268,7 @@ export default defineComponent({
|
|
|
|
|
|
// 判断平仓数量
|
|
|
if (formData.OrderQty > curpositionqty) {
|
|
|
- message.error('交易数量不能大于可用持仓数量');
|
|
|
+ message.error('交易数量不能大于持仓可用数量');
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -291,10 +302,12 @@ export default defineComponent({
|
|
|
rules,
|
|
|
formRef,
|
|
|
formData,
|
|
|
+ isHedging,
|
|
|
goodsList,
|
|
|
buyPrice,
|
|
|
sellPrice,
|
|
|
selectedGoods,
|
|
|
+ getPositionList,
|
|
|
goodsChange,
|
|
|
selectedRowKeys,
|
|
|
priceTypeList,
|