explorer.html 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <style>
  2. .progress {
  3. width: 600px;
  4. height: 10px;
  5. border: 1px solid #ccc;
  6. border-radius: 10px;
  7. margin: 10px 0px;
  8. overflow: hidden;
  9. display: -webkit-inline-box;
  10. }
  11. /* 初始状态设置进度条宽度为0px */
  12. .progress>div {
  13. width: 0px;
  14. height: 100%;
  15. background-color: yellowgreen;
  16. transition: all .3s ease;
  17. }
  18. </style>
  19. <article class="cl pd-20">
  20. <div class="cl pd-5 bg-1 bk-gray">
  21. <span class="l">
  22. <a class="btn radius btn-default" href="{:url('index')}"><i
  23. class="Hui-iconfont Hui-iconfont-pages"></i>数据库模式</a>
  24. <a class="btn radius btn-secondary"><i class="Hui-iconfont Hui-iconfont-jifen"></i> 目录模式 </a>
  25. <a class="btn btn-primary radius" onclick="uploadFile();"><i
  26. class="Hui-iconfont Hui-iconfont-add"></i>上传附件</a>
  27. <input type="file" id="upload_file" hidden multiple onchange="fileChange()">
  28. <input type="hidden" id="activepath" name="activepath" value="{$activepath}">
  29. <div class="progress">
  30. <div></div>
  31. </div>
  32. </span>
  33. <span class="r">共有:
  34. <strong>{$counts}</strong> 个对象</span>
  35. </div>
  36. <div class="cl mt-20">
  37. <table class="table table-border table-bordered table-bg">
  38. <thead>
  39. <tr class="text-c">
  40. <th width="25%">
  41. <strong>文件名</strong>
  42. </th>
  43. <th width="16%">
  44. <strong>文件大小</strong>
  45. </th>
  46. <th width="22%">
  47. <strong>最后修改时间</strong>
  48. </th>
  49. <th width="34%">
  50. <strong>操作</strong>
  51. </th>
  52. </tr>
  53. </thead>
  54. <tbody>
  55. <tr class="text-c" bgcolor='#FFFFFF' height='26' onMouseMove="javascript:this.bgColor='#FCFDEE';"
  56. onMouseOut="javascript:this.bgColor='#FFFFFF';">
  57. <td>
  58. {notempty name="activepath"}<i class="Hui-iconfont Hui-iconfont-arrow1-top"></i>{/notempty}
  59. <a href="/sys/file_manager/explorer?activepath={$activeurl}">上级目录</a>
  60. </td>
  61. <td>当前目录:
  62. <span style="color:#f00;"> ./storage{$activepath} </span>  
  63. </td>
  64. <td></td>
  65. <td></td>
  66. </tr>
  67. {foreach $dirs as $dir}
  68. <tr class="text-c" style="height:26px; " onMouseMove="javascript:this.bgColor='#FCFDEE';"
  69. onMouseOut="javascript:this.bgColor='#FFFFFF';">
  70. <td style="text-align:left;">
  71. <img src=/static/images/icon/dir.png>
  72. <a href="/sys/file_manager/explorer?activepath={$activepath.'/'.$dir}">
  73. {$dir}
  74. </a>
  75. </td>
  76. <td></td>
  77. <td></td>
  78. <td>
  79. <a class="btn" onclick="del_dir(this, '{$activepath}/{$dir}')">删除</a>
  80. </td>
  81. </tr>
  82. {/foreach}
  83. {foreach $files as $file}
  84. <tr class="text-c" bgcolor='#FFFFFF' height='26' onMouseMove="javascript:this.bgColor='#FCFDEE';"
  85. onMouseOut="javascript:this.bgColor='#FFFFFF';">
  86. <td style="text-align:left;">
  87. <img src="/static/images/icon/{$file['extension']}.png">
  88. <a href="/storage{$activepath}/{$file['filename']}" target="_blank">
  89. {$file['filename']}
  90. </a>
  91. </td>
  92. <td align='center'> {$file['size']} </td>
  93. <td align='center'> {$file['time']|date="Y-m-d H:i:s"} </td>
  94. <td>
  95. <a href="/storage{$activepath.'/'.$file['filename']}" class="btn radius btn-primary"
  96. target="_blank">查看/下载</a>&nbsp;
  97. <a class="btn radius btn-danger"
  98. onclick="del_file(this,'{$activepath}/{$file.filename}')">删除</a>&nbsp;
  99. <!-- <a href='' class="btn" >移动</a> -->
  100. </td>
  101. </tr>
  102. {/foreach}
  103. </tbody>
  104. </table>
  105. </div>
  106. </article>
  107. <!--请在下方写此页面业务相关的脚本-->
  108. <script type="text/javascript">
  109. /*删除图片*/
  110. function del_dir(obj, dir) {
  111. layer.confirm('确认要删除吗?', function (index) {
  112. $.post('deldir', {
  113. 'dir': dir
  114. }, function (res) {
  115. if (res.code == 0) {
  116. $(obj).parents('tr').remove();
  117. topalert({
  118. type: 0,
  119. content: res.msg,
  120. speed: 1000
  121. });
  122. } else {
  123. topalert({
  124. type: 2,
  125. content: res.msg,
  126. speed: 2000
  127. });
  128. }
  129. layer.close(layer.index);
  130. }, 'json');
  131. });
  132. }
  133. /*删除图片*/
  134. function del_file(obj, filename) {
  135. layer.confirm('确认要删除吗?', function (index) {
  136. $.post('delfile', {
  137. 'filename': filename
  138. }, function (res) {
  139. if (res.code == 0) {
  140. $(obj).parents('tr').remove();
  141. topalert({
  142. type: 0,
  143. content: res.msg,
  144. speed: 1000
  145. });
  146. } else {
  147. topalert({
  148. type: 2,
  149. content: res.msg,
  150. speed: 2000
  151. });
  152. }
  153. layer.close(layer.index);
  154. }, 'json');
  155. });
  156. }
  157. //通过点击图片来触发文件上传按钮
  158. function uploadFile(params) {
  159. $("#upload_file").click();
  160. }
  161. // 自动上传处理
  162. function fileChange() {
  163. let uploadFile = $("#upload_file").get(0).files;
  164. // console.log(uploadFile);
  165. if (uploadFile == undefined || uploadFile == null) {
  166. layer.msg("请选择文件", { icon: 5, time: 1000 });
  167. return false;
  168. }
  169. if (uploadFile.length > 20) {
  170. layer.msg("最多20个文件", { icon: 5, time: 1000 });
  171. return false;
  172. }
  173. let formData = new FormData();
  174. formData.append('activepath', $('#activepath').val());
  175. for (let i = 0; i < uploadFile.length; i++) {
  176. formData.append('upload_file[]', uploadFile[i]);
  177. }
  178. $.ajax({
  179. url: '{:url("file_manager/uploadFile")}',
  180. type: 'post',
  181. dataType: 'json',
  182. data: formData,
  183. processData: false,
  184. contentType: false,
  185. xhr: function () {
  186. var xhr = new XMLHttpRequest();
  187. //使用XMLHttpRequest.upload监听上传过程,注册progress事件,打印回调函数中的event事件
  188. xhr.upload.addEventListener('progress', function (e) {
  189. // console.log(e);
  190. //loaded代表上传了多少
  191. //total代表总数为多少
  192. var progressRate = (e.loaded / e.total) * 100 + '%';
  193. //通过设置进度条的宽度达到效果
  194. $('.progress > div').css('width', progressRate);
  195. })
  196. return xhr;
  197. },
  198. success: function (res) {
  199. console.log(res);
  200. if (res.code == 0) {
  201. layer.msg(res.msg, {
  202. icon: 1,
  203. time: 1000
  204. });
  205. window.location.reload();
  206. } else {
  207. layer.msg(res.msg, {
  208. icon: 5,
  209. time: 1000
  210. });
  211. return false;
  212. }
  213. }
  214. });
  215. }
  216. </script>
  217. <!--请在上方写此页面业务相关的脚本-->