index.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>报告模板上传</title>
  6. <script src="js/jquery.min.js"></script>
  7. <style>
  8. html,
  9. body {
  10. height: 100%;
  11. margin: 0;
  12. padding: 0;
  13. }
  14. body {
  15. font-family: 'Roboto', sans-serif;
  16. background: -webkit-linear-gradient(bottom, #4F6072, #8699AA);
  17. background: linear-gradient(to top, #4F6072, #8699AA);
  18. display: -webkit-box;
  19. display: -ms-flexbox;
  20. display: flex;
  21. -webkit-box-pack: center;
  22. -ms-flex-pack: center;
  23. justify-content: center;
  24. -webkit-box-align: center;
  25. -ms-flex-align: center;
  26. align-items: center;
  27. }
  28. .upload {
  29. position: relative;
  30. width: 400px;
  31. min-height: 445px;
  32. box-sizing: border-box;
  33. border-radius: 5px;
  34. box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  35. padding-bottom: 20px;
  36. background: #fff;
  37. -webkit-animation: fadeup .5s .5s ease both;
  38. animation: fadeup .5s .5s ease both;
  39. -webkit-transform: translateY(20px);
  40. transform: translateY(20px);
  41. opacity: 0;
  42. }
  43. .upload .upload-files header {
  44. background: #4db6ac;
  45. text-align: center;
  46. }
  47. .upload .upload-files header p {
  48. color: #fff;
  49. font-size: 40px;
  50. margin: 0;
  51. padding: 50px 0;
  52. }
  53. .upload .upload-files header p i {
  54. -webkit-transform: translateY(20px);
  55. transform: translateY(20px);
  56. opacity: 0;
  57. font-size: 30px;
  58. -webkit-animation: fadeup .5s 1s ease both;
  59. animation: fadeup .5s 1s ease both;
  60. }
  61. .upload .upload-files header p .up {
  62. font-weight: bold;
  63. -webkit-transform: translateX(-20px);
  64. transform: translateX(-20px);
  65. display: inline-block;
  66. opacity: 0;
  67. -webkit-animation: faderight .5s 1.5s ease both;
  68. animation: faderight .5s 1.5s ease both;
  69. }
  70. .upload .upload-files header p .load {
  71. display: inline-block;
  72. font-weight: 100;
  73. margin-left: -8px;
  74. -webkit-transform: translateX(-20px);
  75. transform: translateX(-20px);
  76. opacity: 0;
  77. -webkit-animation: faderight 1s 1.5s ease both;
  78. animation: faderight 1s 1.5s ease both;
  79. }
  80. .upload .upload-files .body {
  81. text-align: center;
  82. padding: 50px 0;
  83. padding-bottom: 30px;
  84. }
  85. .upload .upload-files .body.hidden {
  86. display: none;
  87. }
  88. .upload .upload-files .body input {
  89. visibility: hidden;
  90. }
  91. .upload .upload-files .body i {
  92. font-size: 65px;
  93. color: lightgray;
  94. }
  95. .upload .upload-files .body p {
  96. font-size: 14px;
  97. padding-top: 15px;
  98. line-height: 1.4;
  99. }
  100. .upload .upload-files .body p b,
  101. .upload .upload-files .body p a {
  102. color: #4db6ac;
  103. }
  104. .upload .upload-files .body.active {
  105. border: dashed 2px #4db6ac;
  106. }
  107. .upload .upload-files .body.active i {
  108. box-shadow: 0 0 0 -3px #fff, 0 0 0 lightgray, 0 0 0 -3px #fff, 0 0 0 lightgray;
  109. -webkit-animation: file .5s ease both;
  110. animation: file .5s ease both;
  111. }
  112. @-webkit-keyframes file {
  113. 50% {
  114. box-shadow: -8px 8px 0 -3px #fff, -8px 8px 0 lightgray, -8px 8px 0 -3px #fff, -8px 8px 0 lightgray;
  115. }
  116. 75%,
  117. 100% {
  118. box-shadow: -8px 8px 0 -3px #fff, -8px 8px 0 lightgray, -16px 16px 0 -3px #fff, -16px 16px 0 lightgray;
  119. }
  120. }
  121. @keyframes file {
  122. 50% {
  123. box-shadow: -8px 8px 0 -3px #fff, -8px 8px 0 lightgray, -8px 8px 0 -3px #fff, -8px 8px 0 lightgray;
  124. }
  125. 75%,
  126. 100% {
  127. box-shadow: -8px 8px 0 -3px #fff, -8px 8px 0 lightgray, -16px 16px 0 -3px #fff, -16px 16px 0 lightgray;
  128. }
  129. }
  130. .upload .upload-files .body.active .pointer-none {
  131. pointer-events: none;
  132. }
  133. .upload .upload-files footer {
  134. width: 100%;
  135. margin: 0 auto;
  136. height: 0;
  137. }
  138. .upload .upload-files footer .divider {
  139. margin: 0 auto;
  140. width: 0;
  141. border-top: solid 4px #46aba1;
  142. text-align: center;
  143. overflow: hidden;
  144. -webkit-transition: width .5s ease;
  145. transition: width .5s ease;
  146. }
  147. .upload .upload-files footer .divider span {
  148. display: inline-block;
  149. -webkit-transform: translateY(-25px);
  150. transform: translateY(-25px);
  151. font-size: 12px;
  152. padding-top: 8px;
  153. }
  154. .upload .upload-files footer.hasFiles {
  155. height: auto;
  156. }
  157. .upload .upload-files footer.hasFiles .divider {
  158. width: 100%;
  159. }
  160. .upload .upload-files footer.hasFiles .divider span {
  161. -webkit-transform: translateY(0);
  162. transform: translateY(0);
  163. -webkit-transition: -webkit-transform .5s .5s ease;
  164. transition: -webkit-transform .5s .5s ease;
  165. transition: transform .5s .5s ease;
  166. transition: transform .5s .5s ease, -webkit-transform .5s .5s ease;
  167. }
  168. .upload .upload-files footer .list-files {
  169. width: 320px;
  170. margin: 0 auto;
  171. margin-top: 15px;
  172. padding-left: 5px;
  173. text-align: center;
  174. overflow-x: hidden;
  175. overflow-y: auto;
  176. max-height: 210px;
  177. }
  178. .upload .upload-files footer .list-files::-webkit-scrollbar-track {
  179. background-color: rgba(211, 211, 211, 0.25);
  180. }
  181. .upload .upload-files footer .list-files::-webkit-scrollbar {
  182. width: 4px;
  183. background-color: rgba(211, 211, 211, 0.25);
  184. }
  185. .upload .upload-files footer .list-files::-webkit-scrollbar-thumb {
  186. background-color: rgba(77, 182, 172, 0.5);
  187. }
  188. .upload .upload-files footer .list-files .file {
  189. width: 300px;
  190. min-height: 50px;
  191. display: -webkit-box;
  192. display: -ms-flexbox;
  193. display: flex;
  194. -webkit-box-pack: justify;
  195. -ms-flex-pack: justify;
  196. justify-content: space-between;
  197. -webkit-box-align: center;
  198. -ms-flex-align: center;
  199. align-items: center;
  200. opacity: 0;
  201. -webkit-animation: fade .35s ease both;
  202. animation: fade .35s ease both;
  203. }
  204. .upload .upload-files footer .list-files .file .name {
  205. font-size: 12px;
  206. white-space: nowrap;
  207. text-overflow: ellipsis;
  208. overflow: hidden;
  209. width: 80px;
  210. text-align: left;
  211. }
  212. .upload .upload-files footer .list-files .file .progress {
  213. width: 175px;
  214. height: 5px;
  215. border: solid 1px lightgray;
  216. border-radius: 2px;
  217. background: -webkit-linear-gradient(right, rgba(77, 182, 172, 0.2), rgba(77, 182, 172, 0.8)) no-repeat;
  218. background: linear-gradient(to left, rgba(77, 182, 172, 0.2), rgba(77, 182, 172, 0.8)) no-repeat;
  219. background-size: 100% 100%;
  220. }
  221. .upload .upload-files footer .list-files .file .progress.active {
  222. -webkit-animation: progress 30s linear;
  223. animation: progress 30s linear;
  224. }
  225. @-webkit-keyframes progress {
  226. from {
  227. background-size: 0 100%;
  228. }
  229. to {
  230. background-size: 100% 100%;
  231. }
  232. }
  233. @keyframes progress {
  234. from {
  235. background-size: 0 100%;
  236. }
  237. to {
  238. background-size: 100% 100%;
  239. }
  240. }
  241. .upload .upload-files footer .list-files .file .done {
  242. cursor: pointer;
  243. width: 40px;
  244. height: 40px;
  245. background: #4db6ac;
  246. border-radius: 50%;
  247. margin-left: -10px;
  248. -webkit-transform: scale(0);
  249. transform: scale(0);
  250. position: relative;
  251. }
  252. .upload .upload-files footer .list-files .file .done:before {
  253. content: "View";
  254. position: absolute;
  255. top: 0;
  256. left: -5px;
  257. font-size: 24px;
  258. opacity: 0;
  259. }
  260. .upload .upload-files footer .list-files .file .done:hover:before {
  261. -webkit-transition: all .25s ease;
  262. transition: all .25s ease;
  263. top: -30px;
  264. opacity: 1;
  265. }
  266. .upload .upload-files footer .list-files .file .done.anim {
  267. -webkit-animation: done1 .5s ease forwards;
  268. animation: done1 .5s ease forwards;
  269. }
  270. .upload .upload-files footer .list-files .file .done.anim #path {
  271. -webkit-animation: done2 2.5s .5s ease forwards;
  272. animation: done2 2.5s .5s ease forwards;
  273. }
  274. .upload .upload-files footer .list-files .file .done #path {
  275. stroke-dashoffset: 7387.59423828125;
  276. stroke-dasharray: 7387.59423828125 7387.59423828125;
  277. stroke: #fff;
  278. fill: transparent;
  279. stroke-width: 50px;
  280. }
  281. @-webkit-keyframes done2 {
  282. to {
  283. stroke-dashoffset: 0;
  284. }
  285. }
  286. @keyframes done2 {
  287. to {
  288. stroke-dashoffset: 0;
  289. }
  290. }
  291. @-webkit-keyframes done1 {
  292. 50% {
  293. -webkit-transform: scale(0.5);
  294. transform: scale(0.5);
  295. opacity: 1;
  296. }
  297. 80% {
  298. -webkit-transform: scale(0.25);
  299. transform: scale(0.25);
  300. opacity: 1;
  301. }
  302. 100% {
  303. -webkit-transform: scale(0.5);
  304. transform: scale(0.5);
  305. opacity: 1;
  306. }
  307. }
  308. @keyframes done1 {
  309. 50% {
  310. -webkit-transform: scale(0.5);
  311. transform: scale(0.5);
  312. opacity: 1;
  313. }
  314. 80% {
  315. -webkit-transform: scale(0.25);
  316. transform: scale(0.25);
  317. opacity: 1;
  318. }
  319. 100% {
  320. -webkit-transform: scale(0.5);
  321. transform: scale(0.5);
  322. opacity: 1;
  323. }
  324. }
  325. .upload .upload-files footer .importar {
  326. outline: none;
  327. position: absolute;
  328. left: 0;
  329. right: 0;
  330. bottom: 20px;
  331. margin: auto;
  332. border: solid 1px #4db6ac;
  333. color: #4db6ac;
  334. background: transparent;
  335. padding: 8px 15px;
  336. font-size: 12px;
  337. border-radius: 4px;
  338. font-family: Roboto;
  339. line-height: 1;
  340. cursor: pointer;
  341. -webkit-transform: translateY(15px);
  342. transform: translateY(15px);
  343. opacity: 0;
  344. margin-left: calc(50% - 40px);
  345. }
  346. .upload .upload-files footer .importar.active {
  347. -webkit-transition: opacity .5s 1.5s ease, -webkit-transform .5s 1.5s ease;
  348. transition: opacity .5s 1.5s ease, -webkit-transform .5s 1.5s ease;
  349. transition: transform .5s 1.5s ease, opacity .5s 1.5s ease;
  350. transition: transform .5s 1.5s ease, opacity .5s 1.5s ease, -webkit-transform .5s 1.5s ease;
  351. -webkit-transform: translateY(0);
  352. transform: translateY(0);
  353. opacity: 1;
  354. }
  355. .upload .upload-files footer .importar:hover {
  356. background: #4db6ac;
  357. color: #fff;
  358. }
  359. @-webkit-keyframes fadeup {
  360. to {
  361. -webkit-transform: translateY(0);
  362. transform: translateY(0);
  363. opacity: 1;
  364. }
  365. }
  366. @keyframes fadeup {
  367. to {
  368. -webkit-transform: translateY(0);
  369. transform: translateY(0);
  370. opacity: 1;
  371. }
  372. }
  373. @-webkit-keyframes faderight {
  374. to {
  375. -webkit-transform: translateX(0);
  376. transform: translateX(0);
  377. opacity: 1;
  378. }
  379. }
  380. @keyframes faderight {
  381. to {
  382. -webkit-transform: translateX(0);
  383. transform: translateX(0);
  384. opacity: 1;
  385. }
  386. }
  387. @-webkit-keyframes fade {
  388. to {
  389. opacity: 1;
  390. }
  391. }
  392. @keyframes fade {
  393. to {
  394. opacity: 1;
  395. }
  396. }
  397. @media (max-width: 400px) {
  398. .upload {
  399. width: 100%;
  400. height: 100%;
  401. }
  402. }
  403. </style>
  404. </head>
  405. <body>
  406. <link rel="stylesheet" type="text/css" href="http://cdn.bootcss.com/font-awesome/4.6.0/css/font-awesome.min.css">
  407. <div class="upload">
  408. <div class="upload-files">
  409. <header>
  410. <p>
  411. <i class="fa fa-cloud-upload" aria-hidden="true"></i>
  412. <span class="up">up</span>
  413. <span class="load">load</span>
  414. </p>
  415. </header>
  416. <div class="body" id="drop">
  417. <i class="fa fa-file-text-o pointer-none" aria-hidden="true"></i>
  418. <!-- <p class="pointer-none"><b>拖放到这里</b> files here <br /> or <a href="" id="triggerFile">浏览</a>开始上传</p>-->
  419. <p class="pointer-none"><b>拖放到这里</b> files here <br /> or <a href="" id="triggerFile">浏览</a>开始上传</p>
  420. <input type="file" id="file" multiple />
  421. </div>
  422. <footer>
  423. <div class="divider">
  424. <span><AR>FILES</AR></span>
  425. </div>
  426. <div class="list-files">
  427. <!-- template -->
  428. </div>
  429. <button class="importar" onclick="UpladFile()">UPDATE FILES</button>
  430. <!-- <button class="importar" onclick="cancleUploadFile()">CALCLE FILES</button>-->
  431. </footer>
  432. </div>
  433. </div>
  434. <script type="application/javascript">
  435. //上传文件方法
  436. var xhr;
  437. function UpladFile() {
  438. var fileObj = document.getElementById("file").files[0]; // js 获取文件对象
  439. // var url = "http://127.0.0.1:8080" + "/generalReportTemplate"; // 接收上传文件的后台地址
  440. var url = "http://106.14.81.62:8080" + "/api/report/generalReportTemplate"; // 接收上传文件的后台地址
  441. var form = new FormData(); // FormData 对象
  442. form.append("file", fileObj); // 文件对象
  443. xhr = new XMLHttpRequest(); // XMLHttpRequest 对象
  444. xhr.open("post", url, true); //post方式,url为服务器请求地址,true 该参数规定请求是否异步处理。
  445. xhr.onload = uploadComplete; //请求完成
  446. xhr.onerror = uploadFailed; //请求失败
  447. xhr.send(form); //开始上传,发送form数据
  448. }
  449. //上传成功响应
  450. function uploadComplete(evt) {
  451. //服务断接收完文件返回的结果
  452. // console.log(evt.target.responseText);
  453. // var data = JSON.parse(evt.target.responseText);
  454. // console.log(data);
  455. // if (data.success) {
  456. //
  457. // } else {
  458. // alert("上传失败!");
  459. // }
  460. alert("上传成功!");
  461. }
  462. //上传失败
  463. function uploadFailed(evt) {
  464. alert("上传失败!");
  465. }
  466. </script>
  467. <script type="text/javascript">
  468. //DOM
  469. const $ = document.querySelector.bind(document);
  470. //APP
  471. let App = {};
  472. App.init = (function() {
  473. //Init
  474. function handleFileSelect(evt) {
  475. const files = evt.target.files; // FileList object
  476. //files template
  477. let template = `${Object.keys(files)
  478. .map(file => `<div class="file file--${file}">
  479. <div class="name"><span>${files[file].name}</span></div>
  480. <div class="progress active"></div>
  481. <div class="done">
  482. <a href="" target="_blank">
  483. <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 1000 1000">
  484. <g><path id="path" d="M500,10C229.4,10,10,229.4,10,500c0,270.6,219.4,490,490,490c270.6,0,490-219.4,490-490C990,229.4,770.6,10,500,10z M500,967.7C241.7,967.7,32.3,758.3,32.3,500C32.3,241.7,241.7,32.3,500,32.3c258.3,0,467.7,209.4,467.7,467.7C967.7,758.3,758.3,967.7,500,967.7z M748.4,325L448,623.1L301.6,477.9c-4.4-4.3-11.4-4.3-15.8,0c-4.4,4.3-4.4,11.3,0,15.6l151.2,150c0.5,1.3,1.4,2.6,2.5,3.7c4.4,4.3,11.4,4.3,15.8,0l308.9-306.5c4.4-4.3,4.4-11.3,0-15.6C759.8,320.7,752.7,320.7,748.4,325z"</g>
  485. </svg>
  486. </a>
  487. </div>
  488. </div>`)
  489. .join("")}`;
  490. $("#drop").classList.add("hidden");
  491. $("footer").classList.add("hasFiles");
  492. $(".importar").classList.add("active");
  493. setTimeout(() => {
  494. $(".list-files").innerHTML = template;
  495. }, 1000);
  496. Object.keys(files).forEach(file => {
  497. let load = 2000 + file * 2000; // fake load
  498. setTimeout(() => {
  499. $(`.file--${file}`).querySelector(".progress").classList.remove("active");
  500. $(`.file--${file}`).querySelector(".done").classList.add("anim");
  501. }, load);
  502. });
  503. }
  504. // trigger input
  505. $("#triggerFile").addEventListener("click", evt => {
  506. evt.preventDefault();
  507. $("input[type=file]").click();
  508. });
  509. // drop events
  510. $("#drop").ondragleave = evt => {
  511. $("#drop").classList.remove("active");
  512. evt.preventDefault();
  513. };
  514. $("#drop").ondragover = $("#drop").ondragenter = evt => {
  515. $("#drop").classList.add("active");
  516. evt.preventDefault();
  517. };
  518. $("#drop").ondrop = evt => {
  519. var files = evt.dataTransfer.files; // FileList object
  520. //files template
  521. let template = `${Object.keys(files)
  522. .map(file => `<div class="file file--${file}">
  523. <div class="name"><span>${files[file].name}</span></div>
  524. <div class="progress active"></div>
  525. <div class="done">
  526. <a href="" target="_blank">
  527. <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 1000 1000">
  528. <g><path id="path" d="M500,10C229.4,10,10,229.4,10,500c0,270.6,219.4,490,490,490c270.6,0,490-219.4,490-490C990,229.4,770.6,10,500,10z M500,967.7C241.7,967.7,32.3,758.3,32.3,500C32.3,241.7,241.7,32.3,500,32.3c258.3,0,467.7,209.4,467.7,467.7C967.7,758.3,758.3,967.7,500,967.7z M748.4,325L448,623.1L301.6,477.9c-4.4-4.3-11.4-4.3-15.8,0c-4.4,4.3-4.4,11.3,0,15.6l151.2,150c0.5,1.3,1.4,2.6,2.5,3.7c4.4,4.3,11.4,4.3,15.8,0l308.9-306.5c4.4-4.3,4.4-11.3,0-15.6C759.8,320.7,752.7,320.7,748.4,325z"</g>
  529. </svg>
  530. </a>
  531. </div>
  532. </div>`)
  533. .join("")}`;
  534. $("#drop").classList.add("hidden");
  535. $("footer").classList.add("hasFiles");
  536. $(".importar").classList.add("active");
  537. setTimeout(() => {
  538. $(".list-files").innerHTML = template;
  539. }, 1000);
  540. Object.keys(files).forEach(file => {
  541. let load = 2000 + file * 2000; // fake load
  542. setTimeout(() => {
  543. $(`.file--${file}`).querySelector(".progress").classList.remove("active");
  544. $(`.file--${file}`).querySelector(".done").classList.add("anim");
  545. }, load);
  546. });
  547. $("input[type=file]").files = evt.dataTransfer.files;
  548. var fileObj = document.getElementById("file").files[0];
  549. evt.preventDefault();
  550. // $("input[type=file]").files = evt.dataTransfer.files[0];
  551. // $("footer").classList.add("hasFiles");
  552. // $("#drop").classList.remove("active");
  553. // evt.preventDefault();
  554. };
  555. //upload more
  556. $(".importar").addEventListener("click", () => {
  557. $(".list-files").innerHTML = "";
  558. $("footer").classList.remove("hasFiles");
  559. $(".importar").classList.remove("active");
  560. setTimeout(() => {
  561. $("#drop").classList.remove("hidden");
  562. }, 500);
  563. });
  564. // input change
  565. $("input[type=file]").addEventListener("change", handleFileSelect);
  566. })();
  567. </script>
  568. </body>
  569. </html>