|
|
@@ -3,10 +3,8 @@ import { EnumRouterName } from '@/common/constants/enumRouterName';
|
|
|
import { queryResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
|
|
|
import { TableKey } from '@/common/methods/table/interface';
|
|
|
import { getTableColumns, getTableEvent, queryTableList } from "@/common/setup/table";
|
|
|
-import { getCanUseMoney } from '@/services/bus/account';
|
|
|
-import { AccountListItem } from '@/services/dataCenter/interafce/account';
|
|
|
import { queryFaProductDetail, queryWrMarketTradeConfig } from '@/services/go/wrtrade';
|
|
|
-import { WrFAProductDetail, WrMarketTradeConfig, WrOrderQuoteDetail } from "@/services/go/wrtrade/interface";
|
|
|
+import { WrFAProductDetail, WrMarketTradeConfig } from "@/services/go/wrtrade/interface";
|
|
|
import { Ref, ref } from 'vue';
|
|
|
|
|
|
|
|
|
@@ -110,14 +108,6 @@ export function handleIs(enumName: EnumRouterName, buyOrSell: BuyOrSell) {
|
|
|
return { isWR, isBuy, isFloat }
|
|
|
}
|
|
|
|
|
|
-export function handleChildComponentMethod() {
|
|
|
- const childRef = ref<null | { queryTableAction: Function }>(null);
|
|
|
- function loadChildComponentData() {
|
|
|
- childRef.value?.queryTableAction();
|
|
|
- }
|
|
|
- return { childRef, loadChildComponentData }
|
|
|
-}
|
|
|
-
|
|
|
// 获取金额计算规则
|
|
|
const rules = ref<WrMarketTradeConfig[]>([])
|
|
|
export function handlePriceRule(loading: Ref<boolean>, marketid: number) {
|
|
|
@@ -148,7 +138,7 @@ export function getFinacingList(): WrFAProductDetail[] {
|
|
|
return list.value
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+// 商品实时价格
|
|
|
const goodsPrice = ref<string | number>('--')
|
|
|
export function setGoodsPrice(value: string | number) {
|
|
|
goodsPrice.value = value
|
|
|
@@ -156,170 +146,3 @@ export function setGoodsPrice(value: string | number) {
|
|
|
export function getGoodsPrice(): Ref<string | number> {
|
|
|
return goodsPrice
|
|
|
}
|
|
|
-
|
|
|
-/**
|
|
|
- * 我负责计算摘牌页面需要显示的值
|
|
|
- * 这里分四种情况
|
|
|
- * 若履约保证金为0,则不显示括号内容
|
|
|
- * type 1: 一口价 摘牌买入 摘牌最大数量 = min 挂牌数量,可用资金/(买方履约保证金比例*挂牌价格) 摘牌金额=挂牌价格*摘牌数量
|
|
|
- * type 2: 一口价 摘牌卖出 摘牌最大数量 = min(现货库存可用数量,挂牌数量),现货库存数量为所选仓单数量 && 履约保证金=卖方履约保证金比例*摘牌金额,履约保证金为0则括号内容不显示 摘牌金额=挂牌价格*摘牌数量
|
|
|
- * type 3: 浮动价 摘牌买入 摘牌最大数量 = min {可用资金/(买方履约保证金比例*估算总价),挂牌数量} && 履约保证金=履约保证金比例*估算总额,履约保证金为0则括号内容不显示 && 估算总额=估算总价*摘牌数量 && 估算总价=挂牌基差+期货合约价 && 期货合约取价顺序:现价->实时结算价->昨结算价
|
|
|
- * type 4:浮动价 摘牌卖出 摘牌最大数量 = min(现货库存可用数量,挂牌数量),现货库存数量为所选仓单数量 && 履约保证金=履约保证金比例*估算总额
|
|
|
- *
|
|
|
- * type 1: in => 输入 {
|
|
|
- * 挂牌价格, 可用资金, 摘牌数量, 市场交易参数配置, 挂牌数量
|
|
|
- * } out => {
|
|
|
- * 履约保证金, 摘牌金额, 摘牌最大数量
|
|
|
- * }
|
|
|
- *
|
|
|
- * type 2: in => 输入 {
|
|
|
- * 挂牌价格, 仓单数量, 摘牌数量, 市场交易参数配置, 挂牌数量
|
|
|
- * } out => {
|
|
|
- * 履约保证金, 摘牌金额, 摘牌最大数量
|
|
|
- * }
|
|
|
- *
|
|
|
- * type 3: in => 输入 {
|
|
|
- * 期货合约价 + 基差, 可用资金, 摘牌数量, 市场交易参数配置, 挂牌数量
|
|
|
- * } out => {
|
|
|
- * 履约保证金, 估算总额, 摘牌最大数量
|
|
|
- * }
|
|
|
- *
|
|
|
- * type 4: in => 输入 {
|
|
|
- * 期货合约价 + 基差, 仓单数量, 摘牌数量, 市场交易参数配置, 挂牌数量
|
|
|
- * } out => {
|
|
|
- * 履约保证金, 估算总额, 摘牌最大数量
|
|
|
- * }
|
|
|
- */
|
|
|
-export function ListedViewModel(enumType: EnumRouterName) {
|
|
|
-
|
|
|
- let marginPrice = 0 // 履约保证金
|
|
|
- let amount = 0 // 摘牌金额 或 估算总额
|
|
|
- let maxNum = 0 // 摘牌最大数量
|
|
|
-
|
|
|
- // 负责把输入的数据 转换成 ui需要显示的数据
|
|
|
- function getCalculate(param: WrParam) {
|
|
|
- const rule = rules.value;
|
|
|
- if (rule.length) {
|
|
|
- const obj = rule[0]
|
|
|
- switch (enumType) {
|
|
|
- case EnumRouterName.warehouse_receipt_trade_floating_price: // 浮动价 摘牌买入
|
|
|
- case EnumRouterName.warehouse_receipt_trade_price: // 一口价 摘牌买入
|
|
|
- if (param.availableFunds === undefined) { // 这里防止异常
|
|
|
- maxNum = 0
|
|
|
- } else {
|
|
|
- // 摘牌最大数量 = min 挂牌数量,可用资金/(买方履约保证金比例*挂牌价格)
|
|
|
- if (obj.buymarginalgorithm === 1) { // 买方保证金模式 1: 比率 2: 固定
|
|
|
- maxNum = Math.min(param.listedNum, param.availableFunds / obj.buymarginvalue * param.orderPrice)
|
|
|
- } else {
|
|
|
- maxNum = Math.min(param.listedNum, param.availableFunds / (obj.buymarginvalue + param.orderPrice))
|
|
|
- }
|
|
|
- }
|
|
|
- // 摘牌金额 = 挂牌价格 * 摘牌数量
|
|
|
- amount = param.orderPrice * param.deListNum
|
|
|
- // 履约保证金=买方履约保证金比例*摘牌金额,履约保证金为0则括号内容不显示
|
|
|
- if (obj.buymarginalgorithm === 1) { //卖方保证金方式 - 1:比率 2:固定
|
|
|
- marginPrice = obj.buymarginvalue * amount
|
|
|
- } else {
|
|
|
- marginPrice = obj.buymarginvalue + amount
|
|
|
- }
|
|
|
- break
|
|
|
- case EnumRouterName.warehouse_pre_sale_floating_price: // 浮动价 摘牌卖出
|
|
|
- case EnumRouterName.warehouse_pre_sale_price: // 一口价 摘牌卖出
|
|
|
- if (param.warehouseNum === undefined) { // 这里防止异常
|
|
|
- maxNum = 0
|
|
|
- } else {
|
|
|
- // 摘牌最大数量 = min(现货库存可用数量,挂牌数量),现货库存数量为所选仓单数量
|
|
|
- maxNum = Math.min(param.listedNum, param.warehouseNum)
|
|
|
- }
|
|
|
- // 摘牌金额 = 挂牌价格 * 摘牌数量
|
|
|
- amount = param.orderPrice * param.deListNum
|
|
|
- // 履约保证金=卖方履约保证金比例*摘牌金额,履约保证金为0则括号内容不显示
|
|
|
- if (obj.sellmarginalgorithm === 1) { //卖方保证金方式 - 1:比率 2:固定
|
|
|
- marginPrice = obj.sellmarginvalue * amount
|
|
|
- } else {
|
|
|
- marginPrice = obj.sellmarginvalue + amount
|
|
|
- }
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- const uiParam: UiParam = {
|
|
|
- marginPrice: marginPrice,
|
|
|
- amount: amount,
|
|
|
- maxNum: maxNum
|
|
|
- }
|
|
|
-
|
|
|
- return { getCalculate, uiParam }
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * 需要传入的数据集合
|
|
|
- */
|
|
|
-export interface WrParam {
|
|
|
- orderPrice: number // 挂牌价格 (浮动价是期货合约价 + 基差) 也传这个 (会变)
|
|
|
- availableFunds?: number //可用资金(当前账号的可用) 摘牌买入传可用 (可能会变)
|
|
|
- warehouseNum?: number // 仓单数量(如果当前是用自己仓单卖商品给其他人 则需要传自己仓单商品的总数) 摘牌卖出传选择的仓单数量 (可能会变)
|
|
|
- deListNum: number // 摘牌数量 (当前选择数量) (会变)
|
|
|
- listedNum: number // 挂牌数量 (当前单据的挂牌数量) (不变)
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * 需要给ui的数据集合
|
|
|
- */
|
|
|
-export interface UiParam {
|
|
|
- marginPrice: number // 履约保证金
|
|
|
- amount: number // 摘牌金额 或 估算总额
|
|
|
- maxNum: number // 摘牌最大数量
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-// 获取摘牌最大可摘量
|
|
|
-function getMaxNum(enumName: EnumRouterName, buyOrSell: BuyOrSell, qty: number) {
|
|
|
- switch (enumName) {
|
|
|
- case EnumRouterName.warehouse_receipt_trade_price:
|
|
|
-
|
|
|
- break
|
|
|
- case EnumRouterName.warehouse_receipt_trade_floating_price:
|
|
|
-
|
|
|
- break
|
|
|
- case EnumRouterName.warehouse_pre_sale_price:
|
|
|
-
|
|
|
- break
|
|
|
- case EnumRouterName.warehouse_pre_sale_floating_price:
|
|
|
-
|
|
|
- break
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-export function handleNumAndMoney(enumName: EnumRouterName, buyOrSell: BuyOrSell, selectedRow: WrOrderQuoteDetail, fn: Function) {
|
|
|
- // 获取摘牌最大可摘量
|
|
|
- function getMaxNum(qty: number) {
|
|
|
- const result = 0;
|
|
|
- if (buyOrSell === BuyOrSell.buy) {
|
|
|
- if (enumName === EnumRouterName.warehouse_receipt_trade_price) {
|
|
|
- // 仓单贸易 一口价 摘牌最大数量=min{挂牌数量,可用资金/(买方履约保证金比例*挂牌价格)
|
|
|
- const money = getCanUseMoney(fn() as AccountListItem)
|
|
|
-
|
|
|
- }
|
|
|
- switch (enumName) {
|
|
|
- case EnumRouterName.warehouse_receipt_trade_price:
|
|
|
- result
|
|
|
- break
|
|
|
- case EnumRouterName.warehouse_receipt_trade_floating_price:
|
|
|
-
|
|
|
- break
|
|
|
- case EnumRouterName.warehouse_pre_sale_price:
|
|
|
-
|
|
|
- break
|
|
|
- case EnumRouterName.warehouse_pre_sale_floating_price:
|
|
|
-
|
|
|
- break
|
|
|
- }
|
|
|
- } else {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-}
|