浏览代码

用户举报后台

zhangxiaobin 1 年之前
父节点
当前提交
be07729e7a

+ 8 - 3
application/admin/controller/user/Report.php

@@ -22,7 +22,11 @@ class Report extends Backend
     {
         parent::_initialize();
         $this->model = new \app\admin\model\user\Report;
-
+        $typeList = [
+            'statusList' => $this->model->getStatusList(),
+        ];
+        $this->view->assign($typeList);
+        $this->assignconfig($typeList);
     }
 
     public function import()
@@ -54,14 +58,15 @@ class Report extends Backend
             list($where, $sort, $order, $offset, $limit) = $this->buildparams();
 
             $list = $this->model
-                    ->with(['user'])
+                    ->with(['user','ruser'])
                     ->where($where)
                     ->order($sort, $order)
                     ->paginate($limit);
 
             foreach ($list as &$row) {
                 $row->getRelation('user')->visible(['u_id','nickname']);
-                $row->model = $row->reportable;
+                $row->getRelation('ruser')->visible(['u_id','nickname']);
+                //$row->model = $row->reportable;
             }
 
             $result = array("total" => $list->total(), "rows" => $list->items());

+ 4 - 1
application/admin/lang/zh-cn/user/report.php

@@ -9,5 +9,8 @@ return [
     'Image'         => '图片说明',
     'Createtime'    => '创建时间',
     'User.u_id'     => '前端用户ID',
-    'User.nickname' => '昵称'
+    'User.nickname' => '昵称',
+    'Status'        => '状态',
+    'Status 0'      => '待处理',
+    'Status 1'      => '已处理',
 ];

+ 16 - 1
application/admin/model/user/Report.php

@@ -20,14 +20,29 @@ class Report extends Model
 
     // 追加属性
     protected $append = [
-
+        'status_text'
     ];
 
     public function user()
     {
         return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
     }
+    public function ruser()
+    {
+        return $this->belongsTo('app\admin\model\User', 'ruser_id', 'id', [], 'LEFT')->setEagerlyType(0);
+    }
+
+    public function getStatusList()
+    {
+        return ['0' =>__('Status 0'), '1' =>__('Status 1')];
+    }
 
+    public function getStatusTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
+        $list = $this->getStatusList();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
     /**
      * 获取举报对应的多态模型。
      */

+ 15 - 5
application/admin/view/user/report/edit.html

@@ -28,14 +28,24 @@
         <label class="control-label col-xs-12 col-sm-2">{:__('Image')}:</label>
         <div class="col-xs-12 col-sm-8">
             <div class="input-group">
-                <input id="c-image" class="form-control" size="50" name="row[image]" type="text" value="{$row.image|htmlentities}">
+                <input id="c-images" class="form-control" size="50" name="row[images]" type="text" value="{$row.images|htmlentities}">
                 <div class="input-group-addon no-border no-padding">
-                    <span><button type="button" id="faupload-image" class="btn btn-danger faupload" data-input-id="c-image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
-                    <span><button type="button" id="fachoose-image" class="btn btn-primary fachoose" data-input-id="c-image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
+                    <span><button type="button" id="faupload-images" class="btn btn-danger faupload" data-input-id="c-images" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="true" data-preview-id="p-images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
+                    <span><button type="button" id="fachoose-images" class="btn btn-primary fachoose" data-input-id="c-images" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
                 </div>
-                <span class="msg-box n-right" for="c-image"></span>
+                <span class="msg-box n-right" for="c-images"></span>
             </div>
-            <ul class="row list-inline faupload-preview" id="p-image"></ul>
+            <ul class="row list-inline faupload-preview" id="p-images"></ul>
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <select id="c-status" data-rule="required" class="form-control selectpicker" name="row[status]">
+                {foreach name="statusList" item="vo"}
+                    <option value="{$key}" {in name="key" value="$row.status"}selected{/in}>{$vo}</option>
+                {/foreach}
+            </select>
         </div>
     </div>
     <div class="form-group layer-footer">

+ 6 - 20
public/assets/js/backend/user/report.js

@@ -7,7 +7,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                 extend: {
                     index_url: 'user/report/index' + location.search,
                     // add_url: 'user/report/add',
-                    // edit_url: 'user/report/edit',
+                     edit_url: 'user/report/edit',
                     del_url: 'user/report/del',
                     // multi_url: 'user/report/multi',
                     // import_url: 'user/report/import',
@@ -28,24 +28,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'id', title: __('Id')},
                         {field: 'user.u_id', title: __('举报用户ID')},
                         {field: 'user.nickname', title: __('举报用户昵称'), operate: 'LIKE'},
-                        {
-                            field: 'reportable_type', title: __('举报对象类型'), operate: false, formatter: function (value, row, index) {
-                                if (value.indexOf("User") != -1) {
-                                    return "用户";
-                                } else if (value.indexOf("Party") != -1) {
-                                    return '房间';
-                                }
-                            }
-                        },
-                        {
-                            field: 'reportable_id', title: __('举报对象'), operate: false, formatter: function (value, row, index) {
-                                if (row.reportable_type.indexOf("User") != -1) {
-                                        return row.model.nickname + '<br>(用户ID:' + row.model.u_id + ')';
-                                } else if (row.reportable_type.indexOf("Party") != -1) {
-                                    return row.model.party_name + '<br>(派对ID:' + row.model.party_id + ')';
-                                }
-                            }
-                        },
+                        {field: 'type', title: __('举报类型'), operate: 'LIKE'},
+                        {field: 'ruser.u_id', title: __('被举报用户ID')},
+                        {field: 'ruser.nickname', title: __('被举报用户昵称'), operate: 'LIKE'},
                         {
                             field: 'content', title: __('Content'), operate: 'LIKE',
                             formatter: function (value, row, index, field) {
@@ -62,7 +47,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                 };
                             }
                         },
-                        {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
+                        {field: 'images', title: __('Image'), operate: false, events: Table.api.events.images, formatter: Table.api.formatter.images},
+                        {field: 'status', title: __('Status'), searchList: Config.statusList, formatter: Table.api.formatter.status},
                         {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                         {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]