From 5b7f17727d9a37271f02cb62166775663f83cc48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=90=8D=E9=94=90?= <1565842059@qq.com> Date: Thu, 6 Aug 2026 12:41:30 +0800 Subject: [PATCH] =?UTF-8?q?refactor(swaptrade):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BA=92=E6=8D=A2=E4=BA=A4=E6=98=93=E4=B8=AD=E7=9A=84=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E5=92=8C=E9=87=91=E9=A2=9D=E6=A0=BC=E5=BC=8F=E5=8C=96?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 引入UnderlyingInstrumentType字段用于精确控制格式化规则 - 添加quantityPrecision配置支持不同产品类型的数量精度设置 - 实现formatAmount和formatQuantity方法提供统一格式化接口 - 更新视图模板使用新的格式化方法替代直接数据绑定 - 重构swapPricePrecisionHelper.js支持按产品类型定制格式化规则 - 移除废弃的inputFormatTradeAmount等旧格式化配置 - 添加千分位分组显示功能提升数字可读性 --- .../App_Data/Config/swappriceprecision.js | 54 ++++---- YLErpWeb/Views/SwapTrade2/SwapIncome.cshtml | 18 +-- .../Views/SwapTrade2/SwapLongShortSwap.cshtml | 10 +- .../SwapTrade2/SwapLongShortUnwind.cshtml | 14 +- YLErpWeb/Views/SwapTrade2/SwapUnwind.cshtml | 22 ++-- YLErpWeb/Views/SwapTrade2/SwapflowList.cshtml | 2 +- YLErpWeb/Views/SwapTrade2/TradeEdit.cshtml | 2 +- YLErpWeb/Views/SwapTrade2/TradeView.cshtml | 10 +- .../Scripts/app/swaptrade/SwapflowList.js | 20 ++- .../Scripts/app/swaptrade/incomeSwapTrade.js | 12 +- .../Scripts/app/swaptrade/swapLongShort.js | 11 +- .../app/swaptrade/swapPricePrecisionHelper.js | 123 ++++++++++++------ .../Scripts/app/swaptrade/swapTradeEdit.js | 12 +- .../Scripts/app/swaptrade/swapTradeView.js | 5 +- .../Scripts/app/swaptrade/unwindLongShort.js | 11 +- .../Scripts/app/swaptrade/unwindSwapTrade.js | 15 ++- 16 files changed, 218 insertions(+), 123 deletions(-) diff --git a/YLErpWeb/App_Data/Config/swappriceprecision.js b/YLErpWeb/App_Data/Config/swappriceprecision.js index 2cb43923..a0d631eb 100644 --- a/YLErpWeb/App_Data/Config/swappriceprecision.js +++ b/YLErpWeb/App_Data/Config/swappriceprecision.js @@ -2,52 +2,54 @@ window.main = window.main || {}; window.main.swapPricePrecision = { common: { - amount: { precision: 2 }, - quantity: { precision: 2 }, + amount: { precision: 2, grouping: true }, + quantity: { precision: 2, grouping: true }, rate: { precision: 4 } }, - Stock: { integerDigits: 7, precision: 2 }, - StockIndex: { integerDigits: 7, precision: 2 }, - StockIF: { integerDigits: 7, precision: 4 }, - CommodityFutures: { integerDigits: 7, precision: 4 }, - CommoditySpot: { integerDigits: 7, precision: 4 }, - NewOtcStock: { integerDigits: 7, precision: 4 }, - HKStock: { integerDigits: 7, precision: 4 }, - HKStockIndex: { integerDigits: 7, precision: 4 }, - Fund: { integerDigits: 7, precision: 4 }, + Stock: { integerDigits: 7, precision: 2, quantityPrecision: 2 }, + StockIndex: { integerDigits: 7, precision: 2, quantityPrecision: 2 }, + StockIF: { integerDigits: 7, precision: 4, quantityPrecision: 2 }, + CommodityFutures: { integerDigits: 7, precision: 4, quantityPrecision: 2 }, + CommoditySpot: { integerDigits: 7, precision: 4, quantityPrecision: 2 }, + NewOtcStock: { integerDigits: 7, precision: 4, quantityPrecision: 2 }, + HKStock: { integerDigits: 7, precision: 4, quantityPrecision: 2 }, + HKStockIndex: { integerDigits: 7, precision: 4, quantityPrecision: 2 }, + Fund: { integerDigits: 7, precision: 4, quantityPrecision: 4 }, Bond: { + quantityPrecision: 0, grossPrice: { integerDigits: 6, precision: 9 }, netPrice: { integerDigits: 6, precision: 9 }, yield: { integerDigits: 2, precision: 4 } }, TBonds: { + quantityPrecision: 0, grossPrice: { integerDigits: 6, precision: 9 }, netPrice: { integerDigits: 6, precision: 9 }, yield: { integerDigits: 2, precision: 4 } }, CreditBonds: { + quantityPrecision: 0, grossPrice: { integerDigits: 6, precision: 9 }, netPrice: { integerDigits: 6, precision: 9 }, yield: { integerDigits: 2, precision: 4 } }, OtherBonds: { + quantityPrecision: 0, grossPrice: { integerDigits: 6, precision: 9 }, netPrice: { integerDigits: 6, precision: 9 }, yield: { integerDigits: 2, precision: 4 } }, - TBFutures: { integerDigits: 8, precision: 4 }, - OtherFutures: { integerDigits: 8, precision: 4 }, - GoldSpot: { integerDigits: 8, precision: 4 }, - OtherSpot: { integerDigits: 8, precision: 4 }, - AbroadFutures: { integerDigits: 8, precision: 4 }, - AbroadSpot: { integerDigits: 8, precision: 4 }, - AbroadStock: { integerDigits: 8, precision: 2 }, - AbroadStockIndex: { integerDigits: 8, precision: 4 }, - ExRate: { integerDigits: 2, precision: 8 }, - Shibor: { integerDigits: 2, precision: 4 }, - FixingRepoRate: { integerDigits: 2, precision: 4 }, - RateYield: {integerDigits: 6, precision: 8}, - BondIndex: {integerDigits: 6, precision: 4}, - - // TODO: 利率收益率(6+8)、债券指数(6+4)、黄金期货(6+4)待对应的 UnderlyingInstrumentType 枚举确认后启用。 + TBFutures: { integerDigits: 8, precision: 4, quantityPrecision: 2 }, + OtherFutures: { integerDigits: 8, precision: 4, quantityPrecision: 2 }, + GoldSpot: { integerDigits: 8, precision: 4, quantityPrecision: 2 }, + OtherSpot: { integerDigits: 8, precision: 4, quantityPrecision: 2 }, + AbroadFutures: { integerDigits: 8, precision: 4, quantityPrecision: 2 }, + AbroadSpot: { integerDigits: 8, precision: 4, quantityPrecision: 2 }, + AbroadStock: { integerDigits: 8, precision: 2, quantityPrecision: 2 }, + AbroadStockIndex: { integerDigits: 8, precision: 4, quantityPrecision: 2 }, + ExRate: { integerDigits: 2, precision: 8, quantityPrecision: 8 }, + Shibor: { integerDigits: 2, precision: 4, quantityPrecision: 2 }, + FixingRepoRate: { integerDigits: 2, precision: 4, quantityPrecision: 2 }, + RateYield: {integerDigits: 6, precision: 8, quantityPrecision: 2}, + BondIndex: {integerDigits: 6, precision: 4, quantityPrecision: 2}, }; diff --git a/YLErpWeb/Views/SwapTrade2/SwapIncome.cshtml b/YLErpWeb/Views/SwapTrade2/SwapIncome.cshtml index ea00430b..91d9d26f 100644 --- a/YLErpWeb/Views/SwapTrade2/SwapIncome.cshtml +++ b/YLErpWeb/Views/SwapTrade2/SwapIncome.cshtml @@ -42,15 +42,15 @@ 成交名义本金 - {{deal.NotionalValue}} + {{formatAmount(deal.NotionalValue)}} 持仓名义本金 - {{deal.PosiNotionalValue}} + {{formatAmount(deal.PosiNotionalValue)}} 成交数量 - {{deal.NotionalQty}} + {{formatQuantity(deal.NotionalQty)}} 持仓数量 - {{deal.PositionQty2}} + {{formatQuantity(deal.PositionQty2)}} 起始日期 @@ -66,7 +66,7 @@ 平仓总额 - {{deal.SwapCloseAmount}} + {{formatAmount(deal.SwapCloseAmount)}} @@ -98,7 +98,7 @@ - {{item.InterestClosePnL}} + {{formatAmount(item.InterestClosePnL)}} @@ -126,7 +126,7 @@ - {{item.InterestClosePnL}} + {{formatAmount(item.InterestClosePnL)}} @@ -177,13 +177,13 @@ - {{floatPosition.Quantity}} + {{formatQuantity(floatPosition.Quantity)}}
我方{{floatPosition.PayDirection==1?"支付":"收取"}}交易费用
- {{floatPosition.FloatPnlSum}} + {{formatAmount(floatPosition.FloatPnlSum)}} diff --git a/YLErpWeb/Views/SwapTrade2/SwapLongShortSwap.cshtml b/YLErpWeb/Views/SwapTrade2/SwapLongShortSwap.cshtml index 1ef9f150..4df23cf7 100644 --- a/YLErpWeb/Views/SwapTrade2/SwapLongShortSwap.cshtml +++ b/YLErpWeb/Views/SwapTrade2/SwapLongShortSwap.cshtml @@ -28,11 +28,11 @@
- +
- +
@@ -48,7 +48,7 @@
- +
@@ -75,7 +75,7 @@ - {{item.InterestClosePnL}} + {{formatAmount(item.InterestClosePnL)}} @@ -103,7 +103,7 @@ - {{item.InterestClosePnL}} + {{formatAmount(item.InterestClosePnL)}} diff --git a/YLErpWeb/Views/SwapTrade2/SwapLongShortUnwind.cshtml b/YLErpWeb/Views/SwapTrade2/SwapLongShortUnwind.cshtml index c773ae03..bdbc1601 100644 --- a/YLErpWeb/Views/SwapTrade2/SwapLongShortUnwind.cshtml +++ b/YLErpWeb/Views/SwapTrade2/SwapLongShortUnwind.cshtml @@ -29,20 +29,20 @@
- +
- +
- +
- +
@@ -62,7 +62,7 @@
- +
@@ -91,7 +91,7 @@ - {{item.InterestClosePnL}} + {{formatAmount(item.InterestClosePnL)}} @@ -115,7 +115,7 @@ - {{item.InterestClosePnL}} + {{formatAmount(item.InterestClosePnL)}} diff --git a/YLErpWeb/Views/SwapTrade2/SwapUnwind.cshtml b/YLErpWeb/Views/SwapTrade2/SwapUnwind.cshtml index 7f9e2ea1..4d7c979a 100644 --- a/YLErpWeb/Views/SwapTrade2/SwapUnwind.cshtml +++ b/YLErpWeb/Views/SwapTrade2/SwapUnwind.cshtml @@ -33,20 +33,20 @@
- +
- +
- +
- +
@@ -64,7 +64,7 @@
- +
@@ -96,7 +96,7 @@
- +
@@ -125,7 +125,7 @@ - {{item.InterestClosePnL}} + {{formatAmount(item.InterestClosePnL)}} @@ -165,7 +165,7 @@ - {{item.InterestClosePnL}} + {{formatAmount(item.InterestClosePnL)}} @@ -214,7 +214,7 @@ - {{deal.CloseQty}} + {{formatQuantity(deal.CloseQty)}}
我方{{floatPosition.PayDirection==1?"支付":"收取"}}交易费用
@@ -222,8 +222,8 @@ - {{floatPosition.DividendIn}} - {{floatPosition.FloatPnlSum}} + {{formatAmount(floatPosition.DividendIn)}} + {{formatAmount(floatPosition.FloatPnlSum)}} diff --git a/YLErpWeb/Views/SwapTrade2/SwapflowList.cshtml b/YLErpWeb/Views/SwapTrade2/SwapflowList.cshtml index 9ec357e9..863283eb 100644 --- a/YLErpWeb/Views/SwapTrade2/SwapflowList.cshtml +++ b/YLErpWeb/Views/SwapTrade2/SwapflowList.cshtml @@ -233,7 +233,7 @@
- +
diff --git a/YLErpWeb/Views/SwapTrade2/TradeEdit.cshtml b/YLErpWeb/Views/SwapTrade2/TradeEdit.cshtml index eead5b88..6561cbfe 100644 --- a/YLErpWeb/Views/SwapTrade2/TradeEdit.cshtml +++ b/YLErpWeb/Views/SwapTrade2/TradeEdit.cshtml @@ -493,7 +493,7 @@ - {{item.underlying!=null?item.underlying.QuoteUnitString:''}} + {{item.underlying!=null?item.underlying.QuoteUnitString:''}}