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
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
var ResourceFlowConfig = null;
var CurrentFlow = null;
var isframe = false;
var isFirst = true;
 
$(function () {
    var f_project_def = function () {
        this.onTab = function (actionJ, params) { //切换页签
            var myaction = actionJ.action;
            var url = myaction + "?random=" + Math.random() + "&resMainInfoId=" + $("#resMainInfoId").val();
            FTabPages.onTab({
                container: "#div_" + myaction,
                isErase: actionJ.isErase,
                url: url,
                params: {},
                callback: function () {
                    if (actionJ.callback != null) {
                        actionJ.callback();
                    }
                }
            });
        };
 
        FTabPages.init({
            container: "#div_ResResourceClass",
            isErase: false
        });
 
        return {
            onTab: function (actionJ, path) {
                onTab(actionJ, path);
            }
        };
    }();
 
    $.ajax({
        url: "../../../config/ResourceFlowConfig.json",
        dataType: "json",
        success: function (result) {
            ResourceFlowConfig = result;
        },
        error: function (e) {
            console.log(window.location.href + ":" + e.message);
        }
    });
 
    //设置高宽
    var h = window.innerHeight;
    var w = window.innerWidth;
    $(".card-box").height(h - 68);
 
    $("#basic-form").children("div").steps({
        headerTag: "h3",//标头标签用于在声明的向导区域中查找步骤按钮文本。
        bodyTag: "section",//body标签用于查找声明的向导区域中的步骤内容。
        transitionEffect: "slideLeft",
        stepsOrientation: "vertical",
        titleTemplate: "<span class=\"number\">#index#</span> #title#",
        onStepChanging: function (event, currentIndex, newIndex) {
            var resourceclass = $("#hidResourceClass").val();
            if (newIndex == 0) {
                f_project_def.onTab({action: "ResResourceClass", isErase: false});
            } else if (newIndex == 1 && resourceclass == "") {
                alert("请选择资源类型!");
                return false;
            } else {
                if (currentIndex > newIndex) {
 
                } else if (newIndex > 1) {
                    var form = $("#div_" + CurrentFlow.steps[currentIndex - 1].url + " form");
                    if (form.length > 0) {
                        if (!$('#' + form[0].id).valid()) {
                            return false;
                        }
                    }
                }
                if (CurrentFlow.steps[newIndex - 1].isload == false) {
                    f_project_def.onTab({action: "MainInfo", isErase: false});
                } else {
                    if (CurrentFlow.steps[newIndex - 1].isframe) {
                        isframe = true;
                    } else {
                        f_project_def.onTab({action: CurrentFlow.steps[newIndex - 1].url, isErase: false});
                    }
                }
            }
            return true;
        },
        onStepChanged: function (event, currentIndex, priorIndex) {
            if (currentIndex != 0) {
                //隐藏其他流程div
                var section = $(".content.clearfix section");
                for (var i = 0; i < section.length; i++) {
                    if (section[i].children.length > 0) {
                        section[i].children[0].style.display = "none";
                    }
                }
                $("#div_" + CurrentFlow.steps[currentIndex - 1].url).show();
            }
            if (isframe) {
                var iframe = $("#div_" + CurrentFlow.steps[currentIndex - 1].url).find("iframe");
                if (iframe.length == 0) {
                    var resourceclass = $("#hidResourceClass").val();
                    var url = CurrentFlow.steps[currentIndex - 1].url + "?ResourceClass=" + resourceclass;
                    $("#div_" + CurrentFlow.steps[currentIndex - 1].url).html("<iframe id=\"FullMapFrame\" name=\"FullMapFrame\" src=\"" + url + "\" width=\"100%\" height=\"" + (window.innerHeight - 168) + "\" scrolling=\"no\" style=\"border: 0;\"></iframe>");
                }
                isframe = false;
            }
 
            return true;
        },
        onCanceled: function (event) {
            //取消后触发
            window.close();
        },
        onFinishing: function (event, currentIndex) {
            //在完成之前触发,可以通过返回“false”来防止完成。
            var form = $("#div_" + CurrentFlow.steps[currentIndex - 1].url + " form");
            if (form.length > 0) {
                if (!$('#' + form[0].id).valid()) {
                    return false;
                }
            }
 
            //表单保存
            var resourceclass = $("#hidResourceClass").val();
            $("#resourceclass").val(resourceclass);
            var isSaveMainInfo = false, isSaveExt = false, resourceId = null, isCheckUrl = true, extMapUrlStr = "";
            //主表保存
            if (resourceclass == "KJ_JCDT" || resourceclass == "KJ_ZTDT" || resourceclass == "KJ_YWTC") {
                var regStr = /^(http|https):\/\/.+$/;
                var re = new RegExp(regStr);
                if ($("#typeandurl").val() != "" && $("#serverurl").val() != "" && $("#serverurl").val() != "--") {
                    var typeandurl = $("#typeandurl").val();
                    var serverurl = $("#serverurl").val();
                    var esbid = ($("#esbid").val() != "" && $("#esbid").val() != undefined) ? $("#esbid").val() : 0;
                    if (isCheckUrl && !re.test(serverurl)) {
                        isCheckUrl = false;
                    }
                    if (esbid != 0) {
                        newesbidList.push(esbid);
                    }
                    var oldserverurl = ($("#oldserverurl").val() && $("#oldserverurl").val() != undefined) ? $("#oldserverurl").val() : "";
                    extMapUrlStr += typeandurl + "," + serverurl + "," + esbid + "," + oldserverurl + "|";
                }
                if (!isCheckUrl) {
                    alert("请输入正确的服务地址!");
                    return false;
                }
            }
            //判断当前用户是否是管理员,是管理员或是未提交的资源才可以修改资源相关信息
            if (admin == true || auditstatus == 0 || auditstatus == null || auditstatus == -1) {
                var resMainInfoId = $("#resMainInfoId").val();
                if (resMainInfoId != "") {//修改
                    SetAnQuanJiBie();
                    SetGuanJianZi();
                    //修改
                    var image = $('#uploadInput')[0].files[0];
                    if (image != null) {
                        var formdata = new FormData();
                        formdata.append('myFile', $('#uploadInput')[0].files[0]);
                        $.ajax({
                            url: "/res/testuploadimg",
                            type: "POST",
                            data: formdata,
                            cache: false,
                            async: false,
                            processData: false,  // 告诉jQuery不要去处理发送的数据
                            contentType: false,  // 告诉jQuery不要去设置Content-Type请求头
                            success: function (data) {
                                if (data == -1) {
                                    alert("文件格式不正确,请重新上传!");
                                } else if (data == 0) {
                                    alert("上传图片失败");
                                } else {
                                    $("#imgurl").val(data);
                                    $('#mainfrom').ajaxSubmit({
                                        url: '/res/ziYuanUpdaate?resourceid=' + resMainInfoId,
                                        type: 'post',
                                        dataType: 'text',
                                        async: false,
                                        data: {},
                                        success: function (data1) {
                                            var json = eval('(' + data1 + ')');
                                            if (json.result == "1") {
                                                isSaveMainInfo = true;
                                                resourceId = json.ziyuanId;
                                                $("#resMainInfoId").val(resourceId);
                                            } else {
                                                alert("更新失败!");
                                                return false;
                                            }
                                        },
                                        error: function (e) {
                                            alert(e.message);
                                            return false;
                                        }
                                    });
                                }//保存结束
                            },
                            error: function (e) {
                                alert(e.message);
                                return false;
                            }
                        });
                    } else {
                        $('#mainfrom').ajaxSubmit({
                            url: '/res/ziYuanUpdaate?resourceid=' + resMainInfoId,
                            type: 'post',
                            dataType: 'text',
                            async: false,
                            data: {},
                            success: function (data1) {
                                var json = eval('(' + data1 + ')');
                                if (json.result == "1") {
                                    isSaveMainInfo = true;
                                    resourceId = json.ziyuanId;
                                    $("#resMainInfoId").val(resourceId);
                                } else {
                                    alert("更新失败!");
                                    return false;
                                }
                            },
                            error: function (e) {
                                alert(e.message);
                                return false;
                            }
                        });
                    }
                } else { //新增
                    SetAnQuanJiBie();
                    SetGuanJianZi();
                    //判断是否有图片,如果有图片就上传
                    var image = $('#uploadInput')[0].files[0];
                    if (image != null) {
                        var formdata = new FormData();
                        formdata.append('myFile', $('#uploadInput')[0].files[0]);
                        console.log(formdata);
                        $.ajax({
                            url: "/res/testuploadimg",
                            type: "POST",
                            data: formdata,
                            cache: false,
                            async: false,
                            processData: false,  // 告诉jQuery不要去处理发送的数据
                            contentType: false,  // 告诉jQuery不要去设置Content-Type请求头
                            success: function (data) {
                                if (data == 0) {
                                    alert("上传图片失败");
                                } else {
                                    $("#imgurl").val(data);
                                    $('#mainfrom').ajaxSubmit({
                                        url: '/res/ziYuanInsert',
                                        type: 'post',
                                        dataType: 'text',
                                        async: false,
                                        data: {},
                                        success: function (data1) {
                                            var json = eval('(' + data1 + ')');
                                            if (json.result == "1") {
                                                isSaveMainInfo = true;
                                                resourceId = json.ziyuanId;
                                                $("#resMainInfoId").val(resourceId);
                                            } else {
                                                alert("保存失败!");
                                                return false;
                                            }
                                        },
                                        error: function (e) {
                                            alert(e.message);
                                            return false;
                                        }
                                    });
                                }
                            },
                            error: function (e) {
                                alert(e.message);
                                return false;
                            }
                        });
                    } else {
                        $('#mainfrom').ajaxSubmit({
                            url: '/res/ziYuanInsert',
                            type: 'post',
                            dataType: 'text',
                            data: {},
                            async: false,
                            success: function (data1) {
                                var json = eval('(' + data1 + ')');
                                if (json.result == "1") {
                                    isSaveMainInfo = true;
                                    resourceId = json.ziyuanId;
                                    $("#resMainInfoId").val(resourceId);
                                    $(".child img").css("cursor","no-drop");
                                } else {
                                    alert("保存失败!");
                                    return false;
                                }
                            },
                            error: function (e) {
                                alert(e.message);
                                return false;
                            }
                        });
                    }
                }
            } else {
                alert("注销后才可以对该资源进行修改!");
            }
            if (isSaveMainInfo) {
                //alert ykm 2019/02/26
                if(resourceclass.equals("KJ_SWMX") || resourceclass.equals("KJ_SWDX") || resourceclass.equals("KJ_SWYX")) resourceclass = "KJ_SW";
                switch (resourceclass) {
                    case "SJKB"://数据库表
                        isSaveExt = saveDataBaseInfo(resourceId);
                        break;
                    case "JKFW"://接口服务
                        isSaveExt = saveInterFaceInfo(resourceId);
                        isSaveExt = saveFiles(resourceId);//保存相关附件
                        break;
                    case "SJWJ"://数据文件
                        isSaveExt = saveDataFileInfo(resourceId);
                        break;
                    case "YWJC"://业务集成
                        isSaveExt = saveIntegrateInfo(resourceId);
                        break;
                    case "KJ_JCDT"://基础底图
                        isSaveExt = saveBaseMapInfo(resourceId, extMapUrlStr);
                        break;
                    case "KJ_ZTDT"://专题地图
                        isSaveExt = saveThemeMapInfo(resourceId, extMapUrlStr);
                        break;
                    case "KJ_KJFX"://空间分析
                        isSaveExt = saveExtSpaceServerInfo(resourceId);
                        isSaveExt = saveFiles(resourceId);//保存相关附件
                        break;
                    // case "KJ_SWMX"://三维模型
                    case "KJ_SW"://三维类型,三维模型,三维地形,三维影像
                        isSaveExt = save3D(resourceId);
                        break;
                    case "KJ_YWTC"://业务图层
                        isSaveExt = saveBusinessLayer(resourceId, extMapUrlStr);
                        break;
                }
            } else {
                return false;
            }
 
            if (isSaveExt) {
                //保存成功
                $("#ZiYuandelete").show();
                $("#ZiYuanTiJiao").show();
                $("#ZiYuanLook").show();
 
                //新增配置页面
                for (var s = 0; s < CurrentFlow.steps.length; s++) {
                    if (CurrentFlow.steps[s].isSaveLoad) {
                        if ($("#div_" + CurrentFlow.steps[s].url).length == 0) {
                            $("#basic-form").children("div").steps("insert", CurrentFlow.steps[s].index, {
                                title: CurrentFlow.steps[s].title,
                                content: "<div id=\"div_" + CurrentFlow.steps[s].url + "\"></div>"
                            });
                        }
                    }
                }
 
                //业务集成配置控制
                if (resourceclass == "YWJC") {
                    if ($("#rendermode").val() == "统计图") {
                        $("#setChartBtn").show();
                        $(".TongJiTu").show();
                    } else {
                        $("#setChartBtn").hide();
                        $(".TongJiTu").hide();
                    }
                } else if (resourceclass == "KJ_YWTC") {
                    $("#BusinessLayerSetting").show();//显示关联图层、周边查询、图表设置按钮
                }
 
                if (isFirst) {
                    if (resourceclass == "KJ_JCDT" || resourceclass == "KJ_ZTDT" || resourceclass == "KJ_YWTC") {
                        $("#div_" + CurrentFlow.steps[currentIndex - 1].url).empty();
                        f_project_def.onTab({action: CurrentFlow.steps[currentIndex - 1].url, isErase: false});
                    } else if (resourceclass == "JKFW") {
                        // $("#div_" + CurrentFlow.steps[0].url).empty();
                        // f_project_def.onTab({action: CurrentFlow.steps[0].url, isErase: true});
                        // f_project_def.onTab({action: CurrentFlow.steps[1].url, isErase: false});
                    } else if (resourceclass == "SJWJ") {
 
                    }
                    $("#basic-form").children("div").data("options").showFinishButtonAlways = true;//默认所有流程显示保存按钮
                    $("#basic-form").children("div").find(".actions a[href$='#finish']").parent().show();//显示保存按钮
                    isFirst = false;
                }
            } else {
                //保存拓展失败
            }
            return true;
        },
        onFinished: function (event, currentIndex) {
            //完成后触发
            $(".steps.clearfix ul li.current").removeClass("done");//处理保存后当前流程选项未选中问题
        },
        labels: {
            previous: "上一步",
            next: "下一步",
            finish: "保存"
        }
    });
    $(".steps.clearfix").height(h - 108);//左侧流程列表高度
    $(".content.clearfix").height(h - 144);//内容窗口高度
    $(".content.clearfix").width(w - 280);//内容窗口宽度
    $(".actions.clearfix").width(w - 320);//底部按钮区域宽度
 
    //添加删除、提交、关闭、查看按钮
    $(".actions.clearfix ul").append("<li><button class=\"btn btn-danger\" id=\"ZiYuandelete\" type=\"button\" onclick=\"ziYuanDel()\" style=\"display:none;\"><i class=\"fa fa-trash-o\"></i> 删除</button></li>");
    $(".actions.clearfix ul").append("<li><button class=\"btn btn-primary\" id=\"ZiYuanTiJiao\" type=\"button\" onclick=\"ziYuanTiJiao()\" style=\"display:none;\"><i class=\"fa fa-check\"></i> 提交</button></li>");
    $(".actions.clearfix ul").append("<li><button class=\"btn btn-warning\" type=\"button\" onclick=\"window.close()\"><i class=\"fa fa-remove\"></i> 关闭</button></li>");
    $(".actions.clearfix ul").append("<li><button class=\"btn btn-primary\" id=\"ZiYuanLook\" type=\"button\" onclick=\"OpenZiYuan()\" style=\"display:none;\"><i class=\"fa fa-file-text-o\"></i><span style=\"margin-left: 4px;display:inline-block;\">查看</span></button></li>");
 
    f_project_def.onTab({action: "ResResourceClass", isErase: false});
});
 
