Explorar o código

临时工登记系统

ANG YU %!s(int64=4) %!d(string=hai) anos
pai
achega
fbb8d2a296

+ 50 - 0
app/Filters/LaborApplyFilters.php

@@ -0,0 +1,50 @@
+<?php
+
+
+namespace App\Filters;
+
+use App\OrderIssue;
+use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Http\Request;
+use Illuminate\Support\Carbon;
+
+class LaborApplyFilters
+{
+    protected $request;
+    protected $queryBuilder;
+    protected $filters = [
+        'created_at_start',
+        'created_at_end',
+    ];
+
+    protected $orderIssueQuery;
+
+    public function __construct(Request $request)
+    {
+        $this->request = $request;
+    }
+
+    public function apply($builder)
+    {
+        $this->queryBuilder = $builder;
+        $filters = array_filter($this->request->only($this->filters), function ($item) {
+            return $item !== null;
+        });
+        foreach ($filters as $filter => $value) {
+            if (method_exists($this, $filter)) {
+                $this->$filter($value, $this->queryBuilder);
+            }
+        }
+        return $this->queryBuilder;
+    }
+
+    public function created_at_start($created_at_start)
+    {
+        $this->queryBuilder->whereDate('created_at', '>=', $created_at_start);
+    }
+
+    public function created_at_end($created_at_end)
+    {
+        $this->queryBuilder->whereDate('created_at', '<=', $created_at_end);
+    }
+}

+ 48 - 0
app/Filters/LaborCompanyDispatchFilters.php

@@ -0,0 +1,48 @@
+<?php
+
+
+namespace App\Filters;
+
+use Illuminate\Http\Request;
+use Illuminate\Support\Carbon;
+
+class LaborCompanyDispatchFilters
+{
+    protected $request;
+    protected $queryBuilder;
+    protected $filters = [
+        'dispatch_date_start',
+        'dispatch_date_end',
+    ];
+
+    protected $orderIssueQuery;
+
+    public function __construct(Request $request)
+    {
+        $this->request = $request;
+    }
+
+    public function apply($builder)
+    {
+        $this->queryBuilder = $builder;
+        $filters = array_filter($this->request->only($this->filters), function ($item) {
+            return $item !== null;
+        });
+        foreach ($filters as $filter => $value) {
+            if (method_exists($this, $filter)) {
+                $this->$filter($value, $this->queryBuilder);
+            }
+        }
+        return $this->queryBuilder;
+    }
+
+    public function dispatch_date_start($dispatch_date_start)
+    {
+        $this->queryBuilder->whereDate('dispatch_date', '>=', $dispatch_date_start);
+    }
+
+    public function dispatch_date_end($dispatch_date_end)
+    {
+        $this->queryBuilder->whereDate('dispatch_date', '<=', $dispatch_date_end);
+    }
+}

+ 2 - 3
app/Http/Controllers/LaborApplyController.php

