From d280269df15de55886280a951dd1b9c5989603f1 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期日, 20 十一月 2022 10:37:43 +0800 Subject: [PATCH] 1 --- ExportMap/up.html | 158 +++++++++++++++++++++++++++++++++++++++++----------- ExportMap/ExportMap.csproj | 2 2 files changed, 126 insertions(+), 34 deletions(-) diff --git a/ExportMap/ExportMap.csproj b/ExportMap/ExportMap.csproj index ec2af56..e8d8732 100644 --- a/ExportMap/ExportMap.csproj +++ b/ExportMap/ExportMap.csproj @@ -117,7 +117,7 @@ <Content Include="Sources\shps\SITEPOINT.shp.xml" /> <Content Include="Sources\shps\STATIONSERIES.shp.xml" /> <Content Include="Sources\shps\VALVEHOUSEPOINT.shp.xml" /> - <Content Include="Test.html" /> + <Content Include="export.html" /> <Content Include="up.html" /> <Content Include="Web.config"> <SubType>Designer</SubType> diff --git a/ExportMap/up.html b/ExportMap/up.html index 9617618..301b67d 100644 --- a/ExportMap/up.html +++ b/ExportMap/up.html @@ -5,6 +5,40 @@ <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銆乯son銆乯sonp銆乻cript銆乼ext + 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鏍囩 @@ -55,37 +89,6 @@ } </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銆乯son銆乯sonp銆乻cript銆乼ext - 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(); @@ -160,17 +163,106 @@ }); } </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 /> -- Gitblit v1.9.3