//新增资源类型流程
function AddResourceFlow(ResourceClass, flag) {
    //移除已有流程
    if (CurrentFlow != null) {
        if(CurrentFlow.resourceClass == "JKFW" || CurrentFlow.resourceClass == "KJ_KJFX") {
            if ($("#contents").length > 0) {
                UE.getEditor('contents').destroy();
            }
        }
        for (var j = CurrentFlow.steps.length - 1; j >= 0; j--) {
            if (CurrentFlow.steps[j].isload) {
                $("#basic-form").children("div").steps("remove", CurrentFlow.steps[j].index);
            }
        }
        if (ResourceClass == "JKFW") {
            $("#sjcssj").hide();//数据产生时间
            $("#sjgxpl").hide();//数据更新频率
            $("#sjfgfw").hide();//数据覆盖范围
        } else {
            $("#sjcssj").show();//数据产生时间
            $("#sjgxpl").show();//数据更新频率
            $("#sjfgfw").show();//数据覆盖范围
        }
    }
    //获取当前资源类型流程
    for (var i = 0; i < ResourceFlowConfig.length; i++) {
        if (ResourceFlowConfig[i].resourceClass == ResourceClass) {
            CurrentFlow = ResourceFlowConfig[i];
            break;
        }
    }
 
    //添加当前资源类型流程
    for (var f = 1; f <= CurrentFlow.steps.length; f++) {
        if (CurrentFlow.steps[f - 1].isload && !CurrentFlow.steps[f - 1].isSaveLoad) {
            $("#basic-form").children("div").steps("insert", CurrentFlow.steps[f - 1].index, {
                title: CurrentFlow.steps[f - 1].title,
                content: "<div id=\"div_" + CurrentFlow.steps[f - 1].url + "\"></div>"
            });
        }
    }
    //隐藏资源删除、提交、查看按钮
    $("#ZiYuandelete").hide();
    $("#ZiYuanTiJiao").hide();
    $("#ZiYuanLook").hide();
 
    if(flag) {
        $("#basic-form").children("div").steps("next");
    }
}
 
