Browse Source

用户关系

lizhen_gitee 1 year ago
parent
commit
86fe93ccd2

+ 2 - 1
application/admin/controller/Userrelation.php

@@ -54,7 +54,7 @@ class Userrelation extends Backend
             list($where, $sort, $order, $offset, $limit) = $this->buildparams();
 
             $list = $this->model
-                    ->with(['usera','userb'])
+                    ->with(['usera','userb','relation'])
                     ->where($where)
                     ->order($sort, $order)
                     ->paginate($limit);
@@ -63,6 +63,7 @@ class Userrelation extends Backend
                 
                 $row->getRelation('usera')->visible(['username']);
 				$row->getRelation('userb')->visible(['username']);
+				$row->getRelation('relation')->visible(['name']);
             }
 
             $result = array("total" => $list->total(), "rows" => $list->items());

+ 2 - 1
application/admin/lang/zh-cn/userrelation.php

@@ -12,5 +12,6 @@ return [
     'Createtime'    => '申请时间',
     'Updatetime'    => '更新时间',
     'Usera.username' => '用户名',
-    'Userb.username' => '被关联用户名'
+    'Userb.username' => '被关联用户名',
+    'Relation.name' => '关系名'
 ];

+ 6 - 0
application/admin/model/Userrelation.php

@@ -56,4 +56,10 @@ class Userrelation extends Model
     {
         return $this->belongsTo('User', 'to_uid', 'id', [], 'LEFT')->setEagerlyType(0);
     }
+
+
+    public function relation()
+    {
+        return $this->belongsTo('Relation', 'relation_id', 'id', [], 'LEFT')->setEagerlyType(0);
+    }
 }

+ 4 - 3
public/assets/js/backend/userrelation.js

@@ -26,10 +26,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     [
                         {checkbox: true},
                         {field: 'id', title: __('Id')},
-                        {field: 'uid', title: __('Uid')},
+//                        {field: 'uid', title: __('Uid')},
                         {field: 'usera.username', title: __('Usera.username'), operate: 'LIKE'},
-                        {field: 'relation_id', title: __('Relation_id')},
-                        {field: 'to_uid', title: __('To_uid')},
+//                        {field: 'relation_id', title: __('Relation_id')},
+                        {field: 'relation.name', title: __('Relation.name'), operate: 'LIKE'},
+//                        {field: 'to_uid', title: __('To_uid')},
                         {field: 'userb.username', title: __('Userb.username'), operate: 'LIKE'},
                         {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
                         {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},