feat: 日终价格新增标的代码支持输入联想(服务端模糊匹配+原生下拉,防填错)
- 新增 SuggestUnderlyingForEod(code,kind):按代码/名称 LIKE 匹配、Take(20)、强制 LaunchState==1 与类型,与列表查询/Lookup 三处口径一致 - 三个编辑页代码输入框加 oninput 防抖联想,原生 fixed 下拉展示候选,点选回填精确代码并复用失焦校验带出市场;期货额外回填 UnderlyingId - 不依赖任何前端自动补全插件(jQuery UI 未打包),可支撑几十万标的数据量
This commit is contained in:
@@ -176,6 +176,63 @@ namespace YLErp.Web.Controllers
|
||||
Market = u.MarketName,
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新建日终价格时,按手工输入的片段做服务端模糊联想(代码或名称包含匹配),只回前 20 条。
|
||||
/// 与 LookupUnderlyingForEod 同样只返回已上市(LaunchState=="1")且类型匹配的标的。
|
||||
/// 用原生下拉渲染(不依赖 jQuery UI,bundle 未打包),避免几十万标的全量渲染卡死。
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public JsonResult SuggestUnderlyingForEod(string q, string kind)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(q))
|
||||
{
|
||||
return JsonSuccess("", new List<object>());
|
||||
}
|
||||
q = q.Trim();
|
||||
|
||||
string[] types = kind switch
|
||||
{
|
||||
"future" => new[]
|
||||
{
|
||||
ConsGlobal.InstrumentType.CommodityFutures,
|
||||
ConsGlobal.InstrumentType.GoldFutures,
|
||||
ConsGlobal.InstrumentType.TBFutures,
|
||||
ConsGlobal.InstrumentType.OtherFutures,
|
||||
ConsGlobal.InstrumentType.AbroadFutures,
|
||||
},
|
||||
"stock" => new[]
|
||||
{
|
||||
ConsGlobal.InstrumentType.Stock,
|
||||
ConsGlobal.InstrumentType.StockIndex,
|
||||
ConsGlobal.InstrumentType.StockIF,
|
||||
ConsGlobal.InstrumentType.HKStock,
|
||||
ConsGlobal.InstrumentType.HKStockIndex,
|
||||
ConsGlobal.InstrumentType.NewOtcStock,
|
||||
ConsGlobal.InstrumentType.AbroadStock,
|
||||
ConsGlobal.InstrumentType.AbroadStockIndex,
|
||||
},
|
||||
_ => new[]
|
||||
{
|
||||
ConsGlobal.InstrumentType.Bonds,
|
||||
ConsGlobal.InstrumentType.TBonds,
|
||||
ConsGlobal.InstrumentType.CreditBonds,
|
||||
ConsGlobal.InstrumentType.OtherBonds,
|
||||
},
|
||||
};
|
||||
var set = new HashSet<string>(types);
|
||||
|
||||
var list = yldb.underlying_manager
|
||||
.Where(n => n.LaunchState == "1" && set.Contains(n.UnderlyingInstrumentType)
|
||||
&& (n.UnderlyingCode.Contains(q) || n.UnderlyingName.Contains(q)))
|
||||
.OrderBy(n => n.UnderlyingCode)
|
||||
.Take(20)
|
||||
.Select(n => new { n.id, Code = n.UnderlyingCode, Name = n.UnderlyingName, Market = n.MarketName })
|
||||
.ToList();
|
||||
|
||||
return JsonSuccess("", list);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public JsonResult EodFuturePriceEditJson(eod_commodity_future_price req)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user