2
13693261870
2022-09-16 653761a31dfeb50dd3d007e892d69c90bf0cdafc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
<input type="text" type="hidden" id="hidsharprotocol" name="hidsharprotocol" class="form-control col-sm-9" th:value="${resMainInfo.sharprotocol}" />
<form class="form-horizontal" id="jkfwform" method="post" xmlns:th="http://www.w3.org/1999/xhtml">
    <div class="portlet box ltblue">
        <div class="portlet-title">
            接口服务信息
            <div class="caption">
                <i class="fa fa-reorder"></i>
            </div>
            <div class="tools">
                <a class="collapse" onclick="portlet_body_ShowOrHide(this);"></a>
            </div>
        </div>
        <div class="portlet-body">
            <div class="row">
                <div class="col-sm-6">
                    <div class="control-group">
                        <label class="control-label">服务分类<span style="color: red;">*</span></label>
                        <div class="controls input-icon">
                            <select id="servertype" name="servertype" class="form-control col-sm-9" required="">
                                <option value="">--请选择--</option>
                                <option th:selected="(${Res_ExtInterFaceService.servertype}=='WebService')?'true':'false'"  value="WebService">WebService</option>
                                <option th:selected="(${Res_ExtInterFaceService.servertype}=='WEBAPI')?'true':'false'"  value="WEBAPI">WEBAPI</option>
                            </select>
                            <span class="input-warning tooltips" data-original-title="">
                                <i class="fa-warning-sign" style="display: none;margin-left:30px;"></i>
                            </span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12">
                    <div class="control-group">
                        <label class="control-label">服务地址</label>
                        <div class="controls input-icon">
                            <input th:value="${Res_ExtInterFaceService.serverurl}"  id="serverurl" name="serverurl" class="form-control col-sm-10" maxchar="100"/>
                            <a th:if="${Res_ExtInterFaceService.esbid}==null and ${Res_ExtInterFaceService.resourceid} != null" name="esbbtn" style="cursor: pointer;vertical-align:sub;" onclick="showEsbInfo()"><span>注册</span></a>
                            <a th:if="${Res_ExtInterFaceService.esbid}!=null" style="cursor: pointer;vertical-align:sub;" onclick="showEsbInfo()"><span>更新</span></a>
                            <input type="hidden" id="esbid" th:value="${Res_ExtInterFaceService.esbid}" />
                            <input type="hidden" id="zyjc" th:value="${resMainInfo.abbreviation}" />
                            <input type="hidden" id="hidcontextpath" th:value="${Res_ExtInterFaceService.contextpath}"  />
                            <input type="hidden" id="hidagentserverurl" th:value="${Res_ExtInterFaceService.agentserverurl}"  />
                            <input type="hidden" id="hidservertype" th:value="${Res_ExtInterFaceService.servertype}"  />
                            <span class="input-warning tooltips" data-original-title="">
                                <i class="fa-warning-sign" style="display: none;margin-left:30px;"></i>
                            </span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row" style="display: none">
                <div class="col-sm-6">
                    <div class="control-group">
                        <label class="control-label">TOKEN</label>
                        <div class="controls input-icon">
                            <input type="text" id="token" name="token" class="form-control col-sm-9" th:value="${resMainInfo.token}" />
                        </div>
                    </div>
                </div>
            </div>
            <div class="row" >
                <div class="col-sm-6">
                    <div class="control-group">
                        <label class="control-label">是否代理<span style="color: red;">*</span></label>
                        <div class="controls input-icon">
                            <select type="text" id="espproxy" name="espproxy" class="form-control col-sm-9" required="">
                                <option value="">--请选择--</option>
                                <option th:selected="(${resMainInfo.espproxy}==0)?'true':'false'" value="0">否</option>
                                <option th:selected="(${resMainInfo.espproxy}==1)?'true':'false'" value="1">是</option>
                            </select>
                            <span class="input-warning tooltips" data-original-title="">
                                <i class="fa-warning-sign" style="display: none;margin-left:30px;"></i>
                            </span>
                        </div>
                    </div>
                </div>
              
                    <div class="col-sm-6 expiration" style="display: none">
                     <div class="control-group">
                         <label class="control-label">token持续时间</label>
                         <div class="controls input-icon">
                             <input type="text" id="expiration" name="expiration" th:value="${resMainInfo.expiration}" class="form-control col-sm-9"  maxchar="50" />
                             <span class="input-warning tooltips" data-original-title="">
                                 <i class="fa-warning-sign" style="display: none;margin-left:30px;"></i>
                             </span>
                         </div>
                     </div>
                 
               
             </div>
            </div>
            <div class="row">
                <div class="col-sm-12">
                    <div class="control-group">
                        <label class="control-label">帮助说明文档</label>
                        <div class="controls">
                            <!-- 加载编辑器的容器 -->
                            <script id="contents" name="contents" type="text/plain" class="col-sm-11" style="z-index: 0;" ></script>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="form-actions navbar-fixed-bottom" style="z-index: 0;">
        <div style="float: left;">
            <button class="btn btn-primary" id="addJKFWSave" type="button">
                <i class="fa fa-check"></i> 保存
            </button>
            <button th:if="${not #lists.isEmpty(resMainInfoId)}" class="btn btn-danger" id="JKFWDelete" type="button">
                <i class="fa fa-trash-o"></i> 删除
            </button>
            <button class="btn btn-warning" type="button" onclick="window.close()">
                <i class="fa fa-remove"></i> 关闭
            </button>
            <button th:if="${not #lists.isEmpty(resMainInfoId) and resMainInfo.auditstatus eq 2}" class="btn btn-primary" id="copyRes" type="button" onclick="reflayerCopy()">
                <i class="fa fa-copy"></i> 复制
            </button>
        </div>
    </div>
