fix: 日终价格新增改回手动输入标的代码(删除全量下拉、解决null报错与市场带出)
- 删除 BuildUnderlyingOptions/UnderlyingOptionVm(几十万债券全量下拉导致卡死、选不动) - 新增轻量 LookupUnderlyingForEod(code,kind):精确按代码查一条、强制 LaunchState=="1"(与列表查询对齐,杜绝幽灵记录) - 三个编辑页新建时标的代码改为可输入框,onblur 用 main.post 带出市场;期货额外回填 UnderlyingId(按id join) - 隐藏域按新建/编辑分渲染,修复 saveeod_*/on*Picked 读 null 报错 - 删除已废弃的 eodPriceAdd.cshtml
This commit is contained in:
@@ -4,18 +4,6 @@ using YLErp.Modules.EodModule;
|
||||
|
||||
namespace YLErp.Web.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 新建日终价格时,编辑页用来渲染"选择标的"下拉项的轻量视图模型。
|
||||
/// 纯服务端渲染,前端不依赖任何自动补全插件。
|
||||
/// </summary>
|
||||
public class UnderlyingOptionVm
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Code { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Market { get; set; }
|
||||
}
|
||||
|
||||
public class EodPriceController : BaseController
|
||||
{
|
||||
readonly IViewRenderService _viewRenderer;
|
||||
@@ -71,13 +59,8 @@ namespace YLErp.Web.Controllers
|
||||
ViewBag.IsNew = isNew;
|
||||
if (isNew)
|
||||
{
|
||||
// 新建:提供期货类标的下拉,供前端选择后回填 UnderlyingId/UnderlyingCode/市场
|
||||
ViewBag.UnderlyingOptions = BuildUnderlyingOptions(
|
||||
ConsGlobal.InstrumentType.CommodityFutures,
|
||||
ConsGlobal.InstrumentType.GoldFutures,
|
||||
ConsGlobal.InstrumentType.TBFutures,
|
||||
ConsGlobal.InstrumentType.OtherFutures,
|
||||
ConsGlobal.InstrumentType.AbroadFutures);
|
||||
// 新建:手工输入标的代码,失焦时调 LookupUnderlyingForEod 校验并带出市场/UnderlyingId。
|
||||
// 默认估值日期=今天:避免未填日期时落库为 0001-01-01、落在列表默认窗口(今天)之外而查不出。
|
||||
return View(new eod_commodity_future_price { ValueDate = DateTime.Today });
|
||||
}
|
||||
var intid = DecryptInt(enid);
|
||||
@@ -96,16 +79,7 @@ namespace YLErp.Web.Controllers
|
||||
ViewBag.IsNew = isNew;
|
||||
if (isNew)
|
||||
{
|
||||
// 新建:提供股票类标的下拉
|
||||
ViewBag.UnderlyingOptions = BuildUnderlyingOptions(
|
||||
ConsGlobal.InstrumentType.Stock,
|
||||
ConsGlobal.InstrumentType.StockIndex,
|
||||
ConsGlobal.InstrumentType.StockIF,
|
||||
ConsGlobal.InstrumentType.HKStock,
|
||||
ConsGlobal.InstrumentType.HKStockIndex,
|
||||
ConsGlobal.InstrumentType.NewOtcStock,
|
||||
ConsGlobal.InstrumentType.AbroadStock,
|
||||
ConsGlobal.InstrumentType.AbroadStockIndex);
|
||||
// 新建:手工输入标的代码,失焦时调 LookupUnderlyingForEod 校验并带出市场。
|
||||
return View(new eod_stock_price { ValueDate = DateTime.Today });
|
||||
}
|
||||
var intid = DecryptInt(enid);
|
||||
@@ -123,13 +97,8 @@ namespace YLErp.Web.Controllers
|
||||
ViewBag.IsNew = isNew;
|
||||
if (isNew)
|
||||
{
|
||||
// 新建:提供债券类标的下拉(bond_id 由前端选择后回填)。
|
||||
// 默认估值日期=今天:避免未填日期时落库为 0001-01-01,落在列表默认窗口(今天)之外而查不出。
|
||||
ViewBag.UnderlyingOptions = BuildUnderlyingOptions(
|
||||
ConsGlobal.InstrumentType.Bonds,
|
||||
ConsGlobal.InstrumentType.TBonds,
|
||||
ConsGlobal.InstrumentType.CreditBonds,
|
||||
ConsGlobal.InstrumentType.OtherBonds);
|
||||
// 新建:手工输入债券代码(bond_id),失焦时调 LookupUnderlyingForEod 校验并带出市场。
|
||||
// 默认估值日期=今天:避免未填日期时落库为 0001-01-01、落在列表默认窗口(今天)之外而查不出。
|
||||
return View(new ChinaBondValuation { valuation_date = DateTime.Today });
|
||||
}
|
||||
var intid = DecryptLong(enid);
|
||||
@@ -143,23 +112,69 @@ namespace YLErp.Web.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按标的类型取可下拉的标的列表(新建日终价格时供前端选择)。
|
||||
/// 返回 Id/Code/Name/Market,纯服务端渲染,不依赖前端自动补全插件。
|
||||
/// 新建日终价格时,按用户手工输入的标的代码精确查一条标的,带出名称/市场/Id。
|
||||
/// 只返回已上市(LaunchState=="1")且类型匹配的标的——与列表查询 inner join 的过滤对齐,
|
||||
/// 从源头杜绝"新增能存但查不出"的幽灵记录。前端在输入框失焦时调用,不依赖任何下拉/补全插件。
|
||||
/// </summary>
|
||||
private List<UnderlyingOptionVm> BuildUnderlyingOptions(params string[] instrumentTypes)
|
||||
/// <param name="code">标的代码(用户手工输入)</param>
|
||||
/// <param name="kind">bond | future | stock,决定允许的标的类型集合</param>
|
||||
[HttpPost]
|
||||
public JsonResult LookupUnderlyingForEod(string code, string kind)
|
||||
{
|
||||
var set = new HashSet<string>(instrumentTypes);
|
||||
return yldb.underlying_manager
|
||||
.Where(n => n.UnderlyingCode != null && n.LaunchState == "1" && set.Contains(n.UnderlyingInstrumentType))
|
||||
.OrderBy(n => n.UnderlyingCode)
|
||||
.Select(n => new UnderlyingOptionVm
|
||||
if (string.IsNullOrWhiteSpace(code))
|
||||
{
|
||||
return JsonError("请输入标的代码");
|
||||
}
|
||||
code = code.Trim();
|
||||
|
||||
string[] types = kind switch
|
||||
{
|
||||
"future" => new[]
|
||||
{
|
||||
Id = n.id,
|
||||
Code = n.UnderlyingCode,
|
||||
Name = n.UnderlyingName,
|
||||
Market = n.MarketName
|
||||
})
|
||||
.ToList();
|
||||
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 u = yldb.underlying_manager
|
||||
.Where(n => n.UnderlyingCode == code && n.LaunchState == "1" && set.Contains(n.UnderlyingInstrumentType))
|
||||
.Select(n => new { n.id, n.UnderlyingCode, n.UnderlyingName, n.MarketName })
|
||||
.FirstOrDefault();
|
||||
|
||||
if (u == null)
|
||||
{
|
||||
return JsonError("未找到该标的(不存在、未上市或类型不匹配),无法录入");
|
||||
}
|
||||
|
||||
return JsonSuccess("", new
|
||||
{
|
||||
Id = u.id,
|
||||
Code = u.UnderlyingCode,
|
||||
Name = u.UnderlyingName,
|
||||
Market = u.MarketName,
|
||||
});
|
||||
}
|
||||
[HttpPost]
|
||||
public JsonResult EodFuturePriceEditJson(eod_commodity_future_price req)
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
@model ChinaBondValuation
|
||||
@{
|
||||
ViewBag.Title = "日终商品期货价格 | 编辑";
|
||||
ViewBag.Title = "日终债券价格 | 编辑";
|
||||
Layout = "~/Views/Shared/_InfoLayout.cshtml";
|
||||
bool isNew = ViewBag.IsNew != null && (bool)ViewBag.IsNew;
|
||||
}
|
||||
@section JS
|
||||
{
|
||||
@@ -16,16 +17,23 @@
|
||||
return pass;
|
||||
}
|
||||
|
||||
function onBondPicked() {
|
||||
var sel = document.getElementById('BondPicker');
|
||||
var opt = sel.options[sel.selectedIndex];
|
||||
document.getElementById('bond_id').value = opt.value;
|
||||
document.getElementById('MarketBox').value = opt.getAttribute('data-market') || '';
|
||||
// 手工输入债券代码后失焦:校验标的存在且已上市,并带出市场
|
||||
function lookupBond() {
|
||||
var el = document.getElementById('bond_id');
|
||||
if (!el) return;
|
||||
var code = (el.value || '').trim();
|
||||
var mk = document.getElementById('MarketBox');
|
||||
if (!code) { if (mk) mk.value = ''; return; }
|
||||
main.post("/eodPrice/LookupUnderlyingForEod", { code: code, kind: 'bond' }).done(function (res) {
|
||||
el.value = res.obj.Code;
|
||||
if (mk) mk.value = res.obj.Market || '';
|
||||
});
|
||||
}
|
||||
|
||||
function saveeod_bond_price() {
|
||||
if (document.getElementById('BondPicker') && !document.getElementById('bond_id').value) {
|
||||
main.message('请先选择债券标的'); return false;
|
||||
var el = document.getElementById('bond_id');
|
||||
if (el && !(el.value || '').trim()) {
|
||||
main.message('请输入债券标的代码'); return false;
|
||||
}
|
||||
if (!checkSubmitData()) return false;
|
||||
var data = $("#form1").serialize();
|
||||
@@ -41,23 +49,20 @@
|
||||
|
||||
<input type="hidden" value="@Model.id" name="id" id="id" />
|
||||
<input type="hidden" value="@Model.EncryptId" name="EncryptId" id="EncryptId" />
|
||||
<input type="hidden" name="bond_id" value="@(Model.bond_id)" />
|
||||
@if (!isNew)
|
||||
{
|
||||
<input type="hidden" name="bond_id" value="@(Model.bond_id)" />
|
||||
}
|
||||
<input type="hidden" name="term_to_maturity" value="@(Model.term_to_maturity)" />
|
||||
|
||||
<h4>日终债券价格修改</h4>
|
||||
|
||||
<div style="margin-top:20px;">
|
||||
@if (ViewBag.IsNew != null && (bool)ViewBag.IsNew)
|
||||
@if (isNew)
|
||||
{
|
||||
<div class='form-group col-md-6'>
|
||||
<label class='formlabel'>标的</label>
|
||||
<select class='text-box' id="BondPicker" onchange="onBondPicked()">
|
||||
<option value="">-- 请选择债券标的 --</option>
|
||||
@foreach (var u in (List<YLErp.Web.Controllers.UnderlyingOptionVm>)ViewBag.UnderlyingOptions)
|
||||
{
|
||||
<option value="@u.Code" data-market="@u.Market">@u.Code @u.Name</option>
|
||||
}
|
||||
</select>
|
||||
<label class='formlabel'>标的代码</label>
|
||||
<input class='text-box' type='text' id="bond_id" name="bond_id" value="" onblur="lookupBond()" placeholder="输入债券代码,失焦自动带出市场" />
|
||||
</div>
|
||||
<div class='form-group col-md-6'>
|
||||
<label class='formlabel'>市场</label>
|
||||
@@ -85,4 +90,4 @@
|
||||
<button class="btn btn-primary" type="button" onclick="layer.closeMe();">关闭</button>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
@{
|
||||
ViewBag.Title = "日终商品期货价格 | 编辑";
|
||||
Layout = "~/Views/Shared/_InfoLayout.cshtml";
|
||||
bool isNew = ViewBag.IsNew != null && (bool)ViewBag.IsNew;
|
||||
}
|
||||
@section JS
|
||||
{
|
||||
@@ -16,17 +17,29 @@
|
||||
return pass;
|
||||
}
|
||||
|
||||
function onFuturePicked() {
|
||||
var sel = document.getElementById('FuturePicker');
|
||||
var opt = sel.options[sel.selectedIndex];
|
||||
document.getElementById('UnderlyingId').value = opt.value;
|
||||
document.getElementById('UnderlyingCode').value = opt.getAttribute('data-code') || '';
|
||||
document.getElementById('MarketBox').value = opt.getAttribute('data-market') || '';
|
||||
// 手工输入期货合约代码后失焦:校验标的存在且已上市,带出市场并回填 UnderlyingId(列表查询按此 join)
|
||||
function lookupFuture() {
|
||||
var el = document.getElementById('UnderlyingCode');
|
||||
if (!el) return;
|
||||
var code = (el.value || '').trim();
|
||||
var mk = document.getElementById('MarketBox');
|
||||
var idEl = document.getElementById('UnderlyingId');
|
||||
if (!code) { if (mk) mk.value = ''; if (idEl) idEl.value = ''; return; }
|
||||
main.post("/eodPrice/LookupUnderlyingForEod", { code: code, kind: 'future' }).done(function (res) {
|
||||
el.value = res.obj.Code;
|
||||
if (idEl) idEl.value = res.obj.Id;
|
||||
if (mk) mk.value = res.obj.Market || '';
|
||||
});
|
||||
}
|
||||
|
||||
function saveeod_commodity_future_price() {
|
||||
if (document.getElementById('FuturePicker') && !document.getElementById('UnderlyingCode').value) {
|
||||
main.message('请先选择期货标的'); return false;
|
||||
var el = document.getElementById('UnderlyingCode');
|
||||
var idEl = document.getElementById('UnderlyingId');
|
||||
if (el && !(el.value || '').trim()) {
|
||||
main.message('请输入期货标的代码'); return false;
|
||||
}
|
||||
if (el && idEl && !idEl.value) {
|
||||
main.message('标的未校验通过,请重新输入代码后失焦'); return false;
|
||||
}
|
||||
if (!checkSubmitData()) return false;
|
||||
var data = $("#form1").serialize();
|
||||
@@ -42,25 +55,26 @@
|
||||
|
||||
<input type="hidden" value="@Model.id" name="id" id="id" />
|
||||
<input type="hidden" value="@Model.EncryptId" name="EncryptId" id="EncryptId" />
|
||||
<input type="hidden" name="UnderlyingId" value="@(Model.UnderlyingId)" />
|
||||
<input type="hidden" name="UnderlyingCode" value="@(Model.UnderlyingCode)" />
|
||||
@if (isNew)
|
||||
{
|
||||
<input type="hidden" name="UnderlyingId" id="UnderlyingId" value="" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<input type="hidden" name="UnderlyingId" value="@(Model.UnderlyingId)" />
|
||||
<input type="hidden" name="UnderlyingCode" value="@(Model.UnderlyingCode)" />
|
||||
}
|
||||
<input type="hidden" name="HighPrice" value="@(Model.HighPrice)" />
|
||||
<input type="hidden" name="LowPrice" value="@(Model.LowPrice)" />
|
||||
|
||||
<h4>日终商品期货价格修改</h4>
|
||||
|
||||
<div style="margin-top:20px;">
|
||||
@if (ViewBag.IsNew != null && (bool)ViewBag.IsNew)
|
||||
@if (isNew)
|
||||
{
|
||||
<div class='form-group col-md-6'>
|
||||
<label class='formlabel'>标的</label>
|
||||
<select class='text-box' id="FuturePicker" onchange="onFuturePicked()">
|
||||
<option value="">-- 请选择期货标的 --</option>
|
||||
@foreach (var u in (List<YLErp.Web.Controllers.UnderlyingOptionVm>)ViewBag.UnderlyingOptions)
|
||||
{
|
||||
<option value="@u.Id" data-code="@u.Code" data-market="@u.Market">@u.Code @u.Name</option>
|
||||
}
|
||||
</select>
|
||||
<label class='formlabel'>标的代码</label>
|
||||
<input class='text-box' type='text' id="UnderlyingCode" name="UnderlyingCode" value="" onblur="lookupFuture()" placeholder="输入期货合约代码,失焦自动带出市场" />
|
||||
</div>
|
||||
<div class='form-group col-md-6'>
|
||||
<label class='formlabel'>市场</label>
|
||||
@@ -88,4 +102,4 @@
|
||||
<button class="btn btn-primary" type="button" onclick="layer.closeMe();">关闭</button>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
||||
|
||||
@@ -1,268 +0,0 @@
|
||||
@{
|
||||
ViewBag.Title = "日终价格新增";
|
||||
Layout = "~/Views/Shared/_InfoLayout.cshtml";
|
||||
}
|
||||
@section CSS
|
||||
{
|
||||
<style type="text/css">
|
||||
.suggest-box {
|
||||
position: absolute;
|
||||
z-index: 9999;
|
||||
background: #fff;
|
||||
border: 1px solid #c5c5c5;
|
||||
max-height: 260px;
|
||||
overflow-y: auto;
|
||||
width: 100%;
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,.18);
|
||||
}
|
||||
.suggest-item {
|
||||
padding: 7px 12px;
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.suggest-item:hover, .suggest-item.active {
|
||||
background: #eef4ff;
|
||||
}
|
||||
.suggest-empty {
|
||||
padding: 7px 12px;
|
||||
color: #999;
|
||||
}
|
||||
</style>
|
||||
}
|
||||
@section JS
|
||||
{
|
||||
<script type="text/javascript">
|
||||
var activeGroup = null; // 当前显示的字段组选择器
|
||||
var suggestItems = []; // 当前补全项
|
||||
var suggestTimer = null;
|
||||
|
||||
$(function () {
|
||||
$(".datepicker").datepicker({ changeMonth: true, changeYear: true, showButtonPanel: true, showOtherMonths: true, selectOtherMonths: true });
|
||||
|
||||
// 自带下拉补全:不依赖 jQuery UI(bundle 未打包 autocomplete 插件)
|
||||
$("#UnderlyingInput").on("input", function () {
|
||||
clearTimeout(suggestTimer);
|
||||
var q = $(this).val();
|
||||
if (!q) { hideSuggest(); return; }
|
||||
suggestTimer = setTimeout(function () { doSuggest(q); }, 250);
|
||||
}).on("focus", function () {
|
||||
if ($(this).val()) doSuggest($(this).val());
|
||||
});
|
||||
|
||||
// 点击补全项
|
||||
$("#UnderlyingSuggest").on("click", ".suggest-item", function () {
|
||||
var it = suggestItems[$(this).data("i")];
|
||||
selectUnderlying(it);
|
||||
hideSuggest();
|
||||
});
|
||||
|
||||
// 点击外部关闭补全
|
||||
$(document).on("click", function (e) {
|
||||
if (!$(e.target).closest("#UnderlyingInput, #UnderlyingSuggest").length) hideSuggest();
|
||||
});
|
||||
});
|
||||
|
||||
function doSuggest(q) {
|
||||
$.ajax({
|
||||
url: "/eodPrice/UnderlyingSuggestForEod",
|
||||
type: "POST",
|
||||
data: { q: q },
|
||||
success: function (res) {
|
||||
suggestItems = (res && res.obj) || [];
|
||||
var box = $("#UnderlyingSuggest").empty();
|
||||
if (!suggestItems.length) {
|
||||
box.append("<div class='suggest-empty'>未找到匹配标的</div>").show();
|
||||
return;
|
||||
}
|
||||
$.each(suggestItems, function (i, x) {
|
||||
var label = (x.Code || "") + " " + (x.Name || "") + " [" + (x.InstrumentType || "") + "]";
|
||||
$("<div class='suggest-item'></div>")
|
||||
.text(label)
|
||||
.data("i", i)
|
||||
.appendTo(box);
|
||||
});
|
||||
box.show();
|
||||
},
|
||||
error: function () { hideSuggest(); }
|
||||
});
|
||||
}
|
||||
|
||||
function hideSuggest() {
|
||||
$("#UnderlyingSuggest").hide().empty();
|
||||
}
|
||||
|
||||
function selectUnderlying(it) {
|
||||
$("#UnderlyingInput").val((it.Code || "") + " " + (it.Name || ""));
|
||||
$("#UnderlyingCode").val(it.Code);
|
||||
$("#bond_id").val(it.Code);
|
||||
$("#UnderlyingId").val(it.Id);
|
||||
$("#UnderlyingInstrumentType").val(it.InstrumentType);
|
||||
$("#MarketDisplay").val(it.Market);
|
||||
$("#CodeDisplay").val(it.Code);
|
||||
showGroupForType(it.InstrumentType);
|
||||
}
|
||||
|
||||
// 根据标的类型显示对应的字段组
|
||||
function showGroupForType(type) {
|
||||
$(".price-group").hide();
|
||||
activeGroup = null;
|
||||
var t = (type || "").toLowerCase();
|
||||
var g = null;
|
||||
if (t.indexOf("bond") >= 0) g = "#bondFields";
|
||||
else if (t.indexOf("future") >= 0) g = "#futureFields";
|
||||
else if (t.indexOf("stock") >= 0) g = "#stockFields";
|
||||
|
||||
if (g) {
|
||||
$(g).show();
|
||||
activeGroup = g;
|
||||
} else {
|
||||
main.message("该标的类型(" + type + ")暂不支持新增日终价格");
|
||||
}
|
||||
}
|
||||
|
||||
function checkSubmitData() {
|
||||
if (!$("#UnderlyingCode").val() || !$("#UnderlyingInstrumentType").val()) {
|
||||
main.message("请先选择标的");
|
||||
return false;
|
||||
}
|
||||
if (!activeGroup) {
|
||||
main.message("该标的类型不支持新增");
|
||||
return false;
|
||||
}
|
||||
// 仅校验当前字段组的必填项(估值日期/日期)
|
||||
var ok = true;
|
||||
$(activeGroup + " .req").each(function () {
|
||||
if (!$(this).val()) ok = false;
|
||||
});
|
||||
if (!ok) {
|
||||
main.message("请填写估值日期");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function saveEodPrice() {
|
||||
if (!checkSubmitData()) return false;
|
||||
|
||||
// 禁用非激活字段组,避免其输入串入表单(disabled 不会进 serialize)
|
||||
$(".price-group").not(activeGroup).find("input,select").prop("disabled", true);
|
||||
|
||||
var type = $("#UnderlyingInstrumentType").val();
|
||||
var t = type.toLowerCase();
|
||||
var url;
|
||||
if (t.indexOf("bond") >= 0) url = "/eodPrice/EodBondPriceEditJson";
|
||||
else if (t.indexOf("future") >= 0) url = "/eodPrice/EodFuturePriceEditJson";
|
||||
else url = "/eodPrice/EodStockPriceEditJson";
|
||||
|
||||
var data = $("#form1").serialize();
|
||||
$(".price-group").not(activeGroup).find("input,select").prop("disabled", false);
|
||||
|
||||
main.post(url, data).done(function (res) {
|
||||
if (res && res.success === false) {
|
||||
main.message(res.msg || "保存失败");
|
||||
return;
|
||||
}
|
||||
var encId = res && res.obj ? res.obj.EncryptId : "";
|
||||
// 规整成视图路由认的字符串(与 EodPriceView 的分支一致)
|
||||
var viewType = "bond";
|
||||
if (t.indexOf("future") >= 0) viewType = "CommodityFutures";
|
||||
else if (t.indexOf("stock") >= 0) viewType = "Stock";
|
||||
window.location.href = "/eodPrice/eodPriceview?enid=" + encId + "&UnderlyingInstrumentType=" + viewType;
|
||||
if (parent && parent.reloadData) parent.reloadData();
|
||||
}).fail(function (xhr) {
|
||||
main.message("保存失败:" + (xhr.responseJSON && xhr.responseJSON.msg ? xhr.responseJSON.msg : xhr.statusText));
|
||||
});
|
||||
}
|
||||
</script>
|
||||
}
|
||||
|
||||
<form class="yc-panel" id="form1" method="post" onsubmit="return false;">
|
||||
|
||||
<input type="hidden" name="id" id="id" value="0" />
|
||||
<input type="hidden" name="EncryptId" id="EncryptId" value="" />
|
||||
<input type="hidden" name="UnderlyingCode" id="UnderlyingCode" />
|
||||
<input type="hidden" name="bond_id" id="bond_id" />
|
||||
<input type="hidden" name="UnderlyingId" id="UnderlyingId" />
|
||||
<input type="hidden" name="UnderlyingInstrumentType" id="UnderlyingInstrumentType" />
|
||||
|
||||
<h4>日终价格新增</h4>
|
||||
|
||||
<div style="margin-top:20px; position:relative;">
|
||||
<div class='form-group col-md-6'>
|
||||
<label class='formlabel'>标的</label>
|
||||
<input id="UnderlyingInput" class='text-box' placeholder="输入代码/名称搜索,如 600000 或 国债" autocomplete="off" />
|
||||
<div id="UnderlyingSuggest" class="suggest-box" style="display:none;"></div>
|
||||
</div>
|
||||
<div class='form-group col-md-6'>
|
||||
<label class='formlabel'>市场</label>
|
||||
<input id="MarketDisplay" class='text-box' type='text' readonly=readonly />
|
||||
</div>
|
||||
<div class='form-group col-md-6'>
|
||||
<label class='formlabel'>标的代码</label>
|
||||
<input id="CodeDisplay" class='text-box' type='text' readonly=readonly />
|
||||
</div>
|
||||
|
||||
@* 债券字段组 *@
|
||||
<div id="bondFields" class="price-group" style="display:none;width:100%;">
|
||||
<div class='form-group col-md-6'>
|
||||
<label class='formlabel'>估值日期</label>
|
||||
<input class='text-box datepicker req' type='text' name='valuation_date' />
|
||||
</div>
|
||||
<div class='form-group col-md-6'>
|
||||
<label class='formlabel'>全价</label>
|
||||
<input class='text-box' type='text' name='dirty_price_close' />
|
||||
</div>
|
||||
<div class='form-group col-md-6'>
|
||||
<label class='formlabel'>净价</label>
|
||||
<input class='text-box' type='text' name='net_price' />
|
||||
</div>
|
||||
<div class='form-group col-md-6'>
|
||||
<label class='formlabel'>收益率</label>
|
||||
<input class='text-box' type='text' name='yield' />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@* 商品期货字段组 *@
|
||||
<div id="futureFields" class="price-group" style="display:none;width:100%;">
|
||||
<div class='form-group col-md-6'>
|
||||
<label class='formlabel'>估值日期</label>
|
||||
<input class='text-box datepicker req' type='text' name='ValueDate' />
|
||||
</div>
|
||||
<div class='form-group col-md-6'>
|
||||
<label class='formlabel'>收盘价</label>
|
||||
<input class='text-box' type='text' name='ClosePrice' />
|
||||
</div>
|
||||
<div class='form-group col-md-6'>
|
||||
<label class='formlabel'>结算价</label>
|
||||
<input class='text-box' type='text' name='SettlePrice' />
|
||||
</div>
|
||||
<div class='form-group col-md-6'>
|
||||
<label class='formlabel'>参考价</label>
|
||||
<input class='text-box' type='text' name='ReferencePrice' />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@* 股票字段组 *@
|
||||
<div id="stockFields" class="price-group" style="display:none;width:100%;">
|
||||
<div class='form-group col-md-6'>
|
||||
<label class='formlabel'>估值日期</label>
|
||||
<input class='text-box datepicker req' type='text' name='ValueDate' />
|
||||
</div>
|
||||
<div class='form-group col-md-6'>
|
||||
<label class='formlabel'>收盘价</label>
|
||||
<input class='text-box' type='text' name='ClosePrice' />
|
||||
</div>
|
||||
<div class='form-group col-md-6'>
|
||||
<label class='formlabel'>参考价</label>
|
||||
<input class='text-box' type='text' name='ReferencePrice' />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="padding:10px;padding-left:130px;">
|
||||
<button class="btn btn-primary" type="button" onclick="saveEodPrice();">保存</button>
|
||||
<button class="btn btn-primary" type="button" onclick="layer.closeMe();">关闭</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -2,11 +2,11 @@
|
||||
@{
|
||||
ViewBag.Title = "日终股票价格 | 编辑";
|
||||
Layout = "~/Views/Shared/_InfoLayout.cshtml";
|
||||
bool isNew = ViewBag.IsNew != null && (bool)ViewBag.IsNew;
|
||||
}
|
||||
@section JS
|
||||
{
|
||||
<script type="text/javascript">
|
||||
var submitclick_eod_Stock_Price = false;
|
||||
$(function () {
|
||||
$(".datepicker").datepicker({ changeMonth: true, changeYear: true, showButtonPanel: true, showOtherMonths: true, selectOtherMonths: true });
|
||||
$(".form-group").addClass("col-md-6");
|
||||
@@ -17,16 +17,23 @@
|
||||
return pass;
|
||||
}
|
||||
|
||||
function onStockPicked() {
|
||||
var sel = document.getElementById('StockPicker');
|
||||
var opt = sel.options[sel.selectedIndex];
|
||||
document.getElementById('UnderlyingCode').value = opt.getAttribute('data-code') || opt.value;
|
||||
document.getElementById('MarketBox').value = opt.getAttribute('data-market') || '';
|
||||
// 手工输入股票代码后失焦:校验标的存在且已上市,并带出市场
|
||||
function lookupStock() {
|
||||
var el = document.getElementById('UnderlyingCode');
|
||||
if (!el) return;
|
||||
var code = (el.value || '').trim();
|
||||
var mk = document.getElementById('MarketBox');
|
||||
if (!code) { if (mk) mk.value = ''; return; }
|
||||
main.post("/eodPrice/LookupUnderlyingForEod", { code: code, kind: 'stock' }).done(function (res) {
|
||||
el.value = res.obj.Code;
|
||||
if (mk) mk.value = res.obj.Market || '';
|
||||
});
|
||||
}
|
||||
|
||||
function saveeod_Stock_Price() {
|
||||
if (document.getElementById('StockPicker') && !document.getElementById('UnderlyingCode').value) {
|
||||
main.message('请先选择股票标的'); return false;
|
||||
var el = document.getElementById('UnderlyingCode');
|
||||
if (el && !(el.value || '').trim()) {
|
||||
main.message('请输入股票标的代码'); return false;
|
||||
}
|
||||
if (!checkSubmitData()) return false;
|
||||
var data = $("#form1").serialize();
|
||||
@@ -41,24 +48,21 @@
|
||||
|
||||
<input type="hidden" value="@Model.id" name="id" id="id" />
|
||||
<input type="hidden" value="@Model.EncryptId" name="EncryptId" id="EncryptId" />
|
||||
<input type="hidden" name="UnderlyingCode" value="@(Model.UnderlyingCode)" />
|
||||
@if (!isNew)
|
||||
{
|
||||
<input type="hidden" name="UnderlyingCode" value="@(Model.UnderlyingCode)" />
|
||||
}
|
||||
<input type="hidden" name="HighPrice" value="@(Model.HighPrice)" />
|
||||
<input type="hidden" name="LowPrice" value="@(Model.LowPrice)" />
|
||||
|
||||
<h4>日终股票价格修改</h4>
|
||||
|
||||
<div style="margin-top:20px;">
|
||||
@if (ViewBag.IsNew != null && (bool)ViewBag.IsNew)
|
||||
@if (isNew)
|
||||
{
|
||||
<div class='form-group col-md-6'>
|
||||
<label class='formlabel'>标的</label>
|
||||
<select class='text-box' id="StockPicker" onchange="onStockPicked()">
|
||||
<option value="">-- 请选择股票标的 --</option>
|
||||
@foreach (var u in (List<YLErp.Web.Controllers.UnderlyingOptionVm>)ViewBag.UnderlyingOptions)
|
||||
{
|
||||
<option value="@u.Code" data-code="@u.Code" data-market="@u.Market">@u.Code @u.Name</option>
|
||||
}
|
||||
</select>
|
||||
<label class='formlabel'>标的代码</label>
|
||||
<input class='text-box' type='text' id="UnderlyingCode" name="UnderlyingCode" value="" onblur="lookupStock()" placeholder="输入股票代码,失焦自动带出市场" />
|
||||
</div>
|
||||
<div class='form-group col-md-6'>
|
||||
<label class='formlabel'>市场</label>
|
||||
|
||||
Reference in New Issue
Block a user