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.

432 lines
15 KiB
JavaScript

var commonGridObj_Chequelist;
var comboCustomer;//委托单位
function $(id){
return document.getElementById(id);
}
function initWinScreen()
{
var winScreenHeight = 0;
var winScreenWidth = 0;
if(window.screen.height)
{
winScreenHeight = window.screen.height;
}
if(window.screen.width)
{
winScreenWidth = window.screen.width;
}
if(winScreenWidth >= 1440 && winScreenWidth >= 900)
{
document.getElementById("mygrid_container_Chequelist").style.height = "510px";
}
else if(winScreenWidth >= 1366 && winScreenWidth >= 768)
{
document.getElementById("mygrid_container_Chequelist").style.height = "340px";
}
else if(winScreenWidth >= 1024 && winScreenWidth >= 768)
{
document.getElementById("mygrid_container_Chequelist").style.height = "300px";
}
}
function createGrid()
{
//header
var headerArgs_Chequelist = new Array("<input type=\"checkbox\" id=\"ck_all\" onclick=\"checkAll(commonGridObj_Chequelist)\" />","支票类别","是否打印","是否废除","支票号码","客户名称","支票抬头","金额","币别","出票人","出票日期","开出人","开出时间");
//width
var widthArgs_Chequelist = new Array("40","60","60","60","120","120","120","70","50","70","130","70","130");
//column align
var colAlignArgs_Chequelist = new Array("center","center","center","center","center","center","center","center","center","center","center","center","center");
//column sort
var colSortArgs_Chequelist = new Array("na","str","str","str","str","str","str","str","str","str","str","str","str");
//column type
var colTypeArgs_Chequelist = new Array("ch","ro","ch","ch","ro","ro","ro","ro","ro","ro","ro","ro","ro");
commonGridObj_Chequelist = new TGridCommon("mygrid_container_Chequelist","form1",headerArgs_Chequelist,widthArgs_Chequelist,colAlignArgs_Chequelist,colSortArgs_Chequelist,colTypeArgs_Chequelist);
commonGridObj_Chequelist.setResponseUrl("ChCheckListGridSource.aspx");
commonGridObj_Chequelist.setRequest("ChCheckListGridSource.aspx?handle=ChChecklist&show_page=15&cur_page=1&uid="+commonGridObj_Chequelist.newGuid());
commonGridObj_Chequelist.setSourceType("json");
commonGridObj_Chequelist.setSkin("xp");
commonGridObj_Chequelist.setImageUrl("../images/");
commonGridObj_Chequelist.initGrid();
commonGridObj_Chequelist.bind();
commonGridObj_Chequelist.initPageByHandle("ChChecklist");
commonGridObj_Chequelist.getGridObj().attachEvent("onEditCell",function(stage,rId,cInd,nValue,oValue)
{
if(stage == 0)
{
if(cInd == 2 || cInd == 3)
{
return false;
}
else
{
return true;
}
}
});
commonGridObj_Chequelist.getGridObj().attachEvent("onRowDblClicked", function(id,ind)
{
var openSet = "height=510, width=790, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-490)/2 + ",Left= "+(screen.width-900)/2
var openType = "_blank";
var openUrl = "ChCheckInfo.aspx?handle=edit&id="+id;
window.open (openUrl,openType,openSet);
});
commonGridObj_Chequelist.clickEvent = function()
{
commonGridObj_Chequelist.getGridObj().attachEvent("onRowDblClicked", function(id,ind)
{
var openSet = "height=510, width=790, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-490)/2 + ",Left= "+(screen.width-900)/2
var openType = "_blank";
var openUrl = "ChCheckInfo.aspx?handle=edit&id="+id;
window.open (openUrl,openType,openSet);
});
}
}
function initCombo()
{
createComboCustomer();//结算单位
}
//废除支票
function voidCheque(){
var iCount = 0;
var iSuccess = 0;
var iError = 0;
var iReDo = 0;
var iNoPower = 0;
var strNotes = "";
if(commonGridObj_Chequelist != null){
for(var i = 0;i<commonGridObj_Chequelist.getGridObj().getRowsNum();i++){
var rowId = commonGridObj_Chequelist.getGridObj().getRowId(i);
var chBox = commonGridObj_Chequelist.getGridObj().cellByIndex(i,0).getValue();
//如果选中,则将保存的开支票申请提交,提交前先判断当前支票申请是否已经提交申请
if(chBox == 1){
iCount++;
//异步执行操作
var url = "ChCheckListGridSource.aspx?Chequeid="+rowId+"&handle=voidCheque&uid="+commonGridObj_Chequelist.newGuid();
var loader = dhtmlxAjax.getSync(url);
var postStatus = loader.xmlDoc.responseText;
var status = parseInt(postStatus);
switch(status){
case 1:
createGrid();
strNotes = "支票废除成功";
iSuccess++;
break;
case -1:
strNotes = "支票废除异常";
iError++;
break;
case -2:
strNotes = "支票已经废除,不能重复操作";
iReDo++;
break;
case -3:
strNotes = "没有权限作废支票";
iNoPower++;
break;
}
}
}
if(iCount == 0){
alert("您没有选择要废除的支票");
}else if(iCount == 1){
alert(strNotes);
}else if(iCount > 1){
alert("共操作"+iCount+"条 成功"+iSuccess+"条 异常"+iError+"条 禁止重复操作"+iReDo+"条 无权限"+iNoPower+"条");
}
}
}
//直接开出支票
function addApplication()
{
//异步执行操作
// var url = "ChCheckListGridSource.aspx?handle=add&paysettlebillno="+commonGridObj_Chequelist.newGuid();
// var loader = dhtmlxAjax.getSync(url);
// var postStatus = loader.xmlDoc.responseText;
//
// var status = parseInt(postStatus);
//
// if(status > 0)
// {
var openSet = "height=510, width=790, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-490)/2 + ",Left= "+(screen.width-800)/2
var openType = "_blank";
var openUrl = "ChCheckInfo.aspx?handle=add";
window.open (openUrl,openType,openSet);
// }
// else
// {
// alert("没有权限开支票");
// return;
// }
}
//打印支票
function printCheque(){
var iCount = 0;
var iSuccess = 0;
var iError = 0;
var iIsPrint = 0;
var iNoPower = 0;
var strNotes = "";
if(commonGridObj_Chequelist != null){
for(var i = 0;i<commonGridObj_Chequelist.getGridObj().getRowsNum();i++){
var rowId = commonGridObj_Chequelist.getGridObj().getRowId(i);
var chBox = commonGridObj_Chequelist.getGridObj().cellByIndex(i,0).getValue();
//如果选中,则将保存的开支票申请提交,提交前先判断当前支票申请是否已经提交申请
if(chBox == 1){
iCount++;
//异步执行操作
var url = "ChCheckListGridSource.aspx?Chequeid="+rowId+"&handle=print&uid="+commonGridObj_Chequelist.newGuid();
var loader = dhtmlxAjax.getSync(url);
var postStatus = loader.xmlDoc.responseText;
var status = parseInt(postStatus);
switch(status){
case 1:
createGrid();
strNotes = "支票打印成功";
iSuccess++;
break;
case -1:
strNotes = "处理异常";
iError++;
break;
case -2:
strNotes = "支票已经废除不能打印";
iIsPrint++;
break;
case -3:
strNotes = "没有权限打印支票";
iNoPower++;
break;
}
}
}
if(iCount == 0){
alert("您没有选择要打印的支票");
}else if(iCount == 1){
alert(strNotes);
}else if(iCount > 1){
alert("共操作"+iCount+"条 成功"+iSuccess+"条 异常"+iError+"条 已打印不能重复"+iIsPrint+"条 无权限"+iNoPower+"条");
}
}
}
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_Chequelist.initGrid();
commonGridObj_Chequelist.setRequest("ChCheckListGridSource.aspx?handle=ChChecklist&show_page=15&cur_page=1&search="+escape(searchJson));//+"&uid="+commonGridObj_Chequelist.newGuid());
commonGridObj_Chequelist.bind();
commonGridObj_Chequelist.setSearch(searchJson);
commonGridObj_Chequelist.initPageByHandle("ChChecklist");
commonGridObj_Chequelist.getGridObj().attachEvent("onEditCell",function(stage,rId,cInd,nValue,oValue)
{
if(stage == 0)
{
if(cInd == 2 || cInd == 3)
{
return false;
}
else
{
return true;
}
}
});
commonGridObj_Chequelist.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd)
{
var rId = commonGridObj_Chequelist.getGridObj().getSelectedRowId();
var openSet = "height=500, width=960, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-710)/2 + ",Left= "+(screen.width-960)/2
var openType = "_blank";
var openUrl = "ChCheckInfo.aspx?id="+rId+"&handle=edit";
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 createComboCustomer(){//委托单位
comboCustomer = dhtmlXComboFromSelect("sel_customer");
comboCustomer.loadXML("../FeeCodes/WebCrmClientAdapter.aspx?mask=0&pos=0");
comboCustomer.attachEvent("onChange", function(){
comboCustomer.setComboText($("h_customer").value);
});
comboCustomer.attachEvent("onBlur", function(){
var s1 = comboCustomer.getComboText().trim();
var s2 = s1.indexOf("|");
if(s2>0){
s2=s2+2;
}
var s3 = s1.substring(s2);
if(s2>0){
comboCustomer.setComboText(s3);
$("h_customer").value=s3;
}
else
{
comboCustomer.setComboText($("h_customer").value);
}
});
comboCustomer.setComboText($("h_customer").value);
comboCustomer.attachEvent("onKeyPressed", function(keyCode){
if(keyCode!="8"){
var arrayArg = new Array();
setTimeout(function(){
var filterCount = 0;
var is = -1;
var ishd = $("h_customer").value.trim();
if("" != comboCustomer.getComboText().trim()){
while("undefined" != typeof comboCustomer.getOptionByIndex(filterCount)){
var comboValue = comboCustomer.getOptionByIndex(filterCount).text.toUpperCase();//.value;
var enterValue = comboCustomer.getComboText().trim().toUpperCase();
$("h_customer").value = comboCustomer.getComboText().trim().toUpperCase();
if(comboValue.indexOf(enterValue) == 0){
comboCustomer.selectOption(filterCount,true,true);
is=filterCount;
break;
}
++filterCount;
}
if(is==-1){
$("h_customer").value = ishd;
alert("无此内容,请重新选择!");
}
}
},10);
}
});
comboCustomer.attachEvent("onSelectionChange", function(){
$("h_customer").value = comboCustomer.getComboText().trim();
});
}
//初始化界面
function initGrid(){
$("h_customer").value = "";
comboCustomer.setComboText($("h_customer").value);
$("txt_beginDate").value = "";
$("txt_endDate").value = "";
$("txt_billno").value = "";
createGrid();
}