DS7/DSWeb/js/PaySettleApp.js

636 lines
24 KiB
JavaScript

var commonGridObj_application;
var comboCustomer;//委托单位
function $(id){
return document.getElementById(id);
}
function createGrid(){
//header
var headerArgs_application = new Array("<input type=\"checkbox\" id=\"ck_all\" onclick=\"checkAll(commonGridObj_application)\" />", "申请单号", "申请单状态", "结算单位", "USD", "RMB", "申请人", "申请日期", "结算单号", "备注", "业务类别");
//width
var widthArgs_application = new Array("40", "180", "180", "150", "100", "100", "80", "120", "120", "240", "0");
//column align
var colAlignArgs_application = new Array("center", "center", "center", "center", "center", "center", "center", "center", "center", "center", "center");
//column sort
var colSortArgs_application = new Array("na", "str", "str", "str", "str", "str", "str", "str", "str", "str", "str");
//column type
var colTypeArgs_application = new Array("ch", "ro", "ro", "ro", "ro", "ro", "ro", "ro", "ro", "ro", "ro");
commonGridObj_application = new TGridCommon("mygrid_container_application","form1",headerArgs_application,widthArgs_application,colAlignArgs_application,colSortArgs_application,colTypeArgs_application);
commonGridObj_application.setResponseUrl("PaySettlementGridSource.aspx");
if($("sel_type").value == 2){
commonGridObj_application.setRequest("PaySettlementGridSource.aspx?handle=payapp&show_page=15&cur_page=1&search=" + escape($("h_searchJson").value.trim()) + "&uid=" + commonGridObj_application.newGuid());
$("btn_postsavedapp").disabled = true;
$("btn_postsavedapp").onclick = postSavedApp;
$("btn_reapply").disabled = false;
$("btn_reapply").onclick = clickNull;
$("btn_delete").onclick = deleteReject;
}else{
commonGridObj_application.setRequest("PaySettlementGridSource.aspx?handle=savedapp&show_page=15&cur_page=1&search=" + escape($("h_searchJson").value.trim()) + "&uid=" + commonGridObj_application.newGuid());
$("btn_postsavedapp").disabled = false;
$("btn_postsavedapp").onclick = clickNull;
$("btn_reapply").disabled = true;
$("btn_reapply").onclick = reapplyAction;
$("btn_delete").onclick = deleteSavedApp
}
commonGridObj_application.setSourceType("json");
commonGridObj_application.setSkin("xp");
commonGridObj_application.setImageUrl("../images/");
commonGridObj_application.setSearch($("h_searchJson").value.trim());
commonGridObj_application.initGrid();
commonGridObj_application.bind();
if($("sel_type").value == 2){
commonGridObj_application.initPageByHandle("payapp");
}else{
commonGridObj_application.initPageByHandle("savedapp");
}
commonGridObj_application.isDBClickEvent = true;
commonGridObj_application.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd){
if($("sel_type").value == "2"){
var openSet = "height=520, width=1100, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-520)/2 + ",Left= "+(screen.width-1100)/2
var openType = "_blank";
var checkType = 0;
var openUrl = "PaySettleApplicationEdit.aspx?handle=edit&id="+rId+"&checktype="+$("sel_type").value;
window.open (openUrl,openType,openSet);
}else{
var openSet = "height=520, width=1100, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-520)/2 + ",Left= "+(screen.width-1100)/2
var openType = "_blank";
var checkType = 0;
var openUrl = "PaySettleApplicationEdit.aspx?handle=edit&runsettleid="+rId+"&checktype="+$("sel_type").value;
window.open (openUrl,openType,openSet);
}
});
commonGridObj_application.dbclickEvent = function(){
commonGridObj_application.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd){
if($("sel_type").value == "2"){
var openSet = "height=520, width=1100, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-520)/2 + ",Left= "+(screen.width-1100)/2
var openType = "_blank";
var checkType = 0;
var openUrl = "PaySettleApplicationEdit.aspx?handle=edit&id="+rId+"&checktype="+$("sel_type").value;
window.open (openUrl,openType,openSet);
}else{
var openSet = "height=520, width=1100, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-520)/2 + ",Left= "+(screen.width-1100)/2
var openType = "_blank";
var checkType = 0;
var openUrl = "PaySettleApplicationEdit.aspx?handle=edit&runsettleid="+rId+"&checktype="+$("sel_type").value;
window.open (openUrl,openType,openSet);
}
});
}
}
function initCombo(){
createComboCustomer();//结算单位
}
function checkAll(obj){
return true;
}
function applicationAction(){
var url = "PaySettlementGridSource.aspx?handle=validatepaysettleapp&search=" + escape($("h_searchJson").value.trim()) + "&uid=" + commonGridObj_application.newGuid();
var loader = dhtmlxAjax.getSync(url);
var postStatus = loader.xmlDoc.responseText;
var status = parseInt(postStatus);
if(status > 0){
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 moduleName = "";
if(commonGridObj_application.$("h_mod").value != ""){
moduleName = "?mod="+commonGridObj_application.$("h_mod").value;
}
var openUrl = "CommonPaySettleApplication.aspx" + moduleName;
window.open (openUrl,openType,openSet);
}else{
alert("没有权限申请付费");
return;
}
}
function refreshList(){
search();
}
//根据条件查询付费申请信息
function search() {
var dg = new dialog();
dg.html = "程序正在执行,请稍等!";
//dg.html+="<input type=button onclick='new dialog().close();' value='确定'>";
dg.width = 200;
dg.height = 100;
dg.title = "标题";
dg.show();
//
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 _blno = $("txt_blno").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 += "\"billstatus\":\"" + $("ddlBILLSTATUS").value.trim() + "\",";
searchJson += "\"no\":\""+_checkno+"\",";
searchJson += "\"blno\":\"" + _blno + "\",";
searchJson += "\"other\":\"" + _other + "\"";
searchJson += "]";
searchJson +="}";//alert(searchJson);
$("h_searchJson").value = searchJson;
//
createGrid();
//
setTimeout(function () {
dg.close();
}, 300);
}
//校验时间格式
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.setOptionWidth(200);
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_blno").value = "";
//search();
}
//重新提交付费申请(复制原驳回后的数据)
function reapplyAction(){
var postArg = new Array();
var stateArg = new Array();
var oplbArg=new Array();
var success = 0;
var failure = 0;
var feeError = 0;
for(var i=0;i<commonGridObj_application.getGridObj().getRowsNum();i++){
var rId = commonGridObj_application.getGridObj().getRowId(i);
var checkState = commonGridObj_application.getGridObj().cellByIndex(i,0).getValue();
var oplb=commonGridObj_application.getGridObj().cellByIndex(i,9).getValue();
if(checkState == 1){
postArg.push(rId);
oplbArg.push(oplb);
}
}
if(postArg.length > 0){
for(var j=0;j<postArg.length;j++){
var url = "PaySettlementGridSource.aspx?handle=repostpayapp&id=" + postArg[j] + "&oplb=" + oplbArg[j] + "&search=" + escape($("h_searchJson").value.trim()) + "&uid=" + commonGridObj_application.newGuid();
var loader = dhtmlxAjax.getSync(url);
var postStatus = loader.xmlDoc.responseText;
var status = parseInt(postStatus);
if(status == 1){
success++;
}else{
if(status == -3){
feeError++;
}else{
failure++;
}
}
}
search();
alert("提交付费申请 共 "+postArg.length+" 条 成功 "+success+" 条 失败 "+failure+" 条 费用已被申请申请失败 "+feeError+" 条");
}
}
function checkList(val){
search();
}
function postSavedApp(){
var postArg = new Array();
var stateArg = new Array();
var oplbArg=new Array();
var success = 0;
var failure = 0;
var feeError = 0;
for(var i=0;i<commonGridObj_application.getGridObj().getRowsNum();i++){
var rId = commonGridObj_application.getGridObj().getRowId(i);
var checkState = commonGridObj_application.getGridObj().cellByIndex(i,0).getValue();
var oplb=commonGridObj_application.getGridObj().cellByIndex(i,9).getValue();
if(checkState == 1){
postArg.push(rId);
oplbArg.push(oplb);
}
}
if(postArg.length > 0){
for(var j=0;j<postArg.length;j++){
var url = "PaySettlementGridSource.aspx?handle=postsavedapp&runsettleid=" + postArg[j] + "&oplb=" + oplbArg[j] + "&search=" + escape($("h_searchJson").value.trim()) + "&uid=" + commonGridObj_application.newGuid();
var loader = dhtmlxAjax.getSync(url);
var stateVal = loader.xmlDoc.responseText;
if(stateVal == 1){
success++;
}else{
if(stateVal == -3){
feeError++;
}else{
failure++;
}
}
stateArg.push(stateVal);
}
search();
alert("提交付费申请 共 "+postArg.length+" 条 成功 "+success+" 条 失败 "+failure+" 条 费用已被申请申请失败 "+feeError+" 条");
}
}
function clickNull(){
}
function deleteSavedApp(){
var postArg = new Array();
var stateArg = new Array();
var success = 0;
var failure = 0;
//var feeError = 0;
for(var i=0;i<commonGridObj_application.getGridObj().getRowsNum();i++){
var rId = commonGridObj_application.getGridObj().getRowId(i);
var checkState = commonGridObj_application.getGridObj().cellByIndex(i,0).getValue();
if(checkState == 1){
postArg.push(rId);
}
}
if(postArg.length > 0){
for(var j=0;j<postArg.length;j++){
var url = "PaySettlementGridSource.aspx?handle=deletesavedapp&runsettleid=" + postArg[j] + "&search=" + escape($("h_searchJson").value.trim()) + "&uid=" + commonGridObj_application.newGuid();
var loader = dhtmlxAjax.getSync(url);
var stateVal = loader.xmlDoc.responseText;
if(stateVal == 1){
success++;
}else{
if(stateVal == -3){
feeError++;
}else{
failure++;
}
}
stateArg.push(stateVal);
}
search();
alert("删除未提交的申请完成 共 "+postArg.length+" 条 成功 "+success+" 条 失败 "+failure+" 条");
}
}
function deleteReject(){
var postArg = new Array();
var stateArg = new Array();
var success = 0;
var failure = 0;
//var feeError = 0;
for(var i=0;i<commonGridObj_application.getGridObj().getRowsNum();i++){
var rId = commonGridObj_application.getGridObj().getRowId(i);
var checkState = commonGridObj_application.getGridObj().cellByIndex(i,0).getValue();
if(checkState == 1){
postArg.push(rId);
}
}
if(postArg.length > 0){
for(var j=0;j<postArg.length;j++){
var url = "PaySettlementGridSource.aspx?handle=deleterejectapp&id=" + postArg[j] + "&search=" + escape($("h_searchJson").value.trim()) + "&uid=" + commonGridObj_application.newGuid();
var loader = dhtmlxAjax.getSync(url);
var stateVal = loader.xmlDoc.responseText;
if(stateVal == 1){
success++;
}else{
if(stateVal == -3){
feeError++;
}else{
failure++;
}
}
stateArg.push(stateVal);
}
search();
alert("删除申请完成 共 "+postArg.length+" 条 成功 "+success+" 条 失败 "+failure+" 条");
}
}
function printInvoice() {
var checked = commonGridObj_application.getGridObj().getCheckedRows(0); //所有选中的grid的id编号;
var printUrl = "";
var companyID = "";
var typeName = "PayFeeAuditList";
var dbSourceID = "";
var userID = "";
var url = "";
if ($("h_searchJson").value != null) {
url = "../Reports/ReportService.aspx?handle=printpayfeeauditlist&gids=" + checked + "&search=" + escape($("h_searchJson").value) + "&val=" + commonGridObj_application.newGuid();
}
else {
url = "../Reports/ReportService.aspx?handle=printpayfeeauditlist&gids=" + checked + "&val=" + commonGridObj_application.newGuid();
}
typeName = "PayFeeAuditList";
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;
}
}
function printInvoice2() {
var checked = commonGridObj_application.getGridObj().getCheckedRows(0); //所有选中的grid的id编号;
var printUrl = "";
var companyID = "";
var typeName = "PayFeeAuditReport2";
var dbSourceID = "";
var userID = "";
if (checked.trim() == "") {
alert("请先选择要操作的数据!");
return;
}
var url = "../Reports/ReportService.aspx?handle=printpayfeeauditreport2&gids=" + checked + "&val=" + commonGridObj_application.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;
}
}
function dialog() {
this.width = 450;
this.height = 360;
this.title_height = 20;
this.html = '';
this.title = '';
var self = this;
var bgObj, msgObj, titleObj;
this.close = function () {
document.body.removeChild(document.getElementById("bgDiv"));
document.getElementById("msgDiv").removeChild(document.getElementById("msgTitle"));
document.body.removeChild(document.getElementById("msgDiv"));
}
this.show = function () {
var msgw, msgh, bordercolor;
msgw = self.width;
msgh = self.height;
bordercolor = "#336699";
titlecolor = "#99CCFF";
var sWidth, sHeight;
sWidth = document.body.offsetWidth;
sHeight = screen.height;
bgObj = document.createElement("div");
bgObj.setAttribute('id', 'bgDiv');
bgObj.style.position = "absolute";
bgObj.style.top = "0";
bgObj.style.background = "#777";
bgObj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
bgObj.style.opacity = "0.6";
bgObj.style.left = "0";
bgObj.style.width = sWidth + "px";
bgObj.style.height = sHeight + "px";
bgObj.style.zIndex = "10000";
document.body.appendChild(bgObj);
msgObj = document.createElement("div")
msgObj.setAttribute("id", "msgDiv");
msgObj.setAttribute("align", "center");
msgObj.style.background = "white";
msgObj.style.border = "1px solid " + bordercolor;
msgObj.style.position = "absolute";
msgObj.style.left = "50%";
msgObj.style.top = "30%";
msgObj.style.font = "12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
msgObj.style.marginLeft = "-225px";
msgObj.style.marginTop = -75 + document.documentElement.scrollTop + "px";
msgObj.style.width = msgw + "px";
msgObj.style.height = msgh + "px";
msgObj.style.textAlign = "center";
msgObj.style.lineHeight = "25px";
msgObj.style.zIndex = "10001";
titleObj = document.createElement("h4");
titleObj.setAttribute("id", "msgTitle");
titleObj.setAttribute("align", "center");
titleObj.style.margin = "0";
titleObj.style.padding = "3px";
titleObj.style.background = bordercolor;
titleObj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
titleObj.style.opacity = "0.75";
titleObj.style.border = "1px solid " + bordercolor;
titleObj.style.height = self.title_height + "px";
titleObj.style.font = "12px Verdana, Geneva, Arial, Helvetica, sans-serif";
titleObj.style.color = "white";
titleObj.style.cursor = "pointer";
titleObj.innerHTML = self.title;
//titleObj.onclick=function(){self.close();}
document.body.appendChild(msgObj);
document.getElementById("msgDiv").appendChild(titleObj);
var txt = document.createElement("div");
txt.style.margin = "1em 0"
txt.setAttribute("id", "msgTxt");
txt.innerHTML = self.html;
document.getElementById("msgDiv").appendChild(txt);
}
}
function msgBox() {
var dg = new dialog();
dg.html = "正在保存中,请稍等……"; //"<input type=button onclick='new dialog().close();' value='确定'>";
dg.width = 200;
dg.height = 100;
dg.title = "";
dg.show();
}