dyjh 6 năm trước cách đây
mục cha
commit
beabfa41d3

+ 20 - 1
app/Http/Controllers/Admin/Base/UserController.php

xqd
@@ -206,7 +206,26 @@ class UserController extends Controller
     {
         return $this->_role_service->getLevelNode($this->_user['admin_role_id'])->toArray();
     }
-    
+
+    public function searchUser()
+    {
+        $keyword = Request::post('keywords');
+        $query = AlbumManufacturerModel::where('id','>',0);
+        if(isset($keyword) && $keyword) {
+            $query = $query->where('id','like','%'.$keyword.'%')
+                ->orWhere('phone','like','%'.$keyword.'%')
+                ->orWhere('name','like','%'.$keyword.'%');
+        }
+        $list = $query->get(['name','id','phone'])->toArray();
+        if(empty($list)){
+            $list[0]=[
+                'id'=>0,
+                'name'=>'暂无'
+            ];
+        }
+        return response()->json(['code' => 0, 'message' => '', 'data' => $list]);
+    }
+
     /**
      * 得到所有角色
      */

+ 121 - 3
resources/views/admin/base/user/edit.blade.php

xqd xqd
@@ -52,12 +52,20 @@
 
                                 </div>
 
+
                                 <div class="form-group">
-                                    <label class="control-label col-sm-3">商户ID</label>
-                                    <div class="col-sm-9"><input id="txt_store_id" name="info[store_id]" class="form-control" value="{{ $data['store_id'] or ''}}" required="" aria-required="true" @if(!empty($data['mobile'])) readonly @endif placeholder="商户ID"></div>
 
-                                </div>
+                                    <label class="control-label col-sm-3">选择商户 </label>
+
+                                    <div class="col-sm-6">
+                                        <input id="data_store" class="form-control" v-model="checkstore.name"   readonly placeholder="">
+                                        <input id="data_store_id" type="hidden" name="info[store_id]" v-model="checkstore.id"  required="" aria-required="true"  placeholder="">
+                                    </div>
 
+                                    <div class="col-sm-3">
+                                        <button type="button" class="btn btn-w-m btn-primary" data-toggle="modal" data-target="#myModal5">选择</button>
+                                    </div>
+                                </div>
                                 <div class="form-group">
                                     <label class="control-label col-sm-3">密码</label>
                                     <div class="col-sm-9">
@@ -83,6 +91,116 @@
 			</div>
 		</div>
 	</div>
+    <div class="modal inmodal fade" id="myModal5" tabindex="-1" role="dialog"  aria-hidden="true">
+        <div class="modal-dialog modal-lg">
+            <div class="modal-content">
+                <div class="modal-header">
+                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
+                    <h4 class="modal-title">选择厂商</h4>
+                    <div class="search-form">
+                        <div class="input-group">
+                            <input type="text" placeholder="厂商名/ID/电话" name="search" class="form-control input-lg">
+                            <div class="input-group-btn">
+                                <button class="btn btn-lg btn-primary" type="submit" onclick="SearchStore()">
+                                    搜索
+                                </button>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+                <div class="modal-body app_v" id="userList" style="max-height: 420px;overflow: auto;">
+                    <table class="table table-striped table-bordered table-hover dataTables-example dataTable">
+                        <thead>
+                        <tr>
+                            <th> ID</th>
+                            <th> 名称</th>
+                            <th> 电话</th>
+                            <th>相关操作</th>
+                        </tr>
+                        </thead>
+                        <tbody style="max-height: 500px;">
+                        <tr v-if="list.num == 0">
+                            <td colspan="4" style="text-align: center">暂无数据</td>
+                        </tr>
+                        <tr v-for="item in list.data" v-if="list.num > 0">
+                            <td>@{{ item.id }}</td>
+                            <td>@{{ item.name }}</td>
+                            <td>@{{ item.phone }}</td>
+                            <td>
+                                <button class="btn btn-sm btn-success"
+                                        v-on:click="checkStore(item)" data-dismiss="modal">
+                                    选择
+                                </button>
+                            </td>
+                        </tr>
+
+                        </tbody>
+                    </table>
+                </div>
+
+
+            </div>
+        </div>
+    </div>
 </div>
+<script src="/base/js/vue.js"></script>
+<link href="/base/css/plugins/toastr/toastr.min.css" rel="stylesheet">
+<script src="/base/js/plugins/toastr/toastr.min.js"></script>
+<script>
+    toastr.options.positionClass = 'toast-bottom-center';
+    var store_id = "{{ $store['store_id'] or '0'}}";
+    var store_name = "{{ $store['name'] or ''}}";
+    var set = new Vue({
+        el:"#app",
+        data:{
+            list:{
+                num:0,
+                data:[],
+            },
+            checkstore:{
+                name:'请选择商户',
+                id:0
+            },
+        },
+        methods:{
+            init:function(){
+                if(store_name&&store_id!=0){
+                    Vue.set(this.checkstore,'name',store_name);
+                    Vue.set(this.checkstore,'id',store_id);
+                }
+            },
+            checkStore:function (store) {
+                Vue.set(this.checkuser,'name',store.name);
+                Vue.set(this.checkuser,'id',store.id);
+            },
+            changeData:function (e) {
+                var num = e.length;
+                Vue.set(this.list,'data',e)
+                Vue.set(this.list,'num',num)
+            }
+        }
+    });
+    set.init();
+    function SearchStore(){
+        var keywords = $("input[name='search']").val();
+        /* if(keywords == ''){
+             toastr.error('请输入搜索值!');
+             return false;
+         }*/
+        $.ajax({
+            url: "{{ U('Base/User/searchStore') }}",
+            method: 'POST',
+            data: {
+                'keywords':keywords,
+                '_token':"{{ csrf_token() }}"
+            },
+            dataType:'json',
+
+            success: function(data) {
+                set.changeData(data.data, 'user');
+            }
+        });
+    }
 
+</script>
 @endsection