Преглед изворни кода

优化 是否有仓单 和挂牌方式判断

huangbin пре 3 година
родитељ
комит
83d2a07abb

+ 12 - 13
src/views/market/market-spot/components/buy-sell-market/components/delisting/setup.ts

@@ -1,4 +1,4 @@
-import { BuyOrSell } from "@/common/constants/enumCommon";
+import { AuctionwrType, BuyOrSell, ListingMode } from '@/common/constants/enumCommon';
 import { EnumRouterName } from "@/common/constants/enumRouterName";
 import { queryResultLoadingAndInfo } from "@/common/methods/request/resultInfo";
 import { getAccountTypeList, getCanUseMoney } from "@/services/bus/account";
@@ -7,10 +7,12 @@ import { getRules } from '@/services/bus/rules';
 import { AccountListItem } from "@/services/dataCenter/interafce/account";
 import { queryHoldLB, queryWrPosition } from '@/services/go/wrtrade';
 import { QueryWrPositionReq, WrHoldLB, WrOrderQuote, WrOrderQuoteDetail, WrPosition } from "@/services/go/wrtrade/interface";
+import { getAuctionwrType, getListingMode } from '@/views/market/market-spot/setup';
 import { reactive, Ref, ref, UnwrapRef } from "vue";
-import { handleIs } from "../../setup";
 import { ListingForm, Wrhold } from "./interface";
 
