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.

532 lines
20 KiB
JavaScript

var commonGridObj_settlement;
var comboCustomer;//委托单位
function $(id){
return document.getElementById(id);
}
function createGrid(){
//header
var headerArgs_settlement = new Array("<input type=\"checkbox\" id=\"ck_all\" onclick=\"checkAll('ck_all')\" />", "结算单号", "结算单状态", "结算类别", "结算单位", "结算方式", "发票号码", "USD", "RMB", "实付支RMB", "结算人", "结算日期","申请单号", "备注");
//width
var widthArgs_settlement = new Array("40", "120", "70", "70", "100", "70", "80", "80", "80", "80", "150", "150", "150", "200");
//column align
var colAlignArgs_settlement = new Array("center", "center", "center", "center", "center", "center", "center", "center", "center", "center", "center", "center", "center", "center");
//column sort
var colSortArgs_settlement = new Array("na", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str");
//column type
var colTypeArgs_settlement = new Array("ch", "ro", "ro", "ro", "ro", "ro", "ro", "ro", "ro", "ro", "ro", "ro", "ro", "ro");
commonGridObj_settlement = new TGridCommon("mygrid_container_settlement","form1",headerArgs_settlement,widthArgs_settlement,colAlignArgs_settlement,colSortArgs_settlement,colTypeArgs_settlement);
commonGridObj_settlement.setResponseUrl("SettlementGridSourceApp.aspx");
commonGridObj_settlement.setRequest("SettlementGridSourceApp.aspx?handle=settlelist&show_page=15&cur_page=1&uid="+commonGridObj_settlement.newGuid());
commonGridObj_settlement.setSourceType("json");
commonGridObj_settlement.setSkin("xp");
commonGridObj_settlement.setImageUrl("../images/");
commonGridObj_settlement.initGrid();
commonGridObj_settlement.bind();
commonGridObj_settlement.initPageByHandle("settlelist");
// commonGridObj_settlement.getGridObj().attachEvent("onRowSelect", function(id,ind){
// var openSet = "height=520, 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 = "SettlementEdit.aspx?handle=edit&id="+id;
// window.open (openUrl,openType,openSet);
//
// });
//
// commonGridObj_settlement.clickEvent = function(){
// commonGridObj_settlement.getGridObj().attachEvent("onRowSelect", function(id,ind){
// var openSet = "height=520, 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 = "SettlementEdit.aspx?handle=edit&id="+id;
// window.open (openUrl,openType,openSet);
//
// });
// }
commonGridObj_settlement.isDBClickEvent = true;
commonGridObj_settlement.getGridObj().attachEvent("onRowDblClicked", function (rId, cInd) {
var openSet = "height=750, width=1100, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top=10px,Left=100px";
var openType = "_blank";
var openUrl = "SettlementEdit.aspx?handle=edit&id=" + rId;
window.open(openUrl, openType, openSet);
});
commonGridObj_settlement.dbclickEvent = function(){
commonGridObj_settlement.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd){
var openSet = "height=750, width=1100, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top=10px,Left=100px";
var openType = "_blank";
var openUrl = "SettlementEdit.aspx?handle=edit&id="+rId;
window.open (openUrl,openType,openSet);
});
}
}
function settlementAction(){
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";
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 _mblno = $("txt_mblno").value.trim();
var _other = $("txt_other").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 += "\"mblno\":\"" + _mblno + "\",";
searchJson += "\"other\":\"" + _other + "\",";
searchJson += "\"amount1\":\"" + $("txt_amount1").value.trim() + "\",";
searchJson += "\"amount2\":\"" + $("txt_amount2").value.trim() + "\"";
searchJson += "]";
searchJson +="}";//alert(searchJson);
commonGridObj_settlement.initGrid();
commonGridObj_settlement.setRequest("SettlementGridSourceApp.aspx?handle=settlelist&show_page=15&cur_page=1&search="+escape(searchJson)+"&uid="+commonGridObj_settlement.newGuid());
commonGridObj_settlement.bind();
commonGridObj_settlement.setSearch(searchJson);
commonGridObj_settlement.initPageByHandle("settlelist");
// commonGridObj_settlement.getGridObj().attachEvent("onRowSelect", function(id,ind){
// var openSet = "height=520, 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 = "SettlementEdit.aspx?handle=edit&id="+id;
// window.open (openUrl,openType,openSet);
//
// });
//
// commonGridObj_settlement.clickEvent = function(){
// commonGridObj_settlement.getGridObj().attachEvent("onRowSelect", function(id,ind){
// var openSet = "height=520, 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 = "SettlementEdit.aspx?handle=edit&id="+id;
// window.open (openUrl,openType,openSet);
//
// });
// }
commonGridObj_settlement.isDBClickEvent = true;
commonGridObj_settlement.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd){
var openSet = "height=750, width=1100, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top=10px,Left=100px";
var openType = "_blank";
var openUrl = "SettlementEdit.aspx?handle=edit&id="+rId;
window.open (openUrl,openType,openSet);
});
commonGridObj_settlement.dbclickEvent = function(){
commonGridObj_settlement.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd){
var openSet = "height=750, width=1100, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top=10px,Left=100px";
var openType = "_blank";
var openUrl = "SettlementEdit.aspx?handle=edit&id="+rId;
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 = "";
$("txt_amount1").value = "";
$("txt_amount2").value = "";
$("txt_mblno").value = "";
$("txt_other").value = "";
createGrid();
}
function InvoiceVerification(){
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";
window.open (openUrl,openType,openSet);
}
function checkAll(id){
if($(id).checked){
for(var i=0;i<commonGridObj_settlement.getGridObj().getRowsNum();i++){
commonGridObj_settlement.getGridObj().cellByIndex(i,0).setValue(1);
}
}else{
for(var i=0;i<commonGridObj_settlement.getGridObj().getRowsNum();i++){
commonGridObj_settlement.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_settlement.getGridObj().getRowsNum();i++){
var checkState = commonGridObj_settlement.getGridObj().cellByIndex(i,0).getValue();
var billNO = commonGridObj_settlement.getGridObj().cellByIndex(i,1).getValue().trim();
if(checkState == 1){
recvArg.push(billNO);
iCount++;
}
}
if(iCount > 0){
var delCount = 0;
var feeError = 0;
var isVounoError = 0;
if(recvArg.length > 0){
if (window.confirm("您确定要撤销所选应收费用")) {
while(delCount < recvArg.length){
var url = "SettlementGridSourceApp.aspx?handle=cancelrecvsettle&billno="+recvArg[delCount]+"&uid="+commonGridObj_settlement.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 if (state == -5) {
feeError++;
} else if (state == -6) {
isVounoError++;
} else {
failure++;
}
delCount++;
}
}
}
var strError = "";
if (feeError != 0) {
strError += "\n另" + feeError + "条“预收支资料”已使用,不允许操作!请先删除已使用的“预收支取用资料”!";
}
if (isVounoError != 0) {
strError += "\n另" + isVounoError + "条已生成结算凭证,不允许操作!请先删除已生成的“结算凭证”!";
}
alert("执行撤销收费结算操作 共 " + delCount + " 条 成功 " + success + " 条 失败 " + failure + " 条。" + strError);
//
createGrid();
}else{
alert("未选中要操作的费用项");
}
}
function recvfeeapplsettle() {//收费申请结算
//异步执行操作
var url = "RecvSettlementGridSource.aspx?handle=validaterecvsettlement&uid=" + commonGridObj_settlement.newGuid();
var loader = dhtmlxAjax.getSync(url);
var postStatus = loader.xmlDoc.responseText;
var status = parseInt(postStatus);
if (status > 0) {
var openSet = "height=680, width=1050, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " + (screen.height - 650) / 2 + ",Left= " + (screen.width - 1200) / 2
var openType = "_blank";
var openUrl = "RecvApplicationSettlement.aspx";
window.open(openUrl, openType, openSet);
} else {
alert("没有权限操作付费申请结算");
}
}
//是否为数字,且数值格式是否正确
function IsNumFormat(val) {
var re = /^[-\+]?\d+(\.\d+)?$/;
if (!re.test(val)) {
return false;
}
else {
if (val.toString().indexOf(".") > 0) {
val.toString().replace("-", "");
val.toString().replace("+", "");
if (val.toString().substr(0, 1) == "0" && val.toString().substr(0, 2) != "0.") {
return false;
}
}
else {
var re1 = /^[-\+]+[1-9]+[0-9]*]*$/;
if (!re1.test(val)) {
re1 = /^[1-9]+[0-9]*]*$/;
if (!re1.test(val)) {
return false;
}
}
}
return true;
}
}
//
function getIsNum(x) {
var str = x.value.trim();
if (str == "0") {
return;
}
else if (str == "") {
return;
// str = 0;
// x.value = 0;
}
else {
var bl = IsNumFormat(str);
if (!bl) {
alert("数值格式错误!");
x.focus();
x.select();
}
}
}
function printSettlement() {
var strBillNO = commonGridObj_settlement.getGridObj().getCheckedRows(0); //所有选中的grid的id编号
//
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 _mblno = $("txt_mblno").value.trim();
var _other = $("txt_other").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 += "\"mblno\":\"" + _mblno + "\",";
searchJson += "\"other\":\"" + _other + "\",";
searchJson += "\"amount1\":\"" + $("txt_amount1").value.trim() + "\",";
searchJson += "\"amount2\":\"" + $("txt_amount2").value.trim() + "\"";
searchJson += "]";
searchJson += "}"; //alert(searchJson);
//
var printUrl = "";
var companyID = "";
var typeName = "RECVSETTLELIST";
var dbSourceID = "";
var userID = "";
var url = "";
url= "../Reports/ReportService.aspx?handle=printrecvsettlelist&billno=" + strBillNO + "&search=" + escape(searchJson) + "&uid=" + commonGridObj_settlement.newGuid();
var loader = dhtmlxAjax.getSync(url);
var reportVal = loader.xmlDoc.responseText;
var reportObj = null;
if (reportVal != "") {
reportObj = eval('(' + reportVal + ')');
if (reportObj.reports.length > 0) {
if (reportObj.reports[0].compid != "") {
companyID = reportObj.reports[0].compid;
}
if (reportObj.reports[0].sourceid != "") {
dbSourceID = reportObj.reports[0].sourceid;
}
if (reportObj.reports[0].compid != "") {
userID = reportObj.reports[0].userid;
}
printUrl = "print://?comp=" + companyID + "&type=" + typeName + "&dbid=" + dbSourceID + "&uid=" + userID; //alert(printUrl);
window.location.href = window.location.href;
location.href = printUrl;
}
} else {
alert("没有要打印的报表");
return;
}
}