<!DOCTYPE html>
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
<head>
|
<title>etown</title>
|
<meta http-equiv="Expires" content="0" />
|
<meta http-equiv="Cache" content="no-cache" />
|
<meta http-equiv="Pragma" content="no-cache" />
|
<meta http-equiv="Cache-control" content="no-cache" />
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<script src="js/jquery.1.12.4.js"></script>
|
<script src="js/rsa.min.js"></script>
|
<script src="js/rollups.js"></script>
|
<script src="js/turf.min.6.5.js"></script>
|
<script src="js/insertFiles.js"></script>
|
<script>
|
var app = {};
|
var path = "2024102801";
|
var url = "http://192.168.11.74:8085/"
|
|
$(function () {
|
$("#pathSpan").html(path);
|
});
|
|
// 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);
|
}
|
});
|
}
|
|
// 获取URL
|
function getUrl(method) {
|
return url + method + "?t=1";
|
}
|
</script>
|
<script>
|
// 查询目录
|
function selectPath() {
|
ajax(getUrl("meta/selectPath"), "GET", null, null, null, function (rs) {
|
console.log(rs);
|
alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.data);
|
path = rs.data;
|
});
|
}
|
|
// 上传文件
|
function uploadFiles() {
|
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("meta/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.data);
|
},
|
error: function (e) {
|
document.getElementById("file1").value = "";
|
console.error(e);
|
alert("上传文件失败!");
|
}
|
});
|
}
|
|
// 查询文件
|
function selectFiles() {
|
ajax(getUrl("meta/selectFiles") + "&path=" + path, "GET", null, null, null, function (rs) {
|
console.log(rs);
|
alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.data);
|
app.data = rs.data;
|
});
|
}
|
|
// 删除文件
|
function deleteFiles() {
|
if (app.data == null) return;
|
|
ajax(getUrl("meta/deleteFiles"), "POST", JSON.stringify([data[0]]), null, null, function (rs) {
|
console.log(rs);
|
alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.data);
|
selectFiles();
|
});
|
}
|
|
// 查询映射
|
function selectMappers() {
|
ajax(getUrl("meta/selectMappers") + "&path=" + path + "&dirid=1", "GET", null, null, null, function (rs) {
|
console.log(rs);
|
alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.data);
|
if (rs.code == 200) {
|
app.mappers = rs.data;
|
}
|
});
|
}
|
|
// 数据入库
|
function insertFiles() {
|
var data1 = [
|
{
|
"eventid": "fe2845ad-a03d-4037-aeb4-f09d3b704ed4",
|
"dep": null,
|
"dir": "00",
|
"name": "gallery.shp",
|
"type": "shp",
|
"guid": "dcbf69d1e47f577b47c722e65a289703",
|
"path": "2024102801_zip\\gallery.shp",
|
"sizes": 0.019,
|
"createUser": 1,
|
"createTime": null,
|
"extName": ".shp",
|
"tab": "gallery",
|
"entity": "gallery",
|
"rows": 0,
|
"records": 0,
|
"msg": null
|
}
|
];
|
var data2 = [
|
{
|
"eventid": "bcb30f34-30a2-444f-8bfa-c5615780aa18",
|
"dep": null,
|
"dir": "00",
|
"name": "inter_land.gdb\\land_planning",
|
"type": "gdb",
|
"guid": "8a3d080d26fd1d88e0d25ab9ec50b93b",
|
"path": "2024102801_zip\\inter_land.gdb",
|
"sizes": 0.221,
|
"createUser": 1,
|
"createTime": null,
|
"extName": ".gdb",
|
"tab": "land_planning",
|
"entity": "landPlanning",
|
"rows": 0,
|
"records": 0,
|
"msg": null
|
}
|
];
|
|
ajax(getUrl("meta/insertFiles"), "POST", JSON.stringify(data2), null, null, function (rs) {
|
console.log(rs);
|
alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.data);
|
});
|
}
|
// 上传附件
|
function uploadAttach() {
|
var formData = new FormData();
|
var fs = document.getElementById("file3");
|
if (fs.files.length == 0) {
|
alert("请选择要上传的文件!");
|
return;
|
}
|
for (var i = 0, c = fs.files.length; i < c; i++) {
|
formData.append("file", fs.files[i]); // fs.files[i].name,file
|
}
|
|
$.ajax(getUrl("dataQuery/uploadFiles") + "&tabName=lf.sys_style&eventid=fa25979a5ef8b43ba82a0be35b3fb0d4", {
|
type: "post",
|
data: formData,
|
async: true,
|
cache: false,
|
processData: false,
|
contentType: false,
|
success: function (rs) {
|
console.log(rs);
|
document.getElementById("file3").value = "";
|
alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.data);
|
},
|
error: function (e) {
|
console.error(e);
|
document.getElementById("file3").value = "";
|
alert("上传文件失败!");
|
}
|
});
|
}
|
</script>
|
<script>
|
// 元数据-请求下载
|
function metaDownloadReq() {
|
var obj = {
|
pwd: encrypt.encrypt("Test!321&456"),
|
ids: [1411, 1412, 8, 2140]
|
};
|
|
ajax(getUrl("meta/downloadReq"), "POST", JSON.stringify(obj), null, null, function (rs) {
|
console.log(rs);
|
alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.data);
|
});
|
}
|
|
// 下载文件
|
function selectDownloadFile() {
|
var guid = $.trim($("#fileId").val()); // var guid = "55269c88c147fb894c27e3de7076877d";
|
if (!guid) return;
|
var pwd = encodeURIComponent(encrypt.encrypt("Test!321&456")); // Admin@123
|
|
ajax(getUrl("meta/selectDownloadFile") + "&guid=" + guid + "&pwd=" + pwd, "GET", null, null, null, function (rs) {
|
console.log(rs);
|
//alert("code = " + rs.code + ", msg = " + rs.msg + ", result = " + rs.data);
|
if (rs.code != 200 || !rs.data) {
|
alert(rs.msg);
|
return;
|
}
|
|
downloadFile(guid, pwd);
|
});
|
}
|
|
function downloadFile(guid, pwd) {
|
//var a = document.createElement('a');
|
//a.style.display = 'none';
|
//a.href = getUrl("meta/downloadFile") + "&guid=" + guid + "&pwd=" + encodeURIComponent(encrypt.encrypt("Admin@123"));
|
|
//document.body.appendChild(a);
|
//a.click();
|
//document.body.removeChild(a);
|
|
var url = getUrl("meta/downloadFile") + "&guid=" + guid + "&pwd=" + pwd;
|
$("#downFrame").attr("src", url).click();
|
}
|
</script>
|
</head>
|
<body>
|
<!--<form id="upForm" name="upForm" method="post" enctype="multipart/form-data" action="http://127.0.0.1:12316/file/upload">-->
|
<form id="upForm" name="upForm" method="post" enctype="multipart/form-data" action="Upload/Post?path=2024102801">
|
上传路径:<span id="pathSpan"></span>
|
<hr />
|
<br />
|
|
数据入库:
|
<input id="file1" type="file" multiple="multiple" accept=".xls,.xlsx,.mdb,.zip" />
|
<input value="查询目录 *" type="button" onclick="selectPath();" />
|
<input value="上传文件" type="button" onclick="uploadFiles();" />
|
<input value="查询文件 *" type="button" onclick="selectFiles();" />
|
<input value="删除文件" type="button" onclick="deleteFiles();" />
|
<input value="查询映射 *" type="button" onclick="selectMappers();" />
|
<input value="数据入库 *" type="button" onclick="insertFiles();" />
|
<hr />
|
<br />
|
|
元数据:
|
<input value="请求下载" type="button" onclick="metaDownloadReq();" />
|
<input value="下载文件" type="button" onclick="selectDownloadFile();" />
|
<iframe id="downFrame" src="" style="display: none; border: 0; padding: 0; height: 0; width: 0"></iframe>
|
<hr />
|
<br />
|
</form>
|
<br />
|
<br />
|
</body>
|
</html>
|