layui.use(["layer","jquery","table"],function(){function e(e){var a="";switch(e){case"zip":case"rar":case"7z":a="file_zip";break;case"jpg":case"png":case"bmp":case"gif":case"ico":a="file_img";break;case"htm":case"html":a="file_html";break;case"php":case"css":case"jsp":case"js":a="file_code";break;case"exe":a="file_exe";break;case"docx":case"doc":a="file_word";break;case"xlsx":case"xls":a="file_excel";break;case"pptx":case"ppt":a="file_ppt";break;case"pdf":a="file_pdf";break;case"psd":a="file_psd";break;case"mp4":a="file_video";break;case"mp3":a="file_music";break;case"txt":a="file_txt";break;case"wjj":a="folder";break;case"reply":a="fanhui";break;default:a="file"}return'<svg class="icon" aria-hidden="true"><use xlink:href="#icon-'+a+'"></use></svg>'}var a,t=void 0===parent.layer?layui.layer:top.layer,l=layui.jquery,i=layui.table;l.ajax({url:"../../ajax.php?act=systemParameter",type:"get",dataType:"json",success:function(t){var l='<div class="layui-btn-container">';"oss"==t.data.type?l+='<button class="layui-btn layui-btn-sm layui-bg-red" lay-event="ossUpload">上传文件</button>':l+='<button class="layui-btn layui-btn-sm" lay-event="localUpload">上传文件</button>',l+='<button class="layui-btn layui-btn-sm layui-bg-blue" lay-event="break">刷新目录</button></div>',a=i.render({elem:"#List",url:"../../ajax.php?act=getList&dir=",toolbar:l,defaultToolbar:["","",""],size:"sm",cols:[[{field:"type",title:"",templet:function(a){return e(a.type)},width:46,align:"center",unresize:!0},{field:"name",title:"文件名",event:"setSign",style:"cursor: pointer;"},{field:"size",title:"文件大小",width:100,align:"right",unresize:!0},{field:"time",title:"更新时间",width:150,align:"center",unresize:!0},{title:"操作",width:120,templet:"#ListBar",align:"center",unresize:!0}]]})}}),i.on("toolbar(List)",function(e){switch(e.event){case"ossUpload":t.open({type:1,title:"OSS - 上传文件",area:["70%","80%"],content:'<div class="page-container"><blockquote class="layui-elem-quote">1.文件上传位置为当前目录 当前上传目录：<span id="NowDir" style="color:#FF5722;">'+l("#NowDir").val()+'</span><br>2.为不影响你的正常使用，请上传完成后再关闭此窗口</blockquote><div class="layui-upload"><div class="layui-upload-list"><table class="layui-table"><thead><tr><th>文件名</th><th>大小</th><th>进度</th><th>状态</th></tr></thead><tbody id="demoList"></tbody></table></div></div><div id="container"><a id="selectfiles" href="javascript:;" class="layui-btn layui-btn-normal">选择文件</a><a id="postfiles" href="javascript:;" class="layui-btn">开始上传</a></div><script type="text/javascript" src="page/file/upload/plupload/plupload.full.min.js"></script><script type="text/javascript" src="page/file/upload/ossUpload.js"></script></div>'});break;case"localUpload":t.open({type:1,title:"本地 - 上传文件",area:["70%","80%"],content:'<div class="page-container"><blockquote class="layui-elem-quote">1.文件上传位置为当前目录 当前上传目录：<span id="NowDir" style="color:#FF5722;">'+l("#NowDir").val()+'</span><br>2.为不影响你的正常使用，请上传完成后再关闭此窗口</blockquote><div class="layui-upload"><div class="layui-upload-list"><table class="layui-table"><thead><tr><th>文件名</th><th>大小</th><th>进度</th><th>状态</th></tr></thead><tbody id="demoList"></tbody></table></div><button type="button"class="layui-btn layui-btn-normal"id="selectfiles">选择文件</button><button type="button"class="layui-btn"id="postfiles">开始上传</button></div></div></script><script type="text/javascript" src="page/file/upload/localUpload.js"></script>'});break;case"newfolder":alert("等待发布");break;case"break":var i=l("#NowDir").val();a.reload({url:"../../ajax.php?act=getList&dir="+i})}}),i.on("tool(List)",function(e){var i=e.data,s=l("#NowDir").val()+i.name;switch(e.event){case"setSign":if("wjj"==i.type&&(s+="/",a.reload({url:"../../ajax.php?act=getList&dir="+s}),l("#NowDir").val(s)),"reply"==i.type){s=l("#NowDir").val();var r=s.split("/"),c=r.length-2,o="";if(c>0)for(var n=0;n<c;n++)o+=r[n]+"/";a.reload({url:"../../ajax.php?act=getList&dir="+o}),l("#NowDir").val(o)}break;case"down":l.ajax({url:"../../ajax.php?act=Downfile&dir="+s,type:"get",dataType:"json",success:function(e){var a=e.data;a.msg?window.location.href=a.url:t.alert("错误代码：<br>"+a.msg,{icon:2})}});break;case"del":t.confirm("删除后无法恢复，确定删除吗？",{icon:0},function(a){var i=t.msg("数据提交中，请稍候",{icon:16,time:!1,shade:.8});l.ajax({url:"../../ajax.php?act=Delfile&dir="+s,type:"get",dataType:"json",success:function(a){var l=a.data.msg;"ok"==l?(e.del(),t.msg("操作成功！",{icon:1,time:1800})):t.alert("错误代码：<br>"+l,{icon:2}),t.close(i)}})})}})});