You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

314 lines
8.5 KiB

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
String WDK_ROOT = WDKCore.WDK_ROOT;
%>
<!DOCTYPE html>
<%@page import="org.wdk.WDKConstant"%>
<%@page import="org.wdk.WDKCore"%>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! -->
<title>服务测试</title>
<base href="<%=basePath%>" target="_self">
<!-- Bootstrap -->
<script type="text/javascript" src="<%=WDK_ROOT%>/theme/bs/core/js/wdk_bs.js"></script>
<style>
</style>
</head>
<body class="page_body " style="padding-left:10px;padding-right:10px;">
<!-- <input type="hidden" id="service_group"> -->
<!-- <input type="hidden" id="service_name"> -->
<!-- <input type="hidden" id="service_method"> -->
<div class="container-fluid ov_h_x">
<div class="row panel panel-primary">
<div class="panel-heading">选择服务</div>
<div class="panel-body">
<form class="form-horizontal">
<div class="form-group">
<label for="service_group" class="col-sm-2 control-label">服务分组</label>
<div class="col-sm-10">
<select id="service_group" class= "form-control">
</select>
</div>
</div>
<div class="form-group">
<label for="service_name" class="col-sm-2 control-label">服务名称</label>
<div class="col-sm-10">
<select id="service_name" class= "form-control">
</select>
</div>
</div>
<div class="form-group">
<label for="service_method" class="col-sm-2 control-label">服务方法</label>
<div class="col-sm-10">
<select id="service_method" class= "form-control">
</select>
</div>
</div>
</form>
</div>
</div>
<div class="row panel panel-info">
<div class="panel-heading">服务输入参数&nbsp;&nbsp;&nbsp;&nbsp;<button id="dotest" class="btn btn-danger" >执行测试</button>
<input type="checkbox" id="pagequery" value="1">注入分页信息
</div>
<div class="panel-body">
<form id="test_form" class="form-horizontal">
<!-- <div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="inputEmail3" placeholder="Email">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary">执行测试</button>
</div>
</div>-->
</form>
</div>
</div>
<div class="row panel panel-warning">
<div class="panel-heading">测试结果</div>
<div class="panel-body">
<form class="form-horizontal">
<div class="form-group">
<label for="test_result" class="col-sm-2 control-label">执行结果</label>
<div class="col-sm-10">
<textarea class="form-control" id="test_result" rows="5"></textarea>
</div>
</div>
</form>
</div>
</div>
</div>
</body>
<script>
$(function(){
//初始化服务分组树
$.combobox({
id:'service_group'
,url:'wdk?action=wdk.pub&method=call_service&ajaxparam='+new Date().getTime()
,queryParams:{
_SRVNAME:'service.wdk.pub'
,_SRVMETHOD:'srv_getGroup'
,_DATA:$.json2str({
})
,_RSTYPE:'combobox'
,_RSFIELD:'rows'
,_RSPARAM:$.json2str({
idField:'id'
,textField:'text'
})
}
,infinity:true
,initOption:{
id:'group_all'
,text:'选择全部'
}
,onChange:function(value){
$.combobox_refresh({
id:'service_name'
,url:'wdk?action=wdk.pub&method=call_service&ajaxparam='+new Date().getTime()
,queryParams:{
_SRVNAME:'service.wdk.pub'
,_SRVMETHOD:'srv_getServices'
,_DATA:$.json2str({
group_name:value
})
,_RSTYPE:'combobox'
,_RSFIELD:'rows'
,_RSPARAM:$.json2str({
idField:'id'
,textField:'text'
})
}
});
}
});
//初始化服务树
$.combobox({
id:'service_name'
,url:'wdk?action=wdk.pub&method=call_service&ajaxparam='+new Date().getTime()
,queryParams:{
_SRVNAME:'service.wdk.pub'
,_SRVMETHOD:'srv_getServices'
,_DATA:$.json2str({
group_name:''
})
,_RSTYPE:'combobox'
,_RSFIELD:'rows'
,_RSPARAM:$.json2str({
idField:'id'
,textField:'text'
})
}
,infinity:true
,onChange:function(value){
$.combobox_refresh({
id:'service_method'
,url:'wdk?action=wdk.pub&method=call_service&ajaxparam='+new Date().getTime()
,queryParams:{
_SRVNAME:'service.wdk.pub'
,_SRVMETHOD:'srv_getServiceMethods'
,_DATA:$.json2str({
service_name:value
})
,_RSTYPE:'combobox'
,_RSFIELD:'rows'
,_RSPARAM:$.json2str({
idField:'id'
,textField:'text'
})
}
});
}
});
//初始化服务方法树
$.combobox({
id:'service_method'
,url:'wdk?action=wdk.pub&method=call_service&ajaxparam='+new Date().getTime()
,queryParams:{
_SRVNAME:'service.wdk.pub'
,_SRVMETHOD:'srv_getServiceMethods'
,_DATA:$.json2str({
service_name:''
})
,_RSTYPE:'combobox'
,_RSFIELD:'rows'
,_RSPARAM:$.json2str({
idField:'id'
,textField:'text'
})
}
,infinity:true
,onChange:function(value){
//获取所有属性并刷新属性列表
initDetail(value);
}
});
//注册按钮事件
$("#dotest").on("click", function(){
var form_param = $.getFieldValue({formid:'test_form'});
var param = {
_SRVNAME: 'service.wdk.pub',
_SRVMETHOD: 'srv_test',
_DATA: $.json2str({
jparam: {
service_method: _service_method,
form_param: form_param
}
})
};
if($('#pagequery').is(":checked"))
{
param.rows = '10';
param.page = '1';
}
$.cuajax({
url:'wdk?action=wdk.pub&method=call_service&ajaxparam='+new Date().getTime()
,data:param
,success:function(result){
$('#test_result').val(result);
var jres = $.str2json(result);
if('1'==jres.code){
alert('测试执行成功');
}else{
alert(jres.desc);
}
}
,error:function(e){
alert('error:'+e);
}
});
});
});
var _service_method;
function initDetail(service_method){
_service_method = service_method;
$.cuajax({
url:'wdk?action=wdk.pub&method=call_service&ajaxparam='+new Date().getTime()
,data:{
_SRVNAME:'service.wdk.pub'
,_SRVMETHOD:'srv_getServiceMethodParams'
,_DATA:$.json2str({
service_method:service_method
})
}
,success:function(result){
var jres = $.str2json(result);
//根据结果进行动态构建表单
if('1'==jres.code){
$('#test_form').empty();
var jrows = jres.rows;
for(var i=0;i<jrows.length;i++){
var jrow = jrows[i];
var param_type = jrow.param_type;
var param_name = jrow.param_name;
var oDiv=$('<div class="form-group"></div>');
/* <div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="inputEmail3" placeholder="Email">
</div>
</div> */
var html = new Array();
html.push('<label class="col-sm-2 control-label">'+param_type+'</label>');
html.push('<label class="col-sm-2 control-label">'+param_name+'</label>');
html.push('<div class="col-sm-8">');
if('ServiceContext'==param_type){
html.push('<label class="form-control" id="'+param_name+'">系统内置</label>');
}else{
html.push('<textarea class="form-control" id="'+param_name+'" rows="5"/>');
}
html.push('</div>');
oDiv.html(html.join(''));
$("#test_form").append(oDiv);
}
}
}
,error:function(e){
alert('error:'+e);
}
});
}
</script>
</html>