164 lines
6.0 KiB
JavaScript
164 lines
6.0 KiB
JavaScript
if (ylotc.varieties) {
|
|
_.pullAllBy(ylotc.varieties, [{ Code: "组合标的" }, { Code: "篮子标的" }], "Code")
|
|
}
|
|
|
|
(function () {
|
|
|
|
_.each(page.Model, (val, key) => {
|
|
(typeof val === 'undefined' || val === null) && (page.Model[key] = '');
|
|
});
|
|
|
|
let updownLimit = page.Model.UpDownLimit;
|
|
page.Model.UpDownLimitType = !updownLimit || updownLimit.endsWith("%") ? 'P' : 'F';
|
|
|
|
}());
|
|
|
|
|
|
const consSelect = ['MarketCode', 'UnderlyingInstrumentType', 'UnderlyingState', 'UnderlyingStatus', 'UpDownLimitType', 'EtfSubType'];
|
|
|
|
var autoUpDownLimit, autoVariety;
|
|
|
|
$(function () {
|
|
|
|
$(".datepicker").datepicker({
|
|
changeMonth: true,
|
|
changeYear: true,
|
|
showButtonPanel: true,
|
|
showOtherMonths: true,
|
|
selectOtherMonths: true
|
|
});
|
|
if (!page.showDeltaS_S) {
|
|
$('#DeltaS_S').parent().hide();
|
|
}
|
|
FastVue.numberInput(document.getElementById('MarginRate'), { precision: 2, append: '%' });
|
|
FastVue.numberInput(document.getElementById('DeltaS_S'), { precision: 2, append: '%' });
|
|
FastVue.numberInput(document.getElementById('VolatilityRate'), { precision: 2, append: '%' });
|
|
FastVue.numberInput(document.getElementById('BondCouponRate'), { precision: 2, append: '%' });
|
|
FastVue.numberInput(document.getElementById('Spread'), { precision: 2 });
|
|
FastVue.numberInput(document.getElementById('SpreadM'), { precision: 2 });
|
|
FastVue.numberInput(document.getElementById('VolumeMin'), { precision: 0 });
|
|
FastVue.numberInput(document.getElementById('VolumeMax'), { precision: 0 });
|
|
FastVue.numberInput(document.getElementById('VolumeStep'), { precision: 0 });
|
|
FastVue.numberInput(document.getElementById('VolumeLimit'), { precision: 0 });
|
|
autoUpDownLimit = FastVue.numberInput(document.getElementById('UpDownLimit'), { precision: 2, append: page.Model.UpDownLimitType === 'P' ? '%' : '' });
|
|
autoVariety = FastVue.autocomplete(document.getElementById('UnderlyingTypeId'), {
|
|
valueField: 'id', nameField: 'Name', searchField: ['Name', 'PinYin'],
|
|
lookup: ylotc.varieties
|
|
});
|
|
|
|
for (var i = 1; i <= 5; i++) {
|
|
let datas = ylotc.underlyingBlocks.filter(x => x.Group === i);
|
|
let autoBlock = FastVue.autocomplete(document.getElementById('inputBlock' + i), {
|
|
valueField: 'id', nameField: 'Name', searchField: ['Name', 'PinYin'], lookup: datas
|
|
});
|
|
let blockId = page.Model['Block' + i];
|
|
let data = blockId ? datas.find(x => x.id === blockId) : null;
|
|
autoBlock.setData(data);
|
|
}
|
|
|
|
//变更Span涨跌幅度输入样式
|
|
$('#UpDownLimitType').on('change', function () {
|
|
autoUpDownLimit.setOptions({ append: $(this).val() === 'P' ? '%' : '' });
|
|
autoUpDownLimit.setValue(0);
|
|
});
|
|
|
|
if (page.Model.id > 0) {
|
|
_.each(consSelect, x => {
|
|
$('#' + x).val(page.Model[x]);
|
|
});
|
|
let vid = page.Model.UnderlyingTypeId || 0;
|
|
let variety = vid ? ylotc.varieties.find(x => x.id === vid) : null;
|
|
autoVariety.setData(variety);
|
|
}
|
|
|
|
//变更资产类型
|
|
$("#UnderlyingInstrumentType").on('change', function () {
|
|
var classType = ""
|
|
switch ($(this).val()) {
|
|
case "Stock":
|
|
case "StockIndex":
|
|
case "NewOtcStock":
|
|
case "HKStock":
|
|
case "HKStockIndex":
|
|
case "AbroadStock":
|
|
case "AbroadStockIndex":
|
|
classType = "Stock";
|
|
break;
|
|
case "StockIF":
|
|
case "CommodityFutures":
|
|
case "GoldFutures":
|
|
case "TBFutures":
|
|
case "OtherFutures":
|
|
case "AbroadFutures":
|
|
classType = "CommodityFutures";
|
|
break;
|
|
case "CommoditySpot":
|
|
case "GoldSpot":
|
|
case "OtherSpot":
|
|
case "AbroadSpot":
|
|
classType = "CommoditySpot";
|
|
break;
|
|
case "TBonds":
|
|
case "CreditBonds":
|
|
case "OtherBonds":
|
|
classType = "Bonds";
|
|
break;
|
|
case "Fund":
|
|
// 重点功能:资产类型为基金及基金专户时,显示所有 Fund 专属字段。
|
|
classType = "Fund";
|
|
break;
|
|
default:
|
|
classType = type;
|
|
break;
|
|
}
|
|
$('#editForm').removeClass("form-None form-Stock form-CommodityFutures form-CommoditySpot form-Bonds form-Fund").addClass("form-" + classType);
|
|
}).trigger('change');
|
|
});
|
|
|
|
function saveData() {
|
|
|
|
var data = $('#editForm').serializeObject();
|
|
|
|
if (!data.UnderlyingCode) {
|
|
return main.alert("标的资产码 必须填写!");
|
|
}
|
|
|
|
if (!data.UnderlyingName) {
|
|
return main.alert("标的名称 必须填写!");
|
|
}
|
|
|
|
if (!data.UnderlyingInstrumentType) {
|
|
return main.alert("标的资产类型 必须填写!");
|
|
}
|
|
|
|
if (!data.UnderlyingTypeId) {
|
|
return main.alert("资产品种类型 必须填写!");
|
|
}
|
|
|
|
// 重点功能:基金及基金专户必须填写基金管理人,空格内容也视为未填写。
|
|
if (data.UnderlyingInstrumentType === "Fund" &&
|
|
(!data.InvestAdvisorName || !data.InvestAdvisorName.trim())) {
|
|
return main.alert("基金管理人 必须填写!");
|
|
}
|
|
|
|
// 重点功能:ETF 子类只对基金及基金专户显示并必填,先在前端阻止无效提交。
|
|
if (data.UnderlyingInstrumentType === "Fund" && !data.EtfSubType) {
|
|
return main.alert("ETF 子类 必须填写!");
|
|
}
|
|
|
|
if (data.UnderlyingInstrumentType === "CommodityFutures" && !data.MaturityDate) {
|
|
return main.alert("到期日 必须填写!");
|
|
}
|
|
|
|
data = $.extend(page.Model, data);
|
|
|
|
["MarginRate", "Bond.CouponRate", 'DeltaS_S'].forEach(k => {
|
|
data[k] = data[k] ? (parseFloat(data[k]) || 0) / 100 : null;
|
|
});
|
|
|
|
main.post("/underlying_manager/underlying_managerEditJson", data).done(function (resp) {
|
|
main.parentReloadData();
|
|
window.location.href = "/underlying_manager/underlying_managerView?enid=" + resp.obj.EncryptId;
|
|
});
|
|
}
|