|
|
@@ -9,17 +9,17 @@
|
|
|
<span class="white">{{ selectedRow.contractno }}</span>
|
|
|
</a-form-item>
|
|
|
<a-form-item label="账号">
|
|
|
- <a-select class="inlineFormSelect" placeholder="请选择" v-model:value="formData.AccountID" @change="tradeAccountChange">
|
|
|
+ <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>
|
|
|
</a-select>
|
|
|
</a-form-item>
|
|
|
- <a-form-item label="合约">
|
|
|
- <a-select class="inlineFormSelect" placeholder="请选择" :filterOption="filterOption" v-model:value="formData.GoodsID" @change="goodsChange" show-search>
|
|
|
+ <a-form-item label="合约" name="GoodsID">
|
|
|
+ <a-select class="inlineFormSelect" placeholder="请选择合约" :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="价格类型">
|
|
|
- <a-select class="inlineFormSelect" placeholder="请选择" v-model:value="selectedPriceType" @change="priceTypeChange">
|
|
|
+ <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>
|
|
|
</a-select>
|
|
|
</a-form-item>
|
|
|
@@ -31,7 +31,7 @@
|
|
|
<PlusOutlined /> -->
|
|
|
</template>
|
|
|
<template v-else>
|
|
|
- <a-input-number class="commonInput" :value="selectedGoods.last" style="width:100%" disabled />
|
|
|
+ <a-input-number class="commonInput" :value="selectedGoods?.last ?? 0" style="width:100%" disabled />
|
|
|
</template>
|
|
|
</a-form-item>
|
|
|
<a-form-item class="inputIconBox" label="交易数量" name="OrderQty">
|
|
|
@@ -86,6 +86,13 @@ import { Ermcp3SellBuyContract } from '@/services/go/ermcp/purchase/interface';
|
|
|
import { getGoodsQuoteList } from '@/services/bus/goods';
|
|
|
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;
|
|
|
+// }
|
|
|
|
|
|
export default defineComponent({
|
|
|
emits: ['cancel', 'update'],
|
|
|
@@ -93,30 +100,52 @@ export default defineComponent({
|
|
|
components: { Des, Drawer, PlusOutlined, MinusOutlined },
|
|
|
props: {
|
|
|
selectedRow: {
|
|
|
- type: Object as PropType<GoodsQuote & QueryErmcpTradePositionRsp & Ermcp3SellBuyContract>,
|
|
|
+ type: Object as PropType<GoodsQuote & QueryErmcpTradePositionRsp & Ermcp3SellBuyContract & ErmcpRealExposureModel>,
|
|
|
default: () => ({}),
|
|
|
},
|
|
|
},
|
|
|
setup(props, context) {
|
|
|
const { visible, cancel } = _closeModal(context);
|
|
|
- // 是否套保交易 (根据参数 spotcontractid 来判断)
|
|
|
- const isHedging = Boolean(props.selectedRow.spotcontractid);
|
|
|
- // 如果是套保交易,只显示该合约所在的商品组下的合约
|
|
|
- const goodsList = getGoodsQuoteList().filter((item) => isHedging ? item.goodsgroupid === props.selectedRow.goodsgroupid : true);
|
|
|
- const getGoods = (id: number) => goodsList.find((item) => item.goodsid === id)!;
|
|
|
+ const { goodsid, spotcontractid, goodsgroupid, MiddleGoodsID } = props.selectedRow;
|
|
|
+ const { rules, formData } = handleForm();
|
|
|
+ const formRef = ref();
|
|
|
+ const loading = ref<boolean>(false);
|
|
|
+
|
|
|
+ // 合约列表
|
|
|
+ const goodsList = ref(getGoodsQuoteList());
|
|
|
// 当前选中的商品合约
|
|
|
- const selectedGoods = ref<GoodsQuote>(getGoods(props.selectedRow.goodsid));
|
|
|
+ const selectedGoods = ref<GoodsQuote>();
|
|
|
+ // 是否套保交易 (根据参数 spotcontractid 来判断)
|
|
|
+ const isHedging = Boolean(spotcontractid);
|
|
|
+ // 是否实时敞口 (根据参数 MiddleGoodsID 来判断)
|
|
|
+ const isExposure = Boolean(MiddleGoodsID);
|
|
|
|
|
|
- if (!selectedGoods.value) {
|
|
|
- message.error('合约不存在,不能交易!');
|
|
|
- cancel();
|
|
|
+ // 套保交易
|
|
|
+ if (isHedging) {
|
|
|
+ goodsList.value = goodsList.value.filter((e) => e.goodsgroupid === goodsgroupid);
|
|
|
}
|
|
|
|
|
|
- const { futuresAccountList, tradePositionList, tradeAccount, tradeAccountChange } = useTradeAccount();
|
|
|
- const { rules, formData } = handleForm(selectedGoods.value);
|
|
|
- const formRef = ref();
|
|
|
- const loading = ref<boolean>(false);
|
|
|
+ // 实时敞口
|
|
|
+ if (isExposure) {
|
|
|
+ queryExposureGoods({ middlegoodsid: MiddleGoodsID }).then((res) => {
|
|
|
+ const ids = res.map((e) => e.goodsid);
|
|
|
+ goodsList.value = goodsList.value.filter((e) => ids.includes(e.goodsid));
|
|
|
+ }).catch(() => {
|
|
|
+ goodsList.value = [];
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ const { futuresAccountList, tradePositionList, tradeAccount, tradeAccountChange } = useTradeAccount();
|
|
|
// 表格选中的 rowKey 数据 :rowKey="(record,index)=>index"
|
|
|
const selectedRowKeys = ref<number[]>([]);
|
|
|
// 当前选择的持仓单据
|
|
|
@@ -145,7 +174,6 @@ export default defineComponent({
|
|
|
onSelectChange([0], result);
|
|
|
return result;
|
|
|
}
|
|
|
- return [];
|
|
|
} else {
|
|
|
// 过滤出当前商品的持仓单据
|
|
|
const result = tradePositionList.filter((item) => item.goodsid === goodsid);
|
|
|
@@ -191,40 +219,43 @@ export default defineComponent({
|
|
|
const sellPrice = computed(() => getPrice(BuyOrSell.sell));
|
|
|
// 根据买卖方向返回价格
|
|
|
function getPrice(direction: BuyOrSell): number {
|
|
|
- const { last, bid, ask, decimalplace, quoteminunit } = selectedGoods.value;
|
|
|
- switch (selectedPriceType.value) {
|
|
|
- // 最新价
|
|
|
- case 0: {
|
|
|
- return last;
|
|
|
- }
|
|
|
- // 市价
|
|
|
- case 1: {
|
|
|
- return direction === BuyOrSell.buy ? ask : bid;
|
|
|
- }
|
|
|
- // 对手价
|
|
|
- case 2: {
|
|
|
- return direction === BuyOrSell.buy ? ask : bid;
|
|
|
- }
|
|
|
- // 限价
|
|
|
- case 3: {
|
|
|
- return formData.OrderPrice;
|
|
|
- }
|
|
|
- // 超价
|
|
|
- case 4: {
|
|
|
- if (ask && bid) {
|
|
|
- // 系统参数
|
|
|
- const paramValue = APP.get('systemParams').find((el: Systemparam) => el.paramcode === '148')?.paramvalue ?? '0';
|
|
|
- // 点数
|
|
|
- const point = decimalplace > 0 ? -decimalplace * quoteminunit * Number(paramValue) : 1;
|
|
|
- const num = Math.pow(10, point);
|
|
|
- return direction === BuyOrSell.buy ? ask + num : bid - num;
|
|
|
+ if (selectedGoods.value) {
|
|
|
+ const { last, bid, ask, decimalplace, quoteminunit } = selectedGoods.value;
|
|
|
+ switch (selectedPriceType.value) {
|
|
|
+ // 最新价
|
|
|
+ case 0: {
|
|
|
+ return last;
|
|
|
+ }
|
|
|
+ // 市价
|
|
|
+ case 1: {
|
|
|
+ return direction === BuyOrSell.buy ? ask : bid;
|
|
|
+ }
|
|
|
+ // 对手价
|
|
|
+ case 2: {
|
|
|
+ return direction === BuyOrSell.buy ? ask : bid;
|
|
|
+ }
|
|
|
+ // 限价
|
|
|
+ case 3: {
|
|
|
+ return formData.OrderPrice;
|
|
|
+ }
|
|
|
+ // 超价
|
|
|
+ case 4: {
|
|
|
+ if (ask && bid) {
|
|
|
+ // 系统参数
|
|
|
+ const paramValue = APP.get('systemParams').find((el: Systemparam) => el.paramcode === '148')?.paramvalue ?? '0';
|
|
|
+ // 点数
|
|
|
+ const point = decimalplace > 0 ? -decimalplace * quoteminunit * Number(paramValue) : 1;
|
|
|
+ const num = Math.pow(10, point);
|
|
|
+ return direction === BuyOrSell.buy ? ask + num : bid - num;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ default: {
|
|
|
+ return 0;
|
|
|
}
|
|
|
- return 0;
|
|
|
- }
|
|
|
- default: {
|
|
|
- return 0;
|
|
|
}
|
|
|
}
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
// 搜索商品合约
|
|
|
@@ -234,11 +265,13 @@ export default defineComponent({
|
|
|
|
|
|
// 选择商品合约
|
|
|
function goodsChange(id: number) {
|
|
|
+ const item = goodsList.value.find((e) => e.goodsid === id)!;
|
|
|
formData.OrderPrice = 0;
|
|
|
formData.OrderQty = 1;
|
|
|
+ formData.MarketID = item.marketid;
|
|
|
selectedRowKeys.value = [];
|
|
|
selectedPosition.value = undefined;
|
|
|
- selectedGoods.value = getGoods(id);
|
|
|
+ selectedGoods.value = item;
|
|
|
}
|
|
|
|
|
|
// 选择价格类型
|
|
|
@@ -246,6 +279,7 @@ export default defineComponent({
|
|
|
// 除了市价,其它价格类型都属于限价
|
|
|
if (priceType === 1) {
|
|
|
formData.PriceMode = PriceType.market;
|
|
|
+ formRef.value.clearValidate('OrderPrice');
|
|
|
} else {
|
|
|
formData.PriceMode = PriceType.limit;
|
|
|
}
|
|
|
@@ -267,9 +301,9 @@ export default defineComponent({
|
|
|
let successMsg = '成功';
|
|
|
let failMsg = '失败';
|
|
|
|
|
|
- const { saleuserid, spotcontractid, bizsubjectid } = props.selectedRow;
|
|
|
// 判断是否套保交易
|
|
|
if (isHedging) {
|
|
|
+ const { saleuserid, spotcontractid, bizsubjectid } = props.selectedRow;
|
|
|
formData.HedgeFlag = 4;
|
|
|
formData.SaleUserID = saleuserid;
|
|
|
formData.SpotContractID = spotcontractid;
|
|
|
@@ -318,7 +352,7 @@ export default defineComponent({
|
|
|
|
|
|
// 判断是否母账号
|
|
|
if (tradeAccount.value?.ismain) {
|
|
|
- if (selectedGoods.value.outerdealmode === 3 && curtdpositionenabled > 0) {
|
|
|
+ if (selectedGoods.value?.outerdealmode === 3 && curtdpositionenabled > 0) {
|
|
|
formData.CloseTodayQty = curtdpositionenabled;
|
|
|
}
|
|
|
}
|
|
|
@@ -332,6 +366,7 @@ export default defineComponent({
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
return {
|
|
|
submit,
|
|
|
cancel,
|
|
|
@@ -361,9 +396,9 @@ export default defineComponent({
|
|
|
minusQty,
|
|
|
plusQty,
|
|
|
BuyOrSell,
|
|
|
- };
|
|
|
- },
|
|
|
-});
|
|
|
+ }
|
|
|
+ }
|
|
|
+})
|
|
|
</script>
|
|
|
|
|
|
<style lang="less">
|