优化表单重置时组件渲染

移除CRUD默认的重置按钮
优化上传大小判断
优化插件管理
pull/446/head
Karson 2023-07-07 14:56:30 +08:00
parent 7a4d05bbd9
commit aca4e9221c
13 changed files with 68 additions and 51 deletions

View File

@ -5,7 +5,6 @@
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>

View File

@ -5,7 +5,6 @@
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>

View File

@ -14,7 +14,6 @@ return [
'Refresh addon cache' => '刷新插件缓存',
'Userinfo' => '会员信息',
'Reload authorization' => '刷新授权',
'Online store' => '在线商店',
'Local addon' => '本地插件',
'Conflict tips' => '此插件中发现和现有系统中部分文件发现冲突!以下文件将会被影响,请备份好相关文件后再继续操作',
'Pay tips' => '扫码支付后如果仍然无法安装,请不要重复支付,请稍后再重试安装!',
@ -24,8 +23,7 @@ return [
'Upgrade tips' => '确认升级<b>《%s》</b><p class="text-danger">1、请务必做好代码和数据库备份备份备份<br>2、升级后如出现冗余数据请根据需要移除即可!<br>3、不建议在生产环境升级请在本地完成升级测试</p>如有重要数据请备份后再操作!',
'Offline installed tips' => '安装成功!清除浏览器缓存和框架缓存后生效!',
'Online installed tips' => '安装成功!清除浏览器缓存和框架缓存后生效!',
'Not login tips' => '你当前未登录FastAdmin请登录后操作',
'Please login and try to install' => '请登录FastAdmin后再进行离线安装',
'Please login and try to install' => '请登录FastAdmin后再进行本地安装',
'Not installed tips' => '请安装后再访问插件前台页面!',
'Not enabled tips' => '插件已经禁用,请启用后再访问插件前台页面!',
'New version tips' => '发现新版本:%s 点击查看更新日志',
@ -78,7 +76,6 @@ return [
'Enable' => '启用',
'Your username or email' => '你的手机号、用户名或邮箱',
'Your password' => '你的密码',
'Login FastAdmin' => '登录',
'Login' => '登录',
'Logout' => '退出登录',
'Register' => '注册账号',

View File

@ -147,7 +147,7 @@ class Upload
$size = $matches ? $matches[1] : $this->config['maxsize'];
$type = $matches ? strtolower($matches[2]) : 'b';
$typeDict = ['b' => 0, 'k' => 1, 'kb' => 1, 'm' => 2, 'mb' => 2, 'gb' => 3, 'g' => 3];
$size = (int)($size * pow(1024, $typeDict[$type] ?? 0));
$size = $size * pow(1024, $typeDict[$type] ?? 0);
if ($this->fileInfo['size'] > $size) {
throw new UploadException(__(
'File is too big (%sMiB), Max filesize: %sMiB.',

View File

@ -297,6 +297,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'cookie']
Fast.api.ajax({
url: Config.api_url + '/user/logintpl',
type: 'post',
loading: false,
data: {
version: Config.faversion,
sid: Controller.api.sid()
@ -306,7 +307,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'cookie']
content: Template.render(tpldata, {}),
zIndex: 99,
area: area,
title: __('Login FastAdmin'),
title: __('Login'),
resize: false,
btn: [__('Login')],
yes: function (index, layero) {
@ -608,16 +609,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'cookie']
var uid = userinfo ? userinfo.id : 0;
if (parseInt(uid) === 0) {
return Layer.alert(__('Not login tips'), {
title: __('Warning'),
btn: [__('Login now')],
yes: function (index, layero) {
$(".btn-userinfo").trigger("click", name, version);
},
btn2: function () {
install(name, version, false);
}
});
$(".btn-userinfo").trigger("click", name, version);
return false;
}
install(name, version, false);
});

View File

@ -6,7 +6,7 @@ require.config({
main: 'moment'
}],
//在打包压缩时将会把include中的模块合并到主文件中
include: ['css', 'layer', 'toastr', 'fast', 'backend', 'backend-init', 'table', 'form', 'dragsort', 'addtabs', 'selectpage'],
include: ['css', 'layer', 'toastr', 'fast', 'backend', 'backend-init', 'table', 'form', 'dragsort', 'addtabs', 'selectpage', 'bootstrap-daterangepicker'],
paths: {
'lang': "empty:",
'form': 'require-form',
@ -63,7 +63,7 @@ require.config({
exports: '$.fn.bootstrapTable.defaults'
},
'bootstrap-table-export': {
deps: ['bootstrap-table', 'tableexport'],
deps: ['bootstrap-table'],
exports: '$.fn.bootstrapTable.defaults'
},
'bootstrap-table-fixed-columns': {

File diff suppressed because one or more lines are too long

View File

@ -128,7 +128,11 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
});
$(form).on("reset", function () {
setTimeout(function () {
$('.selectpage', form).selectPageClear();
$(".selectpage", form).each(function () {
var selectpage = $(this).data("selectPageObject");
selectpage.elem.hidden.val($(this).val());
$(this).selectPageRefresh();
});
}, 1);
});
}
@ -361,6 +365,12 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
return obj;
};
var fieldlist = $(".fieldlist", form);
//表单重置
form.on("reset", function () {
setTimeout(function () {
fieldlist.trigger("fa.event.refreshfieldlist");
});
});
//监听文本框改变事件
$(document).on('change keyup changed', ".fieldlist input,.fieldlist textarea,.fieldlist select", function () {
var container = $(this).closest(".fieldlist");
@ -478,6 +488,11 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
if ($("[data-role='tagsinput']", form).length > 0) {
require(['tagsinput', 'autocomplete'], function () {
$("[data-role='tagsinput']").tagsinput();
form.on("reset", function () {
setTimeout(function () {
$("[data-role='tagsinput']").tagsinput('reset');
}, 0);
});
});
}
},
@ -505,7 +520,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
'==': function(a, b) { return a == b; },
'!=': function(a, b) { return a != b; },
'in': function(a, b) { return b.split(/\,/).indexOf(a) > -1; },
'regex': function(a, b) {
'regex': function (a, b) {
var regParts = b.match(/^\/(.*?)\/([gim]*)$/);
var regexp = regParts ? new RegExp(regParts[1], regParts[2]) : new RegExp(b);
return regexp.test(a);

View File

@ -62,7 +62,7 @@ require.config({
exports: '$.fn.bootstrapTable.defaults'
},
'bootstrap-table-export': {
deps: ['bootstrap-table', 'tableexport'],
deps: ['bootstrap-table'],
exports: '$.fn.bootstrapTable.defaults'
},
'bootstrap-table-fixed-columns': {

File diff suppressed because one or more lines are too long

View File

@ -398,6 +398,11 @@ define(['jquery', 'bootstrap', 'dropzone', 'template'], function ($, undefined,
});
}
if (input_id) {
$("#" + input_id).closest("form").on("reset", function () {
setTimeout($.proxy(function () {
$("#" + input_id, this).trigger("change");
}, this), 0);
});
//粘贴上传、拖拽上传
$("body").on('paste drop', "#" + input_id, function (event) {
var originEvent = event.originalEvent;

File diff suppressed because one or more lines are too long

View File

@ -273,6 +273,15 @@
});
},
/**
* reset the items
*/
reset: function () {
var val = this.$element.val();
this.removeAll();
this.add(val);
},
/**
* Returns the items added as tags
*/