| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486 |
- /**
- * 当控件为只读时不让光标进入
- * @param target
- */
- function FWnoPointer(target){
- if(jQuery(target).attr("readOnly")){
- //设置tab键为最大避免光标进入时出不来
- jQuery(target).attr("tabindex","10000000");
- jQuery(target).bind('focus.readOnly',function(event){
- this.blur();
- return true;
- });
- }
- }
- /**
- * 显示隐藏表格
- * @param imgId
- * @param tableId
- */
- function FWshowTable(imgId,tableId){
- var tableDivObj = document.getElementById(tableId);
- var imageObj = document.getElementById(imgId);
- var srcPath = imageObj.src;
- var re;
- tableDivObj.style.display = (tableDivObj.style.display=="none"?"block":"none");
- if(tableDivObj.style.display=='none'){
- re = /right/g;
- imageObj.src=srcPath.replace(re,'down');
- var ft = $("#"+tableId).parent("fieldset").get(0);
- var needMoveArchiveBtn = ft.needMoveArchiveBtn;
- if("true" == needMoveArchiveBtn){
- var fwgtid = ft.fwgtid;
- var tblArchiveDiv = document.getElementById(fwgtid+"_archive_div");
- if(null != tblArchiveDiv){
- var tblHeight = $("#" + fwgtid).parent().outerHeight();
- tblArchiveDiv.style.top = parseInt(tblArchiveDiv.style.top) - tblHeight;
- }
- }
- }else{
- re = /down/g;
- imageObj.src=srcPath.replace(re,'right');
- $(document).trigger('gridlazyInit');
- FWresizeObject(tableDivObj);
-
- if($("div:first",tableDivObj).hasClass("fwdatagrid")){
- $(tableDivObj).fwdatagrid('setSize',tableDivObj);
- }
- var ft = $("#"+tableId).parent("fieldset").get(0);
- var needMoveArchiveBtn = ft.needMoveArchiveBtn;
- if("true" == needMoveArchiveBtn){
- var fwgtid = $("#"+tableId).parent("fieldset").get(0).fwgtid;
- var tblArchiveDiv = document.getElementById(fwgtid+"_archive_div");
- if(null != tblArchiveDiv){
- var tblHeight = $("#" + fwgtid).parent().outerHeight();
- tblArchiveDiv.style.top = parseInt(tblArchiveDiv.style.top) + tblHeight;
- }
- }
- }
- }
- /**
- * 单击回车键就调用TAB键
- * @param event
- * @returns {Boolean}
- */
- function FWenterToTab(event){
- //8 backspace 9 tab 46 delete
- if(event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 46){
- return true;
- }
-
- if (event.keyCode == 13) {
- event.keyCode = 9;
- return true;
- }
-
- if(event.ctrlKey||event.shiftKey){return true;}
-
- return false;
- }
- /**
- * 初始化表格的控件
- * @param tableId
- */
- function FWinitObject(tableId){
- var tableDivObj = document.getElementById(tableId);
-
- //获取全部的下拉框的宽度保存到mw属性值内
- //注意目前只有这种方式才能让下拉框的宽度保持一致;
- //fwcombox.js init(target) 函数内会引用到
- jQuery('select',tableDivObj).each(function(){
- var mw = $(this).outerWidth();
- $(this).attr('mw',mw);
- });
-
- $(':input',tableDivObj).each(function(){
- FWObjInit(this);
- });
- }
- /**
- * 初始化每个控件
- * @param obj 控件对象
- */
- function FWObjInit(obj){
- var input = $(obj);
-
- jQuery(obj).each(function(){
-
- //有disabled的属性改成readOnly 目的是改变字体的颜色
- if(this.type=='checkbox'||this.type=='radio'){
- return true;
- }
-
- if(this.type=='text'||this.type=='textarea'){
- //下拉框的不用理会
- if($(this).hasClass('fwcombox-text')){
- return true;
- }
- //可编辑多记录表的下拉框不用理会
- if(this.cmb=='true'){
- return true;
- }
- if($(this).attr('disabled')==true){
- $(this).removeAttr('disabled');
- $(this).attr("readOnly",true);
- toDisabledObj(this);
- }
- if($(this).attr('readOnly')==true){
- toDisabledObj(this);
- }
- }
-
- });
-
- //一般的单行文本输入框
- if(input.hasClass('textbox')){
- FWinitTextBox(obj);
- return true;
- }
-
- // 身份证录入框
- if(input.hasClass('idcardbox')){
- FWinitIdCardBox(obj);
- return true;
- }
-
- //只能录入数值框
- if(input.hasClass('numberbox')){
- FWinitNumberBox(obj);
- return true;
- }
-
- //只能录入浮点数
- if(input.hasClass('floatbox')){
- FWinitFloatBox(obj);
- return true;
- }
-
- //只能录入日期
- if(input.hasClass('datebox')){
- input.datepicker();
- FWinitDateBox(obj);
- return true;
- }
-
- //只能录入日期 时间
- if(input.hasClass('datetime')){
- FWinitDateTime(obj);
- return true;
- }
-
- //只录入时分
- if(input.hasClass('timebox')){
- FWinitTimeBox(obj);
- return true;
- }
-
- //只录入中文
- if(input.hasClass('chinessbox')){
- FWinitChinessBox(obj);
- return true;
- }
-
- //只能录入年月
- if(input.hasClass('yearmonthbox')){
- FWinitYearmonthBox(obj);
- return true;
- }
-
- if(input.hasClass('bankaccount')){
- FWInitBankaccount(obj);
- return true;
- }
-
- //只能录入邮政编码
- if(input.hasClass('postbox')){
- FWinitPostBox(obj);
- return true;
- }
-
-
- //只能录入电话号码
- if(input.hasClass('phonebox')){
- FWinitPhoneBox(obj);
- return true;
- }
-
-
- //不允许复制拷贝录入框
- if(input.hasClass('notpastebox')){
- FWinitNotpasteBox(obj);
- return true;
- }
-
- //对普通的下拉框进行封装
- if(input.hasClass('combobox')){
- var __this = obj;
- $(__this).fwcombox({editable:false});
- var span =jQuery.data(__this,'fwcombox').fwcombox;
- var arrow = span.find('span.fwcombox-arrow');
- jQuery(__this).bind('blur',function(){
- //若为只读则不往下执行
- if(jQuery(__this).attr("readOnly")){return true;}
-
- var msg = FWelementValidate(__this);
- if(msg!=null){
- FWvalidateTip(arrow,msg);
- } else {
- $(arrow).qtip("destroy");
- }
- });
- return true;
- }
-
- //对可录入下拉框进行封装
- if(input.hasClass('incombox')){
- var __this = obj;
- $(__this).fwcombox({editable:true});
- var span =jQuery.data(__this,'fwcombox').fwcombox;
- var arrow = span.find('span.fwcombox-arrow');
- jQuery(__this).bind('blur',function(){
- //若为只读则不往下执行
- if(jQuery(__this).attr("readOnly")){return true;}
-
- var msg = FWelementValidate(__this);
- if(msg!=null){
- FWvalidateTip(arrow,msg);
- } else {
- $(arrow).qtip("destroy");
- }
- });
- return true;
- }
-
- //对可录入远程数据库查询下拉框进行封装
- if(input.hasClass('dbcombox')){
- input.fwcombox({editable:true,remotedb:true});
- return true;
- }
-
- //联动下拉框 现在已经不用这种方式
- //处理目的:当父下拉框选择某项值后,根据此值过滤子下拉框的内容
- if(input.hasClass('ldcombox')){
- input.fwcombox({editable:false,ldcombox:true});
- return true;
- }
-
-
- }
-
- /**
- * 初始化textbox
- * @param obj
- */
- function FWinitTextBox(obj){
- jQuery(obj).bind('keydown',function(event){
- if(FWenterToTab(event)){
- return true;
- }
- });
-
- //焦点失去事件
- jQuery(obj).bind('blur',function(){
- //若为只读则不往下执行
- if(jQuery(this).attr("readOnly")){return true;}
- var msg = FWelementValidate(this);
- if(msg!=null){
- FWvalidateTip(this,msg);
- } else {
- $(this).qtip("destroy");
- }
- });
- }
- /**
- * 初始化idcardbox
- * @param obj
- */
- function FWinitIdCardBox(obj){
- // 焦点失去事件
- jQuery(obj).bind('blur',function(){
- // 若为只读则不往下执行
- if(jQuery(this).attr("readOnly")){return true;}
- var msg = FWelementValidate(this);
- if(msg!=null){
- FWvalidateTip(this,msg);
- return true;
- } else {
- $(this).qtip("destroy");
- }
- FWidcard(this);
- });
-
- jQuery(obj).bind('keydown',function(event){
- if(FWenterToTab(event)){
- return true;
- }
- if(event.keyCode == 88){// X
- return true;
- }
- // 只能录入数字
- if(FWNumOnly(event)){
- return true;
- }
- return false;
- });
- }
- /**
- *初始化数字框
- */
- function FWinitNumberBox(obj){
- var val = obj.value;
- val = val.replace(/,/g,'');
- obj.value = val;
- jQuery(obj).bind('keydown',function(event){
- if(FWenterToTab(event)){
- return true;
- }
- switch(event.keyCode){
- case 189:// -
- case 109:// -(小键盘)
- case 190:// .
- case 110:// .(小键盘)
- case 35:// (End)
- case 36:// (Home)
- case 37://< (Left)
- case 39://> (Right)
- return true;
- default:
- return FWNumOnly(event);
- }
- });
-
- //焦点失去事件
- jQuery(obj).bind('blur',function(){
- //若为只读则不往下执行
- if(jQuery(this).attr("readOnly")){return true;}
- var msg = FWelementValidate(this);
- if(msg!=null){
- FWvalidateTip(this,msg);
- return;
- } else {
- $(this).qtip("destroy");
- }
- // 尝试转化为数值型,继续测试是否为整形
- try{
- var number = this.value;
- if(!isFinite(number)){
- // 非数值类型,清空输入框
- this.value = "";
- FWvalidateTip(this,"此输入框只能录入数字!");
- }else{
- // 转换成可以理解的数值(去除重复的“--”和“..”)
- this.value = number;
- }
- }catch(e){
- this.value = "";
- }
- });
- }
- /**
- * 初始化floatbox
- * @param obj
- */
- function FWinitFloatBox(obj){
- jQuery(obj).bind('keydown',function(event){
-
- if(FWenterToTab(event)){
- return true;
- }
- switch(event.keyCode){
- case 189://-
- case 109://-(小键盘)
- case 190://.
- case 110://.(小键盘)
- case 35:// (End)
- case 36:// (Home)
- case 37://< (Left)
- case 39://> (Right)
- return true;
- default:
- return FWNumOnly(event);
- }
- return false;
- });
-
- //焦点失去事件
- jQuery(obj).bind('blur',function(){
-
- //若为只读则不往下执行
- if(jQuery(this).attr("readOnly")){return true;}
-
- var sValue = this.value;
- if(sValue!=null&&sValue.length>0){
-
- sValue = parseFloat(sValue,10);
- if(isNaN(sValue)){
- this.value = '';
- FWvalidateTip(this,'不是一个浮点数值!');
- return;
- } else {
- $(this).qtip("destroy");
- }
- this.value = sValue;
- sValue = sValue+"";
- var iPos = sValue.indexOf(".");
- if(iPos==-1){
- this.value = sValue+'.00';
- }
- }
- var msg = FWelementValidate(this);
- if(msg!=null){
- FWvalidateTip(this,msg);
- return;
- } else {
- $(this).qtip("destroy");
- }
- });
- }
-
- /**
- * 初始化日期控件
- * @param obj
- */
- function FWinitDateBox(obj){
- var val = obj.value;
- val = val.replace(/,/g,'');
-
- if(val.length==8){
- obj.value = val.substr(0,4)+'-'+ val.substr(4,2) +'-'+ val.substr(6,2);
- }
-
- jQuery(obj).bind('keydown',function(event){
- if(FWenterToTab(event)){
- return true;
- }
- if (event.keyCode == 189){ //-
- return true;
- }
- if (event.keyCode == 109){ //-
- return true;
- }
- if (event.keyCode == 191) { // /
- return true;
- }
- if(FWNumOnly(event)){
- return true;
- }
- return false;
- });
-
- //焦点失去事件
- jQuery(obj).bind('change',function(){
- var val = this.value;
- if(val.length==8){
- this.value = val.substr(0,4)+'-'+ val.substr(4,2) +'-'+ val.substr(6,2);
- }
-
- if(!FWdatebox(this,'yyyy-mm-dd')){
- return;
- }
-
- var msg = FWelementValidate(this);
- if(msg!=null){
- FWvalidateTip(this,msg);
- } else {
- $(this).qtip("destroy");
- }
- });
- }
- /**
- * 初始化日期控件
- * @param obj
- */
- function FWinitDateTime(obj){
- var val = obj.value;
- val = val.replace(/,/g,'');
- if(val.length==14){
- obj.value = val.substr(0,4)+'-'+ val.substr(4,2) +'-'+ val.substr(6,2) + ' ' + val.substr(8,2) + ':'+ val.substr(10,2)+":"+ val.substr(12,2);
- }
-
- jQuery(obj).bind('keydown',function(event){
-
- if(FWenterToTab(event)){
- return true;
- }
-
- if(event.keyCode == 189){ //-
- return true;
- }
- if (event.keyCode == 109){ //-
- return true;
- }
- if(event.keyCode == 191) { // /
- return true;
- }
- if (event.keyCode == 186) { // :
- return true;
- }
- if (event.keyCode == 32) { // 空格
- return true;
- }
- if(FWNumOnly(event)){
- return true;
- }
- return false;
- });
-
- jQuery(obj).bind('blur',function(){
- //若为只读则不往下执行
- if(jQuery(this).attr("readOnly")){return true;}
-
- //yyyy-mm-dd hh:mm:ss
- var val = this.value;
-
- //用户只录入201009011223 改成 2010-09-01 12:23:00
- if(val.length==12){
- this.value = val.substr(0,4)+'-'+ val.substr(4,2) +'-'+ val.substr(6,2) + ' ' + val.substr(8,2) + ':'+ val.substr(10,2)+":00";
- }
-
- //用户只录入20100901 1223 改成 2010-09-01 12:23:00
- if(val.length==13){
- this.value = val.substr(0,4)+'-'+ val.substr(4,2) +'-'+ val.substr(6,2) + ' ' + val.substr(9,2) + ':'+ val.substr(11,2)+":00";
- }
-
- //用户只录入20101010121212 改成 2010-10-10 12:12:12
- if(val.length==14){
- this.value = val.substr(0,4)+'-'+ val.substr(4,2) +'-'+ val.substr(6,2) + ' ' + val.substr(8,2) + ':'+ val.substr(10,2)+":"+ val.substr(12,2);
- }
-
- if(!FWdatetime(this)) {
- return false;
- }
- var msg = FWelementValidate(this);
- if(msg!=null){
- FWvalidateTip(this,msg);
- } else {
- $(this).qtip("destroy");
- }
- });
- }
- /**
- * 初始化时间控件
- * @param obj
- */
- function FWinitTimeBox(obj){
- jQuery(obj).bind('keydown',function(event){
-
- if(FWenterToTab(event)){
- return true;
- }
- if (event.keyCode == 186) { // :
- return true;
- }
- if(FWNumOnly(event)){
- return true;
- }
- return false;
- });
-
- jQuery(obj).bind('blur',function(){
- var val = this.value;
- //若为只读则不往下执行
- if(jQuery(this).attr("readOnly")){return true;}
-
- //用户只录入录120505
- if(val.length==6){
- this.value=val.substr(0,2)+':'+ val.substr(2,2) + ':'+ val.substr(4,2);
- }
- //用户只录入1205 改成
- if(val.length==4){
- this.value=val.substr(0,2)+':'+ val.substr(2,2) + ':00';
- }
-
- if(!FWtimebox(this)){
- return;
- }
-
- var msg = FWelementValidate(this);
- if(msg!=null){
- FWvalidateTip(this,msg);
- } else {
- $(this).qtip("destroy");
- }
-
- });
- }
- /**
- * 初始化只能录入中文控件
- * @param obj
- */
- function FWinitChinessBox(obj){
-
- jQuery(obj).bind('keydown',function(event){
- if(FWenterToTab(event)){
- return true;
- }
- return true;
- });
-
- jQuery(obj).bind('blur',function(){
- //若为只读则不往下执行
- if(jQuery(this).attr("readOnly")){return true;}
-
- if(!FWchiness(this)){
- return ;
- }
-
- var msg = FWelementValidate(this);
- if(msg!=null){
- FWvalidateTip(this,msg);
- } else {
- $(this).qtip("destroy");
- }
- });
- }
- /**
- * 初始化银行账号
- * @param obj
- */
- function FWInitBankaccount(obj){
- var val=obj.value;
- var temp='';
- val=val.replace(/\s+/g,"");
- for(var i=0;i<val.length;i++){
- if(i>0 && i%4==0){
- temp+=" ";
- }
- temp += val.substr (i,1);
- }
- obj.value=temp;
- jQuery(obj).bind('keydown',function(event){
- if(FWenterToTab(event)){
- return true;
- }
- switch(event.keyCode){
- case 189:// -
- case 109:// -(小键盘)
- case 35:// (End)
- case 36:// (Home)
- case 37://< (Left)
- case 39://> (Right)
- return true;
- default:
- return FWNumOnly(event);
- }
- return false;
- });
-
-
- jQuery(obj).bind('blur',function(){
- //若为只读则不往下执行
- if(jQuery(this).attr("readOnly")){return true;}
- if(obj.value==""){
- if( -1 != obj.name.indexOf("_HID_") ){
- var name=obj.name.substr( obj.name.indexOf("_HID_")+5);
- jQuery(':input[name="'+name+'"]').val('');
- }
- return true;
- }
- var val=obj.value;
- var temp='';
- val=val.replace(/\s+/g,"");
- for(var i=0;i<val.length;i++){
- if(i>0 && i%4==0){
- temp+=" ";
- }
- temp += val.substr (i,1);
- }
- obj.value=temp;
- if( -1 != obj.name.indexOf("_HID_") ){
- var name=obj.name.substr( obj.name.indexOf("_HID_")+5);
-
- jQuery(':input[name="'+name+'"]').val(val);
- }
-
- });
- }
- /**
- * 初始化录入年月控件
- * @param obj
- */
- function FWinitYearmonthBox(obj){
- jQuery(obj).bind('keydown',function(event){
- if(FWenterToTab(event)){
- return true;
- }
-
- //小键盘的数字区
- if(event.keyCode >= 96 && event.keyCode <= 105){
- return true;
- }
-
- //王码五笔字形无法录入数字的问题
- if(event.keyCode==229){
- return true;
- }
-
- if(event.keyCode >= 48 && event.keyCode <= 57 && event.ctrlKey == false && event.shiftKey == false){
- /* 解决当值在选中的状态下时输入数字会输入到前边 20110628 herong
- str = this.value;
- iLen = str.length;
- if(iLen>=6){
- this.value = str.substr(0,5);
- } */
- return true;
- }
- return false;
- });
-
- jQuery(obj).bind('blur',function(){
- //若为只读则不往下执行
- if(jQuery(this).attr("readOnly")){return true;}
-
- if(!FWyearmonth(this)) {
- return;
- }
- var msg = FWelementValidate(this);
- if(msg!=null){
- FWvalidateTip(this,msg);
- } else {
- $(this).qtip("destroy");
- }
- });
- }
- /**
- * 初始化邮编控件
- * @param obj
- */
- function FWinitPostBox(obj){
- jQuery(obj).bind('keydown',function(event){
-
- if(FWenterToTab(event)){
- return true;
- }
-
- //王码五笔字形无法录入数字的问题
- if(event.keyCode==229){
- return true;
- }
-
-
- //小键盘的数字区
- if(event.keyCode >= 96 && event.keyCode <= 105){
- return true;
- }
-
- if(event.keyCode >= 48 && event.keyCode <= 57 && event.ctrlKey == false && event.shiftKey == false) {
-
- str = this.value;
- iLen = str.length;
-
- if(iLen>=6){
- this.value = str.substr(0,5);
- }
- return true;
- }
- return false;
- });
-
- jQuery(obj).bind('blur',function(){
- //若为只读则不往下执行
- if(jQuery(this).attr("readOnly")){return true;}
-
- var msg = FWelementValidate(this);
- if(msg!=null){
- FWvalidateTip(this,msg);
- } else {
- $(this).qtip("destroy");
- }
- });
- }
- /**
- * 初始化电话控件
- * @param obj
- */
- function FWinitPhoneBox(obj){
-
- jQuery(obj).bind('keydown',function(event){
-
- if(FWenterToTab(event)){
- return true;
- }
- if(event.keyCode == 189){//-
- return true;
- }
-
- if(event.shiftKey==true && (event.keyCode==48||event.keyCode == 57)){//()
- return true;
- }
-
- if(FWNumOnly(event)){
- return true;
- }
-
- return false;
- });
-
- jQuery(obj).bind('blur',function(){
- //若为只读则不往下执行
- if(jQuery(this).attr("readOnly")){return true;}
-
- var msg = FWelementValidate(this);
- if(msg!=null){
- FWvalidateTip(this,msg);
- } else {
- $(this).qtip("destroy");
- }
- });
- }
- /**
- * 初始化不可粘贴控件
- * @param obj
- */
- function FWinitNotpasteBox(obj){
-
- jQuery(obj).bind('paste',function(event){
- return false;
- });
-
- jQuery(obj).bind('contextmenu',function(event){
- return false;
- });
-
- jQuery(obj).bind('keydown',function(event){
- if(FWenterToTab(event)){
- return true;
- }
- return true;
- });
- }
-
- /**
- * 证件类型的处理 选择了证件类型为身份证号码后,录入的证件号码
- * @param parentOBJ
- * @param childOBJ
- * 必须能校验
- */
- function FWzjlx(parentOBJ,childOBJ){
-
- var child = jQuery(childOBJ).attr("name");
- var parent = jQuery(parentOBJ).attr("name");
-
- jQuery(childOBJ).attr("pn",parent);
- jQuery(parentOBJ).attr("cn",child);
-
- jQuery(childOBJ).unbind('keydown');
-
- jQuery(childOBJ).bind('keydown',function(event){
-
- if(FWenterToTab(event)){
- return true;
- }
-
- if(parentOBJ.value=='6'){//为身份证号码
-
- if(event.keyCode == 88){//X
- return true;
- } //只能录入数字
-
- if(FWNumOnly(event)){
- return true;
- }
- return false;
- }
-
- return true;
- });
-
- //焦点失去事件
- jQuery(childOBJ).bind('blur',function(){
- if(parentOBJ.value=='6'){//为身份证号码
- FWidcard(this);
- }
- });
-
- }
- /**
- * 响应数据装载事件
- * @param ListID
- * @param FunName
- * @returns {Boolean}
- */
- function FWonListLoad(ListID,FunName){
- var target = eval('document.all.'+ListID);
- var opts = null;
- if(jQuery.data(target, 'fwdatagrid')!=null){
- opts = jQuery.data(target, 'fwdatagrid').options;
- }else{
- opts = jQuery.data(target, 'fweditgrid').options;
- }
- var fun = window[FunName];
- opts.onLoadSuccess = fun;
- return true;
- }
- /**
- * 响应单记录表双击事件
- * @param ListID
- * @param FunName
- * @returns {Boolean}
- */
- function FWonDblClickListRow(ListID,FunName){
- var target = eval('document.all.'+ListID);
- var opts = jQuery.data(target, 'fwdatagrid').options;
- var fun = window[FunName];
- opts.onDblClickRow = fun;
- return true;
- }
- /**
- * 响应多记录表单击事件
- * @param ListID
- * @param FunName
- * @returns {Boolean}
- */
- function FWonClickListRow(ListID,FunName){
- var target = eval('document.all.'+ListID);
- var opts = jQuery.data(target, 'fwdatagrid').options;
- var fun = window[FunName];
- opts.onClickRow = fun;
- return true;
- }
- /**
- * 重新装载数据
- * @param ListID
- * @param Where
- * @param pageNum 为刷新列表后显示第几页的数据,-1表示当前页,默认为1
- * @returns {Boolean}
- */
- function FWgetListData(ListID,Where,pageNum){
- var target = eval('document.all.'+ListID);
- var opts ;
-
- if(jQuery.data(target, 'fwdatagrid')!=null){
- opts = jQuery.data(target, 'fwdatagrid').options;
- opts.ReGetListData(target,Where,pageNum);
- return true;
- }
-
- if(jQuery.data(target, 'fweditgrid')!=null){
- opts = jQuery.data(target, 'fweditgrid').options;
- opts.ReGetListData(target,Where,pageNum);
- return true;
- }
-
- return true;
- }
- /**
- * form内部控件的设置和获取
- * 从html的form里面提取控件的值,用object表示,属性名是控件的名称,属性值是控件的值。
- * 如果form里面有重名控件,那么属性值是个数组。另外,checkbox和可以多选的下拉列表的值
- * 总是数组。
- */
- function FWGetForm(form){
- //先取有效的只
- var array = $(form).serializeArray();
- var rst = {};
- //重复的组织成数组
- $.each(array,function(index,element){
- if(typeof rst[element.name] !='undefined'){
- try{//加入数组
- rst[element.name].push(element.value);
- }catch(e){//合并
- rst[element.name]=[rst[element.name],element.value];
- }
- }else{
- rst[element.name]=element.value;
- }
- });
- //如果是字典项,添加字典项的中文在这个form里面
- $('.combobox,.incombox,.dbcombox,.ldcombox',form).each(function(){
- //看看这个控件的代码是否已在GetForm的取值范围内,如果是才取对应的中文值
- var name = this.name;
- if(rst[name]==null){
- return ;
- }
- //取对应的值
- var textValue = $(this).fwcombox('text');
- var textName = '_DIC_'+name;
- //表单中是否已经存在
- if(rst[textName]==null){
- //还没有则直接赋值
- rst[textName]= textValue;
- }else if(!jQuery.isArray(rst[textName])){
- //变成数组处理
- rst[textName]=[rst[textName],textValue];
- }else{
- //已经是数组的话,直接push即可
- rst[textName].push(textValue);
- }
- });
- $('.searchgridbox',form).each(function(){
- //看看这个控件的代码是否已在GetForm的取值范围内,如果是才取对应的中文值
- var name = this.name;
- if(rst[name]==null){
- return ;
- }
- //取对应的值
- var textValue = $(this).searchgrid('text');
- var textName = '_DIC_'+name;
- //表单中是否已经存在
- if(rst[textName]==null){
- //还没有则直接赋值
- rst[textName]= textValue;
- }else if(!jQuery.isArray(rst[textName])){
- //变成数组处理
- rst[textName]=[rst[textName],textValue];
- }else{
- //已经是数组的话,直接push即可
- rst[textName].push(textValue);
- }
- });
- //找出表单中所有的可能为数组的名称串
- if(rst['_multiple']){
- var _multiple =rst['_multiple'];
- if(typeof _multiple =='string'){
- _multiple=[_multiple];
- }
- _multiple=_multiple.join(',').split(',');
- //遍历所有可能多值的对象,全部封装成数组
- for(i in _multiple){
- var v=rst[_multiple[i]];
- if(typeof v=='string'){
- rst[_multiple[i]]=[v];
- }
- //如果是字典项,特殊处理
- v=rst['_DIC_'+_multiple[i]];
- if(typeof v=='string'){
- rst['_DIC_'+_multiple[i]]=[v];
- }
- }
- }
-
- return rst;
- }
- /**
- * 设置表单的值
- * 与FWGetForm相对应,values是一个object
- */
- function FWSetForm(form,values){
- var formName = form.name;
- var target;
- for(key in values){
- target = null;
-
- try{
- target = $('[name="'+key+'"]',form).get(0);
- }catch(e){
- target = null;
- }
-
- try{
-
- if(jQuery.data(target,"fwcombox")!=null){
- FWsetCombVal(target,values[key]);
- }else if(jQuery(target).hasClass("searchgridbox")){
- //05q,05p特殊处理
- //看看有没有字典项_DIC_如果有自动设置
- //先判断是否为空
- if(values[key]===null||typeof values[key]=='undefined'){
- target.value='';
- }else{
- target.value= values[key];
- }
- if(values['_DIC_'+key]){
- //有就拿里面的值
- jQuery(target).searchgrid('text',values['_DIC_'+key]);
- }else{
- if(null !=FW_JS_05Q_SETFORM_ASYN && "true" === (FW_JS_05Q_SETFORM_ASYN).toLowerCase()){
- //没有中文值就从数据库获取中文值
- $(target).searchgrid('setTextById',values[key]);
- }else{;
- //没有中文值就直接设置为空
- $(target).searchgrid('text','');
- }
- }
- }else if(jQuery(target).hasClass('datebox')){
- var val = values[key]+'';
- val = val.replace(/,/g,'');
- if(val.length==10){
- target.value = val;
- }else if(val.length==8){
- target.value = val.substr(0,4)+'-'+ val.substr(4,2) +'-'+ val.substr(6,2);
- } else {
- target.value = "";
- }
- }else if(jQuery(target).hasClass('datetime')){
- var val = values[key]+'';
- val = val.replace(/,/g,'');
- if(val.length==19){
- target.value = val;
- }else if(val.length==14){
- target.value = val.substr(0,4)+'-'+ val.substr(4,2) +'-'+ val.substr(6,2) + ' ' + val.substr(8,2) + ':'+ val.substr(10,2)+":"+ val.substr(12,2);
- } else {
- target.value = "";
- }
- }else if(jQuery(target).hasClass('bankaccounthid')){
- var val= values[key]+'';
- var temp='';
- val=val.replace(/\s+/g,"");
- for(var i=0;i<val.length;i++){
- if(i>0 && i%4==0){
- temp+=" ";
- }
- temp += val.substr (i,1);
- }
- target.value=val;
- var name='_HID_'+key;
- jQuery(':input[name="'+name+'"]',form).val(temp);
- }
- else{
- if(values[key]==null){
- jQuery(':input[name="'+key+'"]',form).val('');
- }else{
- jQuery(':input[name="'+key+'"]',form).val(values[key]);
- }
-
- }
- }catch(e){}
-
- }
-
- }
- /**
- *
- * @param obj 下拉框对象
- * @param val 值
- * 功能说明:因为下拉框经过封装,在JS脚本内赋值给下拉框时,下拉框会没有反应,
- * 需要调用此函数来赋值
- */
- function FWsetCombVal(combox,val){
- if(jQuery(combox).attr("tagName")=="SELECT"){
- //尚未初始化就直接赋值
- if(jQuery.data(combox, 'fwcombox')!=null){
- var opts = jQuery.data(combox, 'fwcombox').options;
- var oldVal = combox.value;
- opts.setValue(combox,val);
- if(val!=oldVal){
- $(combox).trigger('change');
- }
- }else{
- combox.value = val;
- }
- }else if($(combox).hasClass('searchgridbox')){
- $(combox).searchgrid('setTextById',val);
- }
- }
- /**
- * @param combox
- * @param val
- * 功能说明:删掉下拉框内的值,特别说明此函数不会删除IE自带的SELECT框内的值
- * 此函数配合 filter 一起使用
- * e.g:
- * FWremoveItem(document.qForm.ROLETYPE,'11');
- *
- * or
- * 删除多个
- * FWremoveItem(document.qForm.ROLETYPE,['11','12']);
- *
- */
- function FWremoveItem(combox,val){
- if(jQuery(combox).attr("tagName")=="SELECT"){
- if(jQuery.data(combox, 'fwcombox')!=null){
- var opts = jQuery.data(combox, 'fwcombox').options;
- if ( typeof val == 'string') {
- opts.removeItem(combox,val);
- } else {//数组
- $.each(val,function(i,o){
- opts.removeItem(combox,o);
- });
- }
-
- }
- }
- }
- jQuery(':input').live('keydown',function(event){
- if(this.readOnly!=true){
- return true;
- }else if(event.keyCode==8){
- //屏蔽只读输入框的backspace按键
- return false;
- }
- }).live('dblclick',function(){
- //只读采用双击拷贝内容
- window.clipboardData.setData('Text',this.value);
- });
- /**
- * 重新调整网页指定节点(注意,必须是dom对象)里面所有控件(比如:form表单、div等)的大小
- * @param parentObj 网页任意节点对象
- */
- function FWresizeObject(parentObj){
- //查找节点对象里面的所有需要重新调整的节点
- $('.fwresize',parentObj).trigger('fwresize');
- }
- /**
- * 更改form表单输入域js校验规则
- * e.g:
- * FWchangeVldStr(iForm,['XM'],'nn');
- * FWchangeVldStr(iForm,['XM','XB'],'nn');
- *
- * @param formName form表单对象
- * @param fields 输入域名 数组, 如: ['XM','XB']
- * @param vldStr 校验串 ,如: 'nn'
- */
- function FWchangeVldStr(formName,fields,vldStr) {
- var theForm = $(formName);
- $.each(fields, function(i, o) {
- var flag = false;
- var label = $("[name='" + o + "']", theForm).closest('td').prev().css("color","black");
- if(vldStr != null && $.trim(vldStr) != ''){//只要vldstr不为空flag为true
- if( vldStr.indexOf('nn') >= 0){//包含非空必录
- label.css("color","blue");
- }
- if(vldStr.indexOf('sn') >= 0){//包含基础查询条件
- label.css("color","#be0101");
- }
- flag = true;
- }
-
- var msg = label.text();
- //此处对05q控件进行特殊处理,需改变05q的文本行的vldStr
- if($("[name='" + o + "']", theForm).hasClass('searchgridbox')){
- $("[name='" + o + "']", theForm).next(" .searchgrid-text").get(0).vldStr = !flag ? '' : msg + "=" + vldStr;
- }else{
- $("[name='" + o + "']", theForm).get(0).vldStr = !flag ? '' : msg + "=" + vldStr;
- }
-
- });
- }
-
- $('input,textarea').live('focus',function(){
- //$(this).addClass('focus'); 目前暂时采用这种方式
- if($(this).hasClass('readOnly')){
- return true;
- }
- if(this.type=='checkbox'){
- return true;
- }
- var tmp = $(this).css("background-color");
- $(this).attr("_color",tmp);
- $(this).css("background-color","#FDFDBD");
- }).live('blur',function(){
- //$(this).removeClass('focus');
- //应用remove 这种方式会导致焦点移开后录入框撑大
- if($(this).hasClass('readOnly')){
- return true;
- }
- if(this.type=='checkbox'){
- return true;
- }
- var tmp = $(this).attr("_color");
- if(tmp=='#fdfdbd'){
- $(this).css("background-color",'white');
- }else{
- $(this).css("background-color",tmp);
- }
- });
- /**
- * 获取存储大字典所用的APPLET
- * @returns applet对象
- */
- function FWGetDictApplet(){
- var twindow = window;
- while(twindow.dialogArguments!=null || twindow.opener != null){
- while(twindow.dialogArguments!=null){
- if(_isWindow(twindow.dialogArguments)){
- twindow = twindow.dialogArguments;
- }else if(_isWindow(twindow.dialogArguments.window)){
- twindow = twindow.dialogArguments.window;
- }
- }
- while(twindow.opener != null){
- twindow = twindow.opener;
- }
- }
- var tapplet;
- var sortStr = "";
- try {
- var isSsoEnalbeStr = "false";
- if (typeof(ssoDictName) !='undefined') {
- sortStr = ssoDictName;
- }
-
- if (typeof(isSsoEnable) !='undefined') {
- isSsoEnalbeStr = isSsoEnable;
- }
- if ('true' == isSsoEnalbeStr && !isNull(sortStr)) {
- tapplet = twindow.top.frames[sortStr].dictapplet;
- } else {
- tapplet = twindow.top.frames['TreeMenu'].dictapplet;
- }
- } catch (Ex) {
- try {
- if (!isNull(sortStr)) {
- tapplet = twindow.top.frames[sortStr].dictapplet;
- } else {
- FWalert("未设置SSO_SUBSYS_URL字典!");
- return ;
- }
- } catch (Ex2) {
- FWalert(Ex2.message);
- return ;
- }
-
- }
- return tapplet;
-
-
- function _isWindow(obj){
- return obj && typeof obj === "object" && "setInterval" in obj;
- }
- }
-
- /**
- *多记录表单拉伸列宽
- */
- function FWMouseDownToResize(obj,tableID){
- if($(obj).closest('th')[0]['sortable']!='true'){
- return;
- }
- var theObjTable = document.getElementById(tableID);
- FWsetTableLayoutToFixed(tableID);
- obj.mouseDownX=event.clientX;
- obj.pareneTdW=obj.parentElement.offsetWidth;
- obj.pareneTableW=theObjTable.offsetWidth;
- obj.setCapture();
- }
- /**
- *多记录表单拉伸列宽
- */
- function FWMouseMoveToResize(obj,tableID){
- if($(obj).closest('th')[0]['sortable']!='true'){
- return;
- }
- if(!obj.mouseDownX) return false;
- var newWidth=obj.pareneTdW*1+event.clientX*1-obj.mouseDownX;
- if(newWidth>10){
- var theObjTable = document.getElementById(tableID);
- obj.parentElement.style.width = newWidth;
- theObjTable.style.width=obj.pareneTdW*1+event.clientX*1-obj.mouseDownX;
- }
- //处理拉伸列宽时不进行排序
- $(obj).attr('_m',true);
- }
- /**
- *多记录表单拉伸列宽
- */
- function FWMouseUpToResize(obj){
- if($(obj).closest('th')[0]['sortable']!='true'){
- return;
- }
- obj.releaseCapture();
- obj.mouseDownX=0;
- }
- /**
- *多记录表单拉伸列宽
- */
- function FWsetTableLayoutToFixed(tableID){
- var theObjTable = document.getElementById(tableID);
- if(theObjTable.style.tableLayout=='fixed') return;
- var headerTr=theObjTable.rows[0];
- if(headerTr.className=='fweditgrid-header-group'||
- headerTr.className=='fwdatagrid-header-group'){
- return true;
- }
- var height = $(headerTr.cells[0]).height();
- for(var i=0;i<headerTr.cells.length;i++){
- headerTr.cells[i].styleOffsetWidth=headerTr.cells[i].offsetWidth;
- }
-
- for(var i=0;i<headerTr.cells.length;i++){
- headerTr.cells[i].style.width=headerTr.cells[i].styleOffsetWidth;
- $(headerTr.cells[i]).height(height);
- }
- theObjTable.style.tableLayout='fixed';
-
- }
-
- /**
- * add by liujun(2013.4.7)
- * 取查询条件表单的中文条件,用于导出Excel表头条件行使用
- * @param idStr 查询条件表单Form的ID
- * @returns 生成的中文条件
- */
- function FWGetGtZwWhereCls(idStr) {
- var strWhere = "";
- var myobj = $('form[name='+ idStr+"]");
- var array = FWGetForm(myobj.get(0));
-
- $.each(array,function(name,value){
- if(value!=null && value!=""){
- try{
- if(name.indexOf('_DIC')>=0) return true;
- if($('[name="'+name+'"]').attr("type") == "hidden") return true;
- if(typeof array['_DIC_'+name] !='undefined'){
- //字典
- var label = $("[name='" + name + "']", myobj).closest('td').prev().get(0).innerText;
- value = array['_DIC_'+name];
- }else{
- var label = $("[name='" + name + "']", myobj).closest('td').prev().get(0).innerText;
- }
- strWhere += label + ":" + value + " ";
- }catch(e){
- //获取label出错,不作处理
- }
- }
- });
- return strWhere;
- }
-
- /**
- * add by liujun(2013.4.7)
- * 保存查询条件与查询结果表单的关联关系,用于导出Excel表头条件行时使用
- * @param gltid 查询结果的表单ID
- * @param gtid 查询条件的表单ID
- * @returns true:设置成功,false:设置失败
- */
- function FWSaveGtGltRelation(gltid, gtid) {
- var target = eval('document.all.' + gltid);
- var opts;
- if (jQuery.data(target, 'fwdatagrid') != null) {
- opts = jQuery.data(target, 'fwdatagrid').options;
- opts["_gtid"] = gtid;
- return true;
- }
- return false;
- }
-
|