瀏覽代碼

服务管理-参数添加问题解决

demon 8 年之前
父節點
當前提交
64aabea2c5

+ 1 - 0
hos-admin/src/main/java/com/yihu/hos/system/controller/AppController.java

@ -339,4 +339,5 @@ public class AppController extends BaseController {
    }
}

+ 19 - 14
hos-admin/src/main/webapp/WEB-INF/ehr/jsp/system/app/appServiceDetail.jsp

@ -2,6 +2,11 @@
<%@include file="/WEB-INF/ehr/commons/jsp/commonInclude.jsp" %>
<!--######应用管理页面 > 应用详情模板页######-->
<style>
    .l-text{border: 0}
    .params{border: 0}
    .l-textbox{border: 0}
</style>
<div id="div_info_form" class="m-form-inline" style="padding-top:10px;" data-role-form>
    <div class="m-form-group" >
@ -9,14 +14,14 @@
        <div class="m-form-control ">
            <div class="l-text">
                <input type="text" class="l-text-field required" placeholder="请填写服务名称" name="name"/>
                <input type="text" class="l-text-field required" readonly="readonly"  name="name"/>
            </div>
        </div>
        <label style="width:110px;"><span class="red">*&nbsp;</span>版本:</label>
        <div class="m-form-control">
            <div class="l-text">
                <input type="text" style="width:180px;" class="l-text-field" placeholder="请填写版本" name="version"/>
                <input type="text" style="width:180px;" readonly="readonly" class="l-text-field"  name="version"/>
            </div>
        </div>
@ -24,7 +29,7 @@
        <div class="m-form-control">
            <div class="l-text">
                <input  type="text" id="txtValid" class="l-text-field required"  name="valid"/>
                <input  type="text" id="txtValid" class="l-text-field required" readonly="readonly"  name="valid"/>
            </div>
        </div>
    </div>
@ -35,7 +40,7 @@
        <div class="m-form-control">
            <div class="l-text" style="width:800px;">
                <input type="text"  class="l-text-field" placeholder="请填写端点" name="endpoint"/>
                <input type="text"  class="l-text-field" readonly="readonly" name="endpoint"/>
            </div>
        </div>
    </div>
@ -45,7 +50,7 @@
        <div class="m-form-control">
            <div class="l-text" style="width:800px;">
                <input type="text" class="l-text-field" placeholder="请填写描述内容" name="description"/>
                <input type="text" class="l-text-field" readonly="readonly" name="description"/>
            </div>
        </div>
    </div>
@ -55,7 +60,7 @@
        <div class="m-form-control">
            <div class="l-text" style="width:800px;">
                <input type="text" id="healthReportType"  class="l-text-field required" placeholder="请选择监控类型 " name="healthReportType"/>
                <input type="text" id="healthReportType" readonly="readonly"  class="l-text-field required"  name="healthReportType"/>
            </div>
        </div>
    </div>
@ -65,7 +70,7 @@
        <div class="m-form-control">
            <div class="l-text" style="width:800px;">
                <input type="text" id="metricsReportType" class="l-text-field required" placeholder="请选择监控类型 " name="metricsReportType"/>
                <input type="text" id="metricsReportType" class="l-text-field required" readonly="readonly" name="metricsReportType"/>
            </div>
        </div>
    </div>
@ -76,17 +81,16 @@
        <div class="m-form-control">
            <div class="l-text"  style="width:800px;height:100px;" >
                <textarea  style="width:800px;height:100px;" class="l-text-field required"    placeholder="请填写 输入格式 " name="requesModule"></textarea>
                <textarea  style="width:800px;height:100px;" class="l-text-field required"    readonly="readonly" name="requesModule"></textarea>
            </div>
        </div>
    </div>
    <div class="m-form-group">
        <label>参数:</label>
    <div class="m-form-group" >
        <label><span class="red"></span>参数:</label>
        <div class="m-form-control">
            <input type="text" id="serviceCondition"/>
        <div class="m-form-control" id="paramDiv">
        </div>
    </div>
@ -97,7 +101,7 @@
        <div class="m-form-control">
            <div class="l-text"  style="width:800px;height:100px;">
                <textarea style="width:800px;height:100px;"   class="l-text-field required" placeholder="请填写 输出正确格式 " name="responeResult"></textarea>
                <textarea style="width:800px;height:100px;"   class="l-text-field required" readonly="readonly" name="responeResult"></textarea>
            </div>
        </div>
    </div>
