This commit is contained in:
2025-12-25 06:02:38 +08:00
parent 20d230f6c8
commit 7c1d6d447e
44 changed files with 11475 additions and 561 deletions
+12 -13
View File
@@ -5,7 +5,7 @@ define(['jquery', 'bootstrap', 'dropzone', 'template'], function ($, undefined,
config: {
container: document.body,
classname: '.plupload:not([initialized]),.faupload:not([initialized])',
previewtpl: '<li class="col-xs-3"><a href="<%= fullurl%>" data-url="<%= url%>" target="_blank" class="thumbnail"><img src="<%= fullurl%>" onerror="this.src=\'' + Fast.api.fixurl("ajax/icon") + '?suffix=<%= suffix%>\';this.onerror=null;" class="img-responsive"></a><a href="javascript:;" class="btn btn-danger btn-xs btn-trash"><i class="fa fa-trash"></i></a></li>',
previewtpl: '<li class="col-xs-3"><a href="<%= fullurl%>" data-url="<%= url%>" target="_blank" class="thumbnail"><img src="<%= fullurl%>" onerror="this.src=\'' + Fast.api.fixurl("ajax/icon") + '?suffix=<%= suffix%>\';this.onerror=null;" class="img-responsive"></a><a href="javascript:;" class="btn btn-danger btn-xs btn-trash"><i class="mdi mdi-trash-can-outline"></i></a></li>',
},
events: {
//初始化
@@ -28,7 +28,7 @@ define(['jquery', 'bootstrap', 'dropzone', 'template'], function ($, undefined,
if ($(button).data("multiple") && inputObj.val() !== "") {
urlArr.push(inputObj.val());
}
var url = Config.fullmode ? Fast.api.cdnurl(data.url) : data.url;
var url = Config.upload_fullmode=="1" ? data.file_url : data.file_name;
urlArr.push(url);
inputObj.val(urlArr.join(",")).trigger("change").trigger("validate");
}
@@ -127,10 +127,10 @@ define(['jquery', 'bootstrap', 'dropzone', 'template'], function ($, undefined,
}
$(this).attr("initialized", true);
var that = this;
var id = $(this).prop("id") || $(this).prop("name") || Dropzone.uuidv4();
var id = $(this).prop("id") || $(this).prop("name") || Dropzone.Dropzone.uuidv4();
var url = $(this).data("url");
var maxsize = $(this).data("maxsize");
var maxcount = $(this).data("maxcount");
var maxcount = $(this).data("maxcount") || 1;
var mimetype = $(this).data("mimetype");
var multipart = $(this).data("multipart");
var multiple = $(this).data("multiple");
@@ -142,22 +142,21 @@ define(['jquery', 'bootstrap', 'dropzone', 'template'], function ($, undefined,
//上传URL
url = url ? url : Config.upload_url;
url = Fast.api.fixurl(url);
var chunking = false, chunkSize = 2097152, timeout = Config.upload_timeout || 600000;
var chunking = false, chunkSize = 2097152, timeout = Config.upload_timeout*1000 || 600000;
//最大可上传文件大小
maxsize = typeof maxsize !== "undefined" ? maxsize : Config.upload_maxsize;
maxsize = typeof maxsize !== "undefined" ? maxsize : Config.upload_maxsize + 'M';
//文件类型
mimetype = typeof mimetype !== "undefined" ? mimetype : Config.upload_mimetype;
//请求的表单参数
multipart = typeof multipart !== "undefined" ? multipart : Config.upload_multipart;
//是否支持批量上传
multiple = typeof multiple !== "undefined" ? multiple : true;
multiple = typeof multiple !== "undefined" ? multiple : false;
//后缀特殊处理
mimetype = mimetype.split(",").map(function (k) {
return k.indexOf("/") > -1 ? k : (!k || k === "*" || k.charAt(0) === "." ? k : "." + k);
}).join(",");
mimetype = mimetype === '*' ? null : mimetype;
//最大文件限制转换成mb
var maxFilesize = (function (maxsize) {
var matches = maxsize.toString().match(/^([0-9\.]+)(\w+)$/);
@@ -180,7 +179,7 @@ define(['jquery', 'bootstrap', 'dropzone', 'template'], function ($, undefined,
// multipart.category = category;
}
Upload.list[id] = new Dropzone(this, $.extend({
Upload.list[id] = new Dropzone.Dropzone(this, $.extend({
url: url,
params: function (files, xhr, chunk) {
var params = multipart;
@@ -270,12 +269,12 @@ define(['jquery', 'bootstrap', 'dropzone', 'template'], function ($, undefined,
},
uploadprogress: function (file, progress, bytesSent) {
if (file.upload.chunked) {
$(this.element).prop("disabled", true).html("<i class='fa fa-upload'></i> " + __('上传') + Math.floor((file.upload.bytesSent / file.size) * 100) + "%");
$(this.element).prop("disabled", true).html("<i class='mdi mdi-cloud-upload-outline'></i> " + __('上传') + Math.floor((file.upload.bytesSent / file.size) * 100) + "%");
}
},
totaluploadprogress: function (progress, bytesSent) {
if (this.getActiveFiles().length > 0 && !this.options.chunking) {
$(this.element).prop("disabled", true).html("<i class='fa fa-upload'></i> " + __('上传') + Math.floor(progress) + "%");
$(this.element).prop("disabled", true).html("<i class='mdi mdi-cloud-upload-outline'></i> " + __('上传') + Math.floor(progress) + "%");
}
},
queuecomplete: function () {
@@ -364,7 +363,7 @@ define(['jquery', 'bootstrap', 'dropzone', 'template'], function ($, undefined,
}
var suffix = /[\.]?([a-zA-Z0-9]+)$/.exec(j);
suffix = suffix ? suffix[1] : 'file';
j = Config.fullmode ? Fast.api.cdnurl(j) : j;
j = Config.upload_fullmode=="1" ? Fast.api.cdnurl(j) : j;
var value = (json && typeof json[i] !== 'undefined' ? json[i] : null);
var data = {url: j, fullurl: Fast.api.cdnurl(j), data: $(that).data(), key: i, index: i, value: value, row: value, suffix: suffix};
//console.log(data,tpl)
@@ -427,7 +426,7 @@ define(['jquery', 'bootstrap', 'dropzone', 'template'], function ($, undefined,
// AJAX异步上传
send: function (file, onUploadSuccess, onUploadError, onUploadComplete) {
var index = Layer.msg(__('上传中'), {offset: 't', time: 0});
var id = "dropzone-" + Dropzone.uuidv4();
var id = "dropzone-" + Dropzone.Dropzone.uuidv4();
$('<button type="button" id="' + id + '" class="btn btn-danger hidden faupload" />').appendTo("body");
$("#" + id).data("upload-complete", function (files) {
Layer.close(index);