瀏覽代碼

人事管理--解决进组时未绑定问题
库存管理--库存盘点增加完结,删除,货主管控(盘点和查看权限),显示盘点人等

haozi 5 年之前
父節點
當前提交
7ee4ab2373

+ 48 - 6
app/Http/Controllers/InventoryAccountController.php

@@ -45,19 +45,22 @@ class InventoryAccountController extends Controller
     //盘点-任务页面
     public function mission(Request $request,OwnerService $ownerService){
         if(!Gate::allows("库存管理-盘点")){ return redirect(url('/'));  }
-        $ownerService->syncOwnersData();
         $paginateParams = $request->input();
         $queryParam=$request->all();
         $inventoryAccounts=app('inventoryAccountService')->paginate($queryParam);
-        $owners=Owner::select('id','name')->get();
+        $owners=$ownerService->getSelection();
         return view('inventory.stockInventory.mission',compact('owners','inventoryAccounts','paginateParams'));
     }
     //进入盘点中或复盘页面
-    public function enterStockInventory($id){
-        if (!Gate::allows('库存管理-盘点')){return redirect(url('/')); }
+    public function enterStockInventory($id,Request $request){
+        if($request->input('listMode') ?? false){
+            if (!Gate::allows('库存管理-盘点-查看')){return redirect(url('/')); }
+        }else{
+            if (!Gate::allows('库存管理-盘点')){return redirect(url('/')); }
+        }
         if (!$id) return ['success'=>false,'data'=>'参数错误!'];
         $inventoryAccount=InventoryAccount::with('owner')->find($id);
-        $inventoryAccountMissions=InventoryAccountMission::with('commodity.barcodes')->where('inventory_account_id',$id)->orderBy('difference_amount','desc')->get();
+        $inventoryAccountMissions=InventoryAccountMission::with(['commodity.barcodes','stockInventoryPersons'])->where('inventory_account_id',$id)->orderBy('difference_amount','desc')->get();
         return view('inventory.stockInventory.inventoryMission',compact('inventoryAccount','inventoryAccountMissions'));
     }
 
@@ -78,7 +81,8 @@ class InventoryAccountController extends Controller
         /** @var InventoryAccountService $inventoryService */
         $inventoryService=app('inventoryAccountService');
         $inventoryAccount=$inventoryService->updateInventory($inventoryId);
-        return ['success'=>true,'inventoryMission'=>$inventoryAccountMission,'inventory'=>$inventoryAccount];
+        $stockInventoryPersons=$inventoryAccountMission->stockInventoryPersons;
+        return ['success'=>true,'inventoryMission'=>$inventoryAccountMission,'inventory'=>$inventoryAccount,'stockInventoryPersons'=>$stockInventoryPersons];
     }
     //根据该库存和产品条码查询该条盘点记录
     public function searchStockInventoryRecord(Request $request){
@@ -167,4 +171,42 @@ class InventoryAccountController extends Controller
         return ['success'=>true,'data'=>'质量状态修改成功'];
 
     }
+    public function 盘点任务完结($id){
+        if(!Gate::allows('库存管理-盘点-完结')){return['success'=>false,'status'=>'没有权限'];}
+        if (!$id)return['success'=>false,'status'=>'参数错误!'];
+        $inventoryAccount=app('inventoryAccountService')->盘点任务完结($id);
+        if (!$inventoryAccount)return['success'=>false,'status'=>'修改完结状态失败!'];
+        return['success'=>true,'data'=>$inventoryAccount];
+
+    }
+    public function 增加系统之外的库位记录(Request $request){
+        if(!Gate::allows('库存管理-盘点')){return['success'=>false,'data'=>'没有权限'];}
+        $location=$request->input('location');
+        $barcode=$request->input('barcode');
+        $inventoryId=$request->input('inventoryId');
+        $count=$request->input('count');
+        $inventoryAccountMission=app('inventoryAccountService')->增加系统之外的库位记录($location,$barcode,$inventoryId,$count);
+        if (!$inventoryAccountMission)return ['success'=>false,'data'=>'添加系统之外的库位记录失败!'];
+        dd($inventoryAccountMission);
+        return ['success'=>true,'data'=>$inventoryAccountMission];
+    }
+
+    public function 删除盘点记录(Request $request){
+        if(!Gate::allows('库存管理-盘点-删除')){return['success'=>false,'data'=>'没有权限'];}
+        $inventoryAccountMissionId=$request->inventoryAccountMissionId;
+        $inventoryAccountId=$request->inventoryAccountId;
+        if(is_null($inventoryAccountMissionId)){return ['success'=>false,'data'=>'传入id为空'];}
+        $inventoryAccountMission=InventoryAccountMission::where('id',$inventoryAccountMissionId)->delete();
+        $this->log(__METHOD__,__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
+        if ($inventoryAccountMission>0){
+            $inventoryAccount=InventoryAccount::where('id',$inventoryAccountId)->first();
+            $inventoryAccount->total=$inventoryAccount->total-1;
+            $inventoryAccount->processed=$inventoryAccount->getProcessedAmount();//已盘点数
+            $inventoryAccount->difference=$inventoryAccount->getDifferenceAmount();//盘点差异数
+            $inventoryAccount->returned=$inventoryAccount->getReturnedAmount(); //复盘归位数
+            $inventoryAccount->update();
+            $this->log(__METHOD__,'删除盘点记录时修改盘点任务信息'.__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
+        }
+        return ['success'=>true,'data'=>$inventoryAccountMission];
+    }
 }

+ 23 - 4
app/Http/Controllers/UserDutyCheckController.php

@@ -15,6 +15,7 @@ use Carbon\Carbon;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Facades\Cache;
+use Illuminate\Support\Facades\Cookie;
 use Illuminate\Support\Facades\Validator;
 use Ramsey\Uuid\Uuid;
 
@@ -297,11 +298,12 @@ class UserDutyCheckController extends Controller
             if ($userDutyCheck->type == '登出') return "<h1 style='color: red;text-align:center'>进场是否未打卡?如若未打,请先返回打进场卡!</h1>";
             $html=$this->updateLaborReport($user_id,$userWorkgroupID);
             if ($html)return $html;
+        }else{
+            return view("personnel/checking-in/enterGroupClock", compact('userWorkgroupID'));
         }
-        return "<h1 style='color: red;text-align:center'>进场还未打卡,暂无法进组!</h1>";
     }
 
-    public function updateLaborReport($user_id,$userWorkgroupID)
+    public function updateLaborReport($user_id,$userWorkgroupID,$userLaborToken=null)
     {
         $userDetail = UserDetail::find($user_id);
         $group_name = UserWorkgroup::where('id', $userWorkgroupID)->value('name');
@@ -325,7 +327,24 @@ class UserDutyCheckController extends Controller
             if (!$newLaborReport) return "<h1 style='color: red;text-align:center'>打卡异常,请联系相关人员!</h1>";
             if ($newLaborReport) event(new ClockinEvent($newLaborReport));
         }
-        return response()->view('personnel/checking-in/success', ['group_name' => $group_name ?? '', 'full_name' => $userDetail->full_name, 'check_in_at' => $newLaborReport->check_in_at, 'laravelEchoPrefix' => $laravelEchoPrefix]);
+        if ($userLaborToken){
+            return response()->view('personnel/checking-in/success', ['group_name' => $group_name ?? '', 'full_name' => $userDetail->full_name, 'check_in_at' => $newLaborReport->check_in_at, 'laravelEchoPrefix' => $laravelEchoPrefix])
+                ->cookie('userLaborToken',$userLaborToken,config('users.token_check_in_expire_minutes'),'/');
+        }else{
+            return response()->view('personnel/checking-in/success', ['group_name' => $group_name ?? '', 'full_name' => $userDetail->full_name, 'check_in_at' => $newLaborReport->check_in_at, 'laravelEchoPrefix' => $laravelEchoPrefix]);
+        }
     }
-
+    public function 绑定临时工并进组(Request $request){
+        $userWorkgroupID = $request->input('userWorkgroupID');
+        $mobile_phone = $request->input('mobile_phone');
+        $userDetail = UserDetail::where('mobile_phone', $mobile_phone)->first();
+        $userLaborToken=$userDetail->getDutyCheckToken(config('users.token_check_in_expire_minutes'));
+        $dateNow = Carbon::now()->format('Y-m-d');
+        $userDutyCheck = UserDutyCheck::where('user_id', $userDetail->user_id)->where('checked_at', 'like', $dateNow. '%')->orderBy('id', 'desc')->first();
+        if (!$userDutyCheck['verify_user_id']) return "<h1 style='color: red;text-align:center'>进场门卫还未审核,暂无法进组!</h1>";
+        if ($userDutyCheck->type == '登出') return "<h1 style='color: red;text-align:center'>进场是否未打卡?如若未打,请先返回打进场卡!</h1>";
+        $html=$this->updateLaborReport($userDetail->user_id,$userWorkgroupID,$userLaborToken);
+        if ($html)return $html;
     }
+
+}

+ 13 - 0
app/InventoryAccount.php

@@ -5,6 +5,7 @@ namespace App;
 use App\Traits\ModelTimeFormat;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Database\Eloquent\SoftDeletes;