</form>
<div id="resCopyInfo" style="display:none;padding:10px;">
    <div class="col-sm-10">
        <div class="control-group">
            <label class="control-label">资源名称:</label>
            <div class="controls input-icon">
                <input id="copyname" name="copyname" class="form-control col-sm-10" value="" maxchar="50" />
                            <span class="input-warning tooltips" data-original-title="">
                            <i class="fa-warning-sign" style="display: none;margin-left:30px;"></i>
                            </span>
            </div>
        </div>
    </div>
    <div class="col-sm-10">
        <div class="control-group">
            <label class="control-label">服务地址:</label>
            <div class="controls input-icon">
                <input id="copyurl" name="copyurl" class="form-control col-sm-10" value="" maxchar="500" />
                            <span class="input-warning tooltips" data-original-title="">
                            <i class="fa-warning-sign" style="display: none;margin-left:30px;"></i>
                            </span>
            </div>
        </div>
    </div>
    <div style="margin-top:25px;float:right;">
        <button class="btn btn-primary" onclick="copyRes()" type="button">
             <i class="fa fa-check"></i> 保存
         </button>
         <button class="btn btn-warning" type="button" onclick="colseLayer()">
             <i class="fa fa-remove"></i> 关闭
         </button>
    </div>
</div>
<div id="resEsbInfo" style="display:none;padding:10px;" xmlns:th="http://www.w3.org/1999/xhtml">
    <div class="col-sm-12">
        <div class="control-group" style="height: 55px;">
            <label class="control-label" style="padding-right:0;">上下文地址:<br />(全局唯—,必须以/开头)</label>
            <div class="controls input-icon">
                <input id="contexturl" name="contexturl" class="form-control col-sm-12" value=""/>
            </div>
        </div>
    </div>
    <div class="col-sm-12">
        <div class="control-group">
            <label class="control-label" style="line-height:38px;">代理服务地址:</label>
            <div class="controls input-icon">
                <input id="fuwuurl" name="fuwuurl" class="form-control col-sm-12" />
                <input type="hidden" id="wsService" />
                <input type="hidden" id="wsServiceTNS" />
            </div>
        </div>
    </div>
    <div class="col-sm-12" id="selectPort">
        <div class="control-group">
            <label class="control-label" style="line-height:38px;">选择版本:</label>
            <div class="controls input-icon">
                <select class="form-control col-sm-12" id="wsPort">
                </select>
            </div>
        </div>
    </div>
    <div class="col-sm-12">
        <div class="control-group">
            <label class="control-label" style="line-height:38px;">TOKEN:</label>
            <div class="controls input-icon">
                <input id="servicetoken" readonly="readonly" name="servicetoken" class="form-control col-sm-12" />
            </div>
        </div>
    </div>
    <div class="col-sm-12">
        <div class="control-group">
            <label class="control-label" style="line-height:38px;">代理前资源路径:</label>
            <div class="controls input-icon">
                <input id="oldserverurl" name="oldserverurl" class="form-control col-sm-12" th:value="${Res_ExtInterFaceService.oldserverurl}" />
            </div>
        </div>
    </div>
    <div class="col-sm-12">
        <div class="control-group">
            <label class="control-label" style="line-height:38px;">代理后资源路径:</label>
            <div class="controls input-icon">
                <input id="dailihouurl" readonly="readonly" name="dailihouurl" class="form-control col-sm-12"  />
            </div>
        </div>
    </div>
    <input type="hidden" id="hidesbid" />
    <div style="margin-top:25px;float:right;">
        <button class="btn btn-primary" name="esbAgentbtn" onclick="esbSave()" type="button">
            <i class="fa fa-check"></i> 保存
        </button>
        <button class="btn btn-warning" type="button" onclick="colseLayer()">
            <i class="fa fa-remove"></i> 关闭
        </button>
    </div>