/*思路:选择某下拉选项后,先根据记录的去掉的下拉框索引和值将全部下拉框选项全部还原一下,然后清空记录的下拉框索引和值,然后遍历每个下拉框的选中值
    * 将选中的值去掉,记录去掉的下拉框索引和值*/
function DisabledOption() {
      console.log("123");
//    removedOpts.forEach(function (value, i, array) {
//        var opt = new Option(value.text, value.value);
//        $("#tbGKList tr:eq(" + value.selectindex + ")").find('[name=typeandurl]').append("<option value='" + value.value + "' index='" + value.optindex + "'>" + value.text + "</option>");
//    });
//    removedOpts.splice(0, removedOpts.length);
//    $('#tbGKList').find('tr').each(function (i, item) {
//        var optVal = $(item).find("[name=typeandurl]").val();
//        var optText = $(item).find("[name=typeandurl] option:selected").text();
//        if (i != 0 && optVal != "") {
//            $('#tbGKList').find('tr').each(function (j, item2) {
//                if (j != 0 && $(item2).find("[name=typeandurl]").val() != optVal) {
//                    var optindex;
//                    $(item2).find("[name=typeandurl] option").each(function (k, item3) {
//                        if ($(item3).val() == optVal) {
//                            optindex = k;
//                        }
//                    });
//                    $(item2).find("[name=typeandurl] [value='" + optVal + "']").remove();
//                    var obj = {selectindex: j, optindex: optindex, value: optVal, text: optText};
//                    removedOpts.push(obj);
//                }
//            });
//        }
//    });
}
 
