haozi 5 rokov pred
rodič
commit
6fa0c16109

+ 0 - 1
app/Events/ImportEvent.php

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

+ 94 - 3
app/Http/Controllers/InventoryController.php

@@ -3,7 +3,11 @@
 namespace App\Http\Controllers;
 
 use App\Exports\Export;
+use App\Inventory;
+use App\InventoryMission;
 use App\OracleBasCustomer;
+use App\Owner;
+use App\Services\InventoryService;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Gate;
@@ -11,8 +15,13 @@ use Maatwebsite\Excel\Facades\Excel;
 
 class InventoryController extends Controller
 {
+    public function __construct()
+    {
+        app()->singleton('inventoryService',InventoryService::class);
+    }
+
     public function conditionQuery(Request $request,$page=null,$paginate=null){
-        if(!Gate::allows("库存管理-动库报表")){ return redirect(url('/'));  }
+        if(!Gate::allows("库存管理-库存")){ return redirect(url('/'));  }
         $date_start=$request->input('date_start');
         $range = $request->input('range');
         if ($range)$date_start=date('Y-m-d',strtotime('-'.$range." day"));
@@ -85,7 +94,7 @@ class InventoryController extends Controller
         if ($page&&$paginate)$sql.="  where rn>'".($page-1)*$paginate."'";
         return DB::connection('oracle')->select($sql);
     }
-
+    //动库报表
     public function changeInventory(Request $request){
         $page=$request->input('page')??1;
         $paginate=$request->input('paginate')??50;
@@ -94,7 +103,16 @@ class InventoryController extends Controller
         $owners=OracleBasCustomer::select('descr_c')->where('customer_type','OW')->where('active_flag','Y')->get();
         return view('inventory.statement.changeInventory',compact('oracleActTransactingLogs','page','owners'));
     }
-
+    //全部库存
+    public function allInventory(Request $request){
+        if(!Gate::allows("库存管理-库存")){ return redirect(url('/'));  }
+        $page=$request->page??1;
+        $paginate=$request->input('paginate')??50;
+        $oracleActTransactingLogs=$this->conditionQuery($request,$page,$paginate);
+        $oracleActTransactingLogs=json_encode($oracleActTransactingLogs);
+        $owners=OracleBasCustomer::select('descr_c')->where('customer_type','OW')->where('active_flag','Y')->get();
+        return view('inventory.statement.allInventory',compact('oracleActTransactingLogs','page','owners'));
+    }
     public function exportData(Request $request){
         if (!$request->checkAllSign){
             $oracleActTransactingLogs=json_decode($request->input('data'),true);
@@ -143,4 +161,77 @@ class InventoryController extends Controller
         }
         return Excel::download(new Export($row,$list),date('YmdHis', time()).'-动库报表单.xlsx');
     }
+
+    //创建盘点任务
+    public function createStockInventoryMission(Request $request){
+        if(!Gate::allows("库存管理-盘点")){ return redirect(url('/'));  }
+        $inventory=app('inventoryService')->createMission($request);
+        if (is_null($inventory)) return ['success'=>false,'data'=>'参数错误!'];
+        return ['success'=>true,'data'=>$inventory];
+    }
+
+    //盘点-任务页面
+    public function mission(Request $request){
+        if(!Gate::allows("库存管理-盘点")){ return redirect(url('/'));  }
+        $paginateParams = $request->input();
+        $inventories=app('inventoryService')->paginate($request);
+        $owners=Owner::select('id','name')->get();
+        return view('inventory.stockInventory.mission',compact('owners','inventories','paginateParams'));
+    }
+    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');
+            $inventories=app('inventoryService')->get($request);
+        }else{
+            $inventories=app('inventoryService')->some($request);
+        }
+        $row=[[
+            'id'=>'盘点编号',
+            'created_at'=>'创建时间',
+            'owner_id'=>'货主',
+            'type'=>'任务类型',
+            'start_at'=>'起始时间',
+            'end_at'=>'结束时间',
+            'total'=>'记录数',
+            'processed'=>'已盘数',
+            'surplus'=>'剩余数',
+            'difference'=>'复盘差异',
+            'returned'=>'复盘归位',
+        ]];
+        $list=[];
+        for ($i=0; $i<count($inventories);$i++){
+            $inventory=$inventories[$i];
+            $w=[
+                'id'=>isset($inventory->id)?$inventory->id:'',
+                'created_at'=>isset($inventory->created_at)?$inventory->created_at:'',
+                'owner_id'=>isset($inventory->owner->name)?$inventory->owner->name:'',
+                'type'=>isset($inventory->type)?$inventory->type:'',
+                'start_at'=>isset($inventory->start_at)?$inventory->start_at:'',
+                'end_at'=>isset($inventory->end_at)?$inventory->end_at:'',
+                'total'=>isset($inventory->total)?$inventory->total:'',
+                'processed'=>isset($inventory->processed)?$inventory->processed:'',
+                'surplus'=>isset($inventory->surplus)?$inventory->surplus:'',
+                'difference'=>isset($inventory->difference)?$inventory->difference:'',
+                'returned'=>isset($inventory->returned)?$inventory->returned:'',
+            ];
+            $list[$i]=$w;
+        }
+        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'));
+    }
 }

+ 85 - 0
app/Http/Controllers/InventoryMissionController.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\InventoryMission;
+use Illuminate\Http\Request;
+
+class InventoryMissionController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\InventoryMission  $inventoryMission
+     * @return \Illuminate\Http\Response
+     */
+    public function show(InventoryMission $inventoryMission)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\InventoryMission  $inventoryMission
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(InventoryMission $inventoryMission)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\InventoryMission  $inventoryMission
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, InventoryMission $inventoryMission)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\InventoryMission  $inventoryMission
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(InventoryMission $inventoryMission)
+    {
+        //
+    }
+}

+ 85 - 0
app/Http/Controllers/StockInventoryController.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\StockInventory;
+use Illuminate\Http\Request;
+
+class StockInventoryController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\StockInventory  $stockInventory
+     * @return \Illuminate\Http\Response
+     */
+    public function show(StockInventory $stockInventory)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\StockInventory  $stockInventory
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(StockInventory $stockInventory)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\StockInventory  $stockInventory
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, StockInventory $stockInventory)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\StockInventory  $stockInventory
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(StockInventory $stockInventory)
+    {
+        //
+    }
+}

