|
|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<!--仓单贸易 贸易圈挂牌 摘牌-->
|
|
|
- <Drawer :title="'摘牌'"
|
|
|
+ <Drawer :title="isBargin() ? '议价摘牌' : '摘牌'"
|
|
|
:placement="'right'"
|
|
|
:visible="visible"
|
|
|
@cancel="cancel"
|
|
|
@@ -34,22 +34,28 @@
|
|
|
</a-col>
|
|
|
<a-col :span="24">
|
|
|
<a-form-item label="挂牌数量">
|
|
|
- <span class="white ml8">{{selectedRow.orderqty}}</span>
|
|
|
+ <span class="white ml8">{{selectedRow.orderqty}}{{selectedRow.enumdicname}}</span>
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
|
</a-row>
|
|
|
- <a-col :span="24">
|
|
|
+ <a-col :span="24"
|
|
|
+ v-if="isBargin()">
|
|
|
<a-form-item label="摘牌价格"
|
|
|
- name="OrderQty">
|
|
|
+ name="price">
|
|
|
<a-input-number class="commonInput"
|
|
|
style="width: 260px"
|
|
|
:min="0"
|
|
|
- v-model:value="formState.OrderQty" />
|
|
|
- <span class="input-enumdicname">{{selectedRow.enumdicname}}</span>
|
|
|
+ v-model:value="formState.price" />
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
|
-
|
|
|
- <a-col :span="24">
|
|
|
+ <a-col :span="24"
|
|
|
+ v-else>
|
|
|
+ <a-form-item label="摘牌价格">
|
|
|
+ <span class="white ml8">{{selectedRow.fixedprice}}</span>
|
|
|
+ </a-form-item>
|
|
|
+ </a-col>
|
|
|
+ <a-col :span="24"
|
|
|
+ v-if="!isBuy()">
|
|
|
<a-form-item label="现货仓单"
|
|
|
name="LadingBillId">
|
|
|
<a-select class="inlineFormSelect"
|
|
|
@@ -63,7 +69,8 @@
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
|
|
|
|
- <a-row :gutter="24">
|
|
|
+ <a-row :gutter="24"
|
|
|
+ v-if="isCanpart()">
|
|
|
<a-col :span="24">
|
|
|
<a-form-item label="摘牌数量"
|
|
|
class="relative"
|
|
|
@@ -71,14 +78,15 @@
|
|
|
<a-input-number class="dialogInput yellowInput"
|
|
|
style="width: 260px"
|
|
|
:min="0"
|
|
|
- :max="99999"
|
|
|
+ :max="getMaxNum()"
|
|
|
v-model:value="formState.num" />
|
|
|
<span class="input-enumdicname-absolute">{{selectedRow.enumdicname}}</span>
|
|
|
<div class="labelTip">({{selectedRow.minivalue}}{{selectedRow.enumdicname}}起)</div>
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
|
</a-row>
|
|
|
- <a-row :gutter="24">
|
|
|
+ <a-row :gutter="24"
|
|
|
+ v-if="isCanpart()">
|
|
|
<a-col :span="24"
|
|
|
class="mt-20">
|
|
|
<a-form-item>
|
|
|
@@ -89,12 +97,18 @@
|
|
|
style="width: 260px" />
|
|
|
<div class="unit">
|
|
|
<span>0</span>
|
|
|
- <span>99999{{selectedRow.enumdicname}}</span>
|
|
|
+ <span>{{getMaxNum()}}{{selectedRow.enumdicname}}</span>
|
|
|
</div>
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
|
<a-col :span="12"> </a-col>
|
|
|
</a-row>
|
|
|
+ <a-col :span="24"
|
|
|
+ v-if="!isCanpart()">
|
|
|
+ <a-form-item label="摘牌数量">
|
|
|
+ <span class="white ml8">{{selectedRow.orderqty}}{{selectedRow.enumdicname}}</span>
|
|
|
+ </a-form-item>
|
|
|
+ </a-col>
|
|
|
<a-row :gutter="24">
|
|
|
<a-col :span="24"
|
|
|
class="mt-20">
|
|
|
@@ -143,8 +157,8 @@ import Drawer from '@/common/components/drawer/index.vue';
|
|
|
import { PlusOutlined, MinusOutlined } from '@ant-design/icons-vue';
|
|
|
import { hdWROrder } from '@/services/proto/warehousetrade';
|
|
|
import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
|
|
|
-import { DGFactoryItems, WRGoodsInfo } from '@/services/proto/warehousetrade/interface';
|
|
|
-import { getAccountTypeList, getUserId } from '@/services/bus/account';
|
|
|
+import { DGFactoryItems, HdWRDealOrderReq, WrBargainApplyReq, WRGoodsInfo } from '@/services/proto/warehousetrade/interface';
|
|
|
+import { getAccountTypeList, getSelectedAccountId, getUserId } from '@/services/bus/account';
|
|
|
import { v4 as uuidv4 } from 'uuid';
|
|
|
import moment, { Moment } from 'moment';
|
|
|
import { getMarketRunByTradeMode } from '@/services/bus/market';
|
|
|
@@ -158,10 +172,14 @@ import { BuyOrSell } from '@/common/constants/enumCommon';
|
|
|
import { getCanUseMoney } from '@/services/bus/account';
|
|
|
import { TempWrOrderQuoteDetail } from '@/views/market/spot_trade/components/post_buying/interface';
|
|
|
import { handleForm, handleSpotWarrant } from './setup';
|
|
|
+import { getRules } from '@/services/bus/rules';
|
|
|
+import { ListingForm } from './interface';
|
|
|
+import { HdWRDealOrder, wrBargainApply } from '@/services/proto/warehousetrade';
|
|
|
+import Long from 'long';
|
|
|
|
|
|
export default defineComponent({
|
|
|
emits: ['cancel', 'update'],
|
|
|
- name: 'warehouse_receipt_trade_blocs_delisting',
|
|
|
+ name: 'warehouse_receipt_trade_blocs_delisting_tab',
|
|
|
components: { Des, Drawer, PlusOutlined, MinusOutlined },
|
|
|
props: {
|
|
|
selectedRow: {
|
|
|
@@ -182,88 +200,116 @@ export default defineComponent({
|
|
|
const { rules, formState, formRef } = handleForm();
|
|
|
const loading = ref<boolean>(false);
|
|
|
const accountList = getAccountTypeList([2]);
|
|
|
+ // 现货仓单
|
|
|
+ const { wrHoldList, allWrHoldList } = handleSpotWarrant(props.buyOrSell, props.selectedRow, loading);
|
|
|
if (accountList.length) {
|
|
|
formState.accountid = accountList[0].accountid;
|
|
|
}
|
|
|
+
|
|
|
function getSelectedAccount() {
|
|
|
- return accountList.find((e) => e.accountid === formState.accountid);
|
|
|
+ return accountList.find((e) => e.accountid === formState.accountid)!;
|
|
|
+ }
|
|
|
+ // 摘牌金额
|
|
|
+ function getMoney() {
|
|
|
+ const price = isBargin() ? formState.price : props.selectedRow.fixedprice;
|
|
|
+ if (price) {
|
|
|
+ return (price * formState.num).toFixed(2);
|
|
|
+ } else {
|
|
|
+ return '--';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function getMaxNum() {
|
|
|
+ const qty = props.selectedRow.orderqty;
|
|
|
+ let result = 0;
|
|
|
+ if (isBuy()) {
|
|
|
+ // 交易规则
|
|
|
+ const rules = getRules();
|
|
|
+ const { buymarginvalue } = rules[0];
|
|
|
+ const canUseMoney = Number(getCanUseMoney(getSelectedAccount()));
|
|
|
+ if (canUseMoney && !isNaN(canUseMoney)) {
|
|
|
+ const num = +(canUseMoney / buymarginvalue).toFixed(0);
|
|
|
+ // 买 最大可摘数量=min{挂牌数量,可用资金/(履约保证金比例)}
|
|
|
+ result = Math.min(qty, num);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 卖出 最大可摘数量=min{挂牌数量,仓单可用数量}
|
|
|
+ const id = formState.LadingBillId;
|
|
|
+ if (id) {
|
|
|
+ const item = allWrHoldList.value.find((el) => el.ladingbillid === id)!;
|
|
|
+ result = Math.min(qty, item.enableqty);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
}
|
|
|
- function getMoney() {}
|
|
|
function isBuy() {
|
|
|
return props.buyOrSell === BuyOrSell.buy;
|
|
|
}
|
|
|
+ // 是否部分摘牌
|
|
|
+ function isCanpart() {
|
|
|
+ return props.selectedRow.canpart === 1;
|
|
|
+ }
|
|
|
// 是否议价 摘牌
|
|
|
function isBargin() {
|
|
|
return props.componentId === 'warehouse_receipt_trade_blocs_bargain_delisting';
|
|
|
}
|
|
|
- // 现货仓单
|
|
|
- const { wrHoldList } = handleSpotWarrant(props.buyOrSell, props.selectedRow, loading);
|
|
|
+ if (isBargin()) {
|
|
|
+ formState.price = props.selectedRow.fixedprice;
|
|
|
+ }
|
|
|
+
|
|
|
function submit() {
|
|
|
- // const marketInfo = getMarketRunByTradeMode(17);
|
|
|
- // if (marketInfo) {
|
|
|
- // validateAction<FormParam>(formRef, formState).then((res) => {
|
|
|
- // // 现在增加一种挂牌求购的情况
|
|
|
- // // 这种求购模式会生成一种仓单贸易商品
|
|
|
- // const wrGoodsInfo: WRGoodsInfo = {
|
|
|
- // GoodsID: props.selectedRow.goodsid, // uint32 配置商品ID
|
|
|
- // GoodsCode: props.selectedRow.goodscode, // string 配置商品代码
|
|
|
- // PriceFactor: 1, // double 商品价格系数
|
|
|
- // PriceMove: 0, // double 商品升贴水值
|
|
|
- // WeightRatio: 1, // double 商品重量系数
|
|
|
- // };
|
|
|
- // const param = {
|
|
|
- // AccountID: res.accountid, // 默认内部资金账号第一个
|
|
|
- // ClientSerialNo: uuidv4(), // 客户端流水号
|
|
|
- // // OperateSrc: 2,
|
|
|
- // ClientType: 4,
|
|
|
- // // MarketID: marketInfo.marketid,
|
|
|
- // LadingBillId: 0, // 提单id(wrholdlb的LadingBillId字段),卖的时候填写 uint64
|
|
|
- // // LadingBillId: 'uint642081626946446000001', // 提单id(wrholdlb的LadingBillId字段),卖的时候填写 uint64
|
|
|
- // TradeDate: moment(marketInfo.tradedate).format('YYYYMMDD'), // 交易日 string
|
|
|
- // // SubNum: '0', // 提单子单号
|
|
|
- // SubNum: 0,
|
|
|
- // // WRFactorTypeId: '2121626946446000001', // 仓单要素ID(wrholdlb的WRFactorTypeId字段),卖的时候填写 uint64
|
|
|
- // WRFactorTypeId: props.selectedRow.wrfactortypeid ? props.selectedRow.wrfactortypeid : 0, // 仓单要素ID(wrholdlb的WRFactorTypeId字段),卖的时候填写 uint64
|
|
|
- // IsSpecified: 0, // 是否指定对手 0:不指定 1:指定 uint32
|
|
|
- // // MatchUserIDs: 0, // 仓单贸易对手资金账号ID集合(指定对手时填写) uint32
|
|
|
- // OrderQty: res.OrderQty, // 委托数量(可挂部分数据量) ======
|
|
|
- // DeliveryGoodsID: props.selectedRow.deliverygoodsid, // 交割商品商品ID // 有仓单求购
|
|
|
- // WRPriceType: isFloat() ? 2 : 1, // 价格方式 1:固定价 2:浮动价
|
|
|
- // FixedPrice: res.FixedPrice, // 固定价格
|
|
|
- // PriceFactor: 1, // 价格系数(浮动价时填写)
|
|
|
- // PriceMove: res.PriceMove, // 升贴水(浮动价时填写)
|
|
|
- // TimevalidType: 4, // 时间有效类型 1:当日有效 2:本周有效 3:指定时间有效 4:一直有效
|
|
|
- // // ValidTime: moment('2021-08-25 00:00:00').format('YYYY-MM-DD HH:mm:ss'), // 有效期限
|
|
|
- // ClientOrderTime: moment().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
- // FirstRatio: 0, // 首付比例
|
|
|
- // PerformanceTemplateID: 0, // 履约计划模板ID
|
|
|
- // UserID: getUserId(),
|
|
|
- // OperatorID: getUserId(), // 操作员账号ID
|
|
|
- // BuyOrSell: 0, // 买卖方向 0买1卖
|
|
|
- // PriceDisplayMode: 1, // 浮动价显示方式 1:合并显示 2:分开显示
|
|
|
- // CanBargain: 0, // 挂牌是否可议价0:不可1:可-摘牌是否议价
|
|
|
- // Attachment1: '', // 附件1
|
|
|
- // Attachment2: '', // 附件2
|
|
|
- // Remark: '', // 备注
|
|
|
- // ApplyID: 0, // 申请ID
|
|
|
- // WRTradeGoods: isFloat() ? [wrGoodsInfo] : [],
|
|
|
- // CanPart: 1, // 是否允许部份摘牌0:不允许;1:允许
|
|
|
- // WRStandardID: props.selectedRow.wrstandardid,
|
|
|
- // HasWr: isWR(), // 无仓单挂牌 是否有无仓单
|
|
|
- // DeliveryMonth: isWR() ? '' : moment(res.DeliveryMonth).format('YYYY-MM'),
|
|
|
- // FactoryItems: props.selectedRow.wrResult != undefined ? props.selectedRow.wrResult.flatMap((it) => {
|
|
|
- // return {
|
|
|
- // DGFactoryItemTypeID: it.dgfactoryitemtypeid, // uint64 要素项类型ID
|
|
|
- // DGFactoryItemID: it.dgfactoryitemid, // uint64 预约要素项类型值
|
|
|
- // ItemTypeMode: 1, // uint32 要素项类型模式
|
|
|
- // };
|
|
|
- // }): [], // DGFactoryItems 要素类型明细集合(没有仓单要素ID填写)
|
|
|
- // };
|
|
|
- // requestResultLoadingAndInfo(hdWROrder, param, loading, ['求购成功', '求购失败:']).then(() => {
|
|
|
- // cancel(true);
|
|
|
- // });
|
|
|
- // });
|
|
|
- // }
|
|
|
+ validateAction<ListingForm>(formRef, formState).then((res) => {
|
|
|
+ if (isBargin()) {
|
|
|
+ // 议价摘牌
|
|
|
+ const param: WrBargainApplyReq = {
|
|
|
+ WRTradeOrderID: Long.fromString(props.selectedRow.wrtradeorderid),
|
|
|
+ ApplyQty: 10,
|
|
|
+ UserID: String(getUserId()),
|
|
|
+ AccountID: getSelectedAccountId().toString(),
|
|
|
+ BuyOrSell: props.buyOrSell.toString(),
|
|
|
+ ApplyPrice: formState.price.toString(),
|
|
|
+ ApplyRemark: '',
|
|
|
+ };
|
|
|
+ requestResultLoadingAndInfo(wrBargainApply, param, loading, ['议价摘牌成功', '议价摘牌失败:']).then(() => {
|
|
|
+ cancel(true);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ // 首先确定 这是仓单贸易的有仓单挂摘牌 HasWr = 1
|
|
|
+ // 其次判断 摘牌 1。摘买 (需要通过自己的仓单进行摘买) 2。摘卖 (不需要通过仓单)
|
|
|
+ const param: HdWRDealOrderReq = {
|
|
|
+ UserID: getUserId(), // uint32 用户ID
|
|
|
+ AccountID: getSelectedAccountId(), // uint64 资金账号
|
|
|
+ RelatedWRTradeOrderID: props.selectedRow.wrtradeorderid, // uint64 关联委托单号(摘牌委托关联挂牌委托单ID)
|
|
|
+ WRTransferUserID: props.selectedRow.userid, // uint32 仓单受让用户
|
|
|
+ OrderQty: res.num as number, // uint64 委托数量
|
|
|
+ OrderSrc: 0, // uint32 委托来源
|
|
|
+ ClientSerialNo: uuidv4(), // string 客户端流水号
|
|
|
+ ClientOrderTime: moment(new Date()).format('YYYY-MM-DD HH:mm:ss'), // string 客户端委托时间
|
|
|
+ ClientType: 4, // uint32 终端类型
|
|
|
+ OperatorID: getUserId(), // uint64 操作员账号ID
|
|
|
+ BuyOrSell: 0, // uint32 买卖方向
|
|
|
+ ApplyID: 0, // uint64 申请ID
|
|
|
+ // LadingBillId: 0, // uint64 提单id(wrholdlb的LadingBillId字段),卖的时候填写
|
|
|
+ SubNum: 0, // uint64 提单子单号(wrholdlb的SubNum字段),卖的时候填写
|
|
|
+ WRFactorTypeId: Long.fromString(props.selectedRow.wrfactortypeid), // uint64 仓单要素ID(wrholdlb的WRFactorTypeId字段),卖的时候填写
|
|
|
+ TradeDate: moment().format('YYYYMMDD'), // string 交易日
|
|
|
+ DeliveryMonth: '', // string 交收月
|
|
|
+ HasWr: 1, // uint32 是否有仓单-0:没有仓单 1:有仓单
|
|
|
+ IsFinancing: 1, // uint32 是否融资购买(买摘牌时有效)-0:否 1:是
|
|
|
+ ProductDetailID: res.caseId, // uint64 金融机构产品组合ID(融资购买时有效)
|
|
|
+ };
|
|
|
+ // 摘买方向
|
|
|
+ if (isBuy()) {
|
|
|
+ param.BuyOrSell = 1;
|
|
|
+ param.LadingBillId = res.LadingBillId;
|
|
|
+ } else {
|
|
|
+ param.BuyOrSell = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ requestResultLoadingAndInfo(HdWRDealOrder, param, loading, ['摘牌成功', '摘牌失败:']).then(() => {
|
|
|
+ cancel(true);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
return {
|
|
|
submit,
|
|
|
@@ -279,6 +325,9 @@ export default defineComponent({
|
|
|
isBuy,
|
|
|
isBargin,
|
|
|
wrHoldList,
|
|
|
+ loading,
|
|
|
+ getMaxNum,
|
|
|
+ isCanpart,
|
|
|
};
|
|
|
},
|
|
|
});
|