Files
zszq-trs/YLErpWeb/Views/UnderlyingSpanTwo/Edit.cshtml
T
2024-05-09 14:06:26 +08:00

167 lines
6.7 KiB
Plaintext

@model UnderlyingSpanTwoDto
@{
Layout = "~/Views/Shared/_InfoLayout.cshtml";
var autocomplete = string.IsNullOrEmpty(Model.UnderlyingCode);
var isGFSM = PS.Config.Company == CompanyEnum.广发商贸;
}
@section JS{
<script src="~/Statics/libs/input/cleave.min.js?v=@(HtmlUtil.JsVersion)"></script>
<script>
const fmtSpanRate = otcformat.fixed2;
</script>
@if (autocomplete)
{
@if(isGFSM){
<script src="~/front/BasicData?types=广发商贸标的信息&t=@(DateTime.Now.Ticks)"></script>
<script>
$(function () {
var suggestions = [];
_.each(ylotc.gfunderlyings, function (item) {
suggestions.push({ value: item.Code, data: item.Code, name: item.Name });
});
$('#UnderlyingCode').autocomplete({
lookup: suggestions,
onSelect: function (suggestion) {
var code = suggestion.value;
if ($('#UnderlyingCode').data('suggestion') === code) {
return;
}
$('#UnderlyingCode').data('suggestion', code);
$('#UnderlyingName').text(suggestion.name);
$.post("/UnderlyingSpanTwo/AjaxGetDetail", { underlyingCode: code }).done(function (resp) {
resp = resp.obj;
if (resp !== null || resp !== 'undefined') {
$('#SpanRate').val(fmtSpanRate(resp.SpanRate * 100));
}
});
}
});
});
</script>
}
else{
<script src="~/front/BasicData?types=标的信息&t=@(DateTime.Now.Ticks)"></script>
<script>
$(function () {
var suggestions = [];
_.each(ylotc.underlyings, function (item) {
suggestions.push({ value: item.Code, data: item.Code, name: item.Name });
});
$('#UnderlyingCode').autocomplete({
lookup: suggestions,
onSelect: function (suggestion) {
var code = suggestion.value;
if ($('#UnderlyingCode').data('suggestion') === code) {
return;
}
$('#UnderlyingCode').data('suggestion', code);
$('#UnderlyingName').text(suggestion.name);
$.post("/UnderlyingSpanTwo/AjaxGetDetail", { underlyingCode: code }).done(function (resp) {
resp = resp.obj;
if (resp !== null || resp !== 'undefined') {
$('#SpanRate').val(fmtSpanRate(resp.SpanRate * 100));
}
});
}
});
});
</script>
}
}
<script>
$(function () {
new Cleave('#SpanRate', {
numeral: true,
numeralDecimalScale: 2,
numeralIntegerScale: 6
});
});
function saveData() {
var data = {
UnderlyingCode: $.trim($('#UnderlyingCode').val()),
SpanRate: parseFloat($('#SpanRate').val()) / 100 || 0
};
if (!data.UnderlyingCode) {
return main.alert("请填写标的代码");
}
if (isNaN(data.SpanRate)) {
return main.alert("请填写正确的Span涨跌幅");
}
main.post("/UnderlyingSpanTwo/AjaxSaveData", data).done(function (res) {
if (typeof window.parent.SearchClick === 'function')
window.parent.SearchClick();
});
}
</script>
}
@section CSS{
<style>
.container { max-width: 100%; }
.table > tbody > tr > td { text-align: left; }
.form-autorule { max-width: 200px; display: inline; margin-right: 4px; }
.form-check { width: 19px; height: 19px; vertical-align: bottom; margin-right: 2px !important; }
.autocomplete-suggestions { overflow: auto; border: 1px solid #CBD3DD; background: #FFF; }
.autocomplete-suggestion { overflow: hidden; padding: 5px 15px; white-space: nowrap; }
.autocomplete-selected { background: #F0F0F0; }
.autocomplete-suggestions strong { color: #029cca; font-weight: normal; }
.table > tbody > tr > td, .table > tbody > tr > th { border: 0; }
.table th{width:135px;}
</style>
}
<form id="form1" method="post" onsubmit="return false;" autocomplete="off">
<div class="yc-panel">
<table class="table table-noborder" style="width:100%;">
<colgroup>
<col span="1" width="120" />
<col span="1" />
</colgroup>
<tbody>
<tr>
<th>标的代码:</th>
<td>
@if (autocomplete)
{
<input type="text" name="UnderlyingCode" id="UnderlyingCode" value="@(Model.UnderlyingCode)" class="form-control form-autorule" />
}
else
{
<span>@(Model.UnderlyingCode)</span>
<input type="hidden" name="UnderlyingCode" id="UnderlyingCode" value="@(Model.UnderlyingCode)" />
}
</td>
</tr>
<tr>
<th>标的名称:</th>
<td><span id="UnderlyingName">@(Model.UnderlyingName)</span></td>
</tr>
<tr>
<th>Span涨跌幅2(%):</th>
<td><input type="text" name="SpanRate" id="SpanRate" value="@((Model.SpanRate != null) ? ((double)Model.SpanRate*100).ToString("F2") : null)" class="form-control form-autorule" />%</td>
</tr>
<tr>
<td colspan="2" style="padding:20px 0 0 120px;">
<button type="button" class="btn btn-primary" onclick="saveData()">保存</button>
<button type="button" class="btn btn-primary" onclick="layer.closeMe()">关闭</button>
</td>
</tr>
</tbody>
</table>
</div>
</form>