Prechádzať zdrojové kódy

修改摘牌仓单取值问题

li.shaoyi 3 rokov pred
rodič
commit
e72fef9174

+ 34 - 10
src/views/market/spot_trade/components/buy-sell-market/components/delisting/setup.ts

@@ -7,7 +7,7 @@ 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 { reactive, Ref, ref, UnwrapRef } from "vue";
+import { reactive, Ref, ref, UnwrapRef, watch } from "vue";
 import { handleIs } from "../../setup";
 import { ListingForm, Wrhold } from "./interface";
 
@@ -45,19 +45,43 @@ 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 { isBuy } = handleIs(enumName, buyOrSell)
+    const { isWR, isBuy } = handleIs(enumName, buyOrSell)
     const wrHoldList = ref<Wrhold[]>([])
     if (isBuy()) {
         queryResultLoadingAndInfo(queryHoldLB, loading).then(res => {
             allWR.value = res;
-            wrHoldList.value.length = 0
-            res.forEach(e => {
-                if (e.wrfactortypeid === String(selectedRow.wrfactortypeid)) {
-                    const { wrholdeno, enableqty, ladingbillid, enumdicname, subnum } = e
-                    const result = { id: ladingbillid, name: `${wrholdeno}(${enableqty}${enumdicname})`, subnum }
-                    wrHoldList.value.push(result)
-                }
-            })
+            if (isWR()) {
+                // 有仓单
+                res.forEach((e) => {
+                    if (e.wrfactortypeid === String(selectedRow.wrfactortypeid)) {
+                        wrHoldList.value.push({
+                            id: e.ladingbillid,
+                            name: `${e.wrholdeno}(${e.enableqty}${e.enumdicname})`,
+                            subnum: e.subnum
+                        })
+                    }
+                })
+            } else {
+                // 无仓单
+                watch(wrPostion, (value) => {
+                    res.forEach((e) => {
+                        if (e.wrfactortypeid === String(selectedRow.wrfactortypeid)) {
+                            const result: Wrhold = {
+                                id: e.ladingbillid,
+                                name: `${e.wrholdeno}(0${e.enumdicname})`,
+                                subnum: e.subnum
+                            }
+
+                            const item = value.find((p) => p.wrfactortypeid === selectedRow.wrfactortypeid);
+                            if (item) {
+                                result.name = `${e.wrholdeno}(${item.creditenableqty}${e.enumdicname})`;
+                            }
+
+                            wrHoldList.value.push(result);
+                        }
+                    })
+                })
+            }
         })
     }
     return { wrHoldList }