Index: ssts-web/src/main/webapp/ext/js/common.js =================================================================== diff -u -r13718 -r22204 --- ssts-web/src/main/webapp/ext/js/common.js (.../common.js) (revision 13718) +++ ssts-web/src/main/webapp/ext/js/common.js (.../common.js) (revision 22204) @@ -1,5 +1,6 @@ -Ext.BLANK_IMAGE_URL = WWWROOT+'/ext/resources/images/default/s.gif'; - +if (typeof(Ext) != 'undefined'){ + Ext.BLANK_IMAGE_URL = WWWROOT+'/ext/resources/images/default/s.gif'; +} function focusExtJSField(field){ if (field.isVisible(true) == true){ field.focus(); @@ -66,19 +67,20 @@ Ext.getCmp('mainlayout').load(WWWROOT+url); } -Ext.apply(Ext.form.VTypes, { - serialNumber :function(val, field){ - var certificateNameNumberExp = /^\d+[a-zA-Z]\d+$/; - if(certificateNameNumberExp.test(val)){ - return true; - } - return false; - }, - serialNumberText :'编号不规范!正确格式[数字+一个字母+数字]' +if (typeof(Ext) != 'undefined'){ + Ext.apply(Ext.form.VTypes, { + serialNumber :function(val, field){ + var certificateNameNumberExp = /^\d+[a-zA-Z]\d+$/; + if(certificateNameNumberExp.test(val)){ + return true; + } + return false; + }, + serialNumberText :'编号不规范!正确格式[数字+一个字母+数字]' -}); + }); +} - var FormUtils = { setReadOnly : function(form, isReadOnly) { if(typeof form == 'string') { @@ -191,151 +193,154 @@ } }; -Ext.namespace('Ext.ux.util.Format'); -Ext.ux.util.Format = function(){ - var trimRe = /^\s+|\s+$/g; - return { - usMoney : function(v, prefix){ - if(prefix==null){ - prefix = '¥'; - } - v = (Math.round((v-0)*100))/100; - v = (v == Math.floor(v)) ? v + ".00" : ((v*10 == Math.floor(v*10)) ? v + "0" : v); - v = String(v); - var ps = v.split('.'); - var whole = ps[0]; - var sub = ps[1] ? '.'+ ps[1] : '.00'; - var r = /(\d+)(\d{3})/; - while (r.test(whole)) { - whole = whole.replace(r, '$1' + ',' + '$2'); - } - v = whole + sub; - if(v.charAt(0) == '-'){ - return '-' + prefix + v.substr(1); - } +if (typeof(Ext) != 'undefined'){ + Ext.namespace('Ext.ux.util.Format'); + Ext.ux.util.Format = function(){ + var trimRe = /^\s+|\s+$/g; + return { + usMoney : function(v, prefix){ + if(prefix==null){ + prefix = '¥'; + } + v = (Math.round((v-0)*100))/100; + v = (v == Math.floor(v)) ? v + ".00" : ((v*10 == Math.floor(v*10)) ? v + "0" : v); + v = String(v); + var ps = v.split('.'); + var whole = ps[0]; + var sub = ps[1] ? '.'+ ps[1] : '.00'; + var r = /(\d+)(\d{3})/; + while (r.test(whole)) { + whole = whole.replace(r, '$1' + ',' + '$2'); + } + v = whole + sub; + if(v.charAt(0) == '-'){ + return '-' + prefix + v.substr(1); + } - return prefix + v; - } - }; -}(); + return prefix + v; + } + }; + }(); +} - function formatMoneyUtil(v, prefix){ return Ext.ux.util.Format(); } -Ext.override(Ext.grid.EditorGridPanel, { - isCellValid:function(col, row) { - if(!this.colModel.isCellEditable(col, row)) { - return true; - } - - var ed = this.colModel.getCellEditor(col, row); - if(!ed) { - return true; - } - - var record = this.store.getAt(row); - - if(!record) { - return true; - } - - var field = this.colModel.getDataIndex(col); - ed.field.setValue(record.data[field]); - return ed.field.isValid(true); - }, - - isValid:function(editInvalid) { - var cols = this.colModel.getColumnCount(); - var rows = this.store.getCount(); - var r, c; - var valid = true; - for(r = 0; r < rows; r++) { - for(c = 0; c < cols; c++) { - valid = this.isCellValid(c, r); - if(!valid) { - break; - } - } - - if(!valid) { - break; - } - } - - if(editInvalid && !valid) { - this.startEditing(r, c); - } - - return valid; - }, - - setEditable : function(editable){ - var cols = this.colModel.getColumnCount(); - for(c = 0; c < cols; c++) { - if(this.colModel.getCellEditor(c, 0) != null){ - this.colModel.setEditable(c, editable); - } - } - - var topToolbar = this.getTopToolbar(); - if(topToolbar){ - topToolbar.setVisible(editable); - } - - - if(editable){ - this.getView().refresh(false); - } - } -}); - -Ext.override(Ext.form.BasicForm, { - setValues : function(values){ - if(Ext.isArray(values)){ // array of objects - for(var i = 0, len = values.length; i < len; i++){ - var v = values[i]; - var f = this.findField(v.id); - if(f){ - f.setValue(v.value); - if(this.trackResetOnLoad){ - f.originalValue = f.getValue(); - } - } - } - }else{ // object hash - var field, id; - - for(id in values){ - //alert(id + "=" +values[id].length); - - if((typeof values[id] != 'function') && (field = this.findField(id))){ - field.setValue(values[id]); +if (typeof(Ext) != 'undefined'){ + Ext.override(Ext.grid.EditorGridPanel, { + isCellValid:function(col, row) { + if(!this.colModel.isCellEditable(col, row)) { + return true; + } + + var ed = this.colModel.getCellEditor(col, row); + if(!ed) { + return true; + } + + var record = this.store.getAt(row); + + if(!record) { + return true; + } + + var field = this.colModel.getDataIndex(col); + ed.field.setValue(record.data[field]); + return ed.field.isValid(true); + }, + + isValid:function(editInvalid) { + var cols = this.colModel.getColumnCount(); + var rows = this.store.getCount(); + var r, c; + var valid = true; + for(r = 0; r < rows; r++) { + for(c = 0; c < cols; c++) { + valid = this.isCellValid(c, r); + if(!valid) { + break; + } + } + + if(!valid) { + break; + } + } + + if(editInvalid && !valid) { + this.startEditing(r, c); + } + + return valid; + }, + + setEditable : function(editable){ + var cols = this.colModel.getColumnCount(); + for(c = 0; c < cols; c++) { + if(this.colModel.getCellEditor(c, 0) != null){ + this.colModel.setEditable(c, editable); + } + } + + var topToolbar = this.getTopToolbar(); + if(topToolbar){ + topToolbar.setVisible(editable); + } + + + if(editable){ + this.getView().refresh(false); + } + } + }); + + Ext.override(Ext.form.BasicForm, { + setValues : function(values){ + if(Ext.isArray(values)){ // array of objects + for(var i = 0, len = values.length; i < len; i++){ + var v = values[i]; + var f = this.findField(v.id); + if(f){ + f.setValue(v.value); if(this.trackResetOnLoad){ - field.originalValue = field.getValue(); + f.originalValue = f.getValue(); } - }else if((typeof values[id] != 'function') &&(typeof values[id] == 'object') && !(field = this.findField(id))){ - //如果是对象,则遍历该对象的属性设置(只遍历一层) - var currentObject = values[id]; - var parentPname = id; - for(cid in currentObject){ - if((typeof currentObject[cid] != 'function') &&(typeof currentObject[cid] != 'object')){ - var cf = parentPname+'.'+cid; - if( field = this.findField(cf)){ - field.setValue(currentObject[cid]); - if(this.trackResetOnLoad){ - field.originalValue = field.getValue(); - } + } + } + }else{ // object hash + var field, id; + + for(id in values){ + //alert(id + "=" +values[id].length); + + if((typeof values[id] != 'function') && (field = this.findField(id))){ + field.setValue(values[id]); + if(this.trackResetOnLoad){ + field.originalValue = field.getValue(); + } + }else if((typeof values[id] != 'function') &&(typeof values[id] == 'object') && !(field = this.findField(id))){ + //如果是对象,则遍历该对象的属性设置(只遍历一层) + var currentObject = values[id]; + var parentPname = id; + for(cid in currentObject){ + if((typeof currentObject[cid] != 'function') &&(typeof currentObject[cid] != 'object')){ + var cf = parentPname+'.'+cid; + if( field = this.findField(cf)){ + field.setValue(currentObject[cid]); + if(this.trackResetOnLoad){ + field.originalValue = field.getValue(); + } + } + } } - } - } - } - } - } - return this; - } -}); + } + } + } + return this; + } + }); +} function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i