+use Illuminate\Support\Facades\Auth;
 
 class InventoryAccount extends Model
 {
@@ -16,6 +17,10 @@ class InventoryAccount extends Model
     protected $appends = [
             'surplus','check_surplus'
     ];
+    public function creator(){
+        return $this->hasOne('App\Sign','signable_id','id')
+            ->where('signable_type','inventory_accounts')->where('field','创建人');
+    }
     public function owner(){
         return $this->belongsTo('App\Owner','owner_id','id');
     }
@@ -44,4 +49,12 @@ class InventoryAccount extends Model
         return $this->inventoryMissions()->where('inventory_account_id',$this['id'])->where('returned','是')->count();
 
     }
+    public function createSignCreator(){
+        return Sign::query()->create([
+            'signable_type'=>'inventory_accounts',
+            'signable_id'=>$this['id'],
+            'field'=>'创建人',
+            'mark'=>Auth::user()['name'],
+        ]);
+    }
 }

+ 15 - 0
app/InventoryAccountMission.php

@@ -2,10 +2,13 @@
 
 namespace App;
 
+use App\Traits\ModelTimeFormat;
 use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\Auth;
 
 class InventoryAccountMission extends Model
 {
+    use ModelTimeFormat;
     protected $fillable=[
         'id','inventory_account_id','location','commodity_id', 'produced_at', 'valid_at','stored_at','batch_number','erp_type_position','quality','stored_amount','valid_amount',
         'verified_amount','re_checked_amount','difference_amount','occupied_amount','checked',
@@ -13,4 +16,16 @@ class InventoryAccountMission extends Model
     public function commodity(){
         return $this->belongsTo('App\Commodity','commodity_id','id');
     }
+    public function stockInventoryPersons(){
+        return $this->hasMany('App\Sign','signable_id','id')
+            ->where('signable_type','inventory_account_missions')->where('field','盘点人');
+    }
+    public function createSignStockInventoryPersons(){
+        return Sign::query()->firstOrCreate([
+            'signable_type'=>'inventory_account_missions',
+            'signable_id'=>$this['id'],
+            'field'=>'盘点人',
+            'mark'=>Auth::user()['name'],
+        ]);
+    }
 }

+ 110 - 36
app/Services/InventoryAccountService.php

@@ -4,26 +4,26 @@
 namespace App\Services;
 
 use App\Commodity;
+use App\CommodityBarcode;
 use App\Http\Controllers\Controller;
 use App\InventoryAccount;
 use App\InventoryAccountMission;
 use App\OraccleBasCustomer;
-use App\OracleActTransactionLog;
 use App\OracleInvLotAtt;
 use App\OracleInvLotLocId;
 use App\Owner;
 use App\Services\common\QueryService;
+use App\Sign;
+use Carbon\Carbon;
 use Illuminate\Http\Request;
-use Illuminate\Support\Collection;
 use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Facades\DB;
-use Illuminate\Support\Facades\Gate;
 
 class InventoryAccountService
 {
 
     private function conditionQuery($queryParam){
-        $inventories=InventoryAccount::query()->with(['owner'])->orderBy('id','desc');
+        $inventories=InventoryAccount::query()->with(['owner','creator'])->orderBy('id','desc');
         $columnQueryRules=[
             'owner_id' => ['multi' => ','],
             'date_start' => ['alias' => 'created_at' , 'startDate' => ' 00:00:00'],
@@ -142,6 +142,7 @@ class InventoryAccountService
             'total'=>count($wmsInventories),
         ]);
         $inventory->save();
+        $inventory->createSignCreator();
         $this->createInventoryAccountMissionRecord($ownerId,$inventory['id'],$wmsInventories);
         $request=[
             'date_start'=>$date_start,
@@ -155,16 +156,31 @@ class InventoryAccountService
 
     //创建盘点记录任务
     public function createInventoryAccountMissionRecord($ownerId,$inventoryAccountId,$wmsInventories){
+        $commodities=Commodity::query()
+            ->select('id','owner_id','name','sku')
+            ->where('owner_id',$ownerId)
+            ->whereNotNull(['sku','name'])
+            ->get();
+        $commodityArr=[];
         $inventoryAccountMissions=[];
         foreach ($wmsInventories as $wmsInventory){
-            $commodity=Commodity::query()->firstOrCreate([
-                'owner_id'=>$ownerId,
-                'sku'=>$wmsInventory->产品编码,
-                'name'=>$wmsInventory->商品名称,
-            ]);
-            Controller::logS(__METHOD__,"根据wms产品编码和货主查询或创建商品信息__".__FUNCTION__,json_encode($wmsInventory));
-            $commodity->newBarcode($wmsInventory->产品条码);
-            Controller::logS(__METHOD__,"根据wms产品条码和商品id查询或创建商品条码信息__".__FUNCTION__,json_encode($wmsInventory));
+            $commodity=$commodities->where('name',$wmsInventory->商品名称)->where('sku',$wmsInventory->产品编码)->first();
+            if (!$commodity){
+                $commodity=new Commodity();
+                $commodity->owner_id=$ownerId;
+                $commodity->sku=$wmsInventory->产品编码;
+                $commodity->name=$wmsInventory->商品名称;
+                $commodity->save();
+                $commodity->newBarcode($wmsInventory->产品条码);
+                $arr=[
+                    'owner_id'=>$ownerId,
+                    'sku'=>$wmsInventory->产品编码,
+                    'name'=>$wmsInventory->商品名称,
+                    'commodity_id'=>$commodity->id,
+                    'barcode'=>$wmsInventory->产品条码,
+                ];
+                array_push($commodityArr,$arr);
+            }
             if($wmsInventory->质量状态=='ZP') $quality='正品';
             if ($wmsInventory->质量状态=='CC') $quality='残次';
             if ($wmsInventory->质量状态=='XS') $quality='箱损';
@@ -172,29 +188,36 @@ class InventoryAccountService
             if ($wmsInventory->质量状态=='DJ') $quality='冻结';
             if ($wmsInventory->质量状态=='FKT') $quality='封口贴';
             $inventoryAccountMission=[
-            'commodity_id'=>$commodity->id,
-            'inventory_account_id'=>$inventoryAccountId,
-            'location'=>$wmsInventory->库位,
-            'produced_at'=>$wmsInventory->生产日期,
-            'valid_at'=>$wmsInventory->失效日期,
-            'stored_at'=>$wmsInventory->入库日期,
-            'batch_number'=>$wmsInventory->批号,
-            'erp_type_position'=>$wmsInventory->属性仓,
-            'quality'=>$quality,
-            'stored_amount'=>$wmsInventory->在库数量,
-            'occupied_amount'=>$wmsInventory->占用数量,
-            'valid_amount'=>$wmsInventory->在库数量-$wmsInventory->占用数量,
+                'commodity_id'=>$commodity->id,
+                'inventory_account_id'=>$inventoryAccountId,
+                'location'=>$wmsInventory->库位,
+                'produced_at'=>$wmsInventory->生产日期,
+                'valid_at'=>$wmsInventory->失效日期,
+                'stored_at'=>$wmsInventory->入库日期,
+                'batch_number'=>$wmsInventory->批号,
+                'erp_type_position'=>$wmsInventory->属性仓,
+                'quality'=>$quality,
+                'stored_amount'=>$wmsInventory->在库数量,
+                'occupied_amount'=>$wmsInventory->占用数量,
+                'valid_amount'=>$wmsInventory->在库数量-$wmsInventory->占用数量,
+                'created_at'=>Carbon::now()->format('Y-m-d H:i:s'),
             ];
             array_push($inventoryAccountMissions,$inventoryAccountMission);
         }
-        DB::table('inventory_account_missions')->insert($inventoryAccountMissions);
+        $inventoryAccountMissions=InventoryAccountMission::query()->insert($inventoryAccountMissions);
+        if ($commodityArr){
+            Controller::logS(__METHOD__,"插入was中没有的商品信息__".__FUNCTION__,json_encode($commodityArr));
+        }
+        Controller::logS(__METHOD__,"批量插入盘点记录__".__FUNCTION__,json_encode($inventoryAccountMissions));
+
+
     }
     //盘点库存
     public function stockInventory($location,$barcode,$count,$inventoryAccountId){
 
-        $inventoryAccountMission=InventoryAccountMission::whereHas('commodity',function($query)use($barcode){
-             $query->whereHas('barcodes',function($sql)use($barcode){
-                 $sql->where('code','=',$barcode);
+        $inventoryAccountMission=InventoryAccountMission::with(['commodity.barcodes','stockInventoryPersons'])->whereHas('commodity',function($query)use($barcode){
+            $query->whereHas('barcodes',function($sql)use($barcode){
+                $sql->where('code','=',$barcode);
             });
         })->where('location',$location)->where('inventory_account_id',$inventoryAccountId)->first();
         if (!$inventoryAccountMission) return null;
@@ -208,12 +231,13 @@ class InventoryAccountService
             }else{
                 $inventoryAccountMission->returned='否';
             }
-        }else{
+        }else{//初盘
             $inventoryAccountMission->verified_amount=$count;
             $inventoryAccountMission->difference_amount=$count-$inventoryAccountMission->stored_amount;
             $inventoryAccountMission->checked='是';
         }
         $inventoryAccountMission->update();
+        $inventoryAccountMission->createSignStockInventoryPersons();
         $request=[
             'location'=>$location,
             'barcode'=>$barcode,
@@ -221,14 +245,19 @@ class InventoryAccountService
             'inventoryId'=>$inventoryAccountId,
         ];
         Controller::logS(__METHOD__,"盘点__".__FUNCTION__,json_encode($request));
+        $inventoryAccountMission=InventoryAccountMission::with(['commodity.barcodes','stockInventoryPersons'])->whereHas('commodity',function($query)use($barcode){
+            $query->whereHas('barcodes',function($sql)use($barcode){
+                $sql->where('code','=',$barcode);
+            });
+        })->where('location',$location)->where('inventory_account_id',$inventoryAccountId)->first();
         return $inventoryAccountMission;
     }
     //盘点修改盘点任务数据
     public function updateInventory($inventoryAccountId){
         $inventoryAccount=InventoryAccount::find($inventoryAccountId);
-        $inventoryAccount->processed=$inventoryAccount->getProcessedAmount();
-        $inventoryAccount->difference=$inventoryAccount->getDifferenceAmount();
-        $inventoryAccount->returned=$inventoryAccount->getReturnedAmount();
+        $inventoryAccount->processed=$inventoryAccount->getProcessedAmount();//已盘点数
+        $inventoryAccount->difference=$inventoryAccount->getDifferenceAmount();//盘点差异数
+        $inventoryAccount->returned=$inventoryAccount->getReturnedAmount(); //复盘归位数
         if($inventoryAccount->status=='待盘点')
             $inventoryAccount->status='盘点中';
         $inventoryAccount->update();
@@ -245,6 +274,7 @@ class InventoryAccountService
         if (!$inventoryAccountMission) return null;
         return  $inventoryAccountMission;
     }
+
     public function 修改质量状态($id,$location,$sku,$quality,$ownerCode){
         $lotnum=OracleInvLotLocId::query()->where('locationid',$location)->where('customerid',$ownerCode)->where('sku',$sku)->value('lotnum');
         if (!$lotnum) return null;
@@ -255,9 +285,53 @@ class InventoryAccountService
         $oracleInvLotAtt=OracleInvLotAtt::query()->where('lotnum',$lotnum)->where('sku',$sku)->where('customerid',$ownerCode)->update([
             'lotatt08'=>$status,
         ]);
-        $inventoryAccountMission=InventoryAccountMission::query()->find($id);
-        $inventoryAccountMission->quality=$quality;
-        $inventoryAccountMission=$inventoryAccountMission->update();
-        if ($oracleInvLotAtt>0&&$inventoryAccountMission)return $inventoryAccountMission;
+        if ($oracleInvLotAtt>0){
+            $inventoryAccountMission=InventoryAccountMission::query()->find($id);
+            $inventoryAccountMission->quality=$quality;
+            $inventoryAccountMission=$inventoryAccountMission->update();
+            return $inventoryAccountMission;
+        }else{
+            return null;
+        }
+    }
+    public function 盘点任务完结($id){
+        $inventoryAccount=InventoryAccount::query()->find($id);
+        if ($inventoryAccount->status=='复盘中'){
+            $inventoryAccount->status='已完成';
+            $inventoryAccount->update();
+            Controller::logS(__METHOD__,"盘点修改盘点任务中的已盘条数__".__FUNCTION__,json_encode($id));
+            return $inventoryAccount;
+        }else{
+            return null;
+        }
+    }
+    public function 增加系统之外的库位记录($location,$barcode,$inventoryId,$count){
+        $commodity=Commodity::query()->whereHas('barcodes',function ($query)use($barcode){
+            $query->where('code',$barcode);
+        })->first();
+        $inventoryAccountMission=new InventoryAccountMission();
+        $inventoryAccountMission->location=$location;
+        $inventoryAccountMission->inventory_account_id=$inventoryId;
+        $inventoryAccountMission->commodity_id=$commodity->id;
+        $inventoryAccountMission->verified_amount=$count;//盘点数量
+        $inventoryAccountMission->difference_amount=$count;//盘点差异
+        $inventoryAccountMission->checked='是';
+        $inventoryAccountMission->save();
+        Controller::logS(__METHOD__,"".__FUNCTION__,json_encode($inventoryId));
+        if ($inventoryAccountMission){
+            $inventoryAccountMission->createSignStockInventoryPersons();
+            Controller::logS(__METHOD__,"增加盘点人".__FUNCTION__,json_encode($inventoryId));
+            $inventoryAccount=InventoryAccount::query()->find($inventoryId);
+            $inventoryAccount->total=$inventoryAccount->total+1;
+            $inventoryAccount->processed=$inventoryAccount->getProcessedAmount();//已盘点数
+            $inventoryAccount->difference=$inventoryAccount->getDifferenceAmount();//盘点差异数
+            $inventoryAccount->returned=$inventoryAccount->getReturnedAmount(); //复盘归位数
+            $inventoryAccount->update();
+            Controller::logS(__METHOD__,"修改盘点任务记录".__FUNCTION__,json_encode($inventoryId));
+            return $inventoryAccountMission;
+        }else{
+            return null;
+        }
+
     }
 }

+ 2 - 0
app/Sign.php

@@ -2,10 +2,12 @@
 
 namespace App;
 
+use App\Traits\ModelTimeFormat;
 use Illuminate\Database\Eloquent\Model;
 
 class Sign extends Model
 {
+    use ModelTimeFormat;
     const UPDATED_AT = null;
     protected $fillable=[
         'signable_type','signable_id','field','mark'

+ 33 - 0
database/migrations/2020_09_02_181557_add_authorities_inventory_account_mission.php

@@ -0,0 +1,33 @@
+<?php
+
+use App\Authority;
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddAuthoritiesInventoryAccountMission extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        (new Authority(['name'=>'库存管理-盘点-查看','alias_name'=>'库存管理-盘点-查看']))->save();
+        (new Authority(['name'=>'库存管理-盘点-完结','alias_name'=>'库存管理-盘点-完结']))->save();
+        (new Authority(['name'=>'库存管理-盘点-删除','alias_name'=>'库存管理-盘点-删除']))->save();
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Authority::where('name','库存管理-盘点-查看')->delete();
+        Authority::where('name','库存管理-盘点-完结')->delete();
+        Authority::where('name','库存管理-盘点-删除')->delete();
+    }
+}

+ 32 - 0
database/migrations/2020_09_04_160942_add_status_to_inventory_account_missions.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddStatusToInventoryAccountMissions extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('inventory_account_missions', function (Blueprint $table) {
+            $table->enum('status', ['正常', '异常'])->default('正常')->comment('盘点记录');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('inventory_account_missions', function (Blueprint $table) {
+            $table->dropColumn('status');
+        });
+    }
+}

+ 58 - 9
resources/views/inventory/statement/inventoryCompare.blade.php

@@ -102,15 +102,24 @@
                 <tr class="p-0" id="header"></tr>
                 <tr v-for="(inventoryCompare,i) in inventoryCompares">
                    <td>
-                       <input type="checkbox" >
+                       <input type="checkbox" :value="inventoryCompare.id" v-model="checkData">
                    </td>
                     <td>@{{ i+1 }}</td>
-                    <td>@{{ inventoryCompare.owner.name }}</td>
+                    <td>@{{ inventoryCompare.owner_name }}</td>
                     <td>@{{ inventoryCompare.mission_code }}</td>
                     <td>@{{ inventoryCompare.created_at }}</td>
-                    <td>@{{ inventoryCompare.commodity.name }}</td>
-                    <td>@{{ inventoryCompare.commodity.sku }}</td>
-                    <td>@{{ inventoryCompare.commodity.barcode }}</td>
+                    <td>@{{ inventoryCompare.commodity_name }}</td>
+                    <td>@{{ inventoryCompare.commodity_sku }}</td>
+                    <td>
+                        <span v-if="inventoryCompare.commodity_barcodes && inventoryCompare.commodity_barcodes.length>0">
+                            <span v-if="inventoryCompare.commodity_barcodes.length==1">
+                                @{{ inventoryCompare.commodity_barcodes[0].code }}
+                            </span>
+                            <span v-if="inventoryCompare.commodity_barcodes.length>1">
+                                <small v-for="barcode in inventoryCompare.commodity_barcodes">@{{ barcode.code }}<br></small>
+                            </span>
+                        </span>
+                    </td>
                     <td>@{{ inventoryCompare.custom_location }}</td>
                     <td>@{{ inventoryCompare.quality }}</td>
                     <td>@{{ inventoryCompare.amount_in_sys }}</td>
@@ -131,7 +140,23 @@
         let vue = new Vue({
             el:"#container",
             data:{
-                inventoryCompares:{!! $inventoryCompares->toJson() !!}['data'],
+                {{--inventoryCompares:{!! $inventoryCompares->toJson() !!}['data'],--}}
+                inventoryCompares : [
+                        @foreach($inventoryCompares as $inventoryCompare)
+                    {id:'{{$inventoryCompare->id}}',owner_name:'{{$inventoryCompare->owner ? $inventoryCompare->owner->name : ''}}',
+                        created_at:'{{$inventoryCompare->created_at}}', commodity_name:'{{$inventoryCompare->commodity ? $inventoryCompare->commodity->name : ''}}',
+                        commodity_sku:'{{$inventoryCompare->commodity ? $inventoryCompare->commodity->sku : ''}}',
+                        commodity_barcodes:[
+                                @foreach($inventoryCompare->commodity ? $inventoryCompare->commodity->barcodes ?? [] : [] as $barcode)
+                            {code:'{{$barcode->code}}'},
+                            @endforeach
+                        ],
+                        custom_location:'{{$inventoryCompare->custom_location}}', quality:'{{$inventoryCompare->quality}}', amount_in_sys:'{{$inventoryCompare->amount_in_sys}}',
+                        amount_in_compare:'{{$inventoryCompare->amount_in_compare}}',
+                        differ:'{{$inventoryCompare->differ}}', mission_code:'{{$inventoryCompare->mission_code}}',
+                    },
+                    @endforeach
+                ],
                 differ:[
                     {name:'全部',value:'全部'},{name:'有',value:'有'},{name:'无',value:'无'},
                 ],
@@ -145,7 +170,18 @@
                 isSubmit:false,
             },
             watch:{
-
+                checkData:{
+                    handler(){
+                        if (this.checkData.length === this.inventoryCompares.length){
+                            document.querySelector('#all').checked = true;
+                            document.querySelector('#all_temp').checked = true;
+                        }else {
+                            document.querySelector('#all').checked = false;
+                            document.querySelector('#all_temp').checked = false;
+                        }
+                    },
+                    deep:true
+                }
             },
             mounted(){
                 $(".tooltipTarget").tooltip({'trigger': 'hover'});
@@ -175,7 +211,7 @@
                         dom:$('#cloneCheckAll').removeClass('d-none'), neglect: true},
                     {name:'index',value: '序号', neglect: true},
                     {name:'owner_name',value: '货主'},
-                    {name:'owner_name',value: '任务号'},
+                    {name:'mission_code',value: '任务号'},
                     {name: 'created_at', value: '生成时间'},
                     {name: 'commodity_name', value: '商品名称'},
                     {name:'commodity_sku',value: '商品编码'},
@@ -191,7 +227,7 @@
                     let header = new Header({
                         el: "#header",
                         column: column,
-                        data: _this.inventoryDailyLogs,
+                        data: _this.inventoryCompares,
                         restorationColumn: 'id',
                         fixedTop:($('#form').height())+2,
                         vue:vue
@@ -200,6 +236,19 @@
                 },0);
             },
             methods:{
+                //全选事件
+                checkAll(e) {
+                    if (e.target.checked) {
+                        this.inventoryCompares.forEach((el) => {
+                            if (!el.id) this.checkData.push(el.id);
+                            if (el.id && this.checkData.indexOf(el.id) === -1) {
+                                this.checkData.push(el.id);
+                            }
+                        });
+                    } else {
+                        this.checkData = [];
+                    }
+                },
                 importExcel(){
                     $('#importExcel').modal('show');
                 },

+ 289 - 88
resources/views/inventory/stockInventory/inventoryMission.blade.php

@@ -11,10 +11,13 @@
         <div class="mt-3">
 
             <span class="mt-3" >
-                <button class="btn btn-sm" @click="listMode?listMode=false:listMode=true" :class="listMode?'btn-dark':'btn-outline-dark'">
-                    <span v-if="!listMode">切换为列表</span>
-                    <span v-if="listMode">切换为盘点</span>
-                </button>
+                <a :href="'{{url('inventory/stockInventory/enterStockInventory')}}/'+inventory.id+'?listMode=true'"><button class="btn btn-sm btn-outline-dark" v-if="!listMode">切换为列表</button></a>
+                <a :href="'{{url('inventory/stockInventory/enterStockInventory')}}/'+inventory.id+'?listMode=false'"><button class="btn btn-sm btn-outline-dark" v-if="listMode &&inventory.status!='已完成'">切换为盘点</button></a>
+                <span><button class="btn btn-sm btn-outline-info" v-if="inventory.status==='复盘中' &&!listMode" @click="盘点任务完结(inventory.id,inventory.owner.name,inventory.type)">完结</button></span>
+{{--                <button class="btn btn-sm" @click="listMode?listMode=false:listMode=true" :class="listMode?'btn-dark':'btn-outline-dark'">--}}
+                {{--                    <span v-if="!listMode">切换为列表</span>--}}
+                {{--                    <span v-if="listMode">切换为盘点</span>--}}
+                {{--                </button>--}}
             </span>
             <span class="form-group  mb-5">
             <label class="text-muted">货主:</label><span class="font-weight-bold">@{{ inventory.owner.name }}</span>
@@ -64,8 +67,8 @@
         </span>
             <span class="form-group ml-4">
             <label for="barcode" class="text-secondary font-weight-bold">请输产品条码</label>
-            <input id="barcode" name="barcode"  @keypress="inputSwitch($event)"
-                   type="text" value="@if(old('barcode')){{old('barcode')}}@endif" class="form-control  input" autocomplete="off" @blur="searchBarcode">
+                <input id="barcode" name="barcode"  @keypress="inputSwitch($event)"
+                       type="text" value="@if(old('barcode')){{old('barcode')}}@endif" class="form-control  input" autocomplete="off" @blur="searchBarcode">
         </span>
             <span class="form-group ml-4">
             <label for="count" class="text-secondary font-weight-bold">请输盘点数</label>
@@ -74,80 +77,92 @@
         </span>
 
             <span v-if="inventory.status=='复盘中'" class="form-group ml-4">
-            <label for="count" class="text-secondary font-weight-bold">上一次盘点数</label>
+            <label for="count" class="text-secondary">上一次盘点数:</label>
             <span v-if="!inventoryMissionRecord.re_checked_amount">
-                <input type="text" id="count"  @keypress="inputSwitch($event)"
-                       name="count" v-model="inventoryMissionRecord.verified_amount" class="form-control  input" readonly>
+                <span  class="font-weight-bold" >@{{ inventoryMissionRecord.verified_amount }}</span>
             </span>
             <span v-if="inventoryMissionRecord.re_checked_amount">
-                <input type="text" id="count"  @keypress="inputSwitch($event)"
-                       name="count" v-model="inventoryMissionRecord.re_checked_amount" class="form-control  input" readonly>
+                <span class="font-weight-bold">@{{ inventoryMissionRecord.re_checked_amount }}</span>
             </span>
         </span>
+
             <span v-if="inventory.status=='复盘中'" class="form-group ml-4">
-            <label for="count" class="text-secondary font-weight-bold">盘点差异数</label>
-            <input type="text" id="difference_amount"  @keypress="inputSwitch($event)"
-                   name="difference_amount" v-model="inventoryMissionRecord.difference_amount" class="form-control  input" readonly>
+            <label for="count" class="text-secondary">盘点差异数:</label>
+            <span v-if="inventoryMissionRecord.difference_amount" class="font-weight-bold">@{{ inventoryMissionRecord.difference_amount }}</span>
         </span>
         </form>
 
 
-        <table class="table table-sm table-striped table-bordered table-hover text-nowrap d-none d-md-block  mt-2">
-            <tr>
-                <th>序号</th>
-                <th>库位</th>
-                <th>产品名</th>
-                <th>产品条码</th>
-                <th>产品编码</th>
-                <th>生产日期</th>
-                <th>失效日期</th>
-                <th>入库日期</th>
-                <th>批号</th>
-                <th>ERP属性仓</th>
-                <th>质量状态</th>
-                <th>库存数量</th>
-                <th>可用数量</th>
-                <th>盘点数量</th>
-                <th>复盘数量</th>
-                <th>盘点差异</th>
-                <th>分配数量</th>
-            </tr>
-            <tr v-for="(inventoryMission,i) in inventoryMissions" v-if="inventoryMission.checked==='是'||inventory.status==='复盘中'||listMode"  @click="selectedColor(inventoryMission.id)"
-                :style="{'font-weight': inventory.id==selectedStyle?'bold':''}" :class="[
+        <div class="card-header pt-0">
+            <div id="form"></div>
+        </div>
+        <div class="card-body pt-1">
+            <label for="all" class="d-none" id="cloneCheckAll">
+                <input id="all" type="checkbox" @click="checkAll($event)">全选
+            </label>
+            <table class="table table-sm table-bordered d-none text-nowrap " id="headerRoll"></table>
+            <table class="table table-sm table-hover table-striped d-none d-xl-block p-0 text-nowrap table-bordered" id="headerParent">
+                <tr class="p-0" id="header"></tr>
+                <tr v-for="(inventoryMission,i) in inventoryMissions" v-if="inventoryMission.checked==='是'||inventory.status==='复盘中'||listMode"  @click="selectedColor(inventoryMission.id)"
+                    :style="{'font-weight': inventory.id==selectedStyle?'bold':''}" :class="[
                     inventoryMission.mark==='已复盘有差异'?'td-cool':'',
                     inventoryMission.mark==='已复盘无差异'?'td-cool text-muted':'',
                     inventoryMission.mark==='未复盘有差异'?'td-warm font-weight-bold':'',
                     inventoryMission.mark==='无差异'?'text-muted':'',
                     inventoryMission.mark==='未盘'?'td-yellow':'',
                     ]">
-                <td>@{{ i+1 }}</td>
-                <td>@{{ inventoryMission.location }}</td>
-                <td v-if="inventoryMission.commodity">@{{ inventoryMission.commodity.name }}</td>
-                <td v-if="inventoryMission.commodity">@{{ inventoryMission.commodity.barcode }}</td>
-                <td v-if="inventoryMission.commodity">@{{ inventoryMission.commodity.sku }}</td>
-                <td >@{{ inventoryMission.produced_at }}</td>
-                <td >@{{ inventoryMission.valid_at }}</td>
-                <td >@{{ inventoryMission.stored_at }}</td>
-                <td class="text-muted">@{{ inventoryMission.batch_number }}</td>
-                <td >@{{ inventoryMission.erp_type_position }}</td>
-                <td >
-                    <span v-if="listMode">@{{ inventoryMission.quality }}</span>
-                    <select v-else class="form-control-sm" name="quality" id="quality"  v-model="inventoryMission.quality"
-                            @change="updateQuality(inventoryMission.id,inventoryMission.location,inventoryMission.commodity.sku,inventoryMission.quality,inventory.owner.code)">
-                        <option value="正品">正品</option>
-                        <option value="残次">残次</option>
-                    </select>
-                </td>
-                <td >@{{ inventoryMission.stored_amount }}</td>
-                <td >@{{ inventoryMission.valid_amount }}</td>
-                <td>@{{ inventoryMission.verified_amount }}</td>
-                <td>@{{ inventoryMission.re_checked_amount }}</td>
-                <td>@{{ inventoryMission.difference_amount }}</td>
-                <td>@{{ inventoryMission.occupied_amount }}</td>
-            </tr>
-        </table>
+                    <td>
+                        <input type="checkbox" :value="inventoryMission.id" v-model="checkData">
+                    </td>
+                    <td>@{{ i+1 }}</td>
+                    <td>@{{ inventoryMission.location }}</td>
+                    <td v-if="inventoryMission.commodity">@{{ inventoryMission.commodity.name }}</td>
+                    <td v-if="inventoryMission.commodity">@{{ inventoryMission.commodity.barcode }}</td>
+                    <td v-if="inventoryMission.commodity">@{{ inventoryMission.commodity.sku }}</td>
+                    <td >@{{ inventoryMission.produced_at }}</td>
+                    <td >@{{ inventoryMission.valid_at }}</td>
+                    <td class="text-muted">@{{ inventoryMission.batch_number }}</td>
+
+                    <td v-if="inventoryMission.stockInventoryPersons &&!listMode" class="text-muted" :rowspan="inventoryMission.is_multi_row?2:''">
+                        <a href="#" v-if="inventoryMission.stockInventoryPersons.length>0"  class="dropdown-toggle"  data-toggle="dropdown">
+                            @{{ inventoryMission.stockInventoryPersons[0].mark }}<b class="caret"></b>
+                        </a>
+                        <div style="position: absolute;width:320px;margin-left:-100px;background-color: white;max-height:150px ;overflow-y:auto" class="small mt-0 dropdown-menu">
+                            <table class="table table-sm table-striped table-bordered">
+                                <tr>
+                                    <th>盘点人</th>
+                                    <th>时间</th>
+                                </tr>
+                                <tr v-for="stockInventoryPerson in inventoryMission.stockInventoryPersons">
+                                    <td>@{{ stockInventoryPerson.mark }}</td>
+                                    <td>@{{ stockInventoryPerson.created_at }}</td>
+                                </tr>
+                            </table>
+                        </div>
+                    </td><td v-if="listMode"></td>
 
-        <table class="table table-striped table-sm table-bordered table-hover p-0 d-block d-md-none" style="background: rgb(255, 255, 255);" >
+                    <td >@{{ inventoryMission.erp_type_position }}</td>
+                    <td >
+                        <span v-if="listMode">@{{ inventoryMission.quality }}</span>
+                        <select v-else class="form-control-sm" name="quality" id="quality"  v-model="inventoryMission.quality"
+                                @change="updateQuality(inventoryMission.id,inventoryMission.location,inventoryMission.commodity.sku,inventoryMission.quality,inventory.owner.code)">
+                            <option value="正品">正品</option>
+                            <option value="残次">残次</option>
+                        </select>
+                    </td>
+                    <td >@{{ inventoryMission.stored_amount }}</td>
+                    <td >@{{ inventoryMission.valid_amount }}</td>
+                    <td>@{{ inventoryMission.verified_amount }}</td>
+                    <td>@{{ inventoryMission.re_checked_amount }}</td>
+                    <td>@{{ inventoryMission.difference_amount }}</td>
+                    <td>@{{ inventoryMission.occupied_amount }}</td>
+                    <td v-if="!listMode">
+                        <span class="btn  btn-sm btn-outline-danger" @click="删除盘点记录(inventoryMission.id,inventoryMission.inventory_account_id,inventoryMission.commodity.name)">删除</span>
+                    </td>
+                </tr>
+            </table>
+        </div>
+        <table id="listOnPad" class="table table-striped table-sm table-bordered table-hover p-0 d-table  d-xl-none" style="background: rgb(255, 255, 255);" >
             <tbody>
             <tr v-for="inventoryMission in inventoryMissions" v-if="inventoryMission.checked==='是'||inventory.status==='复盘中'||listMode"
                 :class="[
@@ -163,7 +178,7 @@
                             <span class="mr-3 text-nowrap"><span class="font-weight-bold">库位:</span><span style="color:#af7651">@{{ inventoryMission.location }}</span></span>
                             <span class="mr-3 text-nowrap"><span class="font-weight-bold">产品名称:</span><span style="color:#af7651" v-if="inventoryMission.commodity">@{{ inventoryMission.commodity.name }}</span></span>
                             <span class="mr-3 text-nowrap">
-                                <span class="font-weight-bold">产品条码:</span>
+                                <span class="font-weight-bold">质量状态:</span>
                                 <span v-if="listMode">@{{ inventoryMission.quality }}</span>
                         <select v-else class="form-control-sm" name="quality" id="quality"
                                 v-model="inventoryMission.quality"
@@ -178,6 +193,11 @@
                                 <span class="mr-3 text-nowrap"><span style="color:#783000" class="font-weight-bold">复盘数量:</span><span style="color:#af7651">@{{ inventoryMission.re_checked_amount }}</span></span>
                                 <span class="mr-3 text-nowrap"><span style="color:#783000" class="font-weight-bold">盘点差异:</span><span >@{{ inventoryMission.difference_amount }}</span></span>
                             </div>
+                            <div v-if="!listMode">
+                                <span  class="mr-3 text-nowrap"><span class="font-weight-bold">操作:</span>
+                                <span class="btn  btn-sm btn-outline-danger" @click="删除盘点记录(inventoryMission.id,inventoryMission.inventory_account_id,inventoryMission.commodity.name)">删除</span>
+                            </span>
+                            </div>
                         </div>
                     </div>
                 </td>
@@ -190,12 +210,44 @@
 @endsection
 
 @section('lastScript')
+    {{--    <script type="text/javascript" src="{{asset('js/queryForm/export200818a.js')}}"></script>--}}
+    {{--    <script type="text/javascript" src="{{asset('js/queryForm/queryForm200828a.js')}}"></script>--}}
+    <script type="text/javascript" src="{{asset('js/queryForm/header200826b.js')}}"></script>
     <script>
+        let hideHeaderTitle = function (){
+            let $listOnPad = $('#listOnPad');
+            let $headerRoll = $('#headerRoll');
+            if($listOnPad.css('display')!=='none'){
+                $headerRoll.attr('hidden',true)
+            }else{
+                $headerRoll.attr('hidden',false)
+                $headerRoll.find('tr').css('width',$(document).width());
+            }
+        };
+        window.onresize= hideHeaderTitle;
+        window.onscroll=hideHeaderTitle;
         let listVue = new Vue({
             el: "#list",
             data: {
                 inventory:{!! $inventoryAccount!!},
-                inventoryMissions:{!! $inventoryAccountMissions !!},
+                {{--inventoryMissions:{!! $inventoryAccountMissions !!},--}}
+                inventoryMissions : [
+                        @foreach($inventoryAccountMissions as $inventoryMission)
+                    {id:'{{$inventoryMission->id}}',location:'{{$inventoryMission->location}}',
+                        created_at:'{{$inventoryMission->created_at}}', commodity:{!! $inventoryMission->commodity  !!},
+                        commodity_name:'{{$inventoryMission->commodity ? $inventoryMission->commodity->name : ''}}',
+                        commodity_sku:'{{$inventoryMission->commodity ? $inventoryMission->commodity->sku : ''}}',
+                        commodity_barcode:'{{$inventoryMission->commodity ? $inventoryMission->commodity->barcode : ''}}',
+                        stockInventoryPersons:{!! $inventoryMission->stockInventoryPersons  !!},
+                        produced_at:'{{$inventoryMission->produced_at}}', valid_at:'{{$inventoryMission->valid_at}}', verified_amount:'{{$inventoryMission->verified_amount}}',
+                        stored_amount:'{{$inventoryMission->stored_amount}}', valid_amount:'{{$inventoryMission->valid_amount}}',
+                        stored_at:'{{$inventoryMission->stored_at}}', batch_number:'{{$inventoryMission->batch_number}}',
+                        erp_type_position:'{{$inventoryMission->erp_type_position}}', quality:'{{$inventoryMission->quality}}',
+                        difference_amount:'{{$inventoryMission->difference_amount}}', occupied_amount:'{{$inventoryMission->occupied_amount}}',
+                        checked:'{{$inventoryMission->checked}}', returned:'{{$inventoryMission->returned}}',
+                        re_checked_amount:'{{$inventoryMission->re_checked_amount}}'},
+                    @endforeach
+                ],
                 checkData: [],
                 selectedStyle:'',
                 inventoryMissionRecord:{},
@@ -220,13 +272,59 @@
                     if(listMode==='true'){_this.listMode=true;return;}
                     _this.listMode=false;
                 })();
+                let column = [
+                    {name:'cloneCheckAll',customization:true,type:'checkAll',column:'id',
+                        dom:$('#cloneCheckAll').removeClass('d-none'), neglect: true},
+                    {name:'index',value: '序号', neglect: true},
+                    {name:'location',value: '库位'},
+                    {name: 'commodity_name', value: '产品名'},
+                    {name: 'commodity_barcode', value: '产品条码'},
+                    {name:'commodity_sku',value: '产品编码'},
+                    {name: 'produced_at', value: '生产日期', neglect: true},
+                    {name: 'valid_at', value: '失效日期', neglect: true},
+                    {name: 'batch_number', value: '批号', neglect: true},
+                    {name: 'stockInventoryPersons',value: '盘点人', neglect: true},
+                    {name: 'erp_type_position', value: 'ERP属性仓', neglect: true},
+                    {name: 'quality', value: '质量状态', neglect: true},
+                    {name: 'stored_amount', value: '库存数量', neglect: true},
+                    {name: 'valid_amount', value: '可用数量', neglect: true},
+                    {name: 'verified_amount', value: '盘点数量', neglect: true},
+                    {name: 're_checked_amount', value: '复盘数量', neglect: true},
+                    {name: 'difference_amount', value: '复盘差异', neglect: true},
+                    {name: 'occupied_amount', value: '分配数量', neglect: true},
+                    {name: 'remove', value: '', neglect: true},
+                ];
+                setTimeout(function () {
+                    let header = new Header({
+                        el: "#header",
+                        column: column,
+                        data: _this.inventoryMissions,
+                        restorationColumn: 'id',
+                        fixedTop:($('#form').height())+2,
+                        vue:listVue,
+                    });
+                    header.init();
+                },0);
             },
             methods:{
+                //全选事件
+                checkAll(e) {
+                    if (e.target.checked) {
+                        this.inventoryMissions.forEach((el) => {
+                            if (!el.id) this.checkData.push(el.id);
+                            if (el.id && this.checkData.indexOf(el.id) === -1) {
+                                this.checkData.push(el.id);
+                            }
+                        });
+                    } else {
+                        this.checkData = [];
+                    }
+                },
                 inputSwitch(e){
                     if(e.key==='Enter') {
                         let inputs = $("#form .input");
                         let idx = inputs.index($(e.target));     // 获取当前焦点输入框所处的位置
-                        let location=document.getElementById('inventoryInput').value;
+                        let location=document.getElementById('inventoryInput').value.trim();
                         if (idx == 2) {       // 判断是否是最后一个输入框
                             if (location==''){
                                 document.getElementById('inventoryInput').focus();
@@ -248,45 +346,66 @@
                     }
                     this.selectedStyle=id;
                 },
-                //验证输入盘点产品条码对应是否有商品
+                //验证输入盘点产品条码对应是否有商品并且查询出初盘时的盘点记录
                 searchBarcode(){
                     let _this=this;
                     let barcode=document.getElementById('barcode').value.trim();
-                    let location=document.getElementById('inventoryInput').value;
+                    let location=document.getElementById('inventoryInput').value.trim();
                     let inventoryId=_this.inventory.id;
                     let barcodes=[];
                     _this.inventoryMissions.forEach(function (inventoryMission) {
                         barcodes.push(inventoryMission.commodity.barcode);
                     });
                     if (!barcodes.includes(barcode)){
-                        if (barcode!=''){
+                        if (barcode!==''){
                             tempTip.setDuration(2000);
                             tempTip.show('输入的产品条码没有对应的产品!');
                         }
                     }else {
-                        //根据该库存和产品条码查询该条盘点记录
-                        let url='{{url('inventory/searchStockInventoryRecord')}}';
-                        axios.post(url,{location:location,barcode:barcode,inventoryId:inventoryId}).then(function (response) {
-                            if (!response.data.success){
+                        if (location===''){
+                            document.getElementById('inventoryInput').focus();
+                            return;
+                        }
+                        if (_this.inventory.status==='复盘中'){
+                            //根据该库存和产品条码查询该条盘点记录
+                            let url='{{url('inventory/searchStockInventoryRecord')}}';
+                            axios.post(url,{location:location,barcode:barcode,inventoryId:inventoryId}).then(function (response) {
+                                if (!response.data.success){
+                                    tempTip.setDuration(2000);
+                                    tempTip.show('复盘!'+'   '+response.data.data);
+                                }else {
+                                    _this.inventoryMissionRecord=response.data.data;
+                                }
+                            }).catch(function (err) {
                                 tempTip.setDuration(2000);
-                                tempTip.show('复盘!'+'   '+response.data.data);
-                            }else {
-                                _this.inventoryMissionRecord=response.data.data;
-                            }
-                        }).catch(function (err) {
-                            tempTip.setDuration(2000);
-                            tempTip.show('网络错误'+err);
-                        });
+                                tempTip.show('网络错误'+err);
+                            });
+                        }
                     }
                 },
                 //提交盘点
                 submitStockInventory(){
                     let _this=this;
-                    let url='{{url('inventory/stockInventory')}}';
                     let location=document.getElementById('inventoryInput').value.trim();
                     let barcode=document.getElementById('barcode').value.trim();
                     let count=document.getElementById('count').value.trim();
                     let inventoryId=_this.inventory.id;
+                    let locations=[];
+                    _this.inventoryMissions.forEach(function (inventoryMission) {
+                        locations.push(inventoryMission.location);
+                    });
+                    if (location===''){
+                        document.getElementById('inventoryInput').focus();
+                        return;
+                    }
+                    if (_this.inventory.status==='盘点中'||_this.inventory.status==='待盘点'){
+                        if (!locations.includes(location)){
+                            if(!confirm('该'+location+'库位在系统盘点记录中不存在!'+'确定是否需要添加至系统盘点记录中?')){return};
+                            this.增加系统之外的库位记录(location,barcode,count,inventoryId);
+                            return;
+                        }
+                    }
+                    let url='{{url('inventory/stockInventory')}}';
                     axios.post(url,{location:location,barcode:barcode,count:count,inventoryId:inventoryId})
                         .then(function (response) {
                             if (!response.data.success){
@@ -300,11 +419,13 @@
                                 _this.inventory.check_surplus=response.data.inventory.check_surplus;
                             }
                             _this.inventoryMissions.every(function (inventoryMission,i) {
-                                if (inventoryMission.id===response.data.inventoryMission.id){
+
+                                if (parseInt(inventoryMission.id)===parseInt(response.data.inventoryMission.id)){
                                     inventoryMission.checked=response.data.inventoryMission.checked;
                                     inventoryMission.verified_amount=response.data.inventoryMission.verified_amount;
                                     inventoryMission.difference_amount=response.data.inventoryMission.difference_amount;
                                     inventoryMission.re_checked_amount=response.data.inventoryMission.re_checked_amount;
+                                    inventoryMission.stockInventoryPersons=response.data.stockInventoryPersons;
                                     _this.inventoryMissions.splice(i,1)
                                     _this.inventoryMissions.unshift(inventoryMission);
                                     return false;
@@ -314,7 +435,6 @@
                             _this.重排序并标记全列表类型(_this.inventoryMissions);
                             tempTip.setDuration(3000);
                             tempTip.showSuccess('盘点成功!');
-
                         }).catch(function (err) {
                         tempTip.setDuration(2000);
                         tempTip.show('盘点失败!'+'网络错误'+err);
@@ -363,10 +483,10 @@
                     _this.inventoryMissions.forEach(function (mission,i){
                         switch(mission.checked){
                             case '已复核':
-                                if(mission.difference_amount){_this.已复盘有差异列.push(mission); mission.mark='已复盘有差异';return;}
+                                if(parseInt(mission.difference_amount)){_this.已复盘有差异列.push(mission); mission.mark='已复盘有差异';return;}
                                 _this.已复盘无差异列.push(mission); mission.mark='已复盘无差异'; return;
                             case '是':
-                                if(mission.difference_amount){_this.未复盘有差异列.push(mission); mission.mark='未复盘有差异'; return;}
+                                if(parseInt(mission.difference_amount)){_this.未复盘有差异列.push(mission); mission.mark='未复盘有差异'; return;}
                                 _this.无差异列.push(mission); mission.mark='无差异'; return;
                             case '否':
                                 _this.未盘列.push(mission); mission.mark='未盘'; return;
@@ -429,8 +549,89 @@
                     }
                     迭代查重转移(inventoryMissions)
                     return 结果列;
-                }
-                ,
+                },
+                删除盘点记录(inventoryAccountMissionId,inventoryAccountId,name){
+                    let _this=this;
+                    if(!confirm('确定要删除商品为:“'+name+'”的盘点记录吗?')){return};
+                    let url = '{{url('inventory/删除盘点记录')}}';
+                    axios.post(url,{inventoryAccountMissionId:inventoryAccountMissionId,inventoryAccountId:inventoryAccountId}).then(
+                        function (response) {
+                            if(!response.data.success){
+                                tempTip.setDuration(3000);
+                                tempTip.show('盘点单号:'+id+'删除失败!');
+                            }else {
+                                _this.inventoryMissions.every(function (inventoryAccountMission,i) {
+                                    if (response.data.data>0&&inventoryAccountMission.id===inventoryAccountMissionId){
+                                        _this.inventoryMissions.splice(i,1);
+                                        return false;
+                                    }else {
+                                        return true
+                                    }
+                                });
+                                tempTip.setDuration(3000);
+                                tempTip.showSuccess('盘点记录:'+inventoryAccountMissionId+'删除成功!');
+                            }
+                        }
+                    ).catch(function (err) {
+                        tempTip.setDuration(3000);
+                        tempTip.show('删除失败,网络链接错误!'+err);
+                    });
+                },
+                盘点任务完结(id,owner_name,type){
+                    let _this=this;
+                    if(!confirm('确定完结货主为:“'+owner_name+'”的“'+type+'”任务吗?')){return};
+                    let url = '{{url('inventory/盘点任务完结')}}/'+id;
+                    axios.get(url).then(function (response) {
+                        if(!response.data.success){
+                            tempTip.setDuration(3000);
+                            tempTip.show('修改完结状态失败!');
+                        }else {
+                            if (response.data.data.id===id){
+                                tempTip.setDuration(3000);
+                                tempTip.showSuccess('货主为:“'+owner_name+'”的“'+type+'”任务完结成功');
+                                window.setTimeout(function () {
+                                    window.location.href='{{url('inventory/stockInventory/mission')}}';
+                                },1000);
+                            }
+                        }
+                    }).catch(function (err) {
+                        tempTip.setDuration(3000);
+                        tempTip.show('修改完结状态失败!  '+err);
+                    })
+                },
+                增加系统之外的库位记录(location,barcode,count,inventoryId){
+                    let _this=this;
+                    let url='{{url('inventory/增加系统之外的库位记录')}}';
+                    axios.post(url,{location:location,barcode:barcode,count:count,inventoryId:inventoryId}).then(
+                        function (response) {
+                            if(!response.data.success){
+                                tempTip.setDuration(3000);
+                                tempTip.show('增加系统之外的库位记录失败!');
+                            }else {
+                                _this.inventoryMissions.push(response.data.data);
+                                _this.inventoryMissions.every(function (inventoryAccountMission,i) {
+                                    if (parseInt(inventoryAccountMission.id)===parseInt(response.data.data.id)){
+                                        _this.inventoryMissions.splice(i,1)
+                                        _this.inventoryMissions.unshift(inventoryAccountMission);
+                                        return false;
+                                    }else {
+                                        return true
+                                    }
+                                });
+                                _this.重排序并标记全列表类型(_this.inventoryMissions);
+                                tempTip.setDuration(3000);
+                                tempTip.showSuccess('增加系统之外的库位记录成功!');
+                            }
+                        }
+                    ).catch(function (err) {
+                        tempTip.setDuration(3000);
+                        tempTip.show('增加系统之外的库位记录失败,网络链接错误!'+err);
+                    });
+                },
+
+
+
+
                 // 单条排序并着色(inventoryMission){
                 //     let _this=this;
                 //     let 所在临时分类列=[];

+ 112 - 60
resources/views/inventory/stockInventory/mission.blade.php

@@ -8,11 +8,12 @@
         {{--        <div id="form_div"></div>--}}
         <form class="form-inline mt-3">
             <span class="form-inline ml-5">
-                 <span class="btn btn-sm btn-outline-secondary" @click="syncOwners">同步货主</span>
-                <select class="form-control form-control-sm tooltipTarget" name="owner_id" id="owner_id" style="width: 150px" title="选择指定货主">
+                 <span class="btn btn-sm btn-outline-secondary tooltipTarget" @click="syncOwners">同步货主</span>
+                <select class="form-control form-control-sm tooltipTarget" name="owner_id" id="owner_id" style="width: 80px" title="选择指定货主">
                     <option value="">货主</option>
-                    <option v-for="owner in owners" :value="owner.id">@{{ owner.name }}</option>
+                    <option v-for="owner in fakeOwners" :value="owner.id">@{{ owner.name }}</option>
                 </select>
+                <input placeholder="定位货主" id="ownerName" autocomplete="off" class="form-control form-control-sm tooltipTarget" style="width: 100px" @change="定位货主($event)" title="输入关键字定位货主">
             </span>
             <span class="form-inline">
                 <input type="date" @change="hasDateStart" class="form-control form-control-sm ml-5 tooltipTarget" name="date_start" id="date_start"  title="选择创建日期的开始时间" style="width: 150px">
@@ -26,57 +27,46 @@
             </span>
         </form>
 
-        <table class="table table-sm table-striped table-bordered table-hover text-nowrap card-body mt-3">
-            <tr>
-                <th>
-                    <label for="all">
-                        <input id="all" type="checkbox" @click="checkAll($event)">全选
-                    </label>
-                </th>
-                <th>操作</th>
-                <th>序号</th>
-                <th>盘点状态</th>
-                <th>盘点单号</th>
-                <th>创建时间</th>
-                <th>货主</th>
-                <th>任务类型</th>
-                <th>起始时间</th>
-                <th>结束时间</th>
-                <th>记录数</th>
-                <th>已盘点数</th>
-                <th>剩余数</th>
-                <th>复盘差异</th>
-                <th>复盘归位</th>
-                <th>操作</th>
-            </tr>
-            <tr v-for="(inventory,i) in inventoryAccounts" @click="selectedColor(inventory.id)" :style="{'font-weight': inventory.id==selectedStyle?'bold':''}">
-                <td>
-                    <input class="checkItem" type="checkbox" :value="inventory.id" v-model="checkData">
-                </td>
-                <td>
-                    <span class="btn  btn-sm btn-outline-info" @click="enterStockInventory(inventory.id)">进入</span>
-                    <a :href="'{{url('inventory/stockInventory/enterStockInventory')}}/'+inventory.id+'?listMode=true'"><button class="btn btn-sm btn-outline-dark">查看</button></a>
-                </td>
-                <td >@{{ i+1 }}</td>
-                <td >@{{ inventory.status }}</td>
-                <td >@{{ inventory.id }}</td>
-                <td >@{{ inventory.created_at }}</td>
-                <td ><span v-if="inventory.owner">@{{ inventory.owner.name }}</span></td>
-                <td >@{{ inventory.type }}</td>
-                <td >@{{ inventory.start_at }}</td>
-                <td class="text-muted">@{{ inventory.end_at }}</td>
-                <td >@{{ inventory.total }}</td>
-                <td >@{{ inventory.processed }}</td>
-                <td >@{{ inventory.surplus }}</td>
-                <td>@{{ inventory.difference }}</td>
-                <td>@{{ inventory.returned }}</td>
-                <td>
-                    <span class="btn  btn-sm btn-outline-danger" @click="deleteStockInventoryMission(inventory.id)">删除</span>
-                </td>
-            </tr>
-        </table>
-        <div class="text-info h5 btn btn">{{$inventoryAccounts->count()}}/@{{ sum }}</div>
-        <div>{{$inventoryAccounts->appends($paginateParams)->links()}}</div>
+        <div class="card-header pt-0">
+            <div id="form"></div>
+        </div>
+        <div class="card-body pt-1">
+            <label for="all" class="d-none" id="cloneCheckAll">
+                <input id="all" type="checkbox" @click="checkAll($event)">全选
+            </label>
+            <table class="table table-sm text-nowrap table-bordered d-none" id="headerRoll"></table>
+            <table class="table table-sm text-nowrap table-striped table-bordered m-0" id="headerParent">
+                <tr class="p-0" id="header"></tr>
+                <tr v-for="(inventory,i) in inventoryAccounts" @click="selectedColor(inventory.id)" :style="{'font-weight': inventory.id==selectedStyle?'bold':''}">
+                    <td>
+                        <input class="checkItem" type="checkbox" :value="inventory.id" v-model="checkData">
+                    </td>
+                    <td>
+                        <span class="btn  btn-sm btn-outline-info" @click="enterStockInventory(inventory.id)" v-if="inventory.status!='已完成'">进入</span>
+                        <a :href="'{{url('inventory/stockInventory/enterStockInventory')}}/'+inventory.id+'?listMode=true'"><button class="btn btn-sm btn-outline-dark">查看</button></a>
+                    </td>
+                    <td >@{{ i+1 }}</td>
+                    <td >@{{ inventory.status }}</td>
+                    <td >@{{ inventory.id }}</td>
+                    <td >@{{ inventory.created_at }}</td>
+                    <td >@{{ inventory.owner_name }}</td>
+                    <td >@{{ inventory.type }}</td>
+                    <td >@{{ inventory.start_at }}</td>
+                    <td class="text-muted">@{{ inventory.end_at }}</td>
+                    <td >@{{ inventory.total }}</td>
+                    <td >@{{ inventory.processed }}</td>
+                    <td >@{{ inventory.surplus }}</td>
+                    <td>@{{ inventory.difference }}</td>
+                    <td>@{{ inventory.returned }}</td>
+                    <td>@{{ inventory.creator }}</td>
+                    <td>
+                        <span class="btn  btn-sm btn-outline-danger" @click="deleteStockInventoryMission(inventory.id)">删</span>
+                    </td>
+                </tr>
+            </table>
+            <div class="text-info h5 btn btn">{{$inventoryAccounts->count()}}/@{{ sum }}</div>
+            <div>{{$inventoryAccounts->appends($paginateParams)->links()}}</div>
+        </div>
         <span class="dropdown">
         <button class="btn btn-outline-dark btn-sm form-control-sm dropdown-toggle tooltipTarget" :class="[checkData.length>0?'btn-dark text-light':'']"
                 data-toggle="dropdown" title="导出所有页将会以搜索条件得到的筛选结果,将其全部记录(每一页)导出">
@@ -94,11 +84,23 @@
 @section('lastScript')
     <script type="text/javascript" src="{{asset('js/queryForm/export200818a.js')}}"></script>
     <script type="text/javascript" src="{{asset('js/queryForm/queryForm200828a.js')}}"></script>
+    <script type="text/javascript" src="{{asset('js/queryForm/header200826b.js')}}"></script>
     <script>
-        new Vue({
+        let vue = new Vue({
             el: "#list",
             data: {
-                inventoryAccounts:{!! $inventoryAccounts->toJson()!!}['data'],
+                {{--inventoryAccounts:{!! $inventoryAccounts->toJson()!!}['data'],--}}
+                inventoryAccounts : [
+                        @foreach($inventoryAccounts as $inventory)
+                    {id:'{{$inventory->id}}',owner_name:'{{$inventory->owner?$inventory->owner->name:''}}',
+                        creator:'{{$inventory->creator?$inventory->creator->mark:''}}',
+                        created_at:'{{$inventory->created_at}}', status:'{{$inventory->status}}', processed:'{{$inventory->processed}}',
+                        returned:'{{$inventory->returned}}', surplus:'{{$inventory->surplus}}',
+                        total:'{{$inventory->total}}',end_at:'{{$inventory->end_at}}',
+                        start_at:'{{$inventory->start_at}}',type:'{{$inventory->type}}',
+                        difference:'{{$inventory->difference}}'},
+                    @endforeach
+                ],
                 owners:{!! $owners !!},
                 checkData: [],
                 selectedStyle:'',
@@ -106,10 +108,44 @@
                 // formData:{},
                 date_end:'',
                 date_start:'',
+                fakeOwners:'',
             },
             mounted: function () {
                 $(".tooltipTarget").tooltip({'trigger': 'hover'});
                 $("#list").removeClass('d-none');
+                this.fakeOwners=this.owners;
+                let column = [
+                    {name:'cloneCheckAll',customization:true,type:'checkAll',column:'id',
+                        dom:$('#cloneCheckAll').removeClass('d-none'), neglect: true},
+                    {name:'operation',value: '操作', neglect: true},
+                    {name:'index',value: '序号', neglect: true},
+                    {name:'status',value: '盘点状态', neglect: true},
+                    {name:'id',value: '盘点单号', neglect: true},
+                    {name: 'created_at', value: '创建日期'},
+                    {name:'owner_name',value: '货主',neglect: true},
+                    {name: 'type', value: '任务类型'},
+                    {name:'start_at',value: '起始时间'},
+                    {name: 'end_at', value: '结束时间', neglect: true},
+                    {name: 'total', value: '记录数', neglect: true},
+                    {name: 'processed', value: '已盘点数', neglect: true},
+                    {name: 'surplus',value: '剩余数', neglect: true},
+                    {name: 'difference', value: '复盘差异', neglect: true},
+                    {name: 'returned', value: '复盘归位', neglect: true},
+                    {name: 'creator', value: '创建人', neglect: true},
+                    {name:'remove',value: '', neglect: true},
+                ];
+                let _this = this;
+                setTimeout(function () {
+                    let header = new Header({
+                        el: "#header",
+                        column: column,
+                        data: _this.inventoryAccounts,
+                        restorationColumn: 'id',
+                        fixedTop:($('#form').height())+2,
+                        vue:vue
+                    });
+                    header.init();
+                },0);
                 // let data=[
                 //     [
                 //         {name:'owner_id',type:'select_multiple_select',tip:['输入关键词快速定位下拉列表,回车确定','选择要显示的客户'],
@@ -136,7 +172,7 @@
                 },
                 checkAll(e){
                     if (e.target.checked){
-                        this.inventories.forEach((el,i)=>{
+                        this.inventoryAccounts.forEach((el,i)=>{
                             if (this.checkData.indexOf(el.id) == '-1'){
                                 this.checkData.push(el.id);
                             }
@@ -207,6 +243,7 @@
                 },
                 //删除盘点任务
                 deleteStockInventoryMission(id){
+                    let _this=this;
                     if(!confirm('确定要删除盘点单号为:“'+id+'”的运单吗?')){return};
                     let url = '{{url('inventory/deleteStockInventoryMission')}}/'+id;
                     axios.delete(url).then(
@@ -215,11 +252,16 @@
                                 tempTip.setDuration(3000);
                                 tempTip.show('盘点单号:'+id+'删除失败!');
                             }else {
+                                _this.inventoryAccounts.every(function (inventoryAccount,i) {
+                                    if (response.data.data>0&&inventoryAccount.id===id){
+                                        _this.inventoryAccounts.splice(i,1);
+                                        return false;
+                                    }else {
+                                        return true
+                                    }
+                                });
                                 tempTip.setDuration(3000);
                                 tempTip.showSuccess('盘点单号:'+id+'删除成功!');
-                                setInterval(function () {
-                                    window.location.reload();
-                                },1000)
                             }
                         }
                     ).catch(function (err) {
@@ -244,6 +286,16 @@
                         tempTip.show('同步货主失败,网络链接错误!'+err);
                     })
                 },
+                定位货主(e){
+                    let target = $(e.target).val();
+                    if(target === ''){
+                        this.fakeOwners = this.owners;
+                    }else{
+                        this.fakeOwners = this.fakeOwners.filter(function(map){
+                            return map.name.includes(target) ;
+                        })
+                    }
+                },
                 hasDateStart(){
                   this.date_start=document.getElementById('date_start').value;
                 },

+ 25 - 0
resources/views/personnel/checking-in/enterGroupClock.blade.php

@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <meta charset="utf-8">
+        <meta name="viewport" content="width=device-width, initial-scale=1">
+        <link href="{{ asset('css/app.css') }}" rel="stylesheet">
+    </head>
+    <body>
+        <div class="card col-md-8 offset-md-2 mt-5">
+            <div class="card-body">
+                <form method="post" action="{{url('personnel/checking-in/userDutyCheck/绑定临时工并进组')}}">
+                    @csrf
+                    <div class="form-group row">
+                        <label for="mobile_phone" class="form-check-label col-3 pull-right">手机号:</label>
+                        <input name="mobile_phone" id="mobile_phone" class="@error('mobile_phone') is-invalid @enderror col-7 form-control" type="text">
+                    </div>
+                    <input type="hidden" name="userWorkgroupID" value="{{ old('userWorkgroupID',$userWorkgroupID)}}">
+                    <div class="form-group row pt-3">
+                        <button type="submit" class="col-7 offset-3 btn btn-success">提交</button>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </body>
+</html>

+ 3 - 4
resources/views/personnel/laborReport/index.blade.php

@@ -281,12 +281,11 @@
                 sum:{!! $laborReports->total() !!},
             },
             mounted:function(){
-                /*initEcho();*/
+                initEcho();
                 let _this=this;
-/*                let laborReports=_this.laborReports;
+                let laborReports=_this.laborReports;
                 //进场
                 let tokenOfBroadcastEnterAndLeave='{{$tokenOfBroadcastEnterAndLeave}}';
-                //console.log(tokenOfBroadcastEnterAndLeave)
                 if(tokenOfBroadcastEnterAndLeave){
                     Echo.channel('{{$laravelEchoPrefix}}'+tokenOfBroadcastEnterAndLeave).listen('ImportEvent',(e)=>{
                         let labor=e.laborReport;
@@ -361,7 +360,7 @@
                             return true;
                         });
                     });
-                });*/
+                });
                 $(".tooltipTarget").tooltip({'trigger':'hover'});
                 $('#list').removeClass('d-none');
                 let data=[

+ 4 - 1
routes/web.php

@@ -163,6 +163,7 @@ Route::group(['prefix'=>'personnel/checking-in/userDutyCheck'],function(){
     Route::get('clock','UserDutyCheckController@clock');
     //进出场提交打卡
     Route::post('storeClock','UserDutyCheckController@storeClock');
+    Route::post('绑定临时工并进组','UserDutyCheckController@绑定临时工并进组');
     //进出场提交打卡
     Route::post('importGroupClock','UserDutyCheckController@importGroupClock');
     //去往登记资料页面
@@ -302,8 +303,10 @@ Route::group(['prefix'=>'inventory'],function (){
 
     //同步货主
     Route::get('syncOwners','InventoryAccountController@syncOwners');
-
+    Route::any('删除盘点记录','InventoryAccountController@删除盘点记录');
+    Route::get('盘点任务完结/{id}','InventoryAccountController@盘点任务完结');
     Route::post('修改质量状态','InventoryAccountController@修改质量状态');
+    Route::post('增加系统之外的库位记录','InventoryAccountController@增加系统之外的库位记录');
     //库存盘点
     Route::get('stockInventory/mission','InventoryAccountController@mission');
     //创建盘点任务