189 lines
9.3 KiB
JavaScript
189 lines
9.3 KiB
JavaScript
//otcformat禁止千分位分组
|
|
window.otcformat.options.disableGrouping = true;
|
|
const inputFormatEqvNotional = Object.freeze({ precision: otcformat.trading.StockEqvNotional.precision, append: '' });
|
|
let dealDate = model.DealDate;
|
|
const vue = new Vue({
|
|
el: '#vueDiv',
|
|
data: {
|
|
deal: model,
|
|
interestList: [],
|
|
marginList: [],
|
|
oriClosePercent: model.ClosePercent
|
|
},
|
|
computed: {
|
|
minStartDate() {
|
|
return dealDate;
|
|
}
|
|
},
|
|
created() {
|
|
this.initDeal();
|
|
this.calcCloseAmount();
|
|
this.dataFormat();
|
|
},
|
|
methods: {
|
|
initDeal() {
|
|
this.interestList = model.FlowEvents.filter((item) => {
|
|
return item.InterestMode == 1 || item.InterestMode == 2 || item.InterestMode == 7 || item.InterestMode == 8 || item.InterestMode == 9;
|
|
});
|
|
this.marginList = model.FlowEvents.filter((item) => {
|
|
return item.InterestMode == 5 || item.InterestMode == 6;
|
|
});
|
|
},
|
|
dataFormat() {
|
|
this.deal.NotionalValue = otcformat.trading.StockEqvNotional(parseFloat(this.deal.NotionalValue));
|
|
this.deal.PosiNotionalValue = otcformat.trading.StockEqvNotional(parseFloat(this.deal.PosiNotionalValue));
|
|
this.deal.NotionalQty = otcformat.trading.notional(this.deal.NotionalQty);
|
|
this.deal.SwapCloseAmount = otcformat.trading.StockEqvNotional(this.deal.SwapCloseAmount);
|
|
this.deal.PositionQty = otcformat.trading.notional(this.deal.PositionQty);
|
|
this.interestList.forEach(x => {
|
|
//x.Principal = otcformat.trading.StockEqvNotional(x.Principal);
|
|
//x.Rate = otcformat.fixed6(x.Rate);
|
|
x.InterestAmount = otcformat.trading.StockEqvNotional(x.InterestAmount);
|
|
x.InterestClosePnL = otcformat.trading.StockEqvNotional(x.InterestClosePnL);
|
|
//x.InterestStartDate = x.InterestStartDate ? x.InterestStartDate.substr(0, 10) : "";
|
|
//x.InterestEndDate = x.InterestEndDate ? x.InterestEndDate.substr(0, 10) : "";
|
|
});
|
|
this.marginList.forEach(x => {
|
|
x.InterestAmount = otcformat.trading.StockEqvNotional(x.InterestAmount);
|
|
x.InterestClosePnL = otcformat.trading.StockEqvNotional(x.InterestClosePnL);
|
|
});
|
|
},
|
|
changeInterestAmount(item) {//修改利息金额
|
|
let interestRatio = item.InterestDirection == 1 ? 1 : -1;
|
|
item.InterestClosePnL = otcformat.trading.StockEqvNotional(parseFloat(item.InterestAmount) * interestRatio+ parseFloat(item.InterestFee));
|
|
this.calcCloseAmount();
|
|
},
|
|
calcCloseAmount() {//计算平仓总额=浮动收取+利息收取-浮动支付-利息支付
|
|
let thisObj = this;
|
|
thisObj.deal.SwapCloseAmount = 0;
|
|
thisObj.deal.SwapRealizedPnL = 0;
|
|
thisObj.deal.SwapMarginRebatePnl = 0;
|
|
thisObj.deal.SwapMarginAmount = 0;
|
|
this.interestList.forEach(x => {
|
|
/*let interestRatio = x.InterestDirection == 1 ? 1 : -1;*/
|
|
let interestAmount = parseFloat(x.InterestClosePnL);
|
|
thisObj.deal.SwapCloseAmount = parseFloat(thisObj.deal.SwapCloseAmount) + interestAmount;
|
|
thisObj.deal.SwapRealizedPnL = parseFloat(thisObj.deal.SwapRealizedPnL) + interestAmount;
|
|
});
|
|
this.marginList.forEach(x => {
|
|
let interestAmount = parseFloat(x.InterestClosePnL);
|
|
let interestRatio = x.InterestDirection == 1 ? -1 : 1;
|
|
thisObj.deal.SwapCloseAmount = parseFloat(thisObj.deal.SwapCloseAmount) + interestAmount;
|
|
thisObj.deal.SwapMarginRebatePnl = parseFloat(thisObj.deal.SwapMarginRebatePnl) + interestAmount;
|
|
thisObj.deal.SwapRealizedPnL = parseFloat(thisObj.deal.SwapRealizedPnL) + interestAmount;
|
|
thisObj.deal.SwapMarginAmount = parseFloat(thisObj.deal.SwapMarginAmount) + parseFloat(x.InterestPrincipal) * interestRatio;
|
|
});
|
|
thisObj.deal.SwapCloseAmount = otcformat.trading.StockEqvNotional(thisObj.deal.SwapCloseAmount);
|
|
thisObj.deal.SwapRealizedPnL = otcformat.trading.StockEqvNotional(thisObj.deal.SwapRealizedPnL);
|
|
thisObj.deal.SwapMarginRebatePnl = otcformat.trading.StockEqvNotional(thisObj.deal.SwapMarginRebatePnl);
|
|
thisObj.deal.SwapMarginAmount = otcformat.trading.StockEqvNotional(thisObj.deal.SwapMarginAmount);
|
|
},
|
|
closeTrade() {//平仓
|
|
var thisObj = this;
|
|
let reqObj = _.cloneDeep(thisObj.deal);
|
|
let marginCloneList = _.cloneDeep(thisObj.marginList);
|
|
reqObj.FlowEvents = _.cloneDeep(thisObj.interestList);
|
|
marginCloneList.forEach((item) => {
|
|
reqObj.FlowEvents.push(item);
|
|
})
|
|
var postData = { unwindData: reqObj };
|
|
var msg = "确认提交平仓?";
|
|
var postUrl = "/swaptrade2/SwapLongShortUnwindJson";
|
|
if (g_isShowReCheckClose) {
|
|
msg = "确认提交平仓审核?";
|
|
postUrl = "/swaptrade2/ApplyUnwind";
|
|
postData.eventType = 2;//互换3,平仓2
|
|
}
|
|
main.confirm(msg,
|
|
function () {
|
|
//重新计算百分比
|
|
var thisObj2 = thisObj;
|
|
main.post(postUrl, postData).done(function (res) {
|
|
if (res.success) {
|
|
thisObj2.closetrade_cashWindow();
|
|
}
|
|
else {
|
|
try {
|
|
thisObj2.closetrade_cashWindow();
|
|
} catch (e) {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
getSumbitText: function () {
|
|
return g_isShowReCheckClose ? "审核提交" : "保存";
|
|
},
|
|
submitApproval(status) {
|
|
var pop = '';
|
|
if (status === 'pass') {
|
|
pop = "确认通过审批?";
|
|
}
|
|
if (status === 'reject') {
|
|
pop = "确认拒绝?";
|
|
}
|
|
let thisObj = this;
|
|
var confirmFunc = function (additionalProcessing) {
|
|
var pData = { tradeId: thisObj.deal.SwapTradeId, status: status, text: "" };
|
|
if (!main.isEmpty(additionalProcessing)) {
|
|
pData.additionalProcessing = additionalProcessing;
|
|
}
|
|
var thisObj2 = thisObj;
|
|
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) {
|
|
thisObj2.closetrade_cashWindow();
|
|
}
|
|
(parent || window).layer.closeAll();
|
|
}
|
|
});
|
|
}
|
|
return;
|
|
}
|
|
(parent || window).main.message(data.msg);
|
|
try { thisObj2.closetrade_cashWindow(); }
|
|
catch (e) { }
|
|
if (parent) {
|
|
parent.layer.closeAll();
|
|
}
|
|
});
|
|
}
|
|
main.confirm(pop, confirmFunc);
|
|
},
|
|
closetrade_cashWindow: function () {
|
|
layer.closeMe('reloadData');
|
|
},
|
|
closeCurrentWindow: function () {
|
|
try {
|
|
if (window.parent && window.parent.reload) window.parent.reload();
|
|
} catch (e) {
|
|
}
|
|
try {
|
|
var layer = window.parent.layer;
|
|
layer.close(layer.getFrameIndex(window.name));
|
|
} catch (e) {
|
|
}
|
|
}
|
|
},
|
|
components: {
|
|
'vue-datepicker': FastVue.vueDatePicker(),
|
|
'vue-number-input': FastVue.vueNumberInput(),
|
|
}
|
|
});
|