Преглед изворни кода

库存管理--手动修改盘点状态

haozi пре 5 година
родитељ
комит
8bd08c8d8f

+ 12 - 0
app/Http/Controllers/InventoryAccountController.php

@@ -8,6 +8,7 @@ use App\InventoryAccountMission;
 use App\Owner;
 use App\Services\InventoryAccountService;
 use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Facades\Gate;
 use Maatwebsite\Excel\Facades\Excel;
 
@@ -101,6 +102,7 @@ class InventoryAccountController extends Controller
         }
         $row=[[
             'id'=>'盘点编号',
+            'status'=>'盘点状态',
             'created_at'=>'创建时间',
             'owner_id'=>'货主',
             'type'=>'任务类型',
@@ -117,6 +119,7 @@ class InventoryAccountController extends Controller
             $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:'',
@@ -132,4 +135,13 @@ class InventoryAccountController extends Controller
         }
         return Excel::download(new Export($row,$list),date('YmdHis', time()).'-盘点任务记录单.xlsx');
     }
+    public function stockInventoryEnd(Request $request){
+        if (!Gate::allows('库存管理-盘点')){return redirect(url('/')); }
+        $id=$request->input('id');
+        if (!$id) return ['success'=>false,'data'=>'参数错误!'];
+        $inventoryAccount=InventoryAccount::query()->where('id',$id)->update(['status'=>'复盘中']);
+        $this->log(__METHOD__,'结束初盘任务'.__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
+        if ($inventoryAccount>0) return ['success'=>true,'data'=>'复盘中'];
+        return ['success'=>false,'data'=>'参数错误!'];
+    }
 }

+ 1 - 1
app/Http/Controllers/InventoryController.php

@@ -286,7 +286,7 @@ class InventoryController extends Controller
         $owner_id=$request->owner_id;
         if(!$owner_id) return '<h1 class="text-danger">导入Excel失败<br><p style="color: red">您还未选择相应货主!</p></h1>';
         $fileSuffix = $request->file()['file']->getClientOriginalExtension();
