//otcformat禁止千分位分组 window.otcformat.options.disableGrouping = true; const inputFormatEqvNotional = swapPricePrecision.getCommonInputFormat('amount', { append: '' }); const swapInstrumentType = (model.FlowEvents || []).find(item => item && item.UnderlyingInstrumentType)?.UnderlyingInstrumentType || model.UnderlyingInstrumentType || ''; const formatSwapAmount = value => swapPricePrecision.normalizeCommon('amount', value); const formatSwapQuantity = value => swapPricePrecision.normalizeCommon('quantity', value, swapInstrumentType); 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: { formatAmount(value) { return swapPricePrecision.formatCommon('amount', value); }, formatQuantity(value) { return swapPricePrecision.formatCommon('quantity', value, swapInstrumentType); }, 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 = formatSwapAmount(this.deal.NotionalValue); this.deal.PosiNotionalValue = formatSwapAmount(this.deal.PosiNotionalValue); this.deal.NotionalQty = formatSwapQuantity(this.deal.NotionalQty); this.deal.SwapCloseAmount = formatSwapAmount(this.deal.SwapCloseAmount); this.deal.PositionQty = formatSwapQuantity(this.deal.PositionQty); this.interestList.forEach(x => { //x.Principal = formatSwapAmount(x.Principal); //x.Rate = otcformat.fixed6(x.Rate); x.InterestAmount = formatSwapAmount(x.InterestAmount); x.InterestClosePnL = formatSwapAmount(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 = formatSwapAmount(x.InterestAmount); x.InterestClosePnL = formatSwapAmount(x.InterestClosePnL); }); }, changeInterestAmount(item) {//修改利息金额 let interestRatio = item.InterestDirection == 1 ? 1 : -1; item.InterestClosePnL = formatSwapAmount(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 = formatSwapAmount(thisObj.deal.SwapCloseAmount); thisObj.deal.SwapRealizedPnL = formatSwapAmount(thisObj.deal.SwapRealizedPnL); thisObj.deal.SwapMarginRebatePnl = formatSwapAmount(thisObj.deal.SwapMarginRebatePnl); thisObj.deal.SwapMarginAmount = formatSwapAmount(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 = `