Explorar o código

盘点任务--输入库位进行盘点
添加以库位批量盘点

haozi %!s(int64=5) %!d(string=hai) anos
pai
achega
cf104dee4d

+ 361 - 250
app/Http/Controllers/InventoryAccountController.php

@@ -19,322 +19,433 @@ class InventoryAccountController extends Controller
 {
     public function __construct()
     {
-        app()->singleton('inventoryAccountService',InventoryAccountService::class);
+        app()->singleton('inventoryAccountService', InventoryAccountService::class);
     }
 
     //创建盘点任务
-    public function createStockInventoryMission(Request $request){
-        if(!Gate::allows("库存管理-盘点")){ return redirect(url('/'));  }
+    public function createStockInventoryMission(Request $request)
+    {
+        if (!Gate::allows("库存管理-盘点")) {
+            return redirect(url('/'));
+        }
 //        $date_start=$request->input('formData.date_start');
 //        $date_end=$request->input('formData.date_end');
 //        $ownerId=$request->input('formData.owner_id')[0];
-        $date_start=$request->input('date_start');
-        $date_end=$request->input('date_end');
-        $ownerId=$request->input('owner_id');
-        $location=$request->input('location');
-        $barcode=$request->input('barcode');
-        $inventoryAccount=app('inventoryAccountService')->createMission($date_start,$date_end,$ownerId,$location,$barcode);
-        $inventoryAccount=InventoryAccount::with('owner')->find($inventoryAccount->id);
-        if (is_null($inventoryAccount)) return ['success'=>false,'data'=>'参数错误!'];
-        return ['success'=>true,'data'=>$inventoryAccount];
+        $date_start = $request->input('date_start');
+        $date_end = $request->input('date_end');
+        $ownerId = $request->input('owner_id');
+        $location = $request->input('location');
+        $barcode = $request->input('barcode');
+        $inventoryAccount = app('inventoryAccountService')->createMission($date_start, $date_end, $ownerId, $location, $barcode);
+        $inventoryAccount = InventoryAccount::with('owner')->find($inventoryAccount->id);
+        if (is_null($inventoryAccount)) return ['success' => false, 'data' => '参数错误!'];
+        return ['success' => true, 'data' => $inventoryAccount];
     }
+
     //删除盘点任务
-    public function deleteStockInventoryMission($id){
-        if(!Gate::allows('库存管理-盘点')){return['success'=>0,'status'=>'没有权限'];}
-        if(is_null($id)){return ['success'=>false,'data'=>'传入id为空'];}
-        $inventoryAccount=InventoryAccount::where('id',$id)->delete();
-        return ['success'=>true,'data'=>$inventoryAccount];
+    public function deleteStockInventoryMission($id)
+    {
+        if (!Gate::allows('库存管理-盘点')) {
+            return ['success' => 0, 'status' => '没有权限'];
+        }
+        if (is_null($id)) {
+            return ['success' => false, 'data' => '传入id为空'];
+        }
+        $inventoryAccount = InventoryAccount::where('id', $id)->delete();
+        return ['success' => true, 'data' => $inventoryAccount];
     }
-    public function inventoryChecked(Request $request){
-        if(!Gate::allows('库存管理-盘点-项目审核')){return['success'=>false,'msg'=>'没有权限'];}
-        $id=$request->id;
-        if(is_null($id)){return ['success'=>false,'msg'=>'传入id为空'];}
-        $inventoryAccount=InventoryAccount::query()->where('id',$id)->update([
-            'auditor'=>Auth::user()['id'],
-            'status'=>'已审核',
+
+    public function inventoryChecked(Request $request)
+    {
+        if (!Gate::allows('库存管理-盘点-项目审核')) {
+            return ['success' => false, 'msg' => '没有权限'];
+        }
+        $id = $request->id;
+        if (is_null($id)) {
+            return ['success' => false, 'msg' => '传入id为空'];
+        }
+        $inventoryAccount = InventoryAccount::query()->where('id', $id)->update([
+            'auditor' => Auth::user()['id'],
+            'status' => '已审核',
         ]);
-        if ($inventoryAccount==1) {
-            $inventoryAccount=InventoryAccount::query()->with('userAuditor')->find($id);
-            return ['success'=>true,'data'=>$inventoryAccount];
-        }else{
-            return ['success'=>false,'msg'=>'审核失败!'];
+        if ($inventoryAccount == 1) {
+            $inventoryAccount = InventoryAccount::query()->with('userAuditor')->find($id);
+            return ['success' => true, 'data' => $inventoryAccount];
+        } else {
+            return ['success' => false, 'msg' => '审核失败!'];
         }
     }
 
     //盘点-任务页面
-    public function mission(Request $request,OwnerService $ownerService){
-        if(!Gate::allows("库存管理-盘点")){ return redirect(url('/'));  }
+    public function mission(Request $request, OwnerService $ownerService)
+    {
+        if (!Gate::allows("库存管理-盘点")) {
+            return redirect(url('/'));
+        }
         $paginateParams = $request->input();
-        $queryParam=$request->all();
-        $inventoryAccounts=app('inventoryAccountService')->paginate($queryParam);
-        $owners=$ownerService->getSelection();
-        return view('inventory.stockInventory.mission',compact('owners','inventoryAccounts','paginateParams'));
+        $queryParam = $request->all();
+        $inventoryAccounts = app('inventoryAccountService')->paginate($queryParam);
+        $owners = $ownerService->getSelection();
+        return view('inventory.stockInventory.mission', compact('owners', 'inventoryAccounts', 'paginateParams'));
     }
+
     //进入盘点中或复盘页面
-    public function enterStockInventory($id,Request $request){
-        if (!Gate::allows('库存管理-盘点')){return redirect(url('/')); }
-        if (!$id) return ['success'=>false,'data'=>'参数错误!'];
-        $inventoryAccount=InventoryAccount::with('owner')->find($id);
-        $inventoryAccountMissions=InventoryAccountMission::with(['commodity.barcodes','stockInventoryPersons'])->where('inventory_account_id',$id)->orderBy('difference_amount','desc')->get();
-        return view('inventory.stockInventory.inventoryMission',compact('inventoryAccount','inventoryAccountMissions'));
+    public function enterStockInventory($id, Request $request)
+    {
+        if (!Gate::allows('库存管理-盘点')) {
+            return redirect(url('/'));
+        }
+        if (!$id) return ['success' => false, 'data' => '参数错误!'];
+        $inventoryAccount = InventoryAccount::with('owner')->find($id);
+        $inventoryAccountMissions = InventoryAccountMission::with(['commodity.barcodes', 'stockInventoryPersons'])->where('inventory_account_id', $id)->orderBy('difference_amount', 'desc')->get();
+        return view('inventory.stockInventory.inventoryMission', compact('inventoryAccount', 'inventoryAccountMissions'));
     }
-    public function enterBlindReceive($id){
-        if (!Gate::allows('库存管理-盘点')){return redirect(url('/')); }
-        if (!$id) return ['success'=>false,'data'=>'参数错误!'];
-        $inventoryAccount=InventoryAccount::with('owner')->find($id);
-        return view('inventory.stockInventory.blindReceive',compact('inventoryAccount'));
+
+    public function enterBlindReceive($id)
+    {
+        if (!Gate::allows('库存管理-盘点')) {
+            return redirect(url('/'));
+        }
+        if (!$id) return ['success' => false, 'data' => '参数错误!'];
+        $inventoryAccount = InventoryAccount::with('owner')->find($id);
+        return view('inventory.stockInventory.blindReceive', compact('inventoryAccount'));
     }
+
     //依据盘点任务id进行 --盘点
-    public function stockInventory(Request $request){
-        if (!Gate::allows('库存管理-盘点')){return redirect(url('/')); }
-        $location=$request->input('location');
-        $barcode=$request->input('barcode');
-        $inventoryId=$request->input('inventoryId');
-        $count=$request->input('count');
-        $id=$request->input('id');
-        if (is_null($count)) return ['success'=>false,'data'=>'盘点数不能为空!'];
-        /** @var InventoryAccountService $inventoryAccountMission */
-        $inventoryAccountService=app('inventoryAccountService');
-        $inventoryAccountMission=$inventoryAccountService->stockInventory($id,$location,$barcode,$count,$inventoryId);
-        if (!$inventoryAccountMission)return ['success'=>false,'data'=>'参数错误!'];
+    public function stockInventory(Request $request)
+    {
+        if (!Gate::allows('库存管理-盘点')) {
+            return redirect(url('/'));
+        }
+        $location = $request->input('location');
+        $barcode = $request->input('barcode');
+        $inventoryId = $request->input('inventoryId');
+        $count = $request->input('count');
+        $id = $request->input('id');
+        if (is_null($count)) return ['success' => false, 'data' => '盘点数不能为空!'];
+        /** @var InventoryAccountService $inventoryAccountService */
+        $inventoryAccountService = app('inventoryAccountService');
+        $inventoryAccountMission = $inventoryAccountService->stockInventory($id, $location, $barcode, $count, $inventoryId);
+        if (!$inventoryAccountMission) return ['success' => false, 'data' => '参数错误!'];
         /** @var InventoryAccountService $inventoryService */
-        $inventoryService=app('inventoryAccountService');
-        $inventoryAccount=$inventoryService->updateInventory($inventoryId);
-        $stockInventoryPersons=$inventoryAccountMission->stockInventoryPersons;
-        return ['success'=>true,'inventoryMission'=>$inventoryAccountMission,'inventory'=>$inventoryAccount,'stockInventoryPersons'=>$stockInventoryPersons];
+        $inventoryService = app('inventoryAccountService');
+        $inventoryAccount = $inventoryService->updateInventory($inventoryId);
+        $stockInventoryPersons = $inventoryAccountMission->stockInventoryPersons;
+        return ['success' => true, 'inventoryMission' => $inventoryAccountMission, 'inventory' => $inventoryAccount, 'stockInventoryPersons' => $stockInventoryPersons];
     }
-    public function baseOnBlindReceive(Request $request){
-        if (!Gate::allows('库存管理-盘点')){return redirect(url('/')); }
-        $location=$request->input('location');
-        $inventoryId=$request->input('inventoryId');
-        $owner_code=$request->input('owner_code');
-        $goodses=$request->input('goodses');
-        if (!$location) return ['success'=>false,'fail_info'=>'盘点库位不存在!'];
-        if (count($goodses)<1) return ['success'=>false,'fail_info'=>'盘点商品不存在!'];
+
+    public function baseOnBlindReceive(Request $request)
+    {
+        if (!Gate::allows('库存管理-盘点')) {
+            return redirect(url('/'));
+        }
+        $location = $request->input('location');
+        $inventoryId = $request->input('inventoryId');
+        $owner_code = $request->input('owner_code');
+        $goodses = $request->input('goodses');
+        if (!$location) return ['success' => false, 'fail_info' => '盘点库位不存在!'];
+        if (count($goodses) < 1) return ['success' => false, 'fail_info' => '盘点商品不存在!'];
         //dd($location,$owner_code,$goodses,$inventoryId,$owner_id);
         /** @var InventoryAccountService $inventoryAccountMission */
-        $inventoryAccountService=app('inventoryAccountService');
-        $inventoryAccountMissions=$inventoryAccountService->baseOnBlindReceive($location,$owner_code,$goodses,$inventoryId);
-        if (count($inventoryAccountMissions)<0)return ['success'=>false,'fail_info'=>'盲收盘点失败!'];
+        $inventoryAccountService = app('inventoryAccountService');
+        $inventoryAccountMissions = $inventoryAccountService->baseOnBlindReceive($location, $owner_code, $goodses, $inventoryId);
+        if (count($inventoryAccountMissions) < 0) return ['success' => false, 'fail_info' => '盲收盘点失败!'];
         /** @var InventoryAccountService $inventoryService */
-        $inventoryService=app('inventoryAccountService');
-        $inventoryAccount=$inventoryService->updateInventory($inventoryId);
-        if ($inventoryAccountMissions&&$inventoryAccount)
-        $stockInventoryPersons=$inventoryAccountMissions[0]->stockInventoryPersons;
-        return ['success'=>true,'inventoryMissions'=>$inventoryAccountMissions,'inventory'=>$inventoryAccount,'stockInventoryPersons'=>$stockInventoryPersons];
+        $inventoryService = app('inventoryAccountService');
+        $inventoryAccount = $inventoryService->updateInventory($inventoryId);
+        if ($inventoryAccountMissions && $inventoryAccount)
+            $stockInventoryPersons = $inventoryAccountMissions[0]->stockInventoryPersons;
+        return ['success' => true, 'inventoryMissions' => $inventoryAccountMissions, 'inventory' => $inventoryAccount, 'stockInventoryPersons' => $stockInventoryPersons];
     }
+
     //根据该库存和产品条码查询该条盘点记录??
-    public function searchStockInventoryRecord(Request $request){
-        if (!Gate::allows('库存管理-盘点')){return redirect(url('/')); }
-        $location=$request->input('location');
-        $barcode=$request->input('barcode');
-        $inventoryId=$request->input('inventoryId');
+    public function searchStockInventoryRecord(Request $request)
+    {
+        if (!Gate::allows('库存管理-盘点')) {
+            return redirect(url('/'));
+        }
+        $location = $request->input('location');
+        $barcode = $request->input('barcode');
+        $inventoryId = $request->input('inventoryId');
         /** @var InventoryAccountService $application */
         $application = app('inventoryAccountService');
-        $inventoryAccountMissions= $application->searchStockInventoryRecord($location,$barcode,$inventoryId);
-        if ($inventoryAccountMissions->isEmpty())return ['success'=>false,'data'=>'没有找到相应记录!'];
+        $inventoryAccountMissions = $application->searchStockInventoryRecord($location, $barcode, $inventoryId);
+        if ($inventoryAccountMissions->isEmpty()) return ['success' => false, 'data' => '没有找到相应记录!'];
 //        $stockInventoryPersons=$inventoryAccountMissions->stockInventoryPersons;
 //        return ['success'=>true,'data'=>$inventoryAccountMissions,'stockInventoryPersons'=>$stockInventoryPersons];
-        return ['success'=>true,'data'=>$inventoryAccountMissions];
+        return ['success' => true, 'data' => $inventoryAccountMissions];
     }
 
     //盘点任务导出
-    public function stockInventoryExport(Request $request){
-        if (!Gate::allows('库存管理-盘点')){return redirect(url('/')); }
-        ini_set('max_execution_time',3500);
-        ini_set('memory_limit','3526M');
-        if ($request->checkAllSign){
+    public function stockInventoryExport(Request $request)
+    {
+        if (!Gate::allows('库存管理-盘点')) {
+            return redirect(url('/'));
+        }
+        ini_set('max_execution_time', 3500);
+        ini_set('memory_limit', '3526M');
+        if ($request->checkAllSign) {
             $request->offsetUnset('checkAllSign');
-            $queryParam=$request->all();
-            $inventoryAccounts=app('inventoryAccountService')->get($queryParam);
-        }else{
-            $queryParam=$request->all();
-            $inventoryAccounts=app('inventoryAccountService')->some($queryParam);
-        }
-        $row=[[
-            'id'=>'盘点编号',
-            'status'=>'盘点状态',
-            'created_at'=>'创建时间',
-            'owner_id'=>'货主',
-            'type'=>'任务类型',
-            'start_at'=>'起始时间',
-            'end_at'=>'结束时间',
-            'total'=>'记录数',
-            'processed'=>'已盘数',
-            'surplus'=>'剩余数',
-            'difference'=>'复盘差异',
-            'returned'=>'复盘归位',
+            $queryParam = $request->all();
+            $inventoryAccounts = app('inventoryAccountService')->get($queryParam);
+        } else {
+            $queryParam = $request->all();
+            $inventoryAccounts = app('inventoryAccountService')->some($queryParam);
+        }
+        $row = [[
+            'id' => '盘点编号',
+            'status' => '盘点状态',
+            'created_at' => '创建时间',
+            'owner_id' => '货主',
+            'type' => '任务类型',
+            'start_at' => '起始时间',
+            'end_at' => '结束时间',
+            'total' => '记录数',
+            'processed' => '已盘数',
+            'surplus' => '剩余数',
+            'difference' => '复盘差异',
+            'returned' => '复盘归位',
         ]];
-        $list=[];
-        for ($i=0; $i<count($inventoryAccounts);$i++){
-            $inventoryAccount=$inventoryAccounts[$i];
-            $w=[
-                'id'=>isset($inventoryAccount->id)?$inventoryAccount->id:'',
-                'status'=>isset($inventoryAccount->status)?$inventoryAccount->status:'',
-                'created_at'=>isset($inventoryAccount->created_at)?$inventoryAccount->created_at:'',
-                'owner_id'=>isset($inventoryAccount->owner->name)?$inventoryAccount->owner->name:'',
-                'type'=>isset($inventoryAccount->type)?$inventoryAccount->type:'',
-                'start_at'=>isset($inventoryAccount->start_at)?$inventoryAccount->start_at:'',
-                'end_at'=>isset($inventoryAccount->end_at)?$inventoryAccount->end_at:'',
-                'total'=>isset($inventoryAccount->total)?$inventoryAccount->total:'',
-                'processed'=>isset($inventoryAccount->processed)?$inventoryAccount->processed:'',
-                'surplus'=>isset($inventoryAccount->surplus)?$inventoryAccount->surplus:'',
-                'difference'=>isset($inventoryAccount->difference)?$inventoryAccount->difference:'',
-                'returned'=>isset($inventoryAccount->returned)?$inventoryAccount->returned:'',
+        $list = [];
+        for ($i = 0; $i < count($inventoryAccounts); $i++) {
+            $inventoryAccount = $inventoryAccounts[$i];
+            $w = [
+                'id' => isset($inventoryAccount->id) ? $inventoryAccount->id : '',
+                'status' => isset($inventoryAccount->status) ? $inventoryAccount->status : '',
+                'created_at' => isset($inventoryAccount->created_at) ? $inventoryAccount->created_at : '',
+                'owner_id' => isset($inventoryAccount->owner->name) ? $inventoryAccount->owner->name : '',
+                'type' => isset($inventoryAccount->type) ? $inventoryAccount->type : '',
+                'start_at' => isset($inventoryAccount->start_at) ? $inventoryAccount->start_at : '',
+                'end_at' => isset($inventoryAccount->end_at) ? $inventoryAccount->end_at : '',
+                'total' => isset($inventoryAccount->total) ? $inventoryAccount->total : '',
+                'processed' => isset($inventoryAccount->processed) ? $inventoryAccount->processed : '',
+                'surplus' => isset($inventoryAccount->surplus) ? $inventoryAccount->surplus : '',
+                'difference' => isset($inventoryAccount->difference) ? $inventoryAccount->difference : '',
+                'returned' => isset($inventoryAccount->returned) ? $inventoryAccount->returned : '',
             ];
-            $list[$i]=$w;
+            $list[$i] = $w;
         }
-        return Excel::download(new Export($row,$list),date('YmdHis', time()).'-盘点任务记录单.xlsx');
+        return Excel::download(new Export($row, $list), date('YmdHis', time()) . '-盘点任务记录单.xlsx');
     }
-    public function stockInventoryEnd(Request $request){
-        if (!Gate::allows('库存管理-盘点-结束初盘')){return ['success'=>false,'data'=>'没有权限']; }
-        $id=$request->input('id');
-        if (!$id) return ['success'=>false,'data'=>'参数错误!'];
-        $inventoryAccount=InventoryAccount::query()->where('id',$id)->update(['status'=>'复盘中']);
-        app('LogService')->log(__METHOD__,'结束初盘任务'.__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
-        if ($inventoryAccount>0) return ['success'=>true,'data'=>'复盘中'];
-        return ['success'=>false,'data'=>'参数错误!'];
+
+    public function stockInventoryEnd(Request $request)
+    {
+        if (!Gate::allows('库存管理-盘点-结束初盘')) {
+            return ['success' => false, 'data' => '没有权限'];
+        }
+        $id = $request->input('id');
+        if (!$id) return ['success' => false, 'data' => '参数错误!'];
+        $inventoryAccount = InventoryAccount::query()->where('id', $id)->update(['status' => '复盘中']);
+        app('LogService')->log(__METHOD__, '结束初盘任务' . __FUNCTION__, json_encode($request->toArray()), Auth::user()['id']);
+        if ($inventoryAccount > 0) return ['success' => true, 'data' => '复盘中'];
+        return ['success' => false, 'data' => '参数错误!'];
     }
-    public function syncOwners(OwnerService $ownerService){
-        if (!Gate::allows('库存管理-盘点')){return redirect(url('/')); }
-        $owners=$ownerService->syncOwnersData();
-        if (!$owners)return ['success'=>false,'data'=>'同步货主失败!'];
-        return ['success'=>true,'data'=>$owners];
+
+    public function syncOwners(OwnerService $ownerService)
+    {
+        if (!Gate::allows('库存管理-盘点')) {
+            return redirect(url('/'));
+        }
+        $owners = $ownerService->syncOwnersData();
+        if (!$owners) return ['success' => false, 'data' => '同步货主失败!'];
+        return ['success' => true, 'data' => $owners];
     }
-    public function 修改质量状态(Request $request){
-        if (!Gate::allows('库存管理-盘点')){return redirect(url('/')); }
-        $id=$request->input('id');
-        $location=$request->location;
-        $sku=$request->sku;
-        $quality=$request->quality;
-        $ownerCode=$request->ownerCode;
-        $inventoryAccountMission=app('inventoryAccountService')->修改质量状态($id,$location,$sku,$quality,$ownerCode);
-        app('LogService')->log(__METHOD__,__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
-        if ($inventoryAccountMission==null) return ['success'=>false,'data'=>'WMS中不存在该条记录!'];
-        return ['success'=>true,'data'=>'质量状态修改成功'];
+
+    public function 修改质量状态(Request $request)
+    {
+        if (!Gate::allows('库存管理-盘点')) {
+            return redirect(url('/'));
+        }
+        $id = $request->input('id');
+        $location = $request->location;
+        $sku = $request->sku;
+        $quality = $request->quality;
+        $ownerCode = $request->ownerCode;
+        $inventoryAccountMission = app('inventoryAccountService')->修改质量状态($id, $location, $sku, $quality, $ownerCode);
+        app('LogService')->log(__METHOD__, __FUNCTION__, json_encode($request->toArray()), Auth::user()['id']);
+        if ($inventoryAccountMission == null) return ['success' => false, 'data' => 'WMS中不存在该条记录!'];
+        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 完结盘点任务($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');
-        $owner_code=$request->input('owner_code');
-        $param=$request->input('param');
-        if (is_null($count)) return ['success'=>false,'data'=>'盘点数不能为空!'];
-        $inventoryAccountMission=app('inventoryAccountService')->增加系统之外的盘点记录($location,$barcode,$inventoryId,$count,$owner_code,$param);
-        if (!$inventoryAccountMission)return ['success'=>false,'data'=>'添加系统之外的库位记录失败!'];
-        $inventoryAccountMission=InventoryAccountMission::with(['commodity.barcodes','stockInventoryPersons'])->where('id',$inventoryAccountMission->id)->first();
-        $stockInventoryPersons=$inventoryAccountMission->stockInventoryPersons;
-        return ['success'=>true,'inventoryAccountMission'=>$inventoryAccountMission,'stockInventoryPersons'=>$stockInventoryPersons];
+
+    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');
+        $owner_code = $request->input('owner_code');
+        $param = $request->input('param');
+        if (is_null($count)) return ['success' => false, 'data' => '盘点数不能为空!'];
+        $inventoryAccountMission = app('inventoryAccountService')->增加系统之外的盘点记录($location, $barcode, $inventoryId, $count, $owner_code, $param);
+        if (!$inventoryAccountMission) return ['success' => false, 'data' => '添加系统之外的库位记录失败!'];
+        $inventoryAccountMission = InventoryAccountMission::with(['commodity.barcodes', 'stockInventoryPersons'])->where('id', $inventoryAccountMission->id)->first();
+        $stockInventoryPersons = $inventoryAccountMission->stockInventoryPersons;
+        return ['success' => true, 'inventoryAccountMission' => $inventoryAccountMission, 'stockInventoryPersons' => $stockInventoryPersons];
     }
-    public function 盘点选中任务(Request $request){
-        if(!Gate::allows('库存管理-盘点')){return['success'=>false,'data'=>'没有权限'];}
-        $id=$request->input('id');
-        $count=$request->count;
-        $inventoryId=$request->input('inventoryId');
-        $produced_at=$request->input('produced_at');
-        $valid_at=$request->input('valid_at');
-        $batch_number=$request->input('batch_number');
-        if (is_null($count)) return ['success'=>false,'data'=>'盘点数不能为空!'];
-        if ($produced_at||$valid_at||$batch_number){
+
+    public function 盘点选中任务(Request $request)
+    {
+        if (!Gate::allows('库存管理-盘点')) {
+            return ['success' => false, 'data' => '没有权限'];
+        }
+        $id = $request->input('id');
+        $count = $request->count;
+        $inventoryId = $request->input('inventoryId');
+        $produced_at = $request->input('produced_at');
+        $valid_at = $request->input('valid_at');
+        $batch_number = $request->input('batch_number');
+        if (is_null($count)) return ['success' => false, 'data' => '盘点数不能为空!'];
+        if ($produced_at || $valid_at || $batch_number) {
             /** @var InventoryAccountService $inventoryAccountMission */
-            $inventoryAccountService=app('inventoryAccountService');
-            $inventoryAccountMission=$inventoryAccountService ->盘点生产日期_失效日期_批号有改动任务($id,$count,$inventoryId,$produced_at,$valid_at,$batch_number);
-            if (!$inventoryAccountMission)return ['success'=>false,'data'=>'盘点生产日期_失效日期_批号有改动任务失败!'];
+            $inventoryAccountService = app('inventoryAccountService');
+            $inventoryAccountMission = $inventoryAccountService->盘点生产日期_失效日期_批号有改动任务($id, $count, $inventoryId, $produced_at, $valid_at, $batch_number);
+            if (!$inventoryAccountMission) return ['success' => false, 'data' => '盘点生产日期_失效日期_批号有改动任务失败!'];
             /** @var InventoryAccountService $inventoryService */
-            $inventoryService=app('inventoryAccountService');
-            $inventoryAccount=$inventoryService->updateInventory($inventoryId);
-            $stockInventoryPersons=$inventoryAccountMission[0]->stockInventoryPersons;
-            return ['success'=>true,'inventoryMission'=>$inventoryAccountMission,'inventory'=>$inventoryAccount,'stockInventoryPersons'=>$stockInventoryPersons];
-        }else{
+            $inventoryService = app('inventoryAccountService');
+            $inventoryAccount = $inventoryService->updateInventory($inventoryId);
+            $stockInventoryPersons = $inventoryAccountMission[0]->stockInventoryPersons;
+            return ['success' => true, 'inventoryMission' => $inventoryAccountMission, 'inventory' => $inventoryAccount, 'stockInventoryPersons' => $stockInventoryPersons];
+        } else {
             /** @var InventoryAccountService $inventoryAccountMission */
-            $inventoryAccountService=app('inventoryAccountService');
-            $inventoryAccountMission=$inventoryAccountService ->盘点选中任务($id,$count,$inventoryId);
-            if (!$inventoryAccountMission)return ['success'=>false,'data'=>'盘点选中任务失败!'];
+            $inventoryAccountService = app('inventoryAccountService');
+            $inventoryAccountMission = $inventoryAccountService->盘点选中任务($id, $count, $inventoryId);
+            if (!$inventoryAccountMission) return ['success' => false, 'data' => '盘点选中任务失败!'];
             /** @var InventoryAccountService $inventoryService */
-            $inventoryService=app('inventoryAccountService');
-            $inventoryAccount=$inventoryService->updateInventory($inventoryId);
-            $stockInventoryPersons=$inventoryAccountMission->stockInventoryPersons;
-            return ['success'=>true,'inventoryMission'=>$inventoryAccountMission,'inventory'=>$inventoryAccount,'stockInventoryPersons'=>$stockInventoryPersons];
+            $inventoryService = app('inventoryAccountService');
+            $inventoryAccount = $inventoryService->updateInventory($inventoryId);
+            $stockInventoryPersons = $inventoryAccountMission->stockInventoryPersons;
+            return ['success' => true, 'inventoryMission' => $inventoryAccountMission, 'inventory' => $inventoryAccount, 'stockInventoryPersons' => $stockInventoryPersons];
         }
     }
 
-    public function 删除盘点记录(Request $request){
-        if(!Gate::allows('库存管理-盘点-删除')){return['success'=>false,'data'=>'没有权限'];}
-        $inventoryAccountMissionId=$request->input('inventoryAccountMissionId');
-        $inventoryAccountId=$request->input('inventoryAccountId');
-        if(is_null($inventoryAccountMissionId)){return ['success'=>false,'data'=>'传入id为空'];}
+    public function 删除盘点记录(Request $request)
+    {
+        if (!Gate::allows('库存管理-盘点-删除')) {
+            return ['success' => false, 'data' => '没有权限'];
+        }
+        $inventoryAccountMissionId = $request->input('inventoryAccountMissionId');
+        $inventoryAccountId = $request->input('inventoryAccountId');
+        if (is_null($inventoryAccountMissionId)) {
+            return ['success' => false, 'data' => '传入id为空'];
+        }
         /** @var InventoryAccountService $inventoryService */
-        $inventoryService=app('inventoryAccountService');
-        $inventoryAccountMission=$inventoryService->删除盘点记录($inventoryAccountMissionId,$inventoryAccountId);
-        return ['success'=>true,'data'=>$inventoryAccountMission];
+        $inventoryService = app('inventoryAccountService');
+        $inventoryAccountMission = $inventoryService->删除盘点记录($inventoryAccountMissionId, $inventoryAccountId);
+        return ['success' => true, 'data' => $inventoryAccountMission];
     }
-    public function 跳过盘点记录(Request $request){
-        if(!Gate::allows('库存管理-盘点')){return['success'=>false,'data'=>'没有权限'];}
-        $inventoryAccountMissionId=$request->inventoryAccountMissionId;
-        $inventoryAccountId=$request->input('inventoryAccountId');
-        if(is_null($inventoryAccountMissionId)){return ['success'=>false,'data'=>'传入id为空'];}
+
+    public function 跳过盘点记录(Request $request)
+    {
+        if (!Gate::allows('库存管理-盘点')) {
+            return ['success' => false, 'data' => '没有权限'];
+        }
+        $inventoryAccountMissionId = $request->inventoryAccountMissionId;
+        $inventoryAccountId = $request->input('inventoryAccountId');
+        if (is_null($inventoryAccountMissionId)) {
+            return ['success' => false, 'data' => '传入id为空'];
+        }
         /** @var InventoryAccountService $inventoryService */
-        $inventoryService=app('inventoryAccountService');
-        $inventoryAccountMission=$inventoryService->跳过盘点记录($inventoryAccountMissionId,$inventoryAccountId);
-        return ['success'=>true,'inventoryAccountMission'=>$inventoryAccountMission];
+        $inventoryService = app('inventoryAccountService');
+        $inventoryAccountMission = $inventoryService->跳过盘点记录($inventoryAccountMissionId, $inventoryAccountId);
+        return ['success' => true, 'inventoryAccountMission' => $inventoryAccountMission];
     }
-    public function 确认盘点差异(Request $request){
-        if(!Gate::allows('库存管理-盘点')){return['success'=>false,'data'=>'没有权限'];}
-        $inventoryAccountMissionId=$request->inventoryAccountMissionId;
-        $inventoryAccountId=$request->input('inventoryAccountId');
-        if(is_null($inventoryAccountMissionId)){return ['success'=>false,'data'=>'传入id为空'];}
+
+    public function 确认盘点差异(Request $request)
+    {
+        if (!Gate::allows('库存管理-盘点')) {
+            return ['success' => false, 'data' => '没有权限'];
+        }
+        $inventoryAccountMissionId = $request->inventoryAccountMissionId;
+        $inventoryAccountId = $request->input('inventoryAccountId');
+        if (is_null($inventoryAccountMissionId)) {
+            return ['success' => false, 'data' => '传入id为空'];
+        }
         /** @var InventoryAccountService $inventoryService */
-        $inventoryService=app('inventoryAccountService');
-        $inventoryAccountMission=$inventoryService->确认盘点差异($inventoryAccountMissionId,$inventoryAccountId);
-        return ['success'=>true,'inventoryAccountMission'=>$inventoryAccountMission];
+        $inventoryService = app('inventoryAccountService');
+        $inventoryAccountMission = $inventoryService->确认盘点差异($inventoryAccountMissionId, $inventoryAccountId);
+        return ['success' => true, 'inventoryAccountMission' => $inventoryAccountMission];
     }
-    public function 批量跳过或确认差异(Request $request){
-        if(!Gate::allows('库存管理-盘点')){return['success'=>false,'data'=>'没有权限'];}
-        $checkData=$request->checkData;
-        if(is_null($checkData)){return ['success'=>false,'data'=>'传入勾选盘点记录为空'];}
-        $marks=[];
-        foreach ($checkData as $inventoryMission){
-            array_push($marks,$inventoryMission['mark']);
-        }
-        if (in_array('确认差异',$marks)||in_array('跳过',$marks)||in_array('无差异',$marks)||in_array('已复盘无差异',$marks))return ['success'=>false,'data'=>'传入勾选盘点记录存在不可操作项!'];
+
+    public function 批量跳过或确认差异(Request $request)
+    {
+        if (!Gate::allows('库存管理-盘点')) {
+            return ['success' => false, 'data' => '没有权限'];
+        }
+        $checkData = $request->checkData;
+        if (is_null($checkData)) {
+            return ['success' => false, 'data' => '传入勾选盘点记录为空'];
+        }
+        $marks = [];
+        foreach ($checkData as $inventoryMission) {
+            array_push($marks, $inventoryMission['mark']);
+        }
+        if (in_array('确认差异', $marks) || in_array('跳过', $marks) || in_array('无差异', $marks) || in_array('已复盘无差异', $marks)) return ['success' => false, 'data' => '传入勾选盘点记录存在不可操作项!'];
         /** @var InventoryAccountService $inventoryService */
-        $inventoryService=app('inventoryAccountService');
-        $inventoryAccountMissions=$inventoryService->批量跳过或确认差异($checkData);
-        return ['success'=>true,'inventoryAccountMissions'=>$inventoryAccountMissions];
+        $inventoryService = app('inventoryAccountService');
+        $inventoryAccountMissions = $inventoryService->批量跳过或确认差异($checkData);
+        return ['success' => true, 'inventoryAccountMissions' => $inventoryAccountMissions];
     }
-    public function exportInventoryAccountMission(Request $request){
-        if(!Gate::allows("库存管理-盘点")){ return redirect(url('/'));  }
-        $post = Http::post(config('go.export.url'),['type'=>'inventoryAccountMission','data'=>$request->data]);
-        if ($post->status() == 500){
+
+    public function exportInventoryAccountMission(Request $request)
+    {
+        if (!Gate::allows("库存管理-盘点")) {
+            return redirect(url('/'));
+        }
+        $post = Http::post(config('go.export.url'), ['type' => 'inventoryAccountMission', 'data' => $request->data]);
+        if ($post->status() == 500) {
             throw new Exception($post->header("Msg"));
         }
-        return response($post,200, [
-            "Content-type"=>"application/octet-stream",
-            "Content-Disposition"=>"attachment; filename=库存盘点记录-".date('ymdHis').'.xlsx',
+        return response($post, 200, [
+            "Content-type" => "application/octet-stream",
+            "Content-Disposition" => "attachment; filename=库存盘点记录-" . date('ymdHis') . '.xlsx',
         ]);
     }
-    public function searchCommodityByBarcode(Request $request){
-        if(!Gate::allows('库存管理-盘点')){return['success'=>false,'data'=>'没有权限'];}
-        $barcode=$request->input('barcode');
-        $owner_code=$request->input('owner_code');
+
+    public function searchCommodityByBarcode(Request $request)
+    {
+        if (!Gate::allows('库存管理-盘点')) {
+            return ['success' => false, 'data' => '没有权限'];
+        }
+        $barcode = $request->input('barcode');
+        $owner_code = $request->input('owner_code');
         /** @var InventoryAccountService $inventoryService */
-        $inventoryService=app('inventoryAccountService');
-        $commodity=$inventoryService->searchCommodityByBarcode($barcode,$owner_code);
-        if ($commodity){
-            return ['success'=>true,'data'=>$commodity];
-        }else{
-            return ['success'=>false,'data'=>'输入的条码没有对应商品!'];
+        $inventoryService = app('inventoryAccountService');
+        $commodity = $inventoryService->searchCommodityByBarcode($barcode, $owner_code);
+        if ($commodity) {
+            return ['success' => true, 'data' => $commodity];
+        } else {
+            return ['success' => false, 'data' => '输入的条码没有对应商品!'];
         }
     }
+    //根据库位批量盘点该库位下盘点记录
+    public function batchStockByLocation(Request $request)
+    {
+        if (!Gate::allows('库存管理-盘点')) return ['success' => false, 'msg' => '没有权限'];
+        $missions=$request->mission;
+        $inventoryId=$request->inventoryId;
+        if (!$inventoryId||count($missions)<1) return ['success' => false, 'msg' => '参数错误'];
+        /** @var InventoryAccountService $inventoryService */
+        $inventoryService = app('inventoryAccountService');
+        $inventoryMissions=$inventoryService->batchStockByLocation($missions,$inventoryId);
+        $inventoryService = app('inventoryAccountService');
+        $inventoryAccount = $inventoryService->updateInventory($inventoryId);
+        $stockInventoryPersons = $inventoryMissions[0]->stockInventoryPersons;
+        return ['success' => true, 'inventoryMission' => $inventoryMissions, 'inventory' => $inventoryAccount, 'stockInventoryPersons' => $stockInventoryPersons];
+    }
 }

+ 47 - 0
app/Services/InventoryAccountService.php

@@ -14,6 +14,7 @@ use App\OracleInvLotAtt;
 use App\OracleBasCustomer;
 use App\OracleInvLotLocId;
 use App\Owner;
+use App\Services\common\BatchUpdateService;
 use App\Services\common\QueryService;
 use Carbon\Carbon;
 use Illuminate\Support\Facades\Auth;
@@ -635,4 +636,50 @@ class InventoryAccountService
         return $inventoryAccountMissions;
     }
 
+    public function batchStockByLocation($missions,$inventoryId)
+    {
+        $inventory=InventoryAccount::query()->find($inventoryId);
+        if($inventory->status=='复盘中'){
+            $updateParams = [[
+                'id','returned','difference_amount','re_checked_amount','checked','updated_at'
+            ]];
+            foreach ($missions as $mission){
+                if (($mission['amount']-$mission['stored_amount'])==0){
+                    $return='是';
+                }else{
+                    $return='否';
+                }
+                $updateParams[] = [
+                    'id'=>$mission['id'],
+                    're_checked_amount'=>$mission['amount'],
+                    'difference_amount'=>$mission['amount']-$mission['stored_amount'],
+                    'returned'=>$return,
+                    'checked'=>'已复核',
+                    'updated_at' =>Carbon::now()->format('Y-m-d H:i:s'),
+                ];
+            }
+        }else{//初盘
+            $updateParams = [[
+                'id','difference_amount','checked','verified_amount','updated_at'
+            ]];
+            foreach ($missions as $mission){
+                $updateParams[] = [
+                    'id'=>$mission['id'],
+                    'verified_amount'=>$mission['amount'],
+                    'difference_amount'=>$mission['amount']-$mission['stored_amount'],
+                    'checked'=>'是',
+                    'updated_at' =>Carbon::now()->format('Y-m-d H:i:s'),
+                ];
+            }
+        }
+        if(count($updateParams) > 1) app(BatchUpdateService::class)->batchUpdate('inventory_account_missions',$updateParams);
+        LogService::log(__METHOD__,__FUNCTION__,'根据库位批量盘点'.count($updateParams).json_encode($updateParams));
+        $ids = array_unique(data_get($missions,'*.id'));
+        $inventoryMissions=InventoryAccountMission::query()->whereIn('id',$ids)->get();
+        foreach ($inventoryMissions as $inventoryMission){
+            $inventoryMission->createSignStockInventoryPersons();
+        }
+        return InventoryAccountMission::query()->with(['commodity.barcodes','stockInventoryPersons'])->whereIn('id',$ids)->get();
+    }
+
 }

+ 4 - 4
public/js/app.js

@@ -2330,7 +2330,7 @@ function fromByteArray (uint8) {
 var BlobBuilder = typeof BlobBuilder !== 'undefined' ? BlobBuilder :
   typeof WebKitBlobBuilder !== 'undefined' ? WebKitBlobBuilder :
   typeof MSBlobBuilder !== 'undefined' ? MSBlobBuilder :
-  typeof MozBlobBuilder !== 'undefined' ? MozBlobBuilder :
+  typeof MozBlobBuilder !== 'undefined' ? MozBlobBuilder : 
   false;
 
 /**
@@ -86472,8 +86472,8 @@ module.exports = tempTip;
 /*! no static exports found */
 /***/ (function(module, exports, __webpack_require__) {
 
-__webpack_require__(/*! D:\Demo\bswas\resources\js\app.js */"./resources/js/app.js");
-module.exports = __webpack_require__(/*! D:\Demo\bswas\resources\sass\app.scss */"./resources/sass/app.scss");
+__webpack_require__(/*! D:\wamp64\www\bswas\resources\js\app.js */"./resources/js/app.js");
+module.exports = __webpack_require__(/*! D:\wamp64\www\bswas\resources\sass\app.scss */"./resources/sass/app.scss");
 
 
 /***/ }),
@@ -86489,4 +86489,4 @@ module.exports = __webpack_require__(/*! D:\Demo\bswas\resources\sass\app.scss *
 
 /***/ })
 
-/******/ });
+/******/ });

+ 154 - 147
resources/views/inventory/stockInventory/inventoryMission.blade.php

@@ -45,6 +45,10 @@
                     批量跳过
                 </button>
             </span>
+            <span>
+                <button class="btn btn-sm btn-info" @click="新增盘点记录()" :class="listMode?'btn-dark':'btn-outline-dark'" v-if="!listMode&&!addInventoryMission">新增盘点记录</button>
+                 <button class="btn btn-sm" @click="收起新增()" :class="addInventoryMission?'btn-dark':'btn-outline-dark'" v-if="addInventoryMission">收起新增</button>
+            </span>
 
 
             <span class="form-group  mb-5">
@@ -208,7 +212,7 @@
                    @change="locationChange($event)"
                    name="location" type="text" class="form-control  input"  autocomplete="off" value="@if(old('location')){{old('location')}}@endif">
         </span>
-                    <span class="form-group ml-4">
+                    <span class="form-group ml-4" v-if="addInventoryMission">
             <label for="barcode" class="text-secondary font-weight-bold">请输产品条码</label>
                 <input id="barcodeInput" name="barcode"  @keypress="barcodePress($event)"
                        @change="barcodeChange($event)"
@@ -216,18 +220,19 @@
 
         </span>
 
-                    <span class="form-group ml-4" v-if="dataExtraStatus.addingNew" id="countBlock">
+                    <span class="form-group ml-4" v-if="dataExtraStatus.addingNew&&addInventoryMission" id="countBlock">
                         <label for="count" class="text-secondary font-weight-bold">请输盘点数</label>
                         <input type="text" id="amountInput"  @keypress="amountPress($event)"
                                name="count" class="form-control input" value="@if(old('count')){{old('count')}}@endif"  autocomplete="off">
                     </span>
+                    <span type="button" class="btn btn-sm btn-outline-danger col-md-2 form-group ml-4" v-if="location" style="max-width: 160px" @click="stockInventoryByLocation()">盘点该库位下所有记录</span>
                 </div>
             </div>
             <!--相同库位和条码 pc端-->
 
             <div class="row d-none d-xl-block">
                 <div class="col-12 col-md-12 col-sm-12 showBlueTable d-none">
-                    <table class="table table-sm table-bordered table-info mt-2" {{--v-if="!listMode"--}} :class="!listMode?'':'d-none'" id="blueTablePc">
+                    <table class="table table-sm table-bordered table-info mt-2" :class="!listMode?'':'d-none'" id="blueTablePc">
                         <tr>
                             <td class="font-weight-bold">输入盘点数</td>
                             <td>操作</td>
@@ -260,7 +265,7 @@
                             <td><input type="text" class="form-control-sm batch_number" name="batch_number" onchange="batchNumberChange(event)"></td>
                             <td class="erp_type_position"></td>
                             <td class="quality"></td>
-                            <td class="verified_amount"></td>
+                            <td class="verified_amount font-weight-bold text-success"></td>
                             <td class="re_checked_amount"></td>
                             <td class="difference_amount"></td>
                         </tr>
@@ -293,7 +298,7 @@
                                     <span class="mr-3 text-nowrap"><span>属性仓:</span><span class="erp_type_position"></span></span>
                                     <span class="mr-3 text-nowrap"><span>质量状态:</span><span class="quality"></span></span>
                                     <div>
-                                        <span class="mr-3 text-nowrap"><span style="color:#783000">盘点数量:</span><span style="color:#af7651" class="verified_amount"></span></span>
+                                        <span class="mr-3 text-nowrap"><span style="color:#783000">盘点数量:</span><span  class="verified_amount font-weight-bold text-success"></span></span>
                                         <span class="mr-3 text-nowrap"><span style="color:#783000">复盘数量:</span><span style="color:#af7651" class="re_checked_amount"></span></span>
                                         <span class="mr-3 text-nowrap"><span style="color:#783000">盘点差异:</span><span class="difference_amount"></span></span>
                                     </div>
@@ -314,7 +319,7 @@
             <table class="table table-sm table-striped d-none d-xl-block p-0 text-nowrap table-bordered"
                    id="headerParent" ref="boxPc">
                 <tr class="p-0" id="header"></tr>
-                <tr {{--v-for="(inventoryMission,i) in inventoryMissions"--}} v-for="(inventoryMission, i) in 显示记录列" :key="i"
+                <tr v-for="(inventoryMission, i) in 显示记录列" :key="i"
                     :style="{'opacity': inventoryMission.mark==='跳过'?'0.7':'','opacity': inventoryMission.mark==='确认差异'?'0.7':''}" :class="[
                     inventoryMission.mark==='已复盘有差异'?'td-cool':'',
                     inventoryMission.mark==='已复盘无差异'?'td-cool text-muted':'',
@@ -511,7 +516,7 @@
                                       @click="跳过盘点记录(inventoryMission.id,inventory.id,inventoryMission.commodity.name)">跳过</span>
                                      <span class="btn  btn-sm btn-outline-secondary" v-if="inventoryMission.mark==='已复盘有差异'||inventoryMission.mark==='未复盘有差异'"
                                            @click="确认盘点差异(inventoryMission.id,inventory.id,inventoryMission.commodity.name)">跳过</span>
-                                    <span class="btn  btn-sm btn-outline-secondary"
+                                        <span class="btn  btn-sm btn-outline-secondary"
                                           v-if="inventory.type=='动盘'&& inventoryMission.mark=='未盘' &&!listMode"
                                           @click="选中盘点起始位置(inventoryMission.id,inventoryMission.location)">以此为起点</span>
                             </span>
@@ -659,6 +664,7 @@
                     },
                     @endforeach
                 ],
+                库位盘点记录:[],
                 条码索引_记录: {},
                 库位索引_记录: {},
                 checkData: [],
@@ -669,6 +675,7 @@
                 inventoryAccountMissions:[],
                 listMode:false,
                 blindReceive:false,
+                addInventoryMission:false,
                 分割位置id:null,
                 显示记录列:[],
 
@@ -686,8 +693,6 @@
                     scanEndInputted:false,binDisable:false,barcodeDisable:true,amountDisable:false,
                 },
                 goodses:[],//{barcode,amount,bin,produce_date,valid_date,batch_number}
-                // 加载后盒子底部位置:'',
-                // 加载前盒子底部位置:'',
             },
             beforeMount: function () {
                 this.重排序并标记全列表类型();
@@ -789,70 +794,7 @@
                                 _this.加载下方数据并置空上方数据()
                             }
                     }
-                    //可视区域高度(浏览器页面的高度)
-                    //let height=window.innerHeight;
-                    //滚动区域高度
-                    //let scrollHeight = document.documentElement.scrollTop || document.body.scrollTop;
-                    //let _this=this;
-                    // 可视区域+滚动条距离顶部位置 = 浏览器窗口底部的位置
-                    //const count = height + scrollHeight;
-                    //懒加载盒子高度+懒加载盒子距离顶部位置=计算出盒子底部的距离
-                    //const box_bottom = _this.$refs.box.offsetHeight + _this.$refs.box.offsetTop-500;//移动
-                    //const box_bottomPc = _this.$refs.boxPc.offsetHeight + _this.$refs.boxPc.offsetTop;//pc
-                    //console.log("浏览器底部位置",count);
-                    //console.log("隐藏部分",box_bottomPc-count);
-                    // if (box_bottom===-500&&count >= box_bottomPc) {//pc端下划加载
-                    //     if (_this.显示记录列.length < _this.inventoryMissions.length) {
-                    //         _this.加载下方数据并置空上方数据();
-                    //     }
-                    // }
-                    // if (box_bottomPc===0&&count >= box_bottom) {//移动端下划加载
-                    //     if (_this.显示记录列.length < _this.inventoryMissions.length) {
-                    //         _this.加载下方数据并置空上方数据()
-                    //     }
-                    // }
-                    // 窗口高,滚动条位置,页面长度,追加数据长度
-                    // 滚动条位置+窗口高度=当前显示中的页面底部Y
-                    // 页面长度-当前显示中的页面底部Y=(隐藏的高度!!!!+行高)->求出隐藏了多少行
-                    // 隐藏的高度- (func(去掉10行)=去掉后的隐藏高度)=10行去掉了高
-                    // 10行去掉了高/10=每行实际多高
-                    // 隐藏的高度/每行实际多高=去掉多少行可以把下方都清理干净
-                },
-                加载上方数据(){
-                    //1.找到显示中第一条ID
-                    let _this=this;
-                    let 去除空对象的显示数据列=[];
-                    let 空对象数据列=[];
-                    _this.显示记录列.forEach(function (inventoryMission) {
-                        if (!($.isEmptyObject(inventoryMission))){
-                            去除空对象的显示数据列.push(inventoryMission);
-                        }
-                        if (($.isEmptyObject(inventoryMission))){
-                            空对象数据列.push(inventoryMission);
-                        }
-                    })
-                    let 初条显示数据=去除空对象的显示数据列[0];
-                    let 末条显示数据=去除空对象的显示数据列[去除空对象的显示数据列.length-1];
-                    let 空对象条数=空对象数据列.length;
-                    //_this.清理下方数据(去除空对象的显示数据列);
-                    console.log(去除空对象的显示数据列)
-                    console.log(空对象条数)
-                    //console.log(_this.显示记录列)
-                    //2.以1的ID从总列表网上倒退找到N条(N=10)
-                    //2.5, 计算有空行到第几行
-                    //3.将显示中的列表从头清理N行,的2.5的结果下标后插入2的结果
-                },
-                // 清理上方数据(){
-                //
-                // },
-                // 清理下方数据(去除空对象的显示数据列){
-                //     let _this=this;
-                //     let index;
-                //     _this.显示记录列.forEach(function (inventoryMission,i) {
-                //         if (inventoryMission.id===去除空对象的显示数据列[去除空对象的显示数据列.length-6].id) index=i;
-                //         if (i>index) _this.显示记录列.splice(i,1);
-                //     })
-                // },
+                },
                 加载下方数据并置空上方数据(){
                     let _this=this;
                     const count = _this.显示记录列.length;
@@ -860,8 +802,6 @@
                         _this.inventoryMissions.map((inventoryMission, index) => {
                             if (_this.显示记录列.length < 5 + count) {
                                 if (_this.显示记录列.length < _this.inventoryMissions.length) {
-                                    //_this.显示记录列.splice(_this.显示记录列.length-30,1);
-                                    //_this.显示记录列.unshift({});
                                     _this.显示记录列.push(_this.inventoryMissions[_this.显示记录列.length]);
                                 }
                             }
@@ -893,6 +833,7 @@
                         newDom.find('.difference_amount').text($appointInventoryList[i].difference_amount);
                         newDom.show();
                         newDom.find('.blueAmount').attr('data_id', $appointInventoryList[i].id);
+                        newDom.find('.blueAmount').attr('stored_amount', $appointInventoryList[i].stored_amount);
                         newDom.find('.stockButton').attr('data_id', $appointInventoryList[i].id);
                         newDom.addClass('blueTr'+i);
                         newDom.appendTo($blueTable);
@@ -917,6 +858,7 @@
                         newDom.find('.difference_amount').text($appointInventoryList[i].difference_amount);
                         newDom.show();
                         newDom.find('.blueAmountPc').attr('data_id', $appointInventoryList[i].id);
+                        newDom.find('.blueAmountPc').attr('stored_amount', $appointInventoryList[i].stored_amount);
                         newDom.find('.stockButtonPc').attr('data_id', $appointInventoryList[i].id);
                         newDom.addClass('blueTrPc'+i);
                         newDom.appendTo($blueTablePc);
@@ -960,6 +902,9 @@
                 locationChange(e){
                     this.inputs().location = e.target.value;
                     this.提交部分输入();
+                    if(!this.addInventoryMission){
+                        this.location=this.inputs().location ;
+                    }
                 },
                 提交部分输入:_.throttle(function(){
                     let _this = this;
@@ -968,7 +913,11 @@
                     (new Promise(function (resolve, reject) {
                         resolve()
                     })).then(function () {
-                        _this.提交库位和条码();
+                        if(_this.addInventoryMission){
+                            _this.提交库位和条码();
+                        }else{
+                            _this.提交库位();
+                        }
                         _this.显示盘点计数input_按情况();
                     })
 
@@ -983,14 +932,7 @@
                     let id = $(e.target).attr('data_id');
                     _this.selectingId=id;
                     if(e.key==='Enter'){
-                        this.放置焦点光标至正确位置();
-
-                        let re=true;
-                        _this.提交新增并盘点().then(function(result){
-                            if(!result){
-                                _this.提交盘点();
-                            }
-                        })
+                        _this.提交盘点();
                     }
                 },
                 提交库位和条码:_.throttle(async function(){
@@ -1003,6 +945,11 @@
                     }
                     this.筛选出记录(_this.inputs().location,_this.inputs().barcode);
                 },100,{ 'trailing': false }),
+                提交库位:_.throttle(async function(){
+                    let _this=this;
+                    this.清空指定盘点记录列();
+                    this.筛选库位出记录(_this.inputs().location);
+                },100,{ 'trailing': false }),
                 建立记录索引(){
                     let _this=this;
                     _this.inventoryMissions.forEach(function (inventoryMission) {
@@ -1019,11 +966,14 @@
                     $jqueryTable.forEach(function (newDom,i) {
                         newDom.remove();
                     })
-                    $appointInventoryList.forEach(function (inventoryMission,i) {
-                        $appointInventoryList.splice(i,1);
-                    });
+                    // $appointInventoryList.forEach(function (inventoryMission,i) {
+                    //     $appointInventoryList.splice(i,1);
+                    // });
+                    $appointInventoryList=[];
                     $showBlueTable.attr('class','d-none');
                     _this.selectingId='';
+                    _this.location='';
+                    _this.库位盘点记录=[];
                 },
                 显示盘点计数input_按情况(){
                     let _this=this;
@@ -1057,6 +1007,23 @@
                         _this.cloneBlueTrPcDom($appointInventoryList);
                     }
                 },
+                async 筛选库位出记录(库位){
+                    库位=库位.trim();
+                    let _this=this;
+                    if(!库位)return false;
+                    if (!_this.库位索引_记录[库位]) return;
+                    if(Array.isArray(_this.库位索引_记录[库位])){
+                        _this.库位索引_记录[库位].forEach(function(inventoryMission){
+                            if (inventoryMission.location===库位){
+                                $appointInventoryList.push(inventoryMission);
+                                $appointInventoryList=_this.unique($appointInventoryList);
+                            }
+                        });
+                        $showBlueTable.removeClass('d-none');
+                        _this.cloneBlueTrDom($appointInventoryList);
+                        _this.cloneBlueTrPcDom($appointInventoryList);
+                    }
+                },
                 unique(arr){
                     return Array.from(new Set(arr));
                 },
@@ -1067,9 +1034,11 @@
                         $locationInput.focus();
                         return;
                     }
-                    if (!$barcodeInput.val().trim()){
-                        $barcodeInput.focus();
-                        return;
+                    if (_this.addInventoryMission){
+                        if (!$barcodeInput.val().trim()){
+                            $barcodeInput.focus();
+                            return;
+                        }
                     }
                     setTimeout(function(){
                         if(_this.dataExtraStatus.addingNew){
@@ -1149,8 +1118,7 @@
                     let 盘点数=_this.inputs().amount.trim();
                     let 选定盘点记录id=_this.selectingId;
                     $appointInventoryList.forEach(function (inventoryMission) {
-                        inventoryMission.commodity_barcodes.forEach(function (barcode) {
-                            if (inventoryMission.location === 库位 && 条码 === barcode.code) {
+                            if (inventoryMission.location === 库位) {
                                 if (inventoryMission.stockInventoryPersons.length > 0 && inventoryMission.id === _this.selectingId) {
                                     _this.lastStockInventoryRecord = inventoryMission;
                                     _this.stockInventoryPersons = inventoryMission.stockInventoryPersons;
@@ -1162,7 +1130,6 @@
                                 _this.盘点(选定盘点记录id,库位,条码,_this.inventory.id,盘点数);
                                 _this.清空指定盘点记录列();
                             }
-                        })
                     });
                 },100,{ 'trailing': false }),
                 //结束初盘任务
@@ -1522,7 +1489,6 @@
                                 });
                                 if(!Array.isArray(_this.库位索引_记录[location])) _this.库位索引_记录[location]=[];
                                 _this.库位索引_记录[location].push(inventoryAccountMission);
-                                // _this.重排序并标记全列表类型(_this.inventoryMissions);
                                 _this.重排序并显示();
                                 _this.清空inputs();
                                 tempTip.setDuration(3000);
@@ -1596,7 +1562,6 @@
                                 }
                                 return true;
                             });
-                            //_this.重排序并标记全列表类型(_this.inventoryMissions);
                             _this.重排序并显示();
                             if (response.data.inventoryMission.difference_amount!==0)_this.初盘有盘点差异_确认是否重盘();
                             if (response.data.inventoryMission.difference_amount===0){
@@ -1657,7 +1622,6 @@
                     let produced_at=_this.inputs().produced_at.trim();
                     let valid_at=_this.inputs().valid_at.trim();
                     let batch_number=_this.inputs().batch_number.trim();
-                    _this.清空指定盘点记录列();
                     let url = '{{url('inventory/盘点选中任务')}}';
                     axios.post(url, {id:id,count:count,inventoryId:inventoryId,produced_at:produced_at,valid_at:valid_at,batch_number:batch_number}).then(function (response) {
                         if (!response.data.success) {
@@ -1670,22 +1634,22 @@
                                 _this.inventory.surplus = response.data.inventory.surplus;
                                 _this.inventory.check_surplus = response.data.inventory.check_surplus;
                             }
-                            if (response.data.inventoryMission.length >1) {
-                                response.data.inventoryMission.forEach(function (mission) {
-                                    let isToEdit=false;
-                                    let commodity_barcodes=_this.条码索引_记录[_this.inputs().barcode][0].commodity_barcodes;
-                                    _this.条码索引_记录[_this.inputs().barcode].every(function (inventoryMission){
-                                        if (parseInt(inventoryMission.id) === parseInt(mission.id)){
-                                            isToEdit=true;
-                                            inventoryMission.checked = mission.checked;
-                                            inventoryMission.verified_amount = mission.verified_amount;
-                                            inventoryMission.difference_amount =mission.difference_amount;
-                                            inventoryMission.re_checked_amount = mission.re_checked_amount;
-                                            inventoryMission.stockInventoryPersons = response.data.stockInventoryPersons;
-                                            return false;
-                                        }
-                                        return true;
-                                    })
+                                    if (response.data.inventoryMission.length >1) {
+                                        response.data.inventoryMission.forEach(function (mission) {
+                                            let isToEdit=false;
+                                            let commodity_barcodes=mission.commodity_barcodes;
+                                            _this.库位索引_记录[_this.inputs().location.trim()].every(function (inventoryMission){
+                                                if (parseInt(inventoryMission.id) === parseInt(mission.id)){
+                                                    isToEdit=true;
+                                                    inventoryMission.checked = mission.checked;
+                                                    inventoryMission.verified_amount = mission.verified_amount;
+                                                    inventoryMission.difference_amount =mission.difference_amount;
+                                                    inventoryMission.re_checked_amount = mission.re_checked_amount;
+                                                    inventoryMission.stockInventoryPersons = response.data.stockInventoryPersons;
+                                                    return false;
+                                                }
+                                                return true;
+                                            })
                                     if (!isToEdit){
                                         mission.commodity_barcodes= commodity_barcodes;
                                         mission.stockInventoryPersons=response.data.stockInventoryPersons;
@@ -1693,7 +1657,7 @@
                                     }
                                 });
                             }else {
-                                _this.条码索引_记录[_this.inputs().barcode].every(function (inventoryMission,i) {
+                                _this.库位索引_记录[_this.inputs().location.trim()].every(function (inventoryMission,i) {
                                     if (parseInt(inventoryMission.id) === parseInt(response.data.inventoryMission.id)){
                                         inventoryMission.checked = response.data.inventoryMission.checked;
                                         inventoryMission.verified_amount = response.data.inventoryMission.verified_amount;
@@ -1707,7 +1671,7 @@
                                     return true;
                                 })
                             }
-                            _this.重排序并标记全列表类型(_this.inventoryMissions);
+                            _this.重排序并显示();
                             _this.清空inputs();
                             _this.清空指定盘点记录列();
                             tempTip.setDuration(3000);
@@ -1749,7 +1713,82 @@
                         excelExport(checkAllSign,data,url,this.sum,token);
                     }
                 },
-                //盲收
+                stockInventoryByLocation(){
+                    let _this=this;
+                    let inventoryId=_this.inventory.id;
+                    let difference=[];
+                    let trPc = $("#blueTablePc tr:gt(1)").get();
+                    let tr = $("#blueTable tr:gt(0)").get();
+                    $(trPc).each(function(item,key){
+                         input = $(key).find('.blueAmountPc');
+                         let obj=new Object();
+                         obj.id=input.attr('data_id');
+                         obj.stored_amount=input.attr('stored_amount');
+                         obj.amount=input.val();
+                         if (input.val()) _this.库位盘点记录.push(obj);
+                    });
+                    $(tr).each(function(item,key){
+                        input = $(key).find('.blueAmount');
+                        let obj=new Object();
+                        obj.id=input.attr('data_id');
+                        obj.stored_amount=input.attr('stored_amount');
+                        obj.amount=input.val();
+                        if (input.val()) _this.库位盘点记录.push(obj);
+                    });
+                    let url = '{{url('inventory/stockInventory/batchStockByLocation')}}';
+                    axios.post(url,{mission:_this.库位盘点记录,inventoryId:inventoryId}).then(function(response){
+                        if (!response.data.success) {
+                            tempTip.setDuration(2000);
+                            tempTip.show('盘点失败!' + '   ' + response.data.msg);
+                            return;
+                        }else {
+                            if (_this.inventory.id === response.data.inventory.id) {
+                                _this.inventory.processed = response.data.inventory.processed;
+                                _this.inventory.surplus = response.data.inventory.surplus;
+                                _this.inventory.check_surplus = response.data.inventory.check_surplus;
+                            }
+                                response.data.inventoryMission.forEach(function (mission) {
+                                    if(mission.difference_amount>0) difference.push(mission.commodity.barcodes[0].code);
+                                    _this.inventoryMissions.every(function (inventoryMission,i){
+                                        if (parseInt(inventoryMission.id) === parseInt(mission.id)){
+                                            inventoryMission.checked = mission.checked;
+                                            inventoryMission.verified_amount = mission.verified_amount;
+                                            inventoryMission.difference_amount =mission.difference_amount;
+                                            inventoryMission.re_checked_amount = mission.re_checked_amount;
+                                            inventoryMission.stockInventoryPersons = response.data.stockInventoryPersons;
+                                            _this.inventoryMissions.splice(i, 1);
+                                            _this.inventoryMissions.unshift(inventoryMission);
+                                            return false;
+                                        }
+                                        return true;
+                                    })
+                                });
+                            _this.重排序并显示();
+                            _this.清空inputs();
+                            _this.清空指定盘点记录列();
+                            tempTip.setDuration(5000);
+                            if (difference.length>0){
+                                tempTip.show('给库位下:条码为'+difference+'存在差异,如需重盘请针对该条码重新盘点!');
+                                difference=[];
+                            }else {
+                                tempTip.showSuccess('盘点成功!');
+                            }
+                        }
+                    }).catch(function (err) {
+                        tempTip.setDuration(2000);
+                        tempTip.show('盘点失败!' + '网络错误' + err);
+                    })
+                },
+                新增盘点记录(){
+                    let _this=this;
+                    _this.addInventoryMission=true;
+                    _this.清空指定盘点记录列();
+                },
+                收起新增(){
+                    let _this=this;
+                    _this.addInventoryMission=false;
+                    _this.清空指定盘点记录列();
+                },
                 盲收(){
                     let _this=this;
                     _this.blindReceive=true;
@@ -1826,8 +1865,6 @@
                                 case 'increasing': data.commitGoodsOnIncreasingMode();break;
                                 case 'multiIncreasing': data.commitGoodsOnMultiIncreasingMode();break;
                             }
-                            //$('#amount').focus();
-                            //$(document).off('keypress');
                         }
                     });
                 },
@@ -1855,21 +1892,6 @@
                             window.tempTip.showSuccess('保存成功');
                             data.focusDocument();
                             data.audioDing();
-                            // window.tempTip.inputVal('该商品第一件递增请输入隔口号:',function(bin){
-                            //     if(bin===''){
-                            //         window.tempTip.setDuration(1500);
-                            //         window.tempTip.show('未输入隔口号,请重新扫描');
-                            //         data.alertVibrate();
-                            //         data.focusDocument();return}
-                            //     data.inputting.bin=bin;
-                            //     data.inputting.amount=1;
-                            //     data.goodses.unshift(JSON.parse(JSON.stringify(data.inputting)));
-                            //     data.status.binDisable=true;
-                            //     window.tempTip.setDuration(500);
-                            //     window.tempTip.showSuccess('保存成功');
-                            //     data.focusDocument();
-                            //     data.audioDing();
-                            // })
                         }else{
                             increase();
                         }
@@ -1908,21 +1930,6 @@
                         window.tempTip.showSuccess('保存成功');
                         data.focusDocument();
                         data.audioDing();
-                        // window.tempTip.inputVal('该商品第一件递增请输入隔口号:',function(bin){
-                        //     if(bin===''){
-                        //         window.tempTip.setDuration(1500);
-                        //         window.tempTip.show('未输入隔口号,请重新扫描');
-                        //         data.alertVibrate();
-                        //         data.focusDocument();return}
-                        //     data.inputting.bin=bin;
-                        //     data.inputting.amount=1;
-                        //     data.goodses.unshift(JSON.parse(JSON.stringify(data.inputting)));
-                        //     data.status.binDisable=true;
-                        //     window.tempTip.setDuration(500);
-                        //     window.tempTip.showSuccess('保存成功');
-                        //     data.focusDocument();
-                        //     data.audioDing();
-                        // })
                     }else{
                         increase();
                     }

+ 1 - 1
resources/views/personnel/laborReport/index.blade.php

@@ -467,7 +467,7 @@
                             vue:vue
                         });
                         header.init();
-                        let $dom_thisRecordWorkingTime=$('#dom_thisRecordWorkingTime');
+                        let $dom_thisRecordWorkingTime=$('#dom_thisRoundRecordWorkingTime');
                         $dom_thisRecordWorkingTime.attr('title','用工总工时:'+_this.totalWorkingHours);
                         $dom_thisRecordWorkingTime.tooltip({'trigger':'manual'});
                         $dom_thisRecordWorkingTime.tooltip('show')

+ 0 - 38
resources/views/store/inStorage/index.blade.php

@@ -18,44 +18,6 @@
                 <td>
                     <input class="checkItem" type="checkbox" :value="store.id" v-model="checkData">
                 </td>
-{{--                <td v-if="store.store_items" class="text-muted"--}}
-{{--                    :rowspan="store.is_multi_row?2:''">--}}
-{{--                    <span>--}}
-{{--                                        <a href="#" v-if="store.store_items.length>0"--}}
-{{--                                           class="dropdown-toggle btn btn-sm btn-outline-info"--}}
-{{--                                           data-toggle="dropdown">--}}
-{{--                                            查看明细--}}
-{{--                                        </a>--}}
-{{--                                        <div--}}
-{{--                                            style="position: absolute;width:1050px;margin-left:-50px;background-color: white;max-height:175px ;overflow-y:auto"--}}
-{{--                                            class="small mt-0 dropdown-menu">--}}
-{{--                                            <table class="table table-sm table-striped table-bordered">--}}
-{{--                                                <tr class="text-center">--}}
-{{--                                                    <th>ASN单号</th>--}}
-{{--                                                    <th>行号</th>--}}
-{{--                                                    <th>商品名称</th>--}}
-{{--                                                    <th>商品编码</th>--}}
-{{--                                                    <th>商品条码</th>--}}
-{{--                                                     <th>数量</th>--}}
-{{--                                                     <th>质量</th>--}}
-{{--                                                     <th>状态</th>--}}
-{{--                                                     <th>创建时间</th>--}}
-{{--                                                </tr>--}}
-{{--                                                <tr v-for="storeItem in store.store_items" class="text-center">--}}
-{{--                                                    <td>@{{store.asn_code}}</td>--}}
-{{--                                                    <td>@{{ storeItem.asn_line_code }}</td>--}}
-{{--                                                    <td>@{{ storeItem.name }}</td>--}}
-{{--                                                    <td>@{{ storeItem.sku }}</td>--}}
-{{--                                                    <td>@{{ storeItem.barcode }}</td>--}}
-{{--                                                    <td>@{{ storeItem.amount }}</td>--}}
-{{--                                                    <td>@{{ storeItem.quality }}</td>--}}
-{{--                                                    <td>@{{ storeItem.status }}</td>--}}
-{{--                                                    <td>@{{ storeItem.created_at }}</td>--}}
-{{--                                                </tr>--}}
-{{--                                            </table>--}}
-{{--                                        </div>--}}
-{{--                                        </span>--}}
-{{--                </td>--}}
                                 <td>
                                     <button class="btn btn-sm btn-outline-info" v-if="!store.isOpenStoreItem" @click="openStoreItems(store,i,$event);store.isOpenStoreItem=true">查看明细</button>
                                     <button v-if="store.isOpenStoreItem"  @click="closeStoreItems();store.isOpenStoreItem=false" class="btn btn-sm btn-dark">收起明细</button>

+ 1 - 0
routes/web.php

@@ -464,6 +464,7 @@ Route::group(['prefix'=>'inventory'],function(){
         Route::post('searchCommodityByBarcode','InventoryAccountController@searchCommodityByBarcode');
         Route::get('blindReceive/{id}','InventoryAccountController@enterBlindReceive');
         Route::post('baseOnBlindReceive','InventoryAccountController@baseOnBlindReceive');
+        Route::post('batchStockByLocation','InventoryAccountController@batchStockByLocation');
     });
     /** 库存比对 */
     Route::group(['prefix'=>'inventoryCompare'],function(){