Browse Source

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

Karson 3 years ago
parent
commit
ed0da37370

+ 7 - 2
application/admin/controller/general/Attachment.php

@@ -19,6 +19,7 @@ class Attachment extends Backend
     protected $model = null;
 
     protected $searchFields = 'id,filename,url';
+    protected $noNeedRight = ['classify'];
 
     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()) {
             $this->error(__("Invalid parameters"));
         }

+ 1 - 0
application/admin/lang/zh-cn/general/attachment.php

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

+ 1 - 1
application/admin/view/general/attachment/index.html

@@ -16,7 +16,7 @@
                 <div class="widget-body no-padding">
                     <div id="toolbar" class="toolbar">
                         {: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>
                     <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
                            data-operate-edit="{:$auth->check('general/attachment/edit')}"

+ 5 - 4
public/assets/js/backend/general/attachment.js

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