var g_grid = {}; var query_data = {}; $(function () { var PostData = {}; grid = jQuery('#listGrid').jqGrid({ cmTemplate: { width: 80, align: 'center', sortable: false }, url: '/swapTrade2/GetCapitalAcountList', datatype: 'json', multiselect: false, height: 'auto', width: '96%', autowidth: false, shrinkToFit: false, viewrecords: true, jsonReader: { repeatitems: false }, caption: '', mtype: 'POST', postData: PostData, colModel: colModelGrid, pager: jQuery('#pagerGrid'), pagerpos: 'left', rowNum: 20, rowList: [20, 30, 50, 200, 10000], footerrow: false, loadComplete: gridComplete, onPaging: onJqgridPaging, }); }); var getColModelGrid = function () { var col = [ { name: 'id', hidden: true, optionHide: true }, { name: 'ClientId', hidden: true, optionHide: true }, { name: 'ClientName', label: '对手方', width: 260, align: 'center', }, { name: 'SwapTradeNo', width: 260, label: '互换交易编码', align: 'center' }, { name: 'FundAccount', label: '场内资金账号', width: 260, align: 'center' }, { name: 'Status', label: '状态', align: 'center', formatter: function (cellValue, options, rowObject) { if (cellValue == 0) { return "正常"; } return "禁用"; } }, { name: '', label: '操作', align: 'center', width: 140, formatter: showToolName } ]; return col; } var colModelGrid = getColModelGrid(); function showToolName(cellValue, options, rowObject) { var html; html = "" .template(rowObject.EncryptId); html = html + "" .template(rowObject.EncryptId); return html; } function gridComplete() { $(".selftooltip").tooltip({ html: true, show: 50000, trigger: "hover" }); var newHeight = $(window).height() - 250; $(".ui-jqgrid .ui-jqgrid-bdiv").css("cssText", "height: " + newHeight + "px!important;"); $('#listGrid').jqGrid('setGridWidth', $("#searchdiv").width() + 30); $('.ui-jqgrid-bdiv', '#gbox_listGrid').floatingScroll(); } function getList(isSearchclick) { var listGrid = $('#listGrid'); listGrid.appendPostData({ ClientId: $("#ClientId").val() }); listGrid.appendPostData({ TradeNumber: $("#TradeNumber").val() }); listGrid.appendPostData({ FundAccount: $("#FundAccount").val() }); if (typeof isSearchclick !== "undefined" && isSearchclick) { //点击搜索时默认第一页 listGrid.jqGrid('setGridParam', { page: 1 }); } listGrid.trigger('reloadGrid'); } var SwapTradeId = 0; var vue = new Vue({ el: "#acountVue", data: { account: { id: 0, ClientId: 0, ClientName: "", SwapTradeId: 0, SwapTradeNo: "", FundAccount: "", Status: 0 }, clientList: [], tradeNumberList: [], tableList: [] }, mounted: function () { this.clientList = clients; }, methods: { addNew() { this.account = { id: 0, ClientId: 0, ClientName: "", SwapTradeId: 0, SwapTradeNo: "", FundAccount: "", Status: 0 }; SwapTradeId = 0; resetSelect(); $("#accountModal").modal('show'); }, editAccount(id) { var thisObj = this; main.post("/swaptrade2/GetCapitalAccount?enid=" + id).done(function (resp) { var item = resp; thisObj.account.id = item.id; thisObj.account.ClientId = item.ClientId; thisObj.account.ClientName = item.ClientName; thisObj.account.SwapTradeId = item.SwapTradeId; SwapTradeId = thisObj.account.SwapTradeId; thisObj.account.SwapTradeNo = item.SwapTradeNo; thisObj.account.FundAccount = item.FundAccount; thisObj.account.Status = item.Status; thisObj.getClientTradeNumbers(); $("#accountModal").modal('show'); }); }, deleteAccount(id) { var thisObj = this; main.confirm("确定要删除吗?", function () { main.post("/swaptrade2/DeleteCapitalAccount?enid=" + id).done(function (resp) { getList(); }) }); }, saveAccount() { var thisObj = this; if (thisObj.account.ClientId == 0) { return main.alert("请选择对手方"); } if (thisObj.account.SwapTradeNo.length == 0) { return main.alert("请选择互换交易编码"); } if (thisObj.account.FundAccount.length == 0) { return main.alert("请填写场内资金账号"); } if (thisObj.account.FundAccount.length>20) { return main.alert("场内资金账号长度不能超过20位"); } if (thisObj.account.id > 0) { main.confirm("将根据最新的资金账号映射关系来匹配成交流水,是否继续修改?", function () { thisObj.postAccount(); }); } else { thisObj.postAccount(); } }, postAccount() { var thisObj = this; main.post("/swaptrade2/SaveCapitalAccount", { req: thisObj.account }).done(function (resp) { if (resp.success) { getList(); $("#accountModal").modal('hide'); } else { main.alert(resp.msg); } }) }, getClientTradeNumbers() { var thisObj = this; var clientId = thisObj.account.ClientId; var client = thisObj.clientList.filter(item => { if (item.Value == clientId) return item; }); thisObj.account.ClientName = client[0].Text; main.post("/swaptrade2/GetClientTradeNumbers?clientId=" + clientId).done(function (resp) { thisObj.tradeNumberList = resp.obj; setTimeout(resetSelect, 300) }) }, changeTradeNumber() { var thisObj = this; var swapTradeId = thisObj.account.SwapTradeId; var swapTrade = thisObj.tradeNumberList.filter(item => { if (item.Value == swapTradeId) return item }); thisObj.account.SwapTradeNo = swapTrade[0].Text; } } }); function resetSelect() { $('#swapTradeId').selectpicker('val', SwapTradeId); $('#swapTradeId').selectpicker('refresh'); } window.reloadData = getList();