123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596 |
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>报告模板上传</title>
- <script src="js/jquery.min.js"></script>
- <style>
- html,
- body {
- height: 100%;
- margin: 0;
- padding: 0;
- }
- body {
- font-family: 'Roboto', sans-serif;
- background: -webkit-linear-gradient(bottom, #4F6072, #8699AA);
- background: linear-gradient(to top, #4F6072, #8699AA);
- display: -webkit-box;
- display: -ms-flexbox;
- display: flex;
- -webkit-box-pack: center;
- -ms-flex-pack: center;
- justify-content: center;
- -webkit-box-align: center;
- -ms-flex-align: center;
- align-items: center;
- }
- .upload {
- position: relative;
- width: 400px;
- min-height: 445px;
- box-sizing: border-box;
- border-radius: 5px;
- box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
- padding-bottom: 20px;
- background: #fff;
- -webkit-animation: fadeup .5s .5s ease both;
- animation: fadeup .5s .5s ease both;
- -webkit-transform: translateY(20px);
- transform: translateY(20px);
- opacity: 0;
- }
- .upload .upload-files header {
- background: #4db6ac;
- text-align: center;
- }
- .upload .upload-files header p {
- color: #fff;
- font-size: 40px;
- margin: 0;
- padding: 50px 0;
- }
- .upload .upload-files header p i {
- -webkit-transform: translateY(20px);
- transform: translateY(20px);
- opacity: 0;
- font-size: 30px;
- -webkit-animation: fadeup .5s 1s ease both;
- animation: fadeup .5s 1s ease both;
- }
- .upload .upload-files header p .up {
- font-weight: bold;
- -webkit-transform: translateX(-20px);
- transform: translateX(-20px);
- display: inline-block;
- opacity: 0;
- -webkit-animation: faderight .5s 1.5s ease both;
- animation: faderight .5s 1.5s ease both;
- }
- .upload .upload-files header p .load {
- display: inline-block;
- font-weight: 100;
- margin-left: -8px;
- -webkit-transform: translateX(-20px);
- transform: translateX(-20px);
- opacity: 0;
- -webkit-animation: faderight 1s 1.5s ease both;
- animation: faderight 1s 1.5s ease both;
- }
- .upload .upload-files .body {
- text-align: center;
- padding: 50px 0;
- padding-bottom: 30px;
- }
- .upload .upload-files .body.hidden {
- display: none;
- }
- .upload .upload-files .body input {
- visibility: hidden;
- }
- .upload .upload-files .body i {
- font-size: 65px;
- color: lightgray;
- }
- .upload .upload-files .body p {
- font-size: 14px;
- padding-top: 15px;
- line-height: 1.4;
- }
- .upload .upload-files .body p b,
- .upload .upload-files .body p a {
- color: #4db6ac;
- }
- .upload .upload-files .body.active {
- border: dashed 2px #4db6ac;
- }
- .upload .upload-files .body.active i {
- box-shadow: 0 0 0 -3px #fff, 0 0 0 lightgray, 0 0 0 -3px #fff, 0 0 0 lightgray;
- -webkit-animation: file .5s ease both;
- animation: file .5s ease both;
- }
- @-webkit-keyframes file {
- 50% {
- box-shadow: -8px 8px 0 -3px #fff, -8px 8px 0 lightgray, -8px 8px 0 -3px #fff, -8px 8px 0 lightgray;
- }
- 75%,
- 100% {
- box-shadow: -8px 8px 0 -3px #fff, -8px 8px 0 lightgray, -16px 16px 0 -3px #fff, -16px 16px 0 lightgray;
- }
- }
- @keyframes file {
- 50% {
- box-shadow: -8px 8px 0 -3px #fff, -8px 8px 0 lightgray, -8px 8px 0 -3px #fff, -8px 8px 0 lightgray;
- }
- 75%,
- 100% {
- box-shadow: -8px 8px 0 -3px #fff, -8px 8px 0 lightgray, -16px 16px 0 -3px #fff, -16px 16px 0 lightgray;
- }
- }
- .upload .upload-files .body.active .pointer-none {
- pointer-events: none;
- }
- .upload .upload-files footer {
- width: 100%;
- margin: 0 auto;
- height: 0;
- }
- .upload .upload-files footer .divider {
- margin: 0 auto;
- width: 0;
- border-top: solid 4px #46aba1;
- text-align: center;
- overflow: hidden;
- -webkit-transition: width .5s ease;
- transition: width .5s ease;
- }
- .upload .upload-files footer .divider span {
- display: inline-block;
- -webkit-transform: translateY(-25px);
- transform: translateY(-25px);
- font-size: 12px;
- padding-top: 8px;
- }
- .upload .upload-files footer.hasFiles {
- height: auto;
- }
- .upload .upload-files footer.hasFiles .divider {
- width: 100%;
- }
- .upload .upload-files footer.hasFiles .divider span {
- -webkit-transform: translateY(0);
- transform: translateY(0);
- -webkit-transition: -webkit-transform .5s .5s ease;
- transition: -webkit-transform .5s .5s ease;
- transition: transform .5s .5s ease;
- transition: transform .5s .5s ease, -webkit-transform .5s .5s ease;
- }
- .upload .upload-files footer .list-files {
- width: 320px;
- margin: 0 auto;
- margin-top: 15px;
- padding-left: 5px;
- text-align: center;
- overflow-x: hidden;
- overflow-y: auto;
- max-height: 210px;
- }
- .upload .upload-files footer .list-files::-webkit-scrollbar-track {
- background-color: rgba(211, 211, 211, 0.25);
- }
- .upload .upload-files footer .list-files::-webkit-scrollbar {
- width: 4px;
- background-color: rgba(211, 211, 211, 0.25);
- }
- .upload .upload-files footer .list-files::-webkit-scrollbar-thumb {
- background-color: rgba(77, 182, 172, 0.5);
- }
- .upload .upload-files footer .list-files .file {
- width: 300px;
- min-height: 50px;
- display: -webkit-box;
- display: -ms-flexbox;
- display: flex;
- -webkit-box-pack: justify;
- -ms-flex-pack: justify;
- justify-content: space-between;
- -webkit-box-align: center;
- -ms-flex-align: center;
- align-items: center;
- opacity: 0;
- -webkit-animation: fade .35s ease both;
- animation: fade .35s ease both;
- }
- .upload .upload-files footer .list-files .file .name {
- font-size: 12px;
- white-space: nowrap;
- text-overflow: ellipsis;
- overflow: hidden;
- width: 80px;
- text-align: left;
- }
- .upload .upload-files footer .list-files .file .progress {
- width: 175px;
- height: 5px;
- border: solid 1px lightgray;
- border-radius: 2px;
- background: -webkit-linear-gradient(right, rgba(77, 182, 172, 0.2), rgba(77, 182, 172, 0.8)) no-repeat;
- background: linear-gradient(to left, rgba(77, 182, 172, 0.2), rgba(77, 182, 172, 0.8)) no-repeat;
- background-size: 100% 100%;
- }
- .upload .upload-files footer .list-files .file .progress.active {
- -webkit-animation: progress 30s linear;
- animation: progress 30s linear;
- }
- @-webkit-keyframes progress {
- from {
- background-size: 0 100%;
- }
- to {
- background-size: 100% 100%;
- }
- }
- @keyframes progress {
- from {
- background-size: 0 100%;
- }
- to {
- background-size: 100% 100%;
- }
- }
- .upload .upload-files footer .list-files .file .done {
- cursor: pointer;
- width: 40px;
- height: 40px;
- background: #4db6ac;
- border-radius: 50%;
- margin-left: -10px;
- -webkit-transform: scale(0);
- transform: scale(0);
- position: relative;
- }
- .upload .upload-files footer .list-files .file .done:before {
- content: "View";
- position: absolute;
- top: 0;
- left: -5px;
- font-size: 24px;
- opacity: 0;
- }
- .upload .upload-files footer .list-files .file .done:hover:before {
- -webkit-transition: all .25s ease;
- transition: all .25s ease;
- top: -30px;
- opacity: 1;
- }
- .upload .upload-files footer .list-files .file .done.anim {
- -webkit-animation: done1 .5s ease forwards;
- animation: done1 .5s ease forwards;
- }
- .upload .upload-files footer .list-files .file .done.anim #path {
- -webkit-animation: done2 2.5s .5s ease forwards;
- animation: done2 2.5s .5s ease forwards;
- }
- .upload .upload-files footer .list-files .file .done #path {
- stroke-dashoffset: 7387.59423828125;
- stroke-dasharray: 7387.59423828125 7387.59423828125;
- stroke: #fff;
- fill: transparent;
- stroke-width: 50px;
- }
- @-webkit-keyframes done2 {
- to {
- stroke-dashoffset: 0;
- }
- }
- @keyframes done2 {
- to {
- stroke-dashoffset: 0;
- }
- }
- @-webkit-keyframes done1 {
- 50% {
- -webkit-transform: scale(0.5);
- transform: scale(0.5);
- opacity: 1;
- }
- 80% {
- -webkit-transform: scale(0.25);
- transform: scale(0.25);
- opacity: 1;
- }
- 100% {
- -webkit-transform: scale(0.5);
- transform: scale(0.5);
- opacity: 1;
- }
- }
- @keyframes done1 {
- 50% {
- -webkit-transform: scale(0.5);
- transform: scale(0.5);
- opacity: 1;
- }
- 80% {
- -webkit-transform: scale(0.25);
- transform: scale(0.25);
- opacity: 1;
- }
- 100% {
- -webkit-transform: scale(0.5);
- transform: scale(0.5);
- opacity: 1;
- }
- }
- .upload .upload-files footer .importar {
- outline: none;
- position: absolute;
- left: 0;
- right: 0;
- bottom: 20px;
- margin: auto;
- border: solid 1px #4db6ac;
- color: #4db6ac;
- background: transparent;
- padding: 8px 15px;
- font-size: 12px;
- border-radius: 4px;
- font-family: Roboto;
- line-height: 1;
- cursor: pointer;
- -webkit-transform: translateY(15px);
- transform: translateY(15px);
- opacity: 0;
- margin-left: calc(50% - 40px);
- }
- .upload .upload-files footer .importar.active {
- -webkit-transition: opacity .5s 1.5s ease, -webkit-transform .5s 1.5s ease;
- transition: opacity .5s 1.5s ease, -webkit-transform .5s 1.5s ease;
- transition: transform .5s 1.5s ease, opacity .5s 1.5s ease;
- transition: transform .5s 1.5s ease, opacity .5s 1.5s ease, -webkit-transform .5s 1.5s ease;
- -webkit-transform: translateY(0);
- transform: translateY(0);
- opacity: 1;
- }
- .upload .upload-files footer .importar:hover {
- background: #4db6ac;
- color: #fff;
- }
- @-webkit-keyframes fadeup {
- to {
- -webkit-transform: translateY(0);
- transform: translateY(0);
- opacity: 1;
- }
- }
- @keyframes fadeup {
- to {
- -webkit-transform: translateY(0);
- transform: translateY(0);
- opacity: 1;
- }
- }
- @-webkit-keyframes faderight {
- to {
- -webkit-transform: translateX(0);
- transform: translateX(0);
- opacity: 1;
- }
- }
- @keyframes faderight {
- to {
- -webkit-transform: translateX(0);
- transform: translateX(0);
- opacity: 1;
- }
- }
- @-webkit-keyframes fade {
- to {
- opacity: 1;
- }
- }
- @keyframes fade {
- to {
- opacity: 1;
- }
- }
- @media (max-width: 400px) {
- .upload {
- width: 100%;
- height: 100%;
- }
- }
- </style>
- </head>
- <body>
- <link rel="stylesheet" type="text/css" href="http://cdn.bootcss.com/font-awesome/4.6.0/css/font-awesome.min.css">
- <div class="upload">
- <div class="upload-files">
- <header>
- <p>
- <i class="fa fa-cloud-upload" aria-hidden="true"></i>
- <span class="up">up</span>
- <span class="load">load</span>
- </p>
- </header>
- <div class="body" id="drop">
- <i class="fa fa-file-text-o pointer-none" aria-hidden="true"></i>
- <!-- <p class="pointer-none"><b>拖放到这里</b> files here <br /> or <a href="" id="triggerFile">浏览</a>开始上传</p>-->
- <p class="pointer-none"><b>拖放到这里</b> files here <br /> or <a href="" id="triggerFile">浏览</a>开始上传</p>
- <input type="file" id="file" multiple />
- </div>
- <footer>
- <div class="divider">
- <span><AR>FILES</AR></span>
- </div>
- <div class="list-files">
- <!-- template -->
- </div>
- <button class="importar" onclick="UpladFile()">UPDATE FILES</button>
- <!-- <button class="importar" onclick="cancleUploadFile()">CALCLE FILES</button>-->
- </footer>
- </div>
- </div>
- <script type="application/javascript">
- //上传文件方法
- var xhr;
- function UpladFile() {
- var fileObj = document.getElementById("file").files[0]; // js 获取文件对象
- // var url = "http://127.0.0.1:8080" + "/generalReportTemplate"; // 接收上传文件的后台地址
- var url = "http://106.14.81.62:8080" + "/api/report/generalReportTemplate"; // 接收上传文件的后台地址
- var form = new FormData(); // FormData 对象
- form.append("file", fileObj); // 文件对象
- xhr = new XMLHttpRequest(); // XMLHttpRequest 对象
- xhr.open("post", url, true); //post方式,url为服务器请求地址,true 该参数规定请求是否异步处理。
- xhr.onload = uploadComplete; //请求完成
- xhr.onerror = uploadFailed; //请求失败
- xhr.send(form); //开始上传,发送form数据
- }
- //上传成功响应
- function uploadComplete(evt) {
- //服务断接收完文件返回的结果
- // console.log(evt.target.responseText);
- // var data = JSON.parse(evt.target.responseText);
- // console.log(data);
- // if (data.success) {
- //
- // } else {
- // alert("上传失败!");
- // }
- alert("上传成功!");
- }
- //上传失败
- function uploadFailed(evt) {
- alert("上传失败!");
- }
- </script>
- <script type="text/javascript">
- //DOM
- const $ = document.querySelector.bind(document);
- //APP
- let App = {};
- App.init = (function() {
- //Init
- function handleFileSelect(evt) {
- const files = evt.target.files; // FileList object
- //files template
- let template = `${Object.keys(files)
- .map(file => `<div class="file file--${file}">
- <div class="name"><span>${files[file].name}</span></div>
- <div class="progress active"></div>
- <div class="done">
- <a href="" target="_blank">
- <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">
- <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>
- </svg>
- </a>
- </div>
- </div>`)
- .join("")}`;
- $("#drop").classList.add("hidden");
- $("footer").classList.add("hasFiles");
- $(".importar").classList.add("active");
- setTimeout(() => {
- $(".list-files").innerHTML = template;
- }, 1000);
- Object.keys(files).forEach(file => {
- let load = 2000 + file * 2000; // fake load
- setTimeout(() => {
- $(`.file--${file}`).querySelector(".progress").classList.remove("active");
- $(`.file--${file}`).querySelector(".done").classList.add("anim");
- }, load);
- });
- }
- // trigger input
- $("#triggerFile").addEventListener("click", evt => {
- evt.preventDefault();
- $("input[type=file]").click();
- });
- // drop events
- $("#drop").ondragleave = evt => {
- $("#drop").classList.remove("active");
- evt.preventDefault();
- };
- $("#drop").ondragover = $("#drop").ondragenter = evt => {
- $("#drop").classList.add("active");
- evt.preventDefault();
- };
- $("#drop").ondrop = evt => {
- var files = evt.dataTransfer.files; // FileList object
- //files template
- let template = `${Object.keys(files)
- .map(file => `<div class="file file--${file}">
- <div class="name"><span>${files[file].name}</span></div>
- <div class="progress active"></div>
- <div class="done">
- <a href="" target="_blank">
- <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">
- <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>
- </svg>
- </a>
- </div>
- </div>`)
- .join("")}`;
- $("#drop").classList.add("hidden");
- $("footer").classList.add("hasFiles");
- $(".importar").classList.add("active");
- setTimeout(() => {
- $(".list-files").innerHTML = template;
- }, 1000);
- Object.keys(files).forEach(file => {
- let load = 2000 + file * 2000; // fake load
- setTimeout(() => {
- $(`.file--${file}`).querySelector(".progress").classList.remove("active");
- $(`.file--${file}`).querySelector(".done").classList.add("anim");
- }, load);
- });
- $("input[type=file]").files = evt.dataTransfer.files;
- var fileObj = document.getElementById("file").files[0];
- evt.preventDefault();
- // $("input[type=file]").files = evt.dataTransfer.files[0];
- // $("footer").classList.add("hasFiles");
- // $("#drop").classList.remove("active");
- // evt.preventDefault();
- };
- //upload more
- $(".importar").addEventListener("click", () => {
- $(".list-files").innerHTML = "";
- $("footer").classList.remove("hasFiles");
- $(".importar").classList.remove("active");
- setTimeout(() => {
- $("#drop").classList.remove("hidden");
- }, 500);
- });
- // input change
- $("input[type=file]").addEventListener("change", handleFileSelect);
- })();
- </script>
- </body>
- </html>
|