You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

253 lines
10 KiB
JavaScript

11 months ago
var commonGridObj_ratelist;
function $(id){
return document.getElementById(id);
}
function createGrid(){
//header
var headerArgs_ratelist = new Array("<input type=\"checkbox\" id=\"ck_all\" onclick=\"checkAll('ck_all')\" />","货币代码","货币名称","对人民币汇率","汇率类型","起始时间","结束时间","所属分公司","创建人","创建时间");
//width
var widthArgs_ratelist = new Array("40","70","70","100","80","120","120","120","100","130");
//column align
var colAlignArgs_ratelist = new Array("center","center","center","center","center","center","center","center","center","center");
//column sort
var colSortArgs_ratelist = new Array("na","str","str","str","str","str","str","str","str","str");
//column type
var colTypeArgs_ratelist = new Array("ch","ro","ro","ro","ro","ro","ro","ro","ro","ro");
commonGridObj_ratelist = new TGridCommon("mygrid_container_ratelist","form1",headerArgs_ratelist,widthArgs_ratelist,colAlignArgs_ratelist,colSortArgs_ratelist,colTypeArgs_ratelist);
commonGridObj_ratelist.setResponseUrl("ExchangeRateListGridSource.aspx");
commonGridObj_ratelist.setRequest("ExchangeRateListGridSource.aspx?handle=ratelist&show_page=15&cur_page=1&uid="+commonGridObj_ratelist.newGuid());
commonGridObj_ratelist.setSourceType("json");
commonGridObj_ratelist.setSkin("xp");
commonGridObj_ratelist.setImageUrl("../images/");
commonGridObj_ratelist.initGrid();
commonGridObj_ratelist.bind();
commonGridObj_ratelist.initPageByHandle("ratelist");
commonGridObj_ratelist.isDBClickEvent = true;
commonGridObj_ratelist.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd){
var openSet = "height=200, width=1024, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " +(screen.height-200)/2 + ",Left= "+(screen.width-1024)/2
var openType = "_blank";
var openUrl = "ExchangeRateEdit.aspx?handle=edit&id="+rId;
//var tempWin = window.open ("about:blank",openType,openSet);
//tempWin.location = openUrl;
window.open(openUrl,openType,openSet);
});
commonGridObj_ratelist.dbclickEvent = function(){
commonGridObj_settlement.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd){
var openSet = "height=200, width=1024, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " +(screen.height-200)/2 + ",Left= "+(screen.width-1024)/2
var openType = "_blank";
var openUrl = "ExchangeRateEdit.aspx?handle=edit&id="+rId;
//var tempWin = window.open ("about:blank",openType,openSet);
//tempWin.location = openUrl;
window.open(openUrl,openType,openSet);
});
}
}
function refreshList(){
createGrid();
}
//根据条件查询付费申请信息
function search(){
var _begintime = $("txt_beginDate").value.trim();
if(_begintime.trim() != ""){
if(!validateDateTime(_begintime)){
alert("起始时间格式错误");
return;
}
}
var _endtime = $("txt_endDate").value.trim();
if(_endtime.trim() != ""){
if(!validateDateTime(_endtime)){
alert("结束时间格式错误");
return;
}
}
var _customer = $("h_customer").value.trim();
var _checkno = $("txt_billno").value.trim();
var searchJson = "";
//begin
searchJson +="{";
searchJson += "[";
//如果查询条件设置了起始时间和结束时间则判断结束时间是否大于起始时间
if(_begintime != "" && _endtime != ""){
if(_begintime.length > 9 && _endtime.length > 9){
var status = DateTimeEqual(_begintime,_endtime);
if(status == 0){
searchJson += "\"btime\":\""+_begintime+"\","
searchJson += "\"etime\":\""+_endtime+"\","
}else if(status == -1){
alert("时间设置错误,起始时间不能大于结束时间,请修改!");
return;
}
// else if(status == -2){
// alert("时间设置错误,起始时间不能等于结束时间,请修改!");
// return;
// }
}
else{
alert("时间格式有问题,长度应大于9个字符,请修改!");
return;
}
}else{
searchJson += "\"btime\":\""+_begintime+"\","
searchJson += "\"etime\":\""+_endtime+"\","
}
searchJson += "\"cus\":\""+_customer+"\",";
searchJson += "\"no\":\""+_checkno+"\"";
searchJson += "]";
searchJson +="}";//alert(searchJson);
commonGridObj_ratelist.initGrid();
commonGridObj_ratelist.setRequest("SettlementGridSourceApp.aspx?handle=getrecvamount&show_page=15&cur_page=1&search="+escape(searchJson)+"&uid="+commonGridObj_ratelist.newGuid());
commonGridObj_ratelist.bind();
commonGridObj_ratelist.setSearch(searchJson);
commonGridObj_ratelist.initPageByHandle("settlelist");
commonGridObj_ratelist.isDBClickEvent = true;
commonGridObj_ratelist.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd){
var openSet = "height=200, width=1024, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " +(screen.height-200)/2 + ",Left= "+(screen.width-1024)/2
var openType = "_blank";
var openUrl = "ExchangeRateEdit.aspx?handle=edit&id="+rId;
//var tempWin = window.open ("about:blank",openType,openSet);
//tempWin.location = openUrl;
window.open(openUrl,openType,openSet);
});
commonGridObj_ratelist.dbclickEvent = function(){
commonGridObj_settlement.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd){
var openSet = "height=200, width=1024, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " +(screen.height-200)/2 + ",Left= "+(screen.width-1024)/2
var openType = "_blank";
var openUrl = "ExchangeRateEdit.aspx?handle=edit&id="+rId;
//var tempWin = window.open ("about:blank",openType,openSet);
//tempWin.location = openUrl;
window.open(openUrl,openType,openSet);
});
}
}
//校验时间格式
function validateDateTime(dateTimeObj){
var isValid = false;
var parseToObj = new Date(dateTimeObj.replace(/-/g, "/"));
if(!isNaN(parseToObj)){
isValid = true;
}
return isValid;
}
function DateTimeEqual(beginObj,endObj){
var isEqual = 0;
var begin = new Date(beginObj.replace(/-/g, "/"));
var end = new Date(endObj.replace(/-/g, "/"));
if(Date.parse(begin) - Date.parse(end) > 0){
isEqual = -1;//起始时间大于结束时间
}else if(Date.parse(begin) - Date.parse(end) == 0){
isEqual = -2;//起始时间与结束时间相等
}
return isEqual;
}
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,""); }
//初始化界面
function initGrid(){
$("txt_beginDate").value = "";
$("txt_endDate").value = "";
createGrid();
}
function checkAll(id){
if($(id).checked){
for(var i=0;i<commonGridObj_ratelist.getGridObj().getRowsNum();i++){
commonGridObj_ratelist.getGridObj().cellByIndex(i,0).setValue(1);
}
}else{
for(var i=0;i<commonGridObj_ratelist.getGridObj().getRowsNum();i++){
commonGridObj_ratelist.getGridObj().cellByIndex(i,0).setValue(0);
}
}
}
function addExchangeRate(){
var openSet = "height=200, width=1024, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " +(screen.height-200)/2 + ",Left= "+(screen.width-1024)/2
var openType = "_blank";
var openUrl = "ExchangeRateEdit.aspx?handle=add";
//var tempWin = window.open ("about:blank",openType,openSet);
//tempWin.location = openUrl;
window.open(openUrl,openType,openSet);
}
function deleteExchangeRate(){
var delArg = new Array();
var iDelCount = 0;
for(var i=0;i<commonGridObj_ratelist.getGridObj().getRowsNum();i++){
var checkState = commonGridObj_ratelist.getGridObj().cellByIndex(i,0).getValue();
var rId = commonGridObj_ratelist.getGridObj().getRowId(i);
if(checkState == 1){
iDelCount++;
delArg.push(rId);
}
}
if(iDelCount > 0){
if(window.confirm("您确定要将选择汇率删除,汇率删除将影响系统费用汇率调用")){
for(var j=0;j<delArg.length;j++){
var url = "ExchangeRateListGridSource.aspx?handle=deleterate&exchangeid="+delArg[j]+"&uid="+commonGridObj_ratelist.newGuid();
var loader = dhtmlxAjax.getSync(url);
var stateInfo = loader.xmlDoc.responseText;
var state = parseInt(stateInfo);
}
createGrid();
}
}
}
function editExchangeRate(){
var selArg = new Array();
var iCount = 0;
for(var i=0;i<commonGridObj_ratelist.getGridObj().getRowsNum();i++){
var checkState = commonGridObj_ratelist.getGridObj().cellByIndex(i,0).getValue();
var rId = commonGridObj_ratelist.getGridObj().getRowId(i);
if(checkState == 1){
iCount++;
selArg.push(rId);
}
}
if(iCount == 1){
var openSet = "height=200, width=1024, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " +(screen.height-200)/2 + ",Left= "+(screen.width-1024)/2
var openType = "_blank";
var openUrl = "ExchangeRateEdit.aspx?handle=edit&id="+selArg[0];
//var tempWin = window.open ("about:blank",openType,openSet);
//tempWin.location = openUrl;
window.open(openUrl,openType,openSet);
}else{
if(iCount > 1){
alert("每次只能编辑一个汇率信息");
}else{
alert("未选择要编辑的汇率信息");
}
}
}