//保存数据库表拓展信息
function saveDataBaseInfo(resourceId) {
    var isSuccess = false;
    var tabletype = $("#tabletype").val();
    if (tabletype == 1) {
        var primarykey = $("#primarykey").val();
        if (primarykey == null || primarykey == '') {
            alert("主键不能为空!");
            return;
        }
    }
    //判断当前用户是否是管理员,是管理员或是未提交的资源才可以修改资源相关信息
    if (admin == true || auditstatus == 0 || auditstatus == null) {
        var datasourceid = $("#datasourceid").val();
        $('#sjkbform').ajaxSubmit({
            url: '/res/resExtDataBase/insertSelectiveAndUpdate',
            type: 'post',
            dataType: 'text',
            async: false,
            data: {'datasourceid': datasourceid, 'resourceid': resourceId},
            success: function (data) {
                if (data == "1") {
                    alert("保存成功!");
                    isSuccess = true;
                } else {
                    alert("保存失败!");
                }
            },
            error: function (e) {
                alert(e.message);
            }
        });
    }
    else {
        alert("注销后才可以对该资源进行修改!");
    }
 
    return isSuccess;
}
 
//保存接口服务拓展信息
function saveInterFaceInfo(resourceId) {
    var isSuccess = false;
    var content = UE.getEditor('contents').getContent();
    //判断当前用户是否是管理员,是管理员或是未提交的资源才可以修改资源相关信息
    if (admin == true || auditstatus == 0 || auditstatus == null) {
        $('#jkfwform').ajaxSubmit({
            url: '/res/resExtInterFaceService/insertSelectiveAndUpdate?resourceid=' + resourceId,
            type: 'post',
            dataType: 'text',
            async: false,
            data: {
                helpurl: htmlEncodeByRegExp(content)
            },
            success: function (data) {
                if (data == "1") {
                    alert("保存成功!");
                    isSuccess = true;
                } else {
                    alert("保存失败!");
                }
            },
            error: function (e) {
                alert(e.message);
            }
        });
    }
    else {
        alert("注销后才可以对该资源进行修改!");
    }
 
    return isSuccess;
}
 