-        if (in_array($fileSuffix, ['xlsx', 'xlsm', 'xltx', 'xltm', 'xls', 'xlt', 'ods', 'ots', 'slk', 'xml', 'gnumeric', 'htm', 'html', 'csv', 'tsv'])) {
+        if (in_array($fileSuffix, ['xlsx', 'xlsm', 'xltx', 'xltm', 'xls', 'xlt', 'ods', 'ots', 'slk', 'xml', 'gnumeric', 'htm', 'html', 'csv', 'tsv','txt'])) {
             ini_set('max_execution_time', 2100);
             ini_set('memory_limit', '512M');
             $extension = $request->file()['file']->getClientOriginalExtension();

+ 4 - 2
app/Http/Controllers/TestController.php

@@ -9,6 +9,7 @@ use App\City;
 use App\Events\CancelOrder;
 use App\Logistic;
 use App\OracleActAllocationDetails;
+use App\OracleBasSKU;
 use App\OracleDOCOrderHeader;
 use App\OracleDocOrderPackingSummary;
 use App\OracleDOCWaveDetails;
@@ -88,8 +89,9 @@ class TestController extends Controller
     function t2(Request $request)
     { //x        $packagesBatch=Package::where('batch_number',$batch_number)->first();
 
-        $user = User::get();
-        dd($user[1011]['name']??'x');
+
+        $hasSku = OracleBasSKU::query()->where('sku', "2140100024")->where('customerid', "ONKYO")->first();
+        dd($hasSku);
 
     }
 

+ 8 - 4
app/Imports/InventoryCompareImport.php

@@ -3,6 +3,7 @@
 namespace App\Imports;
 
 use App\Commodity;
+use App\CommodityBarcode;
 use App\OracleBasSKU;
 use App\Owner;
 use App\Services\InventoryCompareService;
@@ -76,14 +77,17 @@ class InventoryCompareImport implements ToCollection, WithHeadingRow, WithMultip
                     $sum++;
                     continue;
                 }
-                $hasSku=Commodity::where('owner_id',$this->owner_id)->where('sku',$row[$skuName])->first();
-                if(!$hasSku) {
+                $commodityInWMS=Commodity::where('owner_id',$this->owner_id)->where('sku',$row[$skuName])->first();
+                if(!$commodityInWMS) {
                     $owner=Owner::find($this->owner_id);
-                    $hasSku = OracleBasSKU::query()->where('sku', $row[$skuName])->where('customerid', $owner->code)->first();
+                    $commodityInWMS = OracleBasSKU::query()->where('sku', "$row[$skuName]")->where('customerid', "$owner->code")->first();
+                    $commodity=Commodity::query()->firstOrCreate(['owner_id'=>$this->owner_id,'sku'=>$row[$skuName],'name'=>$commodityInWMS['descr_c'],'length'=>$commodityInWMS['skulength'],'width'=>$commodityInWMS['skuwidth'],'height'=>$commodityInWMS['skuhigh'],'volumn'=>$commodityInWMS['skulength']*$commodityInWMS['skuwidth']*$commodityInWMS['skuhigh']]);
+                    $commodity->newBarcode($commodityInWMS['alternate_sku1']);
                 }
-                if (!$hasSku){
+                if (!$commodityInWMS){
                     array_push($exception, ['该货主下不存在产品编号:'.$row[$skuName]]);
                     $sum++;
+                    continue;
                 }
 
                 /** @var InventoryCompareService $service */

+ 2 - 2
app/InventoryAccount.php

@@ -11,7 +11,7 @@ class InventoryAccount extends Model
     use ModelTimeFormat;
     use SoftDeletes;
     protected $fillable=[
-        'id','owner_id','type', 'start_at', 'end_at','total','processed','difference','returned','deleted_at','created_at',
+        'id','owner_id','type', 'start_at', 'end_at','total','processed','difference','returned','deleted_at','created_at','status',
     ];
     protected $appends = [
             'surplus','check_surplus'
@@ -37,7 +37,7 @@ class InventoryAccount extends Model
         return $this['total'] ? $this['total']-$re_checked_amount:null;
     }
     public function getDifferenceAmount(){
-        return $this->inventoryMissions()->where('inventory_account_id',$this['id'])->where('difference_amount','>',0)->count();
+        return $this->inventoryMissions()->where('inventory_account_id',$this['id'])->where('difference_amount','!=',0)->count();
     }
     //复盘归位
     public function getReturnedAmount(){

+ 3 - 2
app/Services/InventoryAccountService.php

@@ -194,11 +194,11 @@ class InventoryAccountService
         $inventory=InventoryAccount::find($inventoryAccountId);
         if ($inventory->surplus!=0){
             $inventoryAccountMission->verified_amount=$count;
-            $inventoryAccountMission->difference_amount=abs($inventoryAccountMission->stored_amount-$count);
+            $inventoryAccountMission->difference_amount=$count-$inventoryAccountMission->stored_amount;
             $inventoryAccountMission->checked='是';
         }else{
             $inventoryAccountMission->re_checked_amount=$count;
-            $inventoryAccountMission->difference_amount=abs($inventoryAccountMission->stored_amount-$count);
+            $inventoryAccountMission->difference_amount=$count-$inventoryAccountMission->stored_amount;
             if ($inventoryAccountMission->difference_amount==0){
                 $inventoryAccountMission->returned='是';
             }else{
@@ -221,6 +221,7 @@ class InventoryAccountService
         $inventoryAccount->processed=$inventoryAccount->getProcessedAmount();
         $inventoryAccount->difference=$inventoryAccount->getDifferenceAmount();
         $inventoryAccount->returned=$inventoryAccount->getReturnedAmount();
+        $inventoryAccount->status='盘点中';
         $inventoryAccount->update();
         Controller::logS(__METHOD__,"盘点修改盘点任务中的已盘条数__".__FUNCTION__,json_encode($inventoryAccountId));
         return $inventoryAccount;

+ 0 - 46
database/migrations/2020_08_28_134321_change_ids_of_tables_not_int.php

@@ -1,46 +0,0 @@
-<?php
-
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
-
-class ChangeIdsOfTablesNotInt extends Migration
-{
-
-
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        Schema::table('commodity_barcodes', function (Blueprint $table) {
-            $table->bigInteger('commodity_id')->index()->change();
-        });
-        Schema::table('custom_fields', function (Blueprint $table) {
-            $table->bigInteger('authority_id')->change();
-        });
-        Schema::table('orders', function (Blueprint $table) {
-            $table->bigInteger('batch_id')->index()->change();
-        });
-        Schema::table('order_issues', function (Blueprint $table) {
-            $table->bigInteger('order_issue_type_id')->nullable()->change();
-        });
-        Schema::table('shops', function (Blueprint $table) {
-            $table->bigInteger('owner_id')->change();
-        });
-        Schema::table('signs', function (Blueprint $table) {
-            $table->bigInteger('signable_id')->change()->index();
-        });
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-    }
-}

+ 1 - 1
public/js/app.js

@@ -61991,4 +61991,4 @@ module.exports = __webpack_require__(/*! D:\wamp64\www\bswas\resources\sass\app.
 
 /***/ })
 
-/******/ });
+/******/ });