+ 2 - 2
app/Http/Controllers/UserDutyCheckController.php

@@ -64,7 +64,7 @@ class UserDutyCheckController extends Controller
         return view("personnel/checking-in/importAndExportClock", compact('importAndExportQRCodeType'));
     }
 
-    //提交进场打卡
+    //输入手机号提交进场打卡
     public function storeClock(Request $request)
     {
         $importAndExportQRCodeType = $request->input('importAndExportQRCodeType');
@@ -289,7 +289,7 @@ class UserDutyCheckController extends Controller
             $user_id = Cache::get('dutyCheckTokenStr_' . $userLaborToken);
             $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>";
+            if (!$userDutyCheck['verify_user_id']) return "<h1 style='color: red;text-align:center'>进场门卫还未审核,暂无法进组!</h1>";
             if ($userDutyCheck->type == '登出') return "<h1 style='color: red;text-align:center'>进场是否未打卡?如若未打,请先返回打进场卡!</h1>";
             $html=$this->updateLaborReport($user_id,$userWorkgroupID);
             if ($html)return $html;

+ 30 - 0
app/Inventory.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App;
+
+use App\Traits\ModelTimeFormat;
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\SoftDeletes;
+
+class Inventory extends Model
+{
+    use ModelTimeFormat;
+    use SoftDeletes;
+    protected $fillable=[
+        'id','owner_id','owner_id','type', 'start_at', 'end_at','total','processed','difference','returned','deleted_at','created_at',
+    ];
+    protected $appends = [
+            'surplus'
+    ];
+    public function owner(){
+        return $this->belongsTo('App\Owner','owner_id','id');
+    }
+    public function inventoryMissions(){
+        return $this->belongsTo('App\InventoryMission','id','inventory_id');
+    }
+
+    public function getSurplusAttribute()
+    {
+        return $this['total'] ? $this['total']-$this['processed']:null;
+    }
+}

+ 16 - 0
app/InventoryMission.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class InventoryMission extends Model
+{
+    protected $fillable=[
+        'id','inventory_id','location','commodity_id', 'produced_at', 'valid_at','stored_at','batch_number','erp_type_position','quality','stored_amount','valid_amount',
+        'verified_amount','re_checked_amount','difference_amount','occupied_amount','checked',
+    ];
+    public function commodity(){
+        return $this->belongsTo('App\Commodity','commodity_id','id');
+    }
+}

+ 0 - 4
app/LaborReport.php

@@ -7,10 +7,7 @@ use Illuminate\Database\Eloquent\Model;
 use App\Traits\ModelTimeFormat;
 use Illuminate\Database\Eloquent\SoftDeletes;
 use Illuminate\Support\Arr;
-use Illuminate\Support\Collection;
 use Illuminate\Support\Facades\Auth;
-use Illuminate\Support\Facades\Gate;
-use function Matrix\add;
 
 class LaborReport extends Model
 {
@@ -34,7 +31,6 @@ class LaborReport extends Model
     static function tokenOfBroadcastEnterAndLeave(){
         return md5('tokenOfListAll'.Carbon::now()->format('Y-m-d'));
     }
-
     public function userWorkgroup(){
         return $this->belongsTo('App\UserWorkgroup','user_workgroup_id','id');
     }

+ 161 - 0
app/Services/InventoryService.php

@@ -0,0 +1,161 @@
+<?php
+
+
+namespace App\Services;
+
+use App\Commodity;
+use App\Http\Controllers\Controller;
+use App\Inventory;
+use App\InventoryMission;
+use App\OraccleBasCustomer;
+use App\OracleActTransactionLog;
+use App\Owner;
+use App\Services\common\QueryService;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Gate;
+
+class InventoryService
+{
+
+    private function conditionQuery(Request $request){
+        $inventories=Inventory::query()->with(['owner'])->orderBy('id','desc');
+        $columnQueryRules=[
+            'owner_id' => ['multi' => ','],
+            'date_start' => ['alias' => 'created_at' , 'startDate' => ' 00:00:00'],
+            'date_end' => ['alias' => 'created_at' , 'endDate' => ' 23:59:59'],
+        ];
+        $inventories = app(QueryService::class)->query($request,$inventories,$columnQueryRules);
+        return $inventories;
+    }
+    public function paginate(Request $request){
+        $inventories = $this->conditionQuery($request);
+        return $inventories->paginate($request->paginate ?? 50);
+    }
+
+    public function get(Request $request){
+        $inventories = $this->conditionQuery($request);
+        return $inventories->get();
+    }
+
+    public function some(Request $request){
+        return Inventory::query()->with(['owner'])->orderBy('id','DESC')
+            ->whereIn('id',explode(',',$request->data))->get();
+    }
+
+    public function conditionSearch(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];
+        $descr_c=Owner::where('id',$ownerId)->value('name');
+        $sql='select * from (select result.*,rownum rn from (';
+        $sql.=' select customer.Descr_C as 货主,stockLog.客户 客户, 库位, sku.SKU 产品编码, sku.ALTERNATE_SKU1 产品条码, ';
+        $sql.=' sku.Descr_C 商品名称, lot.LotAtt05 属性仓, lot.LotAtt08 质量状态, lot.LotAtt02 失效日期, ';
+        $sql.=' lot.LotAtt04 批号, lot.LotAtt01 生产日期, lot.LotAtt03 入库日期';
+        $sql.=' , sum(移出数量)移出数量, sum(移入数量)移入数量 ';
+        $sql.=' , storeStatus.QTY 在库数量, storeStatus.QtyAllocated 占用数量,count(1) over () as sum from ';
+        $sql.=' (select FMLotNum,FMSKU,TOCustomerID 客户,0 as 移出数量, sum(TOQty_Each) as 移入数量, TOLocation as 库位 ';
+        $sql.=" from ACT_Transaction_Log where TransactionType='PA' ";
+        if ($date_start) $sql.=" and addtime > to_date('".$date_start." 00:00:00','yyyy-mm-dd hh24:mi:ss') ";
+        if ($date_end) $sql.=" and addtime < to_date('".$date_end." 23:59:59','yyyy-mm-dd hh24:mi:ss') ";
+        $sql.=' group by TOCustomerID, TOLocation,FMSKU,FMLotNum union all ';
+        $sql.=' select FMLotNum,FMSKU,FMCUSTOMERID 客户,sum(FMQty_Each) as 移出数量, 0 as 移入数量, FMLOCATION as 库位 ';
+        $sql.=" from ACT_Transaction_Log where TransactionType='SO' ";
+        if ($date_start) $sql.=" and addtime > to_date('".$date_start." 00:00:00','yyyy-mm-dd hh24:mi:ss') ";
+        if ($date_end) $sql.=" and addtime < to_date('".$date_end." 23:59:59','yyyy-mm-dd hh24:mi:ss') ";
+        $sql.=' group by FMCustomerID, FMLocation,FMSKU,FMLotNum union all ';
+        $sql.=' select FMLotNum,FMSKU,FMCUSTOMERID 客户,sum(FMQty_Each) as 移出数量,0 as 移入数量, FMLocation as 库位 ';
+        $sql.=" from ACT_Transaction_Log  where TransactionType='MV' ";
+        if ($date_start) $sql.=" and addtime > to_date('".$date_start." 00:00:00','yyyy-mm-dd hh24:mi:ss') ";
+        if ($date_end) $sql.=" and addtime < to_date('".$date_end." 23:59:59','yyyy-mm-dd hh24:mi:ss') ";
+        $sql.=' group by FMLocation,FMCUSTOMERID,FMSKU,FMLotNum union all ';
+        $sql.=' select FMLotNum,FMSKU,TOCustomerID 客户,0 as 移出数量,sum(TOQty_Each)as 移入数量, TOLocation as 库位 ';
+        $sql.=" from ACT_Transaction_Log where TransactionType='MV' ";
+        if ($date_start) $sql.=" and addtime > to_date('".$date_start." 00:00:00','yyyy-mm-dd hh24:mi:ss') ";
+        if ($date_end) $sql.=" and addtime < to_date('".$date_end." 23:59:59','yyyy-mm-dd hh24:mi:ss') ";
+        $sql.=' group by TOLocation,TOCustomerID,FMSKU,FMLotNum)stockLog ';
+        $sql.=' left join BAS_Customer customer on customer.CustomerID=stockLog.客户 ';
+        $sql.=' left join BAS_SKU sku on sku.SKU=stockLog.FMSKU and sku.CUSTOMERID=stockLog.客户 ';
+        $sql.=' left join INV_LOT_ATT lot on lot.LOTNUM=stockLog.FMLOTNUM ';
+        $sql.=' left join INV_LOT_LOC_ID storeStatus on storeStatus.LOTNUM=stockLog.FMLOTNUM ';;
+        $sql.=' and storeStatus.LocationID=stockLog.库位 ';
+        $sql.=' group by 库位,customer.Descr_C,sku.SKU,sku.ALTERNATE_SKU1 ';
+        $sql.=' ,sku.Descr_C,FMLotNum,lot.LotAtt05,lot.LotAtt01,lot.LotAtt03,lot.LotAtt08,lot.LotAtt02,lot.LotAtt04 ';
+        $sql.=' , storeStatus.QTY, storeStatus.QtyAllocated,stockLog.客户  ';
+        $sql.=' )result where 1=1 ';
+        if ($descr_c){
+            $sql .= ' and 货主 in (';
+            $descr_cs = explode(',',$descr_c);
+            foreach ($descr_cs as $index => $descr_c){
+                if ($index != 0)$sql .= ',';
+                $sql .= "'".$descr_c."'";
+            }
+            $sql .= ') ';
+        }
+        $sql.=' )  ';
+        return DB::connection('oracle')->select($sql);
+    }
+    //创建盘点任务
+    public function createMission(Request $request){
+        if(!Gate::allows("库存管理-盘点")){ return redirect(url('/'));  }
+        $date_start=$request->input('formData.date_start');
+        $date_end=$request->input('formData.date_end');
+        $ownerIds=$request->input('formData.owner_id');
+        if (count($ownerIds)<=0) return null;
+        if ($date_start&&$date_end){
+            $type='动盘';
+        }elseif (!$date_start&&!$date_end){
+            $name=Owner::where('id',$ownerIds[0])->value('name');
+            $ownerName=OraccleBasCustomer::where('customer_type','OW')->where('active_flag','Y')->where('descr_c',$name)->value('customerid');
+            $date_start=OracleActTransactionLog::where('fmcustomerid',$ownerName)->orderBy('addtime','asc')->value('addtime');
+            $date_end=OracleActTransactionLog::where('fmcustomerid',$ownerName)->orderBy('addtime','desc')->value('addtime');
+            $type='全盘';
+        }else{
+            return null;
+        }
+        $ownerId=$ownerIds[0];
+        $inventory=new Inventory([
+            'owner_id'=>$ownerId,
+            'type'=>$type,
+            'start_at'=>$date_start,
+            'end_at'=>$date_end,
+        ]);
+        $inventory->save();
+        $this->createInventoryMissionRecord($request,$inventory['id'],$ownerId);
+        Controller::logS(__METHOD__,"创建盘点记录任务__".__FUNCTION__,json_encode($request,$inventory['id'],$ownerId),Auth::user()['id']);
+        $inventoryMissionCount=InventoryMission::where('inventory_id',$inventory['id'])->count();
+        $inventory->total=$inventoryMissionCount;
+        $inventory->update();
+        Controller::logS(__METHOD__,"创建盘点任务__".__FUNCTION__,json_encode($request),Auth::user()['id']);
+        return $inventory;
+    }
+
+    //创建盘点记录任务
+    public function createInventoryMissionRecord($request,$inventoryId,$ownerId){
+        $wmsInventories=$this->conditionSearch($request);
+        foreach ($wmsInventories as $wmsInventory){
+            $commodity=Commodity::query()->firstOrCreate([
+                'owner_id'=>$ownerId,
+                'sku'=>$wmsInventory->产品编码,
+                'name'=>$wmsInventory->商品名称,
+            ]);
+            $inventoryMission = new InventoryMission();
+            $inventoryMission->commodity_id=$commodity->id;
+            $inventoryMission->inventory_id=$inventoryId;
+            $inventoryMission->location=$wmsInventory->库位;
+            $inventoryMission->produced_at=$wmsInventory->生产日期;
+            $inventoryMission->valid_at=$wmsInventory->失效日期;
+            $inventoryMission->stored_at=$wmsInventory->入库日期;
+            $inventoryMission->batch_number=$wmsInventory->批号;
+            $inventoryMission->erp_type_position=$wmsInventory->属性仓;
+            $inventoryMission->quality=$wmsInventory->质量状态;
+            $inventoryMission->stored_amount=$wmsInventory->在库数量;
+            $inventoryMission->occupied_amount=$wmsInventory->占用数量;
+            $inventoryMission->save();
+        }
+    }
+
+
+}

+ 47 - 0
database/migrations/2020_08_07_105142_change_authorities_inventory.php

@@ -0,0 +1,47 @@
+<?php
+
+use App\Authority;
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class ChangeAuthoritiesInventory extends Migration
+{
+    protected $changeNames=[
+        ["库存管理-动库报表","库存管理-库存"],
+    ];
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        //修改或没有则添加
+        foreach ($this->changeNames as $namePack){
+            $authority=Authority::where('name',$namePack[0])->orWhere('name',$namePack[1])->first();
+            if(!$authority){
+                (new Authority(['name'=>$namePack[1],'alias_name'=>$namePack[1]]))->save();
+            }elseif($authority['name']==$namePack[0]){
+                $authority['name']=$namePack[1];
+                $authority['alias_name']=$namePack[1];
+                $authority->save();
+            }
+        }
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        //改回旧的
+        foreach ($this->changeNames as $namePack){
+            $authority=Authority::where('name',$namePack[1])->first();
+            $authority['name']=$namePack[0];
+            $authority->save();
+        }
+    }
+}

