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
<!--
功能描述:资源管理 - 资源注册 - 基本信息资源信息
-->
<style type="text/css">
    .upload-file {
        position: relative;
        vertical-align: baseline;
        cursor: pointer;
    }
 
    .upload-file input[type='file'] {
        height: 100%;
        width: 100%;
        position: absolute;
        top: 0;
        right: 0;
        opacity: 0;
        filter: alpha(opacity=0);
        cursor: pointer;
    }
</style>
<form class="form-horizontal" id="mainfrom" xmlns:th="http://www.w3.org/1999/xhtml"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
    <input type="hidden" id="ZiYuanId"/>
    <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">
                            <input th:value="${mainInfo.title}" type="text" id="title" name="title"
                                   class="form-control col-sm-9" required="" maxchar="50"/>
                            <span class="input-warning" data-original-title="">
                                <i class="icon-warning-sign" style="display: none;"></i>
                            </span>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">资源简称<span style="color: red;">*</span></label>
                        <div class="controls input-icon">
                            <input th:value="${mainInfo.abbreviation}" type="text" id="abbreviation" name="abbreviation"
                                   class="form-control col-sm-9" required="" maxchar="20"/>
                            <span class="input-warning tooltips" data-original-title="">
                                <i class="icon-warning-sign" style="display: none;margin-left:30px;"></i>
                            </span>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">资源类型<span style="color: red;">*</span></label>
                        <div class="controls input-icon">
                            <select id="resourceclass" name="resourceclass" class="form-control col-sm-9" required="">
                                <option value="">--请选择--</option>
                                <option th:each="item:${ResourceTypeList}" th:value="${item.key}"
                                        th:text="${item.value}"
                                        th:selected="(${mainInfo.resourceclass}==${item.key})?'true':'false'"></option>
                            </select>
                            <span class="input-warning tooltips" data-original-title="">
                                <i class="icon-warning-sign" style="display: none;margin-left:30px;"></i>
                            </span>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">所属目录<span style="color: red;">*</span></label>
                        <div class="controls input-icon">
                            <input th:value="${mainInfo.catlogid}" type="hidden" id="catlogid" name="catlogid"/>
                            <input th:value="${mainInfo.catlogcode}" type="hidden" id="catlogcode" name="catlogcode"/>
                            <input th:value="${catlogtitle}" type="text" id="catlogtitle" name="catlogtitle"
                                   readonly="readonly" class="form-control col-sm-8" required=""/>
                            <a class="btn"
                               style="background-color: #e5e5e5;vertical-align:baseline !important;color: black;"
                               title='选择所属类别' id="model1">...</a>
                            <span class="input-warning tooltips" data-original-title="">
                                <i class="icon-warning-sign" style="display: none;margin-left:34px"></i>
                            </span>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="control-group">
                        <label class="control-label">图标</label>
                        <div class="controls">
                            <div class="fileupload fileupload-new" data-provides="fileupload"
                                 style="margin-bottom:0px;">
                                <div class="fileupload-new thumbnail"
                                     style="width: 262px; height: 146px;border:1px solid #ddd;" id="PhotoDiv1">
                                    <img id="photo" th:src="${mainInfo.imgurl}!='' ? ${Imagelujin}:'' " alt=""
                                         style="width: 262px; height: 146px;border:1px solid #ddd"/>
                                </div>
                                <div class="fileupload-preview fileupload-exists thumbnail" id="PhotoDiv2"
                                     style="max-width: 262px; max-height: 146px; line-height: 20px;margin-bottom:6px;"></div>
                                <div>
                                    <a class="btn btn-info" title='选择图片' id="ShowAtlas">选择图片</a>
                                    <a id="dianjiUpdate" class="btn btn-info"
                                       onclick="javascript:document.getElementById('uploadInput').click();">本地上传</a>
                                    <input style="display: none;" id="uploadInput" type="file" multiple="multiple"/>
                                    <input type="hidden" id="imgurl" name="imgurl" th:value="${mainInfo.imgurl}"/>
                                    <a class="btn btn-info" onclick="DelPhoto()" data-dismiss="fileupload">移除</a>
                                    <span style="color:red;font-size:12px;">(建议图片大小:262 × 146 像素)</span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="control-group">
                        <label class="control-label">数据来源</label>
                        <div class="controls input-icon">
                            <select id="datasources"  name="datasources"
                                    class="form-control col-sm-9">
                                <option value="" >--请选择--</option>
                                <option th:each="item:${datasourcelist}"
                                        th:value="${item.key}"
                                        th:text="${item.value}"
                                        th:selected="(${mainInfo.datasources}==${item.key})?'true':'false'"
                                        id="txt">
                                    <!--                                    <input type="text" id="s" disabled="disabled">-->
                                </option>
                            </select>
 
                            <!--                            <span class="input-warning tooltips" data-original-title="">-->
                            <!--                                <i class="icon-warning-sign" style="display: none;margin-left:30px;"></i>-->
                            <!--                            </span>-->
                        </div>
                    </div>
                    <div class="control-group" id="datasourcesText" style="display: none">
                        <label class="control-label"></label>
                        <div class="controls input-icon">
                            <input class="form-control col-sm-9" maxchar="20" placeholder="请输入数据来源"  id="datasourcesValue" name="datasources" type="text" value="">
                            <span class="input-warning tooltips" data-original-title="">
                                <i class="icon-warning-sign" style="display: none;margin-left:30px;"></i>
                            </span>
                        </div>
                    </div>
                    <div class="control-group" id="sjcssj" th:if="${mainInfo.resourceclass}!='JKFW'">
                        <label class="control-label">数据产生时间</label>
                        <div class="controls input-icon">
                            <input th:value="${productiontime}" type="text" id="productiontime" name="productiontime"
                                   readonly="true" class="form-control col-sm-7 date-picker" style="width: 63%;"/>
                            <button class="btn btn-primary" onclick="javascript:$('#productiontime').val('');"
                                    style="vertical-align: top;">清除
                            </button>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">发布单位<span style="color: red;">*</span></label>
                        <div class="controls input-icon">
                            <input th:value="${mainInfo.pubunitid}" type="hidden" id="pubunitid" name="pubunitid"
                                   class="form-control col-sm-9" required=""/>
                            <input th:value="${unitname}" type="text" class="form-control col-sm-9" required=""
                                   readonly="readonly"/>
                            <span class="input-warning tooltips" data-original-title="">
                                <i class="icon-warning-sign" style="display: none;margin-left:30px;"></i>
                            </span>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">共享协议<span style="color: red;">*</span></label>
                        <div class="controls input-icon">
                            <select id="sharprotocol" name="sharprotocol" class="form-control col-sm-7" required="">
                                <option value="">--请选择--</option>
                                <option th:each="item:${SharProtocolList}" th:value="${item.key}"
                                        th:text="${item.value}"
                                        th:selected="(${mainInfo.sharprotocol}==${item.key})?'true':'false'"></option>
                            </select>
                            <input type="checkbox" id="insteadaudit" name="insteadaudit" value="1"
                                   th:checked="(${mainInfo.insteadaudit}==1 )? 'true':'false' "
                                   style="margin-right:3px;margin-left: 15px;"/>
                            <!--<input type="checkbox" id="insteadaudit" name="insteadaudit"  value="1"  th:if="${mainInfo.insteadaudit}==0"  style="margin-right:3px;margin-left: 15px;" />-->
                            <label for="insteadaudit" style="vertical-align: middle;">委托批复</label>
                            <span class="input-warning tooltips" data-original-title="">
                                <i class="icon-warning-sign" style="display: none;margin-left:30px;"></i>
                            </span>
                        </div>
                    </div>
 
                    <div class="control-group" id="sjfgfw" th:if="${mainInfo.resourceclass}!='JKFW'">
                        <label class="control-label">数据覆盖范围</label>
                        <div class="controls input-icon">
                            <input th:value="${mainInfo.administrativeid}" type="hidden" id="administrativeid"
                                   name="administrativeid"/>
                            <input th:value="${administrativename}" type="text" id="administrativename"
                                   name="administrativename" readonly="readonly" class="form-control col-sm-8"/>
                            <a class="btn"
                               style="background-color: #e5e5e5;vertical-align:baseline !important;color: black;"
                               title='选择区域' id="ShowAreaTree">...</a>
                            <span class="input-warning tooltips" data-original-title="">
                                <i class="icon-warning-sign" style="display: none;margin-left:34px"></i>
                            </span>
                        </div>
                    </div>
                    <div class="control-group" id="sjgxpl" th:if="${mainInfo.resourceclass}!='JKFW'">
                        <label class="control-label">数据更新频率</label>
                        <div class="controls input-icon">
                            <select id="updatetimes" name="updatetimes" class="form-control col-sm-9">
                                <option value="">--请选择--</option>
                                <option th:each="item:${UpdateTimesList}" th:value="${item.key}" th:text="${item.value}"
                                        th:selected="(${mainInfo.updatetimes}==${item.key})?'true':'false'"></option>
                            </select>
                            <span class="input-warning tooltips" data-original-title="">
                                <i class="icon-warning-sign" style="display: none;margin-left:30px;"></i>
                            </span>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">发布人<span style="color: red;">*</span></label>
                        <div class="controls input-icon">
                            <input th:value="${mainInfo.createuserid}" type="hidden" id="createuserid"
                                   name="createuserid" class="form-control col-sm-9" required=""/>
                            <input th:value="${chinesename}" type="text" class="form-control col-sm-9" required=""
                                   readonly="readonly"/>
                            <span class="input-warning tooltips" data-original-title="">
                                <i class="icon-warning-sign" style="display: none;margin-left:30px;"></i>
                            </span>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">发布时间<span style="color: red;">*</span></label>
                        <div class="controls input-icon">
                            <input th:value="${Pubdate}" type="text" id="pubdate" name="pubdate" readonly="true"
                                   class="form-control col-sm-9 date-picker" required=""/>
                            <span class="input-warning tooltips" data-original-title="">
                                <i class="icon-warning-sign" style="display: none;margin-left:30px;"></i>
                            </span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="control-group">
                        <label class="control-label">关键字</label>
                        <div class="controls input-icon" id="divGuanJianZi">
                            <input id="txtTagsGuanJianZi" name="txtTags" class="form-control col-sm-9" type="text"
                                   maxchar="100"/>
                            <input th:value="${mainInfo.keywords}" type="hidden" id="keywords" name="keywords"/>
                            <span class="input-warning tooltips" data-original-title="">
                                <i class="icon-warning-sign" style="display: none;margin-left:30px;"></i>
                            </span>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="control-group">
                        <label class="control-label">安全级别</label>
                        <div class="controls input-icon" id="divAnQuanJiBie" style="line-height: 28px;">
                            <input type="hidden" th:value="${mainInfo.securitylev}" id="securitylev"
                                   name="securitylev"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12" style="padding:0;">
                    <div class="control-group">
                        <label class="control-label">原始数据存储备注</label>
                        <div class="controls input-icon">
                            <input th:value="${mainInfo.remark}" id="remark" name="remark"
                                   class="form-control col-sm-11" type="text"/>
                            <span class="input-warning tooltips" data-original-title="">
                                <i class="icon-warning-sign" style="display: none;margin-left:30px;"></i>
                            </span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row" th:if="${not #lists.isEmpty(resMainInfoId)}">
                <div class="col-sm-12" style="padding:0;">
                    <div class="control-group">
                        <label class="control-label">自定义资源说明地址</label>
                        <div class="controls input-icon">
                            <input th:value="${mainInfo.desurl}" id="desurl" name="desurl"
                                   class="form-control col-sm-11" type="text" maxchar="500"/>
                            <input type="file" name="filepath" id="filepath" style="display: none;"/>
                            <!--<button class="btn btn-primary wenjian" id="remarkfilebtn" onclick="openUploadDialog('filepath','filename','filesize','remarkfilebtn')" style="vertical-align: baseline;" type="button">-->
                            <!--<span class="fa fa-upload"></span> 上传-->
                            <!--</button>-->
                            <div class="upload-file btn btn-primary">
                                <input type="file" id="remarkfilebtn" name="filepath"
                                       onchange="openUploadDialog('remarkfilebtn','filename','filesize','remarkfilebtn')">
                                <span class="fa fa-upload"></span> 上传
                            </div>
                            <span class="input-warning tooltips" data-original-title="">
                                <i class="icon-warning-sign" style="display: none;margin-left:30px;"></i>
                            </span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12" style="padding:0;">
                    <div class="control-group">
                        <label class="control-label">资源说明</label>
                        <div class="controls input-icon">
                            <textarea th:text="${mainInfo.description}" name="description"
                                      class="form-control col-sm-11" id="description" rows="3" cols="20"
                                      style="height: 70px;"></textarea>
                            <span class="input-warning tooltips" data-original-title="">
                                <i class="icon-warning-sign" style="display: none;margin-left:30px;"></i>
                            </span>
                        </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="addZiYuanSave" type="button">
                <i class="fa fa-check"></i> 保存
            </button>
            <button th:if="${not #lists.isEmpty(resMainInfoId)}" class="btn btn-danger" id="ZiYuandelete" type="button">
                <i class="fa fa-trash-o"></i> 删除
            </button>
            <button th:if="${not #lists.isEmpty(resMainInfoId) and auditstatus eq 0}" class="btn btn-primary"
                    id="ZiYuanTiJiao" type="button">
                <i class="fa fa-check"></i> 提交
            </button>
            <button th:if="${not #lists.isEmpty(resMainInfoId) and auditstatus eq 2}" class="btn btn-primary"
                    id="urlfwdw" type="button" onclick="ShowRecommendPanel();">
                <i class="fa fa-share-alt"></i> 推送
            </button>
            <button th:if="${not #lists.isEmpty(resMainInfoId) and auditstatus eq 2 and mainInfo.resourcestatus ne 3}"
                    class="btn btn-danger" id="signOut" type="button">
                <i class="fa fa-refresh"></i> 注销
            </button>
            <button class="btn btn-warning" id="close" type="button" onclick="window.close()">
                <i class="fa fa-remove"></i> 关闭
            </button>
            <button th:if="${not #lists.isEmpty(resMainInfoId)}" class="btn btn-primary" id="ZiYuanLook" type="button"
                    onclick="OpenZiYuan()">
                <i class="fa fa-file-text-o"></i><span style="margin-left: 4px;display:inline-block;">查看</span>
            </button>
        </div>
    </div>
</form>
 
<script th:inline="javascript">
 
    $(function () {
        //表单验证
        cheackForm("mainfrom");
        //资源类型,空间服务区分大小类显示
        $("select option").each(function () {  //遍历所有option
            var txt = $(this).val().substring(0, 3);   //获取option值
            var isKJ = $(this).text();
            if (txt == "KJ_") {
                if (isKJ != "空间服务") {     //禁用空间服务
                    $(this).html("-- " + isKJ);
                } else {
                    $(this).attr("disabled", true);
                }
            }
        });
        //共享协议选择“完全公开”时,委托批复设为不可操作
        var gongxiang = $("#sharprotocol option:selected").val();
        if (gongxiang == "完全公开") {
            $("#insteadaudit").attr("disabled", "disabled");
        }
        //图标去掉外框
        var imgurl = [[${mainInfo.imgurl}]];
        if (imgurl != '' && imgurl != null) {
            $("#PhotoDiv1").css("border", 0);
        } else {
            $("#PhotoDiv1").css("border", "1px solid #ddd !important");
            $("#PhotoDiv1 img").css("border", 0);
        }
    });
</script>
 
<script th:inline="javascript">
    $("#sharprotocol").change(function () {
        var gongxiang = $("#sharprotocol option:selected").val();
        if (gongxiang == "完全公开") {
            $("#insteadaudit").attr("disabled", "disabled")
            $("#insteadaudit").attr("checked", false);
        } else {
            $("#insteadaudit").removeAttr("disabled") //启用
        }
    });
    $("#datasources").change(function () {
        var gongxiang = $("#datasources option:selected").val();
        if (gongxiang == "其它") {
            $("#datasourcesText").show();
            $("#datasourcesValue").attr("name","datasources");
            $("#datasources").attr("name","disabled");
        } else {
            $("#datasourcesText").hide();
            $("#datasources").attr("name","datasources");
            $("#datasourcesValue").attr("name","disabled");
        }
    });
    //如果选择图片改变那么隐藏原来的图片
    $("#uploadInput").change(function () {
        var image = $('#uploadInput')[0].files[0];
        if (image != null) {
            $("#PhotoDiv1").hide();
            $("#PhotoDiv2").show();
        }
    });
 
    //注销资源
    $("#signOut").on('click', function () {
        var resMainInfoId = $("#resMainInfoId").val();
        if (resMainInfoId != "") {
            $.ajax({
                url: '/res/ZiYuan/SignOutResource?resourceid=' + resMainInfoId,
                type: 'post',
                data: {},
                success: function (data) {
                    var json = eval('(' + data + ')');
                    alert(json.msg);
                    parent.window.close();
                },
                error: function (e) {
                    alert(e.message);
                }
            });
        }
    });
 
    //弹出一个页面层
    $('#model1').on('click', function () {
        layer.open({
            type: 2,
            title: '所属目录',
            shadeClose: true,//是否点击遮罩关闭
            shade: 0.7,//遮罩(true、false、Number)
            area: ['300px', '500px'],
            content: 'MuLuShu'
        });
    });
 
    //弹出数据覆盖范围目录树
    $("#ShowAreaTree").on("click", function () {
        layer.open({
            type: 2,
            title: "选择区域",
            shadeClose: true,//是否点击遮罩关闭
            shade: 0.7,//遮罩(true、false、Number)
            area: ["350px", "500px"],
            content: "AreaTree"
        });
    });
 
    //删除资源代码
 
    $('#ZiYuandelete').on('click', function () {
        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) {
                            alert("删除成功,页面即将关闭");
                            parent.window.opener.location.reload();
                            parent.window.close();
                        } else {
                            alert("删除失败");
                        }
                    },
                    error: function (e) {
                        alert(e.message);
                    }
                });
            }
        }
    });
 
    //保存页面代码
 
    var admin = [[${admin}]];
    var auditstatus = [[${auditstatus}]];
    $('#addZiYuanSave').on('click', function () {
 
        //判断当前用户是否是管理员,是管理员或是未提交的资源才可以修改资源相关信息
        if (admin == true || auditstatus == 0 || auditstatus == null || auditstatus == -1) {
 
            if ($('#mainfrom').valid()) {
                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',
                                        data: {},
                                        success: function (data1) {
                                            var json = eval('(' + data1 + ')');
                                            if (json.result == "1") {
                                                alert("更新成功!");
                                                parent.window.opener.location.reload();  //查看页面刷新父页面
                                                parent.location.href = "ResEdit?resMainInfoId=" + json.ziyuanId;
                                            } else {
                                                alert("更新失败!");
                                            }
                                        },
                                        error: function (e) {
                                            alert(e.message + "121");
                                        }
                                    });
                                }//保存结束
                            },
                            error: function (e) {
                                alert(e.message);
                            }
                        });
                    } else {
                        $('#mainfrom').ajaxSubmit({
                            url: '/res/ziYuanUpdaate?resourceid=' + resMainInfoId,
                            type: 'post',
                            dataType: 'text',
                            data: {},
                            success: function (data1) {
                                var json = eval('(' + data1 + ')');
                                if (json.result == "1") {
                                    alert("更新成功!");
                                    parent.window.opener.location.reload();   //刷新父页面数据
                                    parent.location.href = "ResEdit?resMainInfoId=" + json.ziyuanId;
                                } else {
                                    alert("更新失败!");
                                }
                            },
                            error: function (e) {
                                alert(e.message);
                            }
                        });
                    }
                } 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',
                                        data: {},
                                        success: function (data1) {
                                            var json = eval('(' + data1 + ')');
                                            if (json.result == "1") {
                                                alert("保存成功!");
                                                parent.window.opener.location.reload();
                                                parent.location.href = "ResEdit?resMainInfoId=" + json.ziyuanId;
                                            } else {
                                                alert("保存失败!");
                                            }
                                        },
                                        error: function (e) {
                                            alert(e.message + "121");
                                        }
                                    });
                                }//保存结束
                            },
                            error: function (e) {
                                alert(e.message + "123");
                            }
                        });
                    } else {
                        $('#mainfrom').ajaxSubmit({
                            url: '/res/ziYuanInsert',
                            type: 'post',
                            dataType: 'text',
                            data: {},
                            success: function (data1) {
                                var json = eval('(' + data1 + ')');
                                if (json.result == "1") {
                                    alert("保存成功!");
                                    parent.window.opener.location.reload();
                                    parent.location.href = "ResEdit?resMainInfoId=" + json.ziyuanId;
                                } else {
                                    alert("保存失败!");
                                }
                            },
                            error: function (e) {
                                alert(e.message + "121");
                            }
                        });
                    }
                }
            } else {
                // alert("您输入的信息存在错误,请更正后再提交!");
            }
        } else {
            alert("注销后才可以对该资源进行修改!");
        }
    });
 
    //提交资源代码
    $('#ZiYuanTiJiao').on('click', function () {
        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 = "ResEdit?resMainInfoId=" + json.ziyuanId;
                    } else if (json.result == "2") {
                        alert("扩展信息未填写!");
                    } else {
                        alert('提交失败');
                    }
                },
                error: function (e) {
                    alert(e.message);
                }
            });
        } else {
            // alert("您输入的信息存在错误,请更正后再提交!");
        }
    });
 
    $('input[name=espproxy]').click(function () {
        $(this).attr("checked", true);//设置当前选中checkbox的状态为checked
        $(this).siblings().attr("checked", false); //设置当前选中的checkbox同级(兄弟级)其他checkbox状态为未选中
    });
 
    function DelPhoto() {
        $("#PhotoDiv1").show().css("border", "1px solid #CCCCCC");
        $("#photo").attr("src", "");
        $("#imgurl").val("");
        $("#PhotoDiv2").html("");
    }
 
    //获取关键字
    function GetTabValue(tabId) {
        var gjz = "";
        var spans = $("#" + tabId + " #addTagWrap").find("span")
        if (spans.length > 0) {
            spans.each(function (index, element) {
                if (index != 0) {
                    gjz += ",";
                }
                gjz += spans[index].innerText;
            });
        } else
            gjz = "";
        return gjz;
    }
 
    //关键字赋值
    function SetGuanJianZi() {
        var gjz = GetTabValue('divGuanJianZi');
        $("#keywords").val(gjz);
    }
 
    /*<![CDATA[*/
    var KeywordsList = [[${KeywordsList}]];//关键字列表
    //关键字初始化
    function initGuanJianZi() {
        var hotTags = "";
        for (i = 0; i < KeywordsList.length; i++) {
            hotTags += (hotTags == "" ? "" : "|") + KeywordsList[i];
        }
        var gjz = $("#keywords").val();
        $("#txtTagsGuanJianZi")[0].value = gjz;
 
        $("#txtTagsGuanJianZi").TagsInput({
            usedTags: "",
            hotTags: hotTags,
            tagNum: 10,
            maxWords: 10,
            onRemoveTag: function (ele, val) {
 
            }
        });
    }
 
    //安全级别赋值
    function SetAnQuanJiBie() {
        $("#securitylev").val($('#divAnQuanJiBie img[data-on="yes"]').length);
    }
 
    //安全级别图片路径
    var star = "/image/ZiYuan/safety.png";
    var starOff = "/image/ZiYuan/safetyoff.png";
 
    //初始化安全级别
    function AnQuanJiBie() {
        for (var i = 0; i < 5; i++) {
            if (i < parseInt($("#securitylev").val())) {
                $("#divAnQuanJiBie").append($('<img data-on="yes" src="/image/ZiYuan/safety.png" />'));
            } else {
                $("#divAnQuanJiBie").append($('<img data-on="no" src="/image/ZiYuan/safetyoff.png" />'));
            }
        }
        $('#divAnQuanJiBie img').click(function () {
            $(this).attr({"src": star, "data-on": "yes"})
                .prevAll().each(function (index, obj) {
                $(obj).attr({"src": starOff, "data-on": "yes"});
            });
            $(this).nextAll().attr(({"src": star, "data-on": "no"}));
        }).mousemove(function () {
            $(this).attr("src", star)
                .prevAll().each(function (index, obj) {
                $(obj).attr("src", star);
            });
            $(this).nextAll().each(function (index, obj) {
                $(obj).attr("src", starOff);
            });
        }).mouseout(function () {
            $(this).attr("src", function () {
                if ($(this).attr("data-on") == "no") {
                    return starOff;
                } else {
                    return star;
                }
            }).siblings().each(function (index, obj) {
                $(obj).attr("src", function () {
                    if ($(this).attr("data-on") == "no") {
                        return starOff;
                    } else {
                        return star;
                    }
                });
            });
        });
    }
 
    /*]]>*/
    $(function () {
        //修改状态时,资源类型设为不可操作
        if ($('#resourceclass').val().trim() != "") {
            $('#resourceclass').attr("disabled", true);
        }
        //初始化关键字
        initGuanJianZi();
        //安全级别
        AnQuanJiBie();
        //设置文本框宽度 ccr add 2018-12-30
        setInputWidthForMainInfo();
        //页面大小改变事件 ccr add 2018-12-30
        $(window).resize(function () {
            setTimeout("setInputWidthForMainInfo();", 500);
        });
    });
 
    //资源推荐面板
    function ShowRecommendPanel() {
        var resMainInfoId = $("#resMainInfoId").val();
        layer.open({
            type: 2,
            id: 'ZiYuanRecommend',
            title: '推荐',
            shadeClose: true,//是否点击遮罩关闭
            shade: 0.7,//遮罩(true、false、Number)
            area: ['350px', '500px'],
            content: 'ZiYuanRecommend?resourceid=' + resMainInfoId
        });
    }
 
    //查看资源
    function OpenZiYuan(resourceid) {
        var resourceid = $("#resMainInfoId").val();
        window.location.href = "/res/ZiYuan/ZiYuanBaseInfo?resourceid=" + resourceid;
        $.ajax({
            url: '/res/resActionRecord/registerActionRecord',
            type: 'post',
            data: {'resourceid': resourceid, 'actiontype': '浏览'}
        });
    }
 
    //资源类型改变事件
    $("#resourceclass").bind("change", function () {
        if ($(this).val() == "JKFW") {
            $("#sjfgfw").hide();
            $("#sjgxpl").hide();
            $("#sjcssj").hide();
        } else {
            $("#sjfgfw").show();
            $("#sjgxpl").show();
            $("#sjcssj").show();
        }
    })
 
    //打开上传文件
    function openUploadDialog(id) {
        document.getElementById(id).click();
        if (document.getElementById(id).value != '') {
            var postfix = document.getElementById(id).value.substring(document.getElementById(id).value.indexOf('.'), document.getElementById(id).value.length);
            if (postfix != ".html" && postfix != ".htm") {
                alert("只能上传html文件!");
                return false;
            }
            var formdata = new FormData();
            formdata.append('resourceid', $("#resMainInfoId").val());
            var fileName = document.getElementById(id).value;
            formdata.append("json_filesNameArray", fileName);
            var files = document.getElementById(id).files;
            for (var i = 0; i < files.length; i++) {
                formdata.append("myFile", files[i]);   // 文件对象
            }
            $.ajax({
                url: "/res/ZiYuan/uploadfile",
                type: "POST",
                data: formdata,
                cache: false,
                async: false,
                processData: false,  // 告诉jQuery不要去处理发送的数据
                contentType: false,  // 告诉jQuery不要去设置Content-Type请求头
                success: function (data) {
                    var json = eval('(' + data + ')');
                    if (json.result == '0') {
                        alert("上传失败");
                    } else if (json.result == '3') {
                        alert("上传失败,此文件已存在!");
                    } else {
                        $("#desurl").val(json.Path);
                    }
                }
            });
        }
    }
 
    //弹出图集
    $("#ShowAtlas").on("click", function () {
        layer.open({
            type: 2,
            title: "图集选择",
            shadeClose: true,//是否点击遮罩关闭
            shade: 0.7,//遮罩(true、false、Number)
            area: ["953px", "600px"],
            content: "AtkasList?resourceclass=" + $("#resourceclass").val()
        });
    });
 
    //设置一些右边有按钮的文本框的宽度(让它们在不同分辨率下可以对齐,暂时使用JS实现,后面有时间再使用CSS实现) ccr add 2018-12-30
    function setInputWidthForMainInfo() {
        var titleWidth = $("#title").width(); //获取资源名称文本框的宽度
        var titleRemark = $("#remark").width(); //获取资源名称文本框的宽度
        $("#catlogtitle").width(titleWidth - 45); //所属目录
        $("#administrativename").width(titleWidth - 45); //数据覆盖范围
        $("#productiontime").width(titleWidth - 60); //数据产生时间
        $("#sharprotocol").width(titleWidth - 90); //共享协议
        $("#desurl").width(titleRemark - 78); //自定义资源说明地址
    }
