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.

313 lines
10 KiB
JavaScript

9 months 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");
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();
var currency = "RMB";
if (totalObj.totals[0].currency.toString().trim() != "") {
var currency = totalObj.totals[0].currency.toString().trim();
}
commonGridObj_do.getGridObj().addRow(newId, [currency, totalObj.totals[0].totalrmb], rowCount);
}
else {
if (totalObj.totals[0].totalrmb != 0) {
var newId = commonGridObj_do.newGuid();
var rowCount = commonGridObj_do.getGridObj().getRowsNum();
var currency = "RMB";
if (totalObj.totals[0].currency.toString().trim() != "") {
var currency = totalObj.totals[0].currency.toString().trim();
}
commonGridObj_do.getGridObj().addRow(newId, [currency, totalObj.totals[0].totalrmb], rowCount);
}
if (totalObj.totals[0].totalusd != 0) {
var newId = commonGridObj_do.newGuid();
var rowCount = commonGridObj_do.getGridObj().getRowsNum();
var currency = "USD";
if (totalObj.totals[0].currency.toString().trim() != "") {
var currency = totalObj.totals[0].currency.toString().trim();
}
commonGridObj_do.getGridObj().addRow(newId, [currency, totalObj.totals[0].totalusd], rowCount);
}
}
}
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) {
$("h_enter").value = "2";
msgBox();
postEnterFee();
}
}
}
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 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 = "RecvSettleApplicationEdit.aspx?handle=edit&id=" + strGID;
window.open(openUrl, openType, openSet);
//
window.close();
}
function closeAction() {
window.parent.opener.location.href = window.parent.opener.location.href;
window.close();
}
function refresh() {
closeAction();
}