+ 29 - 0
database/migrations/2020_08_07_134547_add_authorities_inventory.php

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

+ 40 - 0
database/migrations/2020_08_07_144503_create_inventories_table.php

@@ -0,0 +1,40 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateInventoriesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('inventories', function (Blueprint $table) {
+            $table->bigIncrements('id');
+            $table->integer('owner_id')->index();
+            $table->enum('type',['全盘','动盘'])->comment('盘点类型');
+            $table->timestamp('start_at')->nullable();
+            $table->timestamp('end_at')->nullable();
+            $table->integer('total')->nullable()->comment('记录数');
+            $table->integer('processed')->default(0)->comment('已盘数');
+            $table->integer('difference')->default(0)->comment('复盘差异');
+            $table->integer('returned')->default(0)->comment('复盘归位');
+            $table->timestamp('deleted_at')->index()->nullable();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('inventories');
+    }
+}

+ 48 - 0
database/migrations/2020_08_07_151618_create_inventory_missions_table.php

@@ -0,0 +1,48 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateInventoryMissionsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('inventory_missions', function (Blueprint $table) {
+            $table->bigIncrements('id');
+            $table->integer('inventory_id')->index();
+            $table->string('location')->index()->comment('库位');
+            $table->integer('commodity_id')->index()->comment('商品id');
+            $table->timestamp('produced_at')->nullable()->comment('生产日期');
+            $table->timestamp('valid_at')->nullable()->comment('失效日期');
+            $table->timestamp('stored_at')->nullable()->comment('入库日期');
+            $table->string('batch_number')->nullable()->comment('批号');
+            $table->string('erp_type_position')->nullable()->comment('erp属性仓');
+            $table->string('quality')->nullable()->comment('质量状态');
+            $table->integer('stored_amount')->nullable()->comment('库存数量');
+            $table->integer('valid_amount')->default(0)->comment('可用数量');
+            $table->integer('verified_amount')->nullable()->comment('盘点数量');
+            $table->integer('re_checked_amount')->nullable()->comment('复盘数量');
+            $table->integer('difference_amount')->nullable()->comment('盘点差异');
+            $table->integer('occupied_amount')->nullable()->comment('分配数量');
+            $table->enum('checked',['是','否'])->default('否')->comment('已盘点');
+            $table->enum('returned',['是','否','无'])->default('无')->comment('已归位');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('inventory_missions');
+    }
+}

