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/DoPayApplication.js

677 lines
26 KiB
JavaScript

3 years ago
var commonGridObj_do;
var jsonCacheObj;
function $(id){
return document.getElementById(id);
}
function createGrid(){
//header
var headerArgs_do = new Array("币别","金额");
//width
var widthArgs_do = new Array("100","100");
//column align
var colAlignArgs_do = new Array("center","center");
//column sort
var colSortArgs_do = new Array("str","str");
//column type
var colTypeArgs_do = new Array("ro","ro");
commonGridObj_do = new TGridCommon("mygrid_container_payappdo","form1",headerArgs_do,widthArgs_do,colAlignArgs_do,colSortArgs_do,colTypeArgs_do);
commonGridObj_do.setResponseUrl("SettlementGridSourceApp.aspx");
//var _billno = $("billno").value;
commonGridObj_do.setRequest("SettlementGridSourceApp.aspx?handle=billlist&billno="+1);
commonGridObj_do.setSourceType("json");
commonGridObj_do.setSkin("xp");
commonGridObj_do.setImageUrl("../images/");
commonGridObj_do.initGrid();
commonGridObj_do.bind();
commonGridObj_do.getGridObj().enableEditEvents(true,false,true);
var totalCache = $("h_total").value;
var totalObj = eval('(' + totalCache + ')');
if (totalObj.totals[0].totalrmb == 0 && totalObj.totals[0].totalusd == 0) {
var newId = commonGridObj_do.newGuid();
var rowCount = commonGridObj_do.getGridObj().getRowsNum();
commonGridObj_do.getGridObj().addRow(newId, ["RMB", totalObj.totals[0].totalrmb], rowCount);
}
else {
if (totalObj.totals[0].totalrmb != 0) {
var newId = commonGridObj_do.newGuid();
var rowCount = commonGridObj_do.getGridObj().getRowsNum();
commonGridObj_do.getGridObj().addRow(newId, ["RMB", totalObj.totals[0].totalrmb], rowCount);
}
if (totalObj.totals[0].totalusd != 0) {
var newId = commonGridObj_do.newGuid();
var rowCount = commonGridObj_do.getGridObj().getRowsNum();
commonGridObj_do.getGridObj().addRow(newId, ["USD", totalObj.totals[0].totalusd], rowCount);
}
}
// var tempCache = $("h_feecache").value;
//
// //alert(tempCache);
// jsonCacheObj = eval('(' + tempCache + ')');
//
// var totalFee = 0.0;
//
// var totalRmbFee = 0.0;//RMB费用合计
// var totalUsdFee = 0.0;//USD费用合计
// var totalOtherFee = 0.0;//其他费用合计
//
// var customerName = "";
// if(jsonCacheObj.caches.length > 0){
//
// for(var i=0;i<jsonCacheObj.caches.length;i++){
// var feeType = 0;
// if(i == 0){
// customerName = jsonCacheObj.caches[i].cus;
// $("txt_customerName").value = customerName;
// }
// feeType = parseInt(jsonCacheObj.caches[i].type);
// var cstl = parseFloat(jsonCacheObj.caches[i].cstl);
// var cur = jsonCacheObj.caches[i].cur;
//
// if(cur == "RMB"){//如果此条费用为RMB
// if(feeType == 2){//如果是应收则累加费用
// totalRmbFee += cstl;
// }else{//如果是应付则累减数据
// totalRmbFee -= cstl;
// }
// }else if(cur == "USD"){//如果此条费用为USD
// if(feeType == 2){//如果是应收则累加费用
// totalUsdFee += cstl;
// }else{//如果是应付则累减数据
// totalUsdFee -= cstl;
// }
// }else{
// if(feeType == 2){//如果是应收则累加费用
// totalOtherFee += cstl;
// }else{//如果是应付则累减数据
// totalOtherFee -= cstl;
// }
// }
// }
//
// //alert(totalRmbFee);
// //alert(totalRmbFee);
// var settleCurrency = $("h_settlecurrency").value;
//// var url = "SettlementGridSourceApp.aspx?handle=bankinfo&uid="+commonGridObj_do.newGuid();
//// var loader = dhtmlxAjax.getSync(url);
////
//// var bankInfo = loader.xmlDoc.responseText;
//// var jsonCacheObj = eval('(' + bankInfo + ')');
//
//
// if(settleCurrency == 1){
// if(totalUsdFee != 0){
// var newId = commonGridObj_do.newGuid();
// var usdToRmbRate = parseFloat($("h_usdtormb").value);
// totalFee = moneyMath(totalUsdFee * usdToRmbRate);
// if(totalRmbFee > 0){
// totalFee += totalRmbFee;
// }
// commonGridObj_do.getGridObj().addRow(newId,["RMB",totalFee],0);
// //commonGridObj_do.bind();
//
//
//// for(var k=0;k<jsonCacheObj.banks.length;k++){
//// if(jsonCacheObj.banks[k].cur == "RMB"){
//// var newCombo = commonGridObj_do.getGridObj().getCustomCombo(newId,2);
//// newCombo.put(jsonCacheObj.banks[k].id,jsonCacheObj.banks[k].bank);
//// }
//// }
//// commonGridObj_do.bind();
// }else if(totalRmbFee != 0){
// var newId = commonGridObj_do.newGuid();
// totalFee = totalRmbFee;
// commonGridObj_do.getGridObj().addRow(newId,["RMB",totalFee],0);
// //commonGridObj_do.bind();
//
//
//// for(var k=0;k<jsonCacheObj.banks.length;k++){
//// if(jsonCacheObj.banks[k].cur == "RMB"){
//// var newCombo = commonGridObj_do.getGridObj().getCustomCombo(newId,2);
//// newCombo.put(jsonCacheObj.banks[k].id,jsonCacheObj.banks[k].bank);
//// }
//// }
//// commonGridObj_do.bind();
// }
// }else if(settleCurrency == 2){
// if(totalRmbFee != 0){
// var newId = commonGridObj_do.newGuid();
// var rmbToUsdRate = parseFloat($("h_rmbtousd").value);
// totalFee = moneyMath(totalRmbFee * rmbToUsdRate);
// if(totalUsdFee > 0){
// totalFee += totalUsdFee;
// }
// //alert(totalFee);
// commonGridObj_do.getGridObj().addRow(newId,["USD",totalFee],0);
// //commonGridObj_do.bind();
//
//// for(var k=0;k<jsonCacheObj.banks.length;k++){
//// if(jsonCacheObj.banks[k].cur == "USD"){
//// var newCombo = commonGridObj_do.getGridObj().getCustomCombo(newId,2);
//// newCombo.put(jsonCacheObj.banks[k].id,jsonCacheObj.banks[k].bank);
//// }
//// }
//// commonGridObj_do.bind();
// }
// else if(totalUsdFee != 0){
// var newId = commonGridObj_do.newGuid();
// totalFee = totalUsdFee;
// commonGridObj_do.getGridObj().addRow(newId,["USD",totalFee],0);
// //commonGridObj_do.bind();
//
//// for(var k=0;k<jsonCacheObj.banks.length;k++){
//// if(jsonCacheObj.banks[k].cur == "USD"){
//// var newCombo = commonGridObj_do.getGridObj().getCustomCombo(newId,2);
//// newCombo.put(jsonCacheObj.banks[k].id,jsonCacheObj.banks[k].bank);
//// }
//// }
//// commonGridObj_do.bind();
//
// }
// }else{
// if(totalRmbFee != 0){
// var newId = commonGridObj_do.newGuid();
// var usdToRmbRate = parseFloat($("h_usdtormb").value);//alert(usdToRmbRate);
// var sumRmdFee = totalRmbFee //+ (totalUsdFee * usdToRmbRate);
//
// commonGridObj_do.getGridObj().addRow(newId,["RMB",sumRmdFee],0);
// //commonGridObj_do.bind();
//
//
//// for(var k=0;k<jsonCacheObj.banks.length;k++){
//// if(jsonCacheObj.banks[k].cur == "RMB"){
//// var newCombo = commonGridObj_do.getGridObj().getCustomCombo(newId,2);
//// newCombo.put(jsonCacheObj.banks[k].id,jsonCacheObj.banks[k].bank);
//// }
//// }
// }
//
// if(totalUsdFee != 0){
// var newId = commonGridObj_do.newGuid();
// var rmbToUsdRate = parseFloat($("h_rmbtousd").value);
// var sumUsdFee = totalUsdFee;
//
// if(totalRmbFee == 0){
// commonGridObj_do.getGridObj().addRow(newId,["USD",sumUsdFee],0);
// }else{
// commonGridObj_do.getGridObj().addRow(newId,["USD",sumUsdFee],1);
// }
// //commonGridObj_do.bind();
//
//
//// for(var k=0;k<jsonCacheObj.banks.length;k++){
//// if(jsonCacheObj.banks[k].cur == "USD"){
//// var newCombo = commonGridObj_do.getGridObj().getCustomCombo(newId,2);
//// newCombo.put(jsonCacheObj.banks[k].id,jsonCacheObj.banks[k].bank);
//// }
//// }
// }
// //commonGridObj_do.bind();
//
// }
//
// }
}
function saveSettle(){
if(commonGridObj_do != null){
// var currency = commonGridObj_do.getGridObj().cellByIndex(0,0).getValue();
// var amount = commonGridObj_do.getGridObj().cellByIndex(0,1).getValue();
// var account = commonGridObj_do.getGridObj().cellByIndex(0,2).getValue();
// var bankinfo = commonGridObj_do.getGridObj().cellByIndex(0,2).getText();
//
// if(account == ""){
// alert("请选择要入账的账户");
// return;
// }
// $("h_currency").value = currency;
// $("h_amount").value = amount;
// $("h_account").value = account;
// $("h_bankinfo").value = bankinfo;
var jsonSettleObj = null;
// var payableTime = $("txt_payableDate").value;
//
// if(payableTime == ""){
// alert("请选择要求支付日期");
// return;
// }
//alert(1111);
var isOrderPay = false;
var isRun = true;
var stlName = "";
var clientName = $("txt_customerName").value.trim();
//验证结算单位是否是月结或者是半月结
var url = "../FeeCodes/CRMClientInfo.aspx?handle=clientstl&name="+escape(clientName)+"&uid="+commonGridObj_do.newGuid();
var loader = dhtmlxAjax.getSync(url);
var stlVal = loader.xmlDoc.responseText;
var stlObj = null;
stlObj = eval('(' + stlVal + ')');
if(stlObj.customer.length > 0){
var stlType = parseInt(stlObj.customer[0].stl);
switch(stlType){
case 0:
case 1:
isOrderPay = true;
stlName = "票结";
break;
case 2:
stlName = "半月结";
isOrderPay = false;
break;
case 3:
stlName = "月结";
isOrderPay = false;
break;
}
}else{
isOrderPay = true;
}
if(!isOrderPay){
if(window.confirm("当前结算单位为 "+stlName+" 您确定要提交付费申请")){
isRun = true;
}else{
isRun = false;
}
}
if(isRun){
// for(var i = 0;i <commonGridObj_do.getGridObj().getRowsNum();i++){
//
// var rId = commonGridObj_do.getGridObj().getRowId(i);
// var rowIndex = commonGridObj_do.getGridObj().getRowIndex(rId);
// var tempSettleInfo = $("h_settleinfo").value;
//
// if(tempSettleInfo == ""){
//
// var cacheBuffer = "";
// cacheBuffer += "{";
// cacheBuffer += "\"id\":\""+rId+"\",";
// cacheBuffer += "\"cur\":\""+commonGridObj_do.getGridObj().cellByIndex(rowIndex,0).getValue()+"\",";//币别
// cacheBuffer += "\"amount\":\""+commonGridObj_do.getGridObj().cellByIndex(rowIndex,1).getValue()+"\"";//金额
// //cacheBuffer += "\"account\":\""+commonGridObj_do.getGridObj().cellByIndex(rowIndex,2).getValue()+"\",";//入账账户GID
// //cacheBuffer += "\"bank\":\""+commonGridObj_do.getGridObj().cellByIndex(rowIndex,2).getText()+"\"";//入账账户显示信息
// cacheBuffer += "}";
//
// var result = "";
// result += "{\"settles\":[";
// result += cacheBuffer;
// result += "]}";
//
//
// jsonSettleObj = eval('(' + result + ')');
//
// $("h_settleinfo").value = JSON.stringify(jsonSettleObj);
//
// }else{
// jsonSettleObj = eval('(' + tempSettleInfo + ')');
// var newSettles = jsonSettleObj.settles;
// newSettles = {id:rId,cur:commonGridObj_do.getGridObj().cellByIndex(rowIndex,0).getValue(),amount:commonGridObj_do.getGridObj().cellByIndex(rowIndex,1).getValue()};
//
// jsonSettleObj.settles.push(newSettles);
// $("h_settleinfo").value = JSON.stringify(jsonSettleObj);
//
// }
// }
//alert($("h_settleinfo").value);
$("h_enter").value = "1";
msgBox();
postEnterFee();
//refreshAppList();
//window.opener.location.href=window.opener.location.href;
}
//window.opener.location.href=window.opener.location.href;
}
}
function postRequest(){
if(commonGridObj_do != null){
var isOrderPay = false;
var isRun = true;
var stlName = "";
var clientName = $("txt_customerName").value.trim();
//验证结算单位是否是月结或者是半月结
var url = "../FeeCodes/CRMClientInfo.aspx?handle=clientstl&name="+escape(clientName)+"&uid="+commonGridObj_do.newGuid();
var loader = dhtmlxAjax.getSync(url);
var stlVal = loader.xmlDoc.responseText;
var stlObj = null;
stlObj = eval('(' + stlVal + ')');
if(stlObj.customer.length > 0){
var stlType = parseInt(stlObj.customer[0].stl);
switch(stlType){
case 0:
case 1:
isOrderPay = true;
stlName = "票结";
break;
case 2:
stlName = "半月结";
isOrderPay = false;
break;
case 3:
stlName = "月结";
isOrderPay = false;
break;
}
}else{
isOrderPay = true;
}
if(!isOrderPay){
if(window.confirm("当前结算单位为 "+stlName+" 您确定要提交付费申请")){
isRun = true;
}else{
isRun = false;
}
}
if(isRun){
// for(var i = 0;i <commonGridObj_do.getGridObj().getRowsNum();i++){
//
// var rId = commonGridObj_do.getGridObj().getRowId(i);
// var rowIndex = commonGridObj_do.getGridObj().getRowIndex(rId);
// var tempSettleInfo = $("h_settleinfo").value;
//
// if(tempSettleInfo == ""){
//
// var cacheBuffer = "";
// cacheBuffer += "{";
// cacheBuffer += "\"id\":\""+rId+"\",";
// cacheBuffer += "\"cur\":\""+commonGridObj_do.getGridObj().cellByIndex(rowIndex,0).getValue()+"\",";//币别
// cacheBuffer += "\"amount\":\""+commonGridObj_do.getGridObj().cellByIndex(rowIndex,1).getValue()+"\"";//金额
// //cacheBuffer += "\"account\":\""+commonGridObj_do.getGridObj().cellByIndex(rowIndex,2).getValue()+"\",";//入账账户GID
// //cacheBuffer += "\"bank\":\""+commonGridObj_do.getGridObj().cellByIndex(rowIndex,2).getText()+"\"";//入账账户显示信息
// cacheBuffer += "}";
//
// var result = "";
// result += "{\"settles\":[";
// result += cacheBuffer;
// result += "]}";
//
//
// jsonSettleObj = eval('(' + result + ')');
//
// $("h_settleinfo").value = JSON.stringify(jsonSettleObj);
//
// }else{
// jsonSettleObj = eval('(' + tempSettleInfo + ')');
// var newSettles = jsonSettleObj.settles;
// newSettles = {id:rId,cur:commonGridObj_do.getGridObj().cellByIndex(rowIndex,0).getValue(),amount:commonGridObj_do.getGridObj().cellByIndex(rowIndex,1).getValue()};
//
// jsonSettleObj.settles.push(newSettles);
// $("h_settleinfo").value = JSON.stringify(jsonSettleObj);
//
// }
// }
//alert($("h_settleinfo").value);
$("h_enter").value = "2";
msgBox();
postEnterFee();
//refreshAppList();
//window.opener.location.href=window.opener.location.href;
}
}
}
function postEnterFee(){
var myForm = document.getElementById("form1");
myForm.submit() ;
}
function outputMoney(number) {
number= number.replace(/\,/g,"");
if (isNaN(number)||number=="") return "";
number = Math.round( number*100) /100;
if(number<0)
return '-'+outputDollars(Math.floor(Math.abs(number)-0) + '') + outputCents(Math.abs(number) - 0);
else
return outputDollars(Math.floor(number-0) + '') + outputCents(number - 0);
}
function outputDollars(number)
{
if (number.length<= 3)
return (number == '' ? '0' : number);
else
{
var mod = number.length%3;
var output = (mod == 0 ? '' : (number.substring(0,mod)));
for (i=0 ; i< Math.floor(number.length/3) ; i++)
{
if ((mod ==0) && (i ==0))
output+= number.substring(mod+3*i,mod+3*i+3);
else
output+= ',' + number.substring(mod+3*i,mod+3*i+3);
}
return (output);
}
}
function outputCents(amount)
{
amount = Math.round( ( (amount) - Math.floor(amount) ) *100);
return (amount<10 ? '.0' + amount : '.' + amount);
}
function ConvertToMoney(strObj){
var result = strObj.replace(",","");
return result;
}
function clearNoNum(valObj)
{
//先把非数字的都替换掉,除了数字和.
valObj = valObj.replace(/[^\d.]/g,"");
//必须保证第一个为数字而不是.
valObj = valObj.replace(/^\./g,"");
//保证只有出现一个.而没有多个.
valObj = valObj.replace(/\.{2,}/g,".");
//保证.只出现一次,而不能出现两次以上
valObj = valObj.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
return valObj;
}
function isObjNaN(Obj){
if(Obj.toString().toLowerCase() == "nan"){
return 0;
}else{
return Obj;
}
}
function moneyMath(original){
var result = Math.round(original*100)/100;
return result;
}
function refreshAppList(){
var url = window.parent.opener.location;
var oldUrl = parentObj.href;
window.parent.opener.location.href = window.parent.opener.location.href;
parentObj.href = oldUrl+"&refreshstate=1";
}
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,""); }
function printApplication(){
var strBillNO = "";
var typeName = "";
strBillNO = $("h_billno").value;
if(strBillNO.trim() != ""){
var printUrl = "";
var companyID = "";
var typeName = "PAYAPPSETTLE";
var dbSourceID = "";
var userID = "";
var url = "";
url = "../Reports/ReportService.aspx?handle=printpayappsettle&billno="+strBillNO+"&val="+commonGridObj_do.newGuid();
typeName = "PAYAPPSETTLE";
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;
}
}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();
}
function openAction(strGID) {
window.parent.opener.location.href = window.parent.opener.location.href;
//
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=" + strGID + "&checktype=2";
window.open(openUrl, openType, openSet);
//
window.close();
}
function closeAction() {
window.parent.opener.location.href = window.parent.opener.location.href;
window.close();
}
function refresh() {
closeAction();
}