500 lines
16 KiB
JavaScript
500 lines
16 KiB
JavaScript
function getColModelGrid() {
|
|
var i = 0;
|
|
var colModelGrid = [
|
|
{
|
|
name: 'trade.id',
|
|
hidden: true,
|
|
optionHide: true
|
|
}, {
|
|
name: 'id',
|
|
hidden: true,
|
|
optionHide: true
|
|
}, {
|
|
name: 'trade.IsMoneynessOption',
|
|
label: 'trade.IsMoneynessOption',
|
|
index: 'trade.IsMoneynessOption',
|
|
sortIndex: i++,
|
|
width: 70,
|
|
align: 'center',
|
|
hidden: true,
|
|
optionHide: true
|
|
}, {
|
|
name: 'trade.SyntheticUnderlyingTipsInfo',
|
|
label: '组合标的信息',
|
|
index: 'trade.SyntheticUnderlyingTipsInfo',
|
|
sortIndex: i++,
|
|
width: 120,
|
|
align: 'left',
|
|
hidden: true,
|
|
optionHide: true
|
|
}, {
|
|
name: 'trade.EncryptId',
|
|
label: 'trade.EncryptId',
|
|
index: 'trade.EncryptId',
|
|
sortIndex: i++,
|
|
width: 70,
|
|
align: 'center',
|
|
hidden: true,
|
|
optionHide: true
|
|
}, {
|
|
name: 'trade.TradeStatus',
|
|
label: '交易状态',
|
|
index: 'trade.TradeStatus',
|
|
sortIndex: i++,
|
|
width: 90,
|
|
align: 'center'
|
|
}, {
|
|
name: 'trade.TradeNumber',
|
|
label: '交易编号',
|
|
index: 'trade.TradeNumber',
|
|
sortIndex: i++,
|
|
width: 150,
|
|
align: 'center'
|
|
}, {
|
|
name: 'trade.AssetBookName',
|
|
label: '簿记帐户',
|
|
index: 'trade.AssetBookName',
|
|
sortIndex: i++,
|
|
width: 150,
|
|
align: 'center'
|
|
}, {
|
|
name: 'trade.ClientName',
|
|
label: '交易对手方',
|
|
index: 'trade.ClientName',
|
|
sortIndex: i++,
|
|
width: 300,
|
|
align: 'center'
|
|
}, {
|
|
name: 'trade.TradeDate',
|
|
label: '成交日期',
|
|
index: 'trade.TradeDate',
|
|
sortIndex: i++,
|
|
width: 90,
|
|
align: 'center',
|
|
formatter: 'date'
|
|
}, {
|
|
name: 'trade.ExerciseDate',
|
|
label: '到期日期',
|
|
index: 'trade.ExerciseDate',
|
|
sortIndex: i++,
|
|
width: 90,
|
|
align: 'center',
|
|
formatter: 'date'
|
|
}, {
|
|
name: 'trade.BuySell',
|
|
label: '买卖方向',
|
|
index: 'trade.BuySell',
|
|
sortIndex: i++,
|
|
width: 70,
|
|
align: 'center'
|
|
}, {
|
|
name: 'trade.ExerciseMode',
|
|
label: '行权方式',
|
|
index: 'trade.ExerciseMode',
|
|
sortIndex: i++,
|
|
width: 70,
|
|
align: 'center',
|
|
formatter: function (cellValue, options, rowObject) {
|
|
return rowObject.trade.ExerciseModeCn;
|
|
}
|
|
}, {
|
|
name: 'trade.TradeType',
|
|
label: '结构类型',
|
|
index: 'trade.TradeType',
|
|
sortIndex: i++,
|
|
width: 70,
|
|
align: 'center',
|
|
formatter: function (cellvalue, options, rowObject) {
|
|
return rowObject.trade.StructureType && rowObject.trade.IsGroup != 2 ? rowObject.trade.StructureType : rowObject.trade.TradeType;
|
|
}
|
|
}, {
|
|
name: 'trade.OptionType',
|
|
label: '看涨看跌',
|
|
index: 'trade.OptionType',
|
|
sortIndex: i++,
|
|
width: 70,
|
|
align: 'center'
|
|
}, {
|
|
name: 'trade.UnderlyingCode',
|
|
label: '标的代码',
|
|
index: 'trade.UnderlyingCode',
|
|
sortIndex: i++,
|
|
width: 70,
|
|
align: 'center'
|
|
}, {
|
|
name: 'trade.UnderlyingName',
|
|
label: '标的名称',
|
|
index: 'trade.UnderlyingName',
|
|
sortIndex: i++,
|
|
width: 70,
|
|
align: 'center',
|
|
sortable: false
|
|
}, {
|
|
name: 'trade.InitialSpotPrice',
|
|
label: '期初标的价格',
|
|
index: 'trade.InitialSpotPrice',
|
|
sortIndex: i++,
|
|
width: 90,
|
|
align: 'right',
|
|
formatter: initialSpotPriceFormat,
|
|
sortable: false
|
|
}, {
|
|
name: 'trade.UnWindUnderlyingPrice',
|
|
label: '终止标的价格',
|
|
index: 'trade.UnWindUnderlyingPrice',
|
|
sortIndex: i++,
|
|
width: 90,
|
|
align: 'right',
|
|
formatter: commonStrikeFormat,
|
|
sortable: false
|
|
}
|
|
, {
|
|
name: 'trade.Strike',
|
|
label: '执行价格',
|
|
index: 'trade.Strike',
|
|
sortIndex: i++,
|
|
width: 90,
|
|
align: 'right',
|
|
formatter: strikeFormat
|
|
}, {
|
|
name: 'trade.UnWindUnderlyingPrice',//和列,终止时标的价格一个值。
|
|
label: '障碍水平',
|
|
index: 'trade.UnWindUnderlyingPrice',
|
|
sortIndex: i++,
|
|
width: 90,
|
|
align: 'center',
|
|
formatter: commonStrikeFormat,
|
|
sortable: false
|
|
}, {
|
|
name: 'trade_cash.UnwindPrice',
|
|
label: '退还款Rebate',
|
|
index: 'trade_cash.UnwindPrice',
|
|
sortIndex: i++,
|
|
width: 90,
|
|
align: 'right',
|
|
formatter: rebateFormat,
|
|
sortable: false
|
|
}, {
|
|
name: 'trade.TradeSinglePrice',
|
|
label: '权利金(成交)',
|
|
index: 'trade.TradeSinglePrice',
|
|
sortIndex: i++,
|
|
width: 90,
|
|
align: 'right',
|
|
formatter: TradeSinglePriceFormat
|
|
}, {
|
|
name: 'TradeOriginalAmount', label: '成交数量', width: 70, sortable: false,
|
|
formatter: function (cellvalue, options, rowObject) {
|
|
if (page.IsUseDisplayNotional) {
|
|
return otcformat.trading.notional(tradeHelper.getTradeAmountV(rowObject.trade) * (rowObject.trade.CountRatio || 1));
|
|
}
|
|
return otcformat.trading.notional(tradeHelper.getTradeAmountV(rowObject.trade));
|
|
}
|
|
}, {
|
|
name: 'trade.OriginalNotional',
|
|
label: '有效成交数量',
|
|
sortIndex: i++,
|
|
width: 96,
|
|
align: 'right',
|
|
sortable: false,
|
|
formatter: function (cellValue, options, rowObject) {
|
|
if (page.IsUseDisplayNotional) {
|
|
return otcformat.trading.notional(rowObject.trade.TradeOriginalAmount * (rowObject.trade.CountRatio || 1));
|
|
}
|
|
return otcformat.trading.notional(rowObject.trade.TradeOriginalAmount);
|
|
}
|
|
}, {
|
|
name: 'trade.TradePrice',
|
|
label: '成交总额',
|
|
index: 'trade.TradePrice',
|
|
sortIndex: i++,
|
|
width: 90,
|
|
align: 'right',
|
|
formatter: otcformat.trading.tradePrice
|
|
}, {
|
|
name: 'trade.trade_barrier_option.KnockInOutDate',
|
|
label: '敲出日期',
|
|
index: 'trade.trade_barrier_option.KnockInOutDate',
|
|
sortIndex: i++,
|
|
width: 90,
|
|
align: 'center',
|
|
formatter: function (cellValue, options, rowObject) {
|
|
if (rowObject.trade.TradeType === "障碍期权") {
|
|
return rowObject.trade.trade_barrier_option.KnockInOutDate;
|
|
}
|
|
else if (rowObject.trade.TradeType === "双鲨期权") {
|
|
return rowObject.trade.trade_double_sharkfin_option.KnockInOutDate;
|
|
}
|
|
else if (rowObject.trade.TradeType === "雪球期权") {
|
|
return rowObject.trade.trade_snowball.KnockInOutDate;
|
|
}
|
|
else if (rowObject.trade.TradeType === "凤凰期权") {
|
|
return rowObject.trade.trade_autocall.KnockInOutDate;
|
|
}
|
|
else if (rowObject.trade.TradeType === "累计期权")
|
|
{
|
|
return rowObject.trade.trade_accumulator_option.KnockOutDate;
|
|
}
|
|
else {
|
|
return "";
|
|
}
|
|
},
|
|
sortable: false
|
|
}, {
|
|
name: 'trade_cash.TradeAmount',
|
|
label: '敲出数量',
|
|
index: 'trade_cash.TradeAmount',
|
|
sortIndex: i++,
|
|
width: 90,
|
|
align: 'right',
|
|
formatter: function (cellvalue, options, rowObject) {
|
|
return otcformat.trading.notional(page.IsUseDisplayNotional ? cellvalue * (rowObject.trade.CountRatio || 1) : cellvalue);
|
|
}
|
|
}, {
|
|
name: 'trade_cash.Amount',
|
|
label: '退款总额',
|
|
index: 'trade_cash.Amount',
|
|
sortIndex: i++,
|
|
width: 90,
|
|
align: 'center',
|
|
formatter: otcformat.trading.tradePrice
|
|
}, {
|
|
name: 'trade.TraderName',
|
|
label: '交易员',
|
|
index: 'trade.TraderName',
|
|
sortIndex: i++,
|
|
width: 90,
|
|
align: 'center'
|
|
}
|
|
];
|
|
|
|
return colModelGrid;
|
|
}
|
|
|
|
function exportTrade() {
|
|
var dateTemp = new Date().Format("yyyyMMddhhmmss");
|
|
var fileName = "Trade_" + page.tabName + "_" + dateTemp;
|
|
main.toExcel("listGrid", fileName, "xls", null, "操作者,操作时间,操作", [{
|
|
colName: "标的代码",
|
|
formatter: function (cellValue, options, rowObject) {
|
|
if (rowObject["trade.TradeType"] === "合成价差期权") {
|
|
return rowObject.trade.SyntheticUnderlyingTipsInfo;
|
|
}
|
|
return cellValue;
|
|
}
|
|
}]);
|
|
}
|
|
|
|
var g_grid = {};
|
|
$(function () {
|
|
showTabTotalCount();
|
|
$("#Btn_BatchExpire").hide();
|
|
$("#tab1NotShow").hide();
|
|
$("#tab3_4NotShow").show();
|
|
var PostData = {};
|
|
PostData.ValueDateStart = page.valueDate;
|
|
PostData.ValueDateEnd = page.valueDate;
|
|
PostData.TabIndex = page.tabIndex;
|
|
PostData.IsHistoryWithUnconfirmed = true;
|
|
$(".datepicker").datepicker({
|
|
changeMonth: true,
|
|
changeYear: true,
|
|
showButtonPanel: true,
|
|
showOtherMonths: true,
|
|
selectOtherMonths: true
|
|
});
|
|
|
|
var colModelGrid = getColModelGrid();
|
|
grid = jQuery('#listGrid').jqGrid({
|
|
url: "/trade/tradeKnockedOutQuery",
|
|
datatype: 'json',
|
|
multiselect: true,
|
|
height: '500px',
|
|
width: '96%',
|
|
autowidth: false,
|
|
shrinkToFit: false,
|
|
viewrecords: true,
|
|
jsonReader: { repeatitems: false },
|
|
caption: '',
|
|
mtype: 'POST',
|
|
postData: PostData,
|
|
colModel: colModelGrid,
|
|
pager: jQuery('#pagerGrid'),
|
|
pagerpos: 'left',
|
|
ondblClickRow: rowdblclick,
|
|
rowNum: 500,
|
|
rowList: [20, 30, 50, 200,500, 10000],
|
|
footerrow: false,
|
|
loadComplete: gridComplete,
|
|
grouping: true
|
|
});
|
|
main.isSearching = true;
|
|
g_grid = jQuery('#listGrid');
|
|
|
|
function keyEnter(event) {
|
|
try {
|
|
var e = event || window.event || {};
|
|
if (e.keyCode === 13) {
|
|
SearchClick(true);
|
|
}
|
|
} catch (e) {
|
|
//
|
|
}
|
|
}
|
|
|
|
document.onkeydown = keyEnter;
|
|
let underlyingCtrl = new tradeHelper.UnderlyingSelectCtrl('#UnderlyingId').setFlag(tradeHelper.UnderlyingSelectFlag.OtcTrade);
|
|
});
|
|
|
|
function showTabTotalCount() {
|
|
main.post("/trade/tradeCountsOnValueDateQuery").done(function (data) {
|
|
for (var i in data) {
|
|
$(`#tab${i}`).find("a").attr("title", `总数${data[i]}笔`);
|
|
}
|
|
|
|
$(".selftooltip").tooltip({ html: true, show: 50000, trigger: "hover" });
|
|
});
|
|
}
|
|
|
|
function rowdblclick(rowid) {
|
|
var rowData = $(this).getRowData(rowid);
|
|
starttradeView(rowData["trade.EncryptId"], rowData["TradeType"]);
|
|
}
|
|
|
|
function doubleFormat(cellValue, options, rowObject) {
|
|
return main.formatNumber(cellValue);
|
|
}
|
|
|
|
function PercentFormat(cellValue, options, rowObject) {
|
|
if (cellValue) {
|
|
var num = new Number(cellValue) * 100;
|
|
return num.toFixed(2) + "%";
|
|
} else {
|
|
return "0.00%";
|
|
}
|
|
}
|
|
|
|
function rebateFormat(cellValue, options, rowObject) {
|
|
return rowObject.trade.IsUsePremiumRate ? otcformat.trading.premiumRateP(rowObject.trade_cash.UnwindPricePercentRate) : otcformat.trading.tradeSinglePrice(rowObject.trade_cash.UnwindPrice);
|
|
}
|
|
|
|
function TradeSinglePriceFormat(cellValue, options, rowObject) {
|
|
if (rowObject.trade.IsUsePremiumRate) {
|
|
return otcformat.trading.premiumRateP(rowObject.trade.PremiumRate);
|
|
}
|
|
else {
|
|
return otcformat.trading.tradeSinglePrice(cellValue);
|
|
}
|
|
}
|
|
|
|
function gridComplete() {
|
|
var jgrid = $(this);
|
|
var newHeight = $(window).height() - 400;
|
|
$(".ui-jqgrid .ui-jqgrid-bdiv").css("cssText", "height: " + newHeight + "px!important;");
|
|
$('.ui-jqgrid-bdiv', '#gbox_listGrid').floatingScroll();
|
|
|
|
$(".selftooltip").tooltip({ html: true, show: 50000, trigger: "hover" });
|
|
main.setcolumnChooser(jgrid, page.configcolumn_name);
|
|
}
|
|
|
|
function downloadFiles(files) {
|
|
if (files instanceof Array) {
|
|
if (files.length > 0) {
|
|
$.each(files, function (index, val) {
|
|
val && setTimeout(function () { window.open(val); }, 500);
|
|
});
|
|
}
|
|
} else {
|
|
files && window.open(files);
|
|
}
|
|
}
|
|
|
|
function initialSpotPriceFormat(cellValue, options, rowObject) {
|
|
return otcformat.trading.umprice(rowObject.trade.InitialSpotPrice || rowObject.trade.SpotPrice);
|
|
}
|
|
|
|
function strikeFormat(cellValue, options, rowObject) {
|
|
if (rowObject.trade.TradeType == "自定义交易") {
|
|
return rowObject.trade.StrikeToShow;
|
|
}
|
|
else if (rowObject.trade.TradeType === "收益互换") {
|
|
return "--";
|
|
}
|
|
|
|
if (rowObject.trade.Strike) {
|
|
if (rowObject.trade.IsMoneynessOption === "是") {
|
|
return otcformat.trading.umprice(rowObject.trade.InitialSpotPrice * rowObject.trade.Strike);
|
|
} else {
|
|
return otcformat.trading.umprice(rowObject.trade.Strike);
|
|
}
|
|
} else {
|
|
if (rowObject.trade.Strike === 0) {
|
|
return otcformat.trading.umprice(0);
|
|
}
|
|
else {
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
|
|
function commonStrikeFormat(cellValue, options, rowObject) {
|
|
return rowObject.trade.IsMoneynessOptionData ? otcformat.trading.umprice(rowObject.trade.InitialSpotPrice * cellValue) : otcformat.trading.umprice(cellValue);
|
|
}
|
|
|
|
function starttradeView(id, tradeType) {
|
|
main.open("查看交易", "/trade/tradeView/?enid={0}".template(id));
|
|
}
|
|
|
|
function reloadtrade() {
|
|
//重新加载
|
|
SearchClick();
|
|
}
|
|
|
|
function setGridPostData() {
|
|
var listGrid = $('#listGrid');
|
|
|
|
listGrid.appendPostData({ ClientIds: $("#ClientId").val() });
|
|
listGrid.appendPostData({ AssetIds: $("#AssetId").val() });
|
|
listGrid.appendPostData({ AssetIdGroupList: $("#GroupId").val() });
|
|
listGrid.appendPostData({ TraderIds: $("#TraderId").val() });
|
|
listGrid.appendPostData({ UnderlyingIds: $("#UnderlyingId").val() });
|
|
listGrid.appendPostData({ VarietyIds: $("#VarietyId").val() });
|
|
listGrid.appendPostData({ BuySell: $("#BuySell").val() });
|
|
listGrid.appendPostData({ OptionType: $("#OptionType").val() });
|
|
}
|
|
|
|
function SearchClick(isSearchclick) {
|
|
setGridPostData();
|
|
if (isSearchclick) {
|
|
//点击搜索时默认第一页
|
|
$('#listGrid').jqGrid('setGridParam', { page: 1 });
|
|
}
|
|
$('#listGrid').trigger('reloadGrid');
|
|
}
|
|
|
|
function showcolumnChooser() {
|
|
var jgrid = jQuery('#listGrid');
|
|
main.showcolumnChooser(jgrid, page.configcolumn_name);
|
|
}
|
|
|
|
function downCsv(fileName, exStrr, fileExtension) {
|
|
if (!fileExtension) {
|
|
fileExtension = ".csv";
|
|
}
|
|
var isIE = navigator.userAgent.indexOf('MSIE') >= 0;
|
|
if (isIE) {
|
|
var strHTML = exStrr;
|
|
var winSave = window.open();
|
|
winSave.document.open("text", "utf-8");
|
|
winSave.document.write(strHTML);
|
|
winSave.document.execCommand("SaveAs", true, fileName + fileExtension);
|
|
winSave.close();
|
|
} else {
|
|
var mimeType = 'text/plain';
|
|
$('#createInvote').attr('download', fileName + fileExtension);
|
|
//\uFEFF bom
|
|
$('#createInvote').attr('href',
|
|
'data:' + mimeType + ';charset=utf-8,\uFEFF' + encodeURIComponent(exStrr));
|
|
document.getElementById('createInvote').click();
|
|
}
|
|
} |