优化附件归类文字和权限判断

pull/305/MERGE
Karson 2021-06-04 14:49:23 +08:00
parent bf720c176e
commit ed0da37370
4 changed files with 14 additions and 7 deletions

View File

@ -19,6 +19,7 @@ class Attachment extends Backend
protected $model = null; protected $model = null;
protected $searchFields = 'id,filename,url'; protected $searchFields = 'id,filename,url';
protected $noNeedRight = ['classify'];
public function _initialize() public function _initialize()
{ {
@ -132,10 +133,14 @@ class Attachment extends Backend
} }
/** /**
* 移动 * 归类
*/ */
public function move($ids = "") public function classify()
{ {
if (!$this->auth->check('general/attachment/edit')) {
\think\Hook::listen('admin_nopermission', $this);
$this->error(__('You have no permission'), '');
}
if (!$this->request->isPost()) { if (!$this->request->isPost()) {
$this->error(__("Invalid parameters")); $this->error(__("Invalid parameters"));
} }

View File

@ -28,6 +28,7 @@ return [
'Custom' => '自定义', 'Custom' => '自定义',
'Unclassed' => '未归类', 'Unclassed' => '未归类',
'Category' => '类别', 'Category' => '类别',
'Classify' => '归类',
'Upload to third' => '上传到第三方', 'Upload to third' => '上传到第三方',
'Upload to local' => '上传到本地', 'Upload to local' => '上传到本地',
'Upload to third by chunk' => '上传到第三方(分片模式)', 'Upload to third by chunk' => '上传到第三方(分片模式)',

View File

@ -16,7 +16,7 @@
<div class="widget-body no-padding"> <div class="widget-body no-padding">
<div id="toolbar" class="toolbar"> <div id="toolbar" class="toolbar">
{:build_toolbar('refresh,add,edit,del')} {:build_toolbar('refresh,add,edit,del')}
<a class="btn btn-info btn-move dropdown-toggle btn-disabled disabled"><i class="fa fa-arrow-right"></i> {:__('Move')}</a> <a class="btn btn-info btn-classify dropdown-toggle btn-disabled disabled {:$auth->check('general/attachment/edit')?'':'hide'}"><i class="fa fa-arrow-right"></i> {:__('Classify')}</a>
</div> </div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap" <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('general/attachment/edit')}" data-operate-edit="{:$auth->check('general/attachment/edit')}"

View File

@ -65,16 +65,17 @@ define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefin
// 为表格绑定事件 // 为表格绑定事件
Table.api.bindevent(table); Table.api.bindevent(table);
$(document).on('click', '.btn-move', function () { // 附件归类
$(document).on('click', '.btn-classify', function () {
var ids = Table.api.selectedids(table); var ids = Table.api.selectedids(table);
Layer.open({ Layer.open({
title: __('Move'), title: __('Classify'),
content: Template("typetpl", {}), content: Template("typetpl", {}),
btn: [__('Move')], btn: [__('OK')],
yes: function (index, layero) { yes: function (index, layero) {
var category = $("select[name='category']", layero).val(); var category = $("select[name='category']", layero).val();
Fast.api.ajax({ Fast.api.ajax({
url: "general/attachment/move", url: "general/attachment/classify",
type: "post", type: "post",
data: {category: category, ids: ids.join(',')}, data: {category: category, ids: ids.join(',')},
}, function () { }, function () {