فهرست منبع

盘点--任务界面调整,添加项目审核按钮及权限

haozi 5 سال پیش
والد
کامیت
4270b979a8

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

@@ -45,6 +45,20 @@ class InventoryAccountController extends Controller
         $inventoryAccount=InventoryAccount::where('id',$id)->delete();
         return ['success'=>true,'data'=>$inventoryAccount];
     }
+    public function inventoryChecked(Request $request){
+        if(!Gate::allows('库存管理-盘点-项目审核')){return['success'=>false,'msg'=>'没有权限'];}
+        $id=$request->id;
+        if(is_null($id)){return ['success'=>false,'msg'=>'传入id为空'];}
+        $inventoryAccount=InventoryAccount::query()->where('id',$id)->update([
+            'auditor'=>Auth::user()['id'],
+        ]);
+        if ($inventoryAccount==1) {
+            $inventoryAccount=InventoryAccount::query()->with('userAuditor')->find($id);
+            return ['success'=>true,'data'=>$inventoryAccount];
+        }else{
+            return ['success'=>false,'msg'=>'审核失败!'];
+        }
+    }
 
     //盘点-任务页面
     public function mission(Request $request,OwnerService $ownerService){

+ 10 - 4
app/InventoryAccount.php

@@ -12,10 +12,10 @@ 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','status','remark',
+        'id','owner_id','type', 'start_at', 'end_at','total','processed','difference','returned','deleted_at','created_at','status','remark','auditor'
     ];
     protected $appends = [
-            'surplus','check_surplus'
+            'surplus','check_surplus','ignored'
     ];
     public function creator(){
         return $this->hasOne('App\Sign','signable_id','id')
@@ -24,16 +24,22 @@ class InventoryAccount extends Model
     public function owner(){
         return $this->belongsTo('App\Owner','owner_id','id');
     }
+    public function userAuditor(){
+        return $this->belongsTo('App\User','auditor','id');
+    }
     public function inventoryMissions(){
         return $this->belongsTo('App\InventoryAccountMission','id','inventory_account_id');
     }
 
     public function getSurplusAttribute()
     {
-        return $this['total'] ? $this['total']-$this['processed']:0;
+        return $this['total'] ? $this['total']-$this['processed']-$this['ignored']:0;
     }
     public function getProcessedAmount(){
-        return $this->inventoryMissions()->whereIn('checked',['是','跳过','确认差异','已复核'])->where('inventory_account_id',$this['id'])->count();
+        return $this->inventoryMissions()->whereIn('checked',['是','确认差异','已复核'])->where('inventory_account_id',$this['id'])->count();
+    }
+    public function getIgnoredAttribute(){
+        return $this->inventoryMissions()->where('checked','跳过')->where('inventory_account_id',$this['id'])->count();
     }
     //复盘剩余数
     public function getCheckSurplusAttribute()

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

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddAuditorToInventoryAccounts extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('inventory_accounts', function (Blueprint $table) {
+            $table->integer('auditor')->index()->nullable()->comment('审核人');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('inventory_accounts', function (Blueprint $table) {
+            $table->dropColumn('auditor');
+        });
+    }
+}

+ 29 - 0
database/migrations/2020_11_09_134301_add_inventory_account_authorities.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 AddInventoryAccountAuthorities extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Authority::query()->firstOrCreate(['name'=>'库存管理-盘点-项目审核','alias_name'=>'库存管理-盘点-项目审核']);
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Authority::query()->where('name','库存管理-盘点-项目审核')->delete();
+    }
+}

+ 57 - 34
resources/views/inventory/stockInventory/mission.blade.php

@@ -11,11 +11,6 @@
         <form class="form-inline mt-2">
             <span class="form-inline ml-5">
                  <span class="btn btn-sm btn-outline-secondary tooltipTarget" @click="syncOwners">同步货主</span>
-{{--                <select class="form-control form-control-sm tooltipTarget" name="owner_id" id="owner_id" style="width: 150px;position: relative" title="选择指定货主">--}}
-{{--                    <option value="">货主</option>--}}
-{{--                    <option v-for="owner in fakeOwners" :value="owner.id">@{{ owner.name }}</option>--}}
-{{--                </select>--}}
-{{--                <input placeholder="定位货主" id="ownerName" autocomplete="off" class="form-control form-control-sm tooltipTarget" style="width: 100px" @input="定位货主()" title="输入关键字定位货主">--}}
                 <select class="form-control form-control-sm tooltipTarget" name="owner_id" id="owner_id" style="width: 150px;position: relative" title="选择指定货主" v-model="owner_id">
                                         <option value="">货主</option>
                                         <option v-for="owner in owners" :value="owner.id">@{{ owner.name }}</option>
