优化上传组件

This commit is contained in:
2020-04-11 22:29:27 +08:00
parent b03606abd7
commit 456d63a231
4 changed files with 37 additions and 66 deletions

View File

@@ -107,8 +107,8 @@ define(['jquery', 'bootstrap', 'validator'], function ($, undefined, Validator)
require(['NKeditor'], function(){
KindEditor.create('.form-editor', {
items: Form.config.editor[items],
uploadJson: "/admin/upload/editor'",
fileManagerJson: "/admin/upload/filemanage"
uploadJson: "/"+Config.module+"/upload/editor'",
fileManagerJson: "/"+Config.module+"/upload/filemanage"
})
})
}
@@ -318,49 +318,6 @@ define(['jquery', 'bootstrap', 'validator'], function ($, undefined, Validator)
})
}
},
faselect: function (form) {
//绑定fachoose选择附件事件
if ($(".fachoose", form).size() > 0) {
$(".fachoose", form).on('click', function () {
var that = this;
var multiple = $(this).data("multiple") ? $(this).data("multiple") : false;
var mimetype = $(this).data("mimetype") ? $(this).data("mimetype") : '';
var admin_id = $(this).data("admin-id") ? $(this).data("admin-id") : '';
var user_id = $(this).data("user-id") ? $(this).data("user-id") : '';
sent.api.open("general/attachment/select?element_id=" + $(this).attr("id") + "&multiple=" + multiple + "&mimetype=" + mimetype + "&admin_id=" + admin_id + "&user_id=" + user_id, __('Choose'), {
callback: function (data) {
var button = $("#" + $(that).attr("id"));
var maxcount = $(button).data("maxcount");
var input_id = $(button).data("input-id") ? $(button).data("input-id") : "";
maxcount = typeof maxcount !== "undefined" ? maxcount : 0;
if (input_id && data.multiple) {
var urlArr = [];
var inputObj = $("#" + input_id);
var value = $.trim(inputObj.val());
if (value !== "") {
urlArr.push(inputObj.val());
}
urlArr.push(data.url)
var result = urlArr.join(",");
if (maxcount > 0) {
var nums = value === '' ? 0 : value.split(/\,/).length;
var files = data.url !== "" ? data.url.split(/\,/) : [];
var remains = maxcount - nums;
if (files.length > remains) {
Toastr.error(__('You can choose up to %d file%s', remains));
return false;
}
}
inputObj.val(result).trigger("change").trigger("validate");
} else {
$("#" + input_id).val(data.url).trigger("change").trigger("validate");
}
}
});
return false;
});
}
},
fieldlist: function (form) {
//绑定fieldlist
if ($(".fieldlist", form).size() > 0) {
@@ -580,7 +537,6 @@ define(['jquery', 'bootstrap', 'validator'], function ($, undefined, Validator)
events.citypicker(form);
events.datetimepicker(form);
events.plupload(form);
events.faselect(form);
events.fieldlist(form);
events.slider(form);
events.switcher(form);