Ver código fonte

库存--动库报表,全部库存显示拥有客户权限的数据

haozi 5 anos atrás
pai
commit
3997804b61

+ 5 - 2
app/Http/Controllers/InventoryController.php

@@ -3,6 +3,7 @@
 namespace App\Http\Controllers;
 
 use App\OracleBasCustomer;
+use App\Owner;
 use App\Services\AllInventoryService;
 use App\Services\InventoryDailyLogService;
 use App\Services\InventoryService;
@@ -25,7 +26,8 @@ class InventoryController extends Controller
         if(!Gate::allows("库存管理-库存")){ return redirect(url('/'));  }
         $oracleActTransactingLogs=app('inventoryService')->paginate($request->input());
         $oracleActTransactingLogs=json_encode($oracleActTransactingLogs);
-        $owners=OracleBasCustomer::query()->select('customerid','descr_c')->where('customer_type','OW')->where('active_flag','Y')->get();
+//        $owners=OracleBasCustomer::query()->select('customerid','descr_c')->where('customer_type','OW')->where('active_flag','Y')->get();
+        $owners=Owner::filterAuthorities()->select(['code', 'name'])->get();
         $isTotalStock=false;
         $page = $request->page ?? 1;
         return view('inventory.statement.changeInventory',compact('oracleActTransactingLogs','page','owners','isTotalStock'));
@@ -35,7 +37,8 @@ class InventoryController extends Controller
         if(!Gate::allows("库存管理-库存")){ return redirect(url('/'));  }
         $oracleActTransactingLogs=app('allInventoryService')->paginate($request->input());
         $oracleActTransactingLogs=json_encode($oracleActTransactingLogs);
-        $owners=OracleBasCustomer::query()->select('customerid','descr_c')->where('customer_type','OW')->where('active_flag','Y')->get();
+//        $owners=OracleBasCustomer::query()->select('customerid','descr_c')->where('customer_type','OW')->where('active_flag','Y')->get();
+        $owners=Owner::filterAuthorities()->select(['code', 'name'])->get();
         $isTotalStock=true;
         $page = $request->page ?? 1;
         return view('inventory.statement.changeInventory',compact('oracleActTransactingLogs','page','owners','isTotalStock'));

+ 0 - 16
app/Http/Controllers/RejectedBillController.php

@@ -270,20 +270,4 @@ class RejectedBillController extends Controller
         $order=OracleDOCOrderHeader::select('soreference1','customerid','c_contact','c_tel2','carrierid')->where('soreference5',$request->soreference5)->first();
         if ($order)return ['success'=>true,'data'=>$order];
     }
-    public function apiChangeRejectedBillRemark(Request $request){
-        if(!Gate::allows('退货管理-编辑备注')){return ['success'=>'false','fail_info'=>'没有权限'];}
-        $id= $request->input('id');
-        $remark = $request->input('remark');
-        if(is_null($id) ){
-            return ['success'=>false,'fail_info'=>'参数异常'];
-        }
-        $rejectedBill=RejectedBill::query()->updateOrCreate([
-            'id'=>$id,
-        ],[
-            'id'=>$id,
-            'remark'=>$remark
-        ]);
-        $this->log(__METHOD__,'添加或者修改退单备注'.__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
-        return ['success'=>true,'status'=>$rejectedBill];
-    }
 }

+ 16 - 0
app/Http/Controllers/RejectedController.php

@@ -505,4 +505,20 @@ class RejectedController extends Controller
         }
         return ['success'=>true,'rejectedBill' => $rejectedBill];
     }
+    public function changeRejectedBillRemark(Request $request){
+        if(!Gate::allows('退货管理-编辑备注')){return ['success'=>'false','fail_info'=>'没有权限'];}
+        $id= $request->input('id');
+        $remark = $request->input('remark');
+        if(is_null($id) ){
+            return ['success'=>false,'fail_info'=>'参数异常'];
+        }
+        $rejectedBill=RejectedBill::query()->updateOrCreate([
+            'id'=>$id,
+        ],[
+            'id'=>$id,
+            'remark'=>$remark
+        ]);
+        $this->log(__METHOD__,'添加或者修改退单备注'.__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
+        return ['success'=>true,'status'=>$rejectedBill];
+    }
 }

+ 28 - 9
app/Services/AllInventoryService.php

@@ -2,11 +2,13 @@
 
 namespace App\Services;
 