@@ -45,7 +40,7 @@
                 <input id="all" type="checkbox" @click="checkAll($event)">全选
             </label>
             <table class="table table-sm text-nowrap table-bordered d-none" id="headerRoll"></table>
-            <table class="table table-sm text-nowrap table-striped table-bordered m-0" id="headerParent">
+            <table class="table table-sm  table-striped table-bordered m-0" id="headerParent">
                 <tr class="p-0" id="header"></tr>
                 <tr v-for="(inventory,i) in inventoryAccounts" @click="selectedColor(inventory.id)" :style="{'font-weight': inventory.id==selectedStyle?'bold':''}">
                     <td>
@@ -59,23 +54,35 @@
                             <a :href="'{{url('inventory/stockInventory/enterStockInventory')}}/'+inventory.id+'?listMode=true'"><button class="btn btn-sm btn-outline-dark">查看</button></a>
                         @endcan
                     </td>
+                    <td>
+                        @can('库存管理-盘点-项目审核')
+                            <span v-if="inventory.auditor">已审核</span>
+                            <span v-else class="btn  btn-sm btn-outline-dark" @click="inventoryChecked(inventory.id)">审核</span>
+                        @else
+                            <span v-if="inventory.auditor">已审核</span>
+                            <span v-else>未审核</span>
+                        @endcan
+                    </td>
                     <td >@{{ i+1 }}</td>
                     <td >@{{ inventory.status }}</td>
                     <td >@{{ inventory.id }}</td>
                     <td >@{{ inventory.created_at }}</td>
                     <td >@{{ inventory.owner_name }}</td>
-                    <td >
-                        @{{ inventory.type }}
-                        <span v-if="inventory.remark">/@{{ inventory.remark }}</span>
+                    <td style="width: 200px;word-wrap: break-word">
+                        <small>@{{ inventory.type }}</small>
+                        <span v-if="inventory.remark" style="word-wrap: break-word;"><small>@{{ inventory.remark }}</small></span>
                     </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.ignored }}</td>
                     <td>@{{ inventory.difference }}</td>
                     <td>@{{ inventory.returned }}</td>
-                    <td>@{{ inventory.creator }}</td>
+                    <td v-if="inventory.processed">@{{ inventory.processed }}/@{{ inventory.total }}</td>
+                    <td>@{{ inventory.auditor }}</td>
+                    <td class="text-muted">@{{ inventory.creator }}</td>
                     <td>
                         <span v-if="inventory.status!='已完成'" class="btn  btn-sm btn-outline-danger" @click="deleteStockInventoryMission(inventory.id)">删</span>
                     </td>
@@ -115,7 +122,9 @@
                         returned:'{{$inventory->returned}}', surplus:'{{$inventory->surplus}}',
                         total:'{{$inventory->total}}',end_at:'{{$inventory->end_at}}',
                         start_at:'{{$inventory->start_at}}',type:'{{$inventory->type}}',
-                        difference:'{{$inventory->difference}}', remark:'{{$inventory->remark}}'},
+                        difference:'{{$inventory->difference}}',
+                        remark:'{{$inventory->remark}}',ignored:'{{$inventory->ignored}}',auditor:'{{$inventory->auditor?$inventory->userAuditor->name:''}}',
+                    },
                     @endforeach
                 ],
                 owners:{!! $owners !!},
@@ -139,19 +148,23 @@
                     {name:'cloneCheckAll',customization:true,type:'checkAll',column:'id',
                         dom:$('#cloneCheckAll').removeClass('d-none'), neglect: true},
                     {name:'operation',value: '操作', neglect: true},
+                    {name:'',value: '审核', neglect: true},
                     {name:'index',value: '序号', neglect: true},
                     {name:'status',value: '盘点状态', neglect: true},
                     {name:'id',value: '盘点单号', neglect: true},
                     {name: 'created_at', value: '创建日期'},
