mirror of https://gitee.com/karson/fastadmin.git
优化附件未归类功能
parent
0c7a4850a2
commit
6178a5c231
|
|
@ -42,7 +42,7 @@ class Attachment extends Backend
|
|||
$filter = $this->request->request('filter');
|
||||
$filterArr = (array)json_decode($filter, true);
|
||||
if (isset($filterArr['category']) && $filterArr['category'] == 'unclassed') {
|
||||
$filterArr['category'] = '';
|
||||
$filterArr['category'] = ',unclassed';
|
||||
$this->request->get(['filter' => json_encode(array_diff_key($filterArr, ['category' => '']))]);
|
||||
}
|
||||
if (isset($filterArr['mimetype']) && preg_match("/[]\,|\*]/", $filterArr['mimetype'])) {
|
||||
|
|
@ -153,6 +153,7 @@ class Attachment extends Backend
|
|||
if ($category && !isset($categoryList[$category])) {
|
||||
$this->error(__('Category not found'));
|
||||
}
|
||||
$category = $category == 'unclassed' ? '' : $category;
|
||||
\app\common\model\Attachment::where('id', 'in', $ids)->update(['category' => $category]);
|
||||
$this->success();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,21 @@ class Attachment extends Model
|
|||
'thumb_style'
|
||||
];
|
||||
|
||||
protected static function init()
|
||||
{
|
||||
// 如果已经上传该资源,则不再记录
|
||||
self::beforeInsert(function ($model) {
|
||||
if (self::where('url', '=', $model['url'])->where('storage', $model['storage'])->find()) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
self::beforeWrite(function ($row) {
|
||||
if (isset($row['category']) && $row['category'] == 'unclassed') {
|
||||
$row['category'] = '';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function setUploadtimeAttr($value)
|
||||
{
|
||||
return is_numeric($value) ? $value : strtotime($value);
|
||||
|
|
@ -76,14 +91,4 @@ class Attachment extends Model
|
|||
$data['unclassed'] = __('Unclassed');
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected static function init()
|
||||
{
|
||||
// 如果已经上传该资源,则不再记录
|
||||
self::beforeInsert(function ($model) {
|
||||
if (self::where('url', '=', $model['url'])->where('storage', $model['storage'])->find()) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefin
|
|||
[
|
||||
{field: 'state', checkbox: true},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'category', title: __('Category'), formatter: Table.api.formatter.label, searchList: Config.categoryList},
|
||||
{field: 'category', title: __('Category'), operate: 'in', formatter: Table.api.formatter.label, searchList: Config.categoryList},
|
||||
{field: 'admin_id', title: __('Admin_id'), visible: false, addClass: "selectpage", extend: "data-source='auth/admin/index' data-field='nickname'"},
|
||||
{field: 'user_id', title: __('User_id'), visible: false, addClass: "selectpage", extend: "data-source='user/user/index' data-field='nickname'"},
|
||||
{field: 'preview', title: __('Preview'), formatter: Controller.api.formatter.thumb, operate: false},
|
||||
|
|
@ -147,7 +147,7 @@ define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefin
|
|||
[
|
||||
{field: 'state', checkbox: multiple, visible: multiple, operate: false},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'category', title: __('Category'), formatter: Table.api.formatter.label, searchList: Config.categoryList},
|
||||
{field: 'category', title: __('Category'), operate: 'in', formatter: Table.api.formatter.label, searchList: Config.categoryList},
|
||||
{field: 'admin_id', title: __('Admin_id'), formatter: Table.api.formatter.search, visible: false},
|
||||
{field: 'user_id', title: __('User_id'), formatter: Table.api.formatter.search, visible: false},
|
||||
{field: 'url', title: __('Preview'), formatter: Controller.api.formatter.thumb, operate: false},
|
||||
|
|
|
|||
Loading…
Reference in New Issue