<include file="public@header"/> </head> <?php use think\Db;?> <body> <link type="text/css" rel="stylesheet" href="__STATIC__/css/zTreeStyle.css" /> <script type="text/javascript" src="__STATIC__/js/jquery.ztree.core.js"></script> <style type="text/css"> .submenu { list-style: outside none none; padding: 0; } .submenu > li{ background-color: #ececec; border-bottom: 1px solid #dcdcdc; border-top: 1px solid #fff; color: #727272; padding: 12px; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8); } </style> <div class="wrap"> <ul class="nav nav-tabs"> <li><a href="{:url('file/index')}">文件管理</a></li> <li class="active"><a href="">文件详情</a></li> </ul> <div class="col-xs-12" style="margin-top: 10px;height: 850px"> <div class="col-xs-3" style="border: 1px solid #18bc9c;height: 100%"> <div style="margin-top: 10px"> <select name="device_id" id="device_id" class="form-control"> <foreach name="devices" item="vo" key="k"> <option <if condition="$k eq $id"> selected</if> value="{$k}">{$vo}</option> </foreach> </select> </div> <ul class="submenu ztree" id="tree"> <!--<li>C:</li> <li>D:</li> <li>E:</li>--> </ul> </div> <div class="col-xs-9"> <table class="table table-hover table-bordered" id="repair_list"> <th>文件位置</th> <th>文件名</th> <th>类型</th> <th>修改日期</th> <th>大小</th> <th>操作</th> </table> </div> </div> </div> <!-- Dispatch Modal --> <div class="modal fade" id="dispatchModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h3 class="modal-title" id="">重命名</h3> </div> <div class="modal-body"> <form id="dispatch-post" class="well form-inline margin-top-20" method="post" action="/admin/file/rename" target="nm_iframe"> <input class="form-control" type="text" name="name" /><br/><br/> <input type="hidden" id="path" name="path" value="" /> <input type="hidden" id="tId" name="tId" value="" /> <input type="hidden" id="cId" name="cId" value="" /> <button type="submit" class="btn btn-primary" >确定</button> </form> <!--form 不跳转--> <iframe id="id_iframe" name="nm_iframe" style="display:none;"></iframe> </div> </div> </div> </div> <script src="__STATIC__/js/admin.js"></script> <script type="text/javascript"> var terminalId='10986'; var clientId; var source_path; var target_dir; var path; $(function () { ws = new WebSocket("ws://quanxintongfu.com.cn:8282"); ws.onmessage = function(e) { console.info ("message from server: " + e.data); var abc=JSON.parse(e.data); if(abc.type == 'client_id'){ clientId=abc.data; send_dir(terminalId,abc.data,''); }else if(abc.type == 'dir_content'){ //newNodes =[{name:"abc",isParent:"true"},{name:"44.docx",isParent:"false"},{name:"新建文本文档.txt",isParent:"false"}]; if(abc.content.length>0) { console.log(454) console.log(abc.content); var str2 = []; var str = ""; $.each(abc.content, function (key, value) { var f = false; if (value.type == 'dir') { f = true; } // str2 += '{name:"' + value.name + '",isParent:"' + f + '"},'; var item = { name: value.name, isParent: f }; str2.push(item); str += "<tr><td>" + abc.dir + "\\" + value.name + "</td><td>" + value.name + "</td><td>" + value.type + "</td><td>" + value.mod_time + "</td><td>" + value.size + "</td><td><a class='dispatch' data-toggle='modal' data-target='#dispatch' path='" + abc.dir + "\\" + value.name + "' href='javascript:void(0);'>重命名</a><a href='javascript:void(0);' οnclick='copy_file(this)' source_path='" + abc.dir + "\\" + value.name + "' target_dir='" + abc.dir + "\\' >复制 </a><a href='javascript:void(0);' οnclick='paste_file()'>粘贴</a><a href='javascript:void(0);' target_dir='" + abc.dir + "\\' path='" + abc.dir + "\\" + value.name + "' οnclick='del_file(this)'>删除</a><a href='javascript:void(0);' path='" + abc.dir + "\\" + value.name + "' οnclick='download_file(this)'>下载</a></td></tr>"; $("#repair_list tr:not(:first)").remove(); }); //str2 = str2.substr(0, str2.length - 1); //str2 += ']'; // str2 = eval(str2); treeObj.addNodes(treeNodeTid, str2); //treeObj.addNodes(treeNodeTid,newNodes); $("#repair_list").append(str); }else{ $("#repair_list tr:not(:first)").remove(); } }else if(abc.type == 'delete'){ if(abc.status == 'ok'){ alert('删除成功'); var t=treeNodeTid.tId; console.log(t); $("#"+t+"_span").trigger("click"); //send_dir(terminalId,clientId,target_dir); }else{ alert('删除失败,请重试'); } }else if(abc.type == 'rename'){ if(abc.status == 'ok'){ $('#dispatchModel').modal("hide"); alert('重命名成功'); var t=treeNodeTid.tId; //console.log(t); $("#"+t+"_span").trigger("click"); //send_dir(terminalId,clientId,target_dir); }else{ alert('删除失败,请重试'); } }else if(abc.type == 'copy'){ if(abc.status == 'ok'){ alert('操作成功'); var t=treeNodeTid.tId; //console.log(t); $("#"+t+"_span").trigger("click"); //send_dir(terminalId,clientId,target_dir); }else{ alert('操作失败,请重试'); } }else if(abc.type == 'download'){ var url=abc.url; if(abc.status == 'ok'){ // window.open ('admin/file/download/url/'+url); window.open ("__ROOT__/admin/file/download?url="+url); /* $.ajax({ url: "{:url('admin/file/download')}", type: 'POST', dataType: 'json', data: {url: url}, success: function(data){ if(data.code==0){ } } })*/ }else{ alert('操作失败,请重试'); } } }; $("#device_id").change(function () { //alert($(this).children('option:selected').val()); str="<li>F:</li><li>G:</li>"; $('ul.submenu').html(str); }); }); $(document).ready(function(){ $(document).on('click',".dispatch",function () { var rename_path= $(this).attr('path'); $("#path").attr("value",rename_path); $("#tId").attr("value",terminalId); $("#cId").attr("value",clientId); $('#dispatchModel').modal(); }); }) function send_dir(terminalId,clientId,dir){ $.ajax({ url: "{:url('admin/file/send_dir')}", type: 'POST', dataType: 'json', data: {terminalId: terminalId, clientId: clientId, dir:dir}, success: function(data){ if(data.code==0){ alert(data.msg); history.go(-1); } } }) } function copy_file(obj){ source_path=$(obj).attr('source_path'); target_dir=$(obj).attr('target_dir'); //console.log(target_dir); alert("复制成功,请进行粘贴操作"); } function paste_file() { //console.log(source_path); //console.log(target_dir); $.ajax({ url: "{:url('admin/file/paste_file')}", type: 'POST', dataType: 'json', data: {source_path: source_path, target_dir: target_dir,clientId: clientId,terminalId: terminalId}, success: function(data){ if(data.code==0){ alert(555); } } }) } function del_file(obj) { path=$(obj).attr('path'); target_dir=$(obj).attr('target_dir'); if(window.confirm('确认要删除吗?')) { $.ajax({ url: "{:url('admin/file/del_file')}", type: 'POST', dataType: 'json', data: {path: path, clientId: clientId, terminalId: terminalId}, success: function (data) { if (data.code == 0) { alert(555); } } }) } } function download_file(obj) { path=$(obj).attr('path'); $.ajax({ url: "{:url('admin/file/download_file')}", type: 'POST', dataType: 'json', data: {path: path, clientId: clientId, terminalId: terminalId}, success: function (data) { if (data.code == 0) { alert(555); } } }) } </script> <SCRIPT type="text/javascript" > var demoIframe; var treeObj; var treeNodeTid; var newNodes; var dir=''; var setting = { view: { dblClickExpand: false, showLine: true, selectedMulti: false }, data: { keep:{ parent:true } }, callback: { beforeClick: function(treeId, treeNode) { console.log(treeNode); console.log(treeNode.getParentNode()); //console.log(treeObj.getNodeByTId(treeNode.tId)); if (treeNode.isParent) { //var newNodes = [{name:"66",isParent:"true"}, {name:"77"}]; //treeObj.addNodes(treeObj.getNodeByTId(treeNode.tId), newNodes); // if(treeNode.getParentNode()!=null){ //console.log(treeNode.getPath()); a=treeNode.getPath(); //console.log(treeNode.getNextNode()); /*if(!treeNode.getNextNode()){ return false; }*/ //dir=treeNode.name; nodes = treeObj.getSelectedNodes(); //console.log(treeNode.tId); if (nodes && nodes.length>0) { var parentNode = treeObj.getNodeByTId(treeNode.tId); //console.log(4); //console.log(parentNode) //treeObj.reAsyncChildNodes(parentNode, "refresh",true); treeObj.removeChildNodes(parentNode); } $.each(a,function(key,value){ dir+=value.name+'\\'; }); //console.log(dir); send_dir(terminalId,clientId,dir); // } dir=""; treeNodeTid=treeObj.getNodeByTId(treeNode.tId); return true; } else { return false; } } } }; var zNodes =[]; $(document).ready(function(){ var t = $("#tree"); t = $.fn.zTree.init(t, setting, zNodes); treeObj = $.fn.zTree.getZTreeObj("tree"); //var newNodes = [{name:"newNode1",isParent:"true"}, {name:"newNode2"}, {name:"newNode3"}]; //newNodes = treeObj.addNodes(null, newNodes); }); </SCRIPT> </body> </html>