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.
DS7/DSWeb/js/ReceiveAmountVerifyList.js

461 lines
17 KiB
JavaScript

3 years ago
var commonGridObj_verify;
var comboCustomer;//委托单位
function $(id){
return document.getElementById(id);
}
function createGrid(){
//header
var headerArgs_verify = new Array("<input type=\"checkbox\" id=\"ck_all\" onclick=\"checkAll('ck_all')\" />","实收名称","实收金额","付款单位","收款人","收款时间","币别","结算金额","未结算金额","结算时间","结算人","备注");
//width
var widthArgs_verify = new Array("40","0","100","100","130","130","60","100","100","100","150","150");
//column align
var colAlignArgs_verify = new Array("center","center","center","center","center","center","center","center","center","center","center","center");
//column sort
var colSortArgs_verify = new Array("na","str","str","str","str","str","str","str","str","str","str","str");
//column type
var colTypeArgs_verify = new Array("ch","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro");
commonGridObj_verify = new TGridCommon("mygrid_container_recvamountverify","form1",headerArgs_verify,widthArgs_verify,colAlignArgs_verify,colSortArgs_verify,colTypeArgs_verify);
commonGridObj_verify.setResponseUrl("SettlementGridSourceApp.aspx");
commonGridObj_verify.setRequest("SettlementGridSourceApp.aspx?handle=getunverfiyrecvamount&show_page=15&cur_page=1&uid="+commonGridObj_verify.newGuid());
commonGridObj_verify.setSourceType("json");
commonGridObj_verify.setSkin("xp");
commonGridObj_verify.setImageUrl("../images/");
commonGridObj_verify.initGrid();
commonGridObj_verify.bind();
commonGridObj_verify.initPageByHandle("getrecvamount");
commonGridObj_verify.isDBClickEvent = true;
commonGridObj_verify.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd){
var openSet = "height=550, width=1000, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-520)/2 + ",Left= "+(screen.width-1000)/2
var openType = "_blank";
var openUrl = "ReceiveAmountEdit.aspx?handle=edit&id="+rId+"&op=verify";
window.open (openUrl,openType,openSet);
});
commonGridObj_verify.dbclickEvent = function(){
commonGridObj_verify.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd){
var openSet = "height=550, width=1000, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-520)/2 + ",Left= "+(screen.width-1000)/2
var openType = "_blank";
var openUrl = "ReceiveAmountEdit.aspx?handle=edit&id="+rId+"&op=verify";
window.open (openUrl,openType,openSet);
});
}
}
function initCombo(){
createComboCustomer();//结算单位
}
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_verify.initGrid();
commonGridObj_verify.setRequest("SettlementGridSourceApp.aspx?handle=getrecvamount&show_page=15&cur_page=1&search="+escape(searchJson)+"&uid="+commonGridObj_recvamount.newGuid());
commonGridObj_verify.bind();
commonGridObj_verify.setSearch(searchJson);
commonGridObj_verify.initPageByHandle("settlelist");
commonGridObj_verify.isDBClickEvent = true;
commonGridObj_verify.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd){
var openSet = "height=v, width=1000, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-520)/2 + ",Left= "+(screen.width-1000)/2
var openType = "_blank";
var openUrl = "ReceiveAmountEdit.aspx?handle=edit&id="+rId+"&op=verify";
window.open (openUrl,openType,openSet);
});
commonGridObj_verify.dbclickEvent = function(){
commonGridObj_verify.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd){
var openSet = "height=550, width=1000, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-520)/2 + ",Left= "+(screen.width-1000)/2
var openType = "_blank";
var openUrl = "ReceiveAmountEdit.aspx?handle=edit&id="+rId+"&op=verify";
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();
}
function InvoiceVerification(){
var selCount = 0;
var isDiff = false;
var isDiffCurr = false;
var customerAry = new Array();
var recvAmountAry = new Array();
var currencyAry = new Array();
var rmbAmount = 0;
var usdAmount = 0;
for(var i=0;i<commonGridObj_verify.getGridObj().getRowsNum();i++){
var rId = commonGridObj_verify.getGridObj().getRowId(i);
var checkState = commonGridObj_verify.getGridObj().cellByIndex(i,0).getValue();
var customerName = commonGridObj_verify.getGridObj().cellByIndex(i,3).getValue();
var currencyVal = commonGridObj_verify.getGridObj().cellByIndex(i,6).getValue();
if(checkState == 1){
selCount++;
if(customerAry.length > 0){
for(var j=0;j<customerAry.length;j++){
if(customerAry[j] != customerName){
isDiff = true;
break;
}
}
}else{
customerAry.push(customerName);
}
if(currencyAry.length > 0){
for(var j=0;j<currencyAry.length;j++){
if(currencyAry[j] != currencyVal){
isDiffCurr = true;
break;
}
}
}else{
currencyAry.push(currencyVal);
}
if(!isDiff && !isDiffCurr){
recvAmountAry.push(rId);
}
if(isDiff){
break;
}
if(isDiffCurr){
break;
}
}
}
if(selCount > 0){
if(isDiff){
alert("付款单位错误,只能对付款单位名称相同的进行实收核销");
}else if(isDiffCurr){
alert("操作错误,只能对相同币别的实收金额进行实收核销");
}else{
var cacheName = "";
if($("h_cachename").value.trim() == ""){
cacheName = commonGridObj_verify.newGuid();
$("h_cachename").value = cacheName;
}else{
cacheName = $("h_cachename").value;
}
for(var k=0;k<recvAmountAry.length;k++){
var url = "SettlementGridSourceApp.aspx?handle=cacheverify&verifycachename="+cacheName+"&recvamountid="+recvAmountAry[k]+"&uid="+commonGridObj_verify.newGuid();
var loader = dhtmlxAjax.getSync(url);
var stateVal = loader.xmlDoc.responseText;
}
var openSet = "height=560, width=1000, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-490)/2 + ",Left= "+(screen.width-1000)/2
var openType = "_blank";
var openUrl = "../Invoice/RecvSettleInvoiceVerification.aspx?handle=verify&cus="+escape(customerAry[0])+"&verifycache="+cacheName;
window.open (openUrl,openType,openSet);
}
}else{
alert("没有选择要核销的实收费用信息");
}
}
function checkAll(id){
if($(id).checked){
for(var i=0;i<commonGridObj_verify.getGridObj().getRowsNum();i++){
commonGridObj_verify.getGridObj().cellByIndex(i,0).setValue(1);
}
}else{
for(var i=0;i<commonGridObj_verify.getGridObj().getRowsNum();i++){
commonGridObj_verify.getGridObj().cellByIndex(i,0).setValue(0);
}
}
}
function cancelSettle(){
var success = 0;
var failure = 0;
var redo = 0;
var noinfo = 0;
var iCount = 0;
var recvArg = new Array();
for(var i=0;i<commonGridObj_verify.getGridObj().getRowsNum();i++){
var checkState = commonGridObj_verify.getGridObj().cellByIndex(i,0).getValue();
var billNO = commonGridObj_verify.getGridObj().cellByIndex(i,1).getValue().trim();
if(checkState == 1){
recvArg.push(billNO);
iCount++;
}
}
if(iCount > 0){
var delCount = 0;
if(recvArg.length > 0){
if(window.confirm("您确定要将所选应收费用删除")){
while(delCount < recvArg.length){
var url = "SettlementGridSourceApp.aspx?handle=cancelrecvsettle&billno="+recvArg[delCount]+"&uid="+commonGridObj_verify.newGuid();
var loader = dhtmlxAjax.getSync(url);
var stateInfo = loader.xmlDoc.responseText;
var state = parseInt(stateInfo);
if(state == 1){
success++;
}else if(state == -3){
failure++;
}else if(state == -4){
failure++;
}else{
failure++;
}
delCount++;
}
}
}
createGrid();
alert("执行撤销收费结算操作 共 "+delCount+" 条 成功 "+success+" 条 失败 "+failure+" 条");
}else{
alert("未选中要操作的费用项");
}
}
function settlementAction(){
var selCount = 0;
var isDiff = false;
var isDiffCurr = false;
var customerAry = new Array();
var recvAmountAry = new Array();
var currencyAry = new Array();
var rmbAmount = 0;
var usdAmount = 0;
for(var i=0;i<commonGridObj_verify.getGridObj().getRowsNum();i++){
var rId = commonGridObj_verify.getGridObj().getRowId(i);
var checkState = commonGridObj_verify.getGridObj().cellByIndex(i,0).getValue();
var customerName = commonGridObj_verify.getGridObj().cellByIndex(i,3).getValue();
var currencyVal = commonGridObj_verify.getGridObj().cellByIndex(i,6).getValue();
if(checkState == 1){
selCount++;
if(customerAry.length > 0){
for(var j=0;j<customerAry.length;j++){
if(customerAry[j] != customerName){
isDiff = true;
break;
}
}
}else{
customerAry.push(customerName);
}
if(currencyAry.length > 0){
for(var j=0;j<currencyAry.length;j++){
if(currencyAry[j] != currencyVal){
isDiffCurr = true;
break;
}
}
}else{
currencyAry.push(currencyVal);
}
if(!isDiff && !isDiffCurr){
recvAmountAry.push(rId);
}
if(isDiff){
break;
}
if(isDiffCurr){
break;
}
}
}
if(selCount > 0){
if(isDiff){
alert("付款单位错误,只能对付款单位名称相同的进行实收核销");
}else if(isDiffCurr){
alert("操作错误,只能对相同币别的实收金额进行实收核销");
}else{
var cacheName = "";
if($("h_cachename").value.trim() == ""){
cacheName = commonGridObj_verify.newGuid();
$("h_cachename").value = cacheName;
}else{
cacheName = $("h_cachename").value;
}
for(var k=0;k<recvAmountAry.length;k++){
var url = "SettlementGridSourceApp.aspx?handle=cacheverify&verifycachename="+cacheName+"&recvamountid="+recvAmountAry[k]+"&uid="+commonGridObj_verify.newGuid();
var loader = dhtmlxAjax.getSync(url);
var stateVal = loader.xmlDoc.responseText;
}
$("h_cachename").value = "";
var openSet = "height=580, width=970, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " +(screen.height-580)/2 + ",Left= "+(screen.width-970)/2
var openType = "_blank";
var openUrl = "commonsettlement.aspx?handle=verify&cus="+escape(customerAry[0])+"&verifycache="+cacheName+"&cur="+currencyAry[0];
window.open (openUrl,openType,openSet);
}
}else{
alert("没有选择要核销的实收费用信息");
}
}