瀏覽代碼

人事--打卡

haozi 5 年之前
父節點
當前提交
1e69a9a0b5

+ 2 - 1
app/Events/ImportEvent.php

@@ -31,7 +31,8 @@ class ImportEvent implements ShouldBroadcast
      */
     public function broadcastOn()
     {
-        return new Channel(LaborReport::tokenOfBroadcastEnterAndLeave());
+        $tokenOfBroadcastEnterAndLeave=LaborReport::tokenOfBroadcastEnterAndLeave();
+        return new Channel($tokenOfBroadcastEnterAndLeave);
         //return new Channel('laborReport');
     }
 

+ 29 - 13
app/Http/Controllers/InventoryController.php

@@ -178,6 +178,35 @@ class InventoryController extends Controller
         $owners=Owner::select('id','name')->get();
         return view('inventory.stockInventory.mission',compact('owners','inventories','paginateParams'));
     }
+    //进入盘点页面
+    public function enterStockInventory($id){
+        if (!Gate::allows('库存管理-盘点')){return redirect(url('/')); }
+        if (!$id) return ['success'=>false,'data'=>'参数错误!'];
+        $inventory=Inventory::with('owner')->find($id);
+        $inventoryMissions=InventoryMission::with(['commodity'])->where('inventory_id',$id)->get();
+        return view('inventory.stockInventory.inventoryMission',compact('inventory','inventoryMissions'));
+    }
+    //依据盘点任务id进行 --盘点
+    public function stockInventory(Request $request){
+        if (!Gate::allows('库存管理-盘点')){return redirect(url('/')); }
+        $count=$request->input('count');
+        if (is_null($count)) return ['success'=>false,'data'=>'盘点数不能为空!'];
+        $inventoryMission=app('inventoryService')->stockInventory($request);
+        if (!$inventoryMission)return ['success'=>false,'data'=>'参数错误!'];
+        $inventory=app('inventoryService')->updateInventoryMissionProcessed($request);
+        return ['success'=>true,'inventoryMission'=>$inventoryMission,'inventory'=>$inventory];
+    }
+
+
+
+
+
+
+
+
+
+
+    //盘点任务导出
     public function stockInventoryExport(Request $request){
         if (!Gate::allows('库存管理-盘点')){return redirect(url('/')); }
         ini_set('max_execution_time',3500);
@@ -221,17 +250,4 @@ class InventoryController extends Controller
         }
         return Excel::download(new Export($row,$list),date('YmdHis', time()).'-盘点任务记录单.xlsx');
     }
-    //进入盘点页面
-    public function enterStockInventory($id){
-        if (!Gate::allows('库存管理-盘点')){return redirect(url('/')); }
-        if (!$id) return ['success'=>false,'data'=>'参数错误!'];
-        $inventory=Inventory::with('owner')->find($id);
-        $inventoryMissions=InventoryMission::with('commodity')->where('inventory_id',$id)->paginate(50);
-        return view('inventory.stockInventory.inventoryMission',compact('inventory','inventoryMissions'));
-    }
-    //盘点任务
-    public function stockInventory(Request $request,$id){
-        if (!Gate::allows('库存管理-盘点')){return redirect(url('/')); }
-        dd($id,$request->input('count'));
-    }
 }

+ 27 - 104
app/Http/Controllers/UserDutyCheckController.php

@@ -6,7 +6,6 @@ use App\Events\ClockinEvent;
 use App\LaborCompany;
 use App\LaborReport;
 use App\Services\LaborReportService;
-use App\Services\UserDutyCheckService;
 use App\User;
 use App\UserDetail;
 use App\UserDutyCheck;
@@ -44,9 +43,12 @@ class UserDutyCheckController extends Controller
             $date = date('Y-m-d H:i:s');
             if ($key < $date) return "<h1 style='color: red;text-align:center'>当前二维码失效,请重新扫码!</h1>";
         }
+
         $userLaborToken = $request->cookie('userLaborToken');
