优化附件选择

pull/354/MERGE
Karson 2021-12-17 15:30:49 +08:00
parent a7317ec08c
commit bc99cfddd8
13 changed files with 180 additions and 26 deletions

View File

@ -1660,7 +1660,7 @@ EOD;
{ {
$uploadfilter = $selectfilter = ''; $uploadfilter = $selectfilter = '';
if ($this->isMatchSuffix($field, $this->imageField)) { if ($this->isMatchSuffix($field, $this->imageField)) {
$uploadfilter = ' data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp"'; $uploadfilter = ' data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp"';
$selectfilter = ' data-mimetype="image/*"'; $selectfilter = ' data-mimetype="image/*"';
} }
$multiple = substr($field, -1) == 's' ? ' data-multiple="true"' : ' data-multiple="false"'; $multiple = substr($field, -1) == 's' ? ' data-multiple="true"' : ' data-multiple="false"';

View File

@ -45,17 +45,13 @@ class Attachment extends Backend
$filterArr['category'] = ',unclassed'; $filterArr['category'] = ',unclassed';
$this->request->get(['filter' => json_encode(array_diff_key($filterArr, ['category' => '']))]); $this->request->get(['filter' => json_encode(array_diff_key($filterArr, ['category' => '']))]);
} }
if (isset($filterArr['mimetype']) && preg_match("/[]\,|\*]/", $filterArr['mimetype'])) { if (isset($filterArr['mimetype']) && preg_match("/(\/|\,|\*)/", $filterArr['mimetype'])) {
$mimetype = $filterArr['mimetype']; $mimetype = $filterArr['mimetype'];
$filterArr = array_diff_key($filterArr, ['mimetype' => '']); $filterArr = array_diff_key($filterArr, ['mimetype' => '']);
$mimetypeQuery = function ($query) use ($mimetype) { $mimetypeQuery = function ($query) use ($mimetype) {
$mimetypeArr = explode(',', $mimetype); $mimetypeArr = array_filter(explode(',', $mimetype));
foreach ($mimetypeArr as $index => $item) { foreach ($mimetypeArr as $index => $item) {
if (stripos($item, "/*") !== false) { $query->whereOr('mimetype', 'like', '%' . str_replace("/*", "/", $item) . '%');
$query->whereOr('mimetype', 'like', str_replace("/*", "/", $item) . '%');
} else {
$query->whereOr('mimetype', 'like', '%' . $item . '%');
}
} }
}; };
} }

View File

