Kaynağa Gözat

人事管理--临时工报表--添加显示已退场选项,调整手机页面大小

haozi 5 yıl önce
ebeveyn
işleme
caab2853c8

+ 5 - 4
app/Events/ExportEvent.php

@@ -2,6 +2,7 @@
 
 namespace App\Events;
 
+use App\LaborReport;
 use App\UserDutyCheck;
 use Illuminate\Broadcasting\Channel;
 use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
@@ -12,16 +13,16 @@ class ExportEvent implements ShouldBroadcast
 {
     use  SerializesModels;
 
-    public $userDutyCheck;
+    public $laborReport;
 
     /**
      * Create a new event instance.
      *
      * @return void
      */
-    public function __construct(UserDutyCheck $userDutyCheck)
+    public function __construct(LaborReport $laborReport)
     {
-        $this->userDutyCheck=$userDutyCheck;
+        $this->laborReport=$laborReport;
     }
 
     /**
@@ -31,7 +32,7 @@ class ExportEvent implements ShouldBroadcast
      */
     public function broadcastOn()
     {
-        return new Channel('userDutyCheck');
+        return new Channel('laborReport');
     }
 
 }

+ 1 - 0
app/Events/GuardAuditEvent.php

@@ -2,6 +2,7 @@
 
 namespace App\Events;
 
+use App\LaborReport;
 use App\UserDutyCheck;
 use Illuminate\Broadcasting\Channel;
 use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

+ 6 - 4
app/Events/ImportEvent.php

@@ -2,6 +2,7 @@
 
 namespace App\Events;
 
+use App\LaborReport;
 use App\UserDutyCheck;
 use Illuminate\Broadcasting\Channel;
 use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
@@ -12,16 +13,16 @@ class ImportEvent implements ShouldBroadcast
 {
     use  SerializesModels;
 
-    public $userDutyCheck;
+    public $laborReport;
 
     /**
      * Create a new event instance.
      *
      * @return void
      */
-    public function __construct(UserDutyCheck $userDutyCheck)
+    public function __construct(LaborReport $laborReport)
     {
-        $this->userDutyCheck=$userDutyCheck;
+        $this->laborReport=$laborReport;
     }
 
     /**
@@ -31,7 +32,8 @@ class ImportEvent implements ShouldBroadcast
      */
     public function broadcastOn()
     {
-        return new Channel('userDutyCheck');
+        return new Channel(LaborReport::tokenOfBroadcastEnterAndLeave());
+        //return new Channel('laborReport');
     }
 
 }

+ 13 - 15
app/Http/Controllers/LaborReportController.php

@@ -32,21 +32,20 @@ class LaborReportController extends Controller
      */
     public function index(Request $request)
     {
-        //if(!Gate::allows('人事管理')){ return redirect(url('/'));  }
         if(!Gate::allows('人事管理-临时工报表')){ return redirect(url('/'));  }
+        $requests=$request->input();
         $user=Auth::user();
         if (!$user)return redirect('/');
-        $userWorkgroupIds=$user->getPermittingWorkgroupIds(Gate::allows('人事管理-临时工报表-可见全部组'));
-        $permittingWorkgroups=UserWorkgroup::whereIn('id',$userWorkgroupIds)->get();
-        if($permittingWorkgroups->isEmpty())$permittingWorkgroups="[]";
         $laravelEchoPrefix = config('database.redis.options.prefix');
-        $laborReportsBuilder=LaborReport::with(['user','userDutyCheck','userWorkgroup'])->whereIn('user_workgroup_id',$userWorkgroupIds);
+        $tokenOfBroadcastEnterAndLeave='';
         if(Gate::allows('人事管理-临时工报表-可见全部组')||Gate::allows('人事管理-门卫审核')){
-            $laborReportsBuilder->orWhereNull('user_workgroup_id');
+            $tokenOfBroadcastEnterAndLeave=LaborReport::tokenOfBroadcastEnterAndLeave();
         }
+        $userWorkgroupIds=$user->getPermittingWorkgroupIds(Gate::allows('人事管理-临时工报表-可见全部组'));
+        $permittingWorkgroups=UserWorkgroup::whereIn('id',$userWorkgroupIds)->get();
+        if($permittingWorkgroups->isEmpty())$permittingWorkgroups="[]";
         $laborReports=app('laborReportService')->paginate($request);
-//        $laborReportsPaginate = $laborReports;
-//        $laborReports=$laborReports->sortBy('name');
+//        $laborReports=$laborReports->sortBy('name');按名字排序
         foreach ($laborReports as $laborReport){
 //            if (!$laborReport->group_user_id){
 //                //三十分钟之内组长未审核实行软删除
@@ -62,9 +61,8 @@ class LaborReportController extends Controller
                 $this->log(__METHOD__,"进场门卫未审核该条记录将在一小时后实行软删除__".__FUNCTION__,$laborReport->toJson(),Auth::user()['id']);
             }
         }
-        $request=$request->input();
         $userWorkGroups=UserWorkgroup::select('id','name')->get();
