Procházet zdrojové kódy

项目耗材添加货主,耗材编码等筛选条件

hu hao před 4 roky
rodič
revize
199decbaf8

+ 10 - 15
app/Filters/OwnerMaterialFilters.php

@@ -15,10 +15,12 @@ class OwnerMaterialFilters
     protected $queryBuilder;
     protected $materialQuery;
     protected $userQuery;
-    protected $filters = [];
+    protected $filters = [
+        'owner_id','material_code','created_at_start','created_at_end','special','specification'
+    ];
     protected $array_filter;
     protected $params = [
-        'owner_id','material_code','user_name','created_at_start','created_at_end','special'
+        'owner_id','material_code','created_at_start','created_at_end','special','specification'
     ];
 
     public function __construct(Request $request)
@@ -64,13 +66,6 @@ class OwnerMaterialFilters
         return $this->materialQuery;
     }
 
-    private function getUserQuery():Builder
-    {
-        if(!$this->userQuery)
-            $this->userQuery = User::query()->selectRaw('id');
-        return $this->userQuery;
-    }
-
     public function owner_Id($owner_id)
     {
         $this->searchWay($this->queryBuilder,$owner_id,'owner_id');
@@ -78,12 +73,8 @@ class OwnerMaterialFilters
 
     public function material_code($material_code)
     {
-        $this->getMaterialQuery()->where('code','like',"{$material_code}%");
-    }
-
-    public function user_name($user_name)
-    {
-        $this->getUserQuery()->where('name','like',"{$user_name}%");
+//        $this->getMaterialQuery()->where('code','like',"{$material_code}%");
+        $this->queryBuilder->where('material_code','like',"{$material_code}%");
     }
 
     public function created_at_start($created_at)
@@ -100,6 +91,10 @@ class OwnerMaterialFilters
     {
         $this->queryBuilder->where('special','like',"{$special}%");
     }
+    public function specification($specification)
+    {
+        $this->queryBuilder->where('specification','like',"{$specification}%");
+    }
 
     public function afterApply()
     {

+ 1 - 1
app/Http/Controllers/OwnerMaterialController.php

@@ -23,7 +23,7 @@ class OwnerMaterialController extends Controller
     public function index(Request $request,OwnerMaterialFilters $filters)
     {
         $this->gate('项目耗材');
-        $ownerMaterials = OwnerMaterial::query()->with(['owner','material','initiator','file'])->orderByDesc('id')->filter($filters)->paginate($request['paginate'] ?? 50);
+        $ownerMaterials = OwnerMaterial::query()->filter($filters)->with(['owner','material','initiator','file'])->orderByDesc('id')->paginate($request['paginate'] ?? 50);
         $owners = app(OwnerService::class)->getAuthorizedOwners();
         $materials = Material::all();
         return view('/maintenance/ownerMaterial/index',compact('ownerMaterials','owners','materials'));

+ 21 - 0
resources/views/maintenance/ownerMaterial/index.blade.php

@@ -5,6 +5,7 @@
 @section('content')
     <div class="container-fluid d-none" id="owner_material">
         <div class="card">
+            <div id="form_div"></div>
             @can('项目耗材-编辑')
                 @include('maintenance.ownerMaterial._create')
                 @include('maintenance.ownerMaterial._edit')
@@ -25,12 +26,18 @@
 @endsection
 
 @section('lastScript')
+    <script type="text/javascript" src="{{mix('js/queryForm/queryForm.js')}}"></script>
 <script>
     let vue = new Vue({
         el:"#owner_material",
         data:{
             ownerMaterials:{!! $ownerMaterials->toJson() !!}['data'],
             owners:{!! $owners->toJson() !!},
+            owner_s:[
+                    @foreach($owners as $owner)
+                {name:'{{$owner->id}}',value:'{{$owner->name}}'},
+                @endforeach
+            ],
             materials:{!! $materials->toJson() !!},
             addOwnerMaterial:{},
             editOwnerMaterial:{},
@@ -45,6 +52,20 @@
             $('#owner_material').removeClass('d-none');
             this.filterOwners = JSON.parse(JSON.stringify(this.owners));
             this.filterMaterials = JSON.parse(JSON.stringify(this.materials));
+            let data = [
+                [
+                    {name:'material_code',type:'input',tip:'可支持多耗材编号,模糊搜索可在两侧添加百分号(%)进行',placeholder:'耗材编码'},
+                    {name:'owner_id',type:'select_multiple_select',tip:['输入关键词快速定位下拉列表,回车确定','选择要显示的客户'],
+                        placeholder:['货主','定位或多选货主'],data:this.owner_s},
+                    {name:'special',type:'input',tip:'模糊搜索可在两侧添加百分号(%)进行',placeholder:'特殊要求'},
+                    {name:'specification',type:'input',tip:'模糊搜索可在两侧添加百分号(%)进行',placeholder:'材质规格'},
+                ]
+            ];
+            this.form = new query({
+                el: '#form_div',
+                condition: data,
+            });
+            this.form.init();
         },
         created(){
             let _this = this;