xeasyui_treegrid.min.js 14 KB

1
  1. function request(n){var t=location.href,f=t.substring(t.indexOf("?")+1,t.length).split("&"),u={},r;for(i=0;j=f[i];i++)u[decodeURI(j.substring(0,j.indexOf("=")).toLowerCase())]=j.substring(j.indexOf("=")+1,j.length);return r=u[decodeURI(n.toLowerCase())],typeof r=="undefined"?"":decodeURI(r)}document.write('<link rel="shortcut icon" href="/img/logo16x16.png" />');document.write('<link rel="bookmark" href="/img/logo16x16.png" />');document.write('<link rel="stylesheet" type="text/css" href="/plugins/jquery-easyui-1.8.3/themes/bootstrap/easyui.css" id="theme">');document.write('<link rel="stylesheet" type="text/css" href="/plugins/jquery-easyui-1.8.3/themes/icon.css">');document.write('<script type="text/javascript" src="/plugins/jquery-easyui-1.8.3/jquery.min.js"><\/script>');document.write('<script type="text/javascript" src="/plugins/jquery-easyui-1.8.3/jquery.easyui.min.js"><\/script>');document.write('<script type="text/javascript" src="/plugins/jquery-easyui-1.8.3/treegrid-dnd.js"><\/script>');document.write('<script type="text/javascript" src="/plugins/jquery-easyui-1.8.3/locale/easyui-lang-zh_CN.js"><\/script>');document.write('<link rel="stylesheet" type="text/css" href="/plugins/xeasyui/xeasyui.css">');var dk={currentPath:window.location.pathname.substring(0,window.location.pathname.lastIndexOf("/")+1),treeTag:"treePanel",tabTag:"tabPanel",tabAllowRepeat:!1,dialogTag:"dd",dialogWidth:800,dialogHeight:600,dialogModal:!0,dialogTarget:window.parent,formTag:"ff",datagridTag:"dg",datagridtoolbarTag:"tb",datagridsearchtextTag:"toolbarSearchtext",datagridcheckboxTag:"toolbarCheckbox",datagridcheckboxShow:!1,afterSaveUrl:"",uploadfileUrl:"/plugins/UEditor/net/controller.ashx?action=uploadfile&encode=utf-8",treeShow:function(n){var t=typeof n.treeTag=="undefined"?xw.treeTag:n.treeTag;$("#"+t).tree({url:typeof n.url=="undefined"?"":n.url,method:typeof n.method=="undefined"?"post":n.method,animate:typeof n.animate=="undefined"?!0:n.animate,lines:typeof n.lines=="undefined"?!1:n.lines,onClick:function(n){if($("#"+t).tree("isLeaf",n.target)){var i=n.attributes.url.replace("@资讯类别",n.attributes["资讯类别"]);switch(n.attributes.target){case"_blank":window.open(i);break;case"_self":window.location=i;break;case"_tabs":xw.tabOpen({title:n.text,url:i,closable:!0});break;default:xw.tabOpen({title:n.text,url:i,closable:!0})}}},onBeforeLoad:function(){$.messager.progress()},onLoadSuccess:function(){$.messager.progress("close")}})},tabOpen:function(n){var t=typeof n.tabTag=="undefined"?xw.tabTag:n.tabTag,u=typeof n.url=="undefined"?"":n.url,i=typeof n.title=="undefined"?"":n.title,r=typeof n.id=="undefined"?n.title:n.id,f=typeof n.closable=="undefined"?!0:n.closable;$("#"+t).tabs("exists",i)&&!xw.tabAllowRepeat?$("#"+t).tabs("select",i):$("#"+t).tabs("add",{id:r,title:i,closable:f,content:'<div style="overflow:hidden;width:100%;height:100%;"><iframe id="'+r+'Frame" scrolling="auto" frameborder="0" src="'+u+'" style="width:100%;height:100%;"><\/iframe><\/div>'})},datagridShow:function(n){var i=typeof n.datagridTag=="undefined"?xw.datagridTag:n.datagridTag,u=typeof n.searchtextTag=="undefined"?xw.datagridsearchtextTag:n.searchtextTag,t=typeof n.queryParams=="undefined"?"":n.queryParams,r;request("ss")!=""&&(t=request("ss"));r=t==""?"":eval("("+t+")");t!=""&&t!="{}"&&$("#"+u).linkbutton({iconCls:"icon-redo",text:t,plain:!0,onClick:toolbarSearchText});$("#"+i).treegrid({iconCls:typeof n.iconCls=="undefined"?"icon-grid":n.iconCls,title:typeof n.title=="undefined"?"":n.title,idField:typeof n.idField=="undefined"?"标识":n.idField,fit:!0,fitColumns:!1,rownumbers:!0,pagination:!1,remoteSort:!0,multiSort:!1,singleSelect:!1,checkOnSelect:!0,selectOnCheck:!0,ctrlSelect:!0,url:typeof n.url=="undefined"?"":n.url,queryParams:r,method:"post",border:!1,collapsible:!0,pageSize:typeof n.pageSize=="undefined"?10:n.pageSize,pageList:typeof n.pageList=="undefined"?[10,15,20,25,30,35,40,45,50]:n.pageList,treeField:"名称",onLoadSuccess:function(n){$("#"+i).treegrid("enableDnd",n?n.id:null)}})},datagridToolbarCheckBox:function(){$.fn.jquery<"2.0.0"?xw.datagridcheckboxShow?(xw.datagridcheckboxShow=!1,$("#"+xw.datagridTag).treegrid("hideColumn","guid")):(xw.datagridcheckboxShow=!0,$("#"+xw.datagridTag).treegrid("showColumn","guid")):$("#"+xw.datagridTag).treegrid($("#"+xw.datagridcheckboxTag).linkbutton("options").selected?"hideColumn":"showColumn","guid")},datagridDelete:function(n){var t=typeof n.datagridTag=="undefined"?xw.datagridTag:n.datagridTag,u=typeof n.url=="undefined"?"":n.url,r=$("#"+t).treegrid("getSelections").length;r>0?$.messager.confirm("删除操作","您确定要删除选定的 "+r+" 条记录吗?",function(n){var r,f,e;if(n){for(r="",f=$("#"+t).treegrid("options").idField,i=0;i<$("#"+t).treegrid("getSelections").length;i++)i>0&&(r+=","),r+=$("#"+t).treegrid("getSelections")[i][f];e="{"+f+':"'+r+'"}';$.post(u,eval("("+e+")"),function(n){var i=eval("("+n+")");i.success=="true"||i.success==!0?$("#"+t).treegrid("reload"):alert(i.message)})}}):$.messager.alert("删除操作","您还没有选择任何记录!","info")},datagridReloadFromDialog:function(){var t=xw.datagridTag,n=xw.dialogTarget,i=xw.tabTag,r,u;n==window.parent?n.$("#tabPanel").length!=0?(r=n.$("#"+i).tabs("getSelected"),u=n.$("#"+i).find("#"+r.attr("id")+"Frame")[0],u.contentWindow.$("#"+t).treegrid("reload")):n.$("#"+t).treegrid("reload"):n.parent.$("#"+t).treegrid("reload")},dialogGotoUrl:function(n){var t=typeof n.url=="undefined"?"":n.url,i=typeof n.dialogTag=="undefined"?xw.dialogTag:n.dialogTag,r=typeof n.dialogTarget=="undefined"?xw.dialogTarget:n.dialogTarget,u=t.indexOf("?")>-1?t+"&r="+Math.random():t+"?r="+Math.random();r.$("#"+i).find("#ddFrame")[0].src=u},dialogShow:function(n){var u=typeof n.modal=="undefined"?xw.dialogModal:n.modal,r=typeof n.url=="undefined"?"":n.url,f=r.indexOf("?")>-1?r+"&r="+Math.random():r+"?r="+Math.random(),i=typeof n.dialogTag=="undefined"?xw.dialogTag:n.dialogTag,t=typeof n.dialogTarget=="undefined"?xw.dialogTarget:n.dialogTarget;t.$("#"+i).length==0&&t.$("body").append('<div id="'+i+'"><\/div>');t.$("#"+i).dialog({iconCls:typeof n.iconCls=="undefined"?"icon-grid":n.iconCls,title:typeof n.title=="undefined"?"数据操作":n.title,top:typeof n.top=="undefined"?($(t).height()-xw.dialogHeight)*.5:n.top,left:typeof n.left=="undefined"?($(t).width()-xw.dialogWidth)*.5:n.left,width:typeof n.width=="undefined"?xw.dialogWidth:n.width,height:typeof n.height=="undefined"?xw.dialogHeight:n.height,closed:!1,cache:!1,maximizable:!0,maximized:!1,minimizable:!1,minimized:!0,collapsible:!1,resizable:!0,content:'<div style="overflow:hidden;width:100%;height:100%;"><iframe id="ddFrame" scrolling="yes" frameborder="0" src="" style="width:100%;height:100%;"><\/iframe><\/div>',modal:u});t.$("#"+i).find("#ddFrame")[0].src=f},dialogSave:function(n){var i=typeof n.url=="undefined"?"":n.url,s=i.indexOf("?")>-1?i+"&r="+Math.random():i+"?r="+Math.random(),e=typeof n.dialogTag=="undefined"?xw.dialogTag:n.dialogTag,o=typeof n.formTag=="undefined"?xw.formTag:n.formTag,r=typeof n.tabTag=="undefined"?xw.tabTag:n.tabTag,u=typeof n.datagridTag=="undefined"?xw.datagridTag:n.datagridTag,t=typeof n.dialogTarget=="undefined"?xw.dialogTarget:n.dialogTarget,f=typeof n.afterSaveUrl=="undefined"?xw.afterSaveUrl:n.afterSaveUrl;$.messager.progress();$("#"+o).form("submit",{url:s,onSubmit:function(){if(typeof xeditor!="undefined")for(var n=0;n<xeditor.length;n++)$("#"+xeditor[n].key.substring(0,xeditor[n].key.length-6)).val(xeditor[n].getContent());return $("#"+o).form("validate")},success:function(n){var i=eval("("+n+")"),o,s;i.success=="true"||i.success==!0?t==window.parent?(t.$("#"+r).length!=0?(o=t.$("#"+r).tabs("getSelected"),s=t.$("#"+r).find("#"+o.attr("id")+"Frame")[0],s.contentWindow.$("#"+u).treegrid("reload")):t.$("#"+u).treegrid("reload"),f==""?t.$("#"+e).dialog("close"):t.$("#"+u).find("#ddFrame")[0].src=asUrl.replace("@id",i["标识"]).replace("@guid",i["标识"])):(ddTarget.parent.$("#"+dgTag).treegrid("reload"),f==""?ddTarget.parent.$("#"+e).dialog("close"):ddTarget.parent.$("#"+ddTag).find("#ddFrame")[0].src=f.replace("@id",i["标识"]).replace("@guid",i["标识"])):alert(i.message);$.messager.progress("close")}})},dialogDelete:function(n){var i=typeof n.url=="undefined"?"":n.url,e=i.indexOf("?")>-1?i+"&r="+Math.random():i+"?r="+Math.random(),r=typeof n.dialogTag=="undefined"?xw.dialogTag:n.dialogTag,u=typeof n.datagridTag=="undefined"?xw.datagridTag:n.datagridTag,t=typeof n.dialogTarget=="undefined"?xw.dialogTarget:n.dialogTarget,f=typeof n.tabTag=="undefined"?xw.tabTag:n.tabTag;$.messager.confirm("删除操作","您确定要删除当前记录吗?",function(n){n&&$.get(e,function(n){var i=eval("("+n+")"),e,o;i.success=="true"||i.success==!0?t==window.parent?t.$("#"+f).length!=0?(e=t.$("#"+f).tabs("getSelected"),o=t.$("#"+f).find("#"+e.attr("id")+"Frame")[0],o.contentWindow.$("#"+u).treegrid("reload"),t.$("#"+r).dialog("close")):(t.$("#"+u).treegrid("reload"),t.$("#"+r).dialog("close")):(t.parent.$("#"+u).treegrid("reload"),t.parent.$("#"+r).dialog("close")):alert(i.message)})})},dialogSearch:function(n){var e=typeof n.dialogTag=="undefined"?xw.dialogTag:n.dialogTag,o=typeof n.tabTag=="undefined"?xw.tabTag:n.tabTag,r=typeof n.datagridTag=="undefined"?xw.datagridTag:n.datagridTag,u=typeof n.searchtextTag=="undefined"?xw.datagridsearchtextTag:n.searchtextTag,t=typeof n.dialogTarget=="undefined"?xw.dialogTarget:n.dialogTarget,i=typeof n.searchStr=="undefined"?"":n.searchStr,s,f;t==window.parent?t.$("#"+o).length!=0?(s=t.$("#"+o).tabs("getSelected"),f=t.$("#"+o).find("#"+s.attr("id")+"Frame")[0],i!="{}"?f.contentWindow.$("#"+u).linkbutton({iconCls:"icon-redo",text:i,plain:!0,onClick:f.contentWindow.toolbarSearchText}):(f.contentWindow.$("#"+u).text(""),f.contentWindow.$("#"+r).treegrid("load",{})),f.contentWindow.$("#"+r).treegrid("load",eval("("+i+")")),t.$("#"+e).dialog("close")):(i!="{}"?t.$("#"+u).linkbutton({iconCls:"icon-redo",text:i,plain:!0,onClick:ddTarget.toolbarSearchText}):(t.$("#"+u).text(""),t.$("#"+r).treegrid("load",{})),t.$("#"+r).treegrid("load",eval("("+i+")")),t.$("#"+e).dialog("close")):(i!="{}"?t.parent.$("#"+u).linkbutton({iconCls:"icon-redo",text:i,plain:!0,onClick:t.parent.toolbarSearchText}):(t.parent.$("#"+u).text(""),t.parent.$("#"+r).treegrid("load",{})),t.parent.$("#"+r).treegrid("load",eval("("+i+")")),t.parent.$("#"+e).dialog("close"))},dialogClose:function(){var n=xw.dialogTag;xw.dialogTarget.parent.$("#"+n).dialog("close")},dialogSetTitle:function(n){var t=typeof n.dialogTag=="undefined"?xw.dialogTag:n.dialogTag,i=typeof n.dialogTarget=="undefined"?xw.dialogTarget:n.dialogTarget,r=typeof n.title=="undefined"?"":n.title;i.parent.$("#"+t).dialog("open").dialog("setTitle",r)},formLoad:function(n){var i=typeof n.formTag=="undefined"?xw.formTag:n.formTag,t=typeof n.url=="undefined"?"":n.url,r=t.indexOf("?")>-1?t+"&r="+Math.random():t+"?r="+Math.random(),u=typeof n.callBack=="undefined"?function(){}:n.callBack;$.messager.progress();$.get(r,function(n){var t,f,e,o,s,h,r,c,l;if(n!=""){if(t=eval("("+n+")"),$("#"+i).form("load",t),f=$('div[xfieldvalue="true"],span[xfieldvalue="true"]'),$.each(f,function(n,i){$("div #"+i.id).html(t[i.id])}),e=$('img[xfieldvalue="true"]'),$.each(e,function(n,i){t[i.id]==""?$("#"+i.id).remove():(i.src=t[i.id],$("#"+i.id).css("max-width","100%"))}),$('a[xfieldvalue="true"]').each(function(n,i){i.href=t[i.id]}),$('input:hidden[xfieldvalue="true"]').each(function(n,i){i.value=t[i.name]}),o=$('input[xfilebox="true"]'),$.each(o,function(n,t){$("#"+t.id).filebox({buttonText:"选择文件",buttonAlign:"right",accept:"image/*",onChange:xw.imagePreview})}),s=$('img[xfilebox="true"]'),$.each(s,function(n,i){t[i.id]==""?xw.imageDelete(i.id):(i.src=t[i.id],i.title="双击图片删除!",$("#"+i.id).dblclick(function(){confirm("您确定要删除图片吗?")&&xw.imageDelete(xw.id)}))}),h=$('[xeditor="true"]'),$.each(h,function(n,i){i.value=t[i.name]}),typeof xeditor!="undefined"){if(typeof UE!="undefined")for(r=0;r<xeditor.length;r++)UE.getEditor(xeditor[r].key).ready(function(){UE.getEditor(this.key).setContent($("#"+this.key.substring(0,+this.key.length-6)).val())});if(typeof UM!="undefined")for(r=0;r<xeditor.length;r++)UM.getEditor(xeditor[r].key).ready(function(){UM.getEditor(this.key).setContent($("#"+this.key.substring(0,+this.key.length-6)).val())})}c=$("input.easyui-switchbutton");$.each(c,function(n,i){t[i.id].toLowerCase()=="true"||t[i.id]=="1"?$("#"+i.id).switchbutton("check"):$("#"+i.id).switchbutton("uncheck")});l=$('div[xtruefalse="true"]');$.each(l,function(n,i){t[i.id]=="True"?$("#"+i.id).html('<img src="/js/themes/icons/ok.png">'):$("#"+i.id).html('<img src="/js/themes/icons/cancel.png">')});$("#确认密码").length>0&&$("#密码").length>0&&($("#确认密码").textbox("setText",$("#密码").textbox("getValue")),$("#确认密码").textbox("setValue",$("#密码").textbox("getValue")));u();$.messager.progress("close")}else $.messager.progress("close"),alert("数据不存在或已被删除!")})},formGet:function(){var i="{",u=$("input:hidden"),n=[],r=-1,t;for($.each(u,function(t,i){var u,f;if(i.name!=""&&i.value!=""){for(r=-1,u=0;u<n.length;u++)i.name==n[u].name&&(r=u);r>=0?n[r].value+=","+i.value:(f={},f.name=i.name,f.value=i.value,n.push(f))}}),t=0;t<n.length;t++)i!="{"&&(i+=","),i+="'"+n[t].name+"':'"+n[t].value+"'";return i+"}"},imagePreview:function(){var f=document.getElementsByTagName("input"),r=0,t,n,u;for(i=0;i<f.length;i++)f[i].type=="file"&&(r++,t=document.getElementById("filebox_file_id_"+r).files[0],t&&(n=document.getElementById("filebox_file_id_"+r),u=window.navigator.userAgent.indexOf("Chrome")>=1||window.navigator.userAgent.indexOf("Safari")>=1?window.webkitURL.createObjectURL(t):window.URL.createObjectURL(t),document.getElementById(n.id+"_img_preview")?document.getElementById(n.id+"_img_preview").src=u:$("#"+n.name).before('<img id="'+n.id+'_img_preview" src="'+u+'" style="max-width: 100%;" title="双击图片删除!" ondblclick="$(\'#'+n.id+"_img_preview').remove();$('#"+n.id+"_br_preview').remove();$('#"+n.name+"').filebox('setValue','')\"><br id=\""+n.id+'_br_preview">')))},imageDelete:function(n){var i='<input id="'+n+'" name="'+n+'" type="text" style="width:100%;height:32px;">',t=$("#"+n);t.before(i);t.remove();$("#"+n).filebox({buttonText:"选择文件",buttonAlign:"right",accept:"image/*",onChange:xw.imagePreview})}};