EasySpider/ServiceGrid/frontEnd/invokeService.html
2020-07-18 10:42:11 +08:00

203 lines
8.3 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html>
<html lang="en">
<head>
<script src="jquery-3.4.1.min.js"></script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="vue.js"></script>
<link rel="stylesheet" href="bootstrap/css/bootstrap.css"></link>
<title>服务调用</title>
<style>
table {
table-layout: auto;
}
table,
td,
th,
tr {
border-color: black!important;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
max-width: 400px;
min-width: 150px;
}
.ID {
width: 10%;
}
</style>
</head>
<body>
<div class="row" style="margin-top: 40px;">
<div class="col-md-6" style="margin:0 auto" id="serviceList" v-if="show">
<h4 style="text-align: center;">服务信息</h4>
<p>服务名称:{{service["name"]}}</p>
<p style="word-wrap: break-word;word-break: break-all;overflow: hidden;max-height: 100px;">服务描述:{{service["desc"]}}</p>
<p style="word-wrap: break-word;word-break: break-all;overflow: hidden;max-height: 100px;">任务号调用URLhttp://183.129.170.180:8041/backEnd/invokeService?id={{service["id"]}}</p>
<p>请输入参数:</p>
<form id="form">
<table class="table table-bordered">
<tbody>
<tr>
<th style="min-width: 50px;">ID</th>
<th>参数名称</th>
<th>调用名称</th>
<th>参数类型</th>
<th>参数值</th>
</tr>
<tr v-if="service.inputParameters.length>0" v-for="i in service.inputParameters.length">
<td style="min-width: 50px;">{{i}}</td>
<td>{{service.inputParameters[i-1]["nodeName"]}}</td>
<td>{{service.inputParameters[i-1]["name"]}}</td>
<td>{{service.inputParameters[i-1]["type"]}}</td>
<td><textarea style="min-height: 100px;min-width: 300px;" v-bind:name="service.inputParameters[i-1]['name']" class="form-control" v-model="service.inputParameters[i-1]['value']"></textarea></td>
</tr>
</tbody>
</table>
</form>
<button style="margin-left: 5px;" v-on:click="localExcuteInstant" class="btn btn-primary">直接本地执行</button>
<button style="margin-left: 5px;" v-on:click="remoteExcuteInstant" class="btn btn-primary">直接远程执行</button>
<div style="margin-bottom: 10px;">
<label style="margin-top: 10px;">任务ID:</label>
<input class="form-control" v-model="ID"></input>
<p></p>
<p>提示点击下方按钮获得任务ID然后根据此ID进行服务执行也可自己POST调用接口得到ID具体参照POST调用文档。</p>
<a href="javascript:void(0)" v-on:click="invokeService" class="btn btn-primary">获得任务ID</a>
<button v-on:click="localExcute" style="margin-left: 8px;" class="btn btn-primary">本地执行任务</button>
<button v-on:click="remoteExcute" style="margin-left: 8px;" class="btn btn-primary">远程执行任务</button></div>
</div>
</div>
</div>
</body>
</html>
<script>
function getUrlParam(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
var r = window.location.search.substr(1).match(reg); //匹配目标参数
if (r != null) return unescape(r[2]);
return null; //返回参数值
}
var sId = getUrlParam('id');
var app = new Vue({
el: '#serviceList',
data: {
service: {},
show: false, //是否渲染
ID: "暂无",
},
methods: {
invokeService: function() {
if (confirm("确定要获得任务ID吗")) {
var para = {};
var t = $('#form').serializeArray();
t.forEach(function(item, index) {
para[item.name] = item.value;
});
$.post("http://183.129.170.180:8041/backEnd/invokeService?id=" + sId, {
id: this.service.id,
paras: JSON.stringify(para)
}, function(result) {
app.$data.ID = result; //得到返回的ID
});
}
},
localExcute: function() {
if (this.ID == "暂无") {
alert("请先获得任务ID");
return;
}
if (confirm("确定要本地执行任务吗?")) {
let message = { //显示flowchart
type: 5, //消息类型,调用执行程序
message: {
"id": app.$data.ID,
}
};
ws.send(JSON.stringify(message));
}
},
remoteExcute: function() {
if (this.ID == "暂无") {
alert("请先获得任务ID");
return;
}
if (confirm("确定要远程执行任务吗?")) {
let message = { //显示flowchart
type: 5, //消息类型,调用执行程序
message: {
"id": app.$data.ID,
}
};
ws.send(JSON.stringify(message));
}
},
localExcuteInstant: function() {
if (confirm("确定要直接本地执行任务吗?")) {
var para = {};
var t = $('#form').serializeArray();
t.forEach(function(item, index) {
para[item.name] = item.value;
});
$.post("http://183.129.170.180:8041/backEnd/invokeService?id=" + sId, {
id: this.service.id,
paras: JSON.stringify(para)
}, function(result) {
let message = { //显示flowchart
type: 5, //消息类型,调用执行程序
message: {
"id": result,
}
};
ws.send(JSON.stringify(message));
});
}
},
remoteExcuteInstant: function() {
if (confirm("确定要直接远程执行任务吗?")) {
var para = {};
var t = $('#form').serializeArray();
t.forEach(function(item, index) {
para[item.name] = item.value;
});
$.post("http://183.129.170.180:8041/backEnd/invokeService?id=" + sId, {
id: this.service.id,
paras: JSON.stringify(para)
}, function(result) {
//待实现
});
}
},
}
});
$.get("http://183.129.170.180:8041/backEnd/queryService?id=" + sId, function(result) {
app.$data.service = result;
app.$data.show = true;
});
ws = new WebSocket("ws://localhost:8084");
ws.onopen = function() {
// Web Socket 已连接上,使用 send() 方法发送数据
console.log("已连接");
message = {
type: 0, //消息类型0代表链接操作
message: {
id: 1, //socket id
}
};
this.send(JSON.stringify(message));
};
ws.onclose = function() {
// 关闭 websocket
console.log("连接已关闭...");
};
</script>