1216 lines
56 KiB
JavaScript
1216 lines
56 KiB
JavaScript
const consClients = ylotc.clients;
|
|
const consTraders = pageData.traderList;
|
|
const consAssetUnits = pageVue.CanSelectTrader ? ylotc.assetunits
|
|
: ylotc.assetunits.filter(x => x.TraderIds.includes(pageVue.Trade.TraderId));
|
|
|
|
const consUnderlyingFlag = function (tradeType) {
|
|
let unSelFlag = tradeHelper.UnderlyingSelectFlag;
|
|
let flag = unSelFlag.UseForTrading | unSelFlag.IncludeMatured | unSelFlag.CheckLaunch | unSelFlag.IncludeSynthetic;
|
|
switch (tradeType) {
|
|
case '合成价差期权': return flag | unSelFlag.OnlySynthetic;
|
|
case '自定义交易': return flag | unSelFlag.UsePinYinFilter | unSelFlag.IncludeSynthetic;
|
|
default: return flag | unSelFlag.UsePinYinFilter;
|
|
}
|
|
};
|
|
const customNumberFormat = { precision: 6, negative: true, };
|
|
const customNumberPercentFormat = { precision: 6, negative: true, append: '%' };
|
|
|
|
var autoVariety, autoUnderlying, salesCommissionCtrl;
|
|
|
|
pageVue.getVolType = function () { return '交易'; };
|
|
|
|
var autoMarginTemplateName;
|
|
|
|
function __init(vue) {
|
|
|
|
if (pageVue.Trade.TradeType !== "现金流交易") {
|
|
//标的品种
|
|
autoVariety = FastVue.autocomplete(document.getElementById('VarietyId'), {
|
|
lookup: ylotc.varieties, nameField: 'Name', valueField: 'id', searchField: ['Name', 'Code', 'PinYin'],
|
|
onSelect: function (data) { vue.changeVariety(data, 'select'); }
|
|
});
|
|
autoVariety.toggleDisabled(vue.trade.TradeType === '合成价差期权');
|
|
autoVariety.toggleDisabled(vue.trade.IsGroup === 2);
|
|
|
|
//标的资产
|
|
autoUnderlying = tradeHelper.UnderlyingAutoComplete('UnderlyingCode', { BlackLimit: 1 })
|
|
.setFlag(consUnderlyingFlag(vue.trade.TradeType));
|
|
autoUnderlying.onSelect(vue.changeUnderlying);
|
|
|
|
//组合标的控件
|
|
if (!pageVue.IsCheck) {
|
|
synthenticPriceCtrl.init({
|
|
getSynthetic(input) {
|
|
return vue.viewState.synthetic;
|
|
},
|
|
setSynthetic(input, synthetic) {
|
|
vue.viewState.synthetic = synthetic;
|
|
vue.trade.SpotPrice = synthetic.Price;
|
|
vue.changeSpotPrice();
|
|
}
|
|
});
|
|
}
|
|
|
|
//标的控件初始化
|
|
if (vue.trade.UnderlyingCode) {
|
|
autoUnderlying.selectByCode(vue.trade.UnderlyingCode);
|
|
}
|
|
else {
|
|
autoUnderlying.selectFirst();
|
|
}
|
|
}
|
|
|
|
//交易员
|
|
if (pageVue.CanSelectTrader) {
|
|
autoTrader = FastVue.autocomplete(document.getElementById('TraderId'), {
|
|
nameField: 'Name', valueField: 'id', searchField: ['Name', 'PinYin'], lookup: consTraders,
|
|
onSelect(data) {
|
|
vue.trade.TraderId = data.id;
|
|
vue.trade.TraderName = data.Name;
|
|
}
|
|
});
|
|
let traderId = pageVue.Trade.TraderId;
|
|
let trader = traderId ? consTraders.find(x => x.id === traderId) : null;
|
|
//if (!trader && pageVue.IsNew) {
|
|
// trader = consTraders[0];
|
|
// trader && (vue.trade.TraderId = trader.id);
|
|
//}
|
|
autoTrader.setData(trader);
|
|
}
|
|
|
|
//簿记账户
|
|
let autoAssetUnit = FastVue.autocomplete(document.getElementById('AssetId'), {
|
|
nameField: 'Name', valueField: 'id', searchField: ['Name', 'PinYin'], lookup: consAssetUnits,
|
|
onSelect(data) {
|
|
vue.trade.AssetId = data.id;
|
|
}
|
|
});
|
|
let assetId = pageVue.Trade.AssetId;
|
|
let asset = assetId ? consAssetUnits.find(x => x.id === assetId) : null;
|
|
if (!asset && pageVue.IsNew) {
|
|
asset = consAssetUnits[0];
|
|
asset && (vue.trade.AssetId = asset.id);
|
|
}
|
|
autoAssetUnit.setData(asset);
|
|
|
|
if (pageVue.Trade.TradeType !== "现金流交易" && pageVue.Trade.TradeType !== "自定义交易") {
|
|
//预付金模板
|
|
autoMarginTemplateName = FastVue.autocomplete(document.getElementById('MarginTemplateName'), {
|
|
nameField: 'Text', valueField: 'Value', searchField: ['Text'], lookup: pageData.tradeMarginTemplateItems,
|
|
onSelect(data) {
|
|
vue.trade.MarginTemplateName = data.Value;
|
|
vue.changeMarginTemplate();
|
|
}
|
|
});
|
|
|
|
let marginTemplateName = pageVue.Trade.MarginTemplateName;
|
|
let marginTemplate = marginTemplateName ? pageData.tradeMarginTemplateItems.find(x => x.Value === marginTemplateName) : null;
|
|
if (!marginTemplate && pageVue.IsNew) {
|
|
marginTemplate = pageData.tradeMarginTemplateItems[0];
|
|
marginTemplate && (vue.trade.MarginTemplateName = marginTemplate.Value);
|
|
}
|
|
autoMarginTemplateName.setData(marginTemplate);
|
|
}
|
|
salesCommissionCtrl = new SalesCommissionCtrl(document.getElementById('salesCommissionCtrl'), pageVue.Trade.SalesCommission);
|
|
|
|
//客户名称
|
|
if (pageVue.CanSelectClient || pageVue.IsCheck) {
|
|
var width = 152;
|
|
for (var i = 0; i < consClients.length; i++) {
|
|
let ele = document.createElement('span')
|
|
ele.innerText = consClients[i].Name;
|
|
ele.style.fontSize = '14px';
|
|
document.documentElement.append(ele);
|
|
var charLength = ele.offsetWidth + 28;//滚动条
|
|
document.documentElement.removeChild(ele);
|
|
if (charLength > width) {
|
|
width = charLength
|
|
}
|
|
}
|
|
let autoClient = FastVue.autocomplete(document.getElementById('ClientId'), {
|
|
nameField: 'Name', valueField: 'id', searchField: ['Name', 'PinYin'], width: width,
|
|
lookup: consClients, onSelect: vue.changeClient
|
|
});
|
|
let clientId = pageVue.Trade.ClientId;
|
|
let client = clientId ? consClients.find(x => x.id === clientId) : null;
|
|
!client && pageVue.IsNew && (client = consClients[0]);
|
|
autoClient.setData(client);
|
|
vue.changeClient(client);
|
|
}
|
|
|
|
|
|
pageVue.DiffList.forEach(function (curValue) {
|
|
$(`[name='${curValue}']`).closest('.form-group').append('<span class="fa fa-remove not-match ml-1" style="float: right;position: absolute;top: 9px;"></span>');
|
|
});
|
|
|
|
}
|
|
|
|
//单个定价组件
|
|
const vue = new Vue({
|
|
el: '#tradeEditForm',
|
|
data: {
|
|
..._.cloneDeep(tradeFieldMgr.defaultData),
|
|
...consVueTrade.data(),
|
|
structureTypes: pageData.structureTypes,
|
|
PropertyMap: pageData.PropertyMap,
|
|
fieldState: tradeFieldMgr.getFieldState(),
|
|
tradeMarginTemplates: pageData.tradeMarginTemplates,
|
|
clientCanSell: true,
|
|
binaryPayoffTypes: pageVue.Trade.ExerciseMode === 'European' ?
|
|
consBinaryPayoffTypes.European : consBinaryPayoffTypes.American,
|
|
ExtendMap: pageData.ExtendMap,
|
|
|
|
ExtendInfos: pageVue.Trade.MetaDic["自定义要素模板"] || "",
|
|
|
|
is宏源: pageData.is宏源,
|
|
isShowActualExerciseDate: false,
|
|
codes: [],
|
|
|
|
changePrepaymentUsedDateTime:0
|
|
},
|
|
watch: {
|
|
'trade.TradeType': {
|
|
handler(newVal, oldVal) {
|
|
this.fieldState.onTradeTypeChanged(this.trade, oldVal, this);
|
|
autoVariety && autoVariety.toggleDisabled(this.trade.TradeType === '合成价差期权');
|
|
if (this.trade.TradeType === '现金流交易') {
|
|
this.trade.IsUsePremiumRate = true;
|
|
} else if (this.trade.TradeType === '累计期权') {
|
|
this.trade.IsUsePremiumRate = false;
|
|
if (this.trade.AccumulatorStructureType == '1') {
|
|
this.trade.EarlyTerminate = false;
|
|
if (this.trade.PayoffType === '固定' && this.trade.OptionType === '看涨') {
|
|
this.trade.Multiplier2 = 1;
|
|
this.trade.Multiplier3 = 1;
|
|
}
|
|
if (this.trade.PayoffType === '固定' && this.trade.OptionType === '看跌') {
|
|
this.trade.Multiplier1 = 1;
|
|
this.trade.Multiplier2 = 1;
|
|
}
|
|
}
|
|
}
|
|
},
|
|
immediate: true
|
|
},
|
|
'trade.ExerciseDate': {
|
|
handler(newVal, oldVal) {
|
|
if (this.trade.SettlementDate !== newVal) {
|
|
this.trade.SettlementDate = newVal;
|
|
this.changeIsAnnualized();
|
|
}
|
|
},
|
|
immediate: false
|
|
},
|
|
'trade.AccumulatorStructureType': {
|
|
handler(newVal, oldVal) {
|
|
if (this.trade.AccumulatorStructureType == '1') {
|
|
this.trade.EarlyTerminate = false;
|
|
}
|
|
},
|
|
immediate: false
|
|
},
|
|
'trade.PayoffType': {
|
|
handler(newVal, oldVal) {
|
|
if (this.trade.TradeType == "累计期权" && this.trade.AccumulatorStructureType == '1' && this.trade.PayoffType === '固定') {
|
|
if (this.trade.OptionType === '看涨') {
|
|
this.trade.Multiplier = 1;
|
|
this.trade.Multiplier2 = 1;
|
|
this.trade.Multiplier3 = 1;
|
|
}
|
|
if (this.trade.OptionType === '看跌') {
|
|
this.trade.Multiplier = 1;
|
|
this.trade.Multiplier2 = 1;
|
|
this.trade.Multiplier3 = 1;
|
|
}
|
|
}
|
|
},
|
|
immediate: false
|
|
},
|
|
'trade.OptionType': {
|
|
handler(newVal, oldVal) {
|
|
if (this.trade.TradeType == "累计期权" && this.trade.AccumulatorStructureType == '1' && this.trade.PayoffType === '固定') {
|
|
if (this.trade.OptionType === '看涨') {
|
|
this.trade.Multiplier = 1;
|
|
this.trade.Multiplier2 = 1;
|
|
this.trade.Multiplier3 = 1;
|
|
}
|
|
if (this.trade.OptionType === '看跌') {
|
|
this.trade.Multiplier = 1;
|
|
this.trade.Multiplier2 = 1;
|
|
this.trade.Multiplier3 = 1;
|
|
}
|
|
}
|
|
},
|
|
immediate: false
|
|
},
|
|
'trade.UnderlyingCode': {
|
|
handler(newVal, oldVal) {
|
|
this.IsCodesExistsCommoditySpot(newVal);
|
|
|
|
},
|
|
immediate: false
|
|
}
|
|
},
|
|
created: consVueTrade.created,
|
|
mounted() {
|
|
pageVue.IsNew && !pageVue.fake_edit && (this.updateKey.underlying = 1);
|
|
this.trade.CalcId = this.trade.id.toString();
|
|
|
|
__init(this);
|
|
$("#MainProtocolCode").val(this.trade.MetaDic["主协议编号"]);
|
|
consVueTrade.methods.changeMainProtocolCode();
|
|
$("#SupProtocolCode").val(this.trade.MetaDic["补充协议编号"]);
|
|
this.changeBuySell(false, false);
|
|
window.saveTrade3 = this.saveTrade3;
|
|
|
|
//观察频率赋值
|
|
this.assObservationRate();
|
|
|
|
this.IsCodesExistsCommoditySpot(this.trade.UnderlyingCode);
|
|
},
|
|
methods: {
|
|
...consVueTrade.methods,
|
|
//变更买入卖出
|
|
changeBuySellEx() {
|
|
if (this.trade.BuySell === "买入") {
|
|
if (pageData.highVolLimit && pageData.highVolLimit !== "0") {
|
|
$("#TradeOpenVolatilityTip").show();
|
|
$("#TradeOpenVolatilityTip").text("不高于 " + numeral(pageData.highVolLimit).format("0,0.00%"));
|
|
}
|
|
else {
|
|
$("#TradeOpenVolatilityTip").hide();
|
|
}
|
|
}
|
|
else {
|
|
if (pageData.lowVolLimit && pageData.lowVolLimit !== "0") {
|
|
$("#TradeOpenVolatilityTip").show();
|
|
$("#TradeOpenVolatilityTip").text("不低于 " + numeral(pageData.lowVolLimit).format("0,0.00%"));
|
|
} else {
|
|
$("#TradeOpenVolatilityTip").hide();
|
|
}
|
|
}
|
|
},
|
|
//变更客户
|
|
changeClient(yldata) {
|
|
let client = yldata || { id: 0 };
|
|
|
|
this.trade.MetaDic["中央对手方清算"] = client.IsCentralClearing;
|
|
this.trade.MetaDic["中央清算平台"] = client.CentralClearingPaltform;
|
|
this.trade.MetaDic["交易平台"] = client.TradingPaltform;
|
|
|
|
$("#selIsCentralClearing").val(client.IsCentralClearing);
|
|
$("#selCentralClearingPaltform").val(client.CentralClearingPaltform);
|
|
$("#selTradingPaltform").val(client.TradingPaltform);
|
|
if (this.trade.StructureType == "牛市价差" || this.trade.StructureType =="熊市价差") {
|
|
client.CanSell = true;
|
|
}
|
|
this.clientCanSell = !!client.CanSell;
|
|
this.trade.ClientId = client.id;
|
|
this.viewState.TwoSideMargin = client.MarginOptionType == 1;
|
|
$('#BuySell').children('.client-sell').prop('disabled', false);
|
|
$('#BuySell').children('.client-buy').prop('disabled', false);
|
|
$('#BuySell').children('.client-sell').prop('disabled', !client.CanSell);
|
|
if (pageData.eecuritiesEnvironment) {
|
|
if (client.AccessRule == 0) {
|
|
$('#BuySell').children('.client-sell').prop('disabled', true);
|
|
$('#BuySell').val("卖出")
|
|
} else if (client.AccessRule == 1) {
|
|
$('#BuySell').children('.client-buy').prop('disabled', true);
|
|
$('#BuySell').val("买入")
|
|
}
|
|
}
|
|
!client.CanSell && (this.trade.BuySell = '卖出');
|
|
this.getMainProtocolCode();
|
|
|
|
if (pageVue.IsNew || this.updateKey.client !== 0) {
|
|
salesCommissionCtrl.changeSalesmen(client.id);
|
|
let data = pageData.tradeMarginTemplateItems[client.MarginOptionType == 3 ? 1 : 0];
|
|
this.trade.MarginTemplateName = data.Value;
|
|
autoMarginTemplateName.setData(data);
|
|
this.changeMarginTemplate();
|
|
}
|
|
$('#ClientId_auto').attr('title', client.Name);
|
|
|
|
this.updateKey.client++;
|
|
},
|
|
synchTrade() {
|
|
//配合东证处理,需要定义一个空方法
|
|
},
|
|
sumTotal() {
|
|
//配合东证处理,需要定义一个空方法
|
|
},
|
|
//变更期权类型
|
|
changeTradeType() {
|
|
this.viewState.Observation.hasValue = false;
|
|
this.viewState.KOObservation.hasValue = false;
|
|
let flag = consUnderlyingFlag(this.trade.TradeType);
|
|
if (this.needUnderlying && autoUnderlying.getFlag() !== flag) {
|
|
autoUnderlying.setFlag(flag);
|
|
autoUnderlying.selectFirst();
|
|
}
|
|
this.changeExerciseMode('TradeType');
|
|
this.trade.StructureType = null;
|
|
if (this.trade.TradeType === "累计期权") {
|
|
this.viewState.MaturityDate = null;
|
|
}
|
|
else {
|
|
this.viewState.MaturityDate = this.viewState.underlying.MaturityDate;
|
|
}
|
|
if (this.trade.TradeType === "Risky期权") {
|
|
tradeUtils.resetRisky(this.trade);
|
|
}
|
|
},
|
|
//变更标的类型
|
|
changeInstrumentType() {
|
|
if (!this.needUnderlying) return;
|
|
let nowTime = new Date().getTime();
|
|
if (nowTime < this.updateKey.variety + 300 || nowTime < this.updateKey.underlying + 300) return;
|
|
this.updateKey.instrumentType = nowTime;
|
|
autoUnderlying.selectFirst({ InstrumentTypes: [this.trade.UnderlyingInstrumentType] });
|
|
},
|
|
//设置标的品种
|
|
changeVariety(variety, flag) {
|
|
if (!this.needUnderlying) return;
|
|
if (flag === 'select') {
|
|
if (this.viewState.variety.id === variety.id) return;
|
|
this.updateKey.variety = new Date().getTime();
|
|
this.trade.UnderlyingInstrumentType = variety.InstrumentType;
|
|
this.trade.QuoteCurrency = this.viewState.variety.QuoteCurrency;
|
|
autoUnderlying.setVarietyId(variety.id);
|
|
Object.assign(this.viewState.underlying, tradeHelper.getEmptyUnderlying(variety.id));
|
|
autoUnderlying.selectFirst(variety.id);
|
|
} else {
|
|
this.trade.QuoteCurrency = variety?.QuoteCurrency;
|
|
autoVariety.setData(variety);
|
|
}
|
|
Object.assign(this.viewState.variety, variety || tradeHelper.getEmptyVariety());
|
|
},
|
|
//变更标的
|
|
changeUnderlying(data) {
|
|
if (!this.needUnderlying) return;
|
|
let trade = this.trade;
|
|
let editFirst = this.updateKey.underlying === 0;
|
|
let instTypeChanged = new Date().getTime() < this.updateKey.instrumentType + 300
|
|
|| trade.UnderlyingInstrumentType !== data.UnderlyingInstrumentType;
|
|
this.updateKey.underlying = new Date().getTime();
|
|
Object.assign(this.viewState.underlying, data);
|
|
if (trade.TradeType === "累计期权") {
|
|
this.viewState.MaturityDate = null;
|
|
}
|
|
else {
|
|
this.viewState.MaturityDate = this.viewState.underlying.MaturityDate;
|
|
}
|
|
trade.UnderlyingId = data.id;
|
|
trade.UnderlyingCode = data.Code;
|
|
$('#UnderlyingCode').attr('title', data.Code);
|
|
data.InstrumentType && (trade.UnderlyingInstrumentType = data.InstrumentType);
|
|
autoUnderlying.setVarietyId(data.VarietyId);
|
|
this.changeVariety(data.VarietyId ? ylotc.varieties.find(x => x.id === data.VarietyId) : null);
|
|
|
|
if (editFirst) {
|
|
if (data.IsSynthetic && !this.viewState.synthetic) {
|
|
this.getSyntheticPrices(data.Code);
|
|
}
|
|
return;
|
|
}
|
|
|
|
let _getSpotPrice = 0;
|
|
if (!pageVue.IsCheck) {
|
|
_getSpotPrice = 1;
|
|
trade.DividendRate = data.DividendRate;
|
|
}
|
|
|
|
//根据标的类型切换
|
|
if (data.InstrumentType === "Stock" || data.InstrumentType === "StockIndex") {
|
|
if (!trade.DividendRate) {
|
|
trade.DividendRate = 0;
|
|
}
|
|
trade.Strike = 1; //股票时权利金默认为百分比
|
|
trade.IsMoneynessOption = '是';
|
|
trade.IsUsePremiumRate = trade.TradeType !== '累计期权';
|
|
} else {
|
|
_getSpotPrice = 2;
|
|
trade.IsMoneynessOption = '否';
|
|
trade.IsUsePremiumRate = false;
|
|
}
|
|
//名义本金 or 成交数量 方式
|
|
if (trade.IsUsePremiumRate) {
|
|
this.changeStockEqvNotional(1e6); //名义本金影响交易数量
|
|
} else {
|
|
this.changeTradeAmount(instTypeChanged ? 1 : null);
|
|
}
|
|
|
|
_getSpotPrice && this.getSpotPrice(_getSpotPrice === 2);
|
|
|
|
instTypeChanged && tradeUtils.onChangeInstrumentType(trade);
|
|
|
|
if (trade.TradeType === "Risky期权") {
|
|
if (trade.IsMoneynessOption === "是") {
|
|
trade.Strike1 = "";
|
|
trade.Strike2 = "";
|
|
trade.Strike3 = 1;
|
|
} else {
|
|
trade.Strike1 = "";
|
|
trade.Strike2 = "";
|
|
trade.Strike3 = trade.SpotPrice;
|
|
}
|
|
}
|
|
|
|
if (data.IsSynthetic) {
|
|
this.getSyntheticPrices(data.Code);
|
|
} else {
|
|
this.viewState.synthetic = null;
|
|
}
|
|
this.changeEffectRatio();
|
|
},
|
|
//权利金计算
|
|
calcPrice() {
|
|
if (this.trade.TradeType == "现金流交易") {
|
|
this.trade.Notional = 1;
|
|
}
|
|
let trade = this.trade;
|
|
if (trade.TradeType === "自定义交易") {
|
|
//trade.TradeOpenVolatility = null;
|
|
//trade.Vol = null;
|
|
trade.ExtendInfo = this.setExtendInfo(trade);
|
|
}
|
|
trade.CountRatio = this.viewState.variety.CountRatio
|
|
let trades = tradeUtils.prepareTrades([trade], pageVue.getVolType(), false);
|
|
if (!trades) return;
|
|
var self = this;
|
|
|
|
main.post("/pricing/ajaxCalcPrice", { trade: trades[0] }).done(function (resp) {
|
|
var calc = resp.obj.calcResult;
|
|
if (trade.IsUsePremiumRate) {
|
|
trade.TradePrice = calc.Pv * (trade.BuySell === "买入" ? 1 : -1);
|
|
tradePricing.tradeCalc(self.trade, tradePricing.calcReason.Pv, self.viewState.variety.CountRatio);
|
|
}
|
|
else {
|
|
var notional = trade.Notional;
|
|
if (trade.TradeType == "累计期权") {
|
|
notional = trade.AccumuTradeAmount;
|
|
var dayCount = 0;
|
|
if (trade.KOObservationDates) {
|
|
dayCount = trade.KOObservationDates.split(";")[0].split(',').length;
|
|
} else {
|
|
var data = {
|
|
alignEnd: "true",
|
|
calcMode: "01",
|
|
endDate: trades[0].ExerciseDate,
|
|
holidayAdjustment: "Following",
|
|
startDate: trades[0].TradeDate,
|
|
termStr: "1D",
|
|
}//获取区间观察日数量;
|
|
main.post("/trade/GetObservationDateList", data, { async: false }).done(
|
|
function (res) {
|
|
dayCount = res.obj.length;
|
|
}
|
|
);
|
|
}
|
|
notional *= dayCount;
|
|
}
|
|
if (notional == 0) {
|
|
trade.TradeSinglePrice = 0;
|
|
} else {
|
|
trade.TradeSinglePrice = trade.Notional ? ((calc.Pv * (trade.BuySell === "买入" ? 1 : -1)) || 0) / notional : 0;
|
|
}
|
|
tradePricing.tradeCalc(self.trade, tradePricing.calcReason.TradeSinglePrice, self.viewState.variety.CountRatio);
|
|
}
|
|
if (trade.TradeType != "现金流交易") {
|
|
if (trade.isTradePricePayType) {
|
|
tradePricing.tradeCalc(self.trade, tradePricing.calcReason.TradePrice, self.viewState.variety.CountRatio);
|
|
} else if (trade.IsUsePremiumRate) {
|
|
tradePricing.tradeCalc(self.trade, tradePricing.calcReason.PremiumRate, self.viewState.variety.CountRatio);
|
|
} else {
|
|
tradePricing.tradeCalc(self.trade, tradePricing.calcReason.TradeSinglePrice, self.viewState.variety.CountRatio);
|
|
}
|
|
}
|
|
|
|
trade.Day1Pnl = pricingFormat.tradePrice(resp.obj.Day1Pnl);
|
|
});
|
|
},
|
|
setRemark(callback, trade, flag) {
|
|
if (pageData.needRemark) {
|
|
$("#extendInfo #editRemarks").val("");
|
|
layer.open({
|
|
type: 1,
|
|
title: "请填写修改说明",
|
|
shadeClose: false,
|
|
shade: 0.4,
|
|
area: ['600px', '280px'],
|
|
content: $("#extendInfo"),
|
|
btn: ['保存', '取消'],
|
|
yes: function (index, layero) {
|
|
var remark = $("#extendInfo #editRemarks").val();
|
|
if (!remark) {
|
|
main.alert("交易编辑时,说明为必填字段");
|
|
return;
|
|
}
|
|
trade.MetaDic["remark"] = remark;
|
|
callback(trade, flag);
|
|
layer.close(index);
|
|
},
|
|
cancel: function (index, layero) {
|
|
layer.close(index);
|
|
}
|
|
});
|
|
} else {
|
|
callback(trade, flag);
|
|
}
|
|
},
|
|
saveTrade(tradeObj, flag) {
|
|
let trade = {};
|
|
if (!flag) {
|
|
this.viewState.synthetic && (this.trade.MetaDic["组合标的"] = JSON.stringify(this.viewState.synthetic));
|
|
this.trade.MetaDic["主协议编号"] = $("#MainProtocolCode").val();
|
|
this.trade.MetaDic["补充协议编号"] = $("#SupProtocolCode").val();
|
|
|
|
this.trade.MetaDic["中央对手方清算"] = $("#selIsCentralClearing").val();
|
|
this.trade.MetaDic["中央清算平台"] = $("#selCentralClearingPaltform").val();
|
|
this.trade.MetaDic["交易平台"] = $("#selTradingPaltform").val();
|
|
|
|
let trades = tradeUtils.prepareTrades([this.trade], pageVue.getVolType(), true, false, this.isShowActualExerciseDate);
|
|
if (!trades) return;
|
|
if (salesCommissionCtrl) {
|
|
trades[0].SalesCommission = salesCommissionCtrl.getValue();
|
|
}
|
|
this.setRemark(this.saveTrade, trades[0], 1);
|
|
return;
|
|
} else {
|
|
trade = tradeObj;
|
|
}
|
|
trade.TradeType === "现金流交易" && tradeUtils.resetCashFlow(trade);
|
|
trade.ExtendInfo = this.setExtendInfo(trade);
|
|
if (trade.TradeType === "累计期权" && pageVue.RestoredActions && pageVue.RestoredActions.includes("换月")) {
|
|
let checkFields = new Array("TradeDate", "ExerciseDate", "PayoffType", "KOBarrier", "Strike", "UnderlyingCode", "KOObservationDates");
|
|
if (checkFields.some(x => _.toString(trade[x]) !== _.toString(pageVue.Trade[x]))) {
|
|
return main.confirm("交易要素发生变动,已有的换月设置将会被清除,请确认是否继续保存?", this.doSaveTrade.bind(this, trade));
|
|
}
|
|
}
|
|
trade.MetaDic["ExchangeRate"] = trade.ExchangeRate;
|
|
trade.MetaDic["MidVol"] = trade.MidVol;
|
|
trade.MetaDic["Day1Pnl"] = trade.Day1Pnl;
|
|
var tags = new Array();
|
|
$(".tag-context .tag-item").each(function (i, v) {
|
|
tags.push({ Id: $(v).data("id"), Name: $(v).data("name") });
|
|
});
|
|
trade.Tags = tags;
|
|
this.doSaveTrade(trade);
|
|
},
|
|
doSaveTrade(trade) {
|
|
//if (ylotc.Company == '方顿') {
|
|
// if (trade.SalesCommission.SalesIds.length === 0) {
|
|
// main.confirm("至少应有一个销售经理");
|
|
// return;
|
|
// }
|
|
// if (trade.SalesCommission.Commission <= 0) {
|
|
// main.confirm("提成比例应大于0");
|
|
// return;
|
|
// }
|
|
//}
|
|
if (_.trim(this.viewState.underlying.MaturityDate) && this.trade.ExerciseDate > this.viewState.underlying.MaturityDate && this.trade.TradeType === "累计期权") {
|
|
var con = "交易到期日,标的" + this.trade.UnderlyingCode + "已过期,是否继续簿记?";
|
|
main.confirm(con, function () {
|
|
main.post("/trade/AjaxSaveTradeV2", { trade: trade }).done(function (resp) {
|
|
window.location.href = "/trade/tradeview?abstract=1&enid=" + resp.obj.EncryptId;
|
|
main.parentReload("SearchClick");
|
|
});
|
|
});
|
|
} else {
|
|
main.post("/trade/AjaxSaveTradeV2", { trade: trade }).done(function (resp) {
|
|
window.location.href = "/trade/tradeview?abstract=1&enid=" + resp.obj.EncryptId;
|
|
main.parentReload("SearchClick");
|
|
});
|
|
}
|
|
},
|
|
saveTrade2() {
|
|
$('#modalTradeSave').modal('show');
|
|
},
|
|
saveTrade3(InitialAdvance, PeriodAdvance, FontEarning, ConfirmedLine, ConfirmedFloor, tags) {
|
|
this.viewState.synthetic && (this.trade.MetaDic["组合标的"] = JSON.stringify(this.viewState.synthetic));
|
|
this.trade.MetaDic["主协议编号"] = $("#MainProtocolCode").val();
|
|
this.trade.MetaDic["补充协议编号"] = $("#SupProtocolCode").val();
|
|
let trades = tradeUtils.prepareTrades([this.trade], pageVue.getVolType(), true);
|
|
if (!trades) { $('#modalTradeSave').modal('hide'); return; }
|
|
if (salesCommissionCtrl) {
|
|
trades[0].SalesCommission = salesCommissionCtrl.getValue();
|
|
//if (ylotc.Company == '方顿') {
|
|
// if (trades[0].SalesCommission.SalesIds.length === 0) {
|
|
// main.confirm("至少应有一个销售经理");
|
|
// return;
|
|
// }
|
|
// if (trades[0].SalesCommission.Commission > 0) {
|
|
// main.confirm("提成比例应大于0");
|
|
// return;
|
|
// }
|
|
//}
|
|
}
|
|
let trade = trades[0];
|
|
trade.TradeType === "现金流交易" && tradeUtils.resetCashFlow(trade);
|
|
trade.InitialAdvance = InitialAdvance;
|
|
trade.PeriodAdvance = PeriodAdvance;
|
|
trade.FontEarning = FontEarning;
|
|
trade.ConfirmedLine = ConfirmedLine;
|
|
trade.ConfirmedFloor = ConfirmedFloor;
|
|
trade.Tags = tags;
|
|
main.post("/trade/AjaxSaveTradeV2", { trade: trade }).done(function (resp) {
|
|
$('#modalTradeSave').modal('hide');
|
|
window.location.href = "/trade/tradeview?abstract=1&enid=" + resp.obj.EncryptId;
|
|
});
|
|
},
|
|
handleClose() {
|
|
this.dialogVisible = false
|
|
},
|
|
syntheticUnderlyingSetting() {
|
|
if (!this.viewState.synthetic || !this.trade.UnderlyingCode) {
|
|
return;
|
|
}
|
|
var url = "/SyntheticUnderlying/SyntheticUnderlyingView?syntheticUnderlyingName=" + encodeURIComponent(this.trade.UnderlyingCode);
|
|
main.open("合成价差期权标的设置", url, {});
|
|
},
|
|
setExtendInfo: function (trade) {
|
|
var propertyList = [];
|
|
var key = this.trade.TradeType === "自定义交易" ? this.trade.StructureType : this.ExtendInfos;
|
|
if (key) {
|
|
var map = this.trade.TradeType === "自定义交易" ? this.PropertyMap : this.ExtendMap;
|
|
if (map[key]) {
|
|
map[key].forEach((item, index) => {
|
|
var note = { name: item.name || item.ColumnName, value: item.ColumnType !== 4 || (item.value || item.ColumnDefaultValue + "").indexOf("%") > 0 ? ((item.value || item.ColumnDefaultValue) + "") : (((item.value || item.ColumnDefaultValue) * 100) + "%") };
|
|
if (note.name) {
|
|
propertyList.push(note);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
trade.ExtendInfo = propertyList.length === 0 ? null : JSON.stringify(propertyList);
|
|
if (trade.ExtendInfo && this.trade.TradeType !== "自定义交易") {
|
|
trade.MetaDic["自定义要素模板"] = key;
|
|
} else {
|
|
trade.MetaDic["自定义要素模板"] = "";
|
|
}
|
|
return trade.ExtendInfo;
|
|
},
|
|
checkTrade() {
|
|
this.viewState.synthetic && (this.trade.MetaDic["组合标的"] = JSON.stringify(this.viewState.synthetic));
|
|
let trades = tradeUtils.prepareTrades([this.trade], pageVue.getVolType(), true);
|
|
if (!trades) return;
|
|
if (salesCommissionCtrl) {
|
|
trades[0].SalesCommission = salesCommissionCtrl.getValue();
|
|
}
|
|
if (pageData.highVolLimit && pageData.highVolLimit !== "0") {
|
|
trades[0].MetaDic["volLimit"] = trades[0].BuySell == "买入" ? ("不高于 " + numeral(pageData.highVolLimit).format("0,0.00%")) : ("不低于 " + numeral(pageData.lowVolLimit).format("0,0.00%"))
|
|
}
|
|
trades[0].ExtendInfo = this.setExtendInfo(trades[0]);
|
|
var checkTradeFunc = function (additionalProcessing, isContinue) {
|
|
if (main.isEmpty(additionalProcessing)) {
|
|
additionalProcessing = "";
|
|
}
|
|
$(".not-match").remove();
|
|
|
|
var doneFunc = function (res) {
|
|
if (res.obj && res.obj.proccessType === "AdditionalProcessing") {
|
|
if (res.obj.type === "LackOfMoney") {
|
|
var htmlContent = `<div style="padding:10px">${res.obj.message}</div>`;
|
|
var lackMoneyConfirmLayer = main.open2("提示",
|
|
htmlContent,
|
|
{
|
|
area: ["430px", "175px"],
|
|
btn: ['交易特批', '取消'],
|
|
yes: function (index, layero) {
|
|
var layerIndex = lackMoneyConfirmLayer;
|
|
main.confirm("客户资金或授信不足,强制成交会导致本机构产生风险!要继续复核通过?", function () {
|
|
layer.close(layerIndex);
|
|
checkTradeFunc("LackOfMoney");
|
|
});
|
|
},
|
|
cancel: function (index, layero) {
|
|
if (window.parent && window.parent.reloadtrade) {
|
|
window.parent.reloadtrade();
|
|
}
|
|
(parent || window).layer.closeAll();
|
|
}
|
|
});
|
|
console.log("lackMoneyConfirmLayer:" + lackMoneyConfirmLayer);
|
|
}
|
|
return;
|
|
}
|
|
if (res.obj && res.obj.proccessType === "CheckTradeScale") {
|
|
let htmlContent = `<div style="padding:10px">${res.obj.message}</div>`;
|
|
let lackMoneyConfirmLayer = main.open2("提示",
|
|
htmlContent,
|
|
{
|
|
area: ["430px", "175px"],
|
|
btn: ['继续', '取消'],
|
|
yes: function (index, layero) {
|
|
checkTradeFunc(undefined, true);
|
|
},
|
|
cancel: function (index, layero) {
|
|
if (window.parent && window.parent.reloadtrade) {
|
|
window.parent.reloadtrade();
|
|
}
|
|
(parent || window).layer.closeAll();
|
|
}
|
|
});
|
|
}
|
|
(parent || window).main.message(res.msg);
|
|
if (pageData.generateAmendDoc) {
|
|
if (res.obj && res.obj.generateChangeSuccess) {
|
|
main.downloadFiles(res.obj);
|
|
}
|
|
}
|
|
|
|
if (pageData.needSendChangeEmail) {
|
|
if (res.obj && res.obj.generateChangeSuccess) {
|
|
main.confirm("确认发送变更确认书?",
|
|
function () {
|
|
main.post("/trade/SendChangeConfirmEmails", { tradeids: tradeId }).done(
|
|
function (res) {
|
|
if (res.success) {
|
|
main.message("发送成功");
|
|
} else {
|
|
main.message(res.msg);
|
|
}
|
|
try {
|
|
window.parent.reloadtrade();
|
|
} catch (e) {
|
|
//
|
|
}
|
|
});
|
|
});
|
|
} else {
|
|
try {
|
|
window.parent.reloadtrade();
|
|
} catch (e) {
|
|
//
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
try {
|
|
$("#btn_check").attr("style", "display:block;float:left");
|
|
$("#btn_Reject").attr("style", "display:block;float:left");
|
|
window.parent.reloadtrade();
|
|
} catch (e) {
|
|
//
|
|
}
|
|
}
|
|
};
|
|
var failFunc = function (res) {
|
|
if (!res || !res.obj || main.isEmpty(res.obj.diffList)) {
|
|
return;
|
|
}
|
|
res.obj.diffList.forEach(function (curValue) {
|
|
if (curValue === "trade_binary_option.PayoffType") {
|
|
$("#trade_binary_option_PayoffType").parent()
|
|
.append('<span class="glyphicon glyphicon-remove not-match" style="color: red;float: right;position: absolute;top: 9px;"></span>');
|
|
$("#BinaryAmericanPayoffType").parent()
|
|
.append('<span class="glyphicon glyphicon-remove not-match" style="color: red;float: right;position: absolute;top: 9px;"></span>');
|
|
}
|
|
else if (curValue === "ExtendInfo") {
|
|
main.message("自定义字段复核失败!");
|
|
}
|
|
else if (curValue === "AnnualizeFactorL") {
|
|
$(`#AnnualizeFactor_ttmDays`).parent()
|
|
.append('<span class="glyphicon glyphicon-remove not-match" style="color: red;float: right;position: absolute;top: 9px;"></span>');
|
|
}
|
|
else if (curValue === "AnnualizeFactorR") {
|
|
$(`#AnnualizeFactor_daysInYear`).parent()
|
|
.append('<span class="glyphicon glyphicon-remove not-match" style="color: red;float: right;position: absolute;top: 9px;"></span>');
|
|
} else if (curValue === "AnnualizeFactor2L") {
|
|
$(`#AnnualizeFactor2_ttmDays`).parent()
|
|
.append('<span class="glyphicon glyphicon-remove not-match" style="color: red;float: right;position: absolute;top: 9px;"></span>');
|
|
}
|
|
else if (curValue === "AnnualizeFactor2R") {
|
|
$(`#AnnualizeFactor2_daysInYear`).parent()
|
|
.append('<span class="glyphicon glyphicon-remove not-match" style="color: red;float: right;position: absolute;top: 9px;"></span>');
|
|
} else {
|
|
$(`[name='${curValue}']`).parent()
|
|
.append('<span class="glyphicon glyphicon-remove not-match" style="color: red;float: right;position: absolute;top: 9px;"></span>');
|
|
}
|
|
});
|
|
pageVue.diffList = res.obj.diffList;
|
|
|
|
if(!main.isEmpty(pageVue.diffList)){
|
|
pageVue.diffList.forEach(function (curValue) {
|
|
if (curValue === "trade_binary_option.PayoffType") {
|
|
$("#trade_binary_option_PayoffType").parent()
|
|
.append('<span class="glyphicon glyphicon-remove not-match" style="color: red;"></span>');
|
|
$("#BinaryAmericanPayoffType").parent()
|
|
.append('<span class="glyphicon glyphicon-remove not-match" style="color: red;"></span>');
|
|
}
|
|
else {
|
|
// $(`[name='${curValue}']`).parent()
|
|
// .append('<span class="glyphicon glyphicon-remove not-match" style="color: red;"></span>');
|
|
$(`[data-name='${curValue}']`).parent()
|
|
.append('<span class="glyphicon glyphicon-remove not-match" style="color: red;"></span>');
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
// showDiffWithReviewTrade();
|
|
};
|
|
|
|
main.post("/trade/CheckTrade", { trade: trades[0], additionalProcessing: additionalProcessing }).done(doneFunc).fail(failFunc);
|
|
};
|
|
checkTradeFunc();
|
|
},
|
|
rejectTrade() {
|
|
let trades = tradeUtils.prepareTrades([this.trade], pageVue.getVolType(), true, true);
|
|
if (!trades) return;
|
|
trades[0].SalesCommission = salesCommissionCtrl.getValue();
|
|
main.post("/trade/TradeReject", trades[0]).done(
|
|
function (res) {
|
|
try {
|
|
window.parent.reloadtrade();
|
|
} catch (e) { }
|
|
}
|
|
);
|
|
},
|
|
getTTM() {
|
|
var data = {
|
|
from: this.trade.ValueDate || this.trade.TradeDate,
|
|
to: this.trade.ExerciseDate,
|
|
varietyid: this.viewState.variety.id
|
|
};
|
|
var self = this;
|
|
if (data.from && data.to) {
|
|
main.post("/calendar/DaysInPeriod", data, false).done(function (resp) {
|
|
var days = Number.parseInt(consNumberFormat.ttmDaysFmt(resp.obj));
|
|
self.trade.NumOfSmoothingDays = days < 1 ? 1 : days;
|
|
if (pageData.is厦门象屿) {
|
|
self.trade.NumOfSmoothingDays = days >= 10 ? 5 : 0;
|
|
}
|
|
});
|
|
} else {
|
|
self.trade.TTMDays = '';
|
|
}
|
|
},
|
|
addNewProperty: function () {
|
|
var map = this.trade.TradeType === "自定义交易" ? this.PropertyMap[this.trade.StructureType] : this.ExtendMap[this.ExtendInfos];
|
|
map.push({ isNew: true, ColumnName: "", ColumnDefaultValue: "", ColumnType: 0 });//0:文本
|
|
},
|
|
deleteProperty: function (index) {
|
|
var map = this.trade.TradeType === "自定义交易" ? this.PropertyMap[this.trade.StructureType] : this.ExtendMap[this.ExtendInfos];
|
|
map.splice(index, 1);
|
|
},
|
|
changeOption: function (index) {
|
|
var map = this.trade.TradeType === "自定义交易" ? this.PropertyMap[this.trade.StructureType] : this.ExtendMap[this.ExtendInfos];
|
|
map.forEach(d => {
|
|
if (d.ColumnName != undefined) {
|
|
d.name = d.ColumnName;
|
|
}
|
|
if (d.ColumnDefaultValue != undefined) {
|
|
d.value = d.ColumnDefaultValue;
|
|
}
|
|
});
|
|
},
|
|
getVol() {
|
|
pageVue.IsTradeVol || this.trade.ExerciseDate && this.getTradeOpenVolatility();
|
|
},
|
|
//交易审批
|
|
submit(status) {
|
|
var pop = '';
|
|
if (status === 'pass') {
|
|
pop = "确认通过审批?";
|
|
}
|
|
if (status === 'reject') {
|
|
pop = "确认拒绝?";
|
|
}
|
|
var confirmFunc = function (additionalProcessing) {
|
|
var pData = { tradeId: pageVue.Trade.id, status: status, text: "" };
|
|
if (!main.isEmpty(additionalProcessing)) {
|
|
pData.additionalProcessing = additionalProcessing;
|
|
}
|
|
main.post("/processtradelog/UpdateTradeProcessLog", pData).done(
|
|
function (data) {
|
|
if (data.obj && data.obj.proccessType == "AdditionalProcessing") {
|
|
if (data.obj.type == "LackOfMoney") {
|
|
var htmlContent = `<div style="padding:10px">${data.obj.message}</div>`;
|
|
var lackMoneyConfirmLayer = main.open2("提示",
|
|
htmlContent,
|
|
{
|
|
area: ["430px", "175px"],
|
|
btn: ['交易特批', '取消'],
|
|
yes: function (index, layero) {
|
|
var layerIndex = lackMoneyConfirmLayer;
|
|
main.confirm("客户资金或授信不足,强制成交会导致本机构产生风险!要继续审批通过?", function () {
|
|
layer.close(layerIndex);
|
|
confirmFunc("LackOfMoney");
|
|
});
|
|
},
|
|
cancel: function (index, layero) {
|
|
if (window.parent && window.parent.reloadtrade) {
|
|
window.parent.reloadtrade();
|
|
}
|
|
(parent || window).layer.closeAll();
|
|
}
|
|
});
|
|
console.log("lackMoneyConfirmLayer:" + lackMoneyConfirmLayer);
|
|
}
|
|
return;
|
|
}
|
|
(parent || window).main.message(data.msg);
|
|
if (pageData.generateAmendDoc) {
|
|
if (data.obj && data.obj.generateChangeSuccess) {
|
|
main.downloadFiles(data.obj.url);
|
|
try { window.parent.reloadtrade(); } catch (e) { }
|
|
}
|
|
}
|
|
if (pageData.needSendChangeEmail) {
|
|
if (data.obj && data.obj.generateChangeSuccess) {
|
|
main.confirm("确认发送变更确认书?",
|
|
function () {
|
|
main.post("/trade/SendChangeConfirmEmails", { tradeids: tradeId }).done(
|
|
function (data) {
|
|
if (data.success) {
|
|
main.message("发送成功");
|
|
} else {
|
|
main.message(data.msg);
|
|
}
|
|
try {
|
|
window.parent.reloadtrade();
|
|
} catch (e) {
|
|
}
|
|
});
|
|
});
|
|
} else {
|
|
try {
|
|
window.parent.reloadtrade();
|
|
} catch (e) {
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
try { window.parent.reloadtrade(); } catch (e) { }
|
|
}
|
|
if (parent) {
|
|
parent.layer.closeAll();
|
|
}
|
|
});
|
|
}
|
|
main.confirm(pop, confirmFunc);
|
|
},
|
|
//观察频率赋值
|
|
assObservationRate() {
|
|
let self = this;
|
|
let kiObservationRate = self.trade.MetaDic["敲入观察周期"];
|
|
let koObservationRate = self.trade.MetaDic["敲出观察周期"];
|
|
let num = 0, unit = "", unitStr = "";
|
|
if (kiObservationRate != null && kiObservationRate != undefined && kiObservationRate != "") {
|
|
let kiOR = kiObservationRate.split("|");
|
|
if (kiOR.length >= 1) {
|
|
num = kiOR[0].substring(0, kiOR[0].length - 1);
|
|
unit = kiOR[0].substring(kiOR[0].length - 1, kiOR[0].length);
|
|
unitStr = self.getUnitStr(unit);
|
|
|
|
self.viewState.Observation.hasValue = true;
|
|
self.viewState.Observation.ObservationUnit = unit;
|
|
self.viewState.Observation.ObservationNum = num;
|
|
self.viewState.Observation.ObservationFrequency = kiOR[1];
|
|
|
|
self.observationRate = "每" + num + unitStr;
|
|
}
|
|
}
|
|
|
|
if (self.trade.TradeType == "凤凰期权" || self.trade.TradeType == "雪球期权" || self.trade.TradeType == "累计期权") {
|
|
if (koObservationRate != null && koObservationRate != undefined && koObservationRate != "") {
|
|
let koOR = koObservationRate.split("|");
|
|
if (koOR.length >= 1) {
|
|
num = koOR[0].substring(0, koOR[0].length - 1);
|
|
unit = koOR[0].substring(koOR[0].length - 1, koOR[0].length);
|
|
unitStr = self.getUnitStr(unit);
|
|
|
|
self.viewState.KOObservation.hasValue = true;
|
|
self.viewState.KOObservation.ObservationUnit = unit;
|
|
self.viewState.KOObservation.ObservationNum = num;
|
|
self.viewState.KOObservation.ObservationFrequency = koOR[1];
|
|
self.koObservationRate = "每" + num + unitStr;
|
|
}
|
|
}
|
|
}
|
|
},
|
|
//观察频率字符串获取
|
|
getUnitStr(unit) {
|
|
let unitStr = "";
|
|
switch (unit) {
|
|
case "W": unitStr = "周";
|
|
case "M": unitStr = "月";
|
|
case "Y": unitStr = "年";
|
|
default: unitStr = "天"
|
|
}
|
|
return unitStr;
|
|
},
|
|
IsCodesExistsCommoditySpot(value) {
|
|
if (pageData.showZheQi) {
|
|
this.codes.push(value);
|
|
//判断标的是否为现货
|
|
var flag = tradeHelper.IsCodesExistsCommoditySpot(this.codes);
|
|
if (flag) {
|
|
this.isShowActualExerciseDate = true;
|
|
} else {
|
|
this.isShowActualExerciseDate = false;
|
|
}
|
|
this.codes.length = 0;
|
|
}
|
|
},
|
|
changePrepaymentUsed() {
|
|
this.changePrepaymentUsedDateTime = new Date().getTime();
|
|
|
|
if (this.trade.PrepaymentUsed) {
|
|
this.trade.PrepaymentRatio = 1;
|
|
this.trade.PrepaymentConvertCashRate = this.trade.NoRiskRate;
|
|
}
|
|
else {
|
|
this.trade.PrepaymentRatio = 0;
|
|
this.trade.PrepaymentConvertCashRate = 0;
|
|
}
|
|
this.changeFieldState();
|
|
}
|
|
},
|
|
computed: {
|
|
...consVueTrade.computed,
|
|
showMaturityDate() {
|
|
return ['CommodityFutures', 'StockIF'].includes(this.viewState.underlying.InstrumentType);
|
|
},
|
|
showTradeUnit() {
|
|
return this.viewState.variety.id && this.showMaturityDate && this.trade.TradeType !== '合成价差期权';
|
|
},
|
|
Compositespread() {
|
|
return this.trade.TradeType === "合成价差期权";
|
|
},
|
|
isShowActualExerciseDate() {
|
|
return this.isShowActualExerciseDate && pageData.showZheQi;
|
|
}
|
|
},
|
|
updated: function () {
|
|
if (pageVue.IsCheck) {
|
|
disableColumns();
|
|
}
|
|
},
|
|
components: {
|
|
'vue-datepicker': FastVue.vueDatePicker(),
|
|
'vue-number-input': FastVue.vueNumberInput(),
|
|
'vue-daycount': vueDayCount(),
|
|
},
|
|
destroyed() {
|
|
|
|
}
|
|
});
|
|
|
|
//兼容定价计算页面观察日设置
|
|
var getObservationDatesSetting = vue.setObservation;
|
|
var getStructureSetting = vue.setStructure;
|
|
|
|
$(function () {
|
|
$(".datepicker").change(function () {
|
|
var dateVal = $(this).val();
|
|
if (!dateVal) return;
|
|
dateVal = dateVal.replace(/\D/g, '').padStart(4, '0');
|
|
switch (dateVal.length) {
|
|
case 4:
|
|
dateVal = new Date().getFullYear() + dateVal; break;
|
|
case 6:
|
|
dateVal = '20' + dateVal; break;
|
|
case 8: break;
|
|
default:
|
|
dateVal = dateVal.length > 8 ? dateVal.substring(0, 8) : ''; break;
|
|
}
|
|
|
|
if (dateVal) {
|
|
dateVal = moment(dateVal).format('YYYY-MM-DD');
|
|
!/^\d+/.test(dateVal) && (dateVal = '');
|
|
}
|
|
|
|
$(this).datepicker("setDate", dateVal);
|
|
});
|
|
|
|
if (pageVue.IsCheck) {
|
|
disableColumns();
|
|
showDiffWithReviewTrade();
|
|
}
|
|
if (!pageData.isAdd && !pageData.eecuritiesEnvironment) {
|
|
if (pageData.metaDic["中央对手方清算"] != undefined) {
|
|
$("#selIsCentralClearing").val(pageData.metaDic["中央对手方清算"]);
|
|
} else {
|
|
$("#selIsCentralClearing").val(undefined);
|
|
}
|
|
if (pageData.metaDic["中央清算平台"] != undefined) {
|
|
$("#selCentralClearingPaltform").val(pageData.metaDic["中央清算平台"]);
|
|
}
|
|
if (pageData.metaDic["交易平台"] != undefined) {
|
|
$("#selTradingPaltform").val(pageData.metaDic["交易平台"]);
|
|
}
|
|
}
|
|
});
|
|
|
|
function disableColumns() {
|
|
if (main.isEmpty(abledList)) {
|
|
return;
|
|
}
|
|
list = [];
|
|
for (var i = 0; i < $("input").length; i++) {
|
|
var a = $("input").eq(i).attr('name');
|
|
if (a !== "ClientId") {
|
|
list.push(a);
|
|
}
|
|
};
|
|
for (var i = 0; i < $("select").length; i++) {
|
|
var a = $("select").eq(i).attr('name'); list.push(a);
|
|
};
|
|
disableList = [];
|
|
list.forEach(function (curValue) {
|
|
if (!abledList.includes(curValue)) {
|
|
disableList.push(curValue);
|
|
}
|
|
})
|
|
disableList.forEach(function (curValue) {
|
|
if (curValue !== '') {
|
|
$(`[name='${curValue}']`).prop("disabled", true);
|
|
$(`#${curValue}_auto`).prop("disabled", true);
|
|
if (curValue === "UnderlyingCode") {
|
|
$("#UnderlyingCode").attr("style", "color: red; font-weight:bold;");
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
function showDiffWithReviewTrade() {
|
|
if (main.isEmpty(pageVue.diffList)) {
|
|
return;
|
|
}
|
|
pageVue.diffList.forEach(function (curValue) {
|
|
if (curValue === "trade_binary_option.PayoffType") {
|
|
$("#trade_binary_option_PayoffType").parent()
|
|
.append('<span class="glyphicon glyphicon-remove not-match" style="color: red;"></span>');
|
|
$("#BinaryAmericanPayoffType").parent()
|
|
.append('<span class="glyphicon glyphicon-remove not-match" style="color: red;"></span>');
|
|
}
|
|
else {
|
|
$(`[name='${curValue}']`).parent()
|
|
.append('<span class="glyphicon glyphicon-remove not-match" style="color: red;"></span>');
|
|
$(`[data-name='${curValue}']`).parent()
|
|
.append('<span class="glyphicon glyphicon-remove not-match" style="color: red;"></span>');
|
|
}
|
|
});
|
|
}
|
|
|
|
function btnSave() {
|
|
let InitialAdvance = parseFloat($("#InitialAdvance").val() == "" ? 0 : $("#InitialAdvance").val());
|
|
let PeriodAdvance = parseFloat($("#PeriodAdvance").val() == "" ? 0 : $("#PeriodAdvance").val());
|
|
let FontEarning = parseFloat($("#FontEarning").val() == "" ? 0 : $("#FontEarning").val());
|
|
let ConfirmedLine = parseFloat($("#ConfirmedLine").val() == "" ? 0 : $("#ConfirmedLine").val());
|
|
let ConfirmedFloor = parseFloat($("#ConfirmedFloor").val() == "" ? 0 : $("#ConfirmedFloor").val());
|
|
var tags = new Array();
|
|
$(".tag-context .tag-item").each(function (i, v) {
|
|
tags.push({ Id: $(v).data("id"), Name: $(v).data("name") });
|
|
});
|
|
|
|
saveTrade3(InitialAdvance, PeriodAdvance, FontEarning, ConfirmedLine, ConfirmedFloor, tags);
|
|
}
|
|
|
|
function closeSave() {
|
|
$('#modalTradeSave').modal('hide');
|
|
} |