//保存业务集成拓展信息
function saveIntegrateInfo(resourceId) {
    var isSuccess = false;
    //判断当前用户是否是管理员,是管理员或是未提交的资源才可以修改资源相关信息
    if (admin == true || auditstatus == 0 || auditstatus == null) {
        var rdata = {};
        //页面集成-校验分辨率
        if ($("#integratetype").val() == "页面集成") {
            var resolution = "";
            if ($("#resolutionBen").val() != "" && $("#resolutionEnd").val() == "") {
                alert("请填写完整的分辨率!");
                return false;
            }
            if ($("#resolutionEnd").val() != "" && $("#resolutionBen").val() == "") {
                alert("请填写完整的分辨率!");
                return false;
            }
            if ($("#resolutionEnd").val() != "" && $("#resolutionBen").val() != "") {
                resolution = $("#resolutionBen").val() + "X" + $("#resolutionEnd").val();
            }
            rdata = {
                resolution: resolution
            };
        }
        var url = $("#serverurl").val();
        if (url != '' && url.indexOf('?') != -1) {
            var first = url.substring(0, url.indexOf('?'));
            var end = url.substring(url.indexOf('?'), url.length);
            $("#serverurl").val(first + encodeURI(end));
        }
        $('#ywjcform').ajaxSubmit({
            url: '/res/resExtIntegrate/insertSelectiveAndUpdate?resourceid=' + resourceId,
            type: 'post',
            dataType: 'text',
            async: false,
            data: rdata,
            success: function (data) {
                $("#serverurl").val(url);
                if (data == "1") {
                    alert("保存成功!");
                    isSuccess = true;
                } else {
                    alert("保存失败!");
                }
            },
            error: function (e) {
                alert(e.message);
            }
        });
    } else {
        alert("注销后才可以对该资源进行修改!");
    }
 
    return isSuccess;
}
 
