|
|
|
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("70","80","400");
|
|
|
|
//column align
|
|
|
|
var colAlignArgs_do = new Array("center","center","center");
|
|
|
|
//column sort
|
|
|
|
var colSortArgs_do = new Array("str","str","str");
|
|
|
|
//column type
|
|
|
|
var colTypeArgs_do = new Array("ro","ro","co");
|
|
|
|
|
|
|
|
|
|
|
|
commonGridObj_do = new TGridCommon("mygrid_container_paydo","form1",headerArgs_do,widthArgs_do,colAlignArgs_do,colSortArgs_do,colTypeArgs_do);
|
|
|
|
|
|
|
|
commonGridObj_do.setResponseUrl("SettlementGridSource.aspx");
|
|
|
|
|
|
|
|
//var _billno = $("billno").value;
|
|
|
|
commonGridObj_do.setRequest("SettlementGridSource.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);
|
|
|
|
commonGridObj_do.getGridObj().attachEvent("onEditCell",function(stage,rId,cInd,nValue,oValue){
|
|
|
|
if(stage == 0){
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if(stage == 1){
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if(stage == 2){
|
|
|
|
return 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 iCount = 0;
|
|
|
|
|
|
|
|
var settleCurrency = $("h_settlecurrency").value;
|
|
|
|
var url = "SettlementGridSource.aspx?handle=bankinfo&uid="+commonGridObj_do.newGuid();
|
|
|
|
var loader = dhtmlxAjax.getSync(url);
|
|
|
|
|
|
|
|
var bankInfo = loader.xmlDoc.responseText;
|
|
|
|
var jsonCacheObj = eval('(' + bankInfo + ')');
|
|
|
|
|
|
|
|
for(var i=0;i < commonGridObj_do.getGridObj().getRowsNum();i++){
|
|
|
|
var rowId = commonGridObj_do.getGridObj().getRowId(i);
|
|
|
|
var newCombo = commonGridObj_do.getGridObj().getCustomCombo(rowId,2);
|
|
|
|
for(var j=0;j < jsonCacheObj.banks.length;j++){
|
|
|
|
if(commonGridObj_do.getGridObj().cellByIndex(i,0).getValue().trim() == jsonCacheObj.banks[j].cur){
|
|
|
|
newCombo.put(jsonCacheObj.banks[j].id,jsonCacheObj.banks[j].bank);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if($("h_usdaccount").value.trim() != "" && commonGridObj_do.getGridObj().cellByIndex(i,0).getValue().length > 0){
|
|
|
|
if(commonGridObj_do.getGridObj().cellByIndex(i,0).getValue().trim() == "USD"){
|
|
|
|
commonGridObj_do.getGridObj().cellByIndex(i,2).setValue($("h_usdaccount").value.trim());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if($("h_rmbaccount").value.trim() != "" && commonGridObj_do.getGridObj().cellByIndex(i,0).getValue().length > 0){
|
|
|
|
if(commonGridObj_do.getGridObj().cellByIndex(i,0).getValue().trim() == "RMB"){
|
|
|
|
commonGridObj_do.getGridObj().cellByIndex(i,2).setValue($("h_rmbaccount").value.trim());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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 cancelSettle(){
|
|
|
|
window.opener.location.href=window.opener.location.href;
|
|
|
|
window.opener='null';window.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,""); }
|
|
|
|
|
|
|
|
function postSettle(){
|
|
|
|
commonGridObj_do.getGridObj().editStop();
|
|
|
|
for(var i=0;i < commonGridObj_do.getGridObj().getRowsNum();i++){
|
|
|
|
if(commonGridObj_do.getGridObj().cellByIndex(i,0).getValue().trim() == "USD"){
|
|
|
|
|
|
|
|
$("h_usdaccount").value = commonGridObj_do.getGridObj().cellByIndex(i,2).getValue().trim();
|
|
|
|
}else if(commonGridObj_do.getGridObj().cellByIndex(i,0).getValue().trim() == "RMB"){
|
|
|
|
|
|
|
|
$("h_rmbaccount").value = commonGridObj_do.getGridObj().cellByIndex(i,2).getValue().trim();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$("h_enter").value = "2";
|
|
|
|
msgBox();
|
|
|
|
postEnterFee();
|
|
|
|
}
|
|
|
|
|
|
|
|
function saveSettle(){
|
|
|
|
var settleJson = "";
|
|
|
|
|
|
|
|
commonGridObj_do.getGridObj().editStop();
|
|
|
|
for(var i=0;i < commonGridObj_do.getGridObj().getRowsNum();i++){
|
|
|
|
if(commonGridObj_do.getGridObj().cellByIndex(i,0).getValue().trim() == "USD"){
|
|
|
|
$("h_usdaccount").value = commonGridObj_do.getGridObj().cellByIndex(i,2).getValue().trim();
|
|
|
|
}else if(commonGridObj_do.getGridObj().cellByIndex(i,0).getValue().trim() == "RMB"){
|
|
|
|
$("h_rmbaccount").value = commonGridObj_do.getGridObj().cellByIndex(i,2).getValue().trim();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$("h_settleinfo").value = settleJson;
|
|
|
|
$("h_enter").value = "1";
|
|
|
|
msgBox();
|
|
|
|
postEnterFee();
|
|
|
|
}
|
|
|
|
|
|
|
|
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 closeAction(){
|
|
|
|
window.parent.opener.location.href = window.parent.opener.location.href;
|
|
|
|
window.close();
|
|
|
|
}
|
|
|
|
function refresh() {
|
|
|
|
closeAction();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function cwvouchersadd(gid) {
|
|
|
|
var url = "../CW/CwVouchersChFeeSettlementListGridSource.aspx?handle=isvouchers&gids=" + gid + "&uid=" + newGuid();
|
|
|
|
var loader = dhtmlxAjax.getSync(url);
|
|
|
|
var jsVal = loader.xmlDoc.responseText;
|
|
|
|
if (jsVal.trim() != "") {
|
|
|
|
alert(jsVal); //"有已生成的凭证,不能重复生成!"
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
var url = "../CW/CwVouchersAddDoGridSource.aspx?read=isvouchers&gids=" + gid + "&uid=" + newGuid();
|
|
|
|
var loader = dhtmlxAjax.getSync(url);
|
|
|
|
var jsVal = loader.xmlDoc.responseText;
|
|
|
|
if (jsVal.trim() == "") {
|
|
|
|
alert("生成凭证失败!"); //"有已生成的凭证,不能重复生成!"
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
var feature = "height=500, width=1000, toolbar=no, menubar=no,scrollbars=no, resizable=0,location=no, status=no,Top= " + (screen.height / 2 - 300) + ",Left= " + (screen.width / 2 - 500);
|
|
|
|
var URLs = "../CW/CwVouchersAddDo.aspx?ordno=" + jsVal;
|
|
|
|
window.open(URLs, "生成结算凭证信息", feature);
|
|
|
|
}
|
|
|
|
|
|
|
|
function newGuid() {
|
|
|
|
var guid = "";
|
|
|
|
for (var i = 1; i <= 32; i++) {
|
|
|
|
var n = Math.floor(Math.random() * 16.0).toString(16);
|
|
|
|
guid += n;
|
|
|
|
if ((i == 8) || (i == 12) || (i == 16) || (i == 20))
|
|
|
|
guid += "-";
|
|
|
|
}
|
|
|
|
return guid.toUpperCase();
|
|
|
|
}
|