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.
 
 
 
 
 
 

410 lines
13 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 http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- 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_name" class="col-sm-2 control-label">服务名称</label>
<div class="col-sm-10">
<select id="service_name" name="service_name" class= "form-control" onchange="changeService(this.value)">
<option value="service.mtr.tbc.brand">卷烟品牌服务</option>
<option value="service.mtr.tbc.factory">卷烟厂家服务</option>
<option value="service.mtr.tbc.provider">卷烟供应商服务</option>
</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 changeService(service_name){
$.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:service_name
})
,_RSTYPE:'combobox'
,_RSFIELD:'rows'
,_RSPARAM:$.json2str({
idField:'id'
,textField:'text'
})
}
});
}
var op_acc = "0000000000000000000zhuxiaowen_hz";//朱晓文
var manage_unit_uuid = '00000000000000000000000000000001';
var delete_brand_uuid = '00000000000000000000000000000001';//品牌删除的品牌标识:上海烟草的熊猫
var create_brand_info = {
brand_code:'320100'
,brand_name:'测试品牌可删除'
,factory_uuid:'00000000000000000000000000000091'
,factory_simple_name:'扬州卷烟厂'
,is_main_20:'1'
,is_main_brand:'1'
,is_top_100:'1'
,is_top_15:'1'
,is_encourage:'0'
,is_ss_15:'0'
,is_active:'1'
,ext_id:''
};
var change_brand_uuid = '';//品牌删除的品牌标识:上海烟草的熊猫
var change_brand_info = {
brand_code:'320100'
,brand_name:'测试品牌可删除2'
,factory_uuid:'00000000000000000000000000000091'
,factory_simple_name:'扬州卷烟厂'
,is_main_20:'1'
,is_main_brand:'1'
,is_top_100:'1'
,is_top_15:'1'
,is_encourage:'0'
,is_ss_15:'0'
,is_active:'1'
,ext_id:''
};
/**下面是卷烟厂家服务用到的参数*/
var create_factory_info = {
factory_code:'0002_test'
,factory_name:'测试卷烟厂家,可删除'
,simple_name:'测试厂家'
,parent_uuid:'00000000000000000000000000000176'
,parent_name:'国产'
,enterprise_size:''
,province_uuid:'330000'
,area_uuid:''
,factory_address:'地址'
,belong_factory_uuid:''
,statistics_org:''
,factory_type:''
,economic:''
,remark:'备注'
,is_active:'1'
};
var delete_factory_uuid = '';//卷烟厂家删除的id
var change_factory_uuid = '';//卷烟厂家修改的id
var change_factory_info = {
factory_name:'测试卷烟厂家,可删除-已修改'
,simple_name:'测试厂家2'
};
/**下面是供应商参数*/
var delete_provider_uuid = "";
var change_provider_uuid = "";
var create_provider_info = {
provider_code:'test_001'
,provider_name:'测试供应商'
,simple_name:'简称'
,provider_type_code:'02'
,buy_type_code:'07'
,sale_type_code:'01'
,province_uuid:'310000'
,area_uuid:'310000'
,address:'地址'
,tel:'电话'
,country_code:'1'
,country_name:''
,currency:'01'
,pay_mode:'01'
,pay_condition:'01'
,tax_class:'01'
,busi_type:'01'
,tax_no:''
,bank_name:'银行名称'
,bank_account:'银行账号'
,invoice_type:'01'
,default_rate:'01'
,is_active:'1'
,manage_unit_uuid:'00000000000000000000000000000020'
,ext_id:''
};
var change_provider_info ={
provider_name:'测试供应商2'
,simple_name:'简称2'
};
$(function(){
//初始化服务方法树
$.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:'service.mtr.tbc.brand'//初始化的时候读取卷烟品牌的
})
,_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){
if(_service_method.startWith("service.mtr.tbc.brand_create")){
//刚才是创建,成功之后把删除的id赋值
delete_brand_uuid = jres.brand_uuid;
change_brand_uuid = jres.brand_uuid;
} else if(_service_method.startWith("service.mtr.tbc.factory_create")){
//刚才是创建,成功之后把删除的id赋值
delete_factory_uuid = jres.factory_uuid;
change_factory_uuid = jres.factory_uuid;
} else if(_service_method.startWith("service.mtr.tbc.provider_create")){
//刚才是创建,成功之后把删除的id赋值
delete_provider_uuid = jres.provider_uuid;
change_provider_uuid = jres.provider_uuid;
}
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">');
//设置默认参数
var value = "";
if(param_name=="op_acc"){
value = op_acc;
} else if(service_method.startWith("service.mtr.tbc.brand_delete")){
//卷烟品牌删除
if(param_name=="brand_uuid"){
value = delete_brand_uuid;
}
} else if(service_method.startWith("service.mtr.tbc.brand_create")){
//卷烟品牌创建
if(param_name=="brand_info"){
value = $.json2str(create_brand_info);
}
} else if(service_method.startWith("service.mtr.tbc.brand_change")){
//卷烟品牌修改
if(param_name=="brand_uuid"){
value = change_brand_uuid;
} else if(param_name=="chg_brand_info"){
value = $.json2str(change_brand_info);
}
} else if(service_method.startWith("service.mtr.tbc.factory_create")){
//厂家新建
if(param_name=="factory_info"){
value = $.json2str(create_factory_info);
}
} else if(service_method.startWith("service.mtr.tbc.factory_change")){
//厂家修改
if(param_name=="factory_uuid"){
value = change_factory_uuid;
} else if(param_name=="chg_factory_info"){
value = $.json2str(change_factory_info);
}
} else if(service_method.startWith("service.mtr.tbc.factory_delete")){
//厂家删除
if(param_name=="factory_uuid"){
value = delete_factory_uuid;
}
} else if(service_method.startWith("service.mtr.tbc.provider_create")){
//供应商新建
if(param_name=="provider_info"){
value = $.json2str(create_provider_info);
}
} else if(service_method.startWith("service.mtr.tbc.provider_change")){
//供应商修改
if(param_name=="provider_uuid"){
value = change_provider_uuid;
} else if(param_name=="chg_provider_info"){
value = $.json2str(change_provider_info);
}
} else if(service_method.startWith("service.mtr.tbc.provider_delete")){
//供应商删除
if(param_name=="provider_uuid"){
value = delete_provider_uuid;
}
}
html.push(value);
html.push('</textarea>');
}
html.push('</div>');
oDiv.html(html.join(''));
$("#test_form").append(oDiv);
}
}
}
,error:function(e){
alert('error:'+e);
}
});
}
String.prototype.startWith=function(str){
var reg=new RegExp("^"+str);
return reg.test(this);
}
</script>
</html>