//保存数据文件
function saveDataFileInfo(resourceId) {
    var sourcetype = $("#sourcetype").val();
    if(sourcetype == "文件夹") {
        var files = document.getElementById("upfilepath1").files;
        if(files.length > 0) {
            upload_file('upfilepath1');
        }
    }
    var isSuccess = false;
    //判断当前用户是否是管理员,是管理员或是未提交的资源才可以修改资源相关信息
    if (admin == true || auditstatus == 0 || auditstatus == null) {
        var filesize = $('#filesize').val();
        var unit = $('#unit').val();
        var sizenum = filesize * 1;
        var savedsizenum = 0;
        switch (unit) {
            case 'B':
                savedsizenum = (sizenum / 1000).toFixed(3);
                break;
            case 'KB':
                savedsizenum = sizenum;
                break;
            case 'MB':
                savedsizenum = sizenum * 1000;
                break;
            case 'GB':
                savedsizenum = sizenum * 1000 * 1000;
                break;
        }
        $('#wdsjform').ajaxSubmit({
            url: '/res/resExtFileSource/insertSelectiveAndUpdate?resourceid=' + resourceId,
            type: 'post',
            dataType: 'text',
            async: false,
            data: {'savedsizenum': savedsizenum},
            success: function (data) {
                if (data == "1") {
                    var str1 = "";
                    $("#ZXFSList").find('tr').each(function (i, item) {
                        if (i != 0 && $(item).find("[name=ShowWay]").val() != "" && $(item).find("[name=ShowWay]").val() != "--") {
                            var ShowWay = $(item).find("[name=ShowWay]").val();
                            var Url = $(item).find("[name=Url]").val();
                            if (Url == "--") {
                                Url == "";
                            }
                            var ReMark = $(item).find("[name=ReMark]").val();
                            str1 += ShowWay + "," + Url + "," + ReMark + "|";
                        }
                    });
 
                    $('#ZXFSform').ajaxSubmit({
                        url: '/res/ResManage/ResRegister/insertSelectiveAndUpdate?resourceid=' + resourceId,
                        type: 'post',
                        dataType: 'text',
                        async: false,
                        data: {'extMapUrlStr': str1},
                        success: function (data) {
                            if (data == "1") {
                                alert("保存成功!");
                                isSuccess = true;
                            } else {
                                alert("保存失败!");
                            }
                        },
                        error: function (e) {
                            alert(e.message);
                        }
                    });
                } else {
                    alert("保存失败!");
                }
            },
            error: function (e) {
                alert(e.message);
            }
        });
    }
    else {
        alert("注销后才可以对该资源进行修改!");
    }
    return isSuccess;
}
 
//保存3D模型
function save3D(resourceId) {
    var isSuccess = false;
    //判断当前用户是否是管理员,是管理员或是未提交的资源才可以修改资源相关信息
    if (admin == true || auditstatus == 0 || auditstatus == null) {
        $('#swmxform').ajaxSubmit({
            url: '/res/resExt3D/insertSelectiveAndUpdate?resourceid=' + resourceId,
            type: 'post',
            dataType: 'text',
            async: false,
            success: function (data) {
                if (data == "1") {
                    alert("保存成功!");
                    isSuccess = true;
                } else {
                    alert("保存失败!");
                }
            },
            error: function (e) {
                alert(e.message);
            }
        });
    } else {
        alert("注销后才可以对该资源进行修改!");
    }
 
    return isSuccess;
}
 
