Skip to content

Commit

Permalink
Add: 增加文件上传类型的控制 (#100)
Browse files Browse the repository at this point in the history
Co-authored-by: Mr.Chung <39075420+zhongshaofa@users.noreply.github.com>
  • Loading branch information
cshaptx4869 and zhongshaofa committed Sep 14, 2021
1 parent 4cb2be1 commit 6c5a542
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions public/static/plugs/easy-admin/easy-admin.js
Expand Up @@ -1291,25 +1291,24 @@ define(["jquery", "tableSelect", "ckeditor"], function ($, tableSelect, undefine

if (uploadList.length > 0) {
$.each(uploadList, function (i, v) {
var exts = $(this).attr('data-upload-exts'),
var uploadExts = $(this).attr('data-upload-exts') || init.upload_exts,
uploadName = $(this).attr('data-upload'),
uploadNumber = $(this).attr('data-upload-number'),
uploadSign = $(this).attr('data-upload-sign');
exts = exts || init.upload_exts;
uploadNumber = uploadNumber || 'one';
uploadSign = uploadSign || '|';
var elem = "input[name='" + uploadName + "']",
uploadNumber = $(this).attr('data-upload-number') || 'one',
uploadSign = $(this).attr('data-upload-sign') || '|',
uploadAccept = $(this).attr('data-upload-accept') || 'file',
uploadAcceptMime = $(this).attr('data-upload-mimetype') || '',
elem = "input[name='" + uploadName + "']",
uploadElem = this;

// 监听上传事件
upload.render({
elem: this,
url: admin.url(init.upload_url),
accept: 'file',
exts: exts,
exts: uploadExts,
accept: uploadAccept,//指定允许上传时校验的文件类型
acceptMime: uploadAcceptMime,//规定打开文件选择框时,筛选出的文件类型
multiple: uploadNumber !== 'one',//是否多文件上传
headers:admin.headers(),
// 让多图上传模式下支持多选操作
multiple: (uploadNumber !== 'one') ? true : false,
done: function (res) {
if (res.code === 1) {
var url = res.data.url;
Expand All @@ -1333,8 +1332,7 @@ define(["jquery", "tableSelect", "ckeditor"], function ($, tableSelect, undefine
$(elem).bind("input propertychange", function (event) {
var urlString = $(this).val(),
urlArray = urlString.split(uploadSign),
uploadIcon = $(uploadElem).attr('data-upload-icon');
uploadIcon = uploadIcon || "file";
uploadIcon = $(uploadElem).attr('data-upload-icon') || "file";

$('#bing-' + uploadName).remove();
if (urlString.length > 0) {
Expand Down Expand Up @@ -1379,13 +1377,10 @@ define(["jquery", "tableSelect", "ckeditor"], function ($, tableSelect, undefine

if (uploadSelectList.length > 0) {
$.each(uploadSelectList, function (i, v) {
var exts = $(this).attr('data-upload-exts'),
uploadName = $(this).attr('data-upload-select'),
uploadNumber = $(this).attr('data-upload-number'),
uploadSign = $(this).attr('data-upload-sign');
exts = exts || init.upload_exts;
uploadNumber = uploadNumber || 'one';
uploadSign = uploadSign || '|';
var uploadName = $(this).attr('data-upload-select'),
uploadNumber = $(this).attr('data-upload-number') || 'one',
uploadSign = $(this).attr('data-upload-sign') || '|';

var selectCheck = uploadNumber === 'one' ? 'radio' : 'checkbox';
var elem = "input[name='" + uploadName + "']",
uploadElem = $(this).attr('id');
Expand Down

0 comments on commit 6c5a542

Please sign in to comment.