505 lines
27 KiB
JavaScript
505 lines
27 KiB
JavaScript
//otcformat禁止千分位分组
|
|
window.otcformat.options.disableGrouping = true;
|
|
$(document).ready(function () {
|
|
var selIds = $("#hidIds").val();
|
|
if (page.reCheck > 0) {
|
|
getGroupTradeCash(selIds.split(','));
|
|
} else {
|
|
addGroupTradeCash(selIds.split(','));
|
|
}
|
|
|
|
});
|
|
|
|
var goToTradeGroupActionList = false;
|
|
|
|
function addGroupTradeCash(selIdArr) {
|
|
|
|
main.post("/trade/CheckSelectedGroupTradesForAction", { tradeids: selIdArr }).done(function (res) {
|
|
if (res.IsSuccess) {
|
|
groupVue.trade = res.trade;
|
|
groupVue.tradeCash.ValueDate = page.valueDate;
|
|
groupVue.tradeCash.Action = "全部平仓";
|
|
groupVue.tradeCash.Amount = 0;
|
|
groupVue.tradeCash.TradeId = res.trade.id;
|
|
groupVue.tradeCash.FinalPrice = res.trade.UnderlyingPrice;
|
|
groupVue.tradeCash.TradeAmount = res.trade.TradeAmount;
|
|
groupVue.tradeCash.Notional = res.trade.Notional;
|
|
groupVue.tradeCash.UnwindTradeAmount = res.trade.TradeAmount;
|
|
groupVue.tradeCash.UnwindPercentRate = res.trade.OriginalNotional != 0 ? res.trade.Notional / res.trade.OriginalNotional * 100 : 0;
|
|
groupVue.tradeCash.ValueDate = groupVue.tradeCash.ValueDate > res.trade.ExerciseDate ? new moment(res.trade.ExerciseDate).format("YYYY-MM-DD") : groupVue.tradeCash.ValueDate;
|
|
$("#unwindDate").datepicker("option", "minDate", !_.trim(_.toString(groupVue.trade.UnWindDate)) ? groupVue.trade.TradeDate : groupVue.trade.UnWindDate);
|
|
$("#unwindDate").datepicker("option", "maxDate", page.valueDate < groupVue.trade.ExerciseDate ? page.valueDate : groupVue.trade.ExerciseDate);
|
|
$("#unwindDate").val(groupVue.tradeCash.ValueDate);
|
|
goToTradeGroupActionList = res.GotoTradeGroupActionList;
|
|
if (res.ChildTradeCashs) {
|
|
groupVue.childTradeCashs = res.ChildTradeCashs;
|
|
groupVue.childTradeCashs.forEach(function (dom, index) {
|
|
dom.oldUnwindPercentRate = dom.UnwindPercentRate;
|
|
dom.oldUnwindStockEqvNotional = dom.UnwindStockEqvNotional;
|
|
dom.oldUnwindTradeAmount = dom.UnwindTradeAmount;
|
|
})
|
|
}
|
|
else {
|
|
groupVue.childTradeCashs = [];
|
|
}
|
|
groupVue.oldUnwindPercentRate = groupVue.tradeCash.UnwindPercentRate;
|
|
groupVue.oldUnwindStockEqvNotional = groupVue.tradeCash.UnwindStockEqvNotional;
|
|
groupVue.oldUnwindTradeAmount = groupVue.tradeCash.UnwindTradeAmount;
|
|
groupVue.tradeCash.IsUnwindStockEqvNotional = false;
|
|
groupVue.tradeCash.UnwindMethod = groupVue.trade.IsUsePremiumRate == true ? 0 : 1;
|
|
//$('#modalGroupTradeCashSave').modal('show');
|
|
}
|
|
else {
|
|
main.message(res.ErrorMsg);
|
|
}
|
|
});
|
|
groupVue.tradeIds = selIdArr;
|
|
}
|
|
function getGroupTradeCash(selIdArr) {
|
|
main.post("/trade/GetGroupTradesForAction", { tradeId: selIdArr[0] }).done(function (res) {
|
|
if (res.IsSuccess) {
|
|
groupVue.trade = res.trade;
|
|
groupVue.tradeCash = res.trade.trade_cash;
|
|
groupVue.tradeCash.ValueDate = groupVue.tradeCash.ValueDate ? groupVue.tradeCash.ValueDate.substr(0, 10) : "";
|
|
groupVue.tradeCash.UnwindPercentRate = groupVue.tradeCash.UnwindPercentRate * 100;
|
|
if (page.reCheck == 1) {
|
|
groupVue.tradeCash.Amount = 0;
|
|
}
|
|
if (res.ChildTradeCashs) {
|
|
groupVue.childTradeCashs = res.ChildTradeCashs;
|
|
}
|
|
else {
|
|
groupVue.childTradeCashs = [];
|
|
}
|
|
}
|
|
else {
|
|
main.message(res.ErrorMsg);
|
|
}
|
|
});
|
|
groupVue.tradeIds = selIdArr;
|
|
}
|
|
|
|
function closeWindow(reload) {
|
|
layer.closeMe(reload ? "reloadData" : "");
|
|
}
|
|
|
|
const pricingFormat = otcformat.trading;
|
|
const consNumberFormat = Object.freeze(new function () {
|
|
this.fixed2 = main.numberFormat(2);
|
|
this.fixed3 = main.numberFormat(3);
|
|
this.fixed4 = main.numberFormat(4);
|
|
this.fixed5 = main.numberFormat(5);
|
|
this.fixed6 = main.numberFormat(6);
|
|
|
|
this.umpriceP = this.fixed4;
|
|
return this;
|
|
}());
|
|
|
|
const inputFormatPercent = Object.freeze({ precision: 2, append: '%' });
|
|
const inputFormatPremiumRate = Object.freeze({ precision: pricingFormat.premiumRateP.precision, append: '' });
|
|
const inputFormatEqvNotional = Object.freeze({ precision: pricingFormat.StockEqvNotional.precision, append: '' });
|
|
const inputFormatTradeAmount = Object.freeze({ precision: pricingFormat.notional.precision, negative: true, append: '' });
|
|
|
|
|
|
function groupTradeCashActionList() {
|
|
window.open("/trade/tradeGroupActionList", "_blank");
|
|
}
|
|
|
|
const inputFormatTradeAmountV = Object.freeze({ precision: pricingFormat.notional.precision, negative: true, append: '' });
|
|
var groupVue = new Vue({
|
|
el: '#modalGroupTradeCashSave',
|
|
data: {
|
|
tradeIds: [],
|
|
SettleType: "0",
|
|
trade: page.trade,
|
|
tradeCash: page.tradeCash,
|
|
childTradeCashs: [],
|
|
unwindStockEqvActionDisabled: true,
|
|
unwindTradeAmountActionDisabled: true,
|
|
CopyFromOld: false,
|
|
oldUnwindPercentRate: 0,
|
|
oldUnwindStockEqvNotional: 0,
|
|
oldUnwindTradeAmount: 0,
|
|
reCheck: page.reCheck,
|
|
//平仓总额视角如果为价值视角
|
|
UnwindAmountAngleIfValue: page.UnwindAmountAngle == 0,
|
|
},
|
|
filters: {
|
|
otcformatNotional: otcformat.trading.notional,
|
|
otcformatStockEqvNotional: otcformat.trading.StockEqvNotional
|
|
},
|
|
computed: {
|
|
inputFormatStrike() {
|
|
let fmt = {};
|
|
if (this.trade.IsMoneynessOption === '是') {
|
|
fmt.append = '%';
|
|
fmt.negative = false;
|
|
fmt.precision = consNumberFormat.umpriceP.precision;
|
|
} else {
|
|
fmt.append = '';
|
|
fmt.negative = true;
|
|
fmt.precision = pricingFormat.umprice.precision;
|
|
}
|
|
return fmt;
|
|
},
|
|
},
|
|
methods: {
|
|
closeModal: function () {
|
|
$('#modalGroupTradeCashSave').modal('hide');
|
|
},
|
|
CheckDate: function () {
|
|
let Checkflag = true;
|
|
if (this.tradeCash.ValueDate > this.trade.ExerciseDate) {
|
|
main.message("了结日期不能在交易到期日之后");
|
|
Checkflag = false;
|
|
}
|
|
if (!_.trim(_.toString(this.tradeCash.Amount))) {
|
|
main.message("了结总额不能为空");
|
|
Checkflag = false;
|
|
}
|
|
if (this.trade.IsUsePremiumRate == true) {
|
|
if (parseFloat(this.tradeCash.UnwindStockEqvNotional) == 0 || parseFloat(this.trade.StockEqvNotional) == 0) {
|
|
main.message("平仓持仓名义本金或持仓名义本金为0,无法计算");
|
|
Checkflag = false;
|
|
}
|
|
if (this.tradeCash.IsUnwindStockEqvNotional) {
|
|
//名义本金
|
|
if (!_.trim(_.toString(this.tradeCash.UnwindStockEqvNotional))) {
|
|
main.message("平仓名义本金不能为空");
|
|
Checkflag = false;
|
|
}
|
|
if (parseFloat(this.tradeCash.UnwindStockEqvNotional) > parseFloat(this.trade.StockEqvNotional)) {
|
|
main.message("平仓名义本金不能大于持仓名义本金");
|
|
Checkflag = false;
|
|
}
|
|
} else {
|
|
//比例
|
|
if (!_.trim(_.toString(this.tradeCash.UnwindPercentRate))) {
|
|
main.message("平仓比例不能为空");
|
|
Checkflag = false;
|
|
}
|
|
if (parseFloat(this.tradeCash.TradeAmount) == 0) {
|
|
main.message("持仓数量为0,无法按比例换算");
|
|
Checkflag = false;
|
|
}
|
|
if (parseFloat(otcformat.trading.notional(this.tradeCash.TradeAmount)) < parseFloat(otcformat.trading.notional(this.tradeCash.UnwindPercentRate / 100 * this.trade.TradeOriginalAmount))) {
|
|
main.message("了结比例不能大于持仓数量比例");
|
|
Checkflag = false;
|
|
}
|
|
}
|
|
} else {
|
|
if (!_.trim(_.toString(this.tradeCash.UnwindTradeAmount))) {
|
|
main.message("平仓数量不能为空");
|
|
Checkflag = false;
|
|
}
|
|
if (parseFloat(this.tradeCash.TradeAmount) < parseFloat(this.tradeCash.UnwindTradeAmount)) {
|
|
main.message("了结数量不能大于持仓数量");
|
|
Checkflag = false;
|
|
}
|
|
}
|
|
this.childTradeCashs.forEach(function (dom, index) {
|
|
if (!_.trim(_.toString(dom.UnwindStockEqvNotional))) {
|
|
main.message("子交易编号" + dom.TradeNumber + ",了结名义本金不能为空");
|
|
Checkflag = false;
|
|
}
|
|
if (parseFloat(dom.StockEqvNotional) < parseFloat(dom.UnwindStockEqvNotional)) {
|
|
main.message("子交易编号" + dom.TradeNumber + ",了结名义本金不能大于持仓名义本金");
|
|
Checkflag = false;
|
|
}
|
|
if (!_.trim(_.toString(dom.UnwindTradeAmount))) {
|
|
main.message("子交易编号" + dom.TradeNumber + ",了结数量不能为空");
|
|
Checkflag = false;
|
|
}
|
|
if (parseFloat(dom.TradeAmount) < parseFloat(dom.UnwindTradeAmount)) {
|
|
main.message("子交易编号" + dom.TradeNumber + ",了结数量不能大于持仓数量");
|
|
Checkflag = false;
|
|
}
|
|
if (!_.trim(_.toString(dom.Amount))) {
|
|
main.message("子交易编号" + dom.TradeNumber + ",了结总额不能为空");
|
|
Checkflag = false;
|
|
}
|
|
})
|
|
return Checkflag;
|
|
},
|
|
saveGroupTradeCash: function () {
|
|
var thisobj = this;
|
|
if (thisobj.CheckDate()) {
|
|
main.post("/trade_cash/SaveGroupTradeCash", { trade_cash: thisobj.tradeCash, tradeIds: this.tradeIds, childTradeCashs: thisobj.childTradeCashs }).done(function (resp) {
|
|
if (resp.success) {
|
|
setTimeout(function () {
|
|
if (goToTradeGroupActionList) {
|
|
groupTradeCashActionList();
|
|
}
|
|
closeWindow(1);
|
|
}, 1000)
|
|
} else {
|
|
parent.main.message("保存失败");
|
|
}
|
|
|
|
});
|
|
}
|
|
},
|
|
closeWindow: function () {
|
|
closeWindow(0);
|
|
},
|
|
changeAction: function () {
|
|
this.unwindStockEqvActionDisabled = !((this.tradeCash.Action === '部分平仓' || this.tradeCash.Action === '部分提前行权') && this.trade.IsUsePremiumRate);
|
|
this.unwindTradeAmountActionDisabled = !((this.tradeCash.Action === '部分平仓' || this.tradeCash.Action === '部分提前行权') && !this.trade.IsUsePremiumRate);
|
|
if (this.tradeCash.Action === '部分平仓' || this.tradeCash.Action === '部分提前行权') {
|
|
this.CopyFromOld = true;
|
|
}
|
|
if (!(this.tradeCash.Action === '部分平仓' || this.tradeCash.Action === '部分提前行权') && this.CopyFromOld) {
|
|
this.tradeCash.UnwindPercentRate = this.oldUnwindPercentRate;
|
|
this.tradeCash.UnwindStockEqvNotional = this.oldUnwindStockEqvNotional;
|
|
this.tradeCash.UnwindTradeAmount = this.oldUnwindTradeAmount;
|
|
this.childTradeCashs.forEach(function (dom, index) {
|
|
dom.UnwindPercentRate = dom.oldUnwindPercentRate;
|
|
dom.UnwindStockEqvNotional = dom.oldUnwindStockEqvNotional;
|
|
dom.UnwindTradeAmount = dom.oldUnwindTradeAmount;
|
|
});
|
|
}
|
|
},
|
|
changeAmount: function () {
|
|
let amount = parseFloat(this.tradeCash.Amount);
|
|
var unwindAmountAngleIfValue = this.UnwindAmountAngleIfValue;
|
|
if (unwindAmountAngleIfValue && this.trade.BuySell === "卖出") {
|
|
amount = -amount;
|
|
}
|
|
let childTotalTradeAmount = 0;
|
|
this.childTradeCashs.forEach(function (dom, index) {
|
|
childTotalTradeAmount += parseFloat(dom.UnwindTradeAmount);
|
|
})
|
|
let singleAmount = amount / childTotalTradeAmount;
|
|
let self = this;
|
|
let zongAmount = 0;
|
|
this.childTradeCashs.forEach(function (dom, index) {
|
|
let isEqualBuySell = unwindAmountAngleIfValue ? dom.BuySell === "买入" ? 1 : -1 : 1;
|
|
dom.Amount = otcformat.trading.tradePrice(parseFloat(dom.UnwindTradeAmount) * singleAmount * isEqualBuySell);
|
|
zongAmount += parseFloat(otcformat.trading.tradePrice(parseFloat(dom.UnwindTradeAmount) * singleAmount));
|
|
})
|
|
//平仓总额不等于子交易平仓总额 小数特殊处理
|
|
if (zongAmount != amount) {
|
|
let isEqualBuySell = unwindAmountAngleIfValue ? this.childTradeCashs[0].BuySell === "买入" ? 1 : -1 : 1;
|
|
let offsetAmout = zongAmount - amount;
|
|
this.childTradeCashs[0].Amount = parseFloat(this.childTradeCashs[0].Amount * isEqualBuySell - offsetAmout) * isEqualBuySell;
|
|
}
|
|
},
|
|
changeUnwindPercentRate: function () {
|
|
if ((this.trade.IsUsePremiumRate == true) && this.tradeCash.TradeAmount == 0) {
|
|
main.message("持仓数量为0,无法按比例换算");
|
|
return false;
|
|
}
|
|
if ((this.trade.IsUsePremiumRate == true) && parseFloat(otcformat.trading.notional(this.tradeCash.TradeAmount)) < parseFloat(otcformat.trading.notional(this.tradeCash.UnwindPercentRate / 100 * this.trade.TradeOriginalAmount))) {
|
|
main.message("了结比例不能大于持仓数量比例");
|
|
return false;
|
|
}
|
|
let unwindPercentRate = parseFloat(this.tradeCash.UnwindPercentRate) / 100;
|
|
this.tradeCash.UnwindStockEqvNotional = parseFloat(this.tradeCash.UnwindPercentRate) / 100 * parseFloat(this.trade.OriginalStockEqvNotional);
|
|
this.tradeCash.UnwindTradeAmount = parseFloat(this.tradeCash.UnwindPercentRate) / 100 * parseFloat(this.trade.TradeOriginalAmount);
|
|
let self = this;
|
|
this.childTradeCashs.forEach(function (dom, index) {
|
|
dom.UnwindPercentRate = unwindPercentRate * 100;
|
|
dom.UnwindStockEqvNotional = parseFloat(otcformat.trading.StockEqvNotional(parseFloat(dom.OriginalStockEqvNotional) * unwindPercentRate));
|
|
dom.UnwindTradeAmount = parseFloat(otcformat.trading.notional(parseFloat(dom.TradeOriginalAmount) * unwindPercentRate));
|
|
});
|
|
this.$forceUpdate();//修改的值有时候无效,得强制刷新
|
|
},
|
|
changeUnwindTradeAmount: function () {
|
|
if ((this.trade.IsUsePremiumRate == false) && parseFloat(otcformat.trading.notional(this.tradeCash.TradeAmount)) < parseFloat(otcformat.trading.notional(this.tradeCash.UnwindTradeAmount))) {
|
|
main.message("了结数量不能大于持仓数量");
|
|
return false;
|
|
}
|
|
let unwindPercentRate = parseFloat(this.tradeCash.UnwindTradeAmount) / parseFloat(this.trade.TradeOriginalAmount);
|
|
this.tradeCash.UnwindPercentRate = unwindPercentRate * 100;
|
|
this.tradeCash.UnwindStockEqvNotional = parseFloat(this.trade.OriginalStockEqvNotional) * unwindPercentRate;
|
|
let self = this;
|
|
this.childTradeCashs.forEach(function (dom, index) {
|
|
dom.UnwindPercentRate = unwindPercentRate * 100;
|
|
dom.UnwindTradeAmount = parseFloat(otcformat.trading.notional(parseFloat(dom.TradeOriginalAmount) * unwindPercentRate));
|
|
dom.UnwindStockEqvNotional = parseFloat(otcformat.trading.StockEqvNotional(parseFloat(dom.OriginalStockEqvNotional) * unwindPercentRate));
|
|
});
|
|
this.$forceUpdate();//修改的值有时候无效,得强制刷新
|
|
},
|
|
changeUnwindStockEqvNotional: function () {
|
|
if ((this.trade.IsUsePremiumRate == true) && parseFloat(this.tradeCash.UnwindStockEqvNotional) == 0 || parseFloat(this.trade.StockEqvNotional) == 0) {
|
|
main.message("平仓持仓名义本金或持仓名义本金为0,无法计算");
|
|
return false;
|
|
}
|
|
if ((this.trade.IsUsePremiumRate == true) && parseFloat(this.tradeCash.UnwindStockEqvNotional) > parseFloat(this.trade.StockEqvNotional)) {
|
|
main.message("平仓名义本金不能大于持仓名义本金");
|
|
return false;
|
|
}
|
|
this.tradeCash.UnwindPercentRate = parseFloat(this.tradeCash.UnwindStockEqvNotional) / parseFloat(this.trade.OriginalStockEqvNotional);
|
|
this.tradeCash.UnwindTradeAmount = parseFloat(this.tradeCash.UnwindPercentRate) * parseFloat(this.trade.TradeOriginalAmount);
|
|
let self = this;
|
|
this.childTradeCashs.forEach(function (dom, index) {
|
|
dom.UnwindPercentRate = self.tradeCash.UnwindPercentRate * 100;
|
|
dom.UnwindStockEqvNotional = parseFloat(otcformat.trading.StockEqvNotional(parseFloat(dom.OriginalStockEqvNotional) * self.tradeCash.UnwindPercentRate));
|
|
dom.UnwindTradeAmount = parseFloat(otcformat.trading.notional(parseFloat(dom.TradeOriginalAmount) * self.tradeCash.UnwindPercentRate));
|
|
})
|
|
},
|
|
changeIsUsePremiumRate: function () {
|
|
groupVue.tradeCash.UnwindMethod = this.trade.IsUsePremiumRate == true ? 0 : 1;
|
|
this.unwindStockEqvActionDisabled = !((this.tradeCash.Action === '部分平仓' || this.tradeCash.Action === '部分提前行权') && this.trade.IsUsePremiumRate);
|
|
this.unwindTradeAmountActionDisabled = !((this.tradeCash.Action === '部分平仓' || this.tradeCash.Action === '部分提前行权') && !this.trade.IsUsePremiumRate);
|
|
if (this.trade.IsUsePremiumRate == false) {
|
|
if (this.tradeCash.IsUnwindStockEqvNotional) {
|
|
this.tradeCash.UnwindPercentRate = parseFloat(this.tradeCash.UnwindStockEqvNotional) / parseFloat(this.trade.OriginalStockEqvNotional);
|
|
} else {
|
|
this.tradeCash.UnwindStockEqvNotional = parseFloat(this.tradeCash.UnwindPercentRate / 100) * parseFloat(this.trade.OriginalStockEqvNotional);
|
|
}
|
|
this.tradeCash.UnwindTradeAmount = parseFloat(this.tradeCash.UnwindStockEqvNotional) / parseFloat(this.trade.OriginalStockEqvNotional) * parseFloat(this.trade.TradeOriginalAmount);
|
|
this.changeUnwindTradeAmount();
|
|
} else {
|
|
let unwindTradeRate = parseFloat(this.tradeCash.UnwindTradeAmount) / parseFloat(this.trade.TradeOriginalAmount);
|
|
if (this.tradeCash.IsUnwindStockEqvNotional) {
|
|
this.tradeCash.UnwindStockEqvNotional = unwindTradeRate * parseFloat(this.trade.OriginalStockEqvNotional);
|
|
this.tradeCash.UnwindPercentRate = unwindTradeRate * 100;
|
|
} else {
|
|
this.tradeCash.UnwindPercentRate = unwindTradeRate * 100;
|
|
this.tradeCash.UnwindTradeAmount = unwindTradeRate * parseFloat(this.trade.TradeOriginalAmount);
|
|
}
|
|
this.changeUnwindPercentRate();
|
|
}
|
|
},
|
|
changeChildUnwindTradeAmount: function (dom) {
|
|
dom.UnwindStockEqvNotional = otcformat.trading.StockEqvNotional(parseFloat(dom.OriginalStockEqvNotional) * parseFloat(dom.UnwindTradeAmount) / parseFloat(dom.TradeOriginalAmount));
|
|
},
|
|
changeChildUnwindStockEqvNotional: function (dom) {
|
|
dom.UnwindTradeAmount = otcformat.trading.notional(parseFloat(dom.UnwindStockEqvNotional) / parseFloat(dom.OriginalStockEqvNotional) * parseFloat(dom.TradeOriginalAmount));
|
|
},
|
|
changeChildAmount: function () {
|
|
let sumAmount = 0;
|
|
var unwindAmountAngleIfValue = this.UnwindAmountAngleIfValue;
|
|
let self = this;
|
|
this.childTradeCashs.forEach(function (dom, index) {
|
|
let isEqualBuySell = unwindAmountAngleIfValue ? dom.BuySell === "买入" ? 1 : -1 : 1;;
|
|
sumAmount += parseFloat(otcformat.trading.tradePrice(dom.Amount) * isEqualBuySell);
|
|
})
|
|
if (unwindAmountAngleIfValue && this.trade.BuySell === "卖出") {
|
|
sumAmount = -sumAmount;
|
|
}
|
|
this.tradeCash.Amount = sumAmount;
|
|
},
|
|
starttradeView: function (EncryptId) {
|
|
let srcurl = "/trade/tradeView/?enid=" + EncryptId + "&checkBtn=1";
|
|
//alert(srcurl);
|
|
parent.main.open("查看交易", srcurl);
|
|
},
|
|
refreshUnderlyingPrice: function () {
|
|
var thisObj = this;
|
|
parent.main.post("/underlying_manager/GetUnderlyingPriceByCode",
|
|
{ code: thisObj.trade.UnderlyingCode, tradeId: thisObj.trade.id, valuedate: thisObj.tradeCash.ValueDate }).done(function (res) {
|
|
thisObj.tradeCash.FinalPrice = res.obj;
|
|
thisObj.$forceUpdate();
|
|
});
|
|
},
|
|
exchangeToUnwindStockEqvNotional: function () {
|
|
this.tradeCash.IsUnwindStockEqvNotional = true;
|
|
if (this.tradeCash.UnwindType !== "全部平仓") {
|
|
this.tradeCash.UnwindStockEqvNotional = parseFloat(otcformat.trading.StockEqvNotional(parseFloat(this.tradeCash.UnwindPercentRate) / 100 * parseFloat(this.trade.OriginalStockEqvNotional)));
|
|
this.tradeCash.UnwindTradeAmount = parseFloat(otcformat.trading.notional(parseFloat(this.tradeCash.UnwindPercentRate) / 100 * parseFloat(this.tradeCash.TradeOriginalAmount)));
|
|
}
|
|
this.changeUnwindStockEqvNotional();
|
|
this.$forceUpdate();
|
|
},
|
|
exchangeToUnwindPercentRate: function () {
|
|
this.tradeCash.IsUnwindStockEqvNotional = false;
|
|
if (this.tradeCash.UnwindType !== "全部平仓") {
|
|
let unwindPercentRate = parseFloat(this.tradeCash.UnwindStockEqvNotional) / parseFloat(this.trade.OriginalStockEqvNotional);
|
|
this.tradeCash.UnwindPercentRate = parseFloat(otcformat.trading.premiumRatePLeft(unwindPercentRate) * 100);
|
|
//this.tradeCash.UnwindStockEqvNotional = parseFloat(otcformat.trading.StockEqvNotional(parseFloat(this.tradeCash.UnwindStockEqvNotional) / parseFloat(this.trade.OriginalStockEqvNotional) * parseFloat(this.trade.OriginalStockEqvNotional)));
|
|
this.tradeCash.UnwindTradeAmount = parseFloat(otcformat.trading.notional(unwindPercentRate * parseFloat(this.tradeCash.TradeOriginalAmount)));
|
|
}
|
|
this.changeUnwindPercentRate();
|
|
this.$forceUpdate();
|
|
},
|
|
init: function () {
|
|
},
|
|
review() {//复核
|
|
var thisobj = this;
|
|
main.confirm("确认复核平仓?", function () {
|
|
main.post("/trade_cash/UnwindParentTrade", { trade_cash: thisobj.tradeCash, tradeIds: thisobj.tradeIds, childTradeCashs: thisobj.childTradeCashs }).done(function (resp) {
|
|
if (resp.success) {
|
|
setTimeout(function () {
|
|
closeWindow(0);
|
|
}, 1000)
|
|
|
|
} else {
|
|
parent.main.message("复核失败");
|
|
}
|
|
|
|
});
|
|
});
|
|
},
|
|
reject() {//复核拒绝
|
|
var thisobj = this;
|
|
main.confirm("确认拒绝平仓?", function () {
|
|
main.post("/trade_cash/DenyReCheckByParent", { tradeId: thisobj.tradeIds[0] }).done(function (resp) {
|
|
if (resp.success) {
|
|
setTimeout(function () {
|
|
closeWindow(0);
|
|
}, 1000)
|
|
}
|
|
});
|
|
});
|
|
},
|
|
submitApproval(status) {//审批
|
|
var thisobj = this;
|
|
var pop = '';
|
|
if (status === 'pass') {
|
|
pop = "确认通过审批?";
|
|
}
|
|
if (status === 'reject') {
|
|
pop = "确认拒绝?";
|
|
}
|
|
var confirmFunc = function (additionalProcessing) {
|
|
var pData = { tradeId: thisobj.tradeIds[0], status: status, text: "" };
|
|
if (!main.isEmpty(additionalProcessing)) {
|
|
pData.additionalProcessing = additionalProcessing;
|
|
}
|
|
main.post("/processtradelog/UpdateParentTradeProcessLog", 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);
|
|
try { window.parent.reloadtrade(); }
|
|
catch (e) { }
|
|
if (parent) {
|
|
parent.layer.closeAll();
|
|
}
|
|
});
|
|
}
|
|
main.confirm(pop, confirmFunc);
|
|
}
|
|
},
|
|
|
|
components: {
|
|
'vue-datepicker': FastVue.vueDatePicker(),
|
|
'vue-number-input': FastVue.vueNumberInput()
|
|
},
|
|
}); |