最先讲解全局方法,因为在后续的讲解中会常用。
Config.js : 全局变量 cfg ,系统的基础配置变量 systemname(系统名称) 、sub(登录人员信息)、language(语言)、theme(主题风格)、crossdomain(是否跨域)。
CommonUtils.js : 全局变量 CU,js中辅组类,主要方法有getUUID 、 getBoolean、getRandomColor、getDate、getBeforeDateString 。
Loader.js :全局变量 Loader,JS、CSS加载器 ,使用 Loader.request(url); 即可加载需要的js或css。
localStorage.js :全局变量 local,项目永久存储信息服务类。 因为 localStorage只能存储字符串。此类把对象转字符串存储和根据key取数据为对象。
sessionStorage.js : 全局变量 session,项目临时存储信息,浏览器关闭自动清除。使用方式,session.get(key); session.set(key,object);
ExtUtils.js : 全局变量 EU ,ext服务类,主要方法:redirectTo(全局路由) 、toastInfo(系统提醒)、RS(数据交互ajax、jsonp)、RSView(试图读取,包含缓存机制)
ProjectUtils.js :全局变量 PU ,框架服务类,主要方法:openTabModule(在框架中tabPanel增加tab页签)、openModule(系统弹出窗口)、openAttachWindow(附件上传/下载组件) download(文件下载)
全局变量
Ext.Viewport 主窗口ViewporExt.FramePanel
Ext.FramePanel 业务Panel面板
Ext.lockPanel 锁屏Panel面板
Ext.SystemTabPanel 当前业务Panel面板中TabPanel对象
Ext.SystemTabPanelAutoOpens 当前业务Panel面板中TabPanel对象自动打开菜单窗口Map对象{menuid:obj} //系统菜单加载时候提取数据
Ext.SystemFavorites 我的收藏菜单Map对象{menuid:obj} //系统菜单加载时候提取数据
Ext.SystemLimits 我的界面权限Map对象 //执行PU.openTabModule时候创建新的tab,判断当前界面modelurl在SystemLimits是否存在,如果没有且加载并且保存在SystemLimits中
/**
* 辅组方法
*/
Ext.define('app.utils.ExtUtils', {
alternateClassName: 'EU',
statics: {
redirectTo :function(xtype){
Ext.Panel.redirectTo(xtype);
},
toastInfo : function( text, config){
var param = {title : '提示信息',html : text,border : true,saveDelay : 10,align : 'tr',closable : true,minWidth : 200,useXAxis : false,slideInDuration : 800,slideBackDuration : 1500,iconCls : 'ux-notification-icon-smile',autoCloseDelay : 4000,slideInAnimation : 'elasticIn',slideBackAnimation : 'elasticIn'};
Ext.apply(param, config);Ext.toast(param);
},
toastWarn :function(text, config){
var param = {title : '警告信息',html : text,border : true,saveDelay : 10,align : 'tr',closable : true,minWidth : 200,useXAxis : false,slideInDuration : 800,slideBackDuration : 1500,iconCls : 'ux-notification-icon-warn',autoCloseDelay : 4000,slideInAnimation : 'elasticIn',slideBackAnimation : 'elasticIn'};
Ext.apply(param, config);
Ext.toast(param);
},
toastErrorInfo :function(text, config){
var param = {title : '错误信息',html : text,border : true,saveDelay : 10,align : 'tr',closable : true,minWidth : 200,useXAxis : false,slideInDuration : 800,slideBackDuration : 1500,iconCls : 'ux-notification-icon-error',autoCloseDelay : 5000,slideInAnimation : 'elasticIn',slideBackAnimation : 'elasticIn'};
Ext.apply(param, config);
Ext.toast(param);
},
/**
* 弹出消息框
* prompt 缺省:false true:可以输入 false不可以输入
*/
showMsg:function(config){
config = config || {};
config.title = config.title || "消息";
config.message = config.message|| config.msg || "";
config.option = config.option || -1;
config.fn = config.callback;
if (Ext.isEmpty(config.buttons)) {
switch (config.option) {
case 1 :{
config.icon = Ext.MessageBox.QUESTION;
config.buttons = Ext.MessageBox.YESNO;
break;
}
case 2 :config.buttons = Ext.MessageBox.YESNOCANCEL;break;
case 3 :config.buttons = Ext.MessageBox.OKCANCEL;break;
default :config.buttons = Ext.MessageBox.OK;break;
}
}
Ext.Msg.show(config);
},
/**
* 远程访问
* @param {} config
*/
RS:function(config){
var thiz = this;
if(config.service && config.method){
config.url = CU.getURL(config.service,config.method);
delete config.method;
}
var params = Ext.isEmpty(config.params)?{}:config.params;
for (var key in params){var data=params[key];if(Ext.isArray(data))params[key] = CU.toString(data);}//转换为spring @RequestList接受的转码格式
config.params = CU.toParams(params);//转换为spring mvc参数接受方式
config.async = Ext.isEmpty(config.async)?true:config.async; // true=异步 , false=同步
config.scope = config.scope || thiz;
config.dataType = config.dataType || "json";
config.timeout = config.timeout || 30000;
config.method = 'POST';
var msg = Ext.isEmpty(config.msg)? config.async :config.msg;
config.message = config.message || '正在访问服务器, 请稍候...';
config.target = config.target || Ext.Viewport;
thiz.myMask = null;
if (msg){
thiz.myMask = new Ext.LoadMask({msg:config.message,target:config.target,removeMask:true}); //,style:'background-color: rgba(208, 208, 208, 0.5);'
thiz.myMask.show();
}
var caller_callback = config.callback;
var caller_errorcallback = config.errorcallback;
var result = null;
var callback = function(type,scope,success,result,response, options){
if(msg)thiz.myMask.hide();
if(success){
if (Ext.isFunction(caller_callback)) {
Ext.callback(caller_callback,config.scope,[result]);
}
}else{
if(type=='json' && response.status=="999")return;
if(Ext.isFunction(caller_errorcallback)){
Ext.callback(caller_errorcallback,config.scope,[response,options]);
}else{
thiz.toastErrorInfo("访问远程服务器失败!");
}
}
}
if(cfg.crossdomain){
config.url = cfg.requestUrl + config.url;
config.callback = function(success, result,errortype) {
Ext.callback(callback,this,['jsonp',config.scope,success,result])
}
Ext.data.JsonP.request(config);
}else{
config.callback = function(options, success, response) {
var text = response.responseText;
var result = CU.toObject(text);
Ext.callback(callback,this,['json',config.scope,success,result,response,options])
};
Ext.Ajax.request(config);
}
return result;
},
/**
* 常用的view转码数据查询(带缓存机制)。
* @param {} config 对象或viewname
* @return {}
*/
RSView:function(config,callback){
var thiz = this;
if(Ext.isString(config))config = {params:{viewname:config}};
var cache = Ext.isEmpty(config.cache)?true:config.cache;//是否缓存,缺省true
var key = config.params.viewname;
var data = cache?session.get(key):null;
callback = callback || config.callback;
var scope = config.scope || thiz;
if(!Ext.isEmpty(data) && Ext.isArray(data)){
if(Ext.isFunction(callback))Ext.callback(callback,scope,[data]);
return data;
}
var url = "platform/basecode/getviewlist.do";
var params = {viewname:config.params.viewname,ids:config.ids,idfield:config.idfield,orderbyfield:config.orderbyfield};
thiz.RS({url:url,params:params,callback:function(result){
if(cache)session.set(key,result);
data = result;
if(Ext.isFunction(callback))Ext.callback(callback,scope,[data]);
}});
return data;
},
/**
* 查询配置文件列表信息
* @param {} config
* @param {} callback
* @return {}
*/
RScfgList:function(config,callback){
var params = {};
if(Ext.isString(config))config = {params:{type:config}};
config.msg = false;
config.url = "platform/systemcfg/getlist.do";
if(Ext.isFunction(callback))config.callback = callback;
return this.RS(config);
},
/**
* 获取系统配置文件信息
* @param {} config 对象或主键id
* @param {} callback
* @return {}
*/
RScfgInfo:function(config,callback){
var params = {};
if(Ext.isString(config))config = {params:{id:config}};
config.msg = false;
config.url = "platform/systemcfg/getinfo.do";
if(Ext.isFunction(callback))config.callback = callback;
return this.RS(config);
},
/**
* 删除系统配置文件信息
* @param {} config 对象或主键id
* @param {} callback
* @return {}
*/
RScfgDel:function(config,callback){
var params = {};
if(!Ext.isObject(config))config = {params:{id:config}};
config.msg = false;
config.url = "platform/systemcfg/delete.do";
if(Ext.isFunction(callback))config.callback = callback;
return this.RS(config);
},
/**
* 新增系统配置文件信息
* @param {} config
* @param {} callback
* @return {}
*/
RScfgSave:function(config,callback){
var params = {};
config.msg = false;
config.url = "platform/systemcfg/saveorupdate.do";
if(Ext.isFunction(callback))config.callback = callback;
return this.RS(config);
}
}
});
/**
* 辅组方法
*/
Ext.define('app.utils.ProjectUtils', {
alternateClassName: 'PU',
requires: [
'app.view.platform.systemattach.FileBatchUpload',
'app.view.platform.systemattach.FileBatchPreview'
],
statics: {
wins:{},
operateLimits:{},
getHeight:function(){
return Ext.FramePanel.getEl().getHeight()
},
getWidth:function(){
return Ext.FramePanel.getEl().getWidth()
},
openTabModule:function(config,tabcfg){
if(Ext.isEmpty(config.type) || config.type =='00')return;
var tabcfg = tabcfg || {}
var contentPanel = Ext.SystemTabPanel;
if(Ext.isEmpty(contentPanel) || !(contentPanel instanceof Ext.tab.Panel)){
EU.toastErrorInfo("TabPanel为空,请与管理员联系。");
return;
}
var id = config.id;
var tabPanel = contentPanel.getComponent("TAB_"+id);
if(Ext.isEmpty(tabPanel)){
if(config.type=='02'){
var html = '';
tabPanel = {id:"TAB_"+id,title:config.text,border:false,closable: true,html:html};
}else {
tabPanel = Ext.create(config.url,{id:"TAB_"+id,title:config.text,closable:true,margin: '1 0 0 0'});
}
tabPanel.menuid = id;
if(!Ext.isEmpty(config.glyph))tabPanel.glyph = config.glyph;
if(!Ext.isEmpty(config.iconCls))tabPanel.iconCls = config.iconCls;
tabPanel = contentPanel.add(tabPanel);
tabPanel.tab.setClosable(!(tabcfg.checked === false));
this.systemLimits(tabPanel);
}
return contentPanel.setActiveTab(tabPanel);
},
openModule:function(config){
var me = this;
if(Ext.isEmpty(config)){EU.toastErrorInfo("错误请求!");return;}
if(Ext.isEmpty(config.url)&&Ext.isEmpty(config.xtype)){EU.toastWarn("url和xtype不能同时为null!");return;}
config.modal = Ext.isEmpty(config.modal)?true:config.modal;
config.layout = Ext.isEmpty(config.layout)?"fit":config.layout;
var xtype = config.xtype; delete config.xtype;
var url = config.url; delete config.url;
Ext.apply(config,{maximizable: true});
var item = null;
var pscope = config.scope;
config.resizable = Ext.isEmpty(config.resizable)?false:config.resizable;
config.closable = false;
config.height = config.height>me.getHeight()?me.getHeight():config.height;
config.width = config.width>me.getWidth()?me.getWidth():config.width;
var dialog = Ext.create('Ext.window.Window',config);
if(!Ext.isEmpty(url)){
item = Ext.create("Ext.ux.IFrame",{src:url});
//item.iframeEl.dom.contentWindow = iframe对象
}else {
item = Ext.create(xtype,{params:config.params,pscope:pscope,callback:config.callback,fn:config.fn});
}
dialog.add(item);
dialog.show();
dialog.on("close",function(panel, eOpts ){delete me.wins[dialog.id];}, this);
dialog.addTool({xtype:'tool',type:'close',tooltip:'关闭窗口',scope:this,handler:function(){
if(Ext.isFunction(item.closeWindowVerify)){
item.closeWindowVerify();
}else{
dialog.close();
}
}});
me.wins[dialog.id] = dialog;
return dialog;
},
/**
* 附件上传/下载组件
* @param {} config
* @param disabeld 是否不可上传 缺省false
*
*/
openAttachWindow : function(config){
config.disabeld = Ext.isEmpty(config.disabeld)?false:config.disabeld;
config.scope = config.scope || this;
config.title = config.title || (config.disabeld?"附件预览":"附件上传");
config.modal = Ext.isEmpty(config.modal) ? true : config.modal;
if(Ext.isEmpty(config.tablename)){
EU.toastErrorInfo("参数:tablename不能为空!");return;
}else if(Ext.isEmpty(config.fieldname)){
EU.toastErrorInfo("参数:fieldname不能为空!");return;
}else if(Ext.isEmpty(config.fieldvalue)){
EU.toastErrorInfo("参数:fieldvalue不能为空!");return;
}
var xtype='FileBatchUpload',width=1000,height=600;
if(config.disabeld){width = 800;xtype = 'FileBatchPreview';}
this.openModule({xtype:xtype,title:config.title,width:width,height:height,params:config,modal:config.modal,scope:config.scope,callback:config.callback});
},
download : function(cfg,timeout){
var me = this;
var params = Ext.isEmpty(cfg.params)?{}:cfg.params;
var url = Ext.isEmpty(cfg.url)?"platform/fileattach/downloadfile.do":cfg.url;
for (var key in params){var data=params[key];if(Ext.isArray(data))params[key] = CU.toString(data);}//转换为spring @RequestList接受的转码格式
params = CU.toParams(params);//转换为spring mvc参数接受方式
url+= (url.indexOf("?")>0?"&":"?")+CU.parseParams(params);
var width = Ext.isEmpty(cfg.width)?650:cfg.width; //350
var height = Ext.isEmpty(cfg.height)?500:cfg.height; //300
var bodyWidth =Ext.getBody().getWidth()
var bodyHeight = Ext.getBody().getHeight();
var iLeft = bodyWidth/2-(width/2);
var iTop = bodyHeight/2-(height/2);
window.open(url,'fullscreen=0,menubar=0,toolbar=0,location=0,scrollbars=0,resizable=0,status=1,left='+iLeft+',top='+iTop+',width='+width+',height='+height);
if(Ext.isFunction(cfg.callback))cfg.callback();
},
/**
* 系统刷新
* @param {} xtype
*/
onAppUpdate:function(xtype){
Ext.Msg.confirm('应用更新', '应用程序有一个更新,是否重新加载界面?',
function (choice) {
if (choice === 'yes') {
if(xtype){
EU.redirectTo(xtype);
}else{
window.location.reload();
}
}
}
);
},
/**
* 退出系统
* @param {} btn
*/
onLogout:function(btn){
EU.showMsg({title:"退出系统",message:"您确定要退出吗?",animateTarget:btn,option:1,callback:function(result){
if(result != 'yes')return;
EU.RS({url:"login/logout.do",callback:function(result){
if(CU.getBoolean(result)){
session.remove("isLogin");
EU.redirectTo(cfg.xtypeLogin);
}
}});
}});
},
/**
* 获取系统全部的url连接
* @param {} callback
* @param {} scope
*/
createUrlFunction:function(systemurls){
if(Ext.isEmpty(systemurls))return;
for(key in systemurls){
var rec = systemurls[key];
if(EU[rec.beanname] == null)EU[rec.beanname] = {};
EU[rec.beanname][rec.methodname] = new Function("cfg","cfg.url='"+rec.url+"';return EU.RS(cfg);");
}
},
/**
* 系统按钮权限控制
* @param {} panel 获取reference的容器
* @param {} xtype 权限获取的父容器
*/
systemLimits:function(panel,modulurl,callback){
if(!Ext.isFunction(panel.lookupReference))return;
modulurl = modulurl || panel.$className;
var url = "platform/systemframe/getsystemlimits.do";
var operateLimits = cfg.sub.systemlimits[modulurl];
if(!Ext.isArray(operateLimits))return;
Ext.each(operateLimits,function(rec){
if(rec.islimit > 0)return;
var object = panel.lookupReference(rec.operatecode);
if(Ext.isEmpty(object))return;
object.hide();
});
if(Ext.isFunction(callback))Ext.callback(callback)
}
}
});
/**
* 辅组方法
*/
Ext.define('app.utils.CommonUtils', {
alternateClassName: 'CU',
statics: {
/**
* 获取UUID
* @param {} len
* @param {} radix
* @return {}
*/
getUUID : function(len, radix){var CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''); var chars = CHARS, uuid = [], i;radix = radix || chars.length;if (len){for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random()*radix];} else { var r; uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';uuid[14] = '4'; for (i = 0; i < 36; i++) {if (!uuid[i]) {r = 0 | Math.random()*16; uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];}}} return uuid.join(''); },
/**
* 转换为boolean类型
* @param {} v
* @return {}
*/
getBoolean : function(v){return v==true||v=='1'||v==1||v=='true'},
/**
* 数据对象转换为string值(url参数)
* @param paramsobj 数据对象{a:1,b=2}
* @return string(&a=1&b=2)
*/
parseParams:function(paramsobj){var paramsstr = "";for(var key in paramsobj) {var value = paramsobj[key];if(Ext.isEmpty(value, true)) continue;if(Ext.isArray(value)) {for(var i=0; i=1)isThousand = 1;sign = (num == (num = Math.abs(num)));num = Math.floor(num*Math.pow(10,cent)+0.50000000001);cents = num%Math.pow(10,cent);num = Math.floor(num/Math.pow(10,cent)).toString();cents = cents.toString();while(cents.length1 && countArray[i]>count){count = countArray[i];val = datas[i];}}return val;},
/**
* 获取平方差
* @param {} datas 数据数组
* @param {} format 小数位 缺省:0.00
* @return {}
*/
getS2:function(datas,format){format = format||'0.00';var m = Ext.Array.mean(datas);var val = 0,n=datas.length;for (var i = 0; i < n; i++) {var x = datas[i];val+=Math.pow(x-m,2);}return Ext.util.Format.number(val/n,format);},
/**
* 获取标准差
* @param {} datas 数据数组
* @param {} format 小数位 缺省:0.00
* @return {}
*/
getSd:function(datas,format){format = format||'0.00';var m = Ext.Array.mean(datas);var val = 0,n=datas.length;for (var i = 0; i < n; i++) {var x = datas[i];val+=Math.pow(x-m,2);}return Ext.util.Format.number(Math.sqrt(val/n),format);},
/**
* 替换字符串
* @param {} str 字符串
* @param {} s1 替换字符串
* @param {} s2 替换为
* @return {}
*/
replaceAll: function (str,s1,s2){return str.replace(new RegExp(s1,"gm"),s2);},
/**
* 获取数字型数据
* @param {} value
* @return {}
*/
getNumber:function(value){return Ext.isNumber(value)?value:isNaN(Number(value))?0:Number(value);},
/**
* 获取随机颜色
* @return {}
*/
getRandomColor : function (){return "#"+("00000"+((Math.random()*16777215+0.5)>>0).toString(16)).slice(-6);},
/**
* 获取当前客户端日期
* @return 日期格式(yyyy-MM-dd)
*/
getDate : function() {return CU.toDateString(new Date());},
/**
* 获取当前客户端时间
* @return 时间格式(yyyy-MM-dd hh:mm:ss)
*/
getTime : function() {return CU.toTimeString(new Date());},
/**
* 自动补全日期字符串格式
* @param {} value 2015=2015-01-01、2015-02 = 2015-02-01
* @return {}
*/
toDateStringSupply : function(value) {value = value+"";var length = value.length;value = length == 4 ? value += "-01-01" : length == 7? value += '-01': value;return value;},
/**
* 字符串转换为日期格式
* @param value 字符串数据(例如:2013-02-27)
* @return 日期对象
*/
toDate : function(value) {return new Date(CU.toDateStringSupply(value).replace(/-/g,"/"));},
/**
* 日期转换为字符串
* @param date 日期
* @return 字符串日期(2013-02-27)
*/
toDateString : function(date) {var y = date.getFullYear();var m = date.getMonth()+1;if(m < 10) m = "0"+m;var d = date.getDate();if(d < 10) d = "0"+d;return y+"-"+m+"-"+d;},
/**
* 日期转换为字符串
* @param date 日期
* @return 字符串时间(2013-02-27 17:10:00)
*/
toTimeString : function(date) {var y = date.getFullYear();var m = date.getMonth()+1;if(m < 10) m = "0"+m;var d = date.getDate();if(d < 10) d = "0"+d;var h = date.getHours();if(h < 10) h = "0"+h;var mi = date.getMinutes();if(mi < 10) mi = "0"+mi;var s = date.getSeconds();if(s < 10) s = "0"+s;return y+"-"+m+"-"+d+" "+h+":"+mi+":"+s;},
/**
* 获取日期差异
* @param small 开始日期long
* @param big 结束日期long
* @return 天
*/
getDateDiff : function(small, big) {return (big-small)/1000/60/60/24;},
/**
* 几天以前的日期
* @param day 天数
* @return 日期对象
*/
getBeforeDate : function(date,day) {date == date || new Date(); return new Date(date.getTime()-1000*60*60*24*day);},
/**
* 几天以前的日期
* @param day 天数
* @return 字符串(2013-02-27)
*/
getBeforeDateString : function(date,day) {var date = CU.getBeforeDate(date,day);var y = date.getFullYear();var m = date.getMonth()+1;var d = date.getDate();if(m < 10) m = "0"+m;if(d < 10) d = "0"+d;return y+"-"+m+"-"+d;},
/**
* 几天以后的日期
* @param day 天数
* @return 日期对象
*/
getAfterDate : function(day) {return new Date(new Date().getTime()+1000*60*60*24*day);},
/**
* 几天某日期以后几天的日期
* @param data 日期对象
* @param day 天数
* @return 日期对象
*/
getAfterDate : function(date,day) {date = date || new Date(); return new Date(date.getTime()+1000*60*60*24*day);},
/**
* 几天以后的日期
* @param day 天数
* @return 字符串(2013-02-27)
*/
getAfterDateString : function(date,day) {var date = CU.getAfterDate(date,day);var y = date.getFullYear();var m = date.getMonth()+1;var d = date.getDate();if(m < 10) m = "0"+m;if(d < 10) d = "0"+d;return y+"-"+m+"-"+d;},
/**
* 获取某年某月的天数
* @param year 年份
* @param month 月份
* @return Number 天数
*/
getDaysInMonth : function(year, month) {switch (month) {case 1:case 3:case 5:case 7:case 8:case 10:case 12: return 31;case 4:case 6:case 9:case 11: return 30;case 2: return ((year%4==0 && year%100!=0) || (year%400==0)) ? 29 : 28;default: return -1;}},
/**
* 获取当前(指定)日期的月份
* @param date 日期格式
* @return 字符串 (2013-03)
*/
getYearMonth : function(date){date = Ext.isEmpty(date)?date = new Date():date;var y = date.getFullYear();var m = date.getMonth()+1;if(m < 10) m = "0"+m; return y+"-"+m;},
/**
* 获取指定日期几个月以后的时间
* @param date 日期格式
* @param count 月数
* @return 字符串 (2013-03)
*/
getAfterYearMonth : function(date,count){date = Ext.isEmpty(date)?date = new Date():date;var y = date.getFullYear();var m = date.getMonth()+1;count = Ext.isEmpty(count)?1:count;m = m+count;if(m%12==0){y+=m/12-1;m=12;}else if(m>12){y+= parseInt(m/12);m=m%12;}if(m < 10) m = "0"+m;return y+"-"+m;},
/**
* 获取指定日期几个月以前的时间
* @param date 日期格式
* @param count 月数
* @return 字符串 (2013-03)
*/
getBeforeYearMonth : function(date,count){date = Ext.isEmpty(date)?date = new Date():date;var y = date.getFullYear();var m = date.getMonth()+1;var sum = (y*12+m) -count;if(sum%12==0){y = parseInt(sum/12)-1;m = 12;}else{y = parseInt(sum/12);m = sum%12;}if(m < 10) m = "0"+m;return y+"-"+m;},
/**
* 根据文件类型获取iconCls图标
* @param {} v
* @return {}
*/
getFileTypeIconCls : function(v){var iconCls = "x-fa fa-file";v = Ext.isEmpty(v)?"":v;switch(v.toUpperCase()){case 'DOC':case 'DOCX':iconCls = 'x-fa fa-file-word-o';break;case 'TXT':iconCls = 'x-fa fa-file-text';break;case 'PDF':iconCls = 'x-fa fa-file-pdf-o';break;case 'MP3':iconCls = 'x-fa fa-file-audio-o';break;case 'XLS':case 'XLSX': iconCls = 'x-fa fa-file-excel-o';break;case 'ZIP':case 'RAR': iconCls = 'x-fa fa-file-archive-o';break;case 'JPG':case 'GIF': case 'PNG' : iconCls = 'x-fa fa-file-image-o';break;}return iconCls;},
/**
* 获取文件后侧名
* @param {} file
* @return {}
*/
getFileSuffix:function(file){if(Ext.isEmpty(file))return "";var beginIndex = file.lastIndexOf(".");return file.substring(beginIndex+1,file.length);},
/**
* 递归读取全部数据
* @param {} datas 数据集合
* @param {} callback 回调方法
* @param {} scope
* @param {} childname 子节点名称 缺省children
*/
eachChild:function(datas,callback,scope,childname){scope = scope || this;var child = childname || 'children';var nextChildNode = function(nodes){Ext.each(nodes,function(data){Ext.callback(callback,scope,[data]);var children = data[child];if(Ext.isArray(children) && children.length>0){nextChildNode(children,callback,scope,child);}});};nextChildNode(datas,callback,scope,child);}
}
});