+use App\Owner;
 use Illuminate\Support\Facades\DB;
 
 Class AllInventoryService
 {
     public function getSql(array $params, $page=null, $paginate=null){
+        $ownerCodes=Owner::filterAuthorities()->select('code')->get();
         $date_start=$params['date_start'] ?? null;
         $range = $params['range'] ?? null;
         if ($range)$date_start=date('Y-m-d',strtotime('-'.$range." day"));
@@ -27,6 +29,23 @@ Class AllInventoryService
         $sql.=' left join BAS_Customer customer on customer.CustomerID=storeStatus.CUSTOMERID ';
         $sql.=' left join BAS_SKU sku on sku.SKU=storeStatus.SKU and sku.CUSTOMERID=storeStatus.CUSTOMERID ';
         $sql.=' left join INV_LOT_ATT lot on lot.LOTNUM = storeStatus.LOTNUM AND lot.CUSTOMERID = storeStatus.CUSTOMERID ';
+        if ($customerid){
+            $sql .= ' where storeStatus.CUSTOMERID in (';
+            $arr = explode(',',$customerid);
+            foreach ($arr as $index => $data){
+                if ($index != 0)$sql .= ',';
+                $sql .= "'".$data."'";
+            }
+            $sql .= ') ';
+        }
+        if (!$customerid&&$ownerCodes){
+            $sql .= ' where storeStatus.CUSTOMERID in (';
+            foreach ($ownerCodes as $index => $data){
+                if ($index != 0)$sql .= ',';
+                $sql .= "'".$data['code']."'";
+            }
+            $sql .= ') ';
+        }
         $sql.=' group by storeStatus.LocationID,customer.Descr_C,sku.SKU,sku.ALTERNATE_SKU1 ';
         $sql.=' ,sku.Descr_C,lot.LotAtt05,lot.LotAtt08,lot.LotAtt02,lot.LotAtt04 ';
         $sql.=' , storeStatus.QTY, storeStatus.QtyAllocated,storeStatus.CUSTOMERID,storeStatus.ADDTIME  ';
@@ -38,15 +57,15 @@ Class AllInventoryService
         if ($date_end)$sql.=" and 创建时间 < to_date('".$date_end." 23:59:59','yyyy-mm-dd hh24:mi:ss') ";
         if ($LotAtt02_start)$sql.=" and 失效日期 >='".$LotAtt02_start." 00:00:00' ";
         if ($LotAtt02_end)$sql.=" and 失效日期 <='".$LotAtt02_end." 23:59:59' ";
-        if ($customerid){
-            $sql .= ' and 客户 in (';
-            $arr = explode(',',$customerid);
-            foreach ($arr as $index => $data){
-                if ($index != 0)$sql .= ',';
-                $sql .= "'".$data."'";
-            }
-            $sql .= ') ';
-        }
+//        if ($customerid){
+//            $sql .= ' and 客户 in (';
+//            $arr = explode(',',$customerid);
+//            foreach ($arr as $index => $data){
+//                if ($index != 0)$sql .= ',';
+//                $sql .= "'".$data."'";
+//            }
+//            $sql .= ') ';
+//        }
         if ($ALTERNATE_SKU1)$sql.=" and 产品条码 like '".$ALTERNATE_SKU1."' ";
         if ($page&&$paginate)$sql.="  and ROWNUM<='".$page*$paginate."'";
         $sql.=' )  ';

+ 34 - 0
app/Services/InventoryService.php

@@ -5,12 +5,14 @@ namespace App\Services;
 
 use App\inventoryDailyLog;
 use App\InventoryDailyLoggingOwner;
+use App\Owner;
 use App\Services\common\QueryService;
 use Illuminate\Support\Facades\DB;
 
 class InventoryService
 {
     public function getSql(array $params,$page=null,$paginate=null){
+        $ownerCodes=Owner::filterAuthorities()->select('code')->get();
         $date_start=$params['date_start'] ?? null;
         $range = $params['range'] ?? null;
         if ($range)$date_start=date('Y-m-d',strtotime('-'.$range." day"));
@@ -43,6 +45,14 @@ class InventoryService
             }
             $sql .= ') ';
         }
+        if (!$customerid&&$ownerCodes){
+            $sql .= ' and TOCustomerID in (';
+            foreach ($ownerCodes as $index => $data){
+                if ($index != 0)$sql .= ',';
+                $sql .= "'".$data['code']."'";
+            }
+            $sql .= ') ';
+        }
         $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' ";
@@ -59,6 +69,14 @@ class InventoryService
             }
             $sql .= ') ';
         }
+        if (!$customerid&&$ownerCodes){
+            $sql .= ' and FMCUSTOMERID in (';
+            foreach ($ownerCodes as $index => $data){
+                if ($index != 0)$sql .= ',';
+                $sql .= "'".$data['code']."'";
+            }
+            $sql .= ') ';
+        }
         $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' ";
@@ -75,6 +93,14 @@ class InventoryService
             }
             $sql .= ') ';
         }
