|
|
@@ -1,13 +1,16 @@
|
|
|
<template>
|
|
|
<!-- 期货交易、套保交易 -->
|
|
|
- <Drawer class="top dialog-trade" :title="isHedging ? '套保交易' : '期货交易'" placement="right" :visible="visible" @cancel="cancel">
|
|
|
+ <Drawer class="top dialog-trade" :title="(isSpotContract | isHedgePlan) ? '套保交易' : '期货交易'" placement="right" :visible="visible" @cancel="cancel">
|
|
|
<div class="futures_trade">
|
|
|
<div class="futures_trade__left">
|
|
|
<div class="futures_trade__form">
|
|
|
<a-form class="inlineForm" ref="formRef" :model="formData" :rules="rules">
|
|
|
- <a-form-item label="合同编号" v-if="isHedging">
|
|
|
+ <a-form-item label="合同编号" v-if="isSpotContract">
|
|
|
<span class="white">{{ selectedRow.contractno }}</span>
|
|
|
</a-form-item>
|
|
|
+ <a-form-item label="计划编号" v-if="isHedgePlan">
|
|
|
+ <span class="white">{{ selectedRow.hedgeplanno }}</span>
|
|
|
+ </a-form-item>
|
|
|
<a-form-item label="账号">
|
|
|
<a-select class="inlineFormSelect" placeholder="请选择账号" v-model:value="formData.AccountID" @change="tradeAccountChange">
|
|
|
<a-select-option v-for="item in futuresAccountList" :value="item.accountid" :key="item.accountid">{{item.accountid}}/{{ item.accountname }}</a-select-option>
|
|
|
@@ -42,13 +45,13 @@
|
|
|
</a-form>
|
|
|
</div>
|
|
|
<div class="futures_trade__submit">
|
|
|
- <!--如果是采购合同隐藏按钮-->
|
|
|
- <a-button class="buy" :loading="loading" @click="submit('buy')" v-if="!isHedging || selectedRow.contracttype === -1">
|
|
|
+ <!--现货销售合同、计划采购合同 显示按钮-->
|
|
|
+ <a-button class="buy" :loading="loading" @click="submit('buy')" v-if="(!isSpotContract && !isHedgePlan) || (isSpotContract && selectedRow.contracttype === -1) || (isHedgePlan && selectedRow.contracttype === 1)">
|
|
|
<span>{{buyPrice}}</span>
|
|
|
<span>买入</span>
|
|
|
</a-button>
|
|
|
- <!--如果是销售合同隐藏按钮-->
|
|
|
- <a-button class="sell" :loading="loading" @click="submit('sell')" v-if="!isHedging || selectedRow.contracttype === 1">
|
|
|
+ <!--现货采购合同、计划销售合同 显示按钮-->
|
|
|
+ <a-button class="sell" :loading="loading" @click="submit('sell')" v-if="(!isSpotContract && !isHedgePlan) || (isSpotContract && selectedRow.contracttype === 1) || (isHedgePlan && selectedRow.contracttype === -1)">
|
|
|
<span>{{sellPrice}}</span>
|
|
|
<span>卖出</span>
|
|
|
</a-button>
|
|
|
@@ -88,11 +91,8 @@ import { useTradeAccount } from '@/hooks/account';
|
|
|
import { message } from 'ant-design-vue';
|
|
|
import { ErmcpRealExposureModel } from '@/services/go/ermcp/exposure/interface';
|
|
|
import { queryExposureGoods } from '@/services/go/ermcp/exposure'
|
|
|
-
|
|
|
-// 类型判断
|
|
|
-// function interfaceOf<T>(object: T, key: keyof T): object is T {
|
|
|
-// return key in object;
|
|
|
-// }
|
|
|
+import { Ermcp3HedgePlan } from '@/services/go/ermcp/plan/interface';
|
|
|
+import { GetDeliveryGoodsDetail } from "@/services/go/ermcp/goodsInfo";
|
|
|
|
|
|
export default defineComponent({
|
|
|
emits: ['cancel', 'update'],
|
|
|
@@ -100,13 +100,13 @@ export default defineComponent({
|
|
|
components: { Des, Drawer, PlusOutlined, MinusOutlined },
|
|
|
props: {
|
|
|
selectedRow: {
|
|
|
- type: Object as PropType<GoodsQuote & QueryErmcpTradePositionRsp & Ermcp3SellBuyContract & ErmcpRealExposureModel>,
|
|
|
+ type: Object as PropType<GoodsQuote & QueryErmcpTradePositionRsp & Ermcp3SellBuyContract & Ermcp3HedgePlan & ErmcpRealExposureModel>,
|
|
|
default: () => ({}),
|
|
|
},
|
|
|
},
|
|
|
setup(props, context) {
|
|
|
const { visible, cancel } = _closeModal(context);
|
|
|
- const { goodsid, spotcontractid, goodsgroupid, MiddleGoodsID } = props.selectedRow;
|
|
|
+ const { goodsid, spotcontractid, hedgeplanid, deliverygoodsid, goodsgroupid, MiddleGoodsID } = props.selectedRow;
|
|
|
const { rules, formData } = handleForm();
|
|
|
const formRef = ref();
|
|
|
const loading = ref<boolean>(false);
|
|
|
@@ -115,13 +115,15 @@ export default defineComponent({
|
|
|
const goodsList = ref(getGoodsQuoteList());
|
|
|
// 当前选中的商品合约
|
|
|
const selectedGoods = ref<GoodsQuote>();
|
|
|
- // 是否套保交易 (根据参数 spotcontractid 来判断)
|
|
|
- const isHedging = Boolean(spotcontractid);
|
|
|
+ // 是否现货合同 (根据参数 spotcontractid 来判断)
|
|
|
+ const isSpotContract = Boolean(spotcontractid);
|
|
|
+ // 是否购销计划 (根据参数 hedgeplanid 来判断)
|
|
|
+ const isHedgePlan = Boolean(hedgeplanid);
|
|
|
// 是否实时敞口 (根据参数 MiddleGoodsID 来判断)
|
|
|
const isExposure = Boolean(MiddleGoodsID);
|
|
|
|
|
|
- // 套保交易
|
|
|
- if (isHedging) {
|
|
|
+ // 现货合同
|
|
|
+ if (isSpotContract) {
|
|
|
goodsList.value = goodsList.value.filter((e) => e.goodsgroupid === goodsgroupid);
|
|
|
}
|
|
|
|
|
|
@@ -139,14 +141,40 @@ export default defineComponent({
|
|
|
goodsList.value = [];
|
|
|
})
|
|
|
} else {
|
|
|
- const item = goodsList.value.find((e) => e.goodsid === goodsid);
|
|
|
- if (!item) {
|
|
|
- message.error('合约不存在,不能交易!');
|
|
|
- cancel();
|
|
|
+ // 购销计划
|
|
|
+ if (isHedgePlan) {
|
|
|
+ GetDeliveryGoodsDetail(deliverygoodsid).then((res) => {
|
|
|
+ const ids: number[] = [];
|
|
|
+ const deliveryGoodsList = res.filter((e) => e.isvalid);
|
|
|
+
|
|
|
+ deliveryGoodsList.forEach((dg) => {
|
|
|
+ dg.wdlst.forEach((wd) => {
|
|
|
+ wd.mglst.forEach((mg) => {
|
|
|
+ mg.GPLST.forEach((gp) => {
|
|
|
+ ids.push(...gp.GDLST.map((e) => e.goodsid));
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ goodsList.value = goodsList.value.filter((e) => ids.includes(e.goodsid));
|
|
|
+ if (goodsList.value.length) {
|
|
|
+ formData.GoodsID = goodsList.value[0].goodsid;
|
|
|
+ goodsChange(formData.GoodsID); // 默认选中第一个
|
|
|
+ }
|
|
|
+ }).catch(() => {
|
|
|
+ goodsList.value = [];
|
|
|
+ })
|
|
|
} else {
|
|
|
- selectedGoods.value = item;
|
|
|
- formData.GoodsID = item.goodsid;
|
|
|
- formData.MarketID = item.marketid;
|
|
|
+ const item = goodsList.value.find((e) => e.goodsid === goodsid);
|
|
|
+ if (!item) {
|
|
|
+ message.error('合约不存在,不能交易!');
|
|
|
+ //cancel();
|
|
|
+ } else {
|
|
|
+ selectedGoods.value = item;
|
|
|
+ formData.GoodsID = item.goodsid;
|
|
|
+ formData.MarketID = item.marketid;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -169,8 +197,8 @@ export default defineComponent({
|
|
|
const positionList = computed(() => {
|
|
|
if (selectedGoods.value) {
|
|
|
const { goodscode, goodsid } = selectedGoods.value;
|
|
|
- // 判断是否套保交易
|
|
|
- if (isHedging) {
|
|
|
+ // 判断是否现货合同交易
|
|
|
+ if (isSpotContract) {
|
|
|
// 买卖方向,根据合同类型判断
|
|
|
const buyorsell = props.selectedRow.contracttype === 1 ? BuyOrSell.buy : BuyOrSell.sell;
|
|
|
const index = tradePositionList.findIndex((item) => item.goodscode === goodscode && item.goodsid === goodsid && item.buyorsell === buyorsell);
|
|
|
@@ -306,8 +334,8 @@ export default defineComponent({
|
|
|
let successMsg = '成功';
|
|
|
let failMsg = '失败';
|
|
|
|
|
|
- // 判断是否套保交易
|
|
|
- if (isHedging) {
|
|
|
+ // 判断是否现货合同交易
|
|
|
+ if (isSpotContract) {
|
|
|
const { saleuserid, spotcontractid, bizsubjectid } = props.selectedRow;
|
|
|
formData.HedgeFlag = 4;
|
|
|
formData.SaleUserID = saleuserid;
|
|
|
@@ -315,6 +343,13 @@ export default defineComponent({
|
|
|
formData.BizSubjectID = bizsubjectid;
|
|
|
}
|
|
|
|
|
|
+ // 判断是否购销计划交易,任务 #3645
|
|
|
+ if (isHedgePlan) {
|
|
|
+ const { hedgeplanid } = props.selectedRow;
|
|
|
+ formData.HedgeFlag = 9;
|
|
|
+ formData.SpotContractID = hedgeplanid;
|
|
|
+ }
|
|
|
+
|
|
|
// 按钮提交类型
|
|
|
switch (submitType) {
|
|
|
case 'buy': {
|
|
|
@@ -382,7 +417,8 @@ export default defineComponent({
|
|
|
rules,
|
|
|
formRef,
|
|
|
formData,
|
|
|
- isHedging,
|
|
|
+ isSpotContract,
|
|
|
+ isHedgePlan,
|
|
|
goodsList,
|
|
|
buyPrice,
|
|
|
sellPrice,
|