lizhen_gitee 1 год назад
Родитель
Сommit
7878eb456b

+ 34 - 0
application/admin/controller/Feedback.php

@@ -37,4 +37,38 @@ class Feedback extends Backend
      */
     
 
+    /**
+     * 查看
+     */
+    public function index()
+    {
+        //当前是否为关联查询
+        $this->relationSearch = true;
+        //设置过滤方法
+        $this->request->filter(['strip_tags', 'trim']);
+        if ($this->request->isAjax()) {
+            //如果发送的来源是Selectpage,则转发到Selectpage
+            if ($this->request->request('keyField')) {
+                return $this->selectpage();
+            }
+            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
+
+            $list = $this->model
+                    ->with(['user'])
+                    ->where($where)
+                    ->order($sort, $order)
+                    ->paginate($limit);
+
+            foreach ($list as $row) {
+                
+                $row->getRelation('user')->visible(['username']);
+            }
+
+            $result = array("total" => $list->total(), "rows" => $list->items());
+
+            return json($result);
+        }
+        return $this->view->fetch();
+    }
+
 }

+ 10 - 9
application/admin/lang/zh-cn/feedback.php

@@ -1,13 +1,14 @@
 <?php
 
 return [
-    'Id'         => 'ID',
-    'User_id'    => '用户ID',
-    'Content'    => '内容',
-    'Images'     => '图片',
-    'Status'     => '状态',
-    'Status 0'   => '待处理',
-    'Status 1'   => '已处理',
-    'Createtime' => '创建时间',
-    'Updatetime' => '更新时间'
+    'Id'            => 'ID',
+    'User_id'       => '用户ID',
+    'Content'       => '内容',
+    'Images'        => '图片',
+    'Status'        => '状态',
+    'Status 0'      => '待处理',
+    'Status 1'      => '已处理',
+    'Createtime'    => '创建时间',
+    'Updatetime'    => '更新时间',
+    'User.username' => '用户名'
 ];

+ 4 - 0
application/admin/model/Feedback.php

@@ -46,4 +46,8 @@ class Feedback extends Model
 
 
 
+    public function user()
+    {
+        return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
+    }
 }

+ 1 - 0
public/assets/js/backend/feedback.js

@@ -32,6 +32,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1')}, formatter: Table.api.formatter.status},
                         {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                         {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+                        {field: 'user.username', title: __('User.username'), operate: 'LIKE'},
                         {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]
                 ]