uploadfile_wev8.js
5.05 KB
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
var currentFileID = "";
var delannexids = "";
var numFilesQ = 0;
var numFilesS = 0;
var numUploadFiles = 0;
var oUploadannexupload;
var cancelNum = 0;
var failNum = 0;
function initFileupload(btnid, fileSizelimit) {
var settings = {
flash_url: "/js/swfupload/swfupload.swf",
upload_url: "/rdeploy/doc/MultiDocUpload.jsp",
file_size_limit: fileSizelimit + "MB",
file_types: "*.*",
file_types_description: "All Files",
file_upload_limit: 100,
file_queue_limit: 0,
custom_settings: {
progressTarget: "fsUploadProgressannexupload",
cancelButtonId: "btnCancelannexupload",
uploadfiedid: "field-annexupload"
},
debug: false,
button_placeholder_id: btnid,
button_width: 60,
button_height: 25,
button_text_top_padding: 5,
button_text_left_padding: 12,
button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
button_cursor: SWFUpload.CURSOR.HAND,
file_queued_handler: fileQueued,
file_queue_error_handler: fileQueueError,
file_dialog_complete_handler: function(numFilesSelected, numFilesQueued) {
initBtnAndShowProgressList(numFilesSelected, numFilesQueued);
},
upload_start_handler: uploadStart,
upload_progress_handler: uploadProgress,
upload_error_handler: uploadError,
upload_success_handler: function(file, serverData) {
progressUplouder(file, serverData);
},
upload_complete_handler: uploadComplete_1,
queue_complete_handler: queueComplete // Queue plugin event
};
try {
oUploadannexupload = new SWFUpload(settings);
} catch(e) {
alert(e)
}
}
// 初始化按钮并显示队列列表
function initBtnAndShowProgressList(numFilesSelected, numFilesQueued) {
if (numFilesSelected > 0) {
contentFrame.window.$("#norecord").remove();
$("#uptitle").empty();
$("#uptitle").append("正在上传:");
if(!$("#count").text())
{
$("#count").empty();
$("#count").append(numFilesSelected);
}
else
{
var count = parseInt(jQuery("#count").text());
$("#count").empty();
$("#count").append(count+numFilesSelected);
}
$("#uploadList").show();
$("#sp").show();
uploadfinish = false;
oUploadannexupload.startUpload();
}
}
// 显示成功列表信息,并创建文档
function progressUplouder(file, serverData) {
try {
var jsonobj = eval('(' + serverData + ')');
var progress = new FileProgress(file, oUploadannexupload.customSettings.progressTarget);
progress.setStatus("上传成功");
var successImgDiv = $("<div />");
successImgDiv.css("float","left");
successImgDiv.css("padding-top","15px");
var successImg = $("<img />");
successImg.attr("src","/rdeploy/assets/img/doc/upload_sucess.png");
successImgDiv.append(successImg);
$("#"+file.id+"rprogressBarStatus").after(successImgDiv);
progress.toggleCancel(true);
jQuery.ajax({
type: "POST",
url: "/rdeploy/doc/MultiDocMaintOpration.jsp?foldertype=" + $("#loadFolderType").val(),
data: {
imgFileId: jsonobj.imageid,
seccategory: $("#fpid").val(),
ownerid: $("#ownerid").val(),
doclangurage: $("#doclangurage").val(),
docdepartmentid: $("#docdepartmentid").val(),
fileSize: file.size
},
cache: false,
async: false,
dataType: 'json',
success: function(data) {
var itemData;
if ($("#loadFolderType").val() == 'publicAll') {
dataJson[$("#fpid").val()].childrenDocs.push(data);
itemData = dataJson[$("#fpid").val()];
} else {
privateDataJson[$("#fpid").val()].childrenDocs.push(data);
itemData = privateDataJson[$("#fpid").val()];
}
if(!$("#suCount").text())
{
$("#suCount").empty();
$("#suCount").append("1");
}
else
{
var sucount = parseInt(jQuery("#suCount").text());
$("#suCount").empty();
$("#suCount").append(sucount+1);
}
$("#"+file.id+"docid").val(data.docid);
contentFrame.window.fullDocitem($("#fpid").val(), data,itemData,"yes",file.id);
}
});
} catch(ex) {
oUploadannexupload.debug(ex);
}
}
var plen = 0;
var rtvids = "";
var rtvnames = "";
var rtvsizes = "";
String.prototype.replaceAll = function(reallyDo, replaceWith, ignoreCase) {
if (!RegExp.prototype.isPrototypeOf(reallyDo)) {
return this.replace(new RegExp(reallyDo, (ignoreCase ? "gi": "g")), replaceWith);
} else {
return this.replace(reallyDo, replaceWith);
}
}