+ 64 - 41
resources/views/inventory/stockInventory/inventoryMission.blade.php

@@ -16,7 +16,7 @@
                     <span v-if="listMode">切换为盘点</span>
                 </button>
             </span>
-        <span class="form-group  mb-5">
+            <span class="form-group  mb-5">
             <label class="text-muted">货主:</label><span class="font-weight-bold">@{{ inventory.owner.name }}</span>
         </span>
             <span class="form-group  p-2 mb-5" class="text-muted">
@@ -29,16 +29,16 @@
 
         <div class="mt-3">
         <span class="h5">
-            <span class="form-group mb-5" v-if="inventory.surplus!=0">
+            <span class="form-group mb-5" v-if="inventory.status=='盘点中' ||inventory.status=='待盘点'">
                 <label class=" font-weight-bold">已盘点:</label><span>@{{ inventory.processed }}/总数:@{{ inventory.total }}</span>
             </span>
-            <span class="form-group mb-5" v-if="inventory.surplus!=0">
+            <span class="form-group mb-5" v-if="inventory.status=='盘点中' ||inventory.status=='待盘点'">
                 <label class=" font-weight-bold">剩余数:</label><span>@{{ inventory.surplus }}</span>
             </span>
-            <span class="form-group mb-5" v-if="inventory.surplus==0">
+            <span class="form-group mb-5" v-if="inventory.status=='复盘中'">
                 <label class=" font-weight-bold">盘点记录数:</label><span>@{{ inventory.total }}</span>
             </span>
-            <span class="form-group mb-5" v-if="inventory.surplus==0">
+            <span class="form-group mb-5" v-if="inventory.status=='复盘中'">
                 <label class=" font-weight-bold">复盘剩余数:</label><span>@{{ inventory.check_surplus }}/复盘总数:@{{ inventory.total }}</span>
             </span>
             </span>
@@ -46,39 +46,46 @@
 
 
         <div class="mt-3" >
-        <span v-if="!listMode" class="btn  col-md-2 font-weight-bold"  style="cursor: default;max-width: 160px" :class="inventory.surplus!=0?'bg-info':'btn-outline-info disabled'">
+        <span v-if="!listMode" class="btn  col-md-2 font-weight-bold"  style="cursor: default;max-width: 160px" :class="inventory.status=='盘点中' ||inventory.status=='待盘点'?'bg-info':'btn-outline-info disabled'">
             @{{ inventory.type }}
         </span>
-            <span v-if="!listMode" class="btn  col-md-2 font-weight-bold" style="cursor: default;max-width: 160px" :class="inventory.surplus!=0?'btn-outline-info disabled':'bg-info'">复盘</span>
+            <span v-if="!listMode && inventory.status=='盘点中' ||inventory.status=='待盘点'" class="btn  col-md-2 font-weight-bold btn-outline-secondary" style="max-width: 160px" @click="stockInventoryEnd(inventory.id)">结束</span>
+            <span v-if="!listMode && inventory.status=='复盘中'" class="btn  col-md-2 font-weight-bold" style="cursor: default;max-width: 160px" :class="inventory.status=='盘点中' ||inventory.status=='待盘点'?'btn-outline-info disabled':'bg-info'">复盘</span>
         </div>
 
 
-        <form id="form"  class="mt-3 form-inline " v-if="!listMode" :class="inventory.surplus!=0?'row-cols-3':'row-cols-5'">
+        <form id="form"  class="mt-3 form-inline " v-if="!listMode" :class="inventory.status=='盘点中' ||inventory.status=='待盘点'?'row-cols-3':'row-cols-5'">
         <span class="form-group">
             <label for="location" class="text-secondary font-weight-bold">请输库位</label>