//保存业务图层
function saveBusinessLayer(resourceId, extMapUrlStr) {
    var isSuccess = false;
    //判断当前用户是否是管理员,是管理员或是未提交的资源才可以修改资源相关信息
    if (admin == true || auditstatus == 0 || auditstatus == null) {
        var espproxy = "", username = "", password = "", token = "";
        if ($("#espproxy").length > 0) espproxy = $("#espproxy").val();
        if ($("#username").length > 0) username = $("#username").val();
        if ($("#password").length > 0) password = $("#password").val();
        if ($("#token").length > 0) token = $("#token").val();
        $('#ywtcform').ajaxSubmit({
            url: '/res/ResExtBusinessLayer/insertSelectiveAndUpdate?resourceid=' + resourceId,
            type: 'post',
            dataType: 'text',
            async: false,
            data: {
                'extMapUrlStr': extMapUrlStr,
                "espproxy": espproxy,
                "username": username,
                "password": password,
                "token": token
            },
            success: function (data) {
                if (data == "1") {
                    alert("保存成功!");
                    isSuccess = true;
                } else {
                    alert("保存失败!");
                }
            },
            error: function (e) {
                alert(e.message);
            }
        });
    }
 
    return isSuccess;
}
 
//空间分析图层
function saveExtSpaceServerInfo(resourceId) {
    var isSuccess = false;
    var content = UE.getEditor('contents').getContent();
    //判断当前用户是否是管理员,是管理员或是未提交的资源才可以修改资源相关信息
    if (admin == true || auditstatus == 0 || auditstatus == null) {
        if ($('#kjfwform').valid()) {
            $('#kjfwform').ajaxSubmit({
                url: '/res/resExtSpaceServer/insertSelectiveAndUpdate?resourceid=' + resourceId,
                type: 'post',
                dataType: 'text',
                async: false,
                data: {
                    helpurl: htmlEncodeByRegExp(content)
                },
                success: function (data) {
                    if (data == "1") {
                        alert("保存成功!");
                        isSuccess = true;
                    } else {
                        alert("保存失败!");
                    }
                },
                error: function (e) {
                    alert(e.message);
                }
            });
        } else {
            // alert("您输入的信息存在错误,请更正后再提交!");
        }
    } else {
        alert("注销后才可以对该资源进行修改!");
    }
 
    return isSuccess;
}
 
//保存基础底图拓展信息
function saveBaseMapInfo(resourceId, extMapUrlStr) {
    var isSuccess = false;
    //判断当前用户是否是管理员,是管理员或是未提交的资源才可以修改资源相关信息
    if (admin == true || auditstatus == 0 || auditstatus == null) {
        var fullxmin = FullMapFrame.document.getElementById("fullxmin").value;
        var fullxmax = FullMapFrame.document.getElementById("fullxmax").value;
        var fullymin = FullMapFrame.document.getElementById("fullymin").value;
        var fullymax = FullMapFrame.document.getElementById("fullymax").value;
        var espproxy = "", username = "", password = "", token = "";
        if ($("#espproxy").length > 0) espproxy = $("#espproxy").val();
        if ($("#username").length > 0) username = $("#username").val();
        if ($("#password").length > 0) password = $("#password").val();
        if ($("#token").length > 0) token = $("#token").val();
        $('#jcdtform').ajaxSubmit({
            url: '/res/resExtBaseMap/insertSelectiveAndUpdate?resourceid=' + resourceId,
            type: 'post',
            dataType: 'text',
            async: false,
            data: {
                'extMapUrlStr': extMapUrlStr,
                "fullxmin": fullxmin,
                "fullxmax": fullxmax,
                "fullymin": fullymin,
                "fullymax": fullymax,
                "espproxy": espproxy,
                "username": username,
                "password": password,
                "token": token
            },
            success: function (data) {
                var json = eval('(' + data + ')');
                if (json.result == "1") {
                    alert("保存成功!");
                    isSuccess = true;
                } else {
                    alert("保存失败!");
                }
            },
            error: function (e) {
                alert(e.message);
            }
        });
    } else {
        alert("注销后才可以对该资源进行修改!");
    }
 
    return isSuccess;
}
 
