Files
zszq-trs/YLErpWeb/wwwroot/Scripts/app/trade/tradeApproval.js
T

1050 lines
43 KiB
JavaScript

var g_grid = {};
var roles = page.rolesStr;
$(function () {
var PostData = {};
$(".datepicker").datepicker({
changeMonth: true,
changeYear: true,
showButtonPanel: true,
showOtherMonths: true,
selectOtherMonths: true
});
grid = jQuery('#listGrid').jqGrid({
url: '/trade/tradeOpeningProcessQuery',
datatype: 'json',
multiselect: true,
height: 'auto',
width: '96%',
autowidth: false,
shrinkToFit: false,
viewrecords: true,
jsonReader: { repeatitems: false },
caption: '',
mtype: 'POST',
postData: PostData,
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
});
g_grid = jQuery('#listGrid');
function keyEnter(event) {
try {
var e = event ? event : (window.event ? window.event : null);
if (e.keyCode === 13) {
SearchClick(true);
}
} catch (e) {
//
}
}
document.onkeydown = keyEnter;
SetAceDropDown();
//标的品种 和 标的代码 联动
$("#UnderlyingAssetClass").change(function (obj) { changeUnderlyingAssetClass(obj); });
let underlyingCtrl = new tradeHelper.UnderlyingSelectCtrl('#UnderlyingId').setFlag(tradeHelper.UnderlyingSelectFlag.OtcTrade);
});
var colModelGrid = [
{
name: '',
label: '操作',
index: '',
align: 'center',
width: 140,
formatter: showToolName
},
{
name: 'ProcessStatus',
label: '交易审批状态',
index: 'ProcessStatus',
width: 60,
align: 'left'
},
{
name: 'ProcessRoleName',
label: '审批角色',
index: 'ProcessRoleName',
width: 60,
align: 'left'
},
{
name: 'id',
label: 'id',
index: 'id',
width: 1,
align: 'left',
hidden: true
}, {
name: 'EncryptId',
label: 'EncryptId',
index: 'EncryptId',
width: 0,
align: 'left',
hidden: true
}, {
name: 'UnderlyingId',
label: 'UnderlyingId',
index: 'UnderlyingId',
width: 0,
align: 'left',
hidden: true
}, {
name: 'TradePrice',
label: 'TradePrice',
index: 'TradePrice',
width: 0,
align: 'left',
hidden: true
},
{
name: 'GroupName',
label: '分组名',
index: 'GroupName',
width: 60
}, {
name: 'TradeStatus',
label: '交易状态',
index: 'TradeStatus',
width: 70,
align: 'left',
hidden: true
}, {
name: 'TradeNumber',
label: '交易编号',
index: 'TradeNumber',
width: 150,
align: 'left',
formatter: ShowStructFormater
}, {
name: 'ClientName',
label: '客户名称',
index: 'ClientName',
width: 70,
align: 'left'
}, {
name: 'TradeDate',
label: '交易日期',
index: 'TradeDate',
width: 90,
align: 'left',
formatter: 'date'
}, {
name: 'BuySell',
label: '交易方向',
index: 'BuySell',
width: 70,
align: 'left'
}, {
name: 'UnderlyingAssetName',
label: '标的名称',
index: 'UnderlyingAssetName',
width: 95,
align: 'left'
}, {
name: 'UnderlyingCode',
label: '标的合约',
index: 'UnderlyingCode',
width: 60,
align: 'left',
formatter: ShowStructFormater
}, {
name: 'InitialSpotPrice',
label: '期初标的价格',
index: 'InitialSpotPrice',
width: 85,
align: 'center',
sortable: false,
formatter: function (cellvalue, options, rowObject) {
if (rowObject.TradeType === "收益互换") {
return otcformat.flex(otcformat.trading.umprice(cellvalue), 2, 9, true, false, true);
}
return otcformat.trading.umprice(cellvalue);
}
}, {
name: 'ExerciseMode',
label: '行权方式',
index: 'ExerciseMode',
width: 90,
align: 'left',
formatter: function (cellvalue, options, rowObject) {
if (rowObject.TradeType === "远期") {
return "N/A";
}
return rowObject.ExerciseModeCn;
}
}, {
name: 'UnderlyingAssetClass',
label: '标的品种',
index: 'UnderlyingAssetClass',
width: 70,
align: 'left',
hidden: true
}, {
name: 'TradeType',
label: '结构类型',
index: 'TradeType',
width: 70,
align: 'left',
formatter: function (cellvalue, options, rowObject) {
return rowObject.StructureType && rowObject.IsGroup != 2 ? rowObject.StructureType : rowObject.TradeType;
}
}, {
name: 'OptionType',
label: '看涨看跌',
index: 'OptionType',
width: 70,
align: 'left'
}, {
name: 'ExerciseDate',
label: '到期日',
index: 'ExerciseDate',
width: 90,
align: 'left',
formatter: 'date'
}, {
name: 'Strike',
label: '行权价',
index: 'Strike',
width: 90,
align: 'right',
formatter: StrikeFormatter
}, {
name: 'Notional',
label: '份额',
index: 'Notional',
width: 70,
align: 'right',
formatter: DoubleFormat
}, {
name: 'AssetBookName',
label: '簿记账户',
index: 'AssetBookName',
width: 70,
align: 'left'
}, {
name: 'StartDate',
label: '开始日期',
index: 'StartDate',
width: 90,
align: 'left',
formatter: 'date',
hidden: true
}, {
name: 'MaturityDate',
label: '标的到期日',
index: 'MaturityDate',
width: 90,
align: 'left',
formatter: 'date',
hidden: true
}, {
name: 'TradeSinglePrice',
label: '权利金(成交)',
index: 'TradeSinglePrice',
width: 90,
align: 'center',
sortable: false,
formatter: TradeSinglePriceFormat
}, {
name: 'TradeOpenVolatility',
label: '成交波动率',
index: 'TradeOpenVolatility',
width: 80,
sortable: false,
align: 'center',
formatter: TradeOpenVolatilityFormatter
}, {
name: 'TraderName',
label: '交易员',
index: 'TraderName',
width: 70,
align: 'left'
}, {
name: 'Comments',
label: '备注',
index: 'Comments',
width: 70,
align: 'left',
hidden: true
}, {
name: 'OptName',
label: '操作者',
index: 'OptName',
width: 70,
align: 'left'
}, {
name: 'OptDate',
label: '操作时间',
index: 'OptDate',
width: 160,
align: 'left',
formatter: 'datetime'
},
];
function setStructTable(rowObject) {
structTrades = rowObject.SubTrades;
var trhtml = "";
var trcode = "<td>标的代码</td><td colspan='{0}'>{1}</td>".template(structTrades.length, rowObject.UnderlyingCode);
var trstrike = "<td>执行价格</td>";
var trbuysell = "<td>买卖方向</td>";
var trvarity = "<td>结构类型</td><td colspan='{0}'>{1}</td>".template(structTrades.length, rowObject.StructureType);
var trstockeqvnotional = "<td>名义本金</td><td colspan='{0}'>{1}</td>".template(structTrades.length, (new Number(rowObject.StockEqvNotional) / 10000).toFixed(2) + "万");
var trmaturedate = "<td>到期日期</td><td colspan='{0}'>{1}</td>".template(structTrades.length, moment(rowObject.ExerciseDate).format("YYYY-MM-DD"));
//trtradestatus = "<td>交易状态</td><td colspan='{0}'>{1}</td>".template(structTrades.length, rowObject.TradeStatus);
if (structTrades) {
for (var i = 0; i < structTrades.length; i++) {
trstrike += "<td>{0}</td>".template(structTrades[i].IsMoneynessOption === "是" ? (new Number(structTrades[i].Strike) * 100).toFixed(2) + "%" : structTrades[i].Strike);
trbuysell += "<td>{0}</td>".template(structTrades[i].BuySell);
}
}
trhtml = "<tr>{0}</tr>".template(trcode);
trhtml += "<tr>{0}</tr>".template(trstrike);
trhtml += "<tr>{0}</tr>".template(trbuysell);
trhtml += "<tr>{0}</tr>".template(trstockeqvnotional);
trhtml += "<tr>{0}</tr>".template(trmaturedate);
trhtml += "<tr>{0}</tr>".template(trvarity);
var showTable = "<table class='table'>{0}<table>".template(trhtml);
return showTable;
}
function ShowStructFormater(cellValue, options, rowObject) {
cellValue = cellValue || "";
var html;
//if (rowObject.TradeType === "结构化交易") {
// html = "<a href=\"#\" class=\"selftooltip\" style=\"z-index:10000000\" data-toggle=\"tooltip\" title=\"{1}\">{0}</a>"
// .template(cellValue, setStructTable(rowObject));
// return html;
//}
if (rowObject.TradeType === "合成价差期权") {
html =
"<a href=\"#\" class=\"selftooltip\" style=\"z-index:10000000\" data-toggle=\"tooltip\" title=\"{1}\">{0}</a>"
.template(cellValue, rowObject.SyntheticUnderlyingTipsInfo);
return html;
}
return cellValue;
}
function StrikeFormatter(cellValue, options, rowObject) {
if (rowObject.Strike) {
if (rowObject.IsMoneynessOption === "是") {
return otcformat.trading.premiumRateP(rowObject.Strike);
} else {
return otcformat.trading.umprice(rowObject.Strike);
}
} else {
if (rowObject.Strike === 0) {
return 0;
}
else {
return "";
}
}
}
function TradeOpenVolatilityFormatter(cellValue, options, rowObject) {
return !cellValue ? "" : otcformat.trading.premiumRateP(cellValue);
}
function DoubleFormat(cellValue, options, rowObject) {
return !cellValue ? "0.00" : otcformat.trading.notional(cellValue);
}
function gridComplete() {
$(".selftooltip").tooltip({ html: true, show: 50000, trigger: "hover" });
}
function TradeSinglePriceFormat(cellValue, options, rowObject) {
//收益互换“权利金(成交)” 取“互换交易单位交易费用”
if (rowObject.TradeType === "收益互换") {
if (cellValue) {
return otcformat.trading.tradeSinglePrice(cellValue);
}
else if (rowObject.PremiumRate) {
return otcformat.trading.premiumRateP(rowObject.PremiumRate);
}
}
//远期交易“权利金(成交)” 取“远期开仓费”
if (rowObject.TradeType === "远期" || rowObject.TradeType === "掉期") {
return otcformat.trading.tradeSinglePrice(cellValue);
}
if (rowObject.IsUsePremiumRate) {
return otcformat.trading.premiumRateP(rowObject.PremiumRate);
}
else {
return otcformat.trading.tradeSinglePrice(cellValue);
}
}
function customButton(cellValue, options, rowObject) {
var imageHtml = "<input type=\"button\" value=\"删除\" class=\"btn-warning\" onclick=\"deletetrade('" +
rowObject.EncryptId +
"');\" />";
return imageHtml;
}
function showToolName(cellValue, options, rowObject) {
var html;
if (rowObject.TradeStatus === "平仓待复核") {
//需要复核
if (rowObject.HasUnwindCheckRight) {
//有审批流程,该用户有该角色权限
if (isAuthorize(rowObject.ProcessRoleId) && page.CloseReApprove) {
//已经有审批人员对该交易进行了复核
if (rowObject.CheckStatus == 2) {
html =
"<input type=\"button\" class=\"wentiEdit\" title='查看交易信息' onclick=\"starttradeView('{0}','{1}')\" value=\"查看\" />"
.template(rowObject.EncryptId, rowObject.TradeType);
if (rowObject.TradeType === "结构化交易" && rowObject.IsGroup == 1) {
html = html + "<input type=\"button\" class=\"wentiEdit\" title='审批' onclick=\"parentUnWindSelect('{0}','审批',2)\" value=\"{1}\" />"
.template(rowObject.id, "审批");
} else {
if (page.IsTradeCheckInfo) {
html = html +
"<input type=\"button\" class=\"wentiEdit\" title='审批' onclick=\"passorreinfo('{0}','{1}','{2}','{3}','{5}')\" value=\"{4}\" />"
.template(rowObject.EncryptId, rowObject.TradeType, rowObject.TradeStatus, rowObject.IsGroup, "审批", rowObject.StructureType);
}
else {
html = html +
"<input type=\"button\" class=\"wentiEdit\" title='审批' onclick=\"passorreject('{0}')\" value=\"{1}\" />"
.template(rowObject.id, "审批");
}
}
}
else {
html =
"<input type=\"button\" class=\"wentiEdit\" title='查看交易信息' onclick=\"starttradeView('{0}','{1}')\" value=\"查看\" />"
.template(rowObject.EncryptId, rowObject.TradeType);
if (rowObject.TradeType === "结构化交易" && rowObject.IsGroup == 1) {
html = html + "<input type=\"button\" class=\"wentiEdit\" title='平仓复核' onclick=\"parentUnWindSelect('{0}','平仓复核',1)\" value=\"{1}\" />"
.template(rowObject.id, "平仓复核");
} else {
html = html + "<input type=\"button\" class=\"wentiEdit\" title='平仓复核' onclick=\"unWindSelect('{0}','{1}','check','{3}')\" value=\"{2}\" />"
.template(rowObject.EncryptId, rowObject.TradeType, "平仓复核", rowObject.StructureType);
}
}
}
//没有审批流程(包括审批参数配置为false或者没有审批流程即审批角色id为空),该用户有该角色权限
else if ((!page.CloseReApprove || !rowObject.ProcessRoleId) && page.hasRight1) {
html =
"<input type=\"button\" class=\"wentiEdit\" title='查看交易信息' onclick=\"starttradeView('{0}','{1}')\" value=\"查看\" />"
.template(rowObject.EncryptId, rowObject.TradeType);
if (rowObject.TradeType === "结构化交易" && rowObject.IsGroup == 1) {
html = html + "<input type=\"button\" class=\"wentiEdit\" title='平仓复核' onclick=\"parentUnWindSelect('{0}','平仓复核',1)\" value=\"{1}\" />"
.template(rowObject.id, "平仓复核");
} else {
html = html + "<input type=\"button\" class=\"wentiEdit\" title='平仓复核' onclick=\"unWindSelect('{0}','{1}','check','{3}')\" value=\"{2}\" />"
.template(rowObject.EncryptId, rowObject.TradeType, "平仓复核", rowObject.StructureType);
}
}
//没有审批权限
else {
//已经有审批人员对该交易进行了复核
if (rowObject.CheckStatus == 2) {
html =
"<input type=\"button\" class=\"wentiEdit\" title='查看交易信息' disabled='disabled' onclick=\"starttradeView('{0}','{1}')\" value=\"查看\" />"
.template(rowObject.EncryptId, rowObject.TradeType);
html = html +
"<input type=\"button\" class=\"wentiEdit\" title='审批' disabled='disabled' value=\"{1}\" />"
.template(rowObject.EncryptId, "审批");
}
else {
html =
"<input type=\"button\" class=\"wentiEdit\" title='查看交易信息' disabled='disabled' onclick=\"starttradeView('{0}','{1}')\" value=\"查看\" />"
.template(rowObject.EncryptId, rowObject.TradeType);
html = html + "<input type=\"button\" class=\"wentiEdit\" title='平仓复核' disabled='disabled' value=\"{2}\" />"
.template(rowObject.EncryptId, rowObject.TradeType, "平仓复核");
}
}
}
//不需要复核,只需要审批
else {
//有审批权限
if (isAuthorize(rowObject.ProcessRoleId)) {
html =
"<input type=\"button\" class=\"wentiEdit\" title='查看交易信息' onclick=\"starttradeView('{0}','{1}')\" value=\"查看\" />"
.template(rowObject.EncryptId, rowObject.TradeType);
if (rowObject.TradeType === "结构化交易" && rowObject.IsGroup == 1) {
html = html + "<input type=\"button\" class=\"wentiEdit\" title='审批' onclick=\"parentUnWindSelect('{0}','审批',2)\" value=\"{1}\" />"
.template(rowObject.id, "审批");
} else {
if (page.IsTradeCheckInfo) {
html = html +
"<input type=\"button\" class=\"wentiEdit\" title='审批' onclick=\"passorreinfo('{0}','{1}','{2}','{3}','{5}')\" value=\"{4}\" />"
.template(rowObject.EncryptId, rowObject.TradeType, rowObject.TradeStatus, rowObject.IsGroup, "审批", rowObject.StructureType);
}
else {
html = html +
"<input type=\"button\" class=\"wentiEdit\" title='审批' onclick=\"passorreject('{0}')\" value=\"{1}\" />"
.template(rowObject.id, "审批");
}
}
}
//无审批权限
else {
html =
"<input type=\"button\" class=\"wentiEdit\" title='查看交易信息' disabled='disabled' onclick=\"starttradeView('{0}','{1}')\" value=\"查看\" />"
.template(rowObject.EncryptId, rowObject.TradeType);
html = html +
"<input type=\"button\" class=\"wentiEdit\" title='审批' disabled='disabled' value=\"{1}\" />"
.template(rowObject.EncryptId, "审批");
}
}
}
else if (rowObject.TradeStatus === "行权待复核") {
//需要复核
if (rowObject.HasExerciseCheckRight) {
//有审批流程,该用户有该角色权限
if (isAuthorize(rowObject.ProcessRoleId) && page.CloseReApprove) {
//已经有审批人员对该交易进行了复核
if (rowObject.CheckStatus == 3) {
html =
"<input type=\"button\" class=\"wentiEdit\" title='查看交易信息' onclick=\"starttradeView('{0}','{1}')\" value=\"查看\" />"
.template(rowObject.EncryptId, rowObject.TradeType);
if (rowObject.TradeType === "结构化交易" && rowObject.IsGroup == 1) {
html = html + "<input type=\"button\" class=\"wentiEdit\" title='审批' onclick=\"parentUnWindSelect('{0}','审批',2)\" value=\"{1}\" />"
.template(rowObject.id, "审批");
} else {
if (page.IsTradeCheckInfo) {
html = html +
"<input type=\"button\" class=\"wentiEdit\" title='审批' onclick=\"passorreinfo('{0}','{1}','{2}','{3}','{5}')\" value=\"{4}\" />"
.template(rowObject.EncryptId, rowObject.TradeType, rowObject.TradeStatus, rowObject.IsGroup, "审批", rowObject.StructureType);
}
else {
html = html +
"<input type=\"button\" class=\"wentiEdit\" title='审批' onclick=\"passorreject('{0}')\" value=\"{1}\" />"
.template(rowObject.id, "审批");
}
}
}
else {
html =
"<input type=\"button\" class=\"wentiEdit\" title='查看交易信息' onclick=\"starttradeView('{0}','{1}')\" value=\"查看\" />"
.template(rowObject.EncryptId, rowObject.TradeType);
if (rowObject.TradeType === "结构化交易" && rowObject.IsGroup == 1) {
html = html + "<input type=\"button\" class=\"wentiEdit\" title='行权复核' onclick=\"parentUnWindSelect('{0}','行权复核',1)\" value=\"{1}\" />"
.template(rowObject.id, "行权复核");
} else {
html = html + "<input type=\"button\" class=\"wentiEdit\" title='行权复核' onclick=\"executionTrade('{0}',true)\" value=\"{1}\" />"
.template(rowObject.EncryptId, "行权复核");
}
}
}
//没有审批流程(包括审批config为false或者没有审批流程即审批角色id为空),该用户有该角色权限
else if ((!page.CloseReApprove || !rowObject.ProcessRoleId) && page.hasRight2) {
html =
"<input type=\"button\" class=\"wentiEdit\" title='查看交易信息' onclick=\"starttradeView('{0}','{1}')\" value=\"查看\" />"
.template(rowObject.EncryptId, rowObject.TradeType);
if (rowObject.TradeType === "结构化交易" && rowObject.IsGroup == 1) {
html = html + "<input type=\"button\" class=\"wentiEdit\" title='行权复核' onclick=\"parentUnWindSelect('{0}','行权复核',1)\" value=\"{1}\" />"
.template(rowObject.id, "行权复核");
} else {
html = html + "<input type=\"button\" class=\"wentiEdit\" title='行权复核' onclick=\"executionTrade('{0}',true)\" value=\"{1}\" />"
.template(rowObject.EncryptId, "行权复核");
}
}
//没有审批权限
else {
//已经有审批人员对该交易进行了复核
if (rowObject.CheckStatus == 3) {
html =
"<input type=\"button\" class=\"wentiEdit\" title='查看交易信息' disabled='disabled' onclick=\"starttradeView('{0}','{1}')\" value=\"查看\" />"
.template(rowObject.EncryptId, rowObject.TradeType);
html = html +
"<input type=\"button\" class=\"wentiEdit\" title='审批' disabled='disabled' value=\"{1}\" />"
.template(rowObject.EncryptId, "审批");
}
else {
html =
"<input type=\"button\" class=\"wentiEdit\" title='查看交易信息' disabled='disabled' onclick=\"starttradeView('{0}','{1}')\" value=\"查看\" />"
.template(rowObject.EncryptId, rowObject.TradeType);
html = html + "<input type=\"button\" class=\"wentiEdit\" title='行权复核' disabled='disabled' value=\"{1}\" />"
.template(rowObject.EncryptId, "行权复核");
}
}
}
//不需要复核,只需要审批
else {
//有审批权限
if (isAuthorize(rowObject.ProcessRoleId)) {
html =
"<input type=\"button\" class=\"wentiEdit\" title='查看交易信息' onclick=\"starttradeView('{0}','{1}')\" value=\"查看\" />"
.template(rowObject.EncryptId, rowObject.TradeType);
if (rowObject.TradeType === "结构化交易" && rowObject.IsGroup == 1) {
html = html + "<input type=\"button\" class=\"wentiEdit\" title='审批' onclick=\"parentUnWindSelect('{0}','审批',2)\" value=\"{1}\" />"
.template(rowObject.id, "审批");
} else {
if (page.IsTradeCheckInfo) {
html = html +
"<input type=\"button\" class=\"wentiEdit\" title='审批' onclick=\"passorreinfo('{0}','{1}','{2}','{3}','{5}')\" value=\"{4}\" />"
.template(rowObject.EncryptId, rowObject.TradeType, rowObject.TradeStatus, rowObject.IsGroup, "审批", rowObject.StructureType);
}
else {
html = html +
"<input type=\"button\" class=\"wentiEdit\" title='审批' onclick=\"passorreject('{0}')\" value=\"{1}\" />"
.template(rowObject.id, "审批");
}
}
}
//无审批权限
else {
html =
"<input type=\"button\" class=\"wentiEdit\" title='查看交易信息' disabled='disabled' onclick=\"starttradeView('{0}','{1}')\" value=\"查看\" />"
.template(rowObject.EncryptId, rowObject.TradeType);
html = html +
"<input type=\"button\" class=\"wentiEdit\" title='审批' disabled='disabled' value=\"{1}\" />"
.template(rowObject.EncryptId, "审批");
}
}
}
else {
if (rowObject.TradeType != "收益互换") {//复核角色权限,收益互换不参与复核
if (isAuthorize(rowObject.ProcessRoleId)) {
if (rowObject.ApprovalRules == "1") {
html =
"<input type=\"button\" class=\"wentiEdit\" title='查看交易信息' onclick=\"starttradeView('{0}','{1}')\" value=\"查看\" />"
.template(rowObject.EncryptId, rowObject.TradeType);
html = html +
"<input type=\"button\" class=\"wentiEdit\" title='规模审批' onclick=\"scaleCheck('{0}')\" value=\"规模审批\" />"
.template(rowObject.id);
}
else if (!rowObject.ApprovalRules || rowObject.CheckStatus == 1) {
html =
"<input type=\"button\" class=\"wentiEdit\" title='查看交易信息' onclick=\"starttradeView('{0}','{1}')\" value=\"查看\" />"
.template(rowObject.EncryptId, rowObject.TradeType);
if (page.IsTradeCheckInfo) {
html = html +
"<input type=\"button\" class=\"wentiEdit\" title='审批' onclick=\"passorreinfo('{0}','{1}','{2}','{3}','{5}')\" value=\"{4}\" />"
.template((rowObject.IsGroup == 1 ? rowObject.id : rowObject.EncryptId), rowObject.TradeType, rowObject.TradeStatus, rowObject.IsGroup, "审批", rowObject.StructureType);
}
else {
html = html +
"<input type=\"button\" class=\"wentiEdit\" title='审批' onclick=\"passorreject('{0}')\" value=\"{1}\" />"
.template(rowObject.id, "审批");
}
}
else {
html =
"<input type=\"button\" class=\"wentiEdit\" title='复核交易信息不能查看交易信息' disabled='disabled' onclick=\"starttradeView('{0}','{1}')\" value=\"查看\" />"
.template(rowObject.EncryptId, rowObject.TradeType);
html = html +
"<input type=\"button\" class=\"wentiEdit\" title=" + ((rowObject.ApprovalRules && rowObject.ApprovalRules.indexOf("0") > -1) ? "'该流程包括规模审批'" : "'复核审批'") + " onclick=\"passorrecheck('{0}','{1}','{2}')\" value=\"复核审批\" />"
.template(rowObject.id, rowObject.TradeType, rowObject.IsGroup);
}
} else {
html =
"<input type=\"button\" class=\"wentiEdit\" title='查看交易信息' onclick=\"starttradeView('{0}','{1}')\" value=\"查看\" />"
.template(rowObject.EncryptId, rowObject.TradeType);
html = html +
"<input type=\"button\" class=\"wentiEdit\" title='复核审批' disabled='disabled' value=\"{1}\" />"
.template(rowObject.id, "复核审批");
}
}
else {
if (isAuthorize(rowObject.ProcessRoleId)) {
if (rowObject.ApprovalRules == "1") {
html =
"<input type=\"button\" class=\"wentiEdit\" title='查看交易信息' onclick=\"starttradeView('{0}','{1}')\" value=\"查看\" />"
.template(rowObject.EncryptId, rowObject.TradeType);
html = html +
"<input type=\"button\" class=\"wentiEdit\" title='规模审批' onclick=\"scaleCheck('{0}')\" value=\"规模审批\" />"
.template(rowObject.id);
} else {
html =
"<input type=\"button\" class=\"wentiEdit\" title='查看交易信息' onclick=\"starttradeView('{0}','{1}')\" value=\"查看\" />"
.template(rowObject.EncryptId, rowObject.TradeType);
if (page.IsTradeCheckInfo) {
html = html +
"<input type=\"button\" class=\"wentiEdit\" title='审批' onclick=\"passorreinfo('{0}','{1}','{2}','{3}','{5}')\" value=\"{4}\" />"
.template(rowObject.EncryptId, rowObject.TradeType, rowObject.TradeStatus, rowObject.IsGroup, "审批", rowObject.StructureType);
}
else {
html = html +
"<input type=\"button\" class=\"wentiEdit\" title='审批' onclick=\"passorreject('{0}')\" value=\"{1}\" />"
.template(rowObject.id, "审批");
}
}
}
else {
html =
"<input type=\"button\" class=\"wentiEdit\" title='查看交易信息' onclick=\"starttradeView('{0}','{1}')\" value=\"查看\" />"
.template(rowObject.EncryptId, rowObject.TradeType);
html = html +
"<input type=\"button\" class=\"wentiEdit\" title='审批' disabled='disabled' value=\"{1}\" />"
.template(rowObject.EncryptId, "审批");
}
}
}
//if (page.hasHistory) {
// html += "<input type=\"button\" class=\"wentiEdit\" title='{1}' onclick = \"tradeTrialHistory('{0}')\" value=\"{1}\" />"
// .template((rowObject.ParentTradeId == 0 ? rowObject.id : rowObject.ParentTradeId), '试算历史');
//}
return html;
}
function tradeTrialHistory(tradeId) {
main.open("试算历史", "/trade/quotaTrialHistory?TradeId=" + tradeId, { area: ["1200px", "600px"] });
}
function passorreject(eid) {
var url = "/processtradelog/processtradelogListInner?eid=" + eid;
main.open("审批", url, { area: ['900px', '600px'] });
}
function passorreinfo(eid, tradeType, status, isGroup, StructureType) {
var url = "";
var title = "审批";
var height = "900px";
var weight = "1300px";
if (status === "平仓待复核") {
title = "平仓审批";
if (tradeType === "远期") {
url = "/forwardtrade/tradeUnwind/?enid=" + eid + "&isUseApproval=" + true;
height = "600px";
}
else if (tradeType === "自定义交易") {
url = "/trade/tradeCustomizedUnwind/?enid=" + eid + "&isUseApproval=" + true;
}
else if (tradeType === "收益互换") {
weight = "95%";
url = "/swaptrade2/SwapUnwind/?enid=" + eid + "&isUseApproval=" + true;
if (StructureType == "多空组合") {
url = "/swaptrade2/SwapLongShortUnwind/?enid=" + eid + "&isUseApproval=" + true;
}
height = "800px";
}
else {
url = "/trade/tradeUnwind/?enid=" + eid + "&isUseApproval=" + true;
}
}
else if (status === "互换待复核") {
weight = "95%";
title = "互换审批";
url = "/swaptrade2/SwapIncome/?enid=" + eid + "&isUseApproval=" + true;
if (StructureType == "多空组合") {
url = "/swaptrade2/SwapLongShortSwap/?enid=" + eid + "&isUseApproval=" + true;
}
height = "720px";
}
else if (status === "行权待复核") {
title = "行权审批";
url = "/trade_cash/executionTradeCash/?enid=" + eid + "&isUseApproval=" + true;
}
else {
if (tradeType === "远期") {
url = "/forwardtrade/tradeEditV2?enid=" + eid + "&isUseApproval=" + true;
}
else if (tradeType === "收益互换") {
url = "/swapTrade2/tradeEdit?enid=" + eid + "&isUseApproval=" + true;
weight = "95%";
height = "90%";
}
else if (isGroup == 1) {
url = "/trade/tradeCheckGroup?enid=" + eid + "&isUseApproval=" + true;
weight = "1000px";
}
else {
url = "/trade/tradeEdit?enid=" + eid + "&isUseApproval=" + true;
}
}
main.open(title, url, {
area: [weight, height],
end: function () {
reloadtrade();
}
});
}
//开仓复核
function passorrecheck(eid, tradeType, isGroup) {
if (tradeType.indexOf("远期") >= 0) {
main.open("复核审批", "/forwardtrade/tradeCheck2?enid=" + eid, { area: ["1340px", "800px"] });
}
else if (isGroup == 1) {
main.open("复核审批", "/trade/tradeCheckGroup?enid=" + eid, { area: ["1000px", "800px"] });
}
else {
main.open("复核审批", "/trade/tradeCheck?enid=" + eid, { area: ["1340px", "800px"] });
}
}
function scaleCheck(eid, isContinue) {
var doneFunc = function (res) {
if (res.obj) {
if (res.obj == "下一步") {
main.open2("提示", `<div style="padding:10px">${res.msg}</div>`,
{
area: ["430px", "175px"],
btn: ['确认', '拒绝', '取消'],
yes: function (index, layero) {
scaleCheck(eid, true);
},
btn2: function (index, layero) {
var pData = { tradeId: eid, status: "reject", text: "投资规模不足" };
main.post("/processtradelog/UpdateTradeProcessLog", pData).done(reloadtrade);
},
cancel: function (index, layero) {
reloadtrade();
}
});
}
else if (res.obj == "无下一步") {
main.open2("提示", `<div style="padding:10px">${res.msg}</div>`,
{
area: ["430px", "175px"],
btn: ['拒绝', '取消'],
yes: function (index, layero) {
var pData = { tradeId: eid, status: "reject", text: "投资规模不足" };
main.post("/processtradelog/UpdateTradeProcessLog", pData).done(reloadtrade);
},
cancel: function (index, layero) {
reloadtrade();
}
});
}
} else if (isContinue || res.success) {
reloadtrade();
}
}
main.post("/trade/CheckTradeScale?eid=" + eid + "&isContinue=" + isContinue).done(doneFunc);
//reloadtrade();
}
function unWindSelect(id, tradeType, isReCheck, StructureType) {
if (tradeType === "商品期货") {
var message = "\"" + tradeType + "\"不允许平仓操作!";
main.confirm(message, function () { });
return;
}
var title = "交易平仓";
if (isReCheck) title = "平仓复核";
//障碍期权特殊处理 敲入时状态必须不为空才为有效 敲出时状态为空为有效
if (tradeType === "障碍期权") {
main.post("/trade/checkBarrierUnwind", { enid: id }).done(function (res) {
if (!res.success) {
main.alert(data.msg);
return;
} else {
var srcurl = "/trade/tradeUnwind/?enid=" + id;
if (isReCheck) srcurl += "&isrecheck=" + isReCheck;
main.open(title, srcurl, {
area: ["1200px", "570px"],
end: function () {
reloadtrade();
}
});
}
});
} else {
if (tradeType === "远期") {
let srcurl = "/forwardtrade/tradeUnwind/?enid=" + id;
if (isReCheck) srcurl += ("&isrecheck=" + isReCheck);
main.open(title, srcurl, {
area: ["1200px", "570px"],
end: function () {
reloadtrade();
}
});
}
else if (tradeType === "自定义交易") {
let srcurl = "/trade/tradeCustomizedUnwind/?enid=" + id;
if (isReCheck) srcurl += "&isrecheck=" + isReCheck;
main.open(title, srcurl, {
area: ["1260px", "800px"],
end: function () {
reloadtrade();
}
});
} else if (tradeType == "收益互换") {
var url = "/swaptrade2/SwapUnwind/?enid=" + id + "&isUseApproval=" + true;;
if (StructureType == "多空组合") {
url = "/swaptrade2/SwapLongShortUnwind/?enid=" + id + "&isUseApproval=" + true;;
}
main.open(title, url, {
area: ["1300px", "720px"],
end: function () {
reloadtrade();
}
});
}
else {
var srcurl = "/trade/tradeUnwind/?enid=" + id;
if (isReCheck) srcurl += "&isrecheck=" + isReCheck;
main.open(title, srcurl, {
area: ["1260px", "800px"],
end: function () {
reloadtrade();
}
});
}
}
}
function parentUnWindSelect(id, title, reCheck) {
var srcurl = "/trade/tradeSettle/?ids=" + id + "&&reCheck=" + reCheck;
main.open(title, srcurl, {
area: ["1220px", "100%"],
end: function () {
reloadtrade();
}
});
}
function executionTrade(id, isReCheck) {
var srcurl = "/trade_cash/executionTradeCash/?enid=" + id;
var title = "执行期权";
if (isReCheck) title = "行权复核";
main.open(title,
srcurl,
{
end: function () {
if (window.parent && window.parent.reloadtrade) {
window.parent.reloadtrade();
}
//closetradeWindow(); 自定义交易 行权复核窗口打开报错
}, area: ["1000px", "800px"]
});
}
function isAuthorize(roleId) {
if (roleId === 'undefined') return false;
var roleIdStr = roleId + "";
if (roleIdStr === "") return false;
var rolesArr = roles.split(",");
var len = roles.length;
if (len <= 0) return false;
for (var i = 0; i < len; i++) {
if (rolesArr[i] === roleIdStr) {
return true;
}
}
return false;
}
function starttradeView(id, tradeType) {
if (tradeType.indexOf("远期") >= 0) {
let srcurl = "/forwardtrade/tradeView/?enid=" + id + "&isOnlyCloseButton=true";
main.open("查看远期交易", srcurl, { area: ['1260px', '800px'] });
}
else if (tradeType == "收益互换") {
main.open("查看交易", "/swaptrade2/tradeView/?enid=" + id + "&isOnlyCloseButton=true", { area: ['90%', '90%'] });
}
else {
let srcurl = "/trade/tradeView/?enid=" + id + "&isOnlyCloseButton=true";
main.open("查看交易", srcurl, { area: ['1260px', '800px'] });
}
}
function pass(eid) {
var url = "/processlog/processlogListInner?eid=" + eid + "&status=pass";
main.open("审批", url);
}
function reject(eid) {
var url = "/processlog/processlogListInner?eid=" + eid + "&status=reject";
main.open("审批", url);
}
function deletetrade(encryptId) {
if (confirm("确定删除吗?")) {
$.ajax({
type: "Post",
url: "/trade/InValidTrade",
data: { id: encryptId, d: new Date() },
success: function (data) {
showmiddlemessage(data.obj);
if (data.success) {
$('#listGrid').trigger('reloadGrid');
}
},
error: function (msg) {
alert("error:" + msg);
}
});
}
}
function reloadtrade() {
//重新加载
SearchClick();
window.layer.closeAll();
}
function SearchClick(isSearchclick) {
var listGrid = $('#listGrid');
listGrid.appendPostData({ TradeNumber: $("#TradeNumber").val() });
listGrid.appendPostData({ AssetIds: ($("#AssetId").val() || []).join(",") });
listGrid.appendPostData({ AssetIdGroupList: $("#GroupId").val() });
listGrid.appendPostData({ ClientIds: ($("#ClientId").val() || []).join() });
listGrid.appendPostData({ AssetType: $("#AssetType").val() });
listGrid.appendPostData({ UnderlyingIds: ($("#UnderlyingId").val() || []).join(",") });
listGrid.appendPostData({
TradeTypes: ($("#TradeTypes").val() || []).join(",")
});
listGrid.appendPostData({ TradeDateStart: $("#DateFromTradeDate").val() });
listGrid.appendPostData({ TradeDateEnd: $("#DateToTradeDate").val() });
listGrid.appendPostData({ BuySell: $("#BuySell").val() });
listGrid.appendPostData({ StartDateStart: $("#DateFromStartDate").val() });
listGrid.appendPostData({ StartDateEnd: $("#DateToStartDate").val() });
listGrid.appendPostData({ ExerciseDateStart: $("#DateFromMaturityDate").val() });
listGrid.appendPostData({ ExerciseDateEnd: $("#DateToMaturityDate").val() });
listGrid.appendPostData({ TradePrice: $("#TradePrice").val() });
listGrid.appendPostData({ OptIds: ($("#OptIds").val() || []).join(",") });
listGrid.appendPostData({ OptDateStart: $("#DateFromOptDate").val() });
listGrid.appendPostData({ OptDateEnd: $("#DateToOptDate").val() });
listGrid.appendPostData({ TraderNames: ($("#TraderName").val() || []).join(",") });
listGrid.appendPostData({ GroupNames: ($("#GroupName").val() || []).join(",") });
listGrid.appendPostData({ ExerciseMode: $("#ExerciseMode").val() });
if (isSearchclick) {
//点击搜索时默认第一页
listGrid.jqGrid('setGridParam', { page: 1 });
}
listGrid.trigger('reloadGrid');
}
function finalSettlement() {
main.post("/clientbalance/finalSettlement").done(function (res) {
});
}
function ProcessOptDateFilter(cellValue, options, rowObject) {
if (rowObject.ProcessStatus === '未确认') {
return '';
}
return rowObject.ProcessOptDate;
}
$("#DateFromTradeDate").parent().addClass("trade-wrap");
$("#DateFromOptDate").parent().addClass("time-wrap");