+ 3 - 0
laravel-echo-server.lock

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

+ 7 - 3
resources/views/inventory/menu.blade.php

@@ -3,9 +3,13 @@
     <div class="card">
         <ul class="nav nav-pills">
             @can('库存管理')
-            <li class="nav-item">
-                <a class="nav-link" href="{{url('inventory/statement/changeInventory?range=1')}}" :class="{active:isActive('statement',2)}">查询</a>
-            </li> @endcan
+                <li class="nav-item">
+                    <a class="nav-link" href="{{url('inventory/statement/changeInventory?range=1')}}" :class="{active:isActive('statement',2)}">库存</a>
+                </li> @endcan
+            @can('库存管理-盘点')
+                <li class="nav-item">
+                    <a class="nav-link" href="{{url('inventory/stockInventory/mission')}}" :class="{active:isActive('stockInventory',2)}">盘点</a>
+                </li> @endcan
         </ul>
     </div>
 </div>

+ 200 - 0
resources/views/inventory/statement/allInventory.blade.php

@@ -0,0 +1,200 @@
+@extends('layouts.app')
+@section('title')库存管理-全部库存@endsection
+
+@section('content')
+    @component('inventory.statement.menu')@endcomponent
+<div id="list" class="d-none card container-fluid" style="min-width: 1500px">
+    <div id="form_div"></div>
+    <span class="dropdown">
+        <button class="btn btn-outline-dark btn-sm form-control-sm dropdown-toggle tooltipTarget" :class="[checkData.length>0?'btn-dark text-light':'']"
+                data-toggle="dropdown" title="导出所有页将会以搜索条件得到的过滤结果,将其全部记录(每一页)导出">
+            导出Excel
+        </button>
+        <div class="dropdown-menu">
+            <a class="dropdown-item" @click="processExport(false)" href="javascript:">导出勾选内容</a>
+            <a class="dropdown-item" @click="processExport(true)" href="javascript:">导出所有页</a>
+        </div>
+    </span>
+    <table class="table table-sm table-striped table-bordered table-hover text-nowrap card-body mt-2">
+        <tr>
+            <th>
+                <label for="all">
+                    <input id="all" type="checkbox" @click="checkAll($event)">全选
+                </label>
+            </th>
+            <th>序号</th>
+            <th>货主</th>
+            <th>库位</th>
+            <th>产品编码</th>
+            <th>产品条码</th>
+            <th>商品名称</th>
+            <th>属性仓</th>
+            <th>质量状态</th>
+            <th>失效日期</th>
+            <th>批号</th>
+            <th>在库数量</th>
+            <th>占用数量</th>
+        </tr>
+        <tr v-for="(oracleActTransactingLog,i) in oracleActTransactingLogs">
+            <td>
+                <input class="checkItem" type="checkbox" :value="oracleActTransactingLog" v-model="checkData">
+            </td>
+            <td>@{{ i+1 }}</td>
+            <td class="text-primary">@{{ oracleActTransactingLog.货主 }}</td>
+            <td class="text-muted">@{{ oracleActTransactingLog.库位 }}</td>
+            <td class="text-muted">@{{ oracleActTransactingLog.产品编码 }}</td>
+            <td class="text-muted">@{{ oracleActTransactingLog.产品条码 }}</td>
+            <td :title="oracleActTransactingLog.商品名称" class="tooltipTarget" style="max-width: 200px;overflow:hidden">@{{ oracleActTransactingLog.商品名称 }}</td>
+            <td class="text-muted">@{{ oracleActTransactingLog.属性仓 }}</td>
+            <td class="text-muted">@{{ oracleActTransactingLog.质量状态 }}</td>
+            <td class="text-muted">@{{ oracleActTransactingLog.失效日期 }}</td>
+            <td class="text-muted">@{{ oracleActTransactingLog.批号 }}</td>
+            <td><span v-if="oracleActTransactingLog.在库数量">@{{ oracleActTransactingLog.在库数量 }}</span><span v-else>0</span></td>
+            <td><span v-if="oracleActTransactingLog.占用数量">@{{ oracleActTransactingLog.占用数量 }}</span><span v-else>0</span></td>
+        </tr>
+    </table>
+    <div>
+        <button type="button" @click="pageUp()" :readonly="page>1?false:true" class="btn btn-sm " :class="page>1?'btn-outline-info':''">上一页</button>
+        <button type="button" @click="pageDown()" :readonly="page<maxPage?false:true" class="btn btn-sm m-3" :class="page<maxPage?'btn-outline-info':''">下一页</button>
+        <div v-if="isPage">
+            <input  @keyup.enter="pageSkip($event)" class="form-control-sm ml-3 tooltipTarget" :placeholder="'当前页数:'+page+'/'+maxPage" title="去往指定页">
+            <span class="text-muted m-1">共 @{{ sum }} 条</span>
+        </div>
+    </div>
+</div>
+@endsection
+
+@section('lastScript')
+    <script type="text/javascript" src="{{asset('js/queryForm/export200804.js')}}"></script>
+    <script type="text/javascript" src="{{asset('js/queryForm/queryForm200805b.js')}}"></script>
+    <script>
+        $.cookie('xxx', 2223);
+        new Vue({
+            el:"#list",
+            data:{
+                oracleActTransactingLogs:{!! $oracleActTransactingLogs !!},
+                page:Number('{{$page}}'),
+                owners:[
+                    @foreach($owners as $owner)
+                    {name:'{{$owner->descr_c}}',value:'{{$owner->descr_c}}'},
+                    @endforeach
+                ],
+                checkData:[],
+                maxPage:1,
+                sum:0,
+                isPage:true,
+                date:[{name:'1',value:'近一天'},{name:'3',value:'近三天'},{name:'7',value:'近一周'},{name:'30',value:'近一月'},],
+            },
+            mounted:function () {
+                $(".tooltipTarget").tooltip({'trigger':'hover'});
+                $("#list").removeClass('d-none');
+                if (this.oracleActTransactingLogs.length>0){
+                    this.maxPage=Math.ceil(this.oracleActTransactingLogs[0].sum/50);
+                    this.sum=this.oracleActTransactingLogs[0].sum;
+                }
+                let data=[
+                    [
+                        {name:['date_start','range'],type:'dateTime_select',tip:['选择创建日期的起始时间','查询内容的日期范围'],placeholder:['','查询内容的日期范围'],data: this.date
+                            ,killings:[['range'],['date_start']]},
+                        {name:'TOLocation',type:'input',tip:'库位:糊模查找需要在左边打上%符号',placeholder: '库位'},
+                        {name:'LotAtt05',type:'input',tip:'属性仓:糊模查找需要在左边打上%符号',placeholder: '属性仓'},
+                        {name:'LotAtt02_start',type:'dateTime',tip:'选择显示失效日期的起始时间'},
+                        {name:'descr_c',type:'select_multiple_select',tip:['输入关键词快速定位下拉列表,回车确定','选择要显示的客户'],
+                            placeholder:['货主','定位或多选货主'],data:this.owners},
+                    ],
+                    [
+                        {name:'date_end',type:'dateTime',tip:'选择创建日期的结束时间',killings:['range']},
+                        {name:'SKU',type:'input',tip:'产品编码:糊模查找需要在左边打上%符号',placeholder: '产品编码'},
+                        {name:'ALTERNATE_SKU1',type:'input',tip:'产品条码:糊模查找需要在左边打上%符号',placeholder: '产品条码'},
+                        {name:'LotAtt02_end',type:'dateTime',tip:'选择显示失效日期的结束时间'},
+                    ],
+                ];
+                this.form = new query({
+                    el:'#form_div',
+                    condition:data
+                });
+                this.form.init();
+                let thisUrl=document.URL;
+                let parameter=thisUrl.split('?',2);
+                if (parameter.length > 1){
+                    let _this=this;
+                    let list=['ALTERNATE_SKU1','LotAtt05','LotAtt02_start','descr_c','LotAtt02_end'];
+                    let param=parameter[1].split('&');
+                    param.every(function (data) {
+                        let arr=data.split('=');
+                        if (arr.length > 1){
+                            if (list.includes(arr[0]) && arr[1]){
+                                _this.isPage = false;
+                                return false;
+                            }
+                        }
+                        return true;
+                    });
+                }
+            },
+            watch:{
+                checkData:{
+                    handler(){
+                        if (this.checkData.length === this.oracleActTransactingLogs.length){
+                            document.querySelector('#all').checked = true;
+                        }else {
+                            document.querySelector('#all').checked = false;
+                        }
+                    },
+                    deep:true
+                }
+            },
+            methods:{
+                pageUp(){
+                    if (this.page<=1)return;
+                    this.href(this.page-1);
+                },
+                pageDown(){
+                    if (this.page>=this.maxPage)return;
+                    this.href(this.page+1);
+                },
+                pageSkip(e){
+                    if (Number(e.target.value)<=0 || Number(e.target.value)>this.maxPage){
+                        tempTip.setDuration(2000);
+                        tempTip.show('页数不存在! ');
+                        return
+                    }
+                    this.href(e.target.value);
+                },
+                href(page){
+                    let url = document.URL;
+                    if (url.indexOf('page='+this.page) != -1){
+                        url = url.replace("page="+this.page,"page="+page);
+                    }else{
+                        if (url.indexOf('?') == -1) url += "?page="+page;
+                        else url += "&page="+page;
+                    }
+                    window.location.href=url;
+                },
+                //全选事件
+                checkAll(e){
+                    if (e.target.checked){
+                        this.oracleActTransactingLogs.forEach((el,i)=>{
+                            if (this.checkData.indexOf(el) == '-1'){
+                                this.checkData.push(el);
+                            }
+                        });
+                    }else {
+                        this.checkData = [];
+                    }
+                },
+                processExport(checkAllSign){
+                    let url = '{{url('inventory/statement/changeInventory/export')}}';
+                    let token='{{ csrf_token() }}';
+                    let data= JSON.stringify( this.checkData );
+                    excelExport(checkAllSign,data,url,this.sum,token);
+                },
+            },
+            filters:{
+                json(value) {
+                    return JSON.stringify(value);
+                }
+            },
+        });
+    </script>
+@endsection