+        if (!$customerid&&$ownerCodes){
+            $sql .= ' and FMCUSTOMERID in (';
+            foreach ($ownerCodes as $index => $data){
+                if ($index != 0)$sql .= ',';
+                $sql .= "'".$data['code']."'";
+            }
+            $sql .= ') ';
+        }
         $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' ";
@@ -91,6 +117,14 @@ class InventoryService
             }
             $sql .= ') ';
         }
+        if (!$customerid&&$ownerCodes){
+            $sql .= ' and TOCustomerID in (';
+            foreach ($ownerCodes as $index => $data){
+                if ($index != 0)$sql .= ',';
+                $sql .= "'".$data['code']."'";
+            }
+            $sql .= ') ';
+        }
         $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.客户 ';

+ 1 - 0
app/Services/RejectedService.php

@@ -28,6 +28,7 @@ class RejectedService
             'created_at_end' => ['alias' => 'created_at', 'endDate' => ' 23:59:59'],
             'owner_id' => ['alias' => 'id_owner', 'multi' => ','],
             'order_number' => ['like' => ''],
+            'remark' => ['like' => '','timeLimit'=>15],
             'logistic_number' => ['like' => ''],
             'mobile_sender' => ['like' => ''],
             'checked_numbers' => ['like' => ''],

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

@@ -64,7 +64,8 @@
                 page:Number('{{$page}}'),
                 owners:[
                     @foreach($owners as $owner)
-                    {name:'{{$owner->customerid}}',value:'{{$owner->descr_c}}'},
+                    {{--{name:'{{$owner->customerid}}',value:'{{$owner->descr_c}}'},--}}
+                    {name:'{{$owner->code}}',value:'{{$owner->name}}'},
                     @endforeach
                 ],
                 checkData:[],

+ 20 - 18
resources/views/rejected/search/general.blade.php

@@ -120,9 +120,9 @@
 {{--                        <td class="text-muted" style="max-width: 190px">@{{rejectedBill.remark}}</td>--}}
                         <td style="min-width:150px;">
                             @can('退货管理-编辑备注')
-                                <textarea  v-if="rejectedBill.remark" class="btn-sm btn-outline-secondary btn" @click="rejectedBillRemarkCheck($event)" :data_id="rejectedBill.id">@{{rejectedBill.remark}}</textarea>
-                                <textarea v-else class="form-control form-control-sm" @blur="addRejectedBillRemark($event)" onfocus="$(this).css('width','200px')" :value="rejectedBill.remark" :data_id="rejectedBill.id" ></textarea>
-                                <textarea type="text" class="form-control form-control-sm"  @blur="updateRejectedBillRemark($event)" :value="rejectedBill.remark" :data_id="rejectedBill.id" style="min-width:200px;display: none"></textarea>
+                                <textarea  v-if="rejectedBill.remark&&rejectedBill.remark.length>=8" :rows="Math.ceil(rejectedBill.remark.length/8)"  cols=8  class="form-control form-control-sm" @click="rejectedBillRemarkCheck($event)" :data_id="rejectedBill.id" style="width:200px;">@{{rejectedBill.remark}}</textarea>
+                                <textarea v-else class="form-control form-control-sm"  @blur="addRejectedBillRemark($event)" onfocus="$(this).css('width','150px')" :value="rejectedBill.remark" :data_id="rejectedBill.id" ></textarea>
+                                <textarea type="text" class="form-control form-control-sm"  @blur="updateRejectedBillRemark($event)" :value="rejectedBill.remark" :data_id="rejectedBill.id" style="min-width:150px;display: none"></textarea>
                             @else
                                 <span v-if="rejectedBill.remark">@{{rejectedBill.remark}}</span>
                             @endcan
@@ -223,6 +223,7 @@
                         {name:'logistic_number',type:'input',tip:'原单单号:可在两侧增加百分号(%)进行模糊搜索',placeholder:'原单单号'},
                         {name:'is_checked',type:'select',placeholder: '是否审核',data:[{name:1,value:'已审核'},{name:0,value:'未审核'}]},
                         {name:'id_logistic_return',type:'select',placeholder: '快递名称',data:this.logistics},