-        if ($userLaborToken && Cache::has('dutyCheckTokenStr_' . $userLaborToken)) {
-            $user_id = Cache::get('dutyCheckTokenStr_' . $userLaborToken);
+        $user_id = Cache::get('dutyCheckTokenStr_' . $userLaborToken);
+        var_dump($userLaborToken);
+        var_dump($user_id);
+        if ($userLaborToken && $user_id) {
             $userDetail = UserDetail::find($user_id);
             if (!$userDetail) return redirect('personnel/checking-in/userDutyCheck/createUserDetail/' . $userDetail->mobile_phone)->with("importAndExportQRCodeType", $importAndExportQRCodeType);
             if($importAndExportQRCodeType=='import') return redirect('personnel/checking-in/userDutyCheck/updateUserLaborCompanies/' . $userDetail->mobile_phone)->with("importAndExportQRCodeType", $importAndExportQRCodeType);
@@ -73,34 +75,35 @@ class UserDutyCheckController extends Controller
         $userDetail = UserDetail::where('mobile_phone', $mobile_phone)->first();
         if (!$userDetail) return redirect('personnel/checking-in/userDutyCheck/createUserDetail/' . $mobile_phone)->with("importAndExportQRCodeType", $importAndExportQRCodeType);
         if (Cache::has('dutyCheckTokenUser_' . $userDetail->user_id)) return "<h1 style='color: red;text-align:center'>请使用原有设备进行打卡,如无法使用原有设备请联系管理人员解绑设备!</h1>";
-        $userDutyCheckOld = UserDutyCheck::where('user_id', $userDetail->user_id)->orderBy('checked_at', 'DESC')->limit(10)->first();
-        $date = date('Y-m-d H:i:s');
-        $lastDate = Carbon::parse($userDutyCheckOld['checked_at']);
-        $thisDate = Carbon::parse($date);
-        $diffDate = $thisDate->diffInMinutes($lastDate);
-        //未登录从新选择劳务所
-        if ($diffDate > 0.5 * 1440 ||!$userDutyCheckOld) {
-            return redirect('personnel/checking-in/userDutyCheck/updateUserLaborCompanies/' . $mobile_phone)->with("importAndExportQRCodeType", $importAndExportQRCodeType);
-        }
+//        $userDutyCheckOld = UserDutyCheck::where('user_id', $userDetail->user_id)->orderBy('checked_at', 'DESC')->first();
+//        $date = date('Y-m-d H:i:s');
+//        $lastDate = Carbon::parse($userDutyCheckOld['checked_at']);
+//        $thisDate = Carbon::parse($date);
+//        $diffDate = $thisDate->diffInMinutes($lastDate);
+//        //未登录从新选择劳务所
+//        if ($diffDate > 0.5 * 1440 ||!$userDutyCheckOld) {
+//            return redirect('personnel/checking-in/userDutyCheck/updateUserLaborCompanies/' . $mobile_phone)->with("importAndExportQRCodeType", $importAndExportQRCodeType);
+//        }
+        if($importAndExportQRCodeType=='import') return redirect('personnel/checking-in/userDutyCheck/updateUserLaborCompanies/' . $userDetail->mobile_phone)->with("importAndExportQRCodeType", $importAndExportQRCodeType);
         $userDutyCheck=$this->importAndExportDutyCheck($userDetail->user_id, $importAndExportQRCodeType);
         if ($userDutyCheck && $userDutyCheck->isNotImport == true) return "<h1 style='color: darkred;text-align:center'>当前还未入场,不可出场!</h1>";
         if ($userDutyCheck && $userDutyCheck->import == true) return "<h1 style='color: darkred;text-align:center'>您已入场,不可再次入场!</h1>";
         if ($userDutyCheck && $userDutyCheck->export == true) return "<h1 style='color: darkred;text-align:center'>您已出场,不可再次出场!!</h1>";
         if (!$userDutyCheck) return "<h1 style='color: red;text-align:center'>打卡异常,请联系相关人员!</h1>";
-        $userLaborToken = $userDetail->getDutyCheckToken(config('users.token_check_in_expire_minutes'));
+        //$userLaborToken = $userDetail->getDutyCheckToken(config('users.token_check_in_expire_minutes'));
         $laborReportService = app('LaborReportService');
         $errorMessage = $laborReportService->makeOrChangeLaborReportByUserDutyCheck($userDutyCheck, $importAndExportQRCodeType);
         if ($errorMessage) return $errorMessage;
         $laravelEchoPrefix = config('database.redis.options.prefix');
-        return response()->view('personnel/checking-in/importAndExportSuccess', ['full_name' => $userDetail->full_name, 'checked_at' => $userDutyCheck->checked_at, 'type' => $userDutyCheck->type, 'laravelEchoPrefix' => $laravelEchoPrefix])
-            ->cookie('userLaborToken', $userLaborToken, config('users.token_check_in_expire_minutes'), '/');
+        return response()->view('personnel/checking-in/importAndExportSuccess', ['full_name' => $userDetail->full_name, 'checked_at' => $userDutyCheck->checked_at, 'type' => $userDutyCheck->type, 'laravelEchoPrefix' => $laravelEchoPrefix]);
+//        ->cookie('userLaborToken', $userLaborToken, config('users.token_check_in_expire_minutes'), '/')
     }
 
     //根据用户提交进出场打卡记录
-    public function importAndExportDutyCheck($user_id, $importAndExportQRCodeType)
+    public function importAndExportDutyCheck($user_id,$importAndExportQRCodeType)
     {
         $dateNow = Carbon::now()->format('Y-m-d');
-        $userDutyCheckOld = UserDutyCheck::where('user_id', $user_id)->where('checked_at', 'like', $dateNow . '%')->orderBy('id', 'desc')->limit(10)->first();
+        $userDutyCheckOld = UserDutyCheck::where('user_id', $user_id)->where('checked_at','like',$dateNow.'%')->orderBy('id','desc')->limit(10)->first();
         $date = date('Y-m-d H:i:s');
         $this->log(__METHOD__, "提交打卡记录__" . __FUNCTION__, json_encode([$user_id, $date]));
         $userDutyCheck = new UserDutyCheck([
@@ -112,7 +115,7 @@ class UserDutyCheckController extends Controller
         if (!$userDutyCheckOld) {
             //当前日期的前一天
             $yesterday = Carbon::yesterday()->format('Y-m-d');
-            $userDutyCheckYesterday = UserDutyCheck::where('user_id', $user_id)->where('checked_at', 'like', $yesterday . '%')->orderBy('id', 'desc')->limit(10)->first();
+            $userDutyCheckYesterday = UserDutyCheck::where('user_id', $user_id)->where('checked_at','like', $yesterday.'%')->orderBy('id','desc')->limit(10)->first();
             if ($importAndExportQRCodeType && $importAndExportQRCodeType == 'export') {
                 if ($userDutyCheckYesterday && $userDutyCheckYesterday->type == '登入') {
                     $userDutyCheck->verify_user_id = $userDutyCheckYesterday->verify_user_id;
@@ -188,6 +191,7 @@ class UserDutyCheckController extends Controller
         if ($userDutyCheck && $userDutyCheck->export == true) return "<h1 style='color: darkred;text-align:center'>您已出场,不可再次出场!!</h1>";
         if (!$userDutyCheck) return "<h1 style='color: red;text-align:center'>打卡异常,请联系相关人员!</h1>";
         $userLaborToken = $userDetail->getDutyCheckToken(config('users.token_check_in_expire_minutes'));
+        var_dump($userLaborToken);
         $laborReportService = app('LaborReportService');
         $laborReportService->makeOrChangeLaborReportByUserDutyCheck($userDutyCheck, $importAndExportQRCodeType);
         $laravelEchoPrefix = config('database.redis.options.prefix');
@@ -249,6 +253,7 @@ class UserDutyCheckController extends Controller
         if ($userDutyCheck&&$userDutyCheck->export==true)return "<h1 style='color: darkred;text-align:center'>您已出场,不可再次出场!</h1>";
         if (!$userDutyCheck)return "<h1 style='color: red;text-align:center'>打卡异常,请联系相关人员!</h1>";
         $userLaborToken=$userDetail->getDutyCheckToken(config('users.token_check_in_expire_minutes'));
+        var_dump($userLaborToken);
         Controller::logS(__METHOD__,"录入临时工,用户,对应工作组,打卡记录".__FUNCTION__,json_encode($userDetail));
         $laravelEchoPrefix = config('database.redis.options.prefix');
         return response()->view('personnel/checking-in/importAndExportSuccess',['full_name'=>$userDetail->full_name,'checked_at'=>$userDutyCheck->checked_at,'type'=>$userDutyCheck->type,'laravelEchoPrefix'=>$laravelEchoPrefix])
@@ -285,8 +290,10 @@ class UserDutyCheckController extends Controller
     {
         $userWorkgroupID = $request->input('userWorkgroupID');
         $userLaborToken = $request->cookie('userLaborToken');
-        if ($userLaborToken && Cache::has('dutyCheckTokenStr_' . $userLaborToken)) {
-            $user_id = Cache::get('dutyCheckTokenStr_' . $userLaborToken);
+        $user_id = Cache::get('dutyCheckTokenStr_' . $userLaborToken);
+        var_dump($userLaborToken);
+        var_dump($user_id);
+        if ($userLaborToken && $user_id) {
             $dateNow = Carbon::now()->format('Y-m-d');
             $userDutyCheck = UserDutyCheck::where('user_id', $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>";
@@ -314,7 +321,6 @@ class UserDutyCheckController extends Controller
             $laborReportNow = LaborReport::where('user_id', $user_id)->orderBy('id', 'desc')->first();
             if ($laborReportNow['group_user_id'] && !$laborReportNow['check_out_at']) return "<h1 style='color: darkred;text-align:center'>您还未退组,暂不可换组,请联系之前组长!</h1>";
             if ($laborReportNow['user_workgroup_id'] == $userWorkgroupID) return "<h1 style='color: darkred;text-align:center'>您已进组,不可再次进组!</h1>";
-            //if (!$laborReportNow['group_user_id']) return "<h1 style='color: darkred;text-align:center'>换组前是否已经其他组!</h1>";
             //此处表示临时工换组操作
             $newLaborReport = $laborReportService->changeGroupAndMakeLaborReport($user_id, $userWorkgroupID);
             $this->log(__METHOD__, "当日临时工换组新建临时工报表记录__" . __FUNCTION__, json_encode([$user_id, $userWorkgroupID]));
@@ -324,87 +330,4 @@ class UserDutyCheckController extends Controller
         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]);
     }
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-//$laborReport = LaborReport::where('user_id', $user_id)->where('user_workgroup_id', $userWorkgroupID)->where('created_at', 'like', Carbon::now()->format('Y-m-d'). '%')->orderBy('id', 'desc')->first();
-//    //此处表示临时工当日换组操作
-//if (!$laborReport) {
-//$newLaborReport = $laborReportService->changeGroupAndMakeLaborReport($user_id, $userWorkgroupID);
-//$this->log(__METHOD__, "当日临时工换组新建临时工报表记录__" . __FUNCTION__, json_encode([$user_id, $userWorkgroupID]));
-//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]);
-//} else if ($laborReport['enter_number'] != $laborReportNow['enter_number']) {
-//    $newLaborReport = $laborReportService->changeGroupAndMakeLaborReport($user_id, $userWorkgroupID);
-//    $this->log(__METHOD__, "当日临时工换组新建临时工报表记录__" . __FUNCTION__, json_encode([$user_id, $userWorkgroupID]));
-//    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]);
-//} else {
-//    return "<h1 style='color: darkred;text-align:center'>重复打卡!</h1>";
-//}
-
-        //进组提交打卡
-//    public function importGroupClock(Request $request)
-//    {
-//        $mobile_phone = $request->input('mobile_phone');
-//        $userWorkgroupID = $request->input('userWorkgroupID');
-//        $laborReportService = app('LaborReportService');
-//        $this->validator($request)->validate();
-//        $userDetail = UserDetail::where('mobile_phone', $mobile_phone)->first();
-//        if (Cache::has('dutyCheckTokenUser_' . $userDetail->user_id)) return "<h1 style='color: red;text-align:center'>请使用原有设备进行打卡,如无法使用原有设备请联系管理人员解绑设备!</h1>";
-//        $dateNow = Carbon::now()->format('Y-m-d');
-//        $group_name = UserWorkgroup::where('id', $userWorkgroupID)->value('name');
-//        $laravelEchoPrefix = config('database.redis.options.prefix');
-//        $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>";
-//        $userLaborToken = $userDetail->getDutyCheckToken(config('users.token_check_in_expire_minutes'));
-//        //判断是否是第一次进组
-//        $laborReport = LaborReport::where('user_id', $userDetail->user_id)->where('user_workgroup_id', null)->where('created_at', 'like', $dateNow . '%')->orderBy('id', 'desc')->first();
-//        if ($laborReport) {
-//            $newLaborReport = $laborReportService->enterGroupAndUpdateLaborReport($laborReport, $userWorkgroupID);
-//            $this->log(__METHOD__, "当日首次进组更新临时工报表记录__" . __FUNCTION__, json_encode($request->all()));
-//            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]);
-//        } else {
-//            $laborReport = LaborReport::where('user_id', $userDetail->user_id)->where('user_workgroup_id', $userWorkgroupID)->where('created_at', 'like', $dateNow . '%')->orderBy('id', 'desc')->first();
-//            //此处表示临时工当日换组操作
-//            if (!$laborReport) {
-//                $newLaborReport = $laborReportService->changeGroupAndMakeLaborReport($userDetail->user_id, $userWorkgroupID);
-//                $this->log(__METHOD__, "当日临时工换组新建临时工报表记录__" . __FUNCTION__, json_encode([$userDetail->user_id, $userWorkgroupID]));
-//                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])
-//                ->cookie('userLaborToken', $userLaborToken, config('users.token_check_in_expire_minutes'), '/');
-//            } else {
-//                return "<h1 style='color: darkred;text-align:center'>重复打卡!</h1>";
-//            }
-//        }
-//    }
-
-
     }

+ 36 - 1
app/Services/InventoryService.php

@@ -139,8 +139,14 @@ class InventoryService
             $commodity=Commodity::query()->firstOrCreate([
                 'owner_id'=>$ownerId,
                 'sku'=>$wmsInventory->产品编码,
-                'name'=>$wmsInventory->商品名称,
             ]);
+            if (!$commodity->name){
+                $commodity->name=$wmsInventory->商品名称;
+                $commodity->update();
+                Controller::logS(__METHOD__,"根据wms产品编码和货主查询或创建商品信息__".__FUNCTION__,json_encode($wmsInventory));
+            }
+            $commodity->newBarcode($wmsInventory->产品条码);
+            Controller::logS(__METHOD__,"根据wms产品条码和商品id查询或创建商品条码信息__".__FUNCTION__,json_encode($wmsInventory));
             $inventoryMission = new InventoryMission();
             $inventoryMission->commodity_id=$commodity->id;
             $inventoryMission->inventory_id=$inventoryId;
@@ -156,6 +162,35 @@ class InventoryService
             $inventoryMission->save();
         }
     }
+    //盘点库存
+    public function stockInventory($request){
+        $inventoryId=$request->inventoryId;
+        $count=$request->count;
+        $location=$request->location;
+        $barcode=$request->barcode;
+        $inventoryMission=InventoryMission::with(['commodity'=>function($query)use($barcode){
+            return $query->with(['barcodes'=>function($sql)use($barcode){
+                return $sql->where('code',$barcode);
+            }]);
+        }])->where('location',$location)->where('inventory_id',$inventoryId)->first();
+        if (!$inventoryMission) return null;
+        $inventoryMission->verified_amount=$count;
+        $inventoryMission->difference_amount=abs($inventoryMission->stored_amount-$count);
+        $inventoryMission->checked='是';
+        $inventoryMission->update();
+        Controller::logS(__METHOD__,"盘点__".__FUNCTION__,json_encode($request));
+        return $inventoryMission;
+    }
+    //盘点修改盘点任务中的已盘条数
+    public function updateInventoryMissionProcessed($request){
+        $inventoryId=$request->inventoryId;
+        $inventory=Inventory::find($inventoryId);
+        $processed=InventoryMission::where('checked','是')->where('inventory_id',$inventoryId)->count();
+        $inventory->processed=$processed;
+        $inventory->update();
+        Controller::logS(__METHOD__,"盘点修改盘点任务中的已盘条数__".__FUNCTION__,json_encode($request));
+        return $inventory;
+    }
 
 
 }

+ 0 - 3
laravel-echo-server.lock

@@ -1,3 +0,0 @@
-{
-	"process": 1304
-}

+ 2 - 2
public/js/app.js

@@ -61974,8 +61974,8 @@ module.exports = tempTip;
 /*! no static exports found */
 /***/ (function(module, exports, __webpack_require__) {
 
-__webpack_require__(/*! D:\Reald\desktop\BsWAS\src\resources\js\app.js */"./resources/js/app.js");
-module.exports = __webpack_require__(/*! D:\Reald\desktop\BsWAS\src\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");
 
 
 /***/ }),

+ 75 - 22
resources/views/inventory/stockInventory/inventoryMission.blade.php

@@ -29,23 +29,25 @@
         </span>
         </div>
         <div class="mt-4 ml-5" >
-        <span class="btn col-1 bg-info  font-weight-bold" v-if="inventory.surplus!=0">
+        <span class="btn col-1 font-weight-bold"  style="cursor: default" :class="inventory.surplus!=0?'bg-info':''">
             @{{ inventory.type }}
         </span>
-            <span v-else class="font-weight-bold">复盘</span>
+            <span class="btn btn-outline-info col-1 disabled font-weight-bold">复盘</span>
         </div>
-
-        <form id="form"  method="POST"  action='{{url('inventory/stockInventory/stockInventory/'.$inventory->owner['id'])}}' class="mt-3 pl-5">
-            @csrf
-            @method('PUT')
-            <div class="row">
+{{--        method="POST"  action='{{url('inventory/stockInventory/stockInventory/'.$inventory->owner['id'])}}' @csrf   @method('PUT')--}}
+        <form id="form"   class="mt-3 pl-5">
+            <div class="row row-cols-3">
         <span>
-            <label class="text-secondary">请输入库位</label>
-            <input id="inventoryInput" name="location" type="text" class="form-control col-8 input" @onkeydown="changeEnter()">
+            <label class="text-secondary font-weight-bold">请输入库位</label>
+            <input id="inventoryInput" name="location" type="text" class="form-control col-6 input"  autocomplete="off">
         </span>
                 <span>
-            <label class="text-secondary">请输入盘点数</label>
-            <input type="text" name="count" class="form-control col-8 input" @onkeydown="changeEnter()">
+                    <label class="text-secondary font-weight-bold">请输入产品条码</label>
+                    <input id="barcode" name="barcode" type="text" class="form-control col-6 input" autocomplete="off" @blur="searchBarcode">
+                </span>
+                <span>
+            <label class="text-secondary font-weight-bold">请输入盘点数</label>
+            <input type="text" id="count" name="count" class="form-control col-6 input"  autocomplete="off">
         </span>
             </div>
         </form>
@@ -65,15 +67,15 @@
                 <th>库存数量</th>
                 <th>可用数量</th>
                 <th>盘点数量</th>
+                <th>复盘数量</th>
                 <th>盘点差异</th>
                 <th>分配数量</th>
             </tr>
-{{--            v-if="inventoryMission.checked=='是'"--}}
-            <tr v-for="(inventoryMission,i) in inventoryMissions"  @click="selectedColor(inventoryMission.id)" :style="{'font-weight': inventory.id==selectedStyle?'bold':''}">
+            <tr v-for="(inventoryMission,i) in inventoryMissions" v-if="inventoryMission.checked=='是'"  @click="selectedColor(inventoryMission.id)" :style="{'font-weight': inventory.id==selectedStyle?'bold':''}">
                 <td>@{{ i+1 }}</td>
                 <td>@{{ inventoryMission.location }}</td>
                 <td v-if="inventoryMission.commodity">@{{ inventoryMission.commodity.name }}</td>
-                <td v-if="inventoryMission.commodity">@{{ inventoryMission.commodity.sku }}</td>
+                <td v-if="inventoryMission.commodity">@{{ inventoryMission.commodity.barcode }}</td>
                 <td >@{{ inventoryMission.produced_at }}</td>
                 <td >@{{ inventoryMission.valid_at }}</td>
                 <td >@{{ inventoryMission.stored_at }}</td>
@@ -81,28 +83,26 @@
                 <td >@{{ inventoryMission.erp_type_position }}</td>
                 <td >@{{ inventoryMission.quality }}</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>
-        <div class="text-info h5 btn btn">{{$inventoryMissions->count()}}/@{{ sum }}</div>
-        <div>{{$inventoryMissions->links()}}</div>
     </div>
 
 @endsection
 
 @section('lastScript')
     <script>
-        new Vue({
+        let listVue = new Vue({
             el: "#list",
             data: {
                 inventory:{!! $inventory!!},
-                inventoryMissions:{!! $inventoryMissions->toJson() !!}['data'],
+                inventoryMissions:{!! $inventoryMissions !!},
                 checkData: [],
                 selectedStyle:'',
-                sum:{!! $inventoryMissions->total() !!},
             },
             mounted: function () {
                 $(".tooltipTarget").tooltip({'trigger': 'hover'});
@@ -117,20 +117,73 @@
                     }
                     this.selectedStyle=id;
                 },
+                //验证输入盘点产品条码对应是否有商品
+                searchBarcode(){
+                    let barcode=document.getElementById('barcode').value;
+                    let _this=this;
+                    let barcodes=[];
+                    _this.inventoryMissions.forEach(function (inventoryMission) {
+                        barcodes.push(inventoryMission.commodity.barcode);
+                    });
+                    if (!barcodes.includes(barcode)){
+                        tempTip.setDuration(2000);
+                        tempTip.show('你输入的产品条码没有对应的产品!');
+                    }
+                },
+                //提交盘点
+                submitStockInventory(){
+                    let _this=this;
+                    let url='{{url('inventory/stockInventory')}}';
+                    let location=document.getElementById('inventoryInput').value;
+                    let barcode=document.getElementById('barcode').value;
+                    let count=document.getElementById('count').value;
+                    let inventoryId=_this.inventory.id;
+                    axios.post(url,{location:location,barcode:barcode,count:count,inventoryId:inventoryId})
+                        .then(function (response) {
+                            if (!response.data.success){
+                                tempTip.setDuration(2000);
+                                tempTip.show('盘点失败!'+'   '+response.data.data);
+                            }else {
+                                if (_this.inventory.id==response.data.inventory.id){
+                                    _this.inventory.processed=response.data.inventory.processed;
+                                    _this.inventory.surplus=response.data.inventory.surplus;
+                                }
+                                _this.inventoryMissions.every(function (inventoryMission,i) {
+                                    if (inventoryMission.id==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;
+                                        _this.inventoryMissions.splice(i,1)
+                                        _this.inventoryMissions.unshift(inventoryMission);
+                                        return false;
+                                    }
+                                    return true;
+                                });
+                                tempTip.setDuration(3000);
+                                tempTip.showSuccess('盘点成功!');
+                            }
+                    }).catch(function (err) {
+                        tempTip.setDuration(2000);
+                        tempTip.show('盘点失败!'+'网络错误'+err);
+                    })
+                },
             }
         });
         $("#form").on("keydown","input",function(){
+            let _this=this;
             let e = event || window.event;
             if(e && e.keyCode==13) {
                 let inputs = $("#form .input");
                 let idx = inputs.index(this);     // 获取当前焦点输入框所处的位置
-                let inputValue=document.getElementById('inventoryInput').value;
+                let location=document.getElementById('inventoryInput').value;
                 if (idx == inputs.length - 1) {       // 判断是否是最后一个输入框
-                    if (inputValue==''||inputValue==undefined||inputValue==null){
+                    if (location==''||location==undefined||location==null){
                         document.getElementById('inventoryInput').focus();
                         return;
                     }
-                    $("#form").submit(); // 提交表单
+                    listVue.submitStockInventory();
+                    $("#form .input").val('');
+                    document.getElementById('inventoryInput').focus();
                 } else {
                     inputs[idx + 1].focus(); // 设置焦点
                     inputs[idx + 1].select(); // 选中文字

+ 1 - 1
routes/web.php

@@ -302,7 +302,7 @@ Route::group(['prefix'=>'inventory'],function (){
     Route::any('stockInventory/enterStockInventory/{id}','InventoryController@enterStockInventory');
     //盘点任务导出
     Route::any('stockInventoryExport','InventoryController@stockInventoryExport');
-    Route::any('stockInventory/stockInventory/{id}','InventoryController@stockInventory');
+    Route::any('stockInventory','InventoryController@stockInventory');
 });
 
 /**