优化文件上传组件;

This commit is contained in:
2022-04-20 15:44:45 +08:00
parent cc29874a16
commit 3bc6b7d467
4 changed files with 28 additions and 24 deletions

View File

@@ -279,7 +279,7 @@ class BuildCurdService
} }
// 获取表名注释 // 获取表名注释
$tableSchema = Db::query("SELECT table_name,table_comment FROM information_schema.TABLES WHERE table_schema = 'easyadmin' AND table_name = '{$this->tablePrefix}{$this->table}'"); $tableSchema = Db::query("SELECT table_name,table_comment FROM information_schema.TABLES WHERE table_schema = 'ulthon_admin' AND table_name = '{$this->tablePrefix}{$this->table}'");
$this->tableComment = (isset($tableSchema[0]['table_comment']) && !empty($tableSchema[0]['table_comment'])) ? $tableSchema[0]['table_comment'] : $this->table; $this->tableComment = (isset($tableSchema[0]['table_comment']) && !empty($tableSchema[0]['table_comment'])) ? $tableSchema[0]['table_comment'] : $this->table;
} catch (\Exception $e) { } catch (\Exception $e) {
throw new TableException($e->getMessage()); throw new TableException($e->getMessage());

View File

@@ -4,7 +4,7 @@
<div class="layui-input-block layuimini-upload"> <div class="layui-input-block layuimini-upload">
<input name="{{field}}" class="layui-input layui-col-xs6" {{required}} placeholder="请上传{{comment}}" value="{{value}}"> <input name="{{field}}" class="layui-input layui-col-xs6" {{required}} placeholder="请上传{{comment}}" value="{{value}}">
<div class="layuimini-upload-btn"> <div class="layuimini-upload-btn">
<span><a class="layui-btn" data-upload="{{field}}" data-upload-number="one" data-upload-exts="*" data-upload-icon="file"><i class="fa fa-upload"></i> 上传</a></span> <span><a class="layui-btn" data-upload="{{field}}" data-upload-number="one" data-upload-exts="zip" data-upload-icon="file" data-disable-preview="1"><i class="fa fa-upload"></i> 上传</a></span>
<span><a class="layui-btn layui-btn-normal" id="select_{{field}}" data-upload-select="{{field}}" data-upload-number="one" data-upload-mimetype="*"><i class="fa fa-list"></i> 选择</a></span> <span><a class="layui-btn layui-btn-normal" id="select_{{field}}" data-upload-select="{{field}}" data-upload-number="one" data-upload-mimetype="*"><i class="fa fa-list"></i> 选择</a></span>
</div> </div>
</div> </div>

View File

@@ -4,7 +4,7 @@
<div class="layui-input-block layuimini-upload"> <div class="layui-input-block layuimini-upload">
<input name="{{field}}" class="layui-input layui-col-xs6" {{required}} placeholder="请上传{{comment}}" value="{{value}}"> <input name="{{field}}" class="layui-input layui-col-xs6" {{required}} placeholder="请上传{{comment}}" value="{{value}}">
<div class="layuimini-upload-btn"> <div class="layuimini-upload-btn">
<span><a class="layui-btn" data-upload="{{field}}" data-upload-number="more" data-upload-exts="*" data-upload-icon="file"><i class="fa fa-upload" data-upload-sign="{{define}}"></i> 上传</a></span> <span><a class="layui-btn" data-upload="{{field}}" data-upload-number="more" data-upload-exts="zip" data-upload-icon="file" data-disable-preview="1"><i class="fa fa-upload" data-upload-sign="{{define}}" ></i> 上传</a></span>
<span><a class="layui-btn layui-btn-normal" id="select_{{field}}" data-upload-select="{{field}}" data-upload-number="more" data-upload-mimetype="*" data-upload-sign="{{define}}"><i class="fa fa-list"></i> 选择</a></span> <span><a class="layui-btn layui-btn-normal" id="select_{{field}}" data-upload-select="{{field}}" data-upload-number="more" data-upload-mimetype="*" data-upload-sign="{{define}}"><i class="fa fa-list"></i> 选择</a></span>
</div> </div>
</div> </div>

View File

@@ -1495,6 +1495,7 @@ define(["jquery", "tableSelect", "ckeditor"], function ($, tableSelect, undefine
uploadSign = $(this).attr('data-upload-sign') || '|', uploadSign = $(this).attr('data-upload-sign') || '|',
uploadAccept = $(this).attr('data-upload-accept') || 'file', uploadAccept = $(this).attr('data-upload-accept') || 'file',
uploadAcceptMime = $(this).attr('data-upload-mimetype') || '', uploadAcceptMime = $(this).attr('data-upload-mimetype') || '',
disablePreview = $(this).attr('data-disable-preview') || '',
elem = "input[name='" + uploadName + "']", elem = "input[name='" + uploadName + "']",
uploadElem = this; uploadElem = this;
@@ -1530,6 +1531,7 @@ define(["jquery", "tableSelect", "ckeditor"], function ($, tableSelect, undefine
} }
}); });
if (disablePreview == 0) {
// 监听上传input值变化 // 监听上传input值变化
$(elem).bind("input propertychange", function (event) { $(elem).bind("input propertychange", function (event) {
var urlString = $(this).val(), var urlString = $(this).val(),
@@ -1552,6 +1554,8 @@ define(["jquery", "tableSelect", "ckeditor"], function ($, tableSelect, undefine
if ($(elem).val() !== '') { if ($(elem).val() !== '') {
$(elem).trigger("input"); $(elem).trigger("input");
} }
}
}); });
// 监听上传文件的删除事件 // 监听上传文件的删除事件