+                        {name:'remark',type:'input',tip:'退单备注:默认查询15天以内记录信息',placeholder: '退单备注'},
                     ],[
                         {name:'created_at_end',type:'dateTime',tip:'选择显示指定日期的结束时间'},
                         {name:'barcode_goods',type:'input',tip:'商品条码:可模糊匹配右边未填完的部分,按回车提交',placeholder:'商品条码'},
@@ -304,9 +305,9 @@
                 rejectedBillRemarkCheck:function (e) {
                     let target = $(e.target);
                     target.hide();
-                    let input = target.next();
-                    input.show();
-                    input.focus();
+                    let textarea = target.next();
+                    textarea.show();
+                    textarea.focus();
                 },
                 // 失焦事件
                 updateRejectedBillRemark:function (e) {
@@ -317,7 +318,7 @@
                     let oldRemark = span.text();
                     let remark = target.val();
                     if(remark !== span.text()){
-                        let ajaxUrl= '{{url("apiLocal/rejectedBill/apiChangeRejectedBillRemark")}}';
+                        let ajaxUrl= '{{url("rejected/changeRejectedBillRemark")}}';
                         axios.post(ajaxUrl,{'id':id,'remark':remark}).then(function (response) {
                             if(response.data.success){
                                 _this.updateRejectedBills(id,remark);
@@ -339,37 +340,39 @@
                 },
                 addRejectedBillRemark(e){
                     let target = $(e.target);
-                    target.css('width','200px');
+                    target.css('width','150px');
                     let _this = this;
                     let id = target.attr('data_id');
                     console.log(id)
                     let remark = target.val();
-                    let ajaxUrl= '{{url("apiLocal/rejectedBill/apiChangeRejectedBillRemark")}}';
+                    let ajaxUrl= '{{url("rejected/changeRejectedBillRemark")}}';
                     if(remark === ''|| remark === null){
-                        target.css('width','200px');
+                        target.css('width','150px');
                         return;
                     }else{
                         axios.post(ajaxUrl,{'id':id,'remark':remark}).then(function (response) {
                             if(response.data.success){
+                                console.log(response,remark)
+                                _this.updateRejectedBills(id,remark);
                                 tempTip.setDuration(2000);
                                 tempTip.showSuccess('备注添加成功');
-                                _this.updateRejectedBills(id,remark);
                             }else{
                                 tempTip.setDuration(3000);
                                 tempTip.show('备注添加失败!'+response.data.fail_info);
                             }
                         }).catch(function (err) {
                             tempTip.setDuration(3000);
-                            tempTip.show('备注添加失败!网络异常:'+response.data.fail_info);
+                            tempTip.show('备注添加失败!网络异常:'+err);
                         });
                         target.css('width','75px');
                     }
                 },
                 // 更新表格数据
-                updateRejectedBills(id,newFee){
+                updateRejectedBills(id,remark){
                     this.rejectedBills.some(function(rejectedBill){
-                        if(rejectedBill.id === id){
-                            rejectedBill.remark = newFee;
+                        if(parseInt(rejectedBill.id) === parseInt(id)){
+                            console.log(remark)
+                            rejectedBill.remark = remark;
                             return true;
                         }
                     })
@@ -455,7 +458,7 @@
                         alert('网络连接错误:'+e);
                         tempTip.setDuration(2500);
                         tempTip.show('审核勾选内容失败,网络连接错误:'+e);
-                        console.log(e);
+
                     });
                     $(e.target).val("")
                 },
@@ -498,7 +501,6 @@
                         alert('网络连接错误:'+e);
                         tempTip.setDuration(2500);
                         tempTip.show('审核勾选内容失败,网络连接错误:'+e);
-                        console.log(e);
                     })
                 },
                 confirmBeStored:function($e,id){
@@ -520,7 +522,7 @@
                         alert('确认失败,网络连接错误:'+e);
                         tempTip.setDuration(2500);
                         tempTip.show('确认失败,网络连接错误:'+e);
-                        console.log(e);
+
                     })
                 },
                 finishAll:function(){

+ 0 - 1
routes/apiLocal.php

@@ -19,7 +19,6 @@ Route::post('rejectedBill/update', 'RejectedBillController@apiUpdate');
 Route::post('rejectedBill/apiGetRecent', 'RejectedBillController@apiGetRecent');
 Route::post('rejectedBill/apiSetIsLoadedAll', 'RejectedBillController@apiSetIsLoadedAll');
 Route::post('rejectedBill/apiConfirmBeStored', 'RejectedBillController@apiConfirmBeStored');
-Route::post('rejectedBill/apiChangeRejectedBillRemark', 'RejectedBillController@apiChangeRejectedBillRemark');
 Route::post('rejectedBill/seekOrder','RejectedBillController@seekOrder');
 
 Route::post('logistic/numberFeatures/computeLogisticByNumber', 'LogisticNumberFeatureController@apiComputeLogisticByNumber');

+ 1 - 0
routes/web.php

@@ -181,6 +181,7 @@ Route::group(['prefix'=>'rejected'],function(){
     Route::any('export', 'RejectedController@export');
     Route::any('exportAnalyze', 'RejectedController@exportAnalyze');
     Route::post('ajaxGetRejected', 'RejectedController@ajaxGetRejected');
+    Route::post('changeRejectedBillRemark', 'RejectedController@changeRejectedBillRemark');
 });
 Route::resource('rejected', 'RejectedController');