Compare commits
4 Commits
ee194ffaa5
...
2ceb4e95fe
| Author | SHA1 | Date |
|---|---|---|
|
|
2ceb4e95fe | |
|
|
cada3b3877 | |
|
|
b2b8533074 | |
|
|
34dd3668fb |
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"method":"feixian",
|
||||
"feixian":{
|
||||
"name":"费县",
|
||||
"map":{
|
||||
"center":[],
|
||||
"zoom":10,
|
||||
"xianjieLayer":"http://175.27.168.120:8080/geoserver/feixian/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=feixian%3Axianjie&maxFeatures=50&outputFormat=application%2Fjson",
|
||||
"yingxiangLayer":"http://60.213.14.14:8060/geoserver/feixian/wms?service=WMS&version=1.1.0&request=GetMap&layers=feixian:yingxiang&styles=&bbox={bbox-epsg-3857}&width=256&height=256&srs=EPSG:3857&format=image/png&TRANSPARENT=TRUE"
|
||||
}
|
||||
},
|
||||
"pingyixian":{
|
||||
"name":"平邑县",
|
||||
"map":{
|
||||
"center":[117.7075,35.43222222],
|
||||
"zoom":9.7,
|
||||
"xianjieLayer":"http://175.27.168.120:8080/geoserver/linyishi/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=linyishi%3Axianjie&cql_filter=xzqdm%20like%20%27%25371326%25%27&maxFeatures=50&outputFormat=application%2Fjson",
|
||||
"yingxiangLayer":"http://175.27.168.120:8080/geoserver/pingyixian/wms?service=WMS&version=1.1.0&request=GetMap&layers=pingyixian:yingxiang&styles=&bbox={bbox-epsg-3857}&width=256&height=256&srs=EPSG:3857&format=image/png&TRANSPARENT=TRUE"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,145 @@
|
|||
.flex{
|
||||
display: flex;
|
||||
}
|
||||
.flex-1{
|
||||
flex: 1;
|
||||
}
|
||||
.wrap{
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.nowrap{
|
||||
flex-wrap: nowrap;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.row{
|
||||
flex-direction: row;
|
||||
}
|
||||
.column{
|
||||
flex-direction: column;
|
||||
}
|
||||
.hidden{
|
||||
overflow: hidden;
|
||||
}
|
||||
.auto{
|
||||
overflow: auto;
|
||||
}
|
||||
.ai-c{
|
||||
align-items: center;
|
||||
}
|
||||
.ai-e{
|
||||
align-items: end;
|
||||
}
|
||||
.jc-se{
|
||||
justify-content: space-evenly;
|
||||
}
|
||||
.jc-sa{
|
||||
justify-content: space-around;
|
||||
}
|
||||
.jc-sb{
|
||||
justify-content: space-between;
|
||||
}
|
||||
.jc-c{
|
||||
justify-content: center;
|
||||
}
|
||||
.jc-e{
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.mt-1{
|
||||
margin-top: 10px;
|
||||
}
|
||||
.mt-2{
|
||||
margin-top: 20px;
|
||||
}
|
||||
.mt-3{
|
||||
margin-top: 30px;
|
||||
}
|
||||
.ml-1{
|
||||
margin-left: 10px;
|
||||
}
|
||||
.ml-2{
|
||||
margin-left: 20px;
|
||||
}
|
||||
.ml-3{
|
||||
margin-left: 30px;
|
||||
}
|
||||
.mb-1{
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.mb-2{
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.mb-3{
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
.mr-1{
|
||||
margin-right: 10px;
|
||||
}
|
||||
.mr-2{
|
||||
margin-right: 20px;
|
||||
}
|
||||
.mr-3{
|
||||
margin-right: 30px;
|
||||
}
|
||||
.ta-c{
|
||||
text-align: center;
|
||||
}
|
||||
.ta-l{
|
||||
text-align: left;
|
||||
}
|
||||
.cursor{
|
||||
cursor: pointer;
|
||||
}
|
||||
.pos-r{
|
||||
position: relative;
|
||||
}
|
||||
.pos-a{
|
||||
position: absolute;
|
||||
}
|
||||
.pos-f{
|
||||
position: fixed;
|
||||
}
|
||||
.max-w{
|
||||
width: 100%;
|
||||
}
|
||||
.max-h{
|
||||
height: 100%;
|
||||
}
|
||||
.fz-12{
|
||||
font-size: 12px;
|
||||
}
|
||||
.fz-14{
|
||||
font-size: 14px;
|
||||
}
|
||||
.fz-16{
|
||||
font-size: 16px;
|
||||
}
|
||||
.fz-18{
|
||||
font-size: 18px;
|
||||
}
|
||||
.fz-20{
|
||||
font-size: 20px;
|
||||
}
|
||||
.fz-22{
|
||||
font-size: 22px;
|
||||
}
|
||||
.fz-24{
|
||||
font-size: 24px;
|
||||
}
|
||||
.fz-26{
|
||||
font-size: 26px;
|
||||
}
|
||||
.fz-28{
|
||||
font-size: 28px;
|
||||
}
|
||||
.fc-w{
|
||||
color: white;
|
||||
}
|
||||
.fc-b{
|
||||
color: black;
|
||||
}
|
||||
.fc-r{
|
||||
color: red;
|
||||
}
|
||||
.fw-b{
|
||||
font-weight: bold;
|
||||
}
|
||||
|
|
@ -0,0 +1,365 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>preview_demo</title>
|
||||
<link href="./common.css" rel="stylesheet">
|
||||
</head>
|
||||
<style>
|
||||
html, body {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
position:relative;
|
||||
}
|
||||
|
||||
.camera-dia{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0,0,0,0);
|
||||
position:relative;
|
||||
}
|
||||
.camera-box{
|
||||
width: 720px;
|
||||
height: 360px;
|
||||
border-radius: 5px;
|
||||
position: fixed;
|
||||
left:100%;
|
||||
top:100%;
|
||||
transform:translate(-50%,-50%);
|
||||
z-index: 9999;
|
||||
}
|
||||
.camera-header{
|
||||
width: 90%;
|
||||
margin-left: 5%;
|
||||
}
|
||||
.camera-header img{
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
}
|
||||
.camera-body{
|
||||
|
||||
width: 90%;
|
||||
height: 230px;
|
||||
/* border: 1px solid #fff; */
|
||||
margin-left: 5%;
|
||||
}
|
||||
.camera-footer{
|
||||
width: 90%;
|
||||
margin-left: 5%;
|
||||
color: #4371ec;
|
||||
text-align: left;
|
||||
margin-top: 8px;
|
||||
}
|
||||
.camera-footer span{
|
||||
margin-left: 5px;
|
||||
}
|
||||
.playWnd {
|
||||
width: 360px; /*播放容器的宽和高设定*/
|
||||
height: 230px;
|
||||
|
||||
}
|
||||
</style>
|
||||
|
||||
<body>
|
||||
<div class="camera-dia">
|
||||
<div class="camera-box">
|
||||
<div class="camera-header ">
|
||||
<span class="fz-16" id="carmerName"></span>
|
||||
<img src="../img/close.png" class="cursor" id="closeBtn" />
|
||||
</div>
|
||||
<div class="camera-body">
|
||||
<!--视频窗口展示-->
|
||||
<div id="playWnd" class="playWnd"></div>
|
||||
</div>
|
||||
<div class="camera-footer mt-1" style="display: none;">
|
||||
设备编号:<span id="carmerCard"></span>
|
||||
</div>
|
||||
<div style="display: none;" id="carmerAppKey"></div>
|
||||
<div style="display: none;" id="carmerIp"></div>
|
||||
<div style="display: none;" id="carmerPort"></div>
|
||||
<div style="display: none;" id="appSecret"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
<!--三个必要的js文件引入-->
|
||||
<script src="jquery-1.12.4.min.js"></script>
|
||||
<script src="jsencrypt.min.js"></script> <!-- 用于RSA加密 -->
|
||||
<script src="jsWebControl-1.0.0.min.js"></script> <!-- 用于前端与插件交互 -->
|
||||
|
||||
<script type="text/javascript">
|
||||
window.onload = () => {
|
||||
// 子页面接收消息
|
||||
window.addEventListener('message', function (e) {
|
||||
if (e.data) {
|
||||
console.log("play-data",e.data);
|
||||
$("#carmerName").text(e.data[0])
|
||||
$("#carmerCard").text(e.data[1])
|
||||
$("#carmerAppKey").text(e.data[2])
|
||||
$("#carmerIp").text(e.data[3])
|
||||
$("#carmerPort").text(e.data[4])
|
||||
$("#appSecret").text(e.data[5])
|
||||
}
|
||||
}, false)
|
||||
|
||||
initPlugin();
|
||||
}
|
||||
$("#closeBtn").click(function(){
|
||||
window.parent.postMessage(
|
||||
{
|
||||
cmd: 'close'
|
||||
}
|
||||
)
|
||||
})
|
||||
//页面加载时创建播放实例初始化
|
||||
$(window).load(function () {
|
||||
// initPlugin();
|
||||
});
|
||||
|
||||
//声明公用变量
|
||||
var initCount = 0;
|
||||
var pubKey = '';
|
||||
|
||||
// 创建播放实例
|
||||
function initPlugin () {
|
||||
oWebControl = new WebControl({
|
||||
szPluginContainer: "playWnd", // 指定容器id
|
||||
iServicePortStart: 15900, // 指定起止端口号,建议使用该值
|
||||
iServicePortEnd: 15909,
|
||||
szClassId:"23BF3B0A-2C56-4D97-9C03-0CB103AA8F11", // 用于IE10使用ActiveX的clsid
|
||||
cbConnectSuccess: function () { // 创建WebControl实例成功
|
||||
oWebControl.JS_StartService("window", { // WebControl实例创建成功后需要启动服务
|
||||
dllPath: "./VideoPluginConnect.dll" // 值"./VideoPluginConnect.dll"写死
|
||||
}).then(function () { // 启动插件服务成功
|
||||
oWebControl.JS_SetWindowControlCallback({ // 设置消息回调
|
||||
cbIntegrationCallBack: cbIntegrationCallBack
|
||||
});
|
||||
|
||||
oWebControl.JS_CreateWnd("playWnd", 400, 265).then(function () { //JS_CreateWnd创建视频播放窗口,宽高可设定
|
||||
init(); // 创建播放实例成功后初始化
|
||||
});
|
||||
}, function () { // 启动插件服务失败
|
||||
});
|
||||
},
|
||||
cbConnectError: function () { // 创建WebControl实例失败
|
||||
oWebControl = null;
|
||||
$("#playWnd").html("插件未启动,正在尝试启动,请稍候...");
|
||||
WebControl.JS_WakeUp("VideoWebPlugin://"); // 程序未启动时执行error函数,采用wakeup来启动程序
|
||||
initCount ++;
|
||||
if (initCount < 3) {
|
||||
setTimeout(function () {
|
||||
initPlugin();
|
||||
}, 3000)
|
||||
} else {
|
||||
window.parent.alertInstallVideoPlayer();
|
||||
$("#playWnd").html("插件启动失败,请检查插件是否安装!");
|
||||
}
|
||||
},
|
||||
cbConnectClose: function (bNormalClose) {
|
||||
// 异常断开:bNormalClose = false
|
||||
// JS_Disconnect正常断开:bNormalClose = true
|
||||
oWebControl = null;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// 设置窗口控制回调
|
||||
function setCallbacks() {
|
||||
oWebControl.JS_SetWindowControlCallback({
|
||||
cbIntegrationCallBack: cbIntegrationCallBack
|
||||
});
|
||||
}
|
||||
|
||||
// 推送消息
|
||||
function cbIntegrationCallBack(oData) {
|
||||
// showCBInfo(JSON.stringify(oData.responseMsg));
|
||||
}
|
||||
|
||||
//初始化
|
||||
function init()
|
||||
{
|
||||
getPubKey(function () {
|
||||
|
||||
////////////////////////////////// 请自行修改以下变量值 ////////////////////////////////////
|
||||
// var appkey = "21274765"; //综合安防管理平台提供的appkey,必填
|
||||
// var ip = "223.99.16.253"; //综合安防管理平台IP地址,必填
|
||||
// var port = 1443; //综合安防管理平台端口,若启用HTTPS协议,默认443
|
||||
|
||||
var appkey = $("#carmerAppKey").text(); //综合安防管理平台提供的appkey,必填
|
||||
var ip = $("#carmerIp").text(); //综合安防管理平台IP地址,必填
|
||||
var port = Number($("#carmerPort").text());
|
||||
var appSecret = $("#appSecret").text();
|
||||
console.log(appkey,ip,port,appSecret)
|
||||
// var secret = setEncrypt("tGJdjmKxKxVWtzp1M6px"); //综合安防管理平台提供的secret,必填
|
||||
var secret = setEncrypt(appSecret); //综合安防管理平台提供的secret,必填
|
||||
|
||||
var playMode = 0; //初始播放模式:0-预览,1-回放
|
||||
var snapDir = "D:\\SnapDir"; //抓图存储路径
|
||||
var videoDir = "D:\\VideoDir"; //紧急录像或录像剪辑存储路径
|
||||
var layout = "1x1"; //playMode指定模式的布局
|
||||
var enableHTTPS = 1; //是否启用HTTPS协议与综合安防管理平台交互,这里总是填1
|
||||
var encryptedFields = 'secret'; //加密字段,默认加密领域为secret
|
||||
var showToolbar = 1; //是否显示工具栏,0-不显示,非0-显示
|
||||
var showSmart = 1; //是否显示智能信息(如配置移动侦测后画面上的线框),0-不显示,非0-显示
|
||||
var buttonIDs = "0,16,256,257,258,259,260,512,513,514,515,516,517,768,769"; //自定义工具条按钮
|
||||
////////////////////////////////// 请自行修改以上变量值 ////////////////////////////////////
|
||||
|
||||
oWebControl.JS_RequestInterface({
|
||||
funcName: "init",
|
||||
argument: JSON.stringify({
|
||||
appkey: appkey, //API网关提供的appkey
|
||||
secret: secret, //API网关提供的secret
|
||||
ip: ip, //API网关IP地址
|
||||
playMode: playMode, //播放模式(决定显示预览还是回放界面)
|
||||
port: port, //端口
|
||||
snapDir: snapDir, //抓图存储路径
|
||||
videoDir: videoDir, //紧急录像或录像剪辑存储路径
|
||||
layout: layout, //布局
|
||||
enableHTTPS: enableHTTPS, //是否启用HTTPS协议
|
||||
encryptedFields: encryptedFields, //加密字段
|
||||
showToolbar: showToolbar, //是否显示工具栏
|
||||
showSmart: showSmart, //是否显示智能信息
|
||||
buttonIDs: buttonIDs //自定义工具条按钮
|
||||
})
|
||||
}).then(function (oData) {
|
||||
oWebControl.JS_Resize(400, 265); // 初始化后resize一次,规避firefox下首次显示窗口后插件窗口未与DIV窗口重合问题
|
||||
setWndCover();
|
||||
});
|
||||
// var cameraIndexCode = 'bbe9c64699174953828ce4fa8bb41b8f'; //获取输入的监控点编号值,必填
|
||||
var cameraIndexCode = $("#carmerCard").text()
|
||||
var streamMode = 0; //主子码流标识:0-主码流,1-子码流
|
||||
var transMode = 1; //传输协议:0-UDP,1-TCP
|
||||
var gpuMode = 0; //是否启用GPU硬解,0-不启用,1-启用
|
||||
var wndId = -1; //播放窗口序号(在2x2以上布局下可指定播放窗口)
|
||||
|
||||
cameraIndexCode = cameraIndexCode.replace(/(^\s*)/g, "");
|
||||
cameraIndexCode = cameraIndexCode.replace(/(\s*$)/g, "");
|
||||
|
||||
oWebControl.JS_RequestInterface({
|
||||
funcName: "startPreview",
|
||||
argument: JSON.stringify({
|
||||
cameraIndexCode:cameraIndexCode, //监控点编号
|
||||
streamMode: streamMode, //主子码流标识
|
||||
transMode: transMode, //传输协议
|
||||
gpuMode: gpuMode, //是否开启GPU硬解
|
||||
wndId:wndId //可指定播放窗口
|
||||
})
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
//获取公钥
|
||||
function getPubKey (callback) {
|
||||
oWebControl.JS_RequestInterface({
|
||||
funcName: "getRSAPubKey",
|
||||
argument: JSON.stringify({
|
||||
keyLength: 1024
|
||||
})
|
||||
}).then(function (oData) {
|
||||
if (oData.responseMsg.data) {
|
||||
pubKey = oData.responseMsg.data;
|
||||
callback()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//RSA加密
|
||||
function setEncrypt (value) {
|
||||
var encrypt = new JSEncrypt();
|
||||
encrypt.setPublicKey(pubKey);
|
||||
return encrypt.encrypt(value);
|
||||
}
|
||||
|
||||
// 监听resize事件,使插件窗口尺寸跟随DIV窗口变化
|
||||
$(window).resize(function () {
|
||||
if (oWebControl != null) {
|
||||
oWebControl.JS_Resize(400, 265);
|
||||
setWndCover();
|
||||
}
|
||||
});
|
||||
|
||||
// 监听滚动条scroll事件,使插件窗口跟随浏览器滚动而移动
|
||||
$(window).scroll(function () {
|
||||
if (oWebControl != null) {
|
||||
oWebControl.JS_Resize(400, 265);
|
||||
setWndCover();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 设置窗口裁剪,当因滚动条滚动导致窗口需要被遮住的情况下需要JS_CuttingPartWindow部分窗口
|
||||
function setWndCover() {
|
||||
var iWidth = $(window).width();
|
||||
var iHeight = $(window).height();
|
||||
var oDivRect = $("#playWnd").get(0).getBoundingClientRect();
|
||||
|
||||
var iCoverLeft = (oDivRect.left < 0) ? Math.abs(oDivRect.left): 0;
|
||||
var iCoverTop = (oDivRect.top < 0) ? Math.abs(oDivRect.top): 0;
|
||||
var iCoverRight = (oDivRect.right - iWidth > 0) ? Math.round(oDivRect.right - iWidth) : 0;
|
||||
var iCoverBottom = (oDivRect.bottom - iHeight > 0) ? Math.round(oDivRect.bottom - iHeight) : 0;
|
||||
|
||||
iCoverLeft = (iCoverLeft > 360) ? 360 : iCoverLeft;
|
||||
iCoverTop = (iCoverTop > 230) ? 230 : iCoverTop;
|
||||
iCoverRight = (iCoverRight > 360) ? 360 : iCoverRight;
|
||||
iCoverBottom = (iCoverBottom > 230) ? 230 : iCoverBottom;
|
||||
|
||||
oWebControl.JS_RepairPartWindow(0, 0, 1001, 230); // 多1个像素点防止还原后边界缺失一个像素条
|
||||
if (iCoverLeft != 0) {
|
||||
oWebControl.JS_CuttingPartWindow(0, 0, iCoverLeft, 230);
|
||||
}
|
||||
if (iCoverTop != 0) {
|
||||
oWebControl.JS_CuttingPartWindow(0, 0, 1001, iCoverTop); // 多剪掉一个像素条,防止出现剪掉一部分窗口后出现一个像素条
|
||||
}
|
||||
if (iCoverRight != 0) {
|
||||
oWebControl.JS_CuttingPartWindow(360 - iCoverRight, 0, iCoverRight, 230);
|
||||
}
|
||||
if (iCoverBottom != 0) {
|
||||
oWebControl.JS_CuttingPartWindow(0, 230 - iCoverBottom, 360, iCoverBottom);
|
||||
}
|
||||
}
|
||||
|
||||
//视频预览功能
|
||||
$("#startPreview").click(function () {
|
||||
var cameraIndexCode = 'bbe9c64699174953828ce4fa8bb41b8f'; //获取输入的监控点编号值,必填
|
||||
var streamMode = 0; //主子码流标识:0-主码流,1-子码流
|
||||
var transMode = 1; //传输协议:0-UDP,1-TCP
|
||||
var gpuMode = 0; //是否启用GPU硬解,0-不启用,1-启用
|
||||
var wndId = -1; //播放窗口序号(在2x2以上布局下可指定播放窗口)
|
||||
|
||||
cameraIndexCode = cameraIndexCode.replace(/(^\s*)/g, "");
|
||||
cameraIndexCode = cameraIndexCode.replace(/(\s*$)/g, "");
|
||||
|
||||
oWebControl.JS_RequestInterface({
|
||||
funcName: "startPreview",
|
||||
argument: JSON.stringify({
|
||||
cameraIndexCode:cameraIndexCode, //监控点编号
|
||||
streamMode: streamMode, //主子码流标识
|
||||
transMode: transMode, //传输协议
|
||||
gpuMode: gpuMode, //是否开启GPU硬解
|
||||
wndId:wndId //可指定播放窗口
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
//停止全部预览
|
||||
$("#stopAllPreview").click(function () {
|
||||
oWebControl.JS_RequestInterface({
|
||||
funcName: "stopAllPreview"
|
||||
});
|
||||
});
|
||||
|
||||
// 标签关闭
|
||||
$(window).unload(function () {
|
||||
if (oWebControl != null){
|
||||
oWebControl.JS_HideWnd(); // 先让窗口隐藏,规避可能的插件窗口滞后于浏览器消失问题
|
||||
oWebControl.JS_Disconnect().then(function(){ // 断开与插件服务连接成功
|
||||
},
|
||||
function() { // 断开与插件服务连接失败
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,318 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>preview_demo</title>
|
||||
<link href="../../common.css" rel="stylesheet">
|
||||
</head>
|
||||
<style>
|
||||
html, body {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.camera-dia{
|
||||
/* width: 100vw;
|
||||
height: 100vh; */
|
||||
}
|
||||
.camera-box{
|
||||
width: 180px;
|
||||
height: 115px;
|
||||
background: rgba(19,21,35,.9);
|
||||
box-shadow: 0 0 0.0625rem 0.3125rem hsl(0deg 0% 100% / 10%);
|
||||
border: 1px solid #386df5;
|
||||
border-radius: 5px;
|
||||
position: fixed;
|
||||
right: 20px;
|
||||
bottom: 130px;
|
||||
z-index: 999;
|
||||
padding: 10px;
|
||||
}
|
||||
.camera-body{
|
||||
width: 100%;
|
||||
height: 115px;
|
||||
border: 1px solid #fff;
|
||||
}
|
||||
|
||||
.playWnd {
|
||||
width: 180px; /*播放容器的宽和高设定*/
|
||||
height: 115px;
|
||||
|
||||
}
|
||||
</style>
|
||||
|
||||
<body>
|
||||
<div class="camera-dia">
|
||||
<div class="camera-box fc-w fz-14">
|
||||
<div class="camera-body pos-r">
|
||||
<!--视频窗口展示-->
|
||||
<div id="playWnd" class="playWnd"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="carmerCard" style="display: none;"></div>
|
||||
</body>
|
||||
|
||||
<!--三个必要的js文件引入-->
|
||||
<script src="jquery-1.12.4.min.js"></script>
|
||||
<script src="jsencrypt.min.js"></script> <!-- 用于RSA加密 -->
|
||||
<script src="jsWebControl-1.0.0.min.js"></script> <!-- 用于前端与插件交互 -->
|
||||
|
||||
<script type="text/javascript">
|
||||
window.onload = () => {
|
||||
// 子页面接收消息
|
||||
window.addEventListener('message', function (e) {
|
||||
if (e.data) {
|
||||
$("#carmerCard").text(e.data[0])
|
||||
}
|
||||
}, false)
|
||||
}
|
||||
$("#closeBtn").click(function(){
|
||||
window.parent.postMessage(
|
||||
{
|
||||
cmd: 'close'
|
||||
}
|
||||
)
|
||||
})
|
||||
//页面加载时创建播放实例初始化
|
||||
$(window).load(function () {
|
||||
initPlugin();
|
||||
});
|
||||
|
||||
//声明公用变量
|
||||
var initCount = 0;
|
||||
var pubKey = '';
|
||||
|
||||
// 创建播放实例
|
||||
function initPlugin () {
|
||||
oWebControl = new WebControl({
|
||||
szPluginContainer: "playWnd", // 指定容器id
|
||||
iServicePortStart: 15900, // 指定起止端口号,建议使用该值
|
||||
iServicePortEnd: 15909,
|
||||
szClassId:"23BF3B0A-2C56-4D97-9C03-0CB103AA8F11", // 用于IE10使用ActiveX的clsid
|
||||
cbConnectSuccess: function () { // 创建WebControl实例成功
|
||||
oWebControl.JS_StartService("window", { // WebControl实例创建成功后需要启动服务
|
||||
dllPath: "./VideoPluginConnect.dll" // 值"./VideoPluginConnect.dll"写死
|
||||
}).then(function () { // 启动插件服务成功
|
||||
oWebControl.JS_SetWindowControlCallback({ // 设置消息回调
|
||||
cbIntegrationCallBack: cbIntegrationCallBack
|
||||
});
|
||||
|
||||
oWebControl.JS_CreateWnd("playWnd", 180, 115).then(function () { //JS_CreateWnd创建视频播放窗口,宽高可设定
|
||||
init(); // 创建播放实例成功后初始化
|
||||
});
|
||||
}, function () { // 启动插件服务失败
|
||||
});
|
||||
},
|
||||
cbConnectError: function () { // 创建WebControl实例失败
|
||||
oWebControl = null;
|
||||
$("#playWnd").html("插件未启动,正在尝试启动,请稍候...");
|
||||
WebControl.JS_WakeUp("VideoWebPlugin://"); // 程序未启动时执行error函数,采用wakeup来启动程序
|
||||
initCount ++;
|
||||
if (initCount < 3) {
|
||||
setTimeout(function () {
|
||||
initPlugin();
|
||||
}, 3000)
|
||||
} else {
|
||||
$("#playWnd").html("插件启动失败,请检查插件是否安装!");
|
||||
}
|
||||
},
|
||||
cbConnectClose: function (bNormalClose) {
|
||||
// 异常断开:bNormalClose = false
|
||||
// JS_Disconnect正常断开:bNormalClose = true
|
||||
oWebControl = null;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// 设置窗口控制回调
|
||||
function setCallbacks() {
|
||||
oWebControl.JS_SetWindowControlCallback({
|
||||
cbIntegrationCallBack: cbIntegrationCallBack
|
||||
});
|
||||
}
|
||||
|
||||
// 推送消息
|
||||
function cbIntegrationCallBack(oData) {
|
||||
// showCBInfo(JSON.stringify(oData.responseMsg));
|
||||
}
|
||||
|
||||
//初始化
|
||||
function init()
|
||||
{
|
||||
getPubKey(function () {
|
||||
|
||||
////////////////////////////////// 请自行修改以下变量值 ////////////////////////////////////
|
||||
var appkey = "21274765"; //综合安防管理平台提供的appkey,必填
|
||||
var secret = setEncrypt("CraRtGvpNB2xOcYSFTov"); //综合安防管理平台提供的secret,必填
|
||||
var ip = "223.99.16.253"; //综合安防管理平台IP地址,必填
|
||||
var playMode = 0; //初始播放模式:0-预览,1-回放
|
||||
var port = 1443; //综合安防管理平台端口,若启用HTTPS协议,默认443
|
||||
var snapDir = "D:\\SnapDir"; //抓图存储路径
|
||||
var videoDir = "D:\\VideoDir"; //紧急录像或录像剪辑存储路径
|
||||
var layout = "1x1"; //playMode指定模式的布局
|
||||
var enableHTTPS = 1; //是否启用HTTPS协议与综合安防管理平台交互,这里总是填1
|
||||
var encryptedFields = 'secret'; //加密字段,默认加密领域为secret
|
||||
var showToolbar = 1; //是否显示工具栏,0-不显示,非0-显示
|
||||
var showSmart = 1; //是否显示智能信息(如配置移动侦测后画面上的线框),0-不显示,非0-显示
|
||||
var buttonIDs = "0,16,256,257,258,259,260,512,513,514,515,516,517,768,769"; //自定义工具条按钮
|
||||
////////////////////////////////// 请自行修改以上变量值 ////////////////////////////////////
|
||||
|
||||
oWebControl.JS_RequestInterface({
|
||||
funcName: "init",
|
||||
argument: JSON.stringify({
|
||||
appkey: appkey, //API网关提供的appkey
|
||||
secret: secret, //API网关提供的secret
|
||||
ip: ip, //API网关IP地址
|
||||
playMode: playMode, //播放模式(决定显示预览还是回放界面)
|
||||
port: port, //端口
|
||||
snapDir: snapDir, //抓图存储路径
|
||||
videoDir: videoDir, //紧急录像或录像剪辑存储路径
|
||||
layout: layout, //布局
|
||||
enableHTTPS: enableHTTPS, //是否启用HTTPS协议
|
||||
encryptedFields: encryptedFields, //加密字段
|
||||
showToolbar: showToolbar, //是否显示工具栏
|
||||
showSmart: showSmart, //是否显示智能信息
|
||||
buttonIDs: buttonIDs //自定义工具条按钮
|
||||
})
|
||||
}).then(function (oData) {
|
||||
oWebControl.JS_Resize(180, 115); // 初始化后resize一次,规避firefox下首次显示窗口后插件窗口未与DIV窗口重合问题
|
||||
setWndCover();
|
||||
});
|
||||
// var cameraIndexCode = 'bbe9c64699174953828ce4fa8bb41b8f'; //获取输入的监控点编号值,必填
|
||||
var cameraIndexCode = $("#carmerCard").text()
|
||||
var streamMode = 0; //主子码流标识:0-主码流,1-子码流
|
||||
var transMode = 1; //传输协议:0-UDP,1-TCP
|
||||
var gpuMode = 0; //是否启用GPU硬解,0-不启用,1-启用
|
||||
var wndId = -1; //播放窗口序号(在2x2以上布局下可指定播放窗口)
|
||||
|
||||
cameraIndexCode = cameraIndexCode.replace(/(^\s*)/g, "");
|
||||
cameraIndexCode = cameraIndexCode.replace(/(\s*$)/g, "");
|
||||
|
||||
oWebControl.JS_RequestInterface({
|
||||
funcName: "startPreview",
|
||||
argument: JSON.stringify({
|
||||
cameraIndexCode:cameraIndexCode, //监控点编号
|
||||
streamMode: streamMode, //主子码流标识
|
||||
transMode: transMode, //传输协议
|
||||
gpuMode: gpuMode, //是否开启GPU硬解
|
||||
wndId:wndId //可指定播放窗口
|
||||
})
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
//获取公钥
|
||||
function getPubKey (callback) {
|
||||
oWebControl.JS_RequestInterface({
|
||||
funcName: "getRSAPubKey",
|
||||
argument: JSON.stringify({
|
||||
keyLength: 1024
|
||||
})
|
||||
}).then(function (oData) {
|
||||
if (oData.responseMsg.data) {
|
||||
pubKey = oData.responseMsg.data;
|
||||
callback()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//RSA加密
|
||||
function setEncrypt (value) {
|
||||
var encrypt = new JSEncrypt();
|
||||
encrypt.setPublicKey(pubKey);
|
||||
return encrypt.encrypt(value);
|
||||
}
|
||||
|
||||
// 监听resize事件,使插件窗口尺寸跟随DIV窗口变化
|
||||
$(window).resize(function () {
|
||||
if (oWebControl != null) {
|
||||
oWebControl.JS_Resize(180, 115);
|
||||
setWndCover();
|
||||
}
|
||||
});
|
||||
|
||||
// 监听滚动条scroll事件,使插件窗口跟随浏览器滚动而移动
|
||||
$(window).scroll(function () {
|
||||
if (oWebControl != null) {
|
||||
oWebControl.JS_Resize(180, 115);
|
||||
setWndCover();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 设置窗口裁剪,当因滚动条滚动导致窗口需要被遮住的情况下需要JS_CuttingPartWindow部分窗口
|
||||
function setWndCover() {
|
||||
var iWidth = $(window).width();
|
||||
var iHeight = $(window).height();
|
||||
var oDivRect = $("#playWnd").get(0).getBoundingClientRect();
|
||||
|
||||
var iCoverLeft = (oDivRect.left < 0) ? Math.abs(oDivRect.left): 0;
|
||||
var iCoverTop = (oDivRect.top < 0) ? Math.abs(oDivRect.top): 0;
|
||||
var iCoverRight = (oDivRect.right - iWidth > 0) ? Math.round(oDivRect.right - iWidth) : 0;
|
||||
var iCoverBottom = (oDivRect.bottom - iHeight > 0) ? Math.round(oDivRect.bottom - iHeight) : 0;
|
||||
|
||||
iCoverLeft = (iCoverLeft > 180) ? 180 : iCoverLeft;
|
||||
iCoverTop = (iCoverTop > 115) ? 115 : iCoverTop;
|
||||
iCoverRight = (iCoverRight > 180) ? 180 : iCoverRight;
|
||||
iCoverBottom = (iCoverBottom > 115) ? 115 : iCoverBottom;
|
||||
|
||||
oWebControl.JS_RepairPartWindow(0, 0, 1001, 115); // 多1个像素点防止还原后边界缺失一个像素条
|
||||
if (iCoverLeft != 0) {
|
||||
oWebControl.JS_CuttingPartWindow(0, 0, iCoverLeft, 115);
|
||||
}
|
||||
if (iCoverTop != 0) {
|
||||
oWebControl.JS_CuttingPartWindow(0, 0, 1001, iCoverTop); // 多剪掉一个像素条,防止出现剪掉一部分窗口后出现一个像素条
|
||||
}
|
||||
if (iCoverRight != 0) {
|
||||
oWebControl.JS_CuttingPartWindow(180 - iCoverRight, 0, iCoverRight, 115);
|
||||
}
|
||||
if (iCoverBottom != 0) {
|
||||
oWebControl.JS_CuttingPartWindow(0, 115 - iCoverBottom, 180, iCoverBottom);
|
||||
}
|
||||
}
|
||||
|
||||
//视频预览功能
|
||||
$("#startPreview").click(function () {
|
||||
var cameraIndexCode = 'bbe9c64699174953828ce4fa8bb41b8f'; //获取输入的监控点编号值,必填
|
||||
var streamMode = 0; //主子码流标识:0-主码流,1-子码流
|
||||
var transMode = 1; //传输协议:0-UDP,1-TCP
|
||||
var gpuMode = 0; //是否启用GPU硬解,0-不启用,1-启用
|
||||
var wndId = -1; //播放窗口序号(在2x2以上布局下可指定播放窗口)
|
||||
|
||||
cameraIndexCode = cameraIndexCode.replace(/(^\s*)/g, "");
|
||||
cameraIndexCode = cameraIndexCode.replace(/(\s*$)/g, "");
|
||||
|
||||
oWebControl.JS_RequestInterface({
|
||||
funcName: "startPreview",
|
||||
argument: JSON.stringify({
|
||||
cameraIndexCode:cameraIndexCode, //监控点编号
|
||||
streamMode: streamMode, //主子码流标识
|
||||
transMode: transMode, //传输协议
|
||||
gpuMode: gpuMode, //是否开启GPU硬解
|
||||
wndId:wndId //可指定播放窗口
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
//停止全部预览
|
||||
$("#stopAllPreview").click(function () {
|
||||
oWebControl.JS_RequestInterface({
|
||||
funcName: "stopAllPreview"
|
||||
});
|
||||
});
|
||||
|
||||
// 标签关闭
|
||||
$(window).unload(function () {
|
||||
if (oWebControl != null){
|
||||
oWebControl.JS_HideWnd(); // 先让窗口隐藏,规避可能的插件窗口滞后于浏览器消失问题
|
||||
oWebControl.JS_Disconnect().then(function(){ // 断开与插件服务连接成功
|
||||
},
|
||||
function() { // 断开与插件服务连接失败
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,318 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>preview_demo</title>
|
||||
<link href="../../common.css" rel="stylesheet">
|
||||
</head>
|
||||
<style>
|
||||
html, body {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.camera-dia{
|
||||
/* width: 100vw;
|
||||
height: 100vh; */
|
||||
}
|
||||
.camera-box{
|
||||
width: 180px;
|
||||
height: 115px;
|
||||
background: rgba(19,21,35,.9);
|
||||
box-shadow: 0 0 0.0625rem 0.3125rem hsl(0deg 0% 100% / 10%);
|
||||
border: 1px solid #386df5;
|
||||
border-radius: 5px;
|
||||
position: fixed;
|
||||
right: 20px;
|
||||
bottom: 10px;
|
||||
z-index: 999;
|
||||
padding: 10px;
|
||||
}
|
||||
.camera-body{
|
||||
width: 100%;
|
||||
height: 115px;
|
||||
border: 1px solid #fff;
|
||||
}
|
||||
|
||||
.playWnd {
|
||||
width: 180px; /*播放容器的宽和高设定*/
|
||||
height: 115px;
|
||||
|
||||
}
|
||||
</style>
|
||||
|
||||
<body>
|
||||
<div class="camera-dia">
|
||||
<div class="camera-box fc-w fz-14">
|
||||
<div class="camera-body pos-r">
|
||||
<!--视频窗口展示-->
|
||||
<div id="playWnd" class="playWnd"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="carmerCard" style="display: none;"></div>
|
||||
</body>
|
||||
|
||||
<!--三个必要的js文件引入-->
|
||||
<script src="jquery-1.12.4.min.js"></script>
|
||||
<script src="jsencrypt.min.js"></script> <!-- 用于RSA加密 -->
|
||||
<script src="jsWebControl-1.0.0.min.js"></script> <!-- 用于前端与插件交互 -->
|
||||
|
||||
<script type="text/javascript">
|
||||
window.onload = () => {
|
||||
// 子页面接收消息
|
||||
window.addEventListener('message', function (e) {
|
||||
if (e.data) {
|
||||
$("#carmerCard").text(e.data[0])
|
||||
}
|
||||
}, false)
|
||||
}
|
||||
$("#closeBtn").click(function(){
|
||||
window.parent.postMessage(
|
||||
{
|
||||
cmd: 'close'
|
||||
}
|
||||
)
|
||||
})
|
||||
//页面加载时创建播放实例初始化
|
||||
$(window).load(function () {
|
||||
initPlugin();
|
||||
});
|
||||
|
||||
//声明公用变量
|
||||
var initCount = 0;
|
||||
var pubKey = '';
|
||||
|
||||
// 创建播放实例
|
||||
function initPlugin () {
|
||||
oWebControl = new WebControl({
|
||||
szPluginContainer: "playWnd", // 指定容器id
|
||||
iServicePortStart: 15900, // 指定起止端口号,建议使用该值
|
||||
iServicePortEnd: 15909,
|
||||
szClassId:"23BF3B0A-2C56-4D97-9C03-0CB103AA8F11", // 用于IE10使用ActiveX的clsid
|
||||
cbConnectSuccess: function () { // 创建WebControl实例成功
|
||||
oWebControl.JS_StartService("window", { // WebControl实例创建成功后需要启动服务
|
||||
dllPath: "./VideoPluginConnect.dll" // 值"./VideoPluginConnect.dll"写死
|
||||
}).then(function () { // 启动插件服务成功
|
||||
oWebControl.JS_SetWindowControlCallback({ // 设置消息回调
|
||||
cbIntegrationCallBack: cbIntegrationCallBack
|
||||
});
|
||||
|
||||
oWebControl.JS_CreateWnd("playWnd", 180, 115).then(function () { //JS_CreateWnd创建视频播放窗口,宽高可设定
|
||||
init(); // 创建播放实例成功后初始化
|
||||
});
|
||||
}, function () { // 启动插件服务失败
|
||||
});
|
||||
},
|
||||
cbConnectError: function () { // 创建WebControl实例失败
|
||||
oWebControl = null;
|
||||
$("#playWnd").html("插件未启动,正在尝试启动,请稍候...");
|
||||
WebControl.JS_WakeUp("VideoWebPlugin://"); // 程序未启动时执行error函数,采用wakeup来启动程序
|
||||
initCount ++;
|
||||
if (initCount < 3) {
|
||||
setTimeout(function () {
|
||||
initPlugin();
|
||||
}, 3000)
|
||||
} else {
|
||||
$("#playWnd").html("插件启动失败,请检查插件是否安装!");
|
||||
}
|
||||
},
|
||||
cbConnectClose: function (bNormalClose) {
|
||||
// 异常断开:bNormalClose = false
|
||||
// JS_Disconnect正常断开:bNormalClose = true
|
||||
oWebControl = null;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// 设置窗口控制回调
|
||||
function setCallbacks() {
|
||||
oWebControl.JS_SetWindowControlCallback({
|
||||
cbIntegrationCallBack: cbIntegrationCallBack
|
||||
});
|
||||
}
|
||||
|
||||
// 推送消息
|
||||
function cbIntegrationCallBack(oData) {
|
||||
// showCBInfo(JSON.stringify(oData.responseMsg));
|
||||
}
|
||||
|
||||
//初始化
|
||||
function init()
|
||||
{
|
||||
getPubKey(function () {
|
||||
|
||||
////////////////////////////////// 请自行修改以下变量值 ////////////////////////////////////
|
||||
var appkey = "21274765"; //综合安防管理平台提供的appkey,必填
|
||||
var secret = setEncrypt("CraRtGvpNB2xOcYSFTov"); //综合安防管理平台提供的secret,必填
|
||||
var ip = "223.99.16.253"; //综合安防管理平台IP地址,必填
|
||||
var playMode = 0; //初始播放模式:0-预览,1-回放
|
||||
var port = 1443; //综合安防管理平台端口,若启用HTTPS协议,默认443
|
||||
var snapDir = "D:\\SnapDir"; //抓图存储路径
|
||||
var videoDir = "D:\\VideoDir"; //紧急录像或录像剪辑存储路径
|
||||
var layout = "1x1"; //playMode指定模式的布局
|
||||
var enableHTTPS = 1; //是否启用HTTPS协议与综合安防管理平台交互,这里总是填1
|
||||
var encryptedFields = 'secret'; //加密字段,默认加密领域为secret
|
||||
var showToolbar = 1; //是否显示工具栏,0-不显示,非0-显示
|
||||
var showSmart = 1; //是否显示智能信息(如配置移动侦测后画面上的线框),0-不显示,非0-显示
|
||||
var buttonIDs = "0,16,256,257,258,259,260,512,513,514,515,516,517,768,769"; //自定义工具条按钮
|
||||
////////////////////////////////// 请自行修改以上变量值 ////////////////////////////////////
|
||||
|
||||
oWebControl.JS_RequestInterface({
|
||||
funcName: "init",
|
||||
argument: JSON.stringify({
|
||||
appkey: appkey, //API网关提供的appkey
|
||||
secret: secret, //API网关提供的secret
|
||||
ip: ip, //API网关IP地址
|
||||
playMode: playMode, //播放模式(决定显示预览还是回放界面)
|
||||
port: port, //端口
|
||||
snapDir: snapDir, //抓图存储路径
|
||||
videoDir: videoDir, //紧急录像或录像剪辑存储路径
|
||||
layout: layout, //布局
|
||||
enableHTTPS: enableHTTPS, //是否启用HTTPS协议
|
||||
encryptedFields: encryptedFields, //加密字段
|
||||
showToolbar: showToolbar, //是否显示工具栏
|
||||
showSmart: showSmart, //是否显示智能信息
|
||||
buttonIDs: buttonIDs //自定义工具条按钮
|
||||
})
|
||||
}).then(function (oData) {
|
||||
oWebControl.JS_Resize(180, 115); // 初始化后resize一次,规避firefox下首次显示窗口后插件窗口未与DIV窗口重合问题
|
||||
setWndCover();
|
||||
});
|
||||
// var cameraIndexCode = 'bbe9c64699174953828ce4fa8bb41b8f'; //获取输入的监控点编号值,必填
|
||||
var cameraIndexCode = $("#carmerCard").text()
|
||||
var streamMode = 0; //主子码流标识:0-主码流,1-子码流
|
||||
var transMode = 1; //传输协议:0-UDP,1-TCP
|
||||
var gpuMode = 0; //是否启用GPU硬解,0-不启用,1-启用
|
||||
var wndId = -1; //播放窗口序号(在2x2以上布局下可指定播放窗口)
|
||||
|
||||
cameraIndexCode = cameraIndexCode.replace(/(^\s*)/g, "");
|
||||
cameraIndexCode = cameraIndexCode.replace(/(\s*$)/g, "");
|
||||
|
||||
oWebControl.JS_RequestInterface({
|
||||
funcName: "startPreview",
|
||||
argument: JSON.stringify({
|
||||
cameraIndexCode:cameraIndexCode, //监控点编号
|
||||
streamMode: streamMode, //主子码流标识
|
||||
transMode: transMode, //传输协议
|
||||
gpuMode: gpuMode, //是否开启GPU硬解
|
||||
wndId:wndId //可指定播放窗口
|
||||
})
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
//获取公钥
|
||||
function getPubKey (callback) {
|
||||
oWebControl.JS_RequestInterface({
|
||||
funcName: "getRSAPubKey",
|
||||
argument: JSON.stringify({
|
||||
keyLength: 1024
|
||||
})
|
||||
}).then(function (oData) {
|
||||
if (oData.responseMsg.data) {
|
||||
pubKey = oData.responseMsg.data;
|
||||
callback()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//RSA加密
|
||||
function setEncrypt (value) {
|
||||
var encrypt = new JSEncrypt();
|
||||
encrypt.setPublicKey(pubKey);
|
||||
return encrypt.encrypt(value);
|
||||
}
|
||||
|
||||
// 监听resize事件,使插件窗口尺寸跟随DIV窗口变化
|
||||
$(window).resize(function () {
|
||||
if (oWebControl != null) {
|
||||
oWebControl.JS_Resize(180, 115);
|
||||
setWndCover();
|
||||
}
|
||||
});
|
||||
|
||||
// 监听滚动条scroll事件,使插件窗口跟随浏览器滚动而移动
|
||||
$(window).scroll(function () {
|
||||
if (oWebControl != null) {
|
||||
oWebControl.JS_Resize(180, 115);
|
||||
setWndCover();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 设置窗口裁剪,当因滚动条滚动导致窗口需要被遮住的情况下需要JS_CuttingPartWindow部分窗口
|
||||
function setWndCover() {
|
||||
var iWidth = $(window).width();
|
||||
var iHeight = $(window).height();
|
||||
var oDivRect = $("#playWnd").get(0).getBoundingClientRect();
|
||||
|
||||
var iCoverLeft = (oDivRect.left < 0) ? Math.abs(oDivRect.left): 0;
|
||||
var iCoverTop = (oDivRect.top < 0) ? Math.abs(oDivRect.top): 0;
|
||||
var iCoverRight = (oDivRect.right - iWidth > 0) ? Math.round(oDivRect.right - iWidth) : 0;
|
||||
var iCoverBottom = (oDivRect.bottom - iHeight > 0) ? Math.round(oDivRect.bottom - iHeight) : 0;
|
||||
|
||||
iCoverLeft = (iCoverLeft > 180) ? 180 : iCoverLeft;
|
||||
iCoverTop = (iCoverTop > 115) ? 115 : iCoverTop;
|
||||
iCoverRight = (iCoverRight > 180) ? 180 : iCoverRight;
|
||||
iCoverBottom = (iCoverBottom > 115) ? 115 : iCoverBottom;
|
||||
|
||||
oWebControl.JS_RepairPartWindow(0, 0, 1001, 115); // 多1个像素点防止还原后边界缺失一个像素条
|
||||
if (iCoverLeft != 0) {
|
||||
oWebControl.JS_CuttingPartWindow(0, 0, iCoverLeft, 115);
|
||||
}
|
||||
if (iCoverTop != 0) {
|
||||
oWebControl.JS_CuttingPartWindow(0, 0, 1001, iCoverTop); // 多剪掉一个像素条,防止出现剪掉一部分窗口后出现一个像素条
|
||||
}
|
||||
if (iCoverRight != 0) {
|
||||
oWebControl.JS_CuttingPartWindow(180 - iCoverRight, 0, iCoverRight, 115);
|
||||
}
|
||||
if (iCoverBottom != 0) {
|
||||
oWebControl.JS_CuttingPartWindow(0, 115 - iCoverBottom, 180, iCoverBottom);
|
||||
}
|
||||
}
|
||||
|
||||
//视频预览功能
|
||||
$("#startPreview").click(function () {
|
||||
var cameraIndexCode = 'bbe9c64699174953828ce4fa8bb41b8f'; //获取输入的监控点编号值,必填
|
||||
var streamMode = 0; //主子码流标识:0-主码流,1-子码流
|
||||
var transMode = 1; //传输协议:0-UDP,1-TCP
|
||||
var gpuMode = 0; //是否启用GPU硬解,0-不启用,1-启用
|
||||
var wndId = -1; //播放窗口序号(在2x2以上布局下可指定播放窗口)
|
||||
|
||||
cameraIndexCode = cameraIndexCode.replace(/(^\s*)/g, "");
|
||||
cameraIndexCode = cameraIndexCode.replace(/(\s*$)/g, "");
|
||||
|
||||
oWebControl.JS_RequestInterface({
|
||||
funcName: "startPreview",
|
||||
argument: JSON.stringify({
|
||||
cameraIndexCode:cameraIndexCode, //监控点编号
|
||||
streamMode: streamMode, //主子码流标识
|
||||
transMode: transMode, //传输协议
|
||||
gpuMode: gpuMode, //是否开启GPU硬解
|
||||
wndId:wndId //可指定播放窗口
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
//停止全部预览
|
||||
$("#stopAllPreview").click(function () {
|
||||
oWebControl.JS_RequestInterface({
|
||||
funcName: "stopAllPreview"
|
||||
});
|
||||
});
|
||||
|
||||
// 标签关闭
|
||||
$(window).unload(function () {
|
||||
if (oWebControl != null){
|
||||
oWebControl.JS_HideWnd(); // 先让窗口隐藏,规避可能的插件窗口滞后于浏览器消失问题
|
||||
oWebControl.JS_Disconnect().then(function(){ // 断开与插件服务连接成功
|
||||
},
|
||||
function() { // 断开与插件服务连接失败
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
</html>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -87,6 +87,16 @@ export const checkServerName = (name) => {
|
|||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 表名效验
|
||||
export const checkTableName = (name) => {
|
||||
return request({
|
||||
url: '/geoserver/checkTableName/' + name,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 文件上传
|
||||
export const uploadFile = (formData) => {
|
||||
return request({
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
export const globalApi = {
|
||||
// 本地测试
|
||||
// BASE_URL: "http://192.168.10.122:8909", //测试 卢国栋
|
||||
// GEOSERVER_URL: "http://192.168.10.136:8180",
|
||||
// netBASE_URL: "http://123.132.248.154:9231", //测试.net
|
||||
// BASE_URL: "http://192.168.10.116:8909", //测试 卢国栋
|
||||
// GEOSERVER_URL: "http://192.168.10.116:8909",
|
||||
// netBASE_URL: "https://py.hopetrytech.com:7001", //测试.net
|
||||
|
||||
// 测试服务器
|
||||
// BASE_URL: "http://123.132.248.154:9217", //测试 服务器
|
||||
|
|
@ -17,8 +17,12 @@ export const globalApi = {
|
|||
|
||||
|
||||
//正式环境
|
||||
// BASE_URL: "http://223.99.16.253:9006", // java
|
||||
// GEOSERVER_URL:"http://223.99.16.253:9007", // geoserver
|
||||
// netBASE_URL: "http://223.99.16.253:9001", //.net
|
||||
// BASE_URL: "http://223.99.16.253:9006", // java
|
||||
// GEOSERVER_URL:"http://223.99.16.253:9007", // geoserver
|
||||
// netBASE_URL: "http://223.99.16.253:9001", //.net
|
||||
|
||||
// BASE_URL: "https://fx.hopetrytech.com:7006/", // java
|
||||
// GEOSERVER_URL:"https://fx.hopetrytech.com:7005", // geoserver
|
||||
// netBASE_URL: "https://py.hopetrytech.com:7001", //.net
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,565 @@
|
|||
<template>
|
||||
<div class="form-container">
|
||||
<div
|
||||
style="height:50px;margin-bottom:40px;font-size:18px;color:#fff;font-weight:bold;border-bottom:1px solid rgba(255,255,255,0.1);">
|
||||
<span style="font-weight:1000;font-size:20px;cursor:pointer;"
|
||||
@click="$router.push({'path':'/upload_type_selected'})"><i class="el-icon el-icon-back"></i></span>
|
||||
导入Excel数据
|
||||
</div>
|
||||
<div class="title">
|
||||
<el-steps :active="currentStep" align-center>
|
||||
<el-step title="文件上传" description="选择Excel格式模板文件并配置服务基础信息"></el-step>
|
||||
<el-step title="信息配置" description="根据中文字段名称配置英文注释用于服务发布"></el-step>
|
||||
<el-step title="创建完成" description="服务创建完成在服务列表中查看服务"></el-step>
|
||||
</el-steps>
|
||||
</div>
|
||||
<div class="first-step" v-if="currentStep == 1">
|
||||
<div class="upload-iocn-box">
|
||||
<div class="upload-icon-bg2"></div>
|
||||
<div class="upload-icon-bg">
|
||||
<p class="upload-iocn">
|
||||
<img src="/images/upload.png" alt="">
|
||||
</p>
|
||||
<p class="upload-icon-text">只能选择后缀(.xlsx)格式模板文件<br />(文件大小不能超过100MB)</p>
|
||||
<p>
|
||||
<el-upload class="upload-demo" :action="''" :on-preview="handlePreview"
|
||||
:before-upload="beforeUpload" multiple :limit="3" :on-exceed="handleExceed"
|
||||
:file-list="fileList">
|
||||
<el-button size="small" type="primary">选择文件</el-button>
|
||||
</el-upload>
|
||||
</p>
|
||||
<p style="margin-top:10px;color:#ccc;">{{file ? file.name : null}}</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="form-box">
|
||||
<el-form ref="forms" :model="form" :rules="rules" label-width="120px" size="small">
|
||||
<el-form-item label="服务名称" prop="serverName">
|
||||
<el-input placeholder="请输入服务名称" style="width: 360px" v-model="form.serverName"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="空间参考" label-width="" prop="spaceType">
|
||||
<el-select style="width: 360px;" v-model="form.spaceType" placeholder="请选择空间参考">
|
||||
<el-option v-for="(item, index) in getDictone" :key="index" :label="item.dictlabel"
|
||||
:value="item.dictlabel"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item style="margin-top:165px;text-align:right;">
|
||||
<el-button type="default" @click="$router.push({'path':'/upload_type_selected'})">取消</el-button>
|
||||
<el-button type="primary" size="small" icon="el-icon-check" @click.native="onSubmit('form')">创建
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="second-step" v-if="currentStep == 2">
|
||||
<div class="btn-container">
|
||||
<el-button type="primary" size="large" icon="el-icon-download" @click.native="downloadTemplate"
|
||||
style="margin-right: 10px;">模板下载
|
||||
</el-button>
|
||||
<el-upload class="upload-demo" action="https://jsonplaceholder.typicode.com/posts/"
|
||||
:file-list="fileListImport" :show-file-list="false" :before-upload="beforeUploadImport">
|
||||
<el-button type="primary" size="large" icon="el-icon-upload">导入
|
||||
</el-button>
|
||||
</el-upload>
|
||||
</div>
|
||||
<div class="table-container">
|
||||
<el-table :data="tableHeader" height="320" border size="mini" style="width: 100%">
|
||||
|
||||
<el-table-column prop="name" label="原始字段名称" width="180">
|
||||
</el-table-column>
|
||||
<el-table-column prop="type" label="数据类型" width="180">
|
||||
</el-table-column>
|
||||
<el-table-column prop="length" label="数据长度">
|
||||
</el-table-column>
|
||||
<el-table-column label="英文名称">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="scope.row.en_name" size="mini"></el-input>
|
||||
<p style="color:#ff0000;font-size:12px;" v-if="!regExp.test(scope.row.en_name)">
|
||||
使用小写字母、数字、下划线的组合</p>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="中文注释">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="scope.row.cn_name" size="mini"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="删除">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" icon="el-icon-delete" type="warning" @click="delColumn(scope)">
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div style="text-align:right;position:absolute;bottom:20px;width: calc( 100% - 160px);">
|
||||
<el-button type="default" size="large" @click="$router.push({'path':'/upload_type_selected'})">取消
|
||||
</el-button>
|
||||
<el-button type="primary" size="large" icon="el-icon-check" @click.native="createService">创建
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="third-step" v-if="currentStep == 3">
|
||||
<el-result icon="success" title="服务创建成功" subTitle="服务创建成功,请在服务列表中心查看服务">
|
||||
<template slot="extra">
|
||||
<el-button type="primary" size="medium" @click="$router.push({'path':'/ServiceList'})">服务列表
|
||||
</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from 'axios';
|
||||
import { getMethodCommon, postMethodCommon } from '../../api/Api';
|
||||
import { globalApi } from '../../api/urlPatterns.js';
|
||||
export default {
|
||||
name: 'data_upload',
|
||||
data() {
|
||||
return {
|
||||
headers: {
|
||||
Authorization: localStorage.getItem("X-Token") || "",
|
||||
},
|
||||
form: {
|
||||
serverName: null,
|
||||
|
||||
},
|
||||
getDictone: [
|
||||
{
|
||||
"dictvalue": "1",
|
||||
"dictlabel": "EPSG:4326"
|
||||
},
|
||||
{
|
||||
"dictvalue": "2",
|
||||
"dictlabel": "EPSG:3857"
|
||||
}
|
||||
],
|
||||
rules: {
|
||||
serverName: [
|
||||
{ required: true, message: '请输入服务名称', trigger: 'blur' },
|
||||
],
|
||||
spaceType: [
|
||||
{ required: true, message: '请选择参考系', trigger: 'blur' },
|
||||
]
|
||||
},
|
||||
fileList: [],
|
||||
file: null,
|
||||
currentStep: 1,
|
||||
tableHeader: [],
|
||||
regExp: /^[a-z0-9_]+$/,
|
||||
fileListImport: [],
|
||||
fileImport: null
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 下载模板
|
||||
downloadTemplate() {
|
||||
window.location.href = globalApi.BASE_URL + '/geoserver/downloadColumn/' + this.tableName
|
||||
},
|
||||
delColumn(scope) {
|
||||
this.tableHeader.splice(scope.$index, 1);
|
||||
},
|
||||
handleRemove(file, fileList) {
|
||||
console.log(file, fileList);
|
||||
},
|
||||
handlePreview(file) {
|
||||
console.log("file222", file);
|
||||
},
|
||||
handleExceed(files, fileList) {
|
||||
console.log("files", files);
|
||||
this.$message.warning(`当前限制选择 3 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
|
||||
},
|
||||
beforeRemove(file, fileList) {
|
||||
return this.$confirm(`确定移除 ${file.name}?`);
|
||||
},
|
||||
beforeUploadImport(file) {
|
||||
console.log(file)
|
||||
let formData = new FormData();
|
||||
formData.append("file", file);
|
||||
let _this = this;
|
||||
axios.post(globalApi.BASE_URL + '/geoserver/uploadModelData', formData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
'Authorization': localStorage.getItem("X-Token") || "",
|
||||
}
|
||||
}).then(res => {
|
||||
if (res.data.code == 200) {
|
||||
console.log(res)
|
||||
var list = res.data.data.data
|
||||
console.log(list)
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
for (var j = 0; j < _this.tableHeader.length; j++) {
|
||||
if (list[i].name0 == _this.tableHeader[j].name) {
|
||||
_this.tableHeader[j].en_name = list[i].name1
|
||||
_this.tableHeader[j].cn_name = list[i].name2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
beforeUpload(file) {
|
||||
console.log(file);
|
||||
this.file = file;
|
||||
let extension = file.name.substring(file.name.lastIndexOf('.') + 1)
|
||||
let size = file.size / 1024 / 1024;
|
||||
if (extension !== 'xlsx') {
|
||||
this.$message.warning('只能上传后缀是.xlsx的文件')
|
||||
return false
|
||||
}
|
||||
if (size > 100) {
|
||||
this.$message.warning('文件大小不得超过100M')
|
||||
return false
|
||||
}
|
||||
return false
|
||||
},
|
||||
handleFileChange(file, fileList) {
|
||||
let f = { ...file }
|
||||
},
|
||||
|
||||
onSubmit() {
|
||||
if (this.file == null) {
|
||||
this.$message({ type: "warning", message: "请选择文件!" })
|
||||
return false;
|
||||
}
|
||||
|
||||
this.$refs['forms'].validate((valid) => {
|
||||
if (valid) {
|
||||
let formData = new FormData();
|
||||
formData.append("file", this.file);
|
||||
formData.append("serverName", this.form.serverName)
|
||||
formData.append("spaceType", this.form.spaceType)
|
||||
let _this = this;
|
||||
axios.post(globalApi.BASE_URL + '/geoserver/uploadExcelFile', formData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
'Authorization': localStorage.getItem("X-Token") || "",
|
||||
}
|
||||
}).then(res => {
|
||||
if (res.data.code == 200) {
|
||||
|
||||
_this.tableName = res.data.data.tableName;
|
||||
let arr = res.data.data.heads;
|
||||
_this.tableHeader = [];
|
||||
var relation = res.data.data.relation
|
||||
arr.forEach((item, index) => {
|
||||
|
||||
let obj = {
|
||||
name: item.name,
|
||||
type: item.type,
|
||||
length: item.length,
|
||||
en_name: item.name.toLowerCase(),
|
||||
cn_name: relation[item.name]
|
||||
}
|
||||
_this.tableHeader.push(obj);
|
||||
})
|
||||
_this.currentStep = 2;
|
||||
}
|
||||
})
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
createService() {
|
||||
// 英文字段验证
|
||||
let valid = [];
|
||||
this.tableHeader.forEach((item, index) => {
|
||||
let isEn = this.regExp.test(item.en_name);
|
||||
valid.push(isEn);
|
||||
})
|
||||
let isEn = valid.find((item, index) => {
|
||||
return item != true;
|
||||
})
|
||||
|
||||
if (isEn == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
let _this = this;
|
||||
let headerJsonString = {};
|
||||
let newHeader = [];
|
||||
this.tableHeader.forEach((item, index) => {
|
||||
|
||||
|
||||
headerJsonString[item.en_name] = item.cn_name;
|
||||
let obj = {
|
||||
name: item.name,
|
||||
type: item.type,
|
||||
length: item.length,
|
||||
refName: item.en_name,
|
||||
initName:item.cn_name
|
||||
}
|
||||
newHeader.push(obj);
|
||||
|
||||
})
|
||||
let formData = {
|
||||
dataType: "点",
|
||||
severType: "矢量",
|
||||
spaceType: this.form.spaceType,
|
||||
tableName: this.tableName,
|
||||
newHeads: newHeader,
|
||||
styleName: null,
|
||||
serverName: this.form.serverName,
|
||||
refRelation: JSON.stringify(headerJsonString),
|
||||
areaName: localStorage.getItem("areaName"),
|
||||
}
|
||||
|
||||
|
||||
postMethodCommon("/geoserver/saveData", formData).then(res => {
|
||||
if (res.data.code == 200) {
|
||||
getMethodCommon("/geoserver/publishLayer/" + _this.tableName).then(response => {
|
||||
_this.$message({
|
||||
type: "success",
|
||||
message: "上传服务成功"
|
||||
})
|
||||
_this.currentStep = 3;
|
||||
})
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
handleSuccess(response, file, fileList) {
|
||||
console.log("response", response);
|
||||
this.tableName = response.msg;
|
||||
},
|
||||
deleateColumn(scope) {
|
||||
console.log(scope);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.form-container {
|
||||
width: 1200px;
|
||||
padding: 20px 20px;
|
||||
height: 700px;
|
||||
background: #162258;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
.title {
|
||||
width: 100%;
|
||||
height: 140px;
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
text-indent: 20px;
|
||||
}
|
||||
|
||||
::v-deep .el-upload-dragger {
|
||||
background: none;
|
||||
border: 1px solid #108eff;
|
||||
color: #fff;
|
||||
margin: 20px auto;
|
||||
width: 400px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
::v-deep .el-upload-dragger .el-upload__text {
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
::v-deep .el-upload-list__item-name {
|
||||
height: 30px;
|
||||
}
|
||||
|
||||
::v-deep .el-input__inner {
|
||||
background: none;
|
||||
border-radius: 0px;
|
||||
border-color: #108eff;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
::v-deep .el-form-item__label {
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.form-box {
|
||||
width: calc(50% - 100px);
|
||||
height: calc(100% - 280px);
|
||||
float: left;
|
||||
margin-left: 100px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.table-container {
|
||||
width: 1040px;
|
||||
margin: 0px auto;
|
||||
}
|
||||
|
||||
.btn-container {
|
||||
width: 1040px;
|
||||
margin: 0px auto;
|
||||
text-align: right;
|
||||
margin-bottom: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.upload-iocn-box {
|
||||
width: calc(50% - 280px);
|
||||
height: calc(100% - 380px);
|
||||
float: left;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
background: #162258;
|
||||
margin-top: 25px;
|
||||
margin-left: 120px;
|
||||
}
|
||||
|
||||
.upload-icon-bg {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
background: #162258;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.upload-iocn-box::after {
|
||||
content: "";
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
background: #108eff;
|
||||
position: absolute;
|
||||
top: -3px;
|
||||
left: -3px;
|
||||
z-index: 1;
|
||||
border-radius: 1px;
|
||||
}
|
||||
|
||||
.upload-iocn-box::before {
|
||||
content: "";
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
background: #108eff;
|
||||
position: absolute;
|
||||
top: -3px;
|
||||
right: -3px;
|
||||
border-radius: 1px;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.upload-icon-bg2::after {
|
||||
content: "";
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
background: #108eff;
|
||||
position: absolute;
|
||||
bottom: -3px;
|
||||
left: -3px;
|
||||
border-radius: 1px;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.upload-icon-bg2::before {
|
||||
content: "";
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
background: #108eff;
|
||||
position: absolute;
|
||||
bottom: -3px;
|
||||
right: -3px;
|
||||
border-radius: 1px;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.upload-iocn-box img {
|
||||
width: 140px;
|
||||
}
|
||||
|
||||
.upload-iocn {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.upload-icon-text {
|
||||
font-size: 12px;
|
||||
color: #ccc;
|
||||
margin: 20px 0px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.upload-iocn-file-name {
|
||||
font-size: 14px;
|
||||
line-height: 20px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
::v-deep .el-button {
|
||||
border-radius: 0px;
|
||||
}
|
||||
|
||||
::v-deep .el-step__icon-inner {
|
||||
text-align: center;
|
||||
text-indent: 0px;
|
||||
}
|
||||
|
||||
::v-deep .el-step__title.is-process {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
::v-deep .el-step__description.is-process {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
::v-deep .el-table {
|
||||
background: none;
|
||||
}
|
||||
|
||||
::v-deep .el-form-item__label {}
|
||||
|
||||
::v-deep .el-form-item {
|
||||
margin-bottom: 35px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
::v-deep .el-result__title p {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
|
||||
::v-deep .el-result__subtitle p {
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
::v-deep .el-table td.el-table__cell,
|
||||
.el-table th.el-table__cell.is-leaf {}
|
||||
|
||||
::v-deep .el-table th.el-table__cell {
|
||||
background: #162258;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
::v-deep .el-table tr {
|
||||
background: #162258;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
|
||||
::v-deep .el-table .el-table__body tr:hover>td {
|
||||
background-color: rgba(255, 255, 255, .1) !important;
|
||||
}
|
||||
|
||||
::v-deep .el-table .el-table__body tr.current-row>td {
|
||||
background-color: rgba(255, 255, 255, .1) !important;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -0,0 +1,625 @@
|
|||
<template>
|
||||
<div class="form-container" v-loading="loading" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading"
|
||||
element-loading-background="rgba(0, 0, 0, 0.8)">
|
||||
<div style="
|
||||
height: 50px;
|
||||
margin-bottom: 40px;
|
||||
font-size: 16px;
|
||||
color: #fff;
|
||||
font-weight: bold;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
">
|
||||
<span style="font-weight: 1000; font-size: 20px; cursor: pointer"
|
||||
@click="$router.push({ path: '/upload_type_selected' })"><i class="el-icon el-icon-back"></i></span>
|
||||
导入ShpFile数据
|
||||
</div>
|
||||
<div class="title">
|
||||
<el-steps :active="currentStep" align-center>
|
||||
<el-step title="文件上传" description="选择ShpFile格式模板文件并配置服务基础信息"></el-step>
|
||||
<el-step title="信息配置" description="根据中文字段名称配置英文注释用于服务发布"></el-step>
|
||||
<el-step title="创建完成" description="服务创建完成在服务列表中查看服务"></el-step>
|
||||
</el-steps>
|
||||
</div>
|
||||
<div class="first-step" v-if="currentStep == 1">
|
||||
<div class="upload-iocn-box">
|
||||
<div class="upload-icon-bg2"></div>
|
||||
<div class="upload-icon-bg">
|
||||
<p class="upload-iocn">
|
||||
<img src="/images/upload.png" alt="" />
|
||||
</p>
|
||||
<p class="upload-icon-text">
|
||||
只能选择后缀(.zip)格式压缩文件<br />(文件大小不能超过50MB)
|
||||
</p>
|
||||
<p>
|
||||
<el-upload class="upload-demo" :action="''" :on-preview="handlePreview" :before-upload="beforeUpload"
|
||||
multiple :limit="3" :on-exceed="handleExceed" :file-list="fileList">
|
||||
<el-button size="small" type="primary">选择文件</el-button>
|
||||
</el-upload>
|
||||
</p>
|
||||
<p style="margin-top: 10px; color: #ccc">
|
||||
{{ file ? file.name : null }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-box">
|
||||
<el-form ref="forms" :model="form" :rules="rules" label-width="120px" size="small">
|
||||
<el-form-item label="服务名称" prop="serverName">
|
||||
<el-input placeholder="请输入服务名称" style="width: 360px" v-model="form.serverName" @change="servernameChange">
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="空间参考" prop="spaceType">
|
||||
<el-select style="width: 360px" v-model="form.spaceType" placeholder="请选择空间参考">
|
||||
<el-option v-for="(item, index) in getDictone" :key="index" :label="item.dictlabel"
|
||||
:value="item.dictlabel"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="服务类型" prop="severType">
|
||||
<el-select style="width: 360px" v-model="form.severType" placeholder="请选择服务类型">
|
||||
<el-option v-for="(item, index) in getDicttwo" :key="index" :label="item.dictlabel"
|
||||
:value="item.dictlabel"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="图层样式">
|
||||
<el-select v-model="form.styleName" style="width: 280px" placeholder="请选择图层样式">
|
||||
<el-option v-for="(value, key) in getDictthree" :key="key" :label="value" :value="value"></el-option>
|
||||
</el-select>
|
||||
<el-button type="primary" @click="createStyle">创建样式</el-button>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item style="margin-top: 60px; text-align: right">
|
||||
<el-button type="default" @click="$router.push({ path: '/upload_type_selected' })">取消</el-button>
|
||||
<el-button type="primary" size="small" icon="el-icon-check" @click.native="onSubmit('form')">创建</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="second-step" v-loading="loading" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading"
|
||||
element-loading-background="rgba(0, 0, 0, 0.8)" v-if="currentStep == 2">
|
||||
<div class="btn-container">
|
||||
<el-button type="primary" size="large" icon="el-icon-download" @click.native="downloadTemplate" style="margin-right: 10px;">模板下载</el-button>
|
||||
<el-upload class="upload-demo" action="https://jsonplaceholder.typicode.com/posts/" :file-list="fileListImport"
|
||||
:show-file-list="false" :before-upload="beforeUploadImport">
|
||||
<el-button type="primary" size="large" icon="el-icon-upload">导入
|
||||
</el-button>
|
||||
</el-upload>
|
||||
</div>
|
||||
<div class="table-container">
|
||||
<el-table :data="tableHeader" height="320" border size="mini" style="width: 100%">
|
||||
<el-table-column prop="name" label="原始字段名称" width="180">
|
||||
</el-table-column>
|
||||
<el-table-column prop="type" label="数据类型" width="180">
|
||||
</el-table-column>
|
||||
<el-table-column prop="length" label="数据长度"> </el-table-column>
|
||||
<el-table-column label="英文名称">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="scope.row.en_name" size="mini"></el-input>
|
||||
<p style="color: #ff0000; font-size: 12px" v-if="!regExp.test(scope.row.en_name)">
|
||||
使用小写字母、数字、下划线的组合
|
||||
</p>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="中文注释">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="scope.row.cn_name" size="mini"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="删除">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" icon="el-icon-delete" type="warning" @click="delColumn(scope)"></el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div style="
|
||||
text-align: right;
|
||||
position: absolute;
|
||||
bottom: 20px;
|
||||
width: calc(100% - 160px);
|
||||
">
|
||||
<el-button type="default" size="large" @click="$router.push({ path: '/upload_type_selected' })">取消</el-button>
|
||||
<el-button type="primary" size="large" icon="el-icon-check" @click.native="createService">创建</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="third-step" v-if="currentStep == 3">
|
||||
<el-result icon="success" title="服务创建成功" subTitle="服务创建成功,请在服务列表中心查看服务">
|
||||
<template slot="extra">
|
||||
<el-button type="primary" size="medium" @click="$router.push({ path: '/ServiceList' })">服务列表</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
</div>
|
||||
|
||||
<StyleConfig @yschange="styleUpdate" v-if="StyleConfigShow"></StyleConfig>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from "axios";
|
||||
import { getMethodCommon, postMethodCommon } from "../../api/Api";
|
||||
import { globalApi } from "../../api/urlPatterns.js";
|
||||
import StyleConfig from "../data_manage/yangshi";
|
||||
import {
|
||||
getDictone,
|
||||
getDicttwo,
|
||||
getLayerStyle,
|
||||
checkServerName,
|
||||
uploadFile,
|
||||
} from "../../api/datamange";
|
||||
|
||||
export default {
|
||||
name: "data_upload",
|
||||
components: {
|
||||
StyleConfig,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
StyleConfigShow: false,
|
||||
headers: {
|
||||
Authorization: localStorage.getItem("X-Token") || "",
|
||||
},
|
||||
form: {
|
||||
serverName: null,
|
||||
},
|
||||
rules: {
|
||||
serverName: [
|
||||
{ required: true, message: "请输入服务名称", trigger: "blur" },
|
||||
],
|
||||
spaceType: [
|
||||
{ required: true, message: "请选择参考系", trigger: "blur" },
|
||||
],
|
||||
severType: [
|
||||
{ required: true, message: "请输选择服务类型", trigger: "blur" },
|
||||
],
|
||||
},
|
||||
getDictone: [],
|
||||
getDicttwo: [],
|
||||
getDictthree: [],
|
||||
fileList: [],
|
||||
file: null,
|
||||
currentStep: 1,
|
||||
tableHeader: [],
|
||||
regExp: /^[a-z0-9_]+$/,
|
||||
fileListImport: [],
|
||||
fileImport: null
|
||||
};
|
||||
},
|
||||
created() {
|
||||
getDictone().then((res) => {
|
||||
this.getDictone = res.data.data;
|
||||
});
|
||||
getDicttwo().then((res) => {
|
||||
this.getDicttwo = res.data.data;
|
||||
});
|
||||
getLayerStyle().then((res) => {
|
||||
this.getDictthree = res.data.data.style.names;
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
// 下载模板
|
||||
downloadTemplate() {
|
||||
window.location.href = globalApi.BASE_URL + '/geoserver/downloadColumn/' + this.tableName
|
||||
},
|
||||
//校验服务名
|
||||
servernameChange() {
|
||||
checkServerName(this.form.serverName).then((res) => {
|
||||
if (res.data.code == 200) {
|
||||
if (res.data.data > 0) {
|
||||
this.$message.error("服务名称已存在,请重新输入");
|
||||
this.form.serverName = "";
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
delColumn(scope) {
|
||||
this.tableHeader.splice(scope.$index, 1);
|
||||
},
|
||||
styleUpdate() {
|
||||
getLayerStyle().then((res) => {
|
||||
this.getDictthree = res.data.data.style.names;
|
||||
});
|
||||
|
||||
this.StyleConfigShow = false;
|
||||
},
|
||||
handleRemove(file, fileList) {
|
||||
console.log(file, fileList);
|
||||
},
|
||||
handlePreview(file) {
|
||||
console.log(file);
|
||||
},
|
||||
handleExceed(files, fileList) {
|
||||
this.$message.warning(
|
||||
`当前限制选择 3 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length
|
||||
} 个文件`
|
||||
);
|
||||
},
|
||||
beforeRemove(file, fileList) {
|
||||
return this.$confirm(`确定移除 ${file.name}?`);
|
||||
},
|
||||
beforeUploadImport(file) {
|
||||
console.log(file)
|
||||
let formData = new FormData();
|
||||
formData.append("file", file);
|
||||
let _this = this;
|
||||
axios.post(globalApi.BASE_URL + '/geoserver/uploadModelData', formData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
'Authorization': localStorage.getItem("X-Token") || "",
|
||||
}
|
||||
}).then(res => {
|
||||
if (res.data.code == 200) {
|
||||
console.log(res)
|
||||
var list = res.data.data.data
|
||||
console.log(list)
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
for (var j = 0; j < _this.tableHeader.length; j++) {
|
||||
if (list[i].name0 == _this.tableHeader[j].name) {
|
||||
_this.tableHeader[j].en_name = list[i].name1
|
||||
_this.tableHeader[j].cn_name = list[i].name2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
beforeUpload(file) {
|
||||
console.log(file);
|
||||
this.file = file;
|
||||
let extension = file.name.substring(file.name.lastIndexOf(".") + 1);
|
||||
let size = file.size / 1024 / 1024;
|
||||
if (extension !== "zip") {
|
||||
this.$message.warning("只能上传后缀是.zip的文件");
|
||||
return false;
|
||||
}
|
||||
if (size > 100) {
|
||||
this.$message.warning("文件大小不得超过100M");
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
handleFileChange(file, fileList) {
|
||||
let f = { ...file };
|
||||
},
|
||||
|
||||
onSubmit() {
|
||||
this.loading = true;
|
||||
if (this.file == null) {
|
||||
this.$message({ type: "warning", message: "请选择文件!" });
|
||||
return false;
|
||||
}
|
||||
this.$refs["forms"].validate((valid) => {
|
||||
if (valid) {
|
||||
let formData = new FormData();
|
||||
formData.append("file", this.file);
|
||||
formData.append("serverName", this.form.serverName);
|
||||
formData.append("spaceType", this.form.spaceType);
|
||||
formData.append("severType", this.form.severType);
|
||||
let _this = this;
|
||||
// axios
|
||||
// .post(globalApi.BASE_URL + "/geoserver/uploadFile", formData, {
|
||||
// headers: {
|
||||
// "Content-Type": "multipart/form-data",
|
||||
// Authorization: localStorage.getItem("X-Token") || "",
|
||||
// },
|
||||
// })
|
||||
uploadFile(formData)
|
||||
.then((res) => {
|
||||
if (res.data.code == 200) {
|
||||
this.loading = false;
|
||||
_this.tableName = res.data.data.tableName;
|
||||
_this.form.dataType = res.data.data.dataType;
|
||||
let arr = res.data.data.heads;
|
||||
_this.tableHeader = [];
|
||||
arr.forEach((item, index) => {
|
||||
let obj = {
|
||||
name: item.name,
|
||||
type: item.type,
|
||||
length: item.length,
|
||||
en_name: item.name.toLowerCase(),
|
||||
cn_name: item.name,
|
||||
};
|
||||
_this.tableHeader.push(obj);
|
||||
});
|
||||
_this.currentStep = 2;
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
// 报错
|
||||
this.loading = false;
|
||||
// console.log(err);
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
createService() {
|
||||
this.loading = true;
|
||||
let valid = [];
|
||||
this.tableHeader.forEach((item, index) => {
|
||||
let isEn = this.regExp.test(item.en_name);
|
||||
valid.push(isEn);
|
||||
});
|
||||
let isEn = valid.find((item, index) => {
|
||||
return item != true;
|
||||
});
|
||||
|
||||
if (isEn == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
let _this = this;
|
||||
let headerJsonString = {};
|
||||
let newHeader = [];
|
||||
this.tableHeader.forEach((item, index) => {
|
||||
headerJsonString[item.en_name.toLowerCase()] = item.cn_name;
|
||||
let obj = {
|
||||
name: item.name,
|
||||
type: item.type,
|
||||
length: item.length,
|
||||
refName: item.en_name,
|
||||
initName:item.cn_name
|
||||
};
|
||||
newHeader.push(obj);
|
||||
});
|
||||
|
||||
let formData = {
|
||||
dataType: this.form.dataType,
|
||||
severType: this.form.severType,
|
||||
spaceType: this.form.spaceType,
|
||||
tableName: this.tableName,
|
||||
newHeads: newHeader,
|
||||
styleName: this.form.styleName,
|
||||
serverName: this.form.serverName,
|
||||
refRelation: JSON.stringify(headerJsonString),
|
||||
areaName: localStorage.getItem('areaName')
|
||||
};
|
||||
|
||||
postMethodCommon("/geoserver/saveData", formData)
|
||||
.then((res) => {
|
||||
if (res.data.code == 200) {
|
||||
getMethodCommon("/geoserver/publishLayer/" + _this.tableName).then(
|
||||
(response) => {
|
||||
this.loading = false;
|
||||
_this.$message({
|
||||
type: "success",
|
||||
message: "上传服务成功",
|
||||
});
|
||||
_this.currentStep = 3;
|
||||
}
|
||||
);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
// console.log(err);
|
||||
// this.$message.error(err);
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
handleSuccess(response, file, fileList) {
|
||||
console.log("response", response);
|
||||
this.tableName = response.msg;
|
||||
},
|
||||
createStyle() {
|
||||
this.StyleConfigShow = true;
|
||||
// this.$router.push({'path':'/layer_style_config'})
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.form-container {
|
||||
width: 1200px;
|
||||
padding: 20px 20px;
|
||||
height: 700px;
|
||||
background: #162258;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
.title {
|
||||
width: 100%;
|
||||
height: 160px;
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
text-indent: 20px;
|
||||
}
|
||||
|
||||
::v-deep .el-upload-dragger {
|
||||
background: none;
|
||||
border: 1px solid #108eff;
|
||||
color: #fff;
|
||||
margin: 20px auto;
|
||||
width: 400px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
::v-deep .el-upload-dragger .el-upload__text {
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
::v-deep .el-upload-list__item-name {
|
||||
height: 30px;
|
||||
}
|
||||
|
||||
::v-deep .el-input__inner {
|
||||
background: none;
|
||||
border-radius: 0px;
|
||||
border-color: #108eff;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
::v-deep .el-form-item__label {
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.form-box {
|
||||
width: calc(50% - 100px);
|
||||
height: calc(100% - 280px);
|
||||
float: left;
|
||||
margin-left: 100px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.table-container {
|
||||
width: 1040px;
|
||||
margin: 0px auto;
|
||||
}
|
||||
|
||||
.btn-container {
|
||||
width: 1040px;
|
||||
margin: 0px auto;
|
||||
text-align: right;
|
||||
margin-bottom: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.upload-iocn-box {
|
||||
width: calc(50% - 280px);
|
||||
height: calc(100% - 380px);
|
||||
float: left;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
background: #162258;
|
||||
margin-top: 25px;
|
||||
margin-left: 120px;
|
||||
}
|
||||
|
||||
.upload-icon-bg {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
background: #162258;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.upload-iocn-box::after {
|
||||
content: "";
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
background: #108eff;
|
||||
position: absolute;
|
||||
top: -3px;
|
||||
left: -3px;
|
||||
z-index: 1;
|
||||
border-radius: 1px;
|
||||
}
|
||||
|
||||
.upload-iocn-box::before {
|
||||
content: "";
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
background: #108eff;
|
||||
position: absolute;
|
||||
top: -3px;
|
||||
right: -3px;
|
||||
border-radius: 1px;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.upload-icon-bg2::after {
|
||||
content: "";
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
background: #108eff;
|
||||
position: absolute;
|
||||
bottom: -3px;
|
||||
left: -3px;
|
||||
border-radius: 1px;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.upload-icon-bg2::before {
|
||||
content: "";
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
background: #108eff;
|
||||
position: absolute;
|
||||
bottom: -3px;
|
||||
right: -3px;
|
||||
border-radius: 1px;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.upload-iocn-box img {
|
||||
width: 140px;
|
||||
}
|
||||
|
||||
.upload-iocn {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.upload-icon-text {
|
||||
font-size: 14px;
|
||||
color: #ccc;
|
||||
margin: 20px 0px;
|
||||
}
|
||||
|
||||
::v-deep .el-button {
|
||||
border-radius: 0px;
|
||||
}
|
||||
|
||||
::v-deep .el-step__icon-inner {
|
||||
text-align: center;
|
||||
text-indent: 0px;
|
||||
}
|
||||
|
||||
::v-deep .el-step__title.is-process {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
::v-deep .el-step__description.is-process {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
::v-deep .el-table {
|
||||
background: none;
|
||||
}
|
||||
|
||||
::v-deep .el-form-item__label {}
|
||||
|
||||
::v-deep .el-form-item {
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
|
||||
::v-deep .el-result__title p {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
::v-deep .el-result__subtitle p {
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
::v-deep .el-table td.el-table__cell,
|
||||
.el-table th.el-table__cell.is-leaf {}
|
||||
|
||||
::v-deep .el-table th.el-table__cell {
|
||||
background: #162258;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
::v-deep .el-table tr {
|
||||
background: #162258;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
::v-deep .el-table .el-table__body tr:hover>td {
|
||||
background-color: rgba(255, 255, 255, 0.1) !important;
|
||||
}
|
||||
|
||||
::v-deep .el-table .el-table__body tr.current-row>td {
|
||||
background-color: rgba(255, 255, 255, 0.1) !important;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -35,13 +35,26 @@
|
|||
<div class="form-box">
|
||||
<el-form ref="forms" :model="form" :rules="rules" label-width="120px" size="small">
|
||||
<el-form-item label="服务名称" prop="serverName">
|
||||
<<<<<<< HEAD
|
||||
<el-input placeholder="请输入服务名称" style="width: 360px" v-model="form.serverName"></el-input>
|
||||
=======
|
||||
<el-input placeholder="请输入服务名称" style="width: 360px" v-model="form.serverName"
|
||||
@change="servernameChange"></el-input>
|
||||
>>>>>>> main
|
||||
</el-form-item>
|
||||
<el-form-item label="空间参考" label-width="" prop="spaceType">
|
||||
<el-select style="width: 360px;" v-model="form.spaceType" placeholder="请选择空间参考">
|
||||
<el-option v-for="(item, index) in getDictone" :key="index" :label="item.dictlabel"
|
||||
:value="item.dictlabel"></el-option>
|
||||
</el-select>
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
</el-form-item>
|
||||
<el-form-item label="表名" prop="tableName">
|
||||
<el-input placeholder="请输入表名" style="width: 360px" v-model="form.tableName"
|
||||
@change="tableNameChange">
|
||||
</el-input>
|
||||
>>>>>>> main
|
||||
</el-form-item>
|
||||
<el-form-item style="margin-top:165px;text-align:right;">
|
||||
<el-button type="default" @click="$router.push({'path':'/upload_type_selected'})">取消</el-button>
|
||||
|
|
@ -119,9 +132,30 @@
|
|||
import axios from 'axios';
|
||||
import { getMethodCommon, postMethodCommon } from '../../api/Api';
|
||||
import { globalApi } from '../../api/urlPatterns.js';
|
||||
import { checkServerName,checkTableName } from "../../api/datamange";
|
||||
export default {
|
||||
name: 'data_upload',
|
||||
data() {
|
||||
var validateE = (rule, value, callback) => {
|
||||
var reg = /^[a-z]\w{0,28}$/
|
||||
if (value === '') {
|
||||
callback(new Error('请次输入表名'));
|
||||
} else if (!reg.test(value)) {
|
||||
callback(new Error('小写字母开头,不能有汉字和大写字母,不能超过30字符'));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
//
|
||||
};
|
||||
var isAllUpperCase = (rule, value, callback) => {
|
||||
for (var i = 0; i < value.length; i++) {
|
||||
if (value[i].charCodeAt(0) > 64 && value[i].charCodeAt(0) < 91) {
|
||||
// return false;
|
||||
callback(new Error('不能有大写字母'));
|
||||
}
|
||||
}
|
||||
callback();
|
||||
};
|
||||
return {
|
||||
headers: {
|
||||
Authorization: localStorage.getItem("X-Token") || "",
|
||||
|
|
@ -146,7 +180,12 @@
|
|||
],
|
||||
spaceType: [
|
||||
{ required: true, message: '请选择参考系', trigger: 'blur' },
|
||||
]
|
||||
],
|
||||
tableName: [
|
||||
{ required: true, message: "请输入表名", trigger: "blur" },
|
||||
{ validator: validateE, trigger: 'blur' },
|
||||
{ validator: isAllUpperCase, trigger: 'blur' },
|
||||
],
|
||||
},
|
||||
fileList: [],
|
||||
file: null,
|
||||
|
|
@ -223,7 +262,28 @@
|
|||
handleFileChange(file, fileList) {
|
||||
let f = { ...file }
|
||||
},
|
||||
|
||||
//校验服务名
|
||||
servernameChange() {
|
||||
checkServerName(this.form.serverName).then((res) => {
|
||||
if (res.data.code == 200) {
|
||||
if (res.data.data > 0) {
|
||||
this.$message.error("服务名称已存在,请重新输入");
|
||||
this.form.serverName = "";
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
// 校验表名
|
||||
tableNameChange() {
|
||||
checkTableName(this.form.tableName).then((res) => {
|
||||
if (res.data.code == 200) {
|
||||
if (res.data.data > 0) {
|
||||
this.$message.error("表名已存在,请重新输入");
|
||||
this.form.tableName = "";
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
onSubmit() {
|
||||
if (this.file == null) {
|
||||
this.$message({ type: "warning", message: "请选择文件!" })
|
||||
|
|
@ -236,6 +296,7 @@
|
|||
formData.append("file", this.file);
|
||||
formData.append("serverName", this.form.serverName)
|
||||
formData.append("spaceType", this.form.spaceType)
|
||||
formData.append("tableName", this.form.tableName)
|
||||
let _this = this;
|
||||
axios.post(globalApi.BASE_URL + '/geoserver/uploadExcelFile', formData, {
|
||||
headers: {
|
||||
|
|
@ -296,7 +357,7 @@
|
|||
type: item.type,
|
||||
length: item.length,
|
||||
refName: item.en_name,
|
||||
initName:item.cn_name
|
||||
initName: item.cn_name
|
||||
}
|
||||
newHeader.push(obj);
|
||||
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@
|
|||
import axios from 'axios';
|
||||
import { postMethodCommon } from "../../api/Api"
|
||||
import Editor from './widget/Editor.vue';
|
||||
import { getCenter } from './lib/getCenter'
|
||||
import { getCenter } from './lib/getCenter'
|
||||
import { waiData } from "./lib/xianjiewai";
|
||||
import { globalApi } from '../../api/urlPatterns.js'
|
||||
// 图形绘制工具类
|
||||
|
|
@ -789,7 +789,6 @@ import { getCenter } from './lib/getCenter'
|
|||
|
||||
// 创建地图
|
||||
initMap() {
|
||||
console.log(waiData)
|
||||
//mapbox 2.0以后的版本需要accessToken 到官网注册下载
|
||||
this.$mapboxgl.accessToken = "pk.eyJ1Ijoic2hpY2hhbzEyMyIsImEiOiJja3FobnI1aDEwNGF6Mm9vOXVhNnBzZmFhIn0.2fZKiMqCQHxVY74QShMEGQ";
|
||||
this.globalMap = new this.$mapboxgl.Map({
|
||||
|
|
@ -800,7 +799,7 @@ import { getCenter } from './lib/getCenter'
|
|||
minZoom: 5,
|
||||
pitch: 0,
|
||||
// style:"mapbox://styles/mapbox/satellite-v9"
|
||||
style: "mapbox://styles/shichao123/clf3b1bxk007801moo0nnl87k"
|
||||
style: "mapbox://styles/mapbox/streets-v11"
|
||||
// style:"mapbox://styles/mapbox/dark-v10"
|
||||
|
||||
});
|
||||
|
|
@ -819,7 +818,7 @@ import { getCenter } from './lib/getCenter'
|
|||
'maxzoom': 14
|
||||
});
|
||||
// add the DEM source as a terrain layer with exaggerated height
|
||||
_this.globalMap.setTerrain({ source: "mapbox-dem", exaggeration: 1.5 });
|
||||
_this.globalMap.setTerrain({ 'source': 'mapbox-dem', 'exaggeration': 1.5 });
|
||||
|
||||
_this.loadGaoQingLayer();
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,10 @@
|
|||
<el-button type="primary" @click="createStyle">创建样式</el-button>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="表名" prop="tableName">
|
||||
<el-input placeholder="请输入表名" style="width: 360px" v-model="form.tableName" @change="tableNameChange">
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item style="margin-top: 60px; text-align: right">
|
||||
<el-button type="default" @click="$router.push({ path: '/upload_type_selected' })">取消</el-button>
|
||||
<el-button type="primary" size="small" icon="el-icon-check" @click.native="onSubmit('form')">创建</el-button>
|
||||
|
|
@ -78,7 +82,8 @@
|
|||
<div class="second-step" v-loading="loading" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading"
|
||||
element-loading-background="rgba(0, 0, 0, 0.8)" v-if="currentStep == 2">
|
||||
<div class="btn-container">
|
||||
<el-button type="primary" size="large" icon="el-icon-download" @click.native="downloadTemplate" style="margin-right: 10px;">模板下载</el-button>
|
||||
<el-button type="primary" size="large" icon="el-icon-download" @click.native="downloadTemplate"
|
||||
style="margin-right: 10px;">模板下载</el-button>
|
||||
<el-upload class="upload-demo" action="https://jsonplaceholder.typicode.com/posts/" :file-list="fileListImport"
|
||||
:show-file-list="false" :before-upload="beforeUploadImport">
|
||||
<el-button type="primary" size="large" icon="el-icon-upload">导入
|
||||
|
|
@ -148,6 +153,7 @@
|
|||
getLayerStyle,
|
||||
checkServerName,
|
||||
uploadFile,
|
||||
checkTableName
|
||||
} from "../../api/datamange";
|
||||
|
||||
export default {
|
||||
|
|
@ -156,6 +162,28 @@
|
|||
StyleConfig,
|
||||
},
|
||||
data() {
|
||||
var validateE = (rule, value, callback) => {
|
||||
var reg = /^[a-z]\w{0,28}$/
|
||||
// var reg = /^[a-zA-Z][^\u4e00-\u9fa5]+$/
|
||||
if (value === '') {
|
||||
callback(new Error('请次输入表名'));
|
||||
} else if (!reg.test(value)) {
|
||||
callback(new Error('小写字母开头,不能有汉字和大写字母,不能超过30字符'));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
|
||||
};
|
||||
var isAllUpperCase = (rule, value, callback) => {
|
||||
for (var i = 0; i < value.length; i++) {
|
||||
if (value[i].charCodeAt(0) > 64 && value[i].charCodeAt(0) < 91) {
|
||||
// return false;
|
||||
callback(new Error('不能有大写字母'));
|
||||
}
|
||||
}
|
||||
callback();
|
||||
};
|
||||
|
||||
return {
|
||||
loading: false,
|
||||
StyleConfigShow: false,
|
||||
|
|
@ -175,6 +203,11 @@
|
|||
severType: [
|
||||
{ required: true, message: "请输选择服务类型", trigger: "blur" },
|
||||
],
|
||||
tableName: [
|
||||
{ required: true, message: "请输入表名", trigger: "blur" },
|
||||
{ validator: validateE, trigger: 'blur' },
|
||||
{ validator: isAllUpperCase, trigger: 'blur' },
|
||||
],
|
||||
},
|
||||
getDictone: [],
|
||||
getDicttwo: [],
|
||||
|
|
@ -215,6 +248,17 @@
|
|||
}
|
||||
});
|
||||
},
|
||||
// 校验表名
|
||||
tableNameChange() {
|
||||
checkTableName(this.form.tableName).then((res) => {
|
||||
if (res.data.code == 200) {
|
||||
if (res.data.data > 0) {
|
||||
this.$message.error("表名已存在,请重新输入");
|
||||
this.form.tableName = "";
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
delColumn(scope) {
|
||||
this.tableHeader.splice(scope.$index, 1);
|
||||
},
|
||||
|
|
@ -289,6 +333,7 @@
|
|||
this.loading = true;
|
||||
if (this.file == null) {
|
||||
this.$message({ type: "warning", message: "请选择文件!" });
|
||||
this.loading = false;
|
||||
return false;
|
||||
}
|
||||
this.$refs["forms"].validate((valid) => {
|
||||
|
|
@ -298,14 +343,9 @@
|
|||
formData.append("serverName", this.form.serverName);
|
||||
formData.append("spaceType", this.form.spaceType);
|
||||
formData.append("severType", this.form.severType);
|
||||
formData.append("tableName", this.form.tableName);
|
||||
formData.append("styleName",this.form.styleName);
|
||||
let _this = this;
|
||||
// axios
|
||||
// .post(globalApi.BASE_URL + "/geoserver/uploadFile", formData, {
|
||||
// headers: {
|
||||
// "Content-Type": "multipart/form-data",
|
||||
// Authorization: localStorage.getItem("X-Token") || "",
|
||||
// },
|
||||
// })
|
||||
uploadFile(formData)
|
||||
.then((res) => {
|
||||
if (res.data.code == 200) {
|
||||
|
|
@ -325,6 +365,9 @@
|
|||
_this.tableHeader.push(obj);
|
||||
});
|
||||
_this.currentStep = 2;
|
||||
} else {
|
||||
|
||||
this.$message({ type: "error", message: res.data.msg });
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
|
|
@ -332,7 +375,9 @@
|
|||
this.loading = false;
|
||||
// console.log(err);
|
||||
});
|
||||
|
||||
} else {
|
||||
this.loading = false;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
|
@ -349,9 +394,13 @@
|
|||
});
|
||||
|
||||
if (isEn == false) {
|
||||
this.$message({
|
||||
type: "error",
|
||||
message: "英文名称使用小写字母、数字、下划线的组合",
|
||||
});
|
||||
this.loading = false;
|
||||
return;
|
||||
}
|
||||
|
||||
let _this = this;
|
||||
let headerJsonString = {};
|
||||
let newHeader = [];
|
||||
|
|
@ -362,10 +411,11 @@
|
|||
type: item.type,
|
||||
length: item.length,
|
||||
refName: item.en_name,
|
||||
initName:item.cn_name
|
||||
initName: item.cn_name
|
||||
};
|
||||
newHeader.push(obj);
|
||||
});
|
||||
console.log(2)
|
||||
|
||||
let formData = {
|
||||
dataType: this.form.dataType,
|
||||
|
|
|
|||
Loading…
Reference in New Issue