+ 4 - 1
resources/views/inventory/statement/changeInventory.blade.php

@@ -1,5 +1,6 @@
 @extends('layouts.app')
-@section('title')库存管理@endsection
+@section('title')库存管理-动库报表@endsection
+
 
 @section('content')
     @component('inventory.statement.menu')@endcomponent
@@ -66,6 +67,7 @@
         </div>
     </div>
 </div>
+
 @endsection
 
 @section('lastScript')
@@ -202,3 +204,4 @@
         });
     </script>
 @endsection
+

+ 6 - 2
resources/views/inventory/statement/menu.blade.php

@@ -4,9 +4,13 @@
     <div class="container-fluid nav3">
         <div class="card menu-third" >
             <ul class="nav nav-pills">
-                @can('库存管理-动库报表')
+                @can('库存管理-库存')
                     <li class="nav-item">
-                        <a class="nav-link text-dark" href="{{url('inventory/statement/changeInventory?range=1')}}" :class="{active:isActive('changeInventory',3)}">动库报表</a>
+                        <a class="nav-link" href="{{url('inventory/statement/changeInventory?range=1')}}" :class="{active:isActive('changeInventory',3)}">动库报表</a>
+                    </li> @endcan
+                @can('库存管理-库存')
+                    <li class="nav-item">
+                        <a class="nav-link" href="{{url('inventory/statement/allInventory')}}" :class="{active:isActive('allInventory',3)}">全部库存</a>
                     </li> @endcan
             </ul>
         </div>

