var ALSObjectWindowFunctions={};//存放所有的重写或修改的数据 var enableFolding=false;//分组是否可折叠 /************JS常量定义开始***********/ ALSObjectWindowFunctions.objectWindowMetaData_DWNAME="DWNAME"; ALSObjectWindowFunctions.objectWindowMetaData_DWCOLUMNS="DWCOLUMNS"; ALSObjectWindowFunctions.objectWindowMetaData_DONO="DONO"; ALSObjectWindowFunctions.objectWindowMetaData_SERIALIZED_ASD="SERIALIZED_ASDFULL"; ALSObjectWindowFunctions.objectWindowMetaData_BIZOBJECTCLASS="JBOCLASS"; ALSObjectWindowFunctions.objectWindowMetaData_DWPARAMETERS="DWPARAMETERS"; ALSObjectWindowFunctions.ObjectWindowStyle_List="1"; ALSObjectWindowFunctions.ObjectWindowStyle_Info="2"; /************JS常量定义结束***********/ /************ObjectWindow客户端数据结构定义开始**************/ ALSObjectWindowFunctions.objectWindowMetaData=[];//存放界面上所有的objectwindow的结构定义 ALSObjectWindowFunctions.ObjectWindowData=[];//存放所有ObjectWindow的数据序列化之后的字符串 ALSObjectWindowFunctions.ObjectWindowOutputData=[];//存放所有ObjectWindow的输出数据,区别于界面录入数据,因为存在一些场景,需要获取OW字段之外的输出值 /************ObjectWindow客户端数据结构定义结束**************/ /************ObjectWindow客户端函数定义开始**************/ /* * 获得ObjectWindow的返回参数值 */ ALSObjectWindowFunctions.getOutputParameter=function(dwname,parameterName){ var parameterObject = ALSObjectWindowFunctions.ObjectWindowOutputData[dwname]; if(parameterObject){ return AsCredit.getBusinessObjectAtrribute(parameterObject,parameterName); } }; /* * 获得ObjectWindow的返回参数值 */ ALSObjectWindowFunctions.getOutputParameterObject=function(dwname){ return ALSObjectWindowFunctions.ObjectWindowOutputData[dwname]; }; /* * 获得ObjectWindow的返回参数值 */ ALSObjectWindowFunctions.getOutputParameters=function(dwname){ return AsCredit.getBusinessObjectAtrributes(ALSObjectWindowFunctions.getOutputParameterObject(dwname)); }; /* * 获取objectwindow对象 */ ALSObjectWindowFunctions.getObjectWindowMetaObject=function(dwname){ if(ALSObjectWindowFunctions.objectWindowMetaData){ return ALSObjectWindowFunctions.objectWindowMetaData[dwname]; } }; /* * 获取objectwindow对象 */ ALSObjectWindowFunctions.getObjectWindowFieldIndex=function(dwname,fieldName){ var columnString = ALSObjectWindowFunctions.getObjectWindowMetaAttribute(dwname,ALSObjectWindowFunctions.objectWindowMetaData_DWCOLUMNS); columnString= columnString.split(","); for(var i=0;i0)eval(postevents); ALSObjectWindowFunctions.addInfoValidator(subdwname); }catch(e){ msg = "操作成功,但是页面刷新失败:"+e.toString(); } }else{ aDWResultError[0] = result.errors; resetDWDialog(result.errors,false); } } }); }; ALSObjectWindowFunctions.clearInfoValidator=function(dwname){ for(colName in _user_validator[dwname].rules){ if(dwname!="0") colName=dwname+"_"+colName; try{ if(document.getElementById(colName)){ $("#"+colName).rules("remove"); } else{ $(document.getElementsByName(colName)).rules("remove"); } }catch(e){} } }; ALSObjectWindowFunctions.addInfoValidator=function(dwname){ var objectWindowStyle=ALSObjectWindowFunctions.getObjectWindowStyle(dwname); if(objectWindowStyle!=ALSObjectWindowFunctions.ObjectWindowStyle_Info) return ; for(colName in _user_validator[dwname].rules){ var actualColName=colName; if(dwname!="0") actualColName=dwname+"_"+colName; try{ var rules=_user_validator[dwname].rules[colName]; rules.messages=_user_validator[dwname].messages[colName]; if(document.getElementById(actualColName)){ $("#"+actualColName).rules("add",rules); } else{ $(document.getElementsByName(actualColName)).rules("add",rules); } }catch(e){} delete rules.messages; } }; ALSObjectWindowFunctions.isGroupVisible=function(groupID){ var tableID="@SysSub@"; if(groupID.length>0) tableID = "@SysSub"+groupID; var tableDiv = document.getElementById(tableID); if(tableDiv){ if(tableDiv.style.display=="none") return false; else return true; } else return false; }; ALSObjectWindowFunctions.showErrors=function(){ var errorcount=0; var iExtCount = 8; document.getElementById("messageBox").style.display='block'; for(var i=0;i"; if(errorcount>=iExtCount){ document.getElementById("ul_error_1").appendChild(ele_error); } else{ document.getElementById("ul_error_0").appendChild(ele_error); } } for(var ii=0;ii" + errmsg + ""; if(errorcount>=iExtCount){ document.getElementById("ul_error_1").appendChild(ele_error); }else{ document.getElementById("ul_error_0").appendChild(ele_error); } } } } if(errorcount<=iExtCount){ $("#showpart").hide(); $("#mobtn").hide(); $("#hidbtn").hide(); }else{ $("#showpart").hide(); $("#hidbtn").hide(); } }; /** * 一次性保存界面中的所有ObjectWindow */ ALSObjectWindowFunctions.saveAllObjectWindow=function(postevents,tempSaveFlag){ if(!ALSObjectWindowFunctions.objectWindowMetaData||ALSObjectWindowFunctions.objectWindowMetaData.length<=0){ return; } var sys_data = [];//用于存放所有的datawindow中变更过的数据 if(!tempSaveFlag||tempSaveFlag==false){ var checkResult = ALSObjectWindowFunctions.validate(); if(!checkResult){ ALSObjectWindowFunctions.showErrors(); return; } } for(var i=0;i0){ eval(postevents); } }catch(e){ msg = "操作成功,但是页面刷新失败:"+e.toString(); } }else{ aDWResultError[0] = result.errors; resetDWDialog(result.errors,false); } } }); }; /** * 获取objectwindow的样式 */ ALSObjectWindowFunctions.getObjectWindowStyle=function(dwname){ return ALSObjectWindowFunctions.getObjectWindowMetaAttribute(dwname,"DWSTYLE"); }; ALSObjectWindowFunctions.showOverTopDiv=function(initTitle){ if(initTitle==undefined) initTitle = "正在处理中..."; var topDiv = document.getElementById("DWOverLayoutDiv"); var dwDiv = document.getElementById("div_my0"); if(dwDiv){ var newheight=dwDiv.offsetHeight; topDiv.style.height=newheight;//修改高度 } topDiv.style.display='block'; var obj = $("#DWOverLayoutSubDiv"); obj.children(".datawindow_overdiv_info").html(initTitle); obj.show(); var iLeft = document.body.clientWidth/2-obj.width()/2+document.body.scrollLeft; var iTop = document.body.clientHeight/2-obj.height()/2+100; obj.css({left:iLeft,top:iTop}); document.getElementById('sp_datawindow_overdiv_top').style.display= 'inline'; }; ALSObjectWindowFunctions.createSubmitData=function(dwname,actionData){ var data = {}; data["DATA"]=actionData; var objectmodel_serialized_string=ALSObjectWindowFunctions.getObjectWindowMetaAttribute(dwname,ALSObjectWindowFunctions.objectWindowMetaData_SERIALIZED_ASD); data["SERIALIZED_ASD"]=objectmodel_serialized_string; return data; }; ALSObjectWindowFunctions.deleteSelectRow=function(dwname,postevents){ var rownum = getRow(dwname); ALSObjectWindowFunctions.deleteListRows(dwname,rownum,postevents); }; ALSObjectWindowFunctions.removeObjectWindow=function(dwname){ }; ALSObjectWindowFunctions.hideObjectWindow=function(dwname){ }; ALSObjectWindowFunctions.showObjectWindow=function(dwname){ }; ALSObjectWindowFunctions.getDZArray=function(dwname,rowObjectArray){ var DZ_T=new Array(); for(var i=0;i0)eval("("+postevents+")"); change_height(); //}catch(e){ // msg = "操作成功,但是页面刷新失败:"+e.toString(); // resetDWDialog(msg,false); //} }else{ aDWResultError[0] = result.errors; resetDWDialog(result.errors,false); } } }); }; ALSObjectWindowFunctions.addRow=function(dwname,parameters,postevents){ var position=getRow(dwname); if(position<0) position= getRowCount(dwname); else position = position+1; ALSObjectWindowFunctions.addRows(dwname,position,1,parameters,postevents); return position; }; /** *删除List中的指定行,rowNum以逗号分隔 */ ALSObjectWindowFunctions.deleteListRows=function(dwname,rowNum,postevents,splitchar){ if(!ALSObjectWindowFunctions.objectWindowMetaData||ALSObjectWindowFunctions.objectWindowMetaData.length<=0){ return; } var actionData = [];//用于存放所有的datawindow中变更过的数据 if(!splitchar) splitchar=","; rowNum=rowNum+""; rowNum=rowNum.split(","); for(var i=0;i0)eval("("+postevents+")"); }catch(e){ msg = "操作成功,但是页面刷新失败:"+e.toString(); resetDWDialog(msg,false); } }else{ aDWResultError[0] = result.errors; resetDWDialog(result.errors,false); } } }); }; /** *显示分组 */ ALSObjectWindowFunctions.showGroup = function (groupID){ var obj = document.getElementById('imgexpand'+groupID); var groupBody = document.getElementById("GroupBody_"+groupID); if(obj.expand=="1"){ obj.expand = "0"; obj.className = "info_group_collapse"; if(groupBody) groupBody.style.display = "none"; } else{ obj.expand = "1"; obj.className = "info_group_expand"; if(groupBody) groupBody.style.display = "block"; } }; ALSObjectWindowFunctions.showItems=function(dwname,colNames){ colNames=colNames.split(","); for(var i=0;i"+title+""; obj.html(spanhtml); } }; ALSObjectWindowFunctions.setItemUnit=function(dwname,colName,unit){ var dwdiv=$("div[name='div_my" + dwname+"']"); var colIndex = ALSObjectWindowFunctions.getObjectWindowColIndex(dwname,colName); var obj; if(dwname!="0") obj = dwdiv.find("span#Unit_" + dwname + "_" + colIndex+""); else obj = dwdiv.find("span#Unit_" + colIndex+""); if(obj){ obj.html(unit); } }; ALSObjectWindowFunctions.setItemDisabled=function(dwname,iRow,colNameString,bDisable){ var colNameArray = colNameString.split(","); for(var i = 0; i < colNameArray.length; i ++){ var obj = getObj(dwname,iRow,colNameArray[i]); setReadOnly(obj,bDisable); } }; ALSObjectWindowFunctions.drawSubList=function(subdwname){ document.getElementById("Table_Content_"+subdwname+"").innerHTML = TableFactory.createTableHTML(subdwname); $("#myiframe"+subdwname+"_float,#myiframe"+subdwname+"_static,#myiframe"+subdwname+"_cells").css({ "overflow-x":"hidden", "overflow-y":"hidden" }); //事件 if(!DZ[subdwname]||!DZ[subdwname][0]||!DZ[subdwname][0][10]) return ; for(var i=0;i"+header+""; if(required){ spanhtml+=" *"; } obj.html(spanhtml); } } } for(var i = 0; i < colNameArray.length; i ++){ var colName = colNameArray[i].toUpperCase(); var header = ALSObjectWindowFunctions.getObjectWindowColAttribute(dwname,colName,"COLUMNHEADER"); var sColName=colName; if(dwname!="0")sColName=dwname+"_"+colName; if(required){ try{ if(document.getElementById(sColName)) $("#"+sColName).rules("add",{required0 : true,messages:{required0:header}}); else $(document.getElementsByName(sColName)).rules("add",{required0 : true,messages:{required0:header}}); } catch(e){ var rules = _user_validator[dwname].rules; var messages = _user_validator[dwname].messages; if(!rules[colName])rules[colName] = new Object(); if(!rules[colName].required0){ rules[colName].required0 = true; if(!messages[colName]) messages[colName] = new Object(); messages[colName].required0="请输入"+header; } } } else{ try{ if(document.getElementById(sColName)) $("#"+sColName).rules("remove","required0"); else $(document.getElementsByName(sColName)).rules("remove","required0"); } catch(e){ var rules = _user_validator[dwname].rules; var messages = _user_validator[dwname].messages; if(rules[colName]&&rules[colName].required0){ rules[colName].required0 = undefined; messages[colName].required0=undefined; } } } } }; ALSObjectWindowFunctions.setItemsRequired=function(dwname,colNameString,required){ ALSObjectWindowFunctions.setClientItemsRequired(dwname,colNameString,required); var serialized_ow=ALSObjectWindowFunctions.getObjectWindowMetaAttribute(dwname,"SERIALIZED_ASDFULL"); var requiredFlag="1"; if(!required) requiredFlag="0"; //更新校验 $.ajax({ type: "POST", url: sDWResourcePath + "/RequiredRuleUpdator.jsp", processData: false, async:false, data: "DataObject=" +serialized_ow+ "&ColName="+ colNameString + "&Required="+requiredFlag, success: function(msg){ if(msg.substring(0,5)=="fail:"){ alert('校验更新失败:' +msg.substring(5)); return; } else{ } } }); }; ALSObjectWindowFunctions.getObjs=function(dwname,row,fieldName){ var objectWindowStyle=ALSObjectWindowFunctions.getObjectWindowStyle(dwname); if(objectWindowStyle==ALSObjectWindowFunctions.ObjectWindowStyle_List){ return ALSObjectWindowFunctions.getListObjs(dwname,row,fieldName); } else if(objectWindowStyle==ALSObjectWindowFunctions.ObjectWindowStyle_Info){ if(fieldName==undefined||fieldName==null)fieldName=row; return ALSObjectWindowFunctions.getInfoObjs(dwname,fieldName); } }; ALSObjectWindowFunctions.getInfoObjs=function(dwname,fieldName){ fieldName=fieldName.toUpperCase(); var formid = "myiframe0";//只能有一个form var form = document.getElementById(formid); if(form==null)alert(formid); if(dwname!="0")fieldName=dwname+"_"+fieldName; var objs = document.getElementsByName(fieldName); return objs; }; ALSObjectWindowFunctions.getListObjs=function(dwname,row,fieldName){ var tableId = "myiframe" + dwname; var colIndex = ALSObjectWindowFunctions.getObjectWindowFieldIndex(dwname, fieldName); var tableColIndex = TableFactory.getTableColIndexFromDZ(tableId,colIndex); var obj = document.getElementById("INPUT_" + tableId + "_" + fieldName + "_" + row + "_" + tableColIndex); if(!obj)obj = document.getElementById("INPUT_" + tableId + "_" + fieldName.toUpperCase() + "_" + row + "_" + tableColIndex); var objs=new Array(); objs[0]=obj; return objs; }; ALSObjectWindowFunctions.infoValidate=function(){ var infodw_validator = {rules: {},messages:{},onsubmit:true,errorPlacement: function (error, element) { ALSObjectWindowFunctions.errorPlaceRule(error,element);} }; var checkFlag=false; var result=true; for(var i=0;i=rowCount) rowIndex = rowCount-1; TableBuilder.TRClick(rowIndex,undefined,"TR_Right_" + dwname + "_" + rowIndex,sWDColors[3]); } function setReadOnly(obj, value) { if (obj) { if (obj.type == 'radio' || obj.type == 'checkbox') { if (obj.name) { var arr = document.getElementsByName(obj.name); var len = arr.length; var tmp = null; for (var i = 0; i < len; i++){ if(value){ arr[i].setAttribute("disabled","disabeld"); }else{ arr[i].removeAttribute("disabled"); } } }else{ if(value){ obj.setAttribute("disabled","disabeld"); }else{ obj.removeAttribute("disabled"); } } }else if (obj.getAttribute("alstype")=="KNumber" || obj.getAttribute("alstype")=="Text" || obj.type == 'textarea') { if(value){ obj.setAttribute("readOnly","true"); if(obj.className.indexOf("info_text_readonly_color")==-1) obj.className+= " info_text_readonly_color"; }else{ obj.removeAttribute("readOnly"); obj.className = obj.className.replace('info_text_readonly_color',''); } }else if(obj.getAttribute("alstype")=="FlatSelect"){ var flatSelect = $(obj).data("FlatSelect"); if(value){ $(obj).addClass("info_text_readonly_color").prop("readOnly", true); if(flatSelect) $(flatSelect["input"]).addClass("info_text_readonly_color").prop("readOnly", true); }else{ $(obj).removeClass("info_text_readonly_color").removeProp("readOnly"); if(flatSelect) $(flatSelect["input"]).removeClass("info_text_readonly_color").removeProp("readOnly"); } }else{ if(value){ obj.setAttribute("disabled","disabeld"); }else{ obj.removeAttribute("disabled"); } } } } /*function setItemRequired(dwname,colNameString,required){ ALSObjectWindowFunctions.setItemsRequired(dwname, colNameString, required); }*/