//保存专题地图拓展信息
function saveThemeMapInfo(resourceId, extMapUrlStr) {
    var isSuccess = false;
    $("#sublayerset").val(getModuleId());
    if (admin == true || auditstatus == 0 || auditstatus == null) {
        var fullxmin = FullMapFrame.document.getElementById("fullxmin").value;
        var fullxmax = FullMapFrame.document.getElementById("fullxmax").value;
        var fullymin = FullMapFrame.document.getElementById("fullymin").value;
        var fullymax = FullMapFrame.document.getElementById("fullymax").value;
        var initxmin = FullMapFrame.document.getElementById("initxmin").value;
        var initxmax = FullMapFrame.document.getElementById("initxmax").value;
        var initymin = FullMapFrame.document.getElementById("initymin").value;
        var initymax = FullMapFrame.document.getElementById("initymax").value;
        var espproxy = "", username = "", password = "", token = "";
        if ($("#espproxy").length > 0) espproxy = $("#espproxy").val();
        if ($("#username").length > 0) username = $("#username").val();
        if ($("#password").length > 0) password = $("#password").val();
        if ($("#token").length > 0) token = $("#token").val();
        $("#ztdtform [disabled=disabled]").each(function () {
            $(this).attr("disabled", false);
        });
        $("#legendurl").val($("#showurl").val());
        $('#ztdtform').ajaxSubmit({
            url: '/res/ResExtThemeMap/insertSelectiveAndUpdate?resourceid=' + resourceId,
            type: 'post',
            dataType: 'text',
            async: false,
            data: {
                'extMapUrlStr': extMapUrlStr,
                "fullxmin": fullxmin,
                "fullxmax": fullxmax,
                "fullymin": fullymin,
                "fullymax": fullymax,
                "initxmin": initxmin,
                "initxmax": initxmax,
                "initymin": initymin,
                "initymax": initymax,
                "espproxy": espproxy,
                "username": username,
                "password": password,
                "token": token
            },
            success: function (data) {
                if (data == "1") {
                    alert("保存成功!");
                    isSuccess = true;
                } else {
                    alert("保存失败!");
                }
            },
            error: function (e) {
                alert(e.message);
            }
        });
    } else {
        alert("注销后才可以对该资源进行修改!");
    }
 
    return isSuccess;
}
 
//删除资源代码
function ziYuanDel() {
    if (confirm("删除包括资源基本信息和扩展信息,确定删除吗?")) {
        var resMainInfoId = $("#resMainInfoId").val();
        if (resMainInfoId != "") {
            //删除
            $('#mainfrom').ajaxSubmit({
                url: '/res/deleteByPrimaryKey?resourceid=' + resMainInfoId,
                type: 'post',
                dataType: 'text',
                data: {},
                success: function (data) {
                    if (data == 1) {
                        delService();
                        alert("删除成功,页面即将关闭");
                        parent.window.opener.location.reload();
                        parent.window.close();
                    } else {
                        alert("删除失败");
                    }
                },
                error: function (e) {
                    alert(e.message);
                }
            });
        }
    }
};
 
//提交资源代码
function ziYuanTiJiao() {
    var resMainInfoId = $("#resMainInfoId").val();
    if ($('#mainfrom').valid()) {
        SetGuanJianZi();
        //保存
        $('#mainfrom').ajaxSubmit({
            url: '/res/ziYuanSubmit?resourceid=' + resMainInfoId,
            type: 'post',
            dataType: 'text',
            data: {},
            success: function (data) {
                var json = eval('(' + data + ')');
                if (json.result == "1") {
                    alert("提交成功!");
                    parent.location.href = "../ResRegister/ResEdit?resMainInfoId=" + json.ziyuanId;
                } else if (json.result == "2") {
                    alert("扩展信息未填写!");
                } else {
                    alert('提交失败');
                }
            },
            error: function (e) {
                alert(e.message);
            }
        });
    } else {
        // alert("您输入的信息存在错误,请更正后再提交!");
    }
};
 
//查看资源
function OpenZiYuan() {
    var resourceid = $("#resMainInfoId").val();
    window.location.href = "/res/ZiYuan/ZiYuanBaseInfo?resourceid=" + resourceid;
    $.ajax({
        url: '/res/resActionRecord/registerActionRecord',
        type: 'post',
        data: {'resourceid': resourceid, 'actiontype': '浏览'}
    });
}
 
//保存相关附件
var filesize = 0;
var filetype = "";
var unit = "";
 
function saveFiles(resourceId) {
    var isSuccess = false;
    if (resourceId != "" && filesize > 0) {
        var sizenum = parseInt(filesize);
        var type = filetype;
        var savedsizenum = 0;
        switch (unit) {
            case 'B':
                savedsizenum = (sizenum / 1000).toFixed(3);
                break;
            case 'KB':
                savedsizenum = sizenum;
                break;
            case 'MB':
                savedsizenum = sizenum * 1000;
                break;
            case 'GB':
                savedsizenum = sizenum * 1000 * 1000;
                break;
        }
        $('#xgfjform').ajaxSubmit({
            url: '/res/resFiles/insertFileData?resourceid=' + resourceId,
            type: 'post',
            dataType: 'text',
            data: {'savedsizenum': savedsizenum, 'filetype': type},
            success: function (data) {
                if (data == "1") {
                    isSuccess = true;
                    //刷新页面
                    $('#xgfjform')[0].reset();
                    ZYMLZiYuanStore.load();
                } else {
                    alert("保存失败!");
                }
            },
            error: function (e) {
                alert(e.message);
            }
        });
    } else {
        isSuccess = true;
    }
    return isSuccess;
}