394 lines
11 KiB
JavaScript
394 lines
11 KiB
JavaScript
var g_grid = {};
|
|
var query_data = {};
|
|
|
|
$(function () {
|
|
var PostData = {};
|
|
|
|
$(".datepicker").datepicker({
|
|
changeMonth: true,
|
|
changeYear: true,
|
|
showButtonPanel: true,
|
|
showOtherMonths: true,
|
|
selectOtherMonths: true
|
|
});
|
|
|
|
grid = jQuery('#listGrid').jqGrid({
|
|
cmTemplate: {
|
|
width: 80,
|
|
align: 'center',
|
|
sortable: false
|
|
},
|
|
url: '/swapTrade/TradeFlowHistoryQuery',
|
|
datatype: 'json',
|
|
height: 'auto',
|
|
width: '96%',
|
|
autowidth: false,
|
|
shrinkToFit: false,
|
|
viewrecords: true,
|
|
jsonReader: { repeatitems: false },
|
|
caption: '',
|
|
mtype: 'POST',
|
|
postData: PostData,
|
|
afterInsertRow: AfterInsertRow,
|
|
onSelectRow: rowclick,
|
|
ondblClickRow: rowdblclick,
|
|
colModel: colModelGrid,
|
|
pager: jQuery('#pagerGrid'),
|
|
pagerpos: 'left',
|
|
rowNum: 20,
|
|
rowList: [20, 30, 50, 200, 10000],
|
|
footerrow: false,
|
|
loadComplete: gridComplete,
|
|
onPaging: onJqgridPaging,
|
|
});
|
|
|
|
function keyEnter(event) {
|
|
try {
|
|
var e = event ? event : (window.event ? window.event : null);
|
|
if (e.keyCode === 13) {
|
|
SearchClick(true);
|
|
}
|
|
} catch (e) {
|
|
//
|
|
}
|
|
}
|
|
|
|
document.onkeydown = keyEnter;
|
|
});
|
|
|
|
var hideObj = { clientWidth: 160 };
|
|
|
|
var i = 0;
|
|
var getColModelGrid = function () {
|
|
return [
|
|
{
|
|
name: 'id',
|
|
label: 'id',
|
|
index: 'id',
|
|
sortIndex: i++,
|
|
width: 70,
|
|
align: 'center',
|
|
hidden: true,
|
|
optionHide: true
|
|
}, {
|
|
name: 'EncryptId',
|
|
label: 'EncryptId',
|
|
index: 'EncryptId',
|
|
sortIndex: i++,
|
|
width: 70,
|
|
align: 'center',
|
|
hidden: true,
|
|
optionHide: true
|
|
}, {
|
|
name: 'ClientName',
|
|
label: '客户名称',
|
|
index: 'ClientName',
|
|
sortIndex: i++,
|
|
width: 100,
|
|
align: 'center',
|
|
sortable: false
|
|
}, {
|
|
name: 'ContractId',
|
|
label: '交易编码',
|
|
index: 'ContractId',
|
|
sortIndex: i++,
|
|
width: 150,
|
|
align: 'center',
|
|
sortable: false
|
|
}, {
|
|
name: 'FlagExpired',
|
|
label: '是否到期',
|
|
index: 'FlagExpired',
|
|
sortIndex: i++,
|
|
width: 90,
|
|
align: 'center',
|
|
sortable: false
|
|
}, {
|
|
name: 'QuoteCurrency',
|
|
label: '计价货币',
|
|
index: 'QuoteCurrency',
|
|
sortIndex: i++,
|
|
width: 70,
|
|
align: 'center',
|
|
sortable: false
|
|
}, {
|
|
name: 'SettleCurrency',
|
|
label: '结算货币',
|
|
index: 'SettleCurrency',
|
|
sortIndex: i++,
|
|
width: 70,
|
|
align: 'center',
|
|
sortable: false
|
|
}, {
|
|
name: 'TradeDate',
|
|
label: '交易日期',
|
|
index: 'TradeDate',
|
|
sortIndex: i++,
|
|
width: 90,
|
|
align: 'center',
|
|
formatter: 'date',
|
|
sortable: false
|
|
}, {
|
|
name: 'ExpireDate',
|
|
label: '到期日',
|
|
index: 'ExpireDate',
|
|
sortIndex: i++,
|
|
width: 90,
|
|
align: 'center',
|
|
formatter: 'date',
|
|
sortable: false
|
|
}, {
|
|
name: 'SettleDate',
|
|
label: '交割日',
|
|
index: 'SettleDate',
|
|
sortIndex: i++,
|
|
width: 90,
|
|
align: 'center',
|
|
formatter: 'date',
|
|
sortable: false
|
|
}, {
|
|
name: 'Direction',
|
|
label: '客户买/卖',
|
|
index: 'Direction',
|
|
sortIndex: i++,
|
|
width: 90,
|
|
align: 'center',
|
|
sortable: false
|
|
}, {
|
|
name: 'PremiumDate',
|
|
label: '权利金日',
|
|
index: 'PremiumDate',
|
|
sortIndex: i++,
|
|
width: 90,
|
|
align: 'center',
|
|
formatter: 'date',
|
|
sortable: false
|
|
}, {
|
|
name: 'PremiumCNY',
|
|
label: '期权费¥',
|
|
index: 'PremiumCNY',
|
|
width: 90,
|
|
align: 'right',
|
|
sortable: false,
|
|
formatter: numberFormat
|
|
}, {
|
|
name: 'TradeType',
|
|
label: '衍生品类型',
|
|
index: 'TradeType',
|
|
sortIndex: i++,
|
|
width: 90,
|
|
align: 'center',
|
|
sortable: false
|
|
}, {
|
|
name: 'UnderlyingCode',
|
|
label: '标的代码',
|
|
index: 'UnderlyingCode',
|
|
sortIndex: i++,
|
|
width: 90,
|
|
align: 'center',
|
|
sortable: false
|
|
}, {
|
|
name: 'InitialLots',
|
|
label: '初始开仓手数',
|
|
index: 'InitialLots',
|
|
width: 90,
|
|
align: 'right',
|
|
sortable: false,
|
|
formatter: numberFormat
|
|
}, {
|
|
name: 'Lots',
|
|
label: '剩余手数',
|
|
index: 'Lots',
|
|
width: 90,
|
|
align: 'right',
|
|
sortable: false,
|
|
formatter: numberFormat
|
|
}, {
|
|
name: 'Size',
|
|
label: '合约乘数',
|
|
index: 'Size',
|
|
width: 90,
|
|
align: 'right',
|
|
sortable: false,
|
|
formatter: numberFormat
|
|
}, {
|
|
name: 'InitialSpotPrice',
|
|
label: '初始价格',
|
|
index: 'InitialSpotPrice',
|
|
width: 90,
|
|
align: 'right',
|
|
sortable: false,
|
|
formatter: numberFormat4
|
|
}, {
|
|
name: 'InitialRate',
|
|
label: '初始汇率',
|
|
index: 'InitialRate',
|
|
width: 90,
|
|
align: 'right',
|
|
sortable: false,
|
|
formatter: numberFormat4
|
|
}, {
|
|
name: 'SpotPrice',
|
|
label: '最新价格',
|
|
index: 'SpotPrice',
|
|
width: 90,
|
|
align: 'right',
|
|
sortable: false,
|
|
formatter: numberFormat4
|
|
}, {
|
|
name: 'Rate',
|
|
label: '最新汇率',
|
|
index: 'Rate',
|
|
width: 90,
|
|
align: 'right',
|
|
sortable: false,
|
|
formatter: numberFormat4
|
|
}, {
|
|
name: 'CommissionRate',
|
|
label: '佣金费率',
|
|
index: 'CommissionRate',
|
|
width: 90,
|
|
align: 'right',
|
|
sortable: false
|
|
}, {
|
|
name: 'EstimateCommision',
|
|
label: '预估佣金¥',
|
|
index: 'EstimateCommision',
|
|
width: 90,
|
|
align: 'right',
|
|
sortable: false,
|
|
formatter: numberFormat4
|
|
}, {
|
|
name: 'AnnualRate',
|
|
label: '年化手续费率',
|
|
index: 'AnnualRate',
|
|
width: 90,
|
|
align: 'right',
|
|
sortable: false,
|
|
formatter: percentFormat
|
|
}, {
|
|
name: 'EstimateAnnualFee',
|
|
label: '预估年化手续费¥',
|
|
index: 'EstimateAnnualFee',
|
|
width: 90,
|
|
align: 'right',
|
|
sortable: false,
|
|
formatter: numberFormat4
|
|
}, {
|
|
name: 'FloatingWinLossQuote',
|
|
label: '浮动收益(计价货币)',
|
|
index: 'FloatingWinLossQuote',
|
|
width: 90,
|
|
align: 'right',
|
|
sortable: false,
|
|
formatter: numberFormat
|
|
}, {
|
|
name: 'FloatingWinLoss',
|
|
label: '浮动收益(结算货币)',
|
|
index: 'FloatingWinLoss',
|
|
width: 90,
|
|
align: 'right',
|
|
sortable: false,
|
|
formatter: numberFormat4
|
|
}, {
|
|
name: 'UnRealizedPnl',
|
|
label: '未实现盈亏(结算货币)',
|
|
index: 'UnRealizedPnl',
|
|
width: 90,
|
|
align: 'right',
|
|
sortable: false,
|
|
formatter: numberFormat4
|
|
}, {
|
|
name: 'RealizedPnl',
|
|
label: '实现盈亏(结算货币)',
|
|
index: 'RealizedPnl',
|
|
width: 90,
|
|
align: 'right',
|
|
sortable: false,
|
|
formatter: numberFormat4
|
|
}
|
|
];
|
|
};
|
|
|
|
var colModelGrid = getColModelGrid();
|
|
|
|
function numberFormat(cellValue, options, rowObject) {
|
|
return main.formatNumber(cellValue, 2);
|
|
}
|
|
|
|
function numberFormat4(cellValue, options, rowObject) {
|
|
return main.formatNumber(cellValue, 4);
|
|
}
|
|
|
|
function percentFormat(cellValue, options, rowObject) {
|
|
return otcformat.fixed2P(cellValue);
|
|
}
|
|
|
|
function gridComplete() {
|
|
var newHeight = $(window).height() - 250;
|
|
$(".ui-jqgrid .ui-jqgrid-bdiv").css("cssText", "height: " + newHeight + "px!important;");
|
|
|
|
$('.ui-jqgrid-bdiv', '#gbox_listGrid').floatingScroll();
|
|
}
|
|
|
|
function boolFormater(cellValue, options, rowObject) {
|
|
var s = cellValue ? "是" : "否";
|
|
var html = "<label>{0}</label>".template(s);
|
|
return html;
|
|
}
|
|
|
|
function reloadtradeflow() {
|
|
//重新加载
|
|
SearchClick();
|
|
}
|
|
|
|
function SearchClick(isSearchclick) {
|
|
var listGrid = $('#listGrid');
|
|
|
|
listGrid.appendPostData({ ClientIds: $("#ClientId").val() });
|
|
listGrid.appendPostData({ UnderlyingCode: $("#UnderlyingCode").val() });
|
|
listGrid.appendPostData({ TradeDateStart: $("#DateFromTradeDate").val() });
|
|
listGrid.appendPostData({ TradeDateEnd: $("#DateToTradeDate").val() });
|
|
listGrid.appendPostData({ ExerciseDateStart: $("#DateFromExerciseDate").val() });
|
|
listGrid.appendPostData({ ExerciseDateEnd: $("#DateToExerciseDate").val() });
|
|
|
|
query_data = listGrid.jqGrid('getPostData');
|
|
if (typeof isSearchclick !== "undefined" && isSearchclick) {
|
|
//点击搜索时默认第一页
|
|
listGrid.jqGrid('setGridParam',
|
|
{
|
|
page: 1
|
|
});
|
|
}
|
|
|
|
listGrid.trigger('reloadGrid');
|
|
}
|
|
|
|
function uploadTradeFlowHistory() {
|
|
main.open("导入历史流水", "/swapTrade/tradeFlowHistoryUpload", { area: ['800px', '600px'] });
|
|
}
|
|
|
|
Array.prototype.contains = function (obj) {
|
|
if (this.length === 0) {
|
|
return false;
|
|
}
|
|
for (var i = 0; i < this.length; i++) {
|
|
if (this[i] === obj) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
//ESC
|
|
$(document).keyup(function (event) {
|
|
switch (event.keyCode) {
|
|
case 27:
|
|
window.parent.layer.closeAll();
|
|
$(".jconfirm-open").addClass("hide");//关闭取消分组弹层
|
|
}
|
|
});
|
|
$(".morebtn").click(function (e) {
|
|
$(".hidediv").toggle();
|
|
});
|
|
|
|
window.reloadData = reloadtradeflow; |