index.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. <<<<<<< HEAD
  2. <style>
  3. .progress {
  4. width: 600px;
  5. height: 10px;
  6. border: 1px solid #ccc;
  7. border-radius: 10px;
  8. margin: 10px 0px;
  9. overflow: hidden;
  10. display: -webkit-inline-box;
  11. }
  12. /* 初始状态设置进度条宽度为0px */
  13. .progress>div {
  14. width: 0px;
  15. height: 100%;
  16. background-color: yellowgreen;
  17. transition: all .3s ease;
  18. }
  19. </style>
  20. <article class="cl pd-10">
  21. <div class="cl pd-5 bg-1 bk-gray mt-20">
  22. <span class="l">
  23. <a class="btn radius btn-secondary"><i class="Hui-iconfont Hui-iconfont-jifen"></i>数据库模式</a>
  24. <a class="btn radius btn-default" href="{:url('explorer')}"><i class="Hui-iconfont Hui-iconfont-pages"></i> 目录模式 </a>
  25. <a class="btn btn-danger radius" onclick="del_all();"><i class="Hui-iconfont Hui-iconfont-del2"></i>批量删除</a>
  26. <a class="btn btn-primary radius" onclick="uploadFile();"><i class="Hui-iconfont Hui-iconfont-add"></i>上传附件</a>
  27. <input type="file" id="upload_file" hidden multiple onchange="fileChange()">
  28. <div class="progress">
  29. <div></div>
  30. </div>
  31. </span>
  32. <span class="r">共有数据:<strong id="total">{$list->total()}</strong>条</span>
  33. </div>
  34. <div class="cl mt-20">
  35. <table class="table table-border table-bordered table-bg">
  36. <thead>
  37. <tr class="text-c">
  38. <th width="25px;">
  39. <input type="checkbox" name="allcheck" value="">
  40. </th>
  41. <th width="60px;">ID</th>
  42. <th>文件title</th>
  43. <th style="min-width: 260px;">文件路径</th>
  44. <th>文件类型</th>
  45. <th>文件大小</th>
  46. <th>增加者</th>
  47. <th>增加时间</th>
  48. <th width="100px;">操作</th>
  49. </tr>
  50. </thead>
  51. <tbody>
  52. {foreach $list as $val}
  53. <tr class="text-c">
  54. <td>
  55. <input type="checkbox" value="{$val.fileid}" name="checkbox[]">
  56. </td>
  57. <td>{$val.fileid}</td>
  58. <td class="text-l">{$val.title}</td>
  59. <td class="text-l">
  60. <a href="{$val.filepath}" title="{$val.filepath}" target="_blank">{$val.filepath}</a>
  61. </td>
  62. <td>{$val.fileextension}</td>
  63. <td>{$val.filesize|format_bytes}</td>
  64. <td>{$val.username}</td>
  65. <td>{$val.filetime|date="Y-m-d H:i:s"}</td>
  66. <td class="td-manager">
  67. <a class="btn btn-secondary radius" title="编辑title" onClick="editTitle('{$val.fileid}','{$val.title}')"><i
  68. class="Hui-iconfont Hui-iconfont-edit"></i></a>
  69. <a class="btn btn-danger radius" title="删除" onClick="del(this,'{$val.fileid}')"><i
  70. class="Hui-iconfont Hui-iconfont-del2"></i></a></td>
  71. </tr>
  72. {/foreach}
  73. </tbody>
  74. </table>
  75. </div>
  76. </article>
  77. <script>
  78. //通过点击图片来触发文件上传按钮
  79. function uploadFile(params) {
  80. $("#upload_file").click();
  81. }
  82. // 上传处理
  83. function fileChange() {
  84. let uploadFile = $("#upload_file").get(0).files;
  85. // console.log(uploadFile);
  86. if (uploadFile == undefined || uploadFile == null) {
  87. layer.msg("请选择文件", { icon: 5, time: 1000 });
  88. return false;
  89. }
  90. if (uploadFile.length > 20) {
  91. layer.msg("最多20个文件", { icon: 5, time: 1000 });
  92. return false;
  93. }
  94. let formData = new FormData();
  95. for (let i = 0; i < uploadFile.length; i++) {
  96. formData.append('upload_file[]', uploadFile[i]);
  97. }
  98. $.ajax({
  99. url: '{:url("file_manager/uploadFile")}',
  100. type: 'post',
  101. dataType: 'json',
  102. data: formData,
  103. processData: false,
  104. contentType: false,
  105. xhr: function () {
  106. var xhr = new XMLHttpRequest();
  107. //使用XMLHttpRequest.upload监听上传过程,注册progress事件,打印回调函数中的event事件
  108. xhr.upload.addEventListener('progress', function (e) {
  109. // console.log(e);
  110. //loaded代表上传了多少
  111. //total代表总数为多少
  112. var progressRate = (e.loaded / e.total) * 100 + '%';
  113. //通过设置进度条的宽度达到效果
  114. $('.progress > div').css('width', progressRate);
  115. })
  116. return xhr;
  117. },
  118. success: function (res) {
  119. console.log(res);
  120. if (res.code == 0) {
  121. layer.msg(res.msg, {
  122. icon: 1,
  123. time: 1000
  124. });
  125. window.location.reload();
  126. } else {
  127. layer.msg(res.msg, {
  128. icon: 5,
  129. time: 1000
  130. });
  131. return false;
  132. }
  133. }
  134. });
  135. }
  136. function editTitle(id, title) {
  137. if (id==0) {
  138. layer.msg('id不可为空', {icon: 5,time: 1000});
  139. }
  140. var content = '<div class="cl" style="padding:20px;">';
  141. content += '<label class="form-label col-sm-4">';
  142. content += '<span class="c-red">*</span>文件title:</label>';
  143. content += '<div class="formControls col-sm-6">';
  144. content += '<input type="text" class="input-text" name="filetile" id="filetile">';
  145. content += '</div><div class="col-3"></div></div></div>';
  146. layer.open({
  147. type: 1,
  148. area: ['500px', '200px'],
  149. title: '修改文件title',
  150. content: '\<\div style="padding:20px;">\<\span class="c-red">*\<\/span>文件title:\<\input type="text" class="input-text" name="filetitle" value="'+title+'" id="filetitle">\<\/div>',
  151. btn: ['确定', '取消'],
  152. yes: function(index, layero){
  153. let filetitle = document.querySelector('input[name="filetitle"]').value;
  154. $.ajax({
  155. url: '{:url("file_manager/updateFileTitle")}',
  156. type: 'post',
  157. dataType: 'json',
  158. contentType: 'application/json',
  159. data: JSON.stringify({
  160. id: id,
  161. filetitle: filetitle
  162. }),
  163. success: function (res) {
  164. if (res.code == 0) {
  165. layer.msg(res.msg, {
  166. icon: 1,
  167. time: 1000
  168. });
  169. window.location.reload();
  170. } else {
  171. layer.msg(res.msg, {
  172. icon: 5,
  173. time: 1000
  174. });
  175. }
  176. layer.close(index);
  177. }
  178. });
  179. }
  180. });
  181. // layer.open({
  182. // type: 2,
  183. // area: ['700px', '500px'],
  184. // fix: false, //不固定
  185. // maxmin: true,
  186. // shade: 0.4,
  187. // title: '添加标题图',
  188. // content: 'test'
  189. // });
  190. }
  191. =======
  192. <style>
  193. .progress {
  194. width: 600px;
  195. height: 10px;
  196. border: 1px solid #ccc;
  197. border-radius: 10px;
  198. margin: 10px 0px;
  199. overflow: hidden;
  200. display: -webkit-inline-box;
  201. }
  202. /* 初始状态设置进度条宽度为0px */
  203. .progress>div {
  204. width: 0px;
  205. height: 100%;
  206. background-color: yellowgreen;
  207. transition: all .3s ease;
  208. }
  209. </style>
  210. <article class="cl pd-10">
  211. <div class="cl pd-5 bg-1 bk-gray mt-20">
  212. <span class="l">
  213. <a class="btn radius btn-secondary"><i class="Hui-iconfont Hui-iconfont-jifen"></i>数据库模式</a>
  214. <a class="btn radius btn-default" href="{:url('explorer')}"><i class="Hui-iconfont Hui-iconfont-pages"></i> 目录模式 </a>
  215. <a class="btn btn-danger radius" onclick="del_all();"><i class="Hui-iconfont Hui-iconfont-del2"></i>批量删除</a>
  216. <a class="btn btn-primary radius" onclick="uploadFile();"><i class="Hui-iconfont Hui-iconfont-add"></i>上传附件</a>
  217. <input type="file" id="upload_file" hidden multiple onchange="fileChange()">
  218. <div class="progress">
  219. <div></div>
  220. </div>
  221. </span>
  222. <span class="r">共有数据:<strong id="total">{$list->total()}</strong>条</span>
  223. </div>
  224. <div class="cl mt-20">
  225. <table class="table table-border table-bordered table-bg">
  226. <thead>
  227. <tr class="text-c">
  228. <th width="25px;">
  229. <input type="checkbox" name="allcheck" value="">
  230. </th>
  231. <th width="60px;">ID</th>
  232. <th>文件title</th>
  233. <th style="min-width: 260px;">文件路径</th>
  234. <th>文件类型</th>
  235. <th>文件大小</th>
  236. <th>增加者</th>
  237. <th>增加时间</th>
  238. <th width="100px;">操作</th>
  239. </tr>
  240. </thead>
  241. <tbody>
  242. {foreach $list as $val}
  243. <tr class="text-c">
  244. <td>
  245. <input type="checkbox" value="{$val.fileid}" name="checkbox[]">
  246. </td>
  247. <td>{$val.fileid}</td>
  248. <td class="text-l">{$val.title}</td>
  249. <td class="text-l">
  250. <a href="{$val.filepath}" title="{$val.filepath}" target="_blank">{$val.filepath}</a>
  251. </td>
  252. <td>{$val.fileextension}</td>
  253. <td>{$val.filesize|format_bytes}</td>
  254. <td>{$val.username}</td>
  255. <td>{$val.filetime|date="Y-m-d H:i:s"}</td>
  256. <td class="td-manager">
  257. <a class="btn btn-secondary radius" title="编辑title" onClick="editTitle('{$val.fileid}','{$val.title}')"><i
  258. class="Hui-iconfont Hui-iconfont-edit"></i></a>
  259. <a class="btn btn-danger radius" title="删除" onClick="del(this,'{$val.fileid}')"><i
  260. class="Hui-iconfont Hui-iconfont-del2"></i></a></td>
  261. </tr>
  262. {/foreach}
  263. </tbody>
  264. </table>
  265. </div>
  266. <div class="cl pd-5 bg-1 bk-gray mt-20 ">
  267. <span class="r">{$list->render()|raw}</span>
  268. </div>
  269. </article>
  270. <script>
  271. //通过点击图片来触发文件上传按钮
  272. function uploadFile(params) {
  273. $("#upload_file").click();
  274. }
  275. // 上传处理
  276. function fileChange() {
  277. let uploadFile = $("#upload_file").get(0).files;
  278. // console.log(uploadFile);
  279. if (uploadFile == undefined || uploadFile == null) {
  280. layer.msg("请选择文件", { icon: 5, time: 1000 });
  281. return false;
  282. }
  283. if (uploadFile.length > 20) {
  284. layer.msg("最多20个文件", { icon: 5, time: 1000 });
  285. return false;
  286. }
  287. let formData = new FormData();
  288. for (let i = 0; i < uploadFile.length; i++) {
  289. formData.append('upload_file[]', uploadFile[i]);
  290. }
  291. $.ajax({
  292. url: '{:url("file_manager/uploadFile")}',
  293. type: 'post',
  294. dataType: 'json',
  295. data: formData,
  296. processData: false,
  297. contentType: false,
  298. xhr: function () {
  299. var xhr = new XMLHttpRequest();
  300. //使用XMLHttpRequest.upload监听上传过程,注册progress事件,打印回调函数中的event事件
  301. xhr.upload.addEventListener('progress', function (e) {
  302. // console.log(e);
  303. //loaded代表上传了多少
  304. //total代表总数为多少
  305. var progressRate = (e.loaded / e.total) * 100 + '%';
  306. //通过设置进度条的宽度达到效果
  307. $('.progress > div').css('width', progressRate);
  308. })
  309. return xhr;
  310. },
  311. success: function (res) {
  312. console.log(res);
  313. if (res.code == 0) {
  314. layer.msg(res.msg, {
  315. icon: 1,
  316. time: 1000
  317. });
  318. window.location.reload();
  319. } else {
  320. layer.msg(res.msg, {
  321. icon: 5,
  322. time: 1000
  323. });
  324. return false;
  325. }
  326. }
  327. });
  328. }
  329. function editTitle(id, title) {
  330. if (id==0) {
  331. layer.msg('id不可为空', {icon: 5,time: 1000});
  332. }
  333. var content = '<div class="cl" style="padding:20px;">';
  334. content += '<label class="form-label col-sm-4">';
  335. content += '<span class="c-red">*</span>文件title:</label>';
  336. content += '<div class="formControls col-sm-6">';
  337. content += '<input type="text" class="input-text" name="filetile" id="filetile">';
  338. content += '</div><div class="col-3"></div></div></div>';
  339. layer.open({
  340. type: 1,
  341. area: ['500px', '200px'],
  342. title: '修改文件title',
  343. content: '\<\div style="padding:20px;">\<\span class="c-red">*\<\/span>文件title:\<\input type="text" class="input-text" name="filetitle" value="'+title+'" id="filetitle">\<\/div>',
  344. btn: ['确定', '取消'],
  345. yes: function(index, layero){
  346. let filetitle = document.querySelector('input[name="filetitle"]').value;
  347. $.ajax({
  348. url: '{:url("file_manager/updateFileTitle")}',
  349. type: 'post',
  350. dataType: 'json',
  351. contentType: 'application/json',
  352. data: JSON.stringify({
  353. id: id,
  354. filetitle: filetitle
  355. }),
  356. success: function (res) {
  357. if (res.code == 0) {
  358. layer.msg(res.msg, {
  359. icon: 1,
  360. time: 1000
  361. });
  362. window.location.reload();
  363. } else {
  364. layer.msg(res.msg, {
  365. icon: 5,
  366. time: 1000
  367. });
  368. }
  369. layer.close(index);
  370. }
  371. });
  372. }
  373. });
  374. // layer.open({
  375. // type: 2,
  376. // area: ['700px', '500px'],
  377. // fix: false, //不固定
  378. // maxmin: true,
  379. // shade: 0.4,
  380. // title: '添加标题图',
  381. // content: 'test'
  382. // });
  383. }
  384. >>>>>>> 78b76253c8ce5873016cf837373af5e30ac80c86
  385. </script>