Prechádzať zdrojové kódy

商家绑定产生多条数据

Cherry 2 rokov pred
rodič
commit
5386583ba0

+ 4 - 1
application/admin/controller/user/User.php

@@ -52,7 +52,7 @@ class User extends Backend
             list($where, $sort, $order, $offset, $limit) = $this->buildparams();
             $list = $this->model
 //                ->with('group')
-                ->with(['joinremarks1','joinremarks2','joinremarks3'])
+                ->with(['joinremarks1','joinremarks2','joinremarks3','bindremarks'])
                 ->where($where)
                 ->order($sort, $order)
                 ->paginate($limit);
@@ -328,6 +328,9 @@ class User extends Backend
 
                             $del_relations = true;
                         }
+                    }else{
+                        // 清空原有备注时,删除旧关系
+                        $del_relations = true;
                     }
                     //删除旧关系
                     $user_b_ids=[];

+ 5 - 0
application/admin/lang/zh-cn/user/user.php

@@ -44,4 +44,9 @@ return [
     'Remarks1' => '回收备注',
     'Remarks2' => '餐具备注',
     'Remarks3' => '商城备注',
+    'TypeRemarks' => '绑定商家备注分类',
+    'TypeRemarks 1' => '回收备注',
+    'TypeRemarks 2' => '餐具备注',
+    'TypeRemarks 3' => '商城备注',
+    'BindRemarks' => '绑定商家备注',
 ];

+ 5 - 0
application/admin/model/User.php

@@ -141,4 +141,9 @@ class User extends Model
     {
         return $this->belongsTo('UserRemarks', 'remarks3', 'id', [], 'LEFT')->setEagerlyType(0);
     }
+
+    public function bindremarks()
+    {
+        return $this->belongsTo('UserRemarks', 'bind_remarks', 'id', [], 'LEFT')->setEagerlyType(1);
+    }
 }

+ 11 - 4
public/assets/js/backend/user/user.js

@@ -46,6 +46,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'joinremarks1.value', title: __('Remarks1')},
                         {field: 'joinremarks2.value', title: __('Remarks2')},
                         {field: 'joinremarks3.value', title: __('Remarks3')},
+                        {
+                            field: 'type_remarks',
+                            title: __('TypeRemarks'),
+                            formatter: Table.api.formatter.normal,
+                            searchList: {"1": __('TypeRemarks 1'), "2": __('TypeRemarks 2'), "3": __('TypeRemarks 3')}
+                        },
+                        {field: 'bindremarks.value', title: __('BindRemarks'), operate: false,},
                         {field: 'score', title: __('Score'), operate: 'LIKE'},
                         {
                             field: 'logintime',
@@ -147,8 +154,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     }
                 }, function (data, ret) {
                     var op = '<option value="">--请选择备注--</option>';
-                    for(var i in data.list){
-                        op += '<option value="'+data.list[i]['id']+'">'+data.list[i]['value']+'</option>'
+                    for (var i in data.list) {
+                        op += '<option value="' + data.list[i]['id'] + '">' + data.list[i]['value'] + '</option>'
                     }
                     $("#c-bind_remarks").html(op);
                     $("#c-bind_remarks").selectpicker("refresh");
@@ -171,8 +178,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     }
                 }, function (data, ret) {
                     var op = '<option value="">--请选择备注--</option>';
-                    for(var i in data.list){
-                        op += '<option value="'+data.list[i]['id']+'">'+data.list[i]['value']+'</option>'
+                    for (var i in data.list) {
+                        op += '<option value="' + data.list[i]['id'] + '">' + data.list[i]['value'] + '</option>'
                     }
                     $("#c-bind_remarks").html(op);
                     $("#c-bind_remarks").selectpicker("refresh");