@@ -17,11 +17,10 @@ use Illuminate\Support\Facades\Gate;
 
 class LaborApplyController extends Controller
 {
-    public function index()
+    public function index(Request $request,\App\Filters\LaborApplyFilters $filters)
     {
-
-
         $builder = LaborApply::query()
+            ->filter($filters)
             ->with(['warehouse', 'userWorkGroup', 'applyUser']);
         if (!(\auth()->user()->isSuperAdmin() || Gate::allows('宝时人事部'))) {
             $builder->where('apply_user_id', \auth()->id());

+ 3 - 1
app/Http/Controllers/LaborCompanyDispatchController.php

@@ -2,6 +2,7 @@
 
 namespace App\Http\Controllers;
 
+use App\Filters\LaborCompanyDispatchFilters;
 use App\LaborApply;
 use App\LaborCompany;
 use App\LaborCompanyDispatch;
@@ -12,10 +13,11 @@ use Illuminate\Support\Facades\Gate;
 
 class LaborCompanyDispatchController extends Controller
 {
-    public function index()
+    public function index(Request $request, LaborCompanyDispatchFilters $filters)
     {
         //按照分配日期倒序
         $builder = LaborCompanyDispatch::query()
+            ->filter($filters)
             ->with(['laborCompany', 'laborCompanyDispatchDetails']);
 
         if (!(\auth()->user()->isSuperAdmin() || Gate::allows('宝时人事部'))) {

+ 5 - 0
app/LaborApply.php

@@ -85,4 +85,9 @@ class LaborApply extends Model
         $arrive_rate = $this->actual_num / $apply_num * 100;
         return number_format($arrive_rate, 1) . '%';
     }
+
+    public function scopeFilter($query, $filters)
+    {
+        return $filters->apply($query);
+    }
 }

+ 5 - 0
app/LaborCompanyDispatch.php

@@ -38,4 +38,9 @@ class LaborCompanyDispatch extends Model
     {
         return $this->hasMany(LaborCompanyDispatchDetail::class);
     }
+
+    public function scopeFilter($query, $filters)
+    {
+        return $filters->apply($query);
+    }
 }

+ 23 - 2
resources/views/personnel/laborApply/dispatch/index.blade.php

@@ -13,7 +13,13 @@
                     <td>
                         <input class="checkItem" type="checkbox" :value="labor_company_dispatch.id">
                     </td>
-                    <td>@{{ i+1 }}</td>
+                    <td>
+                        <div>
+                            @{{ i+1 }}
+                            <span v-if="labor_company_dispatch.exceed_max_labor_num_status==2"><i class="fa fa-thermometer-full" style="color: red" aria-hidden="true"></i></span>
+                        </div>
+
+                    </td>
                     <td>@{{ labor_company_dispatch.labor_company.name }}</td>
                     <td>@{{ labor_company_dispatch.man_num }}</td>
                     <td>@{{ labor_company_dispatch.woman_num }}</td>
@@ -74,7 +80,12 @@
                 $('#list').removeClass('d-none');
                 let _this = this;
                 $(".up").slideUp();
-                let data = []
+                let data = [
+                    [
+                        {name: 'dispatch_date_start', type: 'dateTime', tip: '选择显示分配时间的起始时间'},
+                        {name: 'dispatch_date_end', type: 'dateTime', tip: '选择显示分配时间的截止时间'},
+                    ]
+                ]
                 _this.form = new query({
                     el: '#form_div',
                     condition: data,
@@ -109,6 +120,16 @@
                         url = "{{ url('personnel/laborApply/dispatch') }}/" + labor_company_dispatch.id + '/detail/create';
                     }
                     return url;
+                },
+                exceed_max_labor_num_color(obj) {
+                    let result = {};
+                    if (obj.exceed_max_labor_num_status == 2) {
+                        result = {
+                            color: 'red',
+                        };
+
+                    }
+                    return result;
                 }
             },
         });

+ 7 - 3
resources/views/personnel/laborApply/index.blade.php

@@ -21,7 +21,6 @@
                         <input class="checkItem" type="checkbox" :value="labor_apply.id">
                     </td>
                     <td>@{{ i+1 }}</td>
-                    <td>@{{ labor_apply.id }}</td>
                     <td>@{{ labor_apply.status }}</td>
                     <td>@{{ labor_apply.created_at }}</td>
                     <td>@{{ labor_apply.remark }}</td>
@@ -99,7 +98,13 @@
                 $('#list').removeClass('d-none');
                 let _this = this;
                 $(".up").slideUp();
-                let data = []
+                let data = [
+                    [
+                        {name: 'created_at_start', type: 'dateTime', tip: '选择显示创建时间的起始时间'},
+                        {name: 'created_at_end', type: 'dateTime', tip: '选择显示创建时间的截止时间'},
+
+                    ]
+                ]
                 _this.form = new query({
                     el: '#form_div',
                     condition: data,
@@ -108,7 +113,6 @@
                 _this.form.init();
                 let column = [
                     {name: 'index', value: '序号', neglect: true},
-                    {name: 'id', value: '任务号'},
                     {name: 'status', value: '状态'},
                     {name: 'created_at', value: '申请日期'},
                     {name: 'remark', value: '用工要求'},