-        return view('personnel/laborReport/index',compact('laborReports','userWorkGroups','laravelEchoPrefix','permittingWorkgroups','request'));
+        return view('personnel/laborReport/index',compact('laborReports','userWorkGroups','laravelEchoPrefix','permittingWorkgroups','requests','tokenOfBroadcastEnterAndLeave'));
     }
     public function export(Request $request){
         if (!Gate::allows('人事管理-临时工报表')){return redirect(url('/')); }
@@ -78,16 +76,16 @@ class LaborReportController extends Controller
         }
         $row=[[
             'id'=>'ID',
-            'enter_at'=>'进场时间',
-            'exit_at'=>'退场时间',
             'enter_number'=>'进厂编号',
             'user_workgroup_name'=>'小组',
             'name'=>'临时工',
             'mobile_phone'=>'电话',
             'identity_number'=>'身份证号',
             'labor_company'=>'劳务所',
+            'enter_at'=>'进场时间',
             'check_in_at'=>'进组时间',
             'check_out_at'=>'退组时间',
+            'exit_at'=>'退场时间',
             'verify_at'=>'审核时间',
             'group_user_id'=>'审核人',
             'relax_time'=>'晚饭时间(分)',
@@ -100,16 +98,16 @@ class LaborReportController extends Controller
             $laborReport=$laborReports[$i];
             $w=[
                 'id'=>isset($laborReport->id)?$laborReport->id:'',
-                'enter_at'=>isset($laborReport->enter_at)?$laborReport->enter_at:'',
-                'exit_at'=>isset($laborReport->exit_at)?$laborReport->exit_at:'',
                 'enter_number'=>isset($laborReport->enter_number)?$laborReport->enter_number:'',
                 'user_workgroup_name'=>isset($laborReport->userWorkgroup->name)?$laborReport->userWorkgroup->name:'',
                 'name'=>isset($laborReport->name)?$laborReport->name:'',
                 'mobile_phone'=>isset($laborReport->mobile_phone)?$laborReport->mobile_phone:'',
                 'identity_number'=>isset($laborReport->identity_number)?$laborReport->identity_number:'',
                 'labor_company'=>isset($laborReport->labor_company)?$laborReport->labor_company:'',
+                'enter_at'=>isset($laborReport->enter_at)?$laborReport->enter_at:'',
                 'check_in_at'=>isset($laborReport->check_in_at)?$laborReport->check_in_at:'',
                 'check_out_at'=>isset($laborReport->check_out_at)?$laborReport->check_out_at:'',
+                'exit_at'=>isset($laborReport->exit_at)?$laborReport->exit_at:'',
                 'verify_at'=>isset($laborReport->verify_at)?$laborReport->verify_at:'',
                 'group_user_id'=>isset($laborReport->user->name)?$laborReport->user->name:'',
                 'relax_time'=>isset($laborReport->relax_time)?$laborReport->relax_time:'',
@@ -126,7 +124,7 @@ class LaborReportController extends Controller
     public function guardClockAudit(Request $request){
         if(!Gate::allows('人事管理-门卫审核')){ return ["success"=>false,"data"=>"您无此权限操作!!!"];  }
         $id=$request->input('id');
-        $userDutyCheckId=$request->input('userDutyCheckId');
+        $userDutyCheckId=$request->input('user_duty_check_id');
         $laborReportStatus=new LaborReportStatus([
             'labor_report_id'=>$id,
             'status'=>'已入场',

+ 3 - 3
app/Http/Controllers/PersonnelController.php

@@ -59,7 +59,7 @@ class PersonnelController extends Controller
         if (!$laborReport&&$userDutyCheck->type=='登入'){
             $newReport=$userDutyCheck->makeEnteringRecord();
             $this->log(__METHOD__,"进场创建临时工报表记录__".__FUNCTION__,json_encode([$userDutyCheck]));
-            if ($newReport) event(new ImportEvent($userDutyCheck));
+            if ($newReport) event(new ImportEvent($newReport));
         }
         else if(!$laborReport&&$userDutyCheck->type=='登出'){
             //退场时间跨天情况
@@ -72,7 +72,7 @@ class PersonnelController extends Controller
             if ($laborReportYesterday){
                 $exportReport=$laborReportService->exportReplenishToCreateLaborReportData($laborReportYesterday,$userDutyCheck);
                 $this->log(__METHOD__,"补退场卡修改临时工报表记录__".__FUNCTION__,json_encode([$laborReportYesterday,$userDutyCheck]));
-                if ($exportReport) event(new ExportEvent($userDutyCheck));
+                if ($exportReport) event(new ExportEvent($exportReport));
             }
         }else if($laborReport){
             if (!$laborReport->check_out_at){
@@ -81,7 +81,7 @@ class PersonnelController extends Controller
             }
             $exportReport=$laborReportService->exportReplenishToCreateLaborReportData($laborReport,$userDutyCheck);
             $this->log(__METHOD__,"补退场卡修改临时工报表记录__".__FUNCTION__,json_encode([$laborReport,$userDutyCheck]));
-            if ($exportReport) event(new ExportEvent($userDutyCheck));
+            if ($exportReport) event(new ExportEvent($exportReport));
         }
     }
 

+ 0 - 3
app/Http/Controllers/UserDutyCheckController.php

@@ -3,9 +3,6 @@
 namespace App\Http\Controllers;
 
 use App\Events\ClockinEvent;
-use App\Events\ClockoutEvent;
-use App\Events\ExportEvent;
-use App\Events\ImportEvent;
 use App\LaborCompany;
 use App\LaborReport;
 use App\Services\LaborReportService;

+ 20 - 6
app/LaborReport.php

@@ -8,6 +8,8 @@ use App\Traits\ModelTimeFormat;
 use Illuminate\Database\Eloquent\SoftDeletes;
 use Illuminate\Support\Arr;
 use Illuminate\Support\Collection;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Gate;
 use function Matrix\add;
 
 class LaborReport extends Model
@@ -21,7 +23,7 @@ class LaborReport extends Model
     ];
     protected $appends = [
         'is_exportGroup','is_export', 'exit_at','enter_at','sequence', 'amountOfJoined','remark','thisRecordOnlineTime','thisRecordWorkingTime',
-        'totalOnlineTime',
+        'totalOnlineTime','verifyPerson','userDutyCheckVerifyUserId',
     ];
     protected $tempFields = [
         'temEnteringRecord',
@@ -29,6 +31,10 @@ class LaborReport extends Model
         'amountOfJoined',
     ];
 
+    static function tokenOfBroadcastEnterAndLeave(){
+        return md5('tokenOfListAll'.Carbon::now()->format('Y-m-d'));
+    }
+
     public function userWorkgroup(){
         return $this->belongsTo('App\UserWorkgroup','user_workgroup_id','id');
     }
@@ -36,7 +42,7 @@ class LaborReport extends Model
         return $this->belongsTo('App\User','group_user_id','id');
     }
     public function userDutyCheck(){
-        return $this->belongsTo('App\UserDutyCheck');
+        return $this->belongsTo('App\UserDutyCheck','user_duty_check_id','id');
     }
     public function laborReportStatus(){
         return $this->belongsTo('App\LaborReportStatus','id','labor_report_id');
@@ -52,12 +58,20 @@ class LaborReport extends Model
     public function getIsExportGroupAttribute(){
         return $this['check_out_at']? true:false;
     }
+
+    public function getVerifyPersonAttribute(){
+        if ($this['group_user_id']&&$this['group_user_id']==Auth::user()['id'])
+        return Auth::user()['name'];
+    }
+    public function getUserDutyCheckVerifyUserIdAttribute(){
+        return $this['userDutyCheck']['verify_user_id']?$this['userDutyCheck']['verify_user_id']:'';
+    }
     //总在线时长
     public function getTotalOnlineTimeAttribute(){
         $laborReports=LaborReport::where('enter_number',$this['enter_number'])->get();
         $totalOnlineTime=$laborReports->reduce(function ($value,$laborReport){
-            return $value+$laborReport['thisRecordOnlineTime'];
-        },0);
+            return ($value??0)+$laborReport['thisRecordOnlineTime'];
+        });
         return $totalOnlineTime;
     }
     //总工作时长
@@ -159,7 +173,7 @@ class LaborReport extends Model
 //        return $this['enteringRecord']->userDutyCheck['checked_at'];
         $laborReportStatus=LaborReportStatus::where('labor_report_id',$this['id'])->where('status','未审核')->orderBy('id','desc')->first();
         if (empty($laborReportStatus))return null;
-        return $laborReportStatus['created_at'];
+        return Carbon::parse($laborReportStatus['created_at'])->format('Y-m-d H:i:s');
     }
 
     public function getEnteringRecordAttribute()
@@ -199,7 +213,7 @@ class LaborReport extends Model
     {
         $laborReportStatus=LaborReportStatus::where('labor_report_id',$this['id'])->where('status','已退场')->orderBy('id','desc')->first();
         if (empty($laborReportStatus))return null;
-        return $laborReportStatus['created_at'];
+        return Carbon::parse($laborReportStatus['created_at'])->format('Y-m-d H:i:s');
     }
 
     //创建或获取进场编号

+ 22 - 7
app/Services/LaborReportService.php

@@ -16,12 +16,28 @@ use App\UserDutyCheck;
 use App\UserLabor;
 use Carbon\Carbon;
 use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Gate;
 
 
 class LaborReportService
 {
     private function conditionQuery(Request $request){
-        $laborReports=LaborReport::query()->orderBy('id','DESC');
+        $user=Auth::user();
+        $laborReports=LaborReport::query()->with(['user','userDutyCheck','userWorkgroup'])->orderBy('id','DESC')->whereIn('user_workgroup_id',
+            $user?$user->getPermittingWorkgroupIds(Gate::allows('人事管理-临时工报表-可见全部组')):[]);
+        $laborStatus=LaborReportStatus::select('labor_report_id')->where('status','已退场')->get();
+        $enterNumbers=[];
+        foreach ($laborStatus as $laborId){
+            $enterNumber=LaborReport::where('id',$laborId['labor_report_id'])->value('enter_number');
+            array_push($enterNumbers,$enterNumber);
+        }
+        if (!$request->is_export){
+            $laborReports->whereNotIn('enter_number',$enterNumbers);
+        }else $request->offsetUnset('is_export');
+        if(Gate::allows('人事管理-临时工报表-可见全部组')||Gate::allows('人事管理-门卫审核')){
+            $laborReports->orWhereNull('user_workgroup_id');
+        }
         $columnQueryRules=[
             'enter_number' => ['timeLimit' => 15],
             'created_at_start' => ['alias' => 'created_at' , 'startDate' => ' 00:00:00'],
@@ -39,9 +55,8 @@ class LaborReportService
     }
     public function some(Request $request){
         return LaborReport::query()->orderBy('id','DESC')
-                        ->whereIn('id',$request->data)->get();
+                        ->whereIn('id',explode(',',$request->data))->get();
     }
-
     //根据进场记录创建临时工报表
     public function makeLaborReportByUserDutyCheck($userDutyCheck){
         $dateNow=Carbon::now()->format('Y-m-d');
@@ -50,7 +65,7 @@ class LaborReportService
             $newReport=$userDutyCheck->laborEnterCheck();
             Controller::logS(__METHOD__,"进场创建临时工报表记录__".__FUNCTION__,json_encode([$userDutyCheck]));
             if ($newReport){
-                event(new ImportEvent($userDutyCheck));
+                event(new ImportEvent($newReport));
             }
         }
     }
@@ -62,7 +77,7 @@ class LaborReportService
         if ($userDutyCheck->type=='登入'&&$importAndExportQRCodeType=='import'){
             $newReport=$userDutyCheck->makeEnteringRecord();
             Controller::logS(__METHOD__,"进场创建临时工报表记录__".__FUNCTION__,json_encode([$userDutyCheck]));
-            if ($newReport) event(new ImportEvent($userDutyCheck));
+            if ($newReport) event(new ImportEvent($newReport));
         }
         if(!$laborReport&&$importAndExportQRCodeType=='export'){
             //退场时间跨天情况
@@ -74,7 +89,7 @@ class LaborReportService
             }
                 $exportReport=LaborReport::exitAndChangeLaborReport($laborReportYesterday,$userDutyCheck);
                 Controller::logS(__METHOD__,"退场更改临时工报表信息__".__FUNCTION__,json_encode([$laborReportYesterday,$userDutyCheck]));
-                if ($exportReport) event(new ExportEvent($userDutyCheck));
+                if ($exportReport) event(new ExportEvent($exportReport));
         }
         if($laborReport&&$importAndExportQRCodeType=='export'){
             if (!$laborReport['check_out_at']&&$laborReport['user_workgroup_id']){
@@ -83,7 +98,7 @@ class LaborReportService
             }
             $exportReport=LaborReport::exitAndChangeLaborReport($laborReport,$userDutyCheck);
             Controller::logS(__METHOD__,"退场更改临时工报表信息__".__FUNCTION__,json_encode([$laborReport,$userDutyCheck]));
-            if ($exportReport) event(new ExportEvent($userDutyCheck));
+            if ($exportReport) event(new ExportEvent($exportReport));
         }
     }
 