</script>
<script type="text/javascript">
    /*修改“其他”按钮为input*/
    /*  function drop(id) {
          // debugger;
          var dataItem = document.getElementById(id);
          var i = dataItem.selectedIndex;
          var text = dataItem.options[i].text;
          var value = dataItem.options[i].value;
          if (value == "其他") {
              text = "请手动输入数据来源"
              document.getElementById("txt").disabled = false;
          }
          document.getElementById("txt").value = text;
 
      }*/
    /*
        $('#datasources').on(change.function(){
            console.log("select改变了")
            function () {
 
            }
            var selectedOption=$("#")
        })*/
 
 
    /*   $("#datasources").click(function (id) {
           console.log("click");
           var dataItem = $(this);
           var i = dataItem.resMainInfoId;
           var text = dataItem.options[i].text;
           var value = dataItem.options[i].value;
           console.log(value.key);
           var selectedOption = $("datasources option:selected");
           console.log("selectedOption.value(),selectedOption.text());
           if (selectedOption.value == "其它") {
               text = "请手动输入数据来源"
               $("#txt").disabled = false;
           } else ($("#s").value.type = text)
 
 
       });
 
       function showMeTheText(object) {
           var selectedOption = $("datasources option:selected");
           console.log("selectedOption.value(),selectedOption.text());
           if (selectedOption.value == "其它") {
               $("#txt").disabled = false;
           } else ($("#s").value = text)
 
 
       }
   */
    // $("#datasources").bind("change", function () {
    //         var gongxiang = $("#datasources option:selected").val();
    //         if (gongxiang == "其它") {
    //             $("#testtext").show();
    //             $("#datasources").hide();
    //         } else {
    //             $("#testtext").hide();
    //             $("#datasources").show();
    //         }
    // debugger
    // $("#s").attr("disabled", false);
    // var selected = $(this).find("option:selected").attr("th:selected")
    // $("#s").val(selected);
 
 
 
 
    /*   function show(object) {
           document.getElementById('txt').style.display = (object.value == "其它" ? "block" : "none")
           console.log("我在这")
       }*/
</script>