| | |
| | | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| | | <script src="js/jquery.1.12.4.js"></script> |
| | | <script> |
| | | var data = null; |
| | | var path = "20221119094847"; |
| | | var url = "http://127.0.0.1:12316/"; |
| | | var token = "5e8b731c-0d9b-45d5-8781-23fd3bb8f526"; |
| | | |
| | | $(function () { |
| | | $("#pathSpan").html(path); |
| | | $("#tokenSpan").html(token); |
| | | }); |
| | | |
| | | // Ajax |
| | | function ajax(url, type, data, dataType, contentType, fn) { |
| | | $.ajax({ |
| | | url: url, |
| | | type: type, |
| | | data: data, |
| | | dataType: dataType || "json", // html、json、jsonp、script、text |
| | | contentType: contentType || "application/json", // "application/x-www-form-urlencoded" |
| | | success: function (data) { |
| | | fn(data); |
| | | }, |
| | | error: function (e) { |
| | | console.error(e); |
| | | fn(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | // 获取URL |
| | | function getUrl(method) { |
| | | return url + method + "?token=" + token; |
| | | } |
| | | </script> |
| | | <script> |
| | | // 下载地图 * |
| | | function downloadMap(guid) { |
| | | var a = document.createElement('a'); // 创建a标签 |
| | |
| | | } |
| | | </script> |
| | | <script> |
| | | var data = null; |
| | | var path = "20221119094847"; |
| | | var url = "http://127.0.0.1:12316/"; |
| | | var token = "1a19adf4-18d3-43b9-b51a-8fbba8240902"; |
| | | |
| | | $(function () { |
| | | $("#pathSpan").html(path); |
| | | $("#tokenSpan").html(token); |
| | | }); |
| | | |
| | | function ajax(url, type, data, dataType, contentType, fn) { |
| | | $.ajax({ |
| | | url: url, |
| | | type: type, |
| | | data: data, |
| | | dataType: dataType || "json", // html、json、jsonp、script、text |
| | | contentType: contentType || "application/json", // "application/x-www-form-urlencoded" |
| | | success: function (data) { |
| | | fn(data); |
| | | }, |
| | | error: function (e) { |
| | | console.error(e); |
| | | fn(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | function getUrl(method) { |
| | | return url + method + "?token=" + token; |
| | | } |
| | | |
| | | // 上传文件 |
| | | function uploadFiles() { |
| | | var formData = new FormData(); |
| | |
| | | }); |
| | | } |
| | | </script> |
| | | <script> |
| | | // 上传文件 |
| | | function uploadFiles2() { |
| | | var formData = new FormData(); |
| | | var fs = document.getElementById("file1"); |
| | | for (var i = 0, c = fs.files.length; i < c; i++) { |
| | | formData.append(fs.files[i].name, fs.files[i]); // fs.files[i].name,file |
| | | } |
| | | |
| | | $.ajax(getUrl("dataLoader/uploadFiles") + "&path=" + path, { |
| | | type: "post", |
| | | data: formData, |
| | | async: true, |
| | | cache: false, |
| | | processData: false, |
| | | contentType: false, |
| | | success: function (rs) { |
| | | document.getElementById("file1").value = ""; |
| | | console.log(rs); |
| | | alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result); |
| | | }, |
| | | error: function (e) { |
| | | document.getElementById("file1").value = ""; |
| | | console.error(e); |
| | | alert("上传文件失败!"); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | // 查询文件 |
| | | function selectFiles2() { |
| | | ajax(getUrl("dataLoader/selectFiles") + "&path=" + path, "GET", null, null, null, function (rs) { |
| | | console.log(rs); |
| | | alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result); |
| | | data = rs.result; |
| | | }); |
| | | } |
| | | |
| | | // 删除文件 |
| | | function deleteFiles2() { |
| | | if (data == null) return; |
| | | |
| | | ajax(getUrl("dataLoader/deleteFiles"), "POST", JSON.stringify([data[0]]), null, null, function (rs) { |
| | | console.log(rs); |
| | | alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result); |
| | | selectFiles(); |
| | | }); |
| | | } |
| | | |
| | | // Xls入库 |
| | | function insertXls() { |
| | | if (data == null) return; |
| | | |
| | | var obj = { |
| | | metaEntity: { |
| | | depid: 1, |
| | | dirid: 10, |
| | | verid: 0, |
| | | //type: "file", |
| | | //cs: "CGCS 2000", |
| | | //scale: "1:1000", |
| | | //resolution: "0.5m", |
| | | gather: "2022-10-05 15:00:00", |
| | | descr: "测试Xls", |
| | | }, |
| | | fileEntities: data, |
| | | tabEntities: [ |
| | | { fileName: "2-2 管线成果表.xlsx", tab: null, entity: "ddGdcg" }, |
| | | { fileName: "海原县中线成果表.xlsx", tab: null, entity: "mdZxcg" } |
| | | ] |
| | | }; |
| | | |
| | | ajax(getUrl("dataLoader/insertFiles"), "POST", JSON.stringify(obj), null, null, function (rs) { |
| | | console.log(rs); |
| | | data = null; |
| | | alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.result); |
| | | }); |
| | | } |
| | | </script> |
| | | </head> |
| | | <body> |
| | | <form id="upForm" name="upForm" method="post" enctype="multipart/form-data" action="http://127.0.0.1:12316/file/upload"> |
| | | 上传路径:<span id="pathSpan"></span>,当前令牌:<span id="tokenSpan"></span><br /> |
| | | 上传路径:<span id="pathSpan"></span>,当前令牌:<span id="tokenSpan"></span> |
| | | <hr /><br /><br /> |
| | | |
| | | 请选择文件: |
| | | 数据上传: |
| | | <input id="file1" name="file1" type="file" multiple="multiple" /> |
| | | <input value="上传文件" type="button" onclick="uploadFiles();" /> |
| | | <input value="查询文件" type="button" onclick="selectFiles();" /> |
| | | <input value="删除文件" type="button" onclick="deleteFiles();" /> |
| | | <input value="文件入库" type="button" onclick="insertFiles();" /> |
| | | <hr /><br /><br /> |
| | | |
| | | 数据入库: |
| | | <input id="file2" name="file2" type="file" multiple="multiple" accept=".xls,.xlsx,.mdb,.shp.zip,.gdb.zip" /> |
| | | <input value="上传文件" type="button" onclick="uploadFiles2();" /> |
| | | <input value="查询文件" type="button" onclick="selectFiles2();" /> |
| | | <input value="删除文件" type="button" onclick="deleteFiles2();" /> |
| | | <input value="Xls入库" type="button" onclick="insertXls();" /> |
| | | <hr /><br /><br /> |
| | | </form> |
| | | <br /> |
| | | <br /> |