+const isBuy = (buyOrSell: BuyOrSell) => buyOrSell === BuyOrSell.buy
+
 export function handleForm(data: WrOrderQuoteDetail) {
     const formRef = ref();
     const formState: UnwrapRef<ListingForm> = reactive({
@@ -30,8 +32,7 @@ export function handleForm(data: WrOrderQuoteDetail) {
 // 预售仓单汇总
 const wrPostion = ref<WrPosition[]>([])
 export function getWrPosition(enumName: EnumRouterName, buyOrSell: BuyOrSell, loading: Ref<boolean>) {
-    const { isWR, isBuy } = handleIs(enumName, buyOrSell)
-    if (isBuy() && !isWR()) {
+    if (isBuy(buyOrSell) && getAuctionwrType(AuctionwrType.noWr)) {
         const param: QueryWrPositionReq = {
             haswr: 0,
             querytype: 2,
@@ -45,10 +46,9 @@ export function getWrPosition(enumName: EnumRouterName, buyOrSell: BuyOrSell, lo
 const allWR = ref<WrHoldLB[]>([])
 // 处理现货仓单
 export function handleSpotWarrant(enumName: EnumRouterName, buyOrSell: BuyOrSell, selectedRow: WrOrderQuote, loading: Ref<boolean>) {
-    const { isWR, isBuy } = handleIs(enumName, buyOrSell)
     const wrHoldList = ref<Wrhold[]>([])
-    if (isBuy()) {
-        if (isWR()) {
+    if (isBuy(buyOrSell)) {
+        if (getAuctionwrType(AuctionwrType.hasWr)) {
             queryResultLoadingAndInfo(queryHoldLB, loading).then(res => {
                 allWR.value = res;
                 wrHoldList.value.length = 0
@@ -66,7 +66,6 @@ export function handleSpotWarrant(enumName: EnumRouterName, buyOrSell: BuyOrSell
 }
 
 export function handleNumAndMoney(enumName: EnumRouterName, buyOrSell: BuyOrSell, selectedRow: WrOrderQuoteDetail, parantSelectedRow: WrOrderQuote, formState: UnwrapRef<ListingForm>) {
-    const { isWR, isBuy, isFloat } = handleIs(enumName, buyOrSell)
     // 资金账号
     const accountList = getAccountTypeList([2]);
     // 获取选中的资金账号
@@ -85,8 +84,8 @@ export function handleNumAndMoney(enumName: EnumRouterName, buyOrSell: BuyOrSell
         if (hasRule()) {
             // 可用资金
             const canUseMoney = Number(getCanUseMoney(getSelectedAccount() as AccountListItem))
-            if (!isBuy()) {
-                if (isFloat()) {
+            if (!isBuy(buyOrSell)) {
+                if (getListingMode(ListingMode.float)) {
                     const goodsPrice = getQuoteDayInfoByCodeFindPrice(parantSelectedRow.goodscode);
                     // 估算总价=挂牌基差+期货合约价;
                     if (goodsPrice && goodsPrice !== '--' && pricemove !== null) {   // 有实时行情价格
@@ -104,7 +103,7 @@ export function handleNumAndMoney(enumName: EnumRouterName, buyOrSell: BuyOrSell
                     result = Math.min(orderqty, canUseMoney / marginMoney)
                 }
             } else {
-                if (isWR()) {
+                if (getAuctionwrType(AuctionwrType.hasWr)) {
                     if (formState.LadingBillId) {
                         // 现货库存数量
                         const warehouseNum = allWR.value.find((e) => String(e.ladingbillid) === String(formState.LadingBillId))?.enableqty;
@@ -127,7 +126,7 @@ export function handleNumAndMoney(enumName: EnumRouterName, buyOrSell: BuyOrSell
     //  摘牌金额
     function getMoney() {
         let result = 0
-        if (isFloat()) {
+        if (getListingMode(ListingMode.float)) {
             const goodsPrice = getQuoteDayInfoByCodeFindPrice(parantSelectedRow.goodscode);
             const agreeunit = getGoodsAgreeunitByGoodsCode(parantSelectedRow.goodscode);
             if (goodsPrice && goodsPrice !== '--' && pricemove !== null) {   // 有实时行情价格
@@ -151,7 +150,7 @@ export function handleNumAndMoney(enumName: EnumRouterName, buyOrSell: BuyOrSell
         let result = 0
         if (hasRule()) {
             const { buymarginvalue, sellmarginvalue } = rules[0]
-            const margin = isBuy() ? sellmarginvalue : buymarginvalue
+            const margin = isBuy(buyOrSell) ? sellmarginvalue : buymarginvalue
             result = marginMethod() ? margin * getMoney() : margin + getMoney()
         }
         return Number(result.toFixed(2))

+ 11 - 29
src/views/market/market-spot/components/buy-sell-market/components/financing_delisting/setup.ts

@@ -1,4 +1,4 @@
-import { BuyOrSell } from "@/common/constants/enumCommon";
+import { AuctionwrType, BuyOrSell, ListingMode } from '@/common/constants/enumCommon';
 import { EnumRouterName } from "@/common/constants/enumRouterName";
 import { queryResultLoadingAndInfo } from "@/common/methods/request/resultInfo";
 import { getAccountTypeList, getCanUseMoney } from "@/services/bus/account";
@@ -7,10 +7,12 @@ import { getRules } from '@/services/bus/rules';
 import { AccountListItem } from "@/services/dataCenter/interafce/account";
 import { queryHoldLB, queryWrPosition } from '@/services/go/wrtrade';
 import { QueryWrPositionReq, WrFAProductDetail, WrHoldLB, WrOrderQuote, WrOrderQuoteDetail, WrPosition } from "@/services/go/wrtrade/interface";
+import { getAuctionwrType, getListingMode } from '@/views/market/market-spot/setup';
 import { reactive, Ref, ref, UnwrapRef } from "vue";
-import { handleIs } from "../../setup";
 import { ListingForm, Wrhold } from "./interface";
 
+const isBuy = (buyOrSell: BuyOrSell) => buyOrSell === BuyOrSell.buy
+
 export const selecedFinance = ref<WrFAProductDetail>()
 
 export function handleForm(data: WrOrderQuoteDetail) {
@@ -35,8 +37,7 @@ export function handleForm(data: WrOrderQuoteDetail) {
 // 预售仓单汇总
 const wrPostion = ref<WrPosition[]>([])
 export function getWrPosition(enumName: EnumRouterName, buyOrSell: BuyOrSell, loading: Ref<boolean>) {
-    const { isWR, isBuy } = handleIs(enumName, buyOrSell)
-    if (isBuy() && !isWR()) {
+    if (isBuy(buyOrSell) && getAuctionwrType(AuctionwrType.noWr)) {
         const param: QueryWrPositionReq = {
             haswr: 0,
             querytype: 2,
@@ -50,10 +51,9 @@ export function getWrPosition(enumName: EnumRouterName, buyOrSell: BuyOrSell, lo
 const allWR = ref<WrHoldLB[]>([])
 // 处理现货仓单
 export function handleSpotWarrant(enumName: EnumRouterName, buyOrSell: BuyOrSell, selectedRow: WrOrderQuote, loading: Ref<boolean>) {
-    const { isWR, isBuy } = handleIs(enumName, buyOrSell)
     const wrHoldList = ref<Wrhold[]>([])
-    if (isBuy()) {
-        if (isWR()) {
+    if (isBuy(buyOrSell)) {
+        if (getAuctionwrType(AuctionwrType.hasWr)) {
             queryResultLoadingAndInfo(queryHoldLB, loading).then(res => {
                 allWR.value = res;
                 wrHoldList.value.length = 0
@@ -70,25 +70,7 @@ export function handleSpotWarrant(enumName: EnumRouterName, buyOrSell: BuyOrSell
     return { wrHoldList }
 }
 
-// // 处理现货仓单
-// export function handleSpotWarrant(enumName: EnumRouterName, buyOrSell: BuyOrSell, selectedRow: WrOrderQuote, loading: Ref<boolean>) {
-//     const { isWR, isBuy } = handleIs(enumName, buyOrSell)
-//     const wrHoldList = ref<Wrhold[]>([])
-//     if (isBuy()) {
-//         if (isWR()) {
-//             queryResultLoadingAndInfo(queryHoldLB, loading).then(res => {
-//                 wrHoldList.value = res.filter((e: WrHoldLB) => e.wrfactortypeid === String(selectedRow.wrfactortypeid)).map((e: WrHoldLB) => {
-//                     const { wrholdeno, enableqty, ladingbillid } = e
-//                     return { id: ladingbillid, name: `${wrholdeno}(${enableqty})` }
-//                 })
-//             })
-//         }
-//     }
-//     return { wrHoldList }
-// }
-
 export function handleNumAndMoney(enumName: EnumRouterName, buyOrSell: BuyOrSell, selectedRow: WrOrderQuoteDetail, parantSelectedRow: WrOrderQuote, formState: UnwrapRef<ListingForm>) {
-    const { isWR, isBuy, isFloat } = handleIs(enumName, buyOrSell)
     // 资金账号
     const accountList = getAccountTypeList([2]);
     // 获取选中的资金账号
@@ -107,8 +89,8 @@ export function handleNumAndMoney(enumName: EnumRouterName, buyOrSell: BuyOrSell
         if (hasRule()) {
             // 可用资金
             const canUseMoney = Number(getCanUseMoney(getSelectedAccount() as AccountListItem))
-            if (!isBuy()) {
-                if (isFloat()) {
+            if (!isBuy(buyOrSell)) {
+                if (getListingMode(ListingMode.float)) {
                     const goodsPrice = getQuoteDayInfoByCodeFindPrice(parantSelectedRow.goodscode);
                     // 估算总价=挂牌基差+期货合约价;
                     if (goodsPrice && goodsPrice !== '--' && pricemove !== null) {   // 有实时行情价格
@@ -126,7 +108,7 @@ export function handleNumAndMoney(enumName: EnumRouterName, buyOrSell: BuyOrSell
                     result = Math.min(orderqty, canUseMoney / marginMoney)
                 }
             } else {
-                if (isWR()) {
+                if (getAuctionwrType(AuctionwrType.hasWr)) {
                     if (formState.LadingBillId) {
                         // 现货库存数量
                         const warehouseNum = allWR.value.find((e) => e.ladingbillid === formState.LadingBillId)?.enableqty;
@@ -149,7 +131,7 @@ export function handleNumAndMoney(enumName: EnumRouterName, buyOrSell: BuyOrSell
     //  摘牌金额
     function getMoney() {
         let result = 0
-        if (isFloat()) {
+        if (getListingMode(ListingMode.float)) {
             const goodsPrice = getQuoteDayInfoByCodeFindPrice(parantSelectedRow.goodscode);
             const agreeunit = getGoodsAgreeunitByGoodsCode(parantSelectedRow.goodscode);
             if (goodsPrice && goodsPrice !== '--') {   // 有实时行情价格

+ 0 - 29
src/views/market/market-spot/components/buy-sell-market/setup.ts

@@ -1,10 +1,8 @@
-import { AuctionwrType, BuyOrSell, ListingMode } from '@/common/constants/enumCommon';
 import { EnumRouterName } from '@/common/constants/enumRouterName';
 import { TableKey } from '@/common/methods/table/interface';
 import { getTableColumns, getTableEvent, queryTableList } from "@/common/setup/table";
 import { WrFAProductDetail } from "@/services/go/wrtrade/interface";
 import { Ref, ref } from 'vue';
-import { marketTradeType } from '../../setup';
 
 
 export function handleBuyAndSellList<T>(menuType: EnumRouterName, isDetail: boolean, tableName: keyof TableKey) {
@@ -77,33 +75,6 @@ export function getSellMarketParam(enumName: EnumRouterName) {
     return { wrpricetype, haswr, tableKey }
 }
 
-export function handleIs(enumName: EnumRouterName, buyOrSell: BuyOrSell) {
-    const arr = marketTradeType.value.split('.')
-
-    /**
-     *
-     * @returns 1 => 仓单贸易; 0 => 仓单预售
-     */
-    function isWR(): 0 | 1 {
-        return +arr[1] === AuctionwrType.hasWr ? 1 : 0
-    }
-    /**
-     *
-     * @returns true => 买; false =>卖
-     */
-    function isBuy() {
-        return buyOrSell === BuyOrSell.buy
-    }
-    /**
-     *
-     * @returns  true => 浮动价; false =>一口价
-     */
-    function isFloat() {
-        return +arr[2] === ListingMode.float
-    }
-    return { isWR, isBuy, isFloat }
-}
-
 // 融资摘牌
 const list = ref<WrFAProductDetail[]>([]);
 

+ 7 - 7
src/views/market/market-spot/components/post_buying/setup.ts

@@ -1,4 +1,4 @@
-import { BuyOrSell } from "@/common/constants/enumCommon";
+import { ListingMode } from '@/common/constants/enumCommon';
 import { EnumRouterName } from "@/common/constants/enumRouterName";
 import { validateCommon } from "@/common/setup/validate";
 import { useVerifyBeginDelistingNum, useVerifyListingBasis, useVerifyListingNum } from '@/hooks/form/verify';
@@ -6,10 +6,11 @@ import { getAccountTypeList, getCanUseMoney } from "@/services/bus/account";
 import { getRules } from '@/services/bus/rules';
 import { AccountListItem } from "@/services/dataCenter/interafce/account";
 import { WrOrderQuote } from "@/services/go/wrtrade/interface";
+import { getListingMode } from '@/views/market/market-spot/setup';
 import { RuleObject } from "ant-design-vue/lib/form/interface";
 import moment from "moment";
 import { onBeforeUnmount, reactive, ref, UnwrapRef } from "vue";
-import { getGoodsPrice, handleIs } from "../buy-sell-market/setup";
+import { getGoodsPrice } from "../buy-sell-market/setup";
 import { FormParam, TempWrOrderQuoteDetail } from "./interface";
 
 function initFormData(): FormParam {
@@ -21,7 +22,7 @@ function initFormData(): FormParam {
         DelistMinQty: 0,
         DeliveryMonth: moment(),
         permanceTempName: '',
-        permaceTempId:0,
+        permaceTempId: 0,
         marketid: undefined,
     }
 }
@@ -50,7 +51,6 @@ export function handleForm(selectedRow: TempWrOrderQuoteDetail) {
 
 
 export function handleNumAndPrice(enumName: EnumRouterName, selectedRow: WrOrderQuote) {
-    const { isFloat } = handleIs(enumName, BuyOrSell.buy)
     // 资金账号
     const accountList = getAccountTypeList([2]);
     // 获取选中的资金账号
@@ -66,7 +66,7 @@ export function handleNumAndPrice(enumName: EnumRouterName, selectedRow: WrOrder
         const canUseMoney = Number(getCanUseMoney(getSelectedAccount() as AccountListItem))
         // 挂牌最大数量=可用资金/(买方履约保证金比例*挂牌价格)
         let result = 0
-        if (isFloat()) {
+        if (getListingMode(ListingMode.float)) {
             const price = getPrice()
             if (price !== '--') {
                 result = canUseMoney / (Number(price) * buymarginvalue)
@@ -84,13 +84,13 @@ export function handleNumAndPrice(enumName: EnumRouterName, selectedRow: WrOrder
             // 当市场设置的买保证金为0时,不做数量限制
             return 10000
         }
-        
+
     }
     //  摘牌金额
     function getMoney() {
         let result = 0
         if (formState.OrderQty) {
-            if (isFloat()) {
+            if (getListingMode(ListingMode.float)) {
                 const goodsPrice = getGoodsPrice()
                 if (goodsPrice.value && goodsPrice.value !== '--') {   // 有实时行情价格
                     // 估算总价=挂牌基差+期货合约价;

+ 0 - 31
src/views/market/market-spot/spot_trade_order_transaction/components/buy-sell-market/setup.ts

@@ -1,4 +1,3 @@
-import { BuyOrSell } from '@/common/constants/enumCommon';
 import { EnumRouterName } from '@/common/constants/enumRouterName';
 import { queryResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
 import { TableKey } from '@/common/methods/table/interface';
@@ -78,36 +77,6 @@ export function getSellMarketParam(enumName: EnumRouterName) {
     return { wrpricetype, haswr, tableKey }
 }
 
-export function handleIs(enumName: EnumRouterName, buyOrSell: BuyOrSell) {
-    /**
-     *
-     * @returns 1 => 仓单贸易; 0 => 仓单预售
-     */
-    function isWR(): 0 | 1 {
-        if (enumName === EnumRouterName.warehouse_receipt_trade_price || enumName === EnumRouterName.warehouse_receipt_trade_floating_price) {
-            return 1
-        } else {
-            return 0
-        }
-    }
-    /**
-     *
-     * @returns true => 买; false =>卖
-     */
-    function isBuy() {
-        return buyOrSell === BuyOrSell.buy
-    }
-    /**
-     *
-     * @returns  true => 浮动价; false =>一口价
-     */
-    function isFloat() {
-        return enumName === EnumRouterName.warehouse_receipt_trade_floating_price ||
-            enumName === EnumRouterName.warehouse_pre_sale_floating_price
-    }
-    return { isWR, isBuy, isFloat }
-}
-
 const list = ref<WrFAProductDetail[]>([]);
 // 获取融资摘牌
 export function handleFinacing(loading: Ref<boolean>, id: number) {