+ 4 - 4
app/Services/ProcessService.php

@@ -1,6 +1,6 @@
-<?php 
+<?php
 
-namespace App\Services; 
+namespace App\Services;
 
 use App\Process;
 use App\Services\common\QueryService;
@@ -8,7 +8,7 @@ use Carbon\Carbon;
 use Illuminate\Http\Request;
 
 Class ProcessService
-{ 
+{
     private function conditionQuery(Request $request){
         $processes=Process::filterAuthorities()->with(['tutorials','signs','processesContents'=>function($query){
             return $query->with(['commodity'=>function($query){
@@ -80,4 +80,4 @@ Class ProcessService
         }])->orderBy('processes.id','DESC')->whereIn('processes.id',explode(',',$request->data))->get();
     }
 
-}
+}

+ 0 - 9
app/Services/UserDutyCheckService.php

@@ -2,15 +2,6 @@
 
 
 namespace App\Services;
-use App\Http\Controllers\Controller;
-use App\Events\ExportEvent;
-use App\Events\ImportEvent;
-use App\Http\Controllers\UserDutyCheckController;
-use App\LaborReport;
-use App\UserDutyCheck;
-use Carbon\Carbon;
-use phpDocumentor\Reflection\DocBlock\Tags\Return_;
-
 class UserDutyCheckService
 {
 

+ 129 - 98
resources/views/personnel/laborReport/index.blade.php

@@ -18,7 +18,7 @@
                     <a class="dropdown-item" @click="laborReportExport(true)" href="javascript:">导出所有页</a>
                 </div>
             </span>
-        <table class="table table-sm table-hover table-striped d-none d-sm-block p-0 text-nowrap table-bordered" >
+        <table class="table table-sm table-hover table-striped d-none d-xl-block p-0 text-nowrap table-bordered" >
             <tr>
                 <th class="text-center">
                     <label for="all">
@@ -28,16 +28,16 @@
                 <th class="text-center">序号</th>
                 {{--                            <th>ID</th>--}}
                 <th class="text-center">操作</th>
-                <th class="text-center">进场时间</th>
-                <th class="text-center">退场时间</th>
                 <th class="text-center"  style="background-color: rgb(241, 234, 190)">进厂编号</th>
                 <th class="text-center" style="background-color: rgb(241, 234, 190)">小组</th>
                 <th class="text-center" style="background-color: rgb(241, 234, 190)">临时工</th>
                 <th class="text-center" style="background-color: rgb(241, 234, 190)">电话</th>
                 <th class="text-center" style="background-color: rgb(241, 234, 190)">身份证号</th>
                 <th class="text-center" style="background-color: rgb(241, 234, 190)">劳务所</th>
+                <th class="text-center">进场时间</th>
                 <th class="text-center">进组时间</th>
                 <th class="text-center">退组时间</th>
+                <th class="text-center">退场时间</th>
                 <th class="text-center">审核时间</th>
                 <th class="text-center">审核人</th>
                 <th class="text-center">晚饭打卡(分)</th>
@@ -45,7 +45,7 @@
                 <th class="text-center">本次工作时长</th>
                 <th class="text-center">备注</th>
             </tr>
-            <tr v-for="(laborReport,i) in laborReports" @click="selectedColor(laborReport.id)" :style="{'font-weight': laborReport.id==selectedStyle?'bold':''}">
+            <tr v-for="(laborReport,i) in laborReports"  @click="selectedColor(laborReport.id)" :style="{'font-weight': laborReport.id==selectedStyle?'bold':''}">
                 <td>
                     <input class="checkItem" type="checkbox" :value="laborReport.id" v-model="checkData">
                 </td>
@@ -55,7 +55,7 @@
                         <span >
                         <span v-if="laborReport.userDutyCheckVerifyUserId&&laborReport.amountOfJoined==1"  class="text-success">已审核</span>
                         <span v-else-if="laborReport.userDutyCheckVerifyUserId&&laborReport.amountOfJoined&&laborReport.sequence"  class="text-black">&nbsp;&nbsp;&nbsp;@{{laborReport.sequence}}/@{{laborReport.amountOfJoined}}</span>
-                        <button v-else class="btn btn-sm btn-outline-secondary"  @click="guardClockAudit(laborReport.id,laborReport.userDutyCheckId)">门卫审核</button>
+                        <button v-else class="btn btn-sm btn-outline-secondary"  @click="guardClockAudit(laborReport.id,laborReport.user_duty_check_id)">门卫审核</button>
                         </span>
                     @else
                         <span v-if="laborReport.userDutyCheckVerifyUserId&&laborReport.amountOfJoined==1"  class="text-success">已审核</span>
@@ -68,41 +68,40 @@
                         <button v-if="laborReport.groupUserId&&!laborReport.is_exportGroup" @click="groupExport(laborReport.id,laborReport.name)" class="btn btn-sm btn-outline-danger">退组</button>
                         <span v-else-if="laborReport.groupUserId&&laborReport.is_exportGroup&&!laborReport.is_export" class="text-info">已退组</span>
                             <span v-else-if="laborReport.is_export" class="text-black">已退场</span>
-                        <button v-else-if="laborReport.userWorkGroupId" @click="groupClockAudit(laborReport.id,laborReport.userWorkgroupNeedRemark)" class="btn btn-sm btn-outline-primary">组长审核</button>
+                        <button v-else-if="laborReport.user_workgroup_id" @click="groupClockAudit(laborReport.id,laborReport.userWorkgroupNeedRemark)" class="btn btn-sm btn-outline-primary">组长审核</button>
                         </span>
                     @else
                         <span  v-if="laborReport.groupUserId&&!laborReport.is_exportGroup"><b class="text-success">在组</b></span>
                         <span v-else-if="laborReport.groupUserId&&laborReport.is_exportGroup&&!laborReport.is_export" class="text-info">已退组</span>
                         <span v-else-if="laborReport.is_export" class="text-black">已退场</span>
-                        <span v-else-if="laborReport.userWorkGroupId" class="text-center"><b class="text-danger">组长未审核</b></span>
+                        <span v-else-if="laborReport.user_workgroup_id" class="text-center"><b class="text-danger">组长未审核</b></span>
                     @endcan
                 </td>
-                <td class="text-muted">@{{laborReport.enter_at}}</td>
-                <td >@{{ laborReport.exit_at }}</td>
-                <td class="text-muted">@{{laborReport.enterNumber}}</td>
+                <td class="text-muted">@{{laborReport.enter_number}}</td>
                 <td>@{{laborReport.userWorkGroupName}}</td>
                 <td >@{{laborReport.name}}</td>
-                <td class="text-muted">@{{laborReport.mobilePhone}}</td>
-                <td class="text-muted">@{{laborReport.identityNumber}}</td>
-                <td class="text-muted">@{{laborReport.laborCompany}}</td>
+                <td class="text-muted">@{{laborReport.mobile_phone}}</td>
+                <td class="text-muted">@{{laborReport.identity_number}}</td>
+                <td class="text-muted">@{{laborReport.labor_company}}</td>
+                <td class="text-muted">@{{laborReport.enter_at}}</td>
                 <td>@{{laborReport.checkInAt}}</td>
                 <td class="text-muted">@{{laborReport.checkOutAt}}</td>
+                <td >@{{ laborReport.exit_at }}</td>
                 <td class="text-muted">@{{laborReport.verifyAt}}</td>
                 <td class="text-muted"><span v-if="laborReport.verifyPerson">@{{laborReport.verifyPerson}}</span></td>
                 <td class="text-muted"><span v-if="laborReport.relax_time">@{{laborReport.relax_time}}</span></td>
-{{--                        <td class="text-muted"><span v-if="laborReport.onlineDuration">@{{laborReport.onlineDuration}}</span></td>--}}
+                {{--                        <td class="text-muted"><span v-if="laborReport.onlineDuration">@{{laborReport.onlineDuration}}</span></td>--}}
                 <td class="text-muted"><span v-if="laborReport.thisRecordOnlineTime">@{{laborReport.thisRecordOnlineTime}}</span></td>
                 <td><span v-if="laborReport.thisRecordWorkingTime">@{{laborReport.thisRecordWorkingTime}}</span></td>
-{{--                        <td><span v-if="laborReport.workingDuration">@{{laborReport.workingDuration}}</span></td>--}}
-                        <td><span v-if="laborReport.remark">@{{laborReport.remark}}</span></td>
-                    </tr>
-                </table>
-                <table class="table table-striped table-sm table-bordered table-hover p-0 d-block d-sm-none" style="background: rgb(255, 255, 255);">
-                    <tbody>
-                    <tr v-for="laborReport in laborReports">
-                        <td style="filter:grayscale(30%); ">
-                            <div  class="pl-3 mt-1">
-                                <div style="transform:scale(1)" class="pl-0">
+                {{--                        <td><span v-if="laborReport.workingDuration">@{{laborReport.workingDuration}}</span></td>--}}
+                <td><span v-if="laborReport.remark">@{{laborReport.remark}}</span></td>
+            </tr>
+        </table>
+        <table class="table table-striped table-bordered table-hover p-0 d-table  d-xl-none" style="background: rgb(255, 255, 255);">
+            <tr v-for="laborReport in laborReports">
+                <td style="filter:grayscale(30%);">
+                    <div  class="pl-3 mt-1">
+                        <div style="transform:scale(1)" class="pl-0">
                                         <span class="mr-3 text-nowrap">
                                             <span >操作:</span>
                                             <span >
@@ -110,7 +109,7 @@
                                                     <span >
                                 <b v-if="laborReport.userDutyCheckVerifyUserId&&laborReport.amountOfJoined==1"   class="text-success">已审核</b>
                                 <b v-else-if="laborReport.userDutyCheckVerifyUserId&&laborReport.amountOfJoined&&laborReport.sequence"  class="text-black">&nbsp;&nbsp;&nbsp;@{{laborReport.sequence}}/@{{laborReport.amountOfJoined}}</b>
-                                <button v-else style="transform:scale(1.1)" class="btn btn-lg btn-outline-secondary"  @click="guardClockAudit(laborReport.id,laborReport.userDutyCheckId)">门卫审核</button>
+                                <button v-else style="transform:scale(1.1)" class="btn btn-lg btn-outline-secondary"  @click="guardClockAudit(laborReport.id,laborReport.user_duty_check_id)">门卫审核</button>
                                 </span>
                                                 @else
                                                     <b v-if="laborReport.userDutyCheckVerifyUserId&&laborReport.amountOfJoined==1"  class="text-success">已审核</b>
@@ -123,39 +122,38 @@
                                 <button v-if="laborReport.groupUserId&&!laborReport.is_exportGroup" @click="groupExport(laborReport.id,laborReport.name)" style="transform:scale(1.1)" class="btn btn-lg btn-danger">退组</button>
                                 <b v-else-if="laborReport.groupUserId&&laborReport.is_exportGroup&&!laborReport.is_export" class="text-info">已退组</b>
                                     <b v-else-if="laborReport.is_export" class="text-black">已退场</b>
-                                <button v-else-if="laborReport.userWorkGroupId" @click="groupClockAudit(laborReport.id,laborReport.userWorkgroupNeedRemark)" class="btn btn-lg btn-outline-primary" style="transform:scale(1.1)" >组长审核</button>
+                                <button v-else-if="laborReport.user_workgroup_id" @click="groupClockAudit(laborReport.id,laborReport.userWorkgroupNeedRemark)" class="btn btn-lg btn-outline-primary" style="transform:scale(1.1)" >组长审核</button>
                                 </span>
                                                 @else
                                                     <span  v-if="laborReport.groupUserId&&!laborReport.is_exportGroup"><b class="text-success">在组</b></span>
                                                     <b v-else-if="laborReport.groupUserId&&laborReport.is_exportGroup&&!laborReport.is_export" class="text-info">已退组</b>
                                                     <b v-else-if="laborReport.is_export" class="text-black">已退场</b>
-                                                    <span v-else-if="laborReport.userWorkGroupId" class="text-center"><b class="text-danger">组长未审核</b></span>
+                                                    <span v-else-if="laborReport.user_workgroup_id" class="text-center"><b class="text-danger">组长未审核</b></span>
                                                 @endcan
                                             </span>
                                         </span>
-                                    <span class="mr-3   text-nowrap"><span class="text-black">进场时间:</span><span class="text-black-50">@{{laborReport.enter_at  }}</span></span>
-                                    {{--                                    <span class="mr-3 text-nowrap"><span class="text-black">退场时间:</span><span style="color:#af7651">@{{ laborReport.exit_at }}</span></span>--}}
-                                    {{--                                    <span class="mr-3 text-nowrap"><span class="text-black">进场编号:</span><span style="color:#af7651">@{{ laborReport.enterNumber }}</span></span>--}}
-                                    <span class="mr-3  text-nowrap"><span class="text-black">小组:</span><span class="text-black-50">@{{laborReport.userWorkGroupName  }}</span></span>
-                                    <span class="mr-3   text-nowrap"><span class="text-black">临时工:</span><span class="text-black-50">@{{ laborReport.name }} </span></span>
-                                    {{--                                    <span class="mr-3 text-nowrap"><span class="text-black">电话:</span><span style="color:#af7651" v-if="">@{{ laborReport.mobilePhone }} </span></span>--}}
-                                    {{--                                    <span class="mr-3 text-nowrap"><span class="text-black">身份证号:</span><span style="color:#af7651" v-if="">@{{ laborReport.identityNumber }} </span></span>--}}
-                                    {{--                                    <span class="mr-3 text-nowrap"><span class="text-black">劳务所:</span><span style="color:#af7651" v-if="">@{{ laborReport.laborCompany }} </span></span>--}}
-                                    {{--                                    <span class="mr-3 text-nowrap"><span class="text-black">进组时间:</span><span style="color:#af7651" v-if="">@{{ laborReport.checkInAt }} </span></span>--}}
-                                    {{--                                    <span class="mr-3 text-nowrap"><span class="text-black">退组时间:</span><span style="color:#af7651" v-if="">@{{ laborReport.checkOutAt }} </span></span>--}}
-                                    {{--                                    <span class="mr-3 text-nowrap"><span class="text-black">审核时间:</span><span style="color:#af7651" v-if="">@{{ laborReport.verifyAt }} </span></span>--}}
-                                    {{--                                    <span class="mr-3 text-nowrap"><span class="text-black">审核人:</span><span style="color:#af7651" v-if="">@{{ laborReport.verifyPerson }} </span></span>--}}
-                                    {{--                                    <span class="mr-3 text-nowrap"><span class="text-black">晚饭打卡(分):</span><span style="color:#af7651" v-if="">@{{ laborReport.relax_time }} </span></span>--}}
-                                    {{--                                    <span class="mr-3 text-nowrap"><span class="text-black">在线时长:</span><span style="color:#af7651" v-if="">@{{ laborReport.onlineDuration }} </span></span>--}}
-                                    {{--                                    <span class="mr-3 text-nowrap"><span class="text-black">本次工作时长:</span><span style="color:#af7651" v-if="">@{{ laborReport.workingDuration }} </span></span>--}}
-                                </div>
-                            </div>
-                        </td>
-                    </tr>
-                    </tbody>
-                </table>
+                            <span class="mr-3   text-nowrap"><span class="text-black">进场时间:</span><span class="text-black-50">@{{laborReport.enter_at  }}</span></span>
+                            {{--                                    <span class="mr-3 text-nowrap"><span class="text-black">退场时间:</span><span style="color:#af7651">@{{ laborReport.exit_at }}</span></span>--}}
+                            {{--                                    <span class="mr-3 text-nowrap"><span class="text-black">进场编号:</span><span style="color:#af7651">@{{ laborReport.enter_number }}</span></span>--}}
+                            <span class="mr-3  text-nowrap"><span class="text-black">小组:</span><span class="text-black-50">@{{laborReport.userWorkGroupName  }}</span></span>
+                            <span class="mr-3   text-nowrap"><span class="text-black">临时工:</span><span class="text-black-50">@{{ laborReport.name }} </span></span>
+                            {{--                                    <span class="mr-3 text-nowrap"><span class="text-black">电话:</span><span style="color:#af7651" v-if="">@{{ laborReport.mobile_phone }} </span></span>--}}
+                            {{--                                    <span class="mr-3 text-nowrap"><span class="text-black">身份证号:</span><span style="color:#af7651" v-if="">@{{ laborReport.identity_number }} </span></span>--}}
+                            {{--                                    <span class="mr-3 text-nowrap"><span class="text-black">劳务所:</span><span style="color:#af7651" v-if="">@{{ laborReport.labor_company }} </span></span>--}}
+                            {{--                                    <span class="mr-3 text-nowrap"><span class="text-black">进组时间:</span><span style="color:#af7651" v-if="">@{{ laborReport.checkInAt }} </span></span>--}}
+                            {{--                                    <span class="mr-3 text-nowrap"><span class="text-black">退组时间:</span><span style="color:#af7651" v-if="">@{{ laborReport.checkOutAt }} </span></span>--}}
+                            {{--                                    <span class="mr-3 text-nowrap"><span class="text-black">审核时间:</span><span style="color:#af7651" v-if="">@{{ laborReport.verifyAt }} </span></span>--}}
+                            {{--                                    <span class="mr-3 text-nowrap"><span class="text-black">审核人:</span><span style="color:#af7651" v-if="">@{{ laborReport.verifyPerson }} </span></span>--}}
+                            {{--                                    <span class="mr-3 text-nowrap"><span class="text-black">晚饭打卡(分):</span><span style="color:#af7651" v-if="">@{{ laborReport.relax_time }} </span></span>--}}
+                            {{--                                    <span class="mr-3 text-nowrap"><span class="text-black">在线时长:</span><span style="color:#af7651" v-if="">@{{ laborReport.onlineDuration }} </span></span>--}}
+                            {{--                                    <span class="mr-3 text-nowrap"><span class="text-black">本次工作时长:</span><span style="color:#af7651" v-if="">@{{ laborReport.workingDuration }} </span></span>--}}
+                        </div>
+                    </div>
+                </td>
+            </tr>
+        </table>
         <div class="text-info h5 btn btn">{{$laborReports->count()}}/@{{ sum }}</div>
-        <div>{{$laborReports->appends($request)->links()}}</div>
+        <div>{{$laborReports->appends($requests)->links()}}</div>
         {{--      选择晚饭时长弹框      --}}
         <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
             <div class="modal-dialog">
@@ -235,6 +233,22 @@
 @section('lastScript')
     <script type="text/javascript" src="{{asset('js/queryForm/export.js')}}"></script>
     <script type="text/javascript" src="{{asset('js/queryForm/queryForm200724.js')}}"></script>
+    <script>
+        let today=(new Date());
+        function isTomorrow(){
+            let now=(new Date());
+            const dateTime=new Date(now.setDate(now.getDate()+1));
+            if(dateTime<=today)return true;
+            else return false;
+        }
+        function reloadOnTomorrow(){
+            if(isTomorrow()){
+                window.location.reload();
+            }
+        }
+        window.onfocus=reloadOnTomorrow;
+        setInterval(reloadOnTomorrow,1000*60*60)
+    </script>
     <script>
             @if(isset($request))
         let request={!! json_encode($request) !!};
@@ -244,12 +258,12 @@
             data:{
                 laborReports:[
                         @foreach($laborReports as $laborReport)
-                    {id:'{{$laborReport->id}}',enterNumber:'{{$laborReport->enter_number}}'
-                        ,@if($laborReport->userWorkgroup)userWorkGroupId:'{{$laborReport->userWorkgroup->id}}',
+                    {id:'{{$laborReport->id}}',enter_number:'{{$laborReport->enter_number}}'
+                        ,@if($laborReport->userWorkgroup)user_workgroup_id:'{{$laborReport->userWorkgroup->id}}',
                         userWorkgroupNeedRemark:'{{$laborReport->userWorkgroup->isNeedRemark}}',
                         userWorkGroupName:'{{$laborReport->userWorkgroup->name}}',@endif
                         userId:'{{$laborReport->user_id}}',name:'{{$laborReport->name}}'
-                        ,mobilePhone:'{{$laborReport->mobile_phone}}',identityNumber:'{{$laborReport->identity_number}}',laborCompany:'{{$laborReport->labor_company}}'
+                        ,mobile_phone:'{{$laborReport->mobile_phone}}',identity_number:'{{$laborReport->identity_number}}',labor_company:'{{$laborReport->labor_company}}'
                         ,checkInAt:'{{$laborReport->check_in_at}}', relax_time:'{{$laborReport->relax_time}}',
                         is_exportGroup:'{{$laborReport->is_exportGroup}}',is_export:'{{$laborReport->is_export}}',
                         verifyAt:'{{$laborReport->verify_at}}',groupUserId:'{{$laborReport->group_user_id}}',verifyPerson:'{{$laborReport->user['name']}}',
@@ -259,14 +273,13 @@
                         thisRecordOnlineTime:'{{$laborReport->thisRecordOnlineTime}}',
                         thisRecordWorkingTime:'{{$laborReport->thisRecordWorkingTime}}',
                         sequence:'{{$laborReport->sequence}}',amountOfJoined:'{{$laborReport->amountOfJoined}}',remark:'{{$laborReport->remark}}',
-                        @if($laborReport->userDutyCheck)userDutyCheckId:'{{$laborReport->userDutyCheck->id}}', userDutyCheckVerifyUserId:'{{$laborReport->userDutyCheck->verify_user_id}}'
+                        @if($laborReport->userDutyCheck)user_duty_check_id:'{{$laborReport->userDutyCheck->id}}', userDutyCheckVerifyUserId:'{{$laborReport->userDutyCheck->verify_user_id}}'
                         ,userDutyCheckType:'{{$laborReport->userDutyCheck->type}}',userDutyCheckAt:'{{$laborReport->userDutyCheck->checked_at}}',@endif},
-
                     @endforeach
                 ],
                 i:0,
                 userWorkGroups:[
-                    @foreach($userWorkGroups as $userWorkGroup)
+                        @foreach($userWorkGroups as $userWorkGroup)
                     {name:'{{$userWorkGroup->id}}',value:'{{$userWorkGroup->name}}'},
                     @endforeach
                 ],
@@ -277,63 +290,80 @@
             },
             mounted:function(){
                 initEcho();
+                let _this=this;
+                let laborReports=_this.laborReports;
                 //进场
-                Echo.channel('{{$laravelEchoPrefix}}userDutyCheck').listen('ImportEvent',(e)=>{
-                    window.location.reload();
-                });
+                let tokenOfBroadcastEnterAndLeave='{{$tokenOfBroadcastEnterAndLeave}}';
+                if(tokenOfBroadcastEnterAndLeave)
+                    Echo.channel('{{$laravelEchoPrefix}}'+tokenOfBroadcastEnterAndLeave).listen('ImportEvent',(e)=>{
+                        let labor=e.laborReport;
+                        laborReports.push(labor);
+                    });
                 //退场
-                Echo.channel('{{$laravelEchoPrefix}}userDutyCheck').listen('ExportEvent',(e)=>{
-                    window.location.reload();
+                Echo.channel('{{$laravelEchoPrefix}}laborReport').listen('ExportEvent',(e)=>{
+                    let labor=e.laborReport;
+                    laborReports.every(function (laborReport) {
+                        if (laborReport.id==labor.id){
+                            laborReport.thisRecordOnlineTime=labor.thisRecordOnlineTime;
+                            laborReport.thisRecordWorkingTime=labor.thisRecordWorkingTime;
+                            laborReport.is_export=labor.is_export;
+                            laborReport.exit_at=labor.exit_at;
+                            return false
+                        }
+                        return true;
+                    });
                 });
                 //门卫审核
                 Echo.channel('{{$laravelEchoPrefix}}userDutyCheck').listen('GuardAuditEvent',(e)=>{
-                    setTimeout(function (){
-                        window.location.reload();
-                    }, 500);
+                    let userDutyCheck=e.userDutyCheck;
+                    laborReports.every(function (laborReport) {
+                        if (laborReport.user_duty_check_id==userDutyCheck.id){
+                            laborReport.userDutyCheckVerifyUserId=userDutyCheck.verify_user_id;
+                            laborReport.user_duty_check_id=userDutyCheck.id;
+                            return false
+                        }
+                        return true;
+                    });
                 });
-                {{--Echo.channel('{{$laravelEchoPrefix}}userDutyCheck').listen('GuardAuditEvent',(e)=>{--}}
-                {{--    let userDutyCheck=e.userDutyCheck;--}}
-                {{--    let _this=this;--}}
-                {{--    _this.laborReports.every(function (laborReport) {--}}
-                {{--        if (laborReport.userDutyCheckId==userDutyCheck.id){--}}
-                {{--            laborReport.userDutyCheck=userDutyCheck;--}}
-                {{--            laborReport.userDutyCheckVerifyUserId=userDutyCheck.verify_user_id;--}}
-                {{--            return false--}}
-                {{--        }--}}
-                {{--        return true;--}}
-                {{--    });--}}
-                {{--});--}}
                 //组长审核
                 Echo.channel('{{$laravelEchoPrefix}}laborReport').listen('TeamAuditEvent',(e)=>{
-                    setTimeout(function (){
-                        window.location.reload();
-                    }, 500);
+                    let labor=e.laborReport;
+                        laborReports.every(function (laborReport) {
+                            if (laborReport.id==labor.id){
+                                if(labor.remark){
+                                    laborReport.remark=labor.remark;
+                                }
+                                laborReport.verifyAt=labor.verify_at;
+                                laborReport.groupUserId=labor.group_user_id;
+                                laborReport.verifyPerson=labor.verifyPerson;
+                                return false
+                            }
+                            return true;
+                        });
                 });
-                {{--Echo.channel('{{$laravelEchoPrefix}}laborReport').listen('TeamAuditEvent',(e)=>{--}}
-                {{--    let labor=e.laborReport;--}}
-                {{--    let _this=this;--}}
-                {{--    setTimeout(function (){--}}
-                {{--        _this.laborReports.every(function (laborReport) {--}}
-                {{--            if (laborReport.id==labor.id){--}}
-                {{--                laborReport.groupUserId==labor.group_user_id;--}}
-                {{--                return false--}}
-                {{--            }--}}
-                {{--            return true;--}}
-                {{--        });--}}
-                {{--    }, 500);--}}
-                {{--});--}}
                 //进组
-                this.permittingWorkgroups.forEach(function(workgroup){
+                _this.permittingWorkgroups.forEach(function(workgroup){
                     Echo.channel('{{$laravelEchoPrefix}}'+workgroup.token).listen('ClockinEvent',(e)=>{
                         window.location.reload();
                     });
                 });
                 //退组
-                this.permittingWorkgroups.forEach(function(workgroup){
+                _this.permittingWorkgroups.forEach(function(workgroup){
                     Echo.channel('{{$laravelEchoPrefix}}'+workgroup.token).listen('ClockoutEvent',(e)=>{
-                        setTimeout(function (){
-                            window.location.reload();
-                        }, 500);
+                        let labor=e.laborReport;
+                        laborReports.every(function (laborReport) {
+                            if (laborReport.id==labor.id){
+                                laborReport.thisRecordOnlineTime=labor.thisRecordOnlineTime;
+                                laborReport.thisRecordWorkingTime=labor.thisRecordWorkingTime;
+                                laborReport.is_exportGroup=labor.is_exportGroup;
+                                laborReport.checkOutAt=labor.check_out_at;
+                                if (labor.relax_time){
+                                    laborReport.relax_time=labor.relax_time;
+                                }
+                                return false
+                            }
+                            return true;
+                        });
                     });
                 });
                 $(".tooltipTarget").tooltip({'trigger':'hover'});
@@ -343,6 +373,7 @@
                         {name:'created_at_start',type:'dataTime',tip:'选择显示指定日期的起始时间'},
                         {name:'user_workgroup_id',type:'search_select',tip:['',''],placeholder:['小组',''],data:this.userWorkGroups},
                         {name:'enter_number',type:'input',tip:'进场编号:支持15天内模糊搜索,15天外精确搜索',placeholder: '进场编号'},
+                        {name:'is_export',type:'checkbox',data:[{name:true,value:'显示已退场'}]},
                     ],
                     [
                         {name:'created_at_end',type:'dataTime',tip:'选择显示指定日期的结束时间'},
@@ -393,10 +424,10 @@
                     excelExport(checkAllSign,this.checkData,url,this.sum,token);
                 },
                 //门卫审核
-                guardClockAudit(id,userDutyCheckId){
+                guardClockAudit(id,user_duty_check_id){
                     let url='{{url("laborReport/guardClockAudit")}}';
                     let _this=this;
-                    axios.post(url,{id:id,userDutyCheckId:userDutyCheckId})
+                    axios.post(url,{id:id,user_duty_check_id:user_duty_check_id})
                         .then(function (response) {
                             if (!response.data.success){
                                 tempTip.setDuration(3000);

+ 3 - 2
routes/web.php

@@ -242,8 +242,7 @@ Route::resource('process','ProcessController');
  */
 //临时工报表界面
 Route::resource('personnel/laborReport','LaborReportController');
-//导出
-Route::any('laborReport/export','LaborReportController@export');
+
 Route::get('getLaborReport','LaborReportController@getDailyLabor');
 Route::group(['prefix'=>'laborReport'],function(){
     //门卫打卡审核
@@ -256,6 +255,8 @@ Route::group(['prefix'=>'laborReport'],function(){
     Route::post('groupExport','LaborReportController@groupExport');
     //组长点击退场,是否包含晚饭时间情况
     Route::post('groupExportEnsure','LaborReportController@groupExportEnsure');
+    //导出
+    Route::any('export','LaborReportController@export');
 });
 
 Route::group(['prefix'=>'personnel'],function(){