-                    {name:'owner_name',value: '货主',neglect: true},
-                    {name: 'type', value: '任务类型'},
+                    {name:'owner_name',value: '货主'},
+                    {name: 'type', value: '任务类型',neglect: true},
                     {name:'start_at',value: '起始时间'},
                     {name: 'end_at', value: '结束时间', neglect: true},
-                    {name: 'total', value: '记录数', neglect: true},
-                    {name: 'processed', value: '已盘点数', neglect: true},
-                    {name: 'surplus',value: '剩余数', neglect: true},
-                    {name: 'difference', value: '复盘差异', neglect: true},
+                    {name: 'total', value: '盘点任务数', neglect: true},
+                    {name: 'processed', value: '盘点数量', neglect: true},
+                    {name: 'surplus',value: '未盘数量', neglect: true},
+                    {name: 'surplus',value: '跳过数量', neglect: true},
+                    {name: 'difference', value: '差异数量', neglect: true},
                     {name: 'returned', value: '复盘归位', neglect: true},
+                    {name: 'returned', value: '盘点比例', neglect: true},
+                    {name: 'auditor', value: '审核人', neglect: true},
                     {name: 'creator', value: '创建人', neglect: true},
                     {name:'remove',value: '', neglect: true},
                 ];
@@ -264,10 +277,9 @@
                 enterStockInventory(id){
                     location.href='{{url('inventory/stockInventory/enterStockInventory')}}/'+id;
                 },
-                //删除盘点任务
                 deleteStockInventoryMission(id){
                     let _this=this;
-                    if(!confirm('确定要删除盘点单号为:“'+id+'”的运单吗?')){return};
+                    if(!confirm('确定要删除盘点单号为:“'+id+'”的盘点任务吗?')){return};
                     let url = '{{url('inventory/deleteStockInventoryMission')}}/'+id;
                     axios.delete(url).then(
                         function (response) {
@@ -292,6 +304,32 @@
                         tempTip.show('删除失败,网络链接错误!'+err);
                     });
                 },
+                inventoryChecked(id){
+                    let _this=this;
+                    let url = '{{url('inventory/inventoryChecked')}}';
+                    axios.post(url,{id:id}).then(
+                        function (response) {
+                            if(!response.data.success){
+                                tempTip.setDuration(3000);
+                                tempTip.show('盘点单号:'+id+'审核失败!');
+                            }else {
+                                _this.inventoryAccounts.every(function (inventoryAccount,i) {
+                                    if (inventoryAccount.id===id){
+                                        inventoryAccount.auditor=response.data.data.user_auditor.name;
+                                        return false;
+                                    }else {
+                                        return true
+                                    }
+                                });
+                                tempTip.setDuration(3000);
+                                tempTip.showSuccess('盘点单号:'+id+'审核成功!');
+                            }
+                        }
+                    ).catch(function (err) {
+                        tempTip.setDuration(3000);
+                        tempTip.show('审核失败,网络链接错误!'+err);
+                    });
+                },
                 syncOwners(){
                     let _this=this;
                     let url = '{{url('inventory/syncOwners')}}';
@@ -320,21 +358,6 @@
                         this.owner_id='';
                     }
                 },
-                // 定位货主(){
-                //     let target = $('#ownerName').val();
-                //     if(target === ''){
-                //         this.fakeOwners = this.owners;
-                //         $('#owner_id').attr('size','1');
-                //     }else{
-                //         this.fakeOwners = this.owners.filter(function(map){
-                //             return map.name.includes(target) ;
-                //         })
-                //         if (this.fakeOwners.length>=1){
-                //             //$("#owner_id option[value='"+this.fakeOwners[0].id+"']").attr("selected","selected");
-                //             $('#owner_id').attr('size','2');
-                //         }
-                //     }
-                // },
                 hasDateStart(){
                     this.date_start=document.getElementById('date_start').value;
                 },

+ 1 - 0
routes/web.php

@@ -419,6 +419,7 @@ Route::group(['prefix'=>'inventory'],function(){
     });
 
     Route::get('syncOwners','InventoryAccountController@syncOwners');
+    Route::post('inventoryChecked','InventoryAccountController@inventoryChecked');
     Route::any('删除盘点记录','InventoryAccountController@删除盘点记录');
     Route::post('跳过盘点记录','InventoryAccountController@跳过盘点记录');
     Route::post('确认盘点差异','InventoryAccountController@确认盘点差异');