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
<style>
    .x-form-text {
        padding: 4px !important;
    }
 
    .upload-file {
        position: relative;
        vertical-align: baseline;
    }
 
    .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="wdsjform" method="post">
    <div class="portlet box ltblue">
        <div class="portlet-title" id="fujiangl">
            附件管理
            <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 id="filename" name="filename" type="text" class="form-control col-sm-9" required="" maxchar="200" />
                            <span class="input-warning tooltips" data-original-title="">
                                <i class="icon-warning-sign" style="display: none;"></i>
                            </span>
                        </div>
                    </div>
                </div>
                <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 id="Fileserverurl" name="serverurl" type="text" class="form-control col-sm-9" required="" maxchar="500" />
                            <!--<button type="button" class="btn btn-primary" style="vertical-align: baseline;display: none;" onclick="openDialog('filepath')">-->
                                <!--<i class="fa fa-upload"></i> 上传-->
                            <!--</button>-->
                            <!--<button class="upload-file btn btn-primary">-->
                                <!--<input type="file" id="filepath" name="filepath" onchange="openDialog(this)">-->
                                <!--<i class="fa fa-upload"></i> 上传-->
                            <!--</button>-->
                            <div class="upload-file btn btn-primary">
                                <input type="file" id="filepath" name="filepath" onchange="openDialog(this)">
                                <span class="fa fa-upload"></span> 上传
                            </div>
                            <span class="input-warning tooltips" data-original-title="">
                                <i class="icon-warning-sign" style="display: none;"></i>
                            </span>
 
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <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 style="width:100%;text-align: center;">
                <div style="text-align:center;height:20px;line-height:40px;font-size:15px;margin-top:5px;"></div>
                <div id="grid" style="background: #0a6aa1"></div>
                <div style="height:20px;"></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="addZiYuanFJGLSave" type="button">
                <i class="fa fa-check"></i> 保存
            </button>
            <button class="btn btn-warning" id="close" type="button" onclick="window.close()">
                <i class="fa fa-remove"></i> 关闭
            </button>
        </div>
    </div>
</form>
 
<script src="/js/ZiYuanZhongXin/FJGL_Ext.js"></script>
 
<script>
    $(function () {
        cheackForm("wdsjform");
    });
    var filesize = 0;
    var filetype = "";
    var unit = "";
    var resMainInfoId = $("#resMainInfoId").val();
 
    //上传文件
    function openDialog(dom) {
        if (dom.value != '') {
            var formdata = new FormData();
            formdata.append('myFile', dom.files[0]);
            $.ajax({
                url: "/res/resFile/uploadfile?resourceid=" + resMainInfoId,
                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') {
                        $("#Fileserverurl").val(json.Path);
                        if ($("#filename").val() == "") $("#filename").val(json.Filename);
                        filesize = json.size;
                        unit = json.unit;
                        filetype = json.FileType;
                    } else {
                        alert("上传失败");
                    }
                }
            });
        }
    }
 
    //保存
    $('#addZiYuanFJGLSave').on('click', function () {
        if ($('#wdsjform').valid()) {
            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;
            }
            $('#wdsjform').ajaxSubmit({
                url: '/res/resFiles/insertFileData?resourceid=' + resMainInfoId,
                type: 'post',
                dataType: 'text',
                data: {'savedsizenum': savedsizenum, 'filetype': type},
                success: function (data) {
                    if (data == "1") {
                        alert("保存成功!");
                        // parent.FTabPages.resetTab();
                        reloadExt("ResFiles");
                    }
                    else  {
                        alert("保存失败!");
                    }
                },
                error: function (e) {
                    alert(e.message);
                }
            });
        }
        else {
            // alert("您输入的信息存在错误,请更正后再提交!");
        }
    });
 
    //删除
    function Deletefile(id){
        if(confirm("确定删除该文件?")){
            $.ajax({
                url:'/res/resFiles/deleteFileData',
                type:"post",
                async:false,
                data:{"fileid":id},
                cache:false,
                success:function(res){
                    if(res == "1"){
                        alert("删除成功");
                        // parent.FTabPages.resetTab();
                        reloadExt("ResFiles");
                    }
                    else  {
                        alert("删除失败!");
                    }
                },
                error:function(){
                    alert("error");
                }
            });
            return true;
        }else{
            return false;
        }
 
    }
</script>