Index.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <link rel="stylesheet" type="text/css" href="../Js/layui/font/iconfont.css" />
  5. <link rel="stylesheet" type="text/css" href="../Js/layui/css/layui.css" />
  6. <meta charset="utf-8" />
  7. <title>首页</title>
  8. <style>
  9. body {
  10. font-family: 'Microsoft YaHei';
  11. background-color: #F0F8FF;
  12. }
  13. ul .layui-icon {
  14. font-size: 18px !important;
  15. }
  16. tbody .layui-icon {
  17. font-size: 15px !important;
  18. }
  19. ul .iconfont {
  20. font-size: 18px !important;
  21. }
  22. tbody .iconfont {
  23. font-size: 15px !important;
  24. }
  25. th .headSpan {
  26. font-size: 18px;
  27. }
  28. .layui-breadcrumb {
  29. font-size: 12px;
  30. }
  31. /*.layui-table {
  32. box-shadow: 5px 5px 10px 5px rgba(0,0,0,0.1), -5px 5px 5px 5px rgba(0,0,0,0.1);
  33. }*/
  34. .webuploader-element-invisible label {
  35. background: unset;
  36. visibility: hidden;
  37. display: inherit;
  38. }
  39. .hidden {
  40. display:none;
  41. }
  42. .layui-nav {
  43. height:40px;
  44. }
  45. .layui-nav-item {
  46. line-height: 40px!important;
  47. }
  48. table tr td {
  49. margin: 5px;
  50. }
  51. table tr td a {
  52. margin:5px;
  53. }
  54. </style>
  55. </head>
  56. <body>
  57. <script src="../Js/layui/layui.all.js"></script>
  58. <script src="../Js/Common.js"></script>
  59. <div id="navigation"></div>
  60. <div style="padding: 50px;padding-top:10px;">
  61. <div id="breadcrumb"></div>
  62. <table class="layui-table">
  63. <colgroup>
  64. <col width="350">
  65. <col>
  66. </colgroup>
  67. <thead>
  68. <tr>
  69. <th><span class="headSpan" id="nameHead">Name</span></th>
  70. <th><span class="headSpan" id="fileSizeHead">Size</span></th>
  71. <th><span class="headSpan" id="createrHead">Creater</span></th>
  72. <th><span class="headSpan" id="createTimeHead">CreateTime</span></th>
  73. <th><span class="headSpan" id="operationsHead">Operations</span></th>
  74. </tr>
  75. </thead>
  76. <tbody id="foldersAndFiles">
  77. </tbody>
  78. </table>
  79. <div class="hidden" id="haveNoRight">
  80. <p style="color:coral">You have no permission, please contact the administrator</p>
  81. </div>
  82. </div>
  83. <script>
  84. var param = layui.getParams();
  85. var currUser = param.currUser;
  86. var currId = parseInt(param.currId);
  87. var lang = param.lang;
  88. if (!layui.isEmpty(lang)) {
  89. layui.setCurrentLan(lang);
  90. }
  91. var currRole = 0;
  92. upgradBread(currId);
  93. loadPage();
  94. layui.$("#haveNoRight>p").text(layui.translater("NoPermission"));
  95. layui.$("#nameHead").text(layui.translater("Name"));
  96. layui.$("#operationsHead").text(layui.translater("Operations"));
  97. layui.$("#fileSizeHead").text(layui.translater("FileSize"));
  98. layui.$("#createrHead").text(layui.translater("Creater"));
  99. layui.$("#createTimeHead").text(layui.translater("CreateTime"));
  100. function loadPage() {
  101. layui.doGet("/CloudDisk/User/GetUserByName", { name: currUser }, function (result) {
  102. if (layui.isEmpty(result)) {
  103. layui.$("#haveNoRight").removeClass("hidden");
  104. }
  105. else {
  106. layui.$("#haveNoRight").addClass("hidden");
  107. }
  108. currRole = result.role;
  109. layui.showTPL("#navigation", "/Views/navigationTPL.html", { role: currRole }, function () {
  110. layui.$("#refresh").click(function () {
  111. layui.clearLanguage();
  112. layui.initLanguage();
  113. location.href = "/Views/Index.html?currId=" + currId + "&currUser=" + currUser + "&lang=" + lang + "&time=" + new Date().getTime();
  114. });
  115. layui.$("#upload").click(function () {
  116. layer.open({
  117. type: 2
  118. , offset: 'auto'
  119. , title: ' '
  120. , shade: 0
  121. , area: ['316px', '290px']
  122. , id: 'uploadFileForm' //设定一个id,防止重复弹出
  123. , moveType: 0 //拖拽模式,0或者1
  124. , content: '/Views/upload.html?currId=' + currId + '&currUser=' + currUser
  125. , done: function () {
  126. loadPage();
  127. }
  128. });
  129. });
  130. layui.$("#add").click(function () {
  131. layer.open({
  132. type: 2
  133. , offset: 'auto'
  134. , title: ' '
  135. , shade: 0
  136. , area: ['530px', '221px']
  137. , id: 'addFolderForm' //设定一个id,防止重复弹出
  138. , moveType: 0 //拖拽模式,0或者1
  139. , content: '/Views/addFolder.html?currId=' + currId + '&currUser=' + currUser
  140. , done: function () {
  141. loadPage();
  142. }
  143. });
  144. });
  145. layui.$("#return").click(function () {
  146. var endBreadcrumb = 0;
  147. var breadcrumbList = localStorage.getItem("breadcrumbList");
  148. if (!layui.isEmpty(breadcrumbList)) {
  149. var start = breadcrumbList.lastIndexOf(',');
  150. endBreadcrumb = breadcrumbList.substring(start + 1);
  151. if (endBreadcrumb != "0") {
  152. var newBreadcrumb = breadcrumbList.substring(0, start);
  153. var endBreadcrumbIndex = newBreadcrumb.lastIndexOf(',');
  154. endBreadcrumb = newBreadcrumb.substring(endBreadcrumbIndex + 1);
  155. if (!layui.isEmpty(endBreadcrumb)) {
  156. localStorage.setItem("breadcrumbList", newBreadcrumb);
  157. }
  158. else {
  159. localStorage.setItem("breadcrumbList", "0");
  160. }
  161. }
  162. }
  163. currId = endBreadcrumb;
  164. loadPage();
  165. });
  166. });
  167. layui.doGet("/CloudDisk/FoldersAndFiles/GetFoldersAndFilesByFatherId", { fatherId: currId }, function (result) {
  168. var data = {
  169. items: result,
  170. currId: currId,
  171. role: currRole
  172. };
  173. layui.showTPL("#foldersAndFiles", "/Views/foldersAndFilesTPL.html", data);
  174. });
  175. var breadcrumbList = localStorage.getItem("breadcrumbList");
  176. layui.doPost("/CloudDisk/FoldersAndFiles/GetKeyValues", { breadcrumbList }, function (result) {
  177. var data = {
  178. items: result,
  179. currId: currId
  180. };
  181. layui.showTPL("#breadcrumb", "/Views/breadcrumbListTPL.html", data);
  182. });
  183. });
  184. }
  185. function enterFolder(refobj) {
  186. var data_id = layui.$(refobj).attr("data_id");
  187. var data_pass = layui.$(refobj).attr("data_pass");
  188. if (!layui.isEmpty(data_pass) && currRole<1) {
  189. layer.open({
  190. type: 2
  191. , offset: 'auto'
  192. , title: ' '
  193. , shade: 0
  194. , area: ['345px', '184px']
  195. , id: 'entryPassword' //设定一个id,防止重复弹出
  196. , moveType: 0 //拖拽模式,0或者1
  197. , content: '/Views/entryPassword.html?password=' + encodeURIComponent(data_pass) + "&data_id=" + data_id + "&type=1"
  198. , done: function () {
  199. loadPage();
  200. }
  201. });
  202. }
  203. else {
  204. upgradBread(data_id);
  205. }
  206. }
  207. function upgradBread(data_id) {
  208. currId = data_id;
  209. if (data_id!=null) {
  210. var breadcrumbList = localStorage.getItem("breadcrumbList");
  211. if (layui.isEmpty(breadcrumbList)) {
  212. if (data_id != "0") {
  213. data_id = "0," + data_id;
  214. }
  215. localStorage.setItem("breadcrumbList", data_id);
  216. }
  217. else {
  218. var currBread = breadcrumbList.split(',').find(function (f) { return parseInt(f) == parseInt(data_id); });
  219. if (layui.isEmpty(currBread)) {
  220. localStorage.setItem("breadcrumbList", (breadcrumbList + "," + data_id).trim(','));
  221. }
  222. else {
  223. var newBreadcrumbList = breadcrumbList.substring(0, ("," + breadcrumbList + ",").indexOf("," + data_id + ",") + data_id.toString().length);
  224. localStorage.setItem("breadcrumbList", newBreadcrumbList.trim(','));
  225. }
  226. }
  227. }
  228. loadPage();
  229. }
  230. function deleteFolderAndFiles(refobj) {
  231. var data_id = layui.$(refobj).attr("data_id");
  232. layer.confirm(layui.translater("DeleteConfirm"), { btn: [layui.translater("Confirm"), layui.translater("Cancel")], title: layui.translater("Reminder") }, function (index) {
  233. layui.doGet("/CloudDisk/FoldersAndFiles/DeleteFoldersAndFiles", { id: data_id }, function (back) {
  234. if (back.success) {
  235. loadPage();
  236. layer.close(index);
  237. }
  238. });
  239. });
  240. }
  241. function editFolderAndFiles(refobj) {
  242. var data_id = layui.$(refobj).attr("data_id");
  243. layer.open({
  244. type: 2
  245. , offset: 'auto'
  246. , title: ' '
  247. , shade: 0
  248. , area: ['530px', '221px']
  249. , id: 'EditFoldersAndFiles' //设定一个id,防止重复弹出
  250. , moveType: 0 //拖拽模式,0或者1
  251. , content: '/Views/editFoldersAndFiles.html?id=' + data_id + '&currUser=' + currUser
  252. , done: function () {
  253. loadPage();
  254. }
  255. });
  256. }
  257. var downloadUrl, fileName;
  258. function downloadFile(refobj) {
  259. downloadUrl = layui.$(refobj).attr("data_url");
  260. fileName = layui.$(refobj).attr("data_name");
  261. var data_pass = layui.$(refobj).attr("data_pass");
  262. if (!layui.isEmpty(data_pass) && currRole < 1) {
  263. layer.open({
  264. type: 2
  265. , offset: 'auto'
  266. , title: ' '
  267. , shade: 0
  268. , area: ['345px', '184px']
  269. , id: 'entryPassword' //设定一个id,防止重复弹出
  270. , moveType: 0 //拖拽模式,0或者1
  271. , content: '/Views/entryPassword.html?password=' + data_pass + "&type=0"
  272. , done: function () {
  273. loadPage();
  274. }
  275. });
  276. }
  277. else {
  278. doDownload();
  279. }
  280. }
  281. function doDownload() {
  282. layui.$("#tempDownload").remove();
  283. layui.$("body").append("<area id='tempDownload' target='_blank' style='display:none;' href='" + decodeURIComponent(downloadUrl) + "?fileName=" + decodeURIComponent(fileName) + "' download='" + decodeURIComponent(fileName) + "'></area>");
  284. layui.$("#tempDownload").click();
  285. }
  286. function dateFormat(time) {
  287. return layui.util.toDateString(time, "yyyy-MM-dd HH:mm");
  288. }
  289. function translater(key) {
  290. return layui.translater(key);
  291. }
  292. </script>
  293. </body>
  294. </html>