@ -107,7 +111,7 @@
        <div class="m-form-control">
            <div class="l-text"  style="width:800px;height:100px;" >
                <textarea style="width:800px;height:100px;"  class="l-text-field required" placeholder="请填写 输出错误格式 " name="responeError"></textarea>
                <textarea style="width:800px;height:100px;"  class="l-text-field required" readonly="readonly" name="responeError"></textarea>
            </div>
        </div>
    </div>
@ -117,6 +121,7 @@
    <div class="m-form-group" style="display: none;">
        <input name="id" hidden="hidden"/>
        <input name="appId" hidden="hidden"/>
        <input name="requestParameterList" id="requestParameterList" hidden="hidden"/>
    </div>
    <div class="m-form-bottom">
        <div id="btnCancel" class="l-button l-button-no">

+ 48 - 55
hos-admin/src/main/webapp/WEB-INF/ehr/jsp/system/app/appServiceDetailJs.jsp

@ -6,12 +6,12 @@
    /* *************************** 模块初始化 ***************************** */
    var editorAppService = {
        //form
        actionUrl:"${contextRoot}/app/addAppService",
        $condition: null,
        $valid:"${model.valid}",
        init: function () {
            this.bindEvents();
            this.initForm();
            this.resolveParam();
        },
        initForm: function () {
            var me = this;
@ -20,11 +20,30 @@
            if(modelString!=undefined && modelString!=null && modelString.length>0)
            {
                var valid = "${model.valid}";
                if(valid=='1'){
                    valid="有效";
                }else if(valid=='0'){
                    valid="无效";
                }else{
                    valid="空";
                }
                var healthReportType = "${model.healthReportType}";
                if(healthReportType=='1'){
                    healthReportType="推送";
                }else if(healthReportType=='0'){
                    healthReportType="拉取";
                }else{
                    healthReportType="空";
                }
                var metricsReportType = "${model.metricsReportType}";
                liger.get("txtValid").selectValue(valid);
                liger.get("healthReportType").selectValue(healthReportType);
                liger.get("metricsReportType").selectValue(metricsReportType);
                if(metricsReportType=='1'){
                    metricsReportType="推送";
                }else if(metricsReportType=='0'){
                    metricsReportType="拉取";
                }else{
                    metricsReportType="空";
                }
                data={
                    id: "${model.id}",
@ -39,22 +58,15 @@
                   requestProtocol: "${model.requestProtocol}",
                   requesModule: "${model.requesModule}".replace(/<br>/ig,"\n"),
                   requestMethod: "${model.requestMethod}",
                   healthReportType: "${model.healthReportType}",
                   healthReportType: healthReportType,
                   healthEndpoint: "${model.healthEndpoint}",
                   responeResult:"${model.responeResult}".replace(/<br>/ig,"\n"),
                   responeError: "${model.responeError}".replace(/<br>/ig,"\n"),
                   metricsReportType: "${model.metricsReportType}",
                   metricsEndpoint: "${model.metricsEndpoint}"
                   metricsReportType: metricsReportType,
                    requestParameterList:'${model.requestParameterList}',
                    metricsEndpoint: "${model.metricsEndpoint}"
                };
                me.actionUrl = "${contextRoot}/app/updateAppService";
            }else{
                liger.get("txtValid").selectValue("1");//默认有效
                liger.get("healthReportType").selectValue("");
                liger.get("metricsReportType").selectValue("");
                data={
                    appId: "${appId}"
                };
            }
            $("#div_info_form").ligerAutoForm({
@ -73,54 +85,35 @@
        },
        bindEvents: function () {
            var me = this;
            $(".m-form-bottom").on("click","#btnSave",function () {
                if(!$("#div_info_form").ligerAutoForm("validate")){
                    return;
                }
                var data = $("#div_info_form").ligerAutoForm("getData");
                $.ajax({ //ajax处理
                    type: "POST",
                    url : me.actionUrl,
                    dataType : "json",
                    data:data,
                    cache:false,
                    success :function(data){
                        if(data.successFlg) {
                            parent.appService.dialogSuccess(data.message);
                        }
                        else{
                            $.ligerDialog.error(data.message);
                        }
                    },
                    error :function(data){
                        $.ligerDialog.error("Status:"+data.status +"(" +data.statusText+")");
                    }
                });
            });
            $(".m-form-bottom").on("click","#btnCancel",function () {
                parent.appService.dialog.close();
            });
            $("#txtValid").ligerComboBox({data : [{"value":"有效","code":"1"},{"value":"无效","code":"0"}],
                cancelable:false,
                onSuccess:function(data){
                }});
            $("#healthReportType").ligerComboBox({data : [{"value":"请选择类型","code":""},{"value":"推送","code":"1"},{"value":"拉取","code":"0"}],
                cancelable:false,
                onSuccess:function(data){
                }});
            $("#metricsReportType").ligerComboBox({data : [{"value":"请选择类型","code":""},{"value":"推送","code":"1"},{"value":"拉取","code":"0"}],
                cancelable:false,
                onSuccess:function(data){
                }});
            $("#resourceCondition").css("height", (window.screen.height - 200) / 5).css("overflow", "auto");
            editorAppService.$condition = $('#serviceCondition').ligerCondition({
                stdDictUrl: "${contextRoot}/std/getDictByScheme",
            });
        },
        resolveParam: function () {
            //将json的参数列表解析出来
            var paramStr = $("#requestParameterList").val();
            if (paramStr != ""){
                var paramJson = $.parseJSON(paramStr);
                var index =1;
                for (var name in paramJson) {
                    var type = paramJson[name];
                    //动态添加参数
                    var html = '<div class="params" dataIndex="' + index + '" id="paramGroup' + index + '">';
                    html += '<div class="m-form-control" controlType="textbox" id="divName' + index + '_div" style="margin-left:0px;">参数' + index + ' : ' +
                            '<input type="text" id="name' + index + '" value='+name+' readonly="readonly"  class="l-textbox"/></div>';
                    html += '<div class="m-form-control" controlType="textbox" id="divType' + index + '_div" style="margin-left:0px;"><div class="l-text-wrapper"><div style="padding-left:10px;width: 100%;height: 100%;line-height:30px;"> 类型:&nbsp;</div></div>' +
                            '<input type="text" id="type' + index + '" value='+type+' data-type="select" readonly="readonly"  class="l-textbox"/></div></div>';
                    $("#paramDiv").append(html);
                    index++;
                }
            }
            $(".l-text-combobox").find("div[class=l-trigger]").remove();
        }
    };

+ 9 - 9
hos-admin/src/main/webapp/WEB-INF/ehr/jsp/system/app/editorAppService.jsp

@ -88,7 +88,7 @@
        </div>
    </div>
    <div class="m-form-group" >
        <label><span class="red">*&nbsp;</span></label>
        <label><span class="red"></span></label>
        <div class="m-form-control">
            <div class="l-button">
@ -98,15 +98,15 @@
    </div>
    <div class="m-form-group" >
        <label><span class="red">*&nbsp;</span></label>
    <%--<div class="m-form-group" >--%>
        <%--<label><span class="red">*&nbsp;</span></label>--%>
        <div class="m-form-control">
            <div class="l-button">
                <div class="l-button l-button-green" style="clear:both;margin-left:0px;" id="menu_test"><span>测试参数获取问题</span></div>
            </div>
        </div>
    </div>
        <%--<div class="m-form-control">--%>
            <%--<div class="l-button">--%>
                <%--<div class="l-button l-button-green" style="clear:both;margin-left:0px;" id="menu_test"><span>测试参数获取问题</span></div>--%>
            <%--</div>--%>
        <%--</div>--%>
    <%--</div>--%>
    <%--<div class="m-form-group">--%>
        <%--<label>参数:</label>--%>

+ 53 - 18
hos-admin/src/main/webapp/WEB-INF/ehr/jsp/system/app/editorAppServiceJs.jsp

@ -45,6 +45,7 @@
                   responeResult:"${model.responeResult}".replace(/<br>/ig,"\n"),
                   responeError: "${model.responeError}".replace(/<br>/ig,"\n"),
                   metricsReportType: "${model.metricsReportType}",
                    requestParameterList:'${model.requestParameterList}',
                   metricsEndpoint: "${model.metricsEndpoint}"
                };
@ -57,7 +58,6 @@
                    appId: "${appId}"
                };
            }
            $("#div_info_form").ligerAutoForm({
                data:data,
                validate:{
@ -67,10 +67,9 @@
                    endpoint: {
                        required:true
                    }
                },
            });
            me.resolveParam();
        },
        bindEvents: function () {
            var me = this;
@ -78,6 +77,7 @@
                if(!$("#div_info_form").ligerAutoForm("validate")){
                    return;
                }
                me.spliceParams();
                var data = $("#div_info_form").ligerAutoForm("getData");
                $.ajax({ //ajax处理
                    type: "POST",
@ -108,7 +108,7 @@
            });
            $(".l-button").on("click","#menu_test",function () {
                me.getNewIndex();
                me.spliceParams();
            });
            //下拉框值初始化
@ -133,11 +133,18 @@
        },
        newItem: function () {
            var index = editorAppService.index;
            var html = '<div class="m-form-group" data-index="'+index+'" id="paramGroup'+index+'">';
            html += '<div class="m-form-control" controlType="textbox" id="divName'+index+'_div" style="margin-left:0px;">参数'+index+':' +
            var index;
            var size = $(".params").length;
            if(size!="" && size>0){
                index=$("#"+$(".params")[size-1].id).attr("dataIndex");//获取参数的个数
                index++;
            }else{
                index=1;
            }
            var html = '<div class="params" dataIndex="'+index+'" id="paramGroup'+index+'">';
            html += '<div class="m-form-control" controlType="textbox" id="divName'+index+'_div" style="margin-left:0px;">参数'+index+' : ' +
                    '<input type="text" id="name'+index+'"  class="l-textbox"/></div>';
            html += '<div class="m-form-control" controlType="textbox" id="divType'+index+'_div" style="margin-left:0px;"><div class="l-text-wrapper"><p style="margin-left:0px;width: 100%;height: 100%;vertical-align: middle;">类型:</p></div>' +
            html += '<div class="m-form-control" controlType="textbox" id="divType'+index+'_div" style="margin-left:0px;"><div class="l-text-wrapper"><p style="padding-left:10px;width: 100%;height: 100%;line-height:30px;">类型:</p></div>' +
                    '<input type="text" id="type'+index+'" data-type="select"  class="l-textbox"/></div>';
            html += '<div class="m-form-control"><a class="m-btn-cancle" href="javascrip:void()" style="display:block;" onclick="$(\'#paramGroup'+index+'\').remove()"></a></div>';
@ -147,24 +154,52 @@
                cancelable:false,
                onSuccess:function(data){
                }});
            var newIndex =  parseInt(index) + 1;
            editorAppService.index=newIndex;
        },
        spliceParams: function () {
            //参数拼接成json
            var inputs = $("#paramDiv").find("div[class=m-form-group]");
            var params = {};
            for(var i =0 ; i < inputs.length ; i ++)
            {
                var id = $("#"+inputs[i].id).attr("dataIndex");
                var name = $("#name"+id).val();
                var type = $("#type"+id).val();
                params[name]=type;
            }
            $("#requestParameterList").val(JSON.stringify(params));
        },
        resolveParam: function () {
            //将json的参数列表解析出来
        },
        getNewIndex:function(){
            var inputs = $("#paramDiv div .m-form-group");
            for(var i =0 ; i < inputs.length ; i ++)
            {
                alert(inputs[i].attr("data-index"))
            var index = 1;
            var paramStr = $("#requestParameterList").val();
            if (paramStr != ""){
                var paramJson = $.parseJSON(paramStr);
            for (var name in paramJson) {
                var type = paramJson[name];
                //动态添加参数
                var html = '<div class="params" dataIndex="' + index + '" id="paramGroup' + index + '">';
                html += '<div class="m-form-control" controlType="textbox" id="divName' + index + '_div" style="margin-left:0px;">参数' + index + ' : ' +
                        '<input type="text" id="name' + index + '" value='+name+'  class="l-textbox"/></div>';
                html += '<div class="m-form-control" controlType="textbox" id="divType' + index + '_div" style="margin-left:0px;"><div class="l-text-wrapper"><div style="padding-left:10px;width: 100%;height: 100%;line-height:30px;"><span class="red">*&nbsp;</span> 类型:&nbsp;</div></div>' +
                        '<input type="text" id="type' + index + '" value='+type+' data-type="select"  class="l-textbox"/></div>';
                html += '<div class="m-form-control"><a class="m-btn-cancle" href="javascrip:void()" style="display:block;" onclick="$(\'#paramGroup' + index + '\').remove()"></a></div>';
                $("#paramDiv").append(html);
                $("#type" + index).ligerComboBox({
                    data: [{"value": "String", "code": "String"}, {
                        "value": "Integer",
                        "code": "Integer"
                    }, {"value": "Date", "code": "Date"}],
                    cancelable: false,
                    onSuccess: function (data) {
                    }
                });
                liger.get("type"+index).selectValue(type);
                index++;
            }
        }
        }
    };