+ 142 - 0
resources/views/inventory/stockInventory/inventoryMission.blade.php

@@ -0,0 +1,142 @@
+@extends('layouts.app')
+@section('title')盘点-任务-{!! $inventory->id !!}@endsection
+
+
+@section('content')
+    @component('inventory.stockInventory.menu')
+        <li class="nav-item">
+            <a class="nav-link" href="{{URL::current()}}" :class="{active:isActive('enterStockInventory',3)}">盘点中({!! $inventory->id !!})</a>
+        </li>
+    @endcomponent
+    <div id="list" class="container-fluid" style="min-width: 1500px">
+        <div class="mt-3 pl-5">
+        <span class="form-group pl-5 shadow-sm p-2 mb-5 bg-white rounded">
+            <label class="col-1 font-weight-bold">货主:</label><span>@{{ inventory.owner.name }}</span>
+        </span>
+            <span class="form-group pl-5 shadow-sm p-2 mb-5 bg-white rounded">
+            <label class="col-1 font-weight-bold">盘点单号:</label><span>@{{ inventory.id }}</span>
+        </span>
+        </div>
+        <div class="mt-3 pl-5">
+        <span class="form-group pl-5 shadow-sm p-2 mb-5 bg-white rounded">
+            <label class="col-1 font-weight-bold">时间范围:</label><span>@{{ inventory.start_at }}——@{{ inventory.end_at }}</span>
+        </span>
+            <span class="form-group pl-5 shadow-sm p-2 mb-5 bg-white rounded">
+            <label class="col-1 font-weight-bold">已盘点:</label><span>@{{ inventory.processed }}/总数:@{{ inventory.total }}</span>
+        </span>
+            <span class="form-group pl-5 shadow-sm p-2 mb-5 bg-white rounded">
+            <label class="col-1 font-weight-bold">剩余数:</label><span>@{{ inventory.surplus }}</span>
+        </span>
+        </div>
+        <div class="mt-4 ml-5" >
+        <span class="btn col-1 bg-info  font-weight-bold" v-if="inventory.surplus!=0">
+            @{{ inventory.type }}
+        </span>
+            <span v-else class="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">
+        <span>
+            <label class="text-secondary">请输入库位</label>
+            <input id="inventoryInput" name="location" type="text" class="form-control col-8 input" @onkeydown="changeEnter()">
+        </span>
+                <span>
+            <label class="text-secondary">请输入盘点数</label>
+            <input type="text" name="count" class="form-control col-8 input" @onkeydown="changeEnter()">
+        </span>
+            </div>
+        </form>
+
+        <table class="table table-sm table-striped table-bordered table-hover text-nowrap card-body mt-2">
+            <tr>
+                <th>序号</th>
+                <th>库位</th>
+                <th>产品名</th>
+                <th>产品条码</th>
+                <th>生产日期</th>
+                <th>失效日期</th>
+                <th>入库日期</th>
+                <th>批号</th>
+                <th>ERP属性仓</th>
+                <th>质量状态</th>
+                <th>库存数量</th>
+                <th>可用数量</th>
+                <th>盘点数量</th>
+                <th>盘点差异</th>
+                <th>分配数量</th>
+            </tr>
+{{--            v-if="inventoryMission.checked=='是'"--}}
+            <tr v-for="(inventoryMission,i) in inventoryMissions"  @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 >@{{ inventoryMission.produced_at }}</td>
+                <td >@{{ inventoryMission.valid_at }}</td>
+                <td >@{{ inventoryMission.stored_at }}</td>
+                <td class="text-muted">@{{ inventoryMission.batch_number }}</td>
+                <td >@{{ inventoryMission.erp_type_position }}</td>
+                <td >@{{ inventoryMission.quality }}</td>
+                <td >@{{ inventoryMission.stored_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({
+            el: "#list",
+            data: {
+                inventory:{!! $inventory!!},
+                inventoryMissions:{!! $inventoryMissions->toJson() !!}['data'],
+                checkData: [],
+                selectedStyle:'',
+                sum:{!! $inventoryMissions->total() !!},
+            },
+            mounted: function () {
+                $(".tooltipTarget").tooltip({'trigger': 'hover'});
+                $("#list").removeClass('d-none');
+                document.getElementById('inventoryInput').focus();
+            },
+            methods:{
+                selectedColor(id){
+                    if (id==this.selectedStyle){
+                        this.selectedStyle='';
+                        return;
+                    }
+                    this.selectedStyle=id;
+                },
+            }
+        });
+        $("#form").on("keydown","input",function(){
+            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;
+                if (idx == inputs.length - 1) {       // 判断是否是最后一个输入框
+                    if (inputValue==''||inputValue==undefined||inputValue==null){
+                        document.getElementById('inventoryInput').focus();
+                        return;
+                    }
+                    $("#form").submit(); // 提交表单
+                } else {
+                    inputs[idx + 1].focus(); // 设置焦点
+                    inputs[idx + 1].select(); // 选中文字
+                }
+            }
+        });
+    </script>
+@endsection
+

+ 17 - 0
resources/views/inventory/stockInventory/menu.blade.php

@@ -0,0 +1,17 @@
+<div id="nav2">
+    @component('inventory.menu')
+    @endcomponent
+    <div class="container-fluid nav3">
+        <div class="card menu-third" >
+            <ul class="nav nav-pills">
+                @can('库存管理-盘点')
+                    <li class="nav-item">
+                        <a class="nav-link" href="{{url('inventory/stockInventory/mission')}}" :class="{active:isActive('mission',3)}">任务</a>
+                    </li>
+                @endcan
+                {{$slot}}
+            </ul>
+        </div>
+    </div>
+</div>
+

+ 167 - 0
resources/views/inventory/stockInventory/mission.blade.php

@@ -0,0 +1,167 @@
+@extends('layouts.app')
+@section('title')盘点-任务@endsection
+
+
+@section('content')
+    @component('inventory.stockInventory.menu')@endcomponent
+    <div id="list" class="container-fluid" style="min-width: 1500px">
+        <div id="form_div"></div>
+        <span class="dropdown">
+        <button class="btn btn-outline-dark btn-sm form-control-sm dropdown-toggle tooltipTarget" :class="[checkData.length>0?'btn-dark text-light':'']"
+                data-toggle="dropdown" title="导出所有页将会以搜索条件得到的过滤结果,将其全部记录(每一页)导出">
+            导出Excel
+        </button>
+        <div class="dropdown-menu">
+            <a class="dropdown-item" @click="inventoryExport(false)" href="javascript:">导出勾选内容</a>
+            <a class="dropdown-item" @click="inventoryExport(true)" href="javascript:">导出所有页</a>
+        </div>
+    </span>
+        @can('库存管理-盘点')
+            <span v-if="formData.date_start&&formData.date_end" class="btn btn-sm  btn-outline-secondary tooltipTarget" @click="createInventoryMission" title="选择单一指定货主生成盘点任务">生成动盘任务</span>
+            <span v-else class="btn btn-sm btn-outline-secondary  tooltipTarget" @click="createInventoryMission" title="选择单一指定货主生成盘点任务">生成全盘任务</span>
+        @endcan
+        <table class="table table-sm table-striped table-bordered table-hover text-nowrap card-body mt-2">
+            <tr>
+                <th>
+                    <label for="all">
+                        <input id="all" type="checkbox" @click="checkAll($event)">全选
+                    </label>
+                </th>
+                <th>操作</th>
+                <th>序号</th>
+                <th>盘点单号</th>
+                <th>创建时间</th>
+                <th>货主</th>
+                <th>任务类型</th>
+                <th>起始时间</th>
+                <th>结束时间</th>
+                <th>记录数</th>
+                <th>已盘点数</th>
+                <th>剩余数</th>
+                <th>复盘差异</th>
+                <th>复盘归位</th>
+                <th>操作</th>
+            </tr>
+            <tr v-for="(inventory,i) in inventories" @click="selectedColor(inventory.id)" :style="{'font-weight': inventory.id==selectedStyle?'bold':''}">
+                <td>
+                    <input class="checkItem" type="checkbox" :value="inventory.id" v-model="checkData">
+                </td>
+                <td>
+                    <span class="btn  btn-sm btn-outline-info" @click="enterStockInventory(inventory.id)">进入</span>
+                </td>
+                <td >@{{ i+1 }}</td>
+                <td >@{{ inventory.id }}</td>
+                <td >@{{ inventory.created_at }}</td>
+                <td ><span v-if="inventory.owner">@{{ inventory.owner.name }}</span></td>
+                <td >@{{ inventory.type }}</td>
+                <td >@{{ inventory.start_at }}</td>
+                <td class="text-muted">@{{ inventory.end_at }}</td>
+                <td >@{{ inventory.total }}</td>
+                <td >@{{ inventory.processed }}</td>
+                <td >@{{ inventory.surplus }}</td>
+                <td>@{{ inventory.difference }}</td>
+                <td>@{{ inventory.returned }}</td>
+                <td>
+                    <span class="btn  btn-sm btn-outline-danger">删除</span>
+                </td>
+            </tr>
+        </table>
+        <div class="text-info h5 btn btn">{{$inventories->count()}}/@{{ sum }}</div>
+        <div>{{$inventories->appends($paginateParams)->links()}}</div>
+    </div>
+
+@endsection
+
+@section('lastScript')
+    <script type="text/javascript" src="{{asset('js/queryForm/export200804.js')}}"></script>
+    <script type="text/javascript" src="{{asset('js/queryForm/queryForm200805b.js')}}"></script>
+    <script>
+        new Vue({
+            el: "#list",
+            data: {
+                inventories:{!! $inventories->toJson()!!}['data'],
+                owners: [
+                        @foreach($owners as $owner)
+                    {
+                        name: '{{$owner->id}}', value: '{{$owner->name}}'
+                    },
+                    @endforeach
+                ],
+                checkData: [],
+                selectedStyle:'',
+                sum:{!! $inventories->total() !!},
+                formData:{},
+            },
+            mounted: function () {
+                $(".tooltipTarget").tooltip({'trigger': 'hover'});
+                $("#list").removeClass('d-none');
+                let data=[
+                    [
+                        {name:'owner_id',type:'select_multiple_select',tip:['输入关键词快速定位下拉列表,回车确定','选择要显示的客户'],
+                            placeholder:['货主','定位或多选货主'],data:this.owners},
+                        {name:'date_start',type:'dateTime',tip:'选择创建日期的开始时间',},
+                        {name:'date_end',type:'dateTime',tip:'选择创建日期的结束时间',},
+                    ],
+                ];
+                this.form = new query({
+                    el:'#form_div',
+                    condition:data,
+                });
+                this.form.init();
+                let obj=this.form.getSearchData();
+                this.formData=obj;
+            },
+            methods:{
+                selectedColor(id){
+                    if (id==this.selectedStyle){
+                        this.selectedStyle='';
+                        return;
+                    }
+                    this.selectedStyle=id;
+                },
+                checkAll(e){
+                    if (e.target.checked){
+                        this.inventories.forEach((el,i)=>{
+                            if (this.checkData.indexOf(el.id) == '-1'){
+                                this.checkData.push(el.id);
+                            }
+                        });
+                    }else {
+                        this.checkData = [];
+                    }
+                },
+                inventoryExport(checkAllSign){
+                    let url = '{{url('inventory/stockInventoryExport')}}';
+                    let token='{{ csrf_token() }}';
+                    excelExport(checkAllSign,this.checkData,url,this.sum,token);
+                },
+                //生成盘点任务
+                createInventoryMission(){
+                    let _this=this;
+                    let url='{{url('inventory/stockInventory/createStockInventoryMission')}}';
+                    axios.post(url,{formData:_this.formData}).then(function (response) {
+                            if(!response.data.success){
+                                tempTip.setDuration(1000);
+                                tempTip.show('生成盘点任务失败'+'   '+response.data.data);
+                                return;
+                            }else{
+                                let inventory=response.data.data;
+                                _this.inventories.push(inventory);
+                                tempTip.setDuration(1000);
+                                tempTip.showSuccess('生成盘点任务成功!');
+                            }
+                        })
+                        .catch(function (err) {
+                            tempTip.setDuration(3000);
+                            tempTip.show('生成盘点任务失败!'+'网络错误:' + err);
+                        });
+                },
+                //进入盘点中页面
+                enterStockInventory(id){
+                        location.href="{{url('inventory/stockInventory/enterStockInventory')}}/"+id;
+                    },
+            }
+        });
+    </script>
+@endsection
+

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

@@ -294,11 +294,13 @@
                 let laborReports=_this.laborReports;
                 //进场
                 let tokenOfBroadcastEnterAndLeave='{{$tokenOfBroadcastEnterAndLeave}}';
-                if(tokenOfBroadcastEnterAndLeave)
+                //console.log(tokenOfBroadcastEnterAndLeave)
+                if(tokenOfBroadcastEnterAndLeave){
                     Echo.channel('{{$laravelEchoPrefix}}'+tokenOfBroadcastEnterAndLeave).listen('ImportEvent',(e)=>{
                         let labor=e.laborReport;
                         laborReports.push(labor);
                     });
+                }
                 //退场
                 Echo.channel('{{$laravelEchoPrefix}}laborReport').listen('ExportEvent',(e)=>{
                     let labor=e.laborReport;

+ 9 - 0
routes/web.php

@@ -294,6 +294,15 @@ Route::group(['prefix'=>'inventory'],function (){
     Route::any('statement/changeInventory/export','InventoryController@exportData');
     Route::get('statement/changeInventory/downLoadExcel','InventoryController@downLoadExcel');
     Route::post('statement/changeInventory/deleteExcel','InventoryController@deleteExcel');
+    //全部库存
+    Route::get('statement/allInventory','InventoryController@allInventory');
+    //库存盘点
+    Route::get('stockInventory/mission','InventoryController@mission');
+    Route::post('stockInventory/createStockInventoryMission','InventoryController@createStockInventoryMission');
+    Route::any('stockInventory/enterStockInventory/{id}','InventoryController@enterStockInventory');
+    //盘点任务导出
+    Route::any('stockInventoryExport','InventoryController@stockInventoryExport');
+    Route::any('stockInventory/stockInventory/{id}','InventoryController@stockInventory');
 });
 
 /**