-            <input id="inventoryInput" name="location" type="text" class="form-control  input"  autocomplete="off" value="@if(old('location')){{old('location')}}@endif">
+            <input id="inventoryInput" @keypress="inputSwitch($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">
             <label for="barcode" class="text-secondary font-weight-bold">请输产品条码</label>
-            <input id="barcode" name="barcode" type="text" value="@if(old('barcode')){{old('barcode')}}@endif" class="form-control  input" autocomplete="off" @blur="searchBarcode">
+            <input id="barcode" name="barcode"  @keypress="inputSwitch($event)"
+                   type="text" value="@if(old('barcode')){{old('barcode')}}@endif" class="form-control  input" autocomplete="off" @blur="searchBarcode">
         </span>
-                <span class="form-group ml-4">
+            <span class="form-group ml-4">
             <label for="count" class="text-secondary font-weight-bold">请输盘点数</label>
-            <input type="text" id="count" name="count" class="form-control input" value="@if(old('count')){{old('count')}}@endif"  autocomplete="off">
+            <input type="text" id="count"  @keypress="inputSwitch($event)"
+                   name="count" class="form-control input" value="@if(old('count')){{old('count')}}@endif"  autocomplete="off">
         </span>
 
-                <span v-if="inventory.surplus==0">
+            <span v-if="inventory.status=='复盘中'" class="form-group ml-4">
             <label for="count" class="text-secondary font-weight-bold">上一次盘点数</label>
             <span v-if="!inventoryMissionRecord.re_checked_amount">
-                <input type="text" id="count" name="count" v-model="inventoryMissionRecord.verified_amount" class="form-control  input" readonly>
+                <input type="text" id="count"  @keypress="inputSwitch($event)"
+                       name="count" v-model="inventoryMissionRecord.verified_amount" class="form-control  input" readonly>
             </span>
             <span v-if="inventoryMissionRecord.re_checked_amount">
-                <input type="text" id="count" name="count" v-model="inventoryMissionRecord.re_checked_amount" class="form-control  input" readonly>
+                <input type="text" id="count"  @keypress="inputSwitch($event)"
+                       name="count" v-model="inventoryMissionRecord.re_checked_amount" class="form-control  input" readonly>
             </span>
         </span>
-                <span v-if="inventory.surplus==0">
+            <span v-if="inventory.status=='复盘中'" class="form-group ml-4">
             <label for="count" class="text-secondary font-weight-bold">盘点差异数</label>
-            <input type="text" id="count" name="count" v-model="inventoryMissionRecord.difference_amount" class="form-control  input" readonly>
+            <input type="text" id="difference_amount"  @keypress="inputSwitch($event)"
+                   name="difference_amount" v-model="inventoryMissionRecord.difference_amount" class="form-control  input" readonly>
         </span>
         </form>
 
@@ -131,7 +138,7 @@
                             <span class="mr-3 text-nowrap"><span class="font-weight-bold">库位:</span><span style="color:#af7651">@{{ inventoryMission.location }}</span></span>
                             <span class="mr-3 text-nowrap"><span class="font-weight-bold">产品名称:</span><span style="color:#af7651" v-if="inventoryMission.commodity">@{{ inventoryMission.commodity.name }}</span></span>
                             <span class="mr-3 text-nowrap"><span class="font-weight-bold">产品条码:</span><span style="color:#af7651" v-if="inventoryMission.commodity">@{{ inventoryMission.commodity.barcode }}</span></span>
-                            <div v-if="inventory.surplus==0">
+                            <div v-if="inventory.status=='复盘中'">
                                 <span class="mr-3 text-nowrap"><span style="color:#783000" class="font-weight-bold">盘点数量:</span><span style="color:#af7651">@{{ inventoryMission.verified_amount }}</span></span>
                                 <span class="mr-3 text-nowrap"><span style="color:#783000" class="font-weight-bold">复盘数量:</span><span style="color:#af7651">@{{ inventoryMission.re_checked_amount }}</span></span>
                                 <span class="mr-3 text-nowrap"><span style="color:#783000" class="font-weight-bold">盘点差异:</span><span >@{{ inventoryMission.difference_amount }}</span></span>