@ -136,7 +136,7 @@
{case value="images"} {case value="images"}
<div class="form-inline"> <div class="form-inline">
<input id="c-{$item.name}" class="form-control" size="50" name="row[{$item.name}]" type="text" value="{$item.value|htmlentities}" data-tip="{$item.tip}"> <input id="c-{$item.name}" class="form-control" size="50" name="row[{$item.name}]" type="text" value="{$item.value|htmlentities}" data-tip="{$item.tip}">
<span><button type="button" id="faupload-{$item.name}" class="btn btn-danger faupload" data-input-id="c-{$item.name}" data-mimetype="image/*" data-multiple="{$item.type=='image'?'false':'true'}" data-preview-id="p-{$item.name}"><i class="fa fa-upload"></i> {:__('Upload')}</button></span> <span><button type="button" id="faupload-{$item.name}" class="btn btn-danger faupload" data-input-id="c-{$item.name}" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="{$item.type=='image'?'false':'true'}" data-preview-id="p-{$item.name}"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-{$item.name}" class="btn btn-primary fachoose" data-input-id="c-{$item.name}" data-mimetype="image/*" data-multiple="{$item.type=='image'?'false':'true'}"><i class="fa fa-list"></i> {:__('Choose')}</button></span> <span><button type="button" id="fachoose-{$item.name}" class="btn btn-primary fachoose" data-input-id="c-{$item.name}" data-mimetype="image/*" data-multiple="{$item.type=='image'?'false':'true'}"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
<span class="msg-box n-right" for="c-{$item.name}"></span> <span class="msg-box n-right" for="c-{$item.name}"></span>
<ul class="row list-inline faupload-preview" id="p-{$item.name}"></ul> <ul class="row list-inline faupload-preview" id="p-{$item.name}"></ul>

View File

@ -39,7 +39,7 @@
</style> </style>
<div class="row animated fadeInRight"> <div class="row animated fadeInRight">
<div class="col-md-4"> <div class="col-md-4">
<div class="box box-success"> <div class="box box-primary">
<div class="panel-heading"> <div class="panel-heading">
{:__('Profile')} {:__('Profile')}
</div> </div>
@ -76,7 +76,7 @@
<input type="password" class="form-control" id="password" placeholder="{:__('Leave password blank if dont want to change')}" autocomplete="new-password" name="row[password]" value="" data-rule="password"/> <input type="password" class="form-control" id="password" placeholder="{:__('Leave password blank if dont want to change')}" autocomplete="new-password" name="row[password]" value="" data-rule="password"/>
</div> </div>
<div class="form-group"> <div class="form-group">
<button type="submit" class="btn btn-success">{:__('Submit')}</button> <button type="submit" class="btn btn-primary">{:__('Submit')}</button>
<button type="reset" class="btn btn-default">{:__('Reset')}</button> <button type="reset" class="btn btn-default">{:__('Reset')}</button>
</div> </div>

View File

@ -277,16 +277,12 @@ class User extends Frontend
$where = []; $where = [];
$filter = $this->request->request('filter'); $filter = $this->request->request('filter');
$filterArr = (array)json_decode($filter, true); $filterArr = (array)json_decode($filter, true);
if (isset($filterArr['mimetype']) && preg_match("/[]\,|\*]/", $filterArr['mimetype'])) { if (isset($filterArr['mimetype']) && preg_match("/(\/|\,|\*)/", $filterArr['mimetype'])) {
$this->request->get(['filter' => json_encode(array_diff_key($filterArr, ['mimetype' => '']))]); $this->request->get(['filter' => json_encode(array_diff_key($filterArr, ['mimetype' => '']))]);
$mimetypeQuery = function ($query) use ($filterArr) { $mimetypeQuery = function ($query) use ($filterArr) {
$mimetypeArr = explode(',', $filterArr['mimetype']); $mimetypeArr = array_filter(explode(',', $filterArr['mimetype']));
foreach ($mimetypeArr as $index => $item) { foreach ($mimetypeArr as $index => $item) {
if (stripos($item, "/*") !== false) { $query->whereOr('mimetype', 'like', '%' . str_replace("/*", "/", $item) . '%');
$query->whereOr('mimetype', 'like', str_replace("/*", "/", $item) . '%');
} else {
$query->whereOr('mimetype', 'like', '%' . $item . '%');
}
} }
}; };
} elseif (isset($filterArr['mimetype'])) { } elseif (isset($filterArr['mimetype'])) {

View File

@ -12,6 +12,32 @@
@import url("../libs/bootstrap-select/dist/css/bootstrap-select.min.css"); @import url("../libs/bootstrap-select/dist/css/bootstrap-select.min.css");
@import url("../libs/fastadmin-selectpage/selectpage.css"); @import url("../libs/fastadmin-selectpage/selectpage.css");
@import url("../libs/bootstrap-slider/slider.css"); @import url("../libs/bootstrap-slider/slider.css");
.m-0 {
margin-top: 0px !important;
margin-right: 0px !important;
margin-bottom: 0px !important;
margin-left: 0px !important;
}
.mt-0 {
margin-top: 0px !important;
}
.mr-0 {
margin-right: 0px !important;
}
.mb-0 {
margin-bottom: 0px !important;
}
.ml-0 {
margin-left: 0px !important;
}
.mx-0 {
margin-left: 0px !important;
margin-right: 0px !important;
}
.my-0 {
margin-top: 0px !important;
margin-bottom: 0px !important;
}
.m-1 { .m-1 {
margin-top: 5px !important; margin-top: 5px !important;
margin-right: 5px !important; margin-right: 5px !important;
@ -116,6 +142,32 @@
margin-top: 20px !important; margin-top: 20px !important;
margin-bottom: 20px !important; margin-bottom: 20px !important;
} }
.p-0 {
padding-top: 0px !important;
padding-right: 0px !important;
padding-bottom: 0px !important;
padding-left: 0px !important;
}
.pt-0 {
padding-top: 0px !important;
}
.pr-0 {
padding-right: 0px !important;
}
.pb-0 {
padding-bottom: 0px !important;
}
.pl-0 {
padding-left: 0px !important;
}
.px-0 {
padding-left: 0px !important;
padding-right: 0px !important;
}
.py-0 {
padding-top: 0px !important;
padding-bottom: 0px !important;
}
.p-1 { .p-1 {
padding-top: 5px !important; padding-top: 5px !important;
padding-right: 5px !important; padding-right: 5px !important;
@ -1378,7 +1430,7 @@ table.table-nowrap thead > tr > th {
} }
.radio > label > input, .radio > label > input,
.checkbox > label > input { .checkbox > label > input {
margin: 2px 0 0; margin: 5px 0 0;
} }
.wipecache li a { .wipecache li a {
color: #444444 !important; color: #444444 !important;

View File

@ -11,6 +11,32 @@
@import url("../libs/bootstrap-select/dist/css/bootstrap-select.min.css"); @import url("../libs/bootstrap-select/dist/css/bootstrap-select.min.css");
@import url("../libs/fastadmin-selectpage/selectpage.css"); @import url("../libs/fastadmin-selectpage/selectpage.css");
@import url("../libs/bootstrap-slider/slider.css"); @import url("../libs/bootstrap-slider/slider.css");
.m-0 {
margin-top: 0px !important;
margin-right: 0px !important;
margin-bottom: 0px !important;
margin-left: 0px !important;
}
.mt-0 {
margin-top: 0px !important;
}
.mr-0 {
margin-right: 0px !important;
}
.mb-0 {
margin-bottom: 0px !important;
}
.ml-0 {
margin-left: 0px !important;
}
.mx-0 {
margin-left: 0px !important;
margin-right: 0px !important;
}
.my-0 {
margin-top: 0px !important;
margin-bottom: 0px !important;
}
.m-1 { .m-1 {
margin-top: 5px !important; margin-top: 5px !important;
margin-right: 5px !important; margin-right: 5px !important;
@ -115,6 +141,32 @@
margin-top: 20px !important; margin-top: 20px !important;
margin-bottom: 20px !important; margin-bottom: 20px !important;
} }
.p-0 {
padding-top: 0px !important;
padding-right: 0px !important;
padding-bottom: 0px !important;
padding-left: 0px !important;
}
.pt-0 {
padding-top: 0px !important;
}
.pr-0 {
padding-right: 0px !important;
}
.pb-0 {
padding-bottom: 0px !important;
}
.pl-0 {
padding-left: 0px !important;
}
.px-0 {
padding-left: 0px !important;
padding-right: 0px !important;
}
.py-0 {
padding-top: 0px !important;
padding-bottom: 0px !important;
}
.p-1 { .p-1 {
padding-top: 5px !important; padding-top: 5px !important;
padding-right: 5px !important; padding-right: 5px !important;
@ -446,7 +498,7 @@ input.selectpage {
} }
.radio > label > input, .radio > label > input,
.checkbox > label > input { .checkbox > label > input {
margin: 2px 0 0; margin: 5px 0 0;
} }
form.form-horizontal .control-label { form.form-horizontal .control-label {
font-weight: normal; font-weight: normal;

View File

@ -1,3 +1,29 @@
.m-0 {
margin-top: 0px !important;
margin-right: 0px !important;
margin-bottom: 0px !important;
margin-left: 0px !important;
}
.mt-0 {
margin-top: 0px !important;
}
.mr-0 {
margin-right: 0px !important;
}
.mb-0 {
margin-bottom: 0px !important;
}
.ml-0 {
margin-left: 0px !important;
}
.mx-0 {
margin-left: 0px !important;
margin-right: 0px !important;
}
.my-0 {
margin-top: 0px !important;
margin-bottom: 0px !important;
}
.m-1 { .m-1 {
margin-top: 5px !important; margin-top: 5px !important;
margin-right: 5px !important; margin-right: 5px !important;
@ -102,6 +128,32 @@
margin-top: 20px !important; margin-top: 20px !important;
margin-bottom: 20px !important; margin-bottom: 20px !important;
} }
.p-0 {
padding-top: 0px !important;
padding-right: 0px !important;
padding-bottom: 0px !important;
padding-left: 0px !important;
}
.pt-0 {
padding-top: 0px !important;
}
.pr-0 {
padding-right: 0px !important;
}
.pb-0 {
padding-bottom: 0px !important;
}
.pl-0 {
padding-left: 0px !important;
}
.px-0 {
padding-left: 0px !important;
padding-right: 0px !important;
}
.py-0 {
padding-top: 0px !important;
padding-bottom: 0px !important;
}
.p-1 { .p-1 {
padding-top: 5px !important; padding-top: 5px !important;
padding-right: 5px !important; padding-right: 5px !important;

View File

@ -67,6 +67,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
}); });
}); });
//当表格分页变更时
table.on('page-change.bs.table', function (e, page, pagesize) {
if (!isNaN(pagesize)) {
localStorage.setItem("pagesize-addon", pagesize);
}
});
Template.helper("Moment", Moment); Template.helper("Moment", Moment);
Template.helper("addons", Config['addons']); Template.helper("addons", Config['addons']);
@ -149,7 +156,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
{ {
field: 'id', field: 'id',
title: __('Operate'), title: __('Operate'),
align: 'center',
table: table, table: table,
formatter: Controller.api.formatter.operate, formatter: Controller.api.formatter.operate,
align: 'right' align: 'right'
@ -172,7 +178,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
commonSearch: true, commonSearch: true,
searchFormVisible: true, searchFormVisible: true,
searchFormTemplate: 'searchformtpl', searchFormTemplate: 'searchformtpl',
pageSize: 5, pageSize: localStorage.getItem('pagesize-addon') || 50,
}); });
// 为表格绑定事件 // 为表格绑定事件

View File

@ -248,6 +248,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
var mimetype = $(this).data("mimetype") ? $(this).data("mimetype") : ''; var mimetype = $(this).data("mimetype") ? $(this).data("mimetype") : '';
var admin_id = $(this).data("admin-id") ? $(this).data("admin-id") : ''; var admin_id = $(this).data("admin-id") ? $(this).data("admin-id") : '';
var user_id = $(this).data("user-id") ? $(this).data("user-id") : ''; var user_id = $(this).data("user-id") ? $(this).data("user-id") : '';
mimetype = mimetype.replace(/\/\*/ig, '/');
var url = $(this).data("url") ? $(this).data("url") : (typeof Backend !== 'undefined' ? "general/attachment/select" : "user/attachment"); var url = $(this).data("url") ? $(this).data("url") : (typeof Backend !== 'undefined' ? "general/attachment/select" : "user/attachment");
parent.Fast.api.open(url + "?element_id=" + $(this).attr("id") + "&multiple=" + multiple + "&mimetype=" + mimetype + "&admin_id=" + admin_id + "&user_id=" + user_id, __('Choose'), { parent.Fast.api.open(url + "?element_id=" + $(this).attr("id") + "&multiple=" + multiple + "&mimetype=" + mimetype + "&admin_id=" + admin_id + "&user_id=" + user_id, __('Choose'), {
callback: function (data) { callback: function (data) {

View File

@ -1432,7 +1432,7 @@ table.table-nowrap {
margin-right: 10px; margin-right: 10px;
> input { > input {
margin: 2px 0 0; margin: 5px 0 0;
} }
} }
} }

View File

@ -292,7 +292,7 @@ input.selectpage {
margin-right: 10px; margin-right: 10px;
> input { > input {
margin: 2px 0 0; margin: 5px 0 0;
} }
} }
} }
@ -889,4 +889,3 @@ main.content {
} }
} }

View File

@ -2,7 +2,7 @@
.make-margin-padding(margin, m, 5px, 4); .make-margin-padding(margin, m, 5px, 4);
.make-margin-padding(padding, p, 5px, 4); .make-margin-padding(padding, p, 5px, 4);
.make-margin-padding(@type, @prefix, @space, @i) when (@i > 0) { .make-margin-padding(@type, @prefix, @space, @i) when (@i >= 0) {
.make-margin-padding(@type, @prefix, @space, @i - 1); .make-margin-padding(@type, @prefix, @space, @i - 1);
@pixel: @space * @i; @pixel: @space * @i;
.@{prefix}-@{i} { .@{prefix}-@{i} {