</div>
<script th:inline="javascript">
    /*<![CDATA[*/
    var resMainInfoId = [[${resMainInfoId}]];
    /*]]>*/
    $(function () {
        var content = [[${content}]];
        if(content == null) content = "";
        cheackForm("jkfwform");
        initEditor(content != "" ? htmlDecodeByRegExp(content) : "");
    });
 
    //复制弹框
    function reflayerCopy() {
        //弹出一个页面层
        layer.open({
            type: 1,
            title: '复制',
            shadeClose: true,
            shade: false,
            maxmin: false, //开启最大化最小化按钮
            area: ['650px', '215px'],
            content: jQuery("#resCopyInfo")
        });
    }
 
      //关闭复制弹框
    function colseLayer(){
        $(".layui-layer-close1").click();
    }
 
    //实例化编辑器
    function initEditor(content) {
        UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
        UE.Editor.prototype.getActionUrl = function(action){
            if(action == 'uploadimage' || action == 'uploadfile'){
                return "/res/common/uploadueditorfile";
            }else{
                return this._bkGetActionUrl.call(this,action);
            }
        }
        //建议使用工厂方法getEditor创建和引用编辑器实例,如果在某个闭包下引用该编辑器,直接调用UE.getEditor('editor')就能拿到相关的实例
        var ue = UE.getEditor('contents', {
            toolbars: [
                [
                    'source',
                    'undo', //撤销
                    'redo', //重做
                    '|',
                    'bold', //加粗
                    'italic', //斜体
                    'strikethrough', //删除线
                    'underline', //下划线
                    '|',
                    'forecolor', //字体颜色
                    'backcolor', //背景色
                    '|',
                    'insertorderedlist', //有序列表
                    'insertunorderedlist', //无序列表
                    '|',
                    'fontfamily', //字体
                    'fontsize', //字号
                    '|',
                    'justifyleft', //居左对齐
                    'justifyright', //居右对齐
                    'justifycenter', //居中对齐
                    'justifyjustify', //两端对齐
                    '|',
                    'link', //超链接
                    'unlink', //取消链接
                    '|',
                    'simpleupload' //单图上传
                ]
            ],
            initialContent: content, //初始化显示内容
            initialFrameHeight: 300, //初始化高度
            enableAutoSave: false //是否启用自动保存
        });
    }
 
    //解码
    function htmlDecodeByRegExp(str){
        var s = "";
        if(str.length == 0) return "";
        s = str.replace(/&amp;/g,"&");
        s = s.replace(/&lt;/g,"<");
        s = s.replace(/&gt;/g,">");
        s = s.replace(/&nbsp;/g," ");
        s = s.replace(/&#39;/g,"\'");
        s = s.replace(/&quot;/g,"\"");
        return s;
    }
 
    var admin = [[${admin}]];
    var auditstatus = [[${resMainInfo.auditstatus}]];
    $('#addJKFWSave').on('click', function() {
        var content = UE.getEditor('contents').getContent();
        //判断当前用户是否是管理员,是管理员或是未提交的资源才可以修改资源相关信息
        if(admin == true || auditstatus == 0 || auditstatus == null) {
        if($('#jkfwform').valid()){
            $('#jkfwform').ajaxSubmit({
                url: '/res/resExtInterFaceService/insertSelectiveAndUpdate?resourceid=' +resMainInfoId,
                type: 'post',
                dataType: 'text',
                data: {
                    helpurl:htmlEncodeByRegExp(content)
                },
                success: function (data) {
                    if(data == "1") {
                        alert("保存成功!");
                        UE.getEditor('contents').destroy();
                        // parent.FTabPages.resetTab();
                        reloadExt("ExtInterFaceService");
                    } else  {
                        alert("保存失败!");
                    }
                },
                error: function (e) {
                    alert(e.message);
                }
            });
        }
        else {
            // alert("您输入的信息存在错误,请更正后再提交!");
        }
        }
        else {
            alert("注销后才可以对该资源进行修改!");
        }
    });
 
    //转码
    function htmlEncodeByRegExp(str){
        var s = "";
        if(str.length == 0) return "";
        s = str.replace(/&/g,"&amp;");
        s = s.replace(/</g,"&lt;");
        s = s.replace(/>/g,"&gt;");
        s = s.replace(/ /g,"&nbsp;");
        s = s.replace(/\'/g,"&#39;");
        s = s.replace(/\"/g,"&quot;");
        return s;
    }
 
    $("#JKFWDelete").click(function() {
        if(confirm("删除扩展信息,确定删除吗?")){
            $.ajax({
                url: '/res/resExtInterFaceService/deleteByPrimaryKey?resourceid=' + resMainInfoId,
                type: 'post',
                dataType: 'json',
                data: {},
                success: function (data) {
                    if (data == "1") {
                        delService();//addbydsh 2018/12/13
                        UE.getEditor('contents').destroy();
                        alert("删除成功!");
                        //parent.FTabPages.resetTab();
                        reloadExt("ExtInterFaceService");
                    } else {
                        alert("删除失败!");
                    }
                },
                error: function (e) {
                    alert(e.message)
                }
            });
        }
    });
 
    //复制
    function copyRes(){
        if($("#copyname").val() == ""){
            alert("资源名称不能为空!");
            return false;
        }
        if($("#copyurl").val() == ""){
            alert("服务地址不能为空!");
            return false;
        }
        $.ajax({
            url: '/res/ZiYuan/copyMainInfoAndKZ',
            type: 'post',
            dataType: 'json',
            data: {
                "resourceid":resMainInfoId,
                "copyname":$("#copyname").val(),
                "copyurl":$("#copyurl").val(),
                "type":"ExtInterFaceService"
            },
            success: function (data) {
                if(data != 0){
                    alert("复制成功!")
                    parent.location.href = "/res/ResManage/ResRegister/ResEdit?resMainInfoId=" + data;
                }
            },
            error: function (e) {
                alert(e.message)
            }
        });
    }
</script>
<script th:inline="javascript">
    var esbWebServiceHost = [[${esbWebServiceHost}]];
    var esbHost = [[${esbHost}]];
    var esbUrl = [[${esbUrl}]];
 
    //弹出ESB代理
    function showEsbInfo () {
        if ($("#servertype").val() == "") {
            alert("请选择服务分类!");
            return false;
        }
        if ($("#serverurl").val() == "") {//addbydsh 2018/12/13
            alert("请输入服务地址!");
            return false;
        }
        $("#resEsbInfo input").val("");//清空文本框
        $("[name=esbAgentbtn]").show();//按钮显示
        var isService = $("#servertype").val() == "WebService" ? true : false;
        var oldserverurl = $("#oldserverurl").attr("value");//代理前路径
        layer.open({
            type: 1,
            title: 'ESB代理',
            shadeClose: true,
            shade: false,
            maxmin: false, //开启最大化最小化按钮
            area: ['720px', '470px'],
            content: jQuery("#resEsbInfo")
        });
        $("#servicetoken").val($("#token").val());
        var isChangeType = $("#servertype").val() != $("#hidservertype").val() ? true : false;
        $("#oldserverurl").val(oldserverurl);
        if (oldserverurl == "" || isChangeType || (isService && oldserverurl.indexOf("wsdl")==-1)) {
            $("#oldserverurl").val($("#serverurl").val());
            $("#fuwuurl").val($("#serverurl").val());
        } else {
            $("#fuwuurl").val(oldserverurl);
        }
        if ($("#hidagentserverurl").val() != "" && !isChangeType && (isService && oldserverurl.indexOf("wsdl")!=-1)) {
            $("#fuwuurl").val($("#hidagentserverurl").val());
        }
        if (isService) {
            $("#selectPort").show();
            getWsPort($("#oldserverurl").val());
        } else {
            $("#selectPort").hide();
        }
        //上下文地址
        if ($("#hidcontextpath").val() != "" && !isChangeType && (isService && oldserverurl.indexOf("wsdl")!=-1)) {
            $("#contexturl").val($("#hidcontextpath").val());
        } else {
            if(isService) {
                var surl = oldserverurl.indexOf("wsdl")!=-1?oldserverurl:$("#serverurl").val();
                $("#contexturl").val("/" + resMainInfoId + "/" + surl.substring(surl.lastIndexOf('/') + 1, surl.lastIndexOf(".")));
            }else{
                var surl = $("#oldserverurl").val();
                var url = surl.indexOf("//")!=-1?surl.split("://")[1].substring(surl.split("://")[1].indexOf("/"),surl.split("://")[1].length):surl.substring(surl.indexOf("/"),surl.length);
                $("#contexturl").val((url.indexOf(resMainInfoId) != -1 ?"":("/" + resMainInfoId)) + url);
            }
        }
    }
    //ESB代理注册、更新
    function esbSave(){
        if ($("#contexturl").val() == "") {
            alert("上下文地址不能为空!");
            return false;
        }
        if($("#contexturl").val().substring(0,1) != "/"){
            alert("请输入正确的上下文地址!");
            return false;
        }
        var isService = $("#servertype").val() == "WebService" ? true : false;
        if(isService && $("#wsPort").val() == ""){
            alert("请选择版本!");
            return false;
        }
        if(isService){
            if($("#oldserverurl").val().indexOf(esbWebServiceHost) != -1){
                alert("代理前资源路径错误,请重新输入!");
                return false;
            }
        }else{
            if($("#oldserverurl").val().indexOf(esbHost) != -1){
                alert("代理前资源路径错误,请重新输入!");
                return false;
            }
        }
        //检验上下文地址是否唯一(若为更新,上下文地址与原来一样则不用校验)
        if($("#esbid").val() =="" || ($("#esbid").val() != "" && $("#contexturl").val() != $("#hidcontextpath").val())){
            $.ajax({
                url: '/res/resExtInterFaceService/isExistContextPath',
                type: 'post',
                dataType: 'text',
                data: {
                    'contextpath': deleteSprit($("#contexturl").val()),
                },
                success: function (data) {
                    if(data > 0){
                        alert("上下文地址已存在,请检查!");
                        return false;
                    }else{
                        submit();
                    }
                }
            });
        }else{
            submit();
        }
    }
    //提交
    function submit(){
        var lasturl = $("#oldserverurl").val().replace($("#fuwuurl").val(), "");
        lasturl += (lasturl.indexOf("?wsdl") == -1) ?("?wsdl"):"";
        var newurl = "";
        if($("#servertype").val() == "WebService"){
            newurl = esbWebServiceHost + $("#contexturl").val() + lasturl;
        }else{
            newurl = esbHost + $("#contexturl").val();
        }
        var url = esbUrl + "/esb/";
        var isPublic = $("#hidsharprotocol").val() == "完全公开" ? 1 : 0;
        if($("#esbid").val() != ""){
            if($("#servertype").val() == "WebService"){
                url += "updateArcgisServer?esbId="+$("#esbid").val()+"&zyid="+$("#resMainInfoId").val()
                    +"&serverUrl="+encodeURI($("#oldserverurl").val()) +"&zyjc="+encodeURI($("#zyjc").val())+"&arcgisToken="
                    +encodeURI($("#servicetoken").val())+"&contextPath="+encodeURI($("#contexturl").val())+"&urlid=&sublayer=&isWS=1&wsPort="
                    +$("#wsPort").val()+"&wsService="+$("#wsService").val()+"&wsServiceTNS="+$("#wsServiceTNS").val()+"&isPublic="+isPublic;
            }else{
                url += "updateArcgisServer?esbId="+$("#esbid").val()+"&zyid="+$("#resMainInfoId").val()
                    +"&serverUrl="+encodeURI(deleteSprit($("#oldserverurl").val())) +"&zyjc="+encodeURI($("#zyjc").val())+"&arcgisToken="
                    +encodeURI($("#servicetoken").val())+"&contextPath="+encodeURI(deleteSprit($("#contexturl").val()))+"&urlid=&isPublic="+isPublic+"&isWS=0&sublayer=";
            }
        }else{
            if($("#servertype").val() == "WebService"){
                url += "addArcgisServer?zyid="+$("#resMainInfoId").val()+"&serverUrl="+encodeURI($("#oldserverurl").val()) +"&zyjc="+encodeURI($("#zyjc").val())
                    +"&arcgisToken="+encodeURI($("#servicetoken").val())+"&contextPath="+encodeURI($("#contexturl").val())
                    +"&urlid=&sublayer=&isWS=1&wsPort="+$("#wsPort").val()+"&wsService="+$("#wsService").val()+"&wsServiceTNS="+$("#wsServiceTNS").val()+"&isPublic="+isPublic;
            }else{
                url += "addArcgisServer?zyid="+$("#resMainInfoId").val()+"&serverUrl="+encodeURI(deleteSprit($("#oldserverurl").val())) +"&zyjc="+encodeURI($("#zyjc").val())
                    +"&arcgisToken="+encodeURI($("#servicetoken").val())+"&contextPath="+encodeURI(deleteSprit($("#contexturl").val()))
                    +"&urlid=&isPublic="+isPublic+"&isWS=0&sublayer=";
            }
        }
        $.ajax({
            url: url,
            type: "GET",
            dataType: 'jsonp',
            callback: "callback",
            success:function(data){
                $("[name=esbAgentbtn]").hide();
                if(data.result == 0){
                    var esbid = data.esbId;
                    $("#dailihouurl").val(deleteSprit(newurl));
                    $("#serverurl").val(deleteSprit(newurl));
                    updateEsbinfo(resMainInfoId,newurl,esbid);
                }else{
                    alert($("#esbid").val() != ""?"更新失败":"注册失败");
                }
            },
            error: function (e) {
                console.log(e);
            }
        });
    }
    //获取webservice
    function getWsPort(oldserverurl){
        $.ajax({
            url: "/res/webservice/getWebServiceInfo?webServiceUrl=" + oldserverurl,
            type: 'get',
            async: false,
            success: function (result) {
                if (result != "") {
                    var data = eval("(" + result + ")");
                    var wsports = data.wsports;
                    $("#wsPort").empty().append("<option value=\"\">--请选择--</option>");
                    for (var i = 0; i < wsports.split(",").length; i++) {
                        $("#wsPort").append("<option>" + wsports.split(",")[i] + "</option>");
                    }
                    $("#wsService").val(data.servicename);
                    $("#wsServiceTNS").val(data.tns);
                }
            },
            error: function (e) {
                console.log("error");
            }
        });
    }
    //更新esb信息
    function updateEsbinfo(resMainInfoId,newurl,esbid){
        $.ajax({
            url: '/res/resExtInterFaceService/insertSelectiveAndUpdate?resourceid=' +resMainInfoId,
            type: 'post',
            data: {
                serverurl:deleteSprit(newurl),
                oldserverurl:deleteSprit($("#oldserverurl").val()),
                esbid:esbid,
                token:$("#servicetoken").val(),
                contextpath:deleteSprit($("#contexturl").val()),
                agentserverurl:deleteSprit($("#fuwuurl").val())
            },
            success: function (data) {
                if(data == "1") {
                    alert($("#esbid").val() != ""?"更新成功":"注册成功");
                    $("#hidcontextpath").val($("#contexturl").val());
                    $("#hidagentserverurl").val($("#fuwuurl").val());
                    UE.getEditor('contents').destroy();
                    // parent.FTabPages.resetTab();
                    reloadExt("ExtInterFaceService");
                }
            },
            error: function (e) {
                alert(e.message);
            }
        });
    }
    //WEBAPI注册取掉斜杠
    function deleteSprit(str){
        var restr = str;
        if(str != "" && str.length != 0 && str.substring(str.length-1,str.length) == "/"){
            restr = str.substring(0,str.length-1);
        }
        return restr;
    }
    //删除esb服务   addbydsh 2018/12/13
    function delService(){
        if($("#esbid").val() != ""){
            $.ajax({
                url: esbUrl + "/esb/delService?esbId="+$("#esbid").val(),
                type: "GET",
                dataType: 'jsonp',
                callback: "callback",
                success:function(data){
                    console.log(data);
                },
                error: function (e) {
                }
            });
        }
    }
</script>