@@ -166,7 +173,6 @@
 
                 (function 焦点放置(){
                     let inventoryInput=$('#inventoryInput')
-                    console.log(inventoryInput.length)
                     if(inventoryInput.length>0)
                         $('#inventoryInput').focus()
                 })();
@@ -177,6 +183,26 @@
                 })();
             },
             methods:{
+                inputSwitch(e){
+                    if(e.key==='Enter') {
+                        let inputs = $("#form .input");
+                        let idx = inputs.index($(e.target));     // 获取当前焦点输入框所处的位置
+                        let location=document.getElementById('inventoryInput').value;
+                        console.log(idx)
+                        if (idx == 2) {       // 判断是否是最后一个输入框
+                            if (location==''){
+                                document.getElementById('inventoryInput').focus();
+                                return;
+                            }
+                            listVue.submitStockInventory();
+                            $("#form .input").val(' ');
+                            document.getElementById('inventoryInput').focus();
+                        } else {
+                            inputs[idx + 1].focus(); // 设置焦点
+                            inputs[idx + 1].select(); // 选中文字
+                        }
+                    }
+                },
                 selectedColor(id){
                     if (id==this.selectedStyle){
                         this.selectedStyle='';
@@ -254,27 +280,24 @@
                         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 location=document.getElementById('inventoryInput').value;
-                if (idx == 2) {       // 判断是否是最后一个输入框
-                    if (location==''||location==undefined||location==null){
-                        document.getElementById('inventoryInput').focus();
-                        return;
-                    }
-                    listVue.submitStockInventory();
-                    $("#form .input").val(' ');
-                    document.getElementById('inventoryInput').focus();
-                } else {
-                    inputs[idx + 1].focus(); // 设置焦点
-                    inputs[idx + 1].select(); // 选中文字
-                }
+                //结束初盘任务
+                stockInventoryEnd(id){
+                    let _this=this;
+                    let url='{{url('inventory/stockInventoryEnd')}}';
+                    axios.post(url,{id:id}).then(function (response) {
+                        if (!response.data.success){
+                            tempTip.setDuration(2000);
+                            tempTip.show('结束初盘失败!'+'   '+response.data.data);
+                        }else {
+                            _this.inventory.status=response.data.data;
+                            tempTip.setDuration(2000);
+                            tempTip.showSuccess('结束初盘,进入复盘!');
+                        }
+                    }).catch(function (err) {
+                        tempTip.setDuration(2000);
+                        tempTip.show('结束初盘失败!'+'网络错误'+err);
+                    })
+                },
             }
         });
     </script>

+ 3 - 1
resources/views/inventory/stockInventory/mission.blade.php

@@ -34,6 +34,7 @@
                 </th>
                 <th>操作</th>
                 <th>序号</th>
+                <th>盘点状态</th>
                 <th>盘点单号</th>
                 <th>创建时间</th>
                 <th>货主</th>
@@ -53,9 +54,10 @@
                 </td>
                 <td>
                     <span class="btn  btn-sm btn-outline-info" @click="enterStockInventory(inventory.id)">进入</span>
-                    <button class="btn btn-sm btn-outline-dark" href="{{url('inventory/stockInventory/enterStockInventory')}}/'+id?listMode=true;">查看</button>
+                    <a :href="'{{url('inventory/stockInventory/enterStockInventory')}}/'+inventory.id+'?listMode=true'"><button class="btn btn-sm btn-outline-dark">查看</button></a>
                 </td>
                 <td >@{{ i+1 }}</td>
+                <td >@{{ inventory.status }}</td>
                 <td >@{{ inventory.id }}</td>
                 <td >@{{ inventory.created_at }}</td>
                 <td ><span v-if="inventory.owner">@{{ inventory.owner.name }}</span></td>

+ 2 - 0
routes/web.php

@@ -304,6 +304,8 @@ Route::group(['prefix'=>'inventory'],function (){
     Route::get('stockInventory/mission','InventoryAccountController@mission');
     //创建盘点任务
     Route::post('stockInventory/createStockInventoryMission','InventoryAccountController@createStockInventoryMission');
+    //结束初盘任务
+    Route::post('stockInventoryEnd','InventoryAccountController@stockInventoryEnd');
     //删除盘点任务
     Route::any('deleteStockInventoryMission/{id}','InventoryAccountController@deleteStockInventoryMission');
     //进入盘点或者复盘页面