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

Merge branch 'master' into Haozi

haozi пре 5 година
родитељ
комит
458a9a17ac

+ 1 - 1
app/Http/Controllers/Auth/LoginController.php

@@ -43,7 +43,7 @@ class LoginController extends Controller
      */
     public function __construct()
     {
-//        $this->middleware('guest')->except('logout');
+        $this->middleware('guest')->except('logout');
     }
     public function username()
     {

+ 5 - 5
app/Http/Controllers/PackageController.php

@@ -322,7 +322,7 @@ class PackageController extends Controller
             'length'=>'长(CM)',
             'width'=>'宽(CM)',
             'height'=>'高(CM)',
-            'bulk'=>'体积(CM³)',
+            'bulk'=>'体积(DM³)',
             'paperBox_name'=>'纸箱',
             'status'=>'状态',
         ]];
@@ -342,10 +342,10 @@ class PackageController extends Controller
                 'logistic_name'=>isset($package->logistic_name)?$package->logistic_name:'',
                 'measuringMachine_name'=>isset($package->measuringMachine_name)?$package->measuringMachine_name:'',
                 'weight'=>isset($package->weight)?$package->weight:'',
-                'length'=>isset($package->length)?$package->length:'',
-                'width'=>isset($package->width)?$package->width:'',
-                'height'=>isset($package->height)?$package->height:'',
-                'bulk'=>isset($package->bulk)?$package->bulk:'',
+                'length'=>isset($package->length)?$package->length/10:'',
+                'width'=>isset($package->width)?$package->width/10:'',
+                'height'=>isset($package->height)?$package->height/10:'',
+                'bulk'=>isset($package->bulk)?round($package->bulk/10000)/100:'',//立方毫米到立方分米带双小数
                 'paperBox_name'=>isset($package->paperBox_name)?$package->paperBox_name:'',
                 'status'=>isset($package->status)?$package->status:''
             ];

+ 94 - 60
app/Http/Controllers/ProcessController.php

@@ -2,6 +2,8 @@
 
 namespace App\Http\Controllers;
 
+use App\Commodity;
+use App\CommodityBarcode;
 use App\Exports\Export;
 use App\Owner;
 use App\Process;
@@ -65,6 +67,9 @@ class ProcessController extends Controller
         if ($request->input('status')){
             $processes=$processes->where('status',$request->input('status'));
         }
+        if ($request->input('code')){
+            $processes=$processes->where('code','like',$request->input('code')."%");
+        }
         if ($request->input('wms_code')){
             $processesTem=clone $processes;
             $wms_code=$request->input('wms_code');
@@ -91,7 +96,7 @@ class ProcessController extends Controller
     public function index(Request $request)
     {
         if(!Gate::allows('二次加工管理-查询')){ return redirect(url('/'));  }
-        $processes=Process::with(['tutorials','signs','processesContents'=>function($query){
+        $processes=Process::filterAuthorities()->with(['tutorials','signs','processesContents'=>function($query){
             return $query->with(['commodity'=>function($query){
                 return $query->with('barcodes');
             }]);
@@ -101,7 +106,7 @@ class ProcessController extends Controller
             return $excel;
         }
         $processes=$this->conditionQuery($request,$processes);
-        $owners=Owner::select('id','name')->get();
+        $owners=Owner::filterAuthorities()->select('id','name')->get();
         return view('process.index',['processes'=>$processes,'owners'=>$owners,'request'=>$request->input()]);
     }
 
@@ -127,10 +132,9 @@ class ProcessController extends Controller
         $id=$request->input('id');
         $processDailies=ProcessDaily::with(['processDailyParticipants','process'])->orderBy('date','DESC')
             ->where('process_id',$id)->get();
-        $process=Process::with('automaticSupplementSign')->find($id);
+        $process=Process::find($id);
         if (count($processDailies)>0){
-            if ((($process->amount)-($process->completed_amount))<=0 || $process->status=='交接完成'
-                || $process->automaticSupplementSign)$result=true;
+            if ((($process->amount)-($process->completed_amount))<=0 || $process->status=='交接完成')$result=true;
             else $result=$this->createDeficiencyData($processDailies,$today);
             if ($result){
                 $processDailies=ProcessDaily::with(['processDailyParticipants','process'])
@@ -207,15 +211,13 @@ class ProcessController extends Controller
     }
     //生成二次加工单缺失时间记录及本日记录
     private function createDeficiencyData($processDailies,$today){
-        $today=Carbon::parse($today);
         $processDailiesArr=[];
         foreach ($processDailies as $processDaily){
             $processDailiesArr[$processDaily->date]=$processDaily;
         }
         $processDailyOne=$processDailies[count($processDailies)-1];
         $startDate=Carbon::parse($processDailyOne->date);
-        $diffDay=$startDate->diffInDays($today,false);
-        if ($diffDay<1)return true;
+        $diffDay=$startDate->diffInDays($today,true);
         $remain=$processDailyOne->remain;
         $processId=$processDailyOne->process_id;
         for ($i=1;$i<=$diffDay;$i++){
@@ -489,13 +491,6 @@ class ProcessController extends Controller
         $this->log(__METHOD__,"登记工时参与人审核".__FUNCTION__,json_encode($processDailyParticipant),Auth::user()['id']);
         return ['success'=>true,'processDailyParticipant'=>$processDailyParticipant];
     }
-    /*//临时工详情
-    public function showUserDetail(Request $request){
-        $id=$request->input('user_id');
-        $userDetail=UserDetail::with('user_labor')->find($id);
-        if (!$userDetail) return ['success'=>'false'];
-        return ['success'=>'true','userDetail'=>$userDetail];
-    }*/
     //获取全部教程
     public function getTutorials($id){
         $process=Process::with('tutorials')->find($id);
@@ -622,10 +617,10 @@ class ProcessController extends Controller
         if (count($errors)>0)return ['success'=>false,'data'=>'非法参数!'];
         $process=Process::with('signs')->find($request->id);
         if (!$process || $process->status!='交接完成' || count($process->signs)>0)return ['success'=>false,'data'=>'无法操作该二次加工单!'];
-        $process->update(['unit_price'=>$request->unit_price]);
+        $process->createSignUnitPrice($request->unit_price);
         $sign=$process->createSign('发起修改');
         $this->log(__METHOD__,"修改二次加工单价格_".__FUNCTION__,json_encode($request->input()),Auth::user()['id']);
-        return ['success'=>true,'data'=>$process->unit_price,'sign'=>$sign];
+        return ['success'=>true,'sign'=>$sign];
     }
 
     //二次加工组审核   两个方法大体相同 拆分原因是为了精确区分权限
@@ -649,13 +644,21 @@ class ProcessController extends Controller
         }
         if (isset($signMap[$msg]))return ['success'=>false,'data'=>'该单已被确认过!'];
         if (isset($signMap['二次加工组确认'])){
-            $this->statistic($process);
+            $signUnitPrice=$process->signUnitPrice();
+            if ($signUnitPrice){
+                $process->update(['unit_price' => $signUnitPrice->mark]);
+                $this->statistic($process);
+            }
             $process->createSign('财务确认');
             $process->destroySign();
             return ['success'=>true,'data'=>false];
         }
         if (isset($signMap['财务确认'])){
-            $this->statistic($process);
+            $signUnitPrice=$process->signUnitPrice();
+            if ($signUnitPrice){
+                $process->update(['unit_price' => $signUnitPrice->mark]);
+                $this->statistic($process);
+            }
             $process->createSign('二次加工组确认');
             $process->destroySign();
             return ['success'=>true,'data'=>false];
@@ -805,15 +808,15 @@ class ProcessController extends Controller
     }
     //加工完成
     function processAccomplish(Request $request){
-       if(!Gate::allows('二次加工管理-登记工时')){ return ['success'=>false,'data'=>'您无权进行该操作!'];  }
-       $process= Process::find($request->id);
-       if (!$process)return ['success'=>false];
-       $process->update([
-           'status'=>'待验收'
-       ]);
-       $process->createOperatorLog('加工完成');
+        if(!Gate::allows('二次加工管理-登记工时')){ return ['success'=>false,'data'=>'您无权进行该操作!'];  }
+        $process= Process::find($request->id);
+        if (!$process)return ['success'=>false];
+        $process->update([
+            'status'=>'待验收'
+        ]);
+        $process->createOperatorLog('加工完成');
         $this->log(__METHOD__,"标记加工完成_".__FUNCTION__,json_encode($request->input()),Auth::user()['id']);
-       return ['success'=>true,'data'=>'待验收'];
+        return ['success'=>true,'data'=>'待验收'];
     }
 
     //质量验收
@@ -832,7 +835,7 @@ class ProcessController extends Controller
     //回收站
     function recycle(Request $request){
         if(!Gate::allows('二次加工管理-删除')){ return redirect('/');  }
-        $processes=Process::onlyTrashed()->paginate($request->paginate??50);
+        $processes=Process::filterAuthorities()->onlyTrashed()->paginate($request->paginate??50);
         return view('process.recycle',compact('processes'));
     }
 
@@ -857,11 +860,11 @@ class ProcessController extends Controller
 
     //修改二次加工单每日单的起始日期
     public function updateStartDate(Request $request){
-        $start_date=$request->date;
+        $start_date=$request->start_date;
         $process_id=$request->process_id;
         if (!$start_date || !$process_id)return ['success'=>false,'data'=>'起始日期为空或单据已不存在!'];
         $processDailiesId=[];
-        $processDailies=ProcessDaily::where('process_id',$process_id)->orderBy('date','DESC')->get();
+        $processDailies=ProcessDaily::where('process_id',$process_id)->get();
         $is_process_daily=false;
         foreach ($processDailies as $processDaily){
             if ($processDaily->date == $start_date){
@@ -891,38 +894,69 @@ class ProcessController extends Controller
         $this->log(__METHOD__,"修改二次加工单加工日记录_".__FUNCTION__,json_encode($request),Auth::user()['id']);
         return ['success'=>true,'data'=>$processDailies];
     }
-
-    //修改二次加工单终止日期
-    public function updateEndDate(Request $request){
-        $end_date=$request->date;
-        $process_id=$request->process_id;
-        if (!$end_date || !$process_id)return ['success'=>false,'data'=>'终止日期为空或单据已不存在!'];
-        $processDailiesId=[];
-        $processDailies=ProcessDaily::where('process_id',$process_id)->orderBy('date','DESC')->get();
-        foreach ($processDailies as $processDaily){
-            if (Carbon::parse($processDaily->date)->gt(Carbon::parse($end_date))){
-                array_push($processDailiesId,$processDaily->id);
-                unset($processDaily);
+    //删除临时工工作记录
+    public function destroyDailyParticipant($id){
+        if (ProcessDailyParticipant::destroy($id)) return ['success'=>true];
+        return ['success'=>false , 'data'=>'记录不存在!'];
+    }
+    //导入商品数据
+    public function importPasteData(Request $request){
+        $commodities = explode("\n",$request->data); //拆分行
+        $owner='';
+        $processContents=[];
+        foreach ($commodities as $commodity){
+            $commodity = array_filter(preg_split('/[\t]+/is',$commodity)); //拆分列
+            if (count($commodity)<count($request->rows)){
+                unset($commodity);
+                continue;
             }
+            $commodityData=[];
+            $wmsCode='';
+            $barcode='';
+            $amount=0;
+            foreach ($request->rows as $index => $row){
+                if ($row == '货主'){
+                    if (isset($commodity[$index]) && $commodity[$index] && !$owner){
+                        $owner=Owner::where('code',$commodity[$index])->orWhere('name',$commodity[$index])->first();
+                        if (!$owner){
+                            $owner = Owner::create([
+                                'code' => $commodity[$index],
+                                'name' => $commodity[$index]
+                            ]);
+                        }
+                    }
+                }
+                if ($row == '单据'){
+                    $wmsCode = isset($commodity[$index]) ? $commodity[$index] : '';
+                }
+                if ($row == 'SKU'){
+                    $commodityData['sku'] = isset($commodity[$index]) ? $commodity[$index] : '';
+                }
+                if ($row == '品名'){
+                    $commodityData['name'] = isset($commodity[$index]) ? $commodity[$index] : '';
+                }
+                if ($row == '条码'){
+                    $barcode = isset($commodity[$index]) ? $commodity[$index] : '';
+                }
+                if ($row == '数量'){
+                    $amount = isset($commodity[$index]) ? $commodity[$index] : '';
+                }
+            }
+            $commodity = Commodity::query()->whereNull('owner_id')
+                ->where('sku',$commodityData['sku'])->where('name',$commodityData['name'])->first();
+            if (!$commodity)$commodity = Commodity::create($commodityData);
+            $commodityBarCode=CommodityBarcode::create([
+                'code' => $barcode,
+                'commodity_id' => $commodity->id
+            ]);
+            $processContent=['bill_type'=>'入库单','commodity_id'=>$commodity->id,'wms_code'=>$wmsCode,'amount'=>$amount,
+                'commodity_name'=>$commodity->name,'commodity_barcodes'=>[$commodityBarCode],'commodity_sku'=>$commodity->sku,
+                'lineNo'=>1,'owner_id'=>$owner->id,'owner_name'=>$owner->name,'addBtnShow'=>false,'type'=>false];
+            array_push($processContents,$processContent);
+            $processContent['type']=true;
+            array_push($processContents,$processContent);
         }
-        ProcessDaily::destroy($processDailiesId);
-        ProcessDailyParticipant::whereIn('process_daily_id',$processDailiesId)->delete();
-        $this->createDeficiencyData($processDailies,$end_date);
-        $processDailies=ProcessDaily::with('processDailyParticipants')->where('process_id',$process_id)
-            ->orderBy('date','DESC')->get();
-        $this->createAutomaticSupplement($process_id);
-        $this->log(__METHOD__,"修改二次加工单加工日记录_".__FUNCTION__,json_encode($request),Auth::user()['id']);
-        return ['success'=>true,'data'=>$processDailies];
-    }
-
-    //增加填充标记
-    private function createAutomaticSupplement($process_id){
-        Sign::create([
-            'signable_type'=>'processes',
-            'signable_id'=>$process_id,
-            'field'=>'automatic_supplement',
-            'mark'=>"停止自动补充每日记录单"
-        ]);
+        return ['success'=>true,'data'=>$processContents];
     }
 
     //执行

+ 24 - 26
app/Http/Controllers/TestController.php

@@ -10,6 +10,7 @@ use App\Events\CancelOrder;
 use App\Events\WmsReceiveNewEvent;
 use App\Http\Controllers\Api\thirdPart\flux\WaybillController;
 use App\Logistic;
+use App\OracleActAllocationDetails;
 use App\OracleDOCOrderHeader;
 use App\OracleDocOrderPackingSummary;
 use App\OracleDOCWaveDetails;
@@ -31,7 +32,9 @@ use App\WMSReflectReceive;
 use Carbon\Carbon;
 use Endroid\QrCode\Response\QrCodeResponse;
 use Illuminate\Http\Request;
+use Illuminate\Support\Arr;
 use Illuminate\Support\Facades\DB;
+use Ramsey\Uuid\Uuid;
 use function PHPSTORM_META\map;
 use Zttp\Zttp;
 
@@ -121,31 +124,10 @@ class TestController extends Controller
     }
     function t1(Request $request)
     {
-        {
-            $username=config('database.connections.oracle.username');
-            $password=config('database.connections.oracle.password');
-            $host=config('database.connections.oracle.host');
-            $service_name=config('database.connections.oracle.service_name');
-            $conn=oci_connect($username,$password,$host.'/'.$service_name); //连接oracle数据库
-            $IN_WarehouseID='';
-            $IN_TraceID='' ;
-            $IN_WavenNo='';
-            $IN_UserID='';
-            $IN_Language='';
-            $OUT_Return_Code='';
-            $sql_sp="begin SPCUS_EDI_WCS001(:IN_WarehouseID,:IN_Process_Action_C,:IN_Process_By_C,
-        :IN_WaveNO_C,:IN_OrderNO_C,:IN_OrderLineNO_C,:IN_AllocationDetailsID,:IN_Language,:IN_UserID,:OUT_Return_Code); end;";
-            $stmt = oci_parse($conn, $sql_sp);
-            oci_bind_by_name($stmt,':IN_Warehouse',$IN_WarehouseID);
-            oci_bind_by_name($stmt,':IN_TraceID',$IN_TraceID);
-            oci_bind_by_name($stmt,':IN_WavenNo',$IN_WavenNo);
-            oci_bind_by_name($stmt,':IN_Language',$IN_Language);
-            oci_bind_by_name($stmt,':IN_UserID',$IN_UserID);
-            oci_bind_by_name($stmt,':OUT_Return_Code',$OUT_Return_Code);
-            return oci_execute($stmt);
-
-        }
-
+        $package=Package::first();
+        $package->length=31;
+        $package->save();
+        dd($package);
 
     }
 
@@ -192,7 +174,20 @@ class TestController extends Controller
 
     public function delme()
     {
-        dd(DB::connection('oracle')->insert("insert into delme_log (id,name)values(?,?)",[32,'xx']));
+        $package=new Package([
+            'logistic_number'=>'546683955954',
+            'delivery_number'=>'546683955954',
+            'measuring_machine_id'=>'mm',
+            'weight'=>12,
+            'length'=>33,
+            'width'=>22,
+            'height'=>11,
+            'weighed_at'=>now(),
+            'status'=>"无",
+        ]);
+        $package->fetchAllFromOracle();
+        dd($package->toJson());
+        $package->fetchPaperBox();
     }
     public function excelIt()
     {
@@ -267,6 +262,9 @@ class TestController extends Controller
     /*1*/
     function test()
     {/**/
+        $a='';
+        if ($a)dd(1);
+        else dd(2);
     }
 
 }

+ 7 - 4
app/Http/Controllers/api/thirdPart/flux/StoreController.php

@@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
 use App\Store;
 use App\WMSReflectReceive;
 use App\WMSReflectReceiveSku;
+use Illuminate\Support\Facades\Auth;
 use Zttp\Zttp;
 
 class StoreController extends Controller
@@ -21,6 +22,7 @@ class StoreController extends Controller
     {
         $METHOD=__METHOD__;
         $FUNCTION=__FUNCTION__;
+        Controller::logS(__METHOD__, __FUNCTION__, '快递入库进入WMS接口:' . $store['asn_code']);
         $wmsReceiveds=WMSReflectReceive::where('ASNNO',$store['asn_code'])->get();
         if($wmsReceiveds->isEmpty()){
             (new Controller())->log(__METHOD__,'error_'.__FUNCTION__,'没有本地WMS入库单');
@@ -89,6 +91,7 @@ class StoreController extends Controller
 
             $sendingJson = json_decode($json,true);
             $url=url(config('api.flux.receive.new'));
+//            (new Controller())->log($METHOD,$FUNCTION,$store['asn_code'].'||' .json_encode($sendingJson));
             $response = Zttp::post($url, $sendingJson);
             $noIssues=true;
             $json = $response->json();
@@ -98,7 +101,7 @@ class StoreController extends Controller
             }
             if($json&&isset($json['Response'])){
                 if($json['Response']['return']['returnFlag']=='2'){
-                    (new Controller())->log($METHOD,'error_'.$FUNCTION,$response->body());
+                    (new Controller())->log($METHOD,'error_'.$FUNCTION,$store['asn_code'].'||' . $response->body());
                     return true;
                 }
 //                if(isset($json['Response']['return']['returnDesc'])&&strpos($json['Response']['return']['returnDesc'],'唯一约束')!==false){
@@ -106,18 +109,18 @@ class StoreController extends Controller
 //                    return true;
 //                }
                 if(isset($json['Response']['return']['errordescr'])&&strpos($json['Response']['return']['errordescr'],'已完成')!==false){
-                    (new Controller())->log($METHOD,'error_'.$FUNCTION,$response->body());
+                    (new Controller())->log($METHOD,'error_'.$FUNCTION,$store['asn_code'].'||' . $response->body());
                     return true;
                 }
             }
             if($noIssues&&$json['Response']['return']['returnFlag']=='1'){
                 $wmsReceived['is_uploaded']=1;
                 $wmsReceived->save();
-                (new Controller())->log($METHOD, 'success_' . $FUNCTION, $response->body());
+                (new Controller())->log($METHOD, 'success_' .$FUNCTION,  $store['asn_code'].'||' .$response->body());
                 return true;
             }else {
                 $success = false;
-                (new Controller())->log($METHOD, 'error_' . $FUNCTION, $response->body());
+                (new Controller())->log($METHOD, 'error_'.$FUNCTION, $store['asn_code'].'||' . $response->body());
             }
         });
 

+ 11 - 10
app/Http/Controllers/api/thirdPart/weight/PackageController.php

@@ -185,14 +185,15 @@ class PackageController extends Controller
         rsort($edges);
         $fluxController=new \App\Http\Controllers\Api\thirdPart\flux\PackageController();
         if ($package){
-            $package->fetchPaperBox($edges[0],$edges[1],$edges[2]);
-            $package['bulk']=$edges[0]*$edges[1]*$edges[2];
             $package['measuring_machine_id']=$measuringMachine->id;
             $package['weight']=$request['weight'];
             $package['length']=$edges[0];
             $package['width']=$edges[1];
             $package['height']=$edges[2];
             $package['weighed_at']=$reqDate;
+            $package->fetchAllFromOracle();
+            $package->fetchPaperBox();
+            $package['bulk']=$edges[0]*$edges[1]*$edges[2];
             if ($package->isActivityBatch()){//处理活动波次
                 $this->log(__METHOD__,__FUNCTION__,"依波次号同步所有包裹:".json_encode($package),null);
                 $package->unifyThisMeasureUnderSameBatch();
@@ -230,7 +231,14 @@ class PackageController extends Controller
                 'status'=>"无",
             ]);
             $package->fetchAllFromOracle();
-            $package->fetchPaperBox($edges[0], $edges[1], $edges[2]);
+            $package->fetchPaperBox();
+            try{
+                $package->save();
+            }catch (\Exception $e){
+                $response=["msg"=>"保存时发生错误(未下发)!","code"=>500,"data"=>null];
+                $this->log(__METHOD__,'weightApi(ERROR)'.__FUNCTION__,json_encode($request).'||'.json_encode($response).'||'.json_encode($e),null);
+                return json_encode($response,JSON_UNESCAPED_UNICODE);
+            }
             $result=$fluxController->accomplishToWMS($package);
             if(!$package['batch_number'])
                 FetchPackageFromOracle::dispatch($package)->delay(Carbon::now()->addMinutes(1440));
@@ -239,13 +247,6 @@ class PackageController extends Controller
                 $response=["msg"=>"写入WMS失败!","code"=>500,"data"=>null];
                 return json_encode($response,JSON_UNESCAPED_UNICODE);
             }
-            try{
-                $package->save();
-            }catch (\Exception $e){
-                $response=["msg"=>"保存时发生错误(未下发)!","code"=>500,"data"=>null];
-                $this->log(__METHOD__,'weightApi(ERROR)'.__FUNCTION__,json_encode($request).'||'.json_encode($response),null);
-                return json_encode($response,JSON_UNESCAPED_UNICODE);
-            }
         }
         if(!empty($package->order_code))
             Waybill::setWeightByOrderCode($package->order_code,$package->weight);

+ 1 - 1
app/OracleDocOrderPackingSummary.php

@@ -20,7 +20,7 @@ class OracleDocOrderPackingSummary extends Model
             ->leftJoin('act_allocation_details','doc_wave_details.orderno','act_allocation_details.orderno')->get();
         $numbersesOfBatch=$numbersesOfBatch->unique('logistic_number');
         $numbersUseful=$numbersesOfBatch->map(function($numbers){return $numbers['logistic_number'];});
-        $oneIdxAsrsReceive=OracleDocOrderPackingSummary::whereIn('traceid',$numbersUseful)->first();
+        $oneIdxAsrsReceive=OracleDocOrderPackingSummary::whereIn('traceid',$numbersUseful)->get();
         if($oneIdxAsrsReceive->count()<$numbersesOfBatch->count()){
             $numbersUseful=[];
             foreach($numbersesOfBatch as $numbers){//跳过idx_asrs_receive已有快递单号

+ 63 - 44
app/Package.php

@@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
 use Carbon\Carbon;
 use Illuminate\Database\Eloquent\Model;
 use App\Traits\ModelTimeFormat;
+use Illuminate\Support\Arr;
 
 class Package extends Model
 {
@@ -24,14 +25,16 @@ class Package extends Model
         'WMSReflectPackage_name'
     ];
     static protected $oracleOrderHeaderFields = [
-    'doc_order_header.userdefine1',
-    'doc_order_header.userdefine2',
-    'doc_order_header.soreference5',
-    'doc_order_header.waveno',
-    'doc_order_header.orderno',
-    'doc_order_header.customerid',
-    'doc_order_header.consigneename',
-    'doc_order_header.carrierid'
+        'doc_order_header.userdefine1',
+        'doc_order_header.soreference5',
+        'doc_order_header.waveno',
+        'doc_order_header.orderno',
+        'doc_order_header.customerid',
+        'doc_order_header.consigneename',
+        'doc_order_header.carrierid',
+        'doc_order_header.c_tel1',
+        'doc_order_header.c_tel2',
+        'doc_wave_header.descr',
     ];
     protected $tempFields=[
         'temOracleInfo','temOwner','temLogistic',
@@ -55,18 +58,22 @@ class Package extends Model
     public function WMSReflectPackage(){
         return $this->hasOne('App\WMSReflectPackage','SOReference5','logistic_number');
     }
-    public function save(array $options=[]){
-        foreach ($this->tempFields as $field){
-            unset($this->$field);
-        }
-        parent::save($options);
-    }
 
-    public function update(array $attributes=[],array $options=[]){
-        foreach ($this->tempFields as $field){
-            unset($this->$field);
-        }
-        parent::update($attributes,$options);
+    public function setLengthAttribute($value){
+        if(empty((int)($value)))return;
+        $this->attributes['length'] = $value;
+    }
+    public function setWidthAttribute($value){
+        if(empty((int)($value)))return;
+        $this->attributes['width'] = $value;
+    }
+    public function setHeightAttribute($value){
+        if(empty((int)($value)))return;
+        $this->attributes['height'] = $value;
+    }
+    public function setBulkAttribute($value){
+        if(empty((int)($value)))return;
+        $this->attributes['bulk'] = $value;
     }
 
     public function isActivityBatch(){
@@ -103,58 +110,67 @@ class Package extends Model
     }
 
     public function fetchLogisticFromOracle(){
-        if(!$this['oracleInfo'])return null;
-        if($this['temLogistic'])return $this['temLogistic'];
-        Controller::logs(__METHOD__, __FUNCTION__, "tempPackage:{$this['oracleInfo']['carrierid']}||SOR:{$this['oracleInfo']['SOReference5']}||sor:{$this['oracleInfo']['soreference5']}||orderno:{$this['orderno']}" , null);
-        if(!$this['oracleInfo']['carrierid'])return null;
-        $logistic= Logistic::where('code',$this['oracleInfo']['carrierid'])->first();
+        if(empty($this->oracleInfo))return null;
+        if(Arr::exists($this->tempFields,'temLogistic'))return $this->tempFields['temLogistic'];
+        Controller::logs(__METHOD__, __FUNCTION__, "tempPackage:{$this->oracleInfo['carrierid']}||SOR:{$this->oracleInfo['SOReference5']}||sor:{$this->oracleInfo['soreference5']}||orderno:{$this['orderno']}" , null);
+        if(!$this->oracleInfo['carrierid'])return null;
+        $logistic= Logistic::where('code',$this->oracleInfo['carrierid'])->first();
         if(!$logistic){
-            Logistic::create(['code'=>$this['oracleInfo']['carrierid'],'name'=>$this['oracleInfo']['carrierid']]);
-            Controller::logs(__METHOD__, __FUNCTION__, "富勒下发找不到快递公司,添加{$this['oracleInfo']['carrierid']}" , null);
+            $logistic=Logistic::create(['code'=>$this->oracleInfo['carrierid'],'name'=>$this->oracleInfo['carrierid']]);
+            Controller::logs(__METHOD__, __FUNCTION__, "富勒下发找不到快递公司,添加{$this->oracleInfo['carrierid']}" , null);
         }
         Controller::logs(__METHOD__, __FUNCTION__, "tempPackage2:{$logistic->id}" , null);
         if(!$logistic)return null;
-        $this['temLogistic']=$logistic;
+        $this->tempFields['temLogistic']=$logistic;
         $this['logistic_id'] = $logistic['id'];
         return $logistic;
     }
     public function fetchOwnerFromOracle(){
-        if(!$this['oracleInfo'])return null;
-        if($this['temOwner'])return $this['temOwner'];
-        $owner= Owner::where('code',$this['oracleInfo']['customerid'])->first();
+        if(empty($this->oracleInfo))return null;
+        if(Arr::exists($this->tempFields,'temOwner'))return $this->tempFields['temOwner'];
+        $owner= Owner::where('code',$this->oracleInfo['customerid'])->first();
         if(!$owner){
-            Owner::create(['code'=>$this['oracleInfo']['customerid'],'name'=>$this['oracleInfo']['customerid']]);
-            Controller::logs(__METHOD__, __FUNCTION__, "富勒下发找不到货主,添加{$this['oracleInfo']['customerid']}" , null);
+            $owner=Owner::create(['code'=>$this->oracleInfo['customerid'],'name'=>$this->oracleInfo['customerid']]);
+            Controller::logs(__METHOD__, __FUNCTION__, "富勒下发找不到货主,添加{$this->oracleInfo['customerid']}" , null);
         }
         if(!$owner)return null;
-        $this['temOwner']=$owner;
+        $this->tempFields['temOwner']=$owner;
         $this['owner_id'] = $owner['id'];
         return $owner;
     }
     public function fetchAllFromOracle(){
-        if(!$this['oracleInfo'])return null;
+        if(empty($this->oracleInfo))return null;
         $this->fetchOwnerFromOracle();
         $this->fetchLogisticFromOracle();
-        $this['recipient'] = $this['oracleInfo']['consigneename'];
-        if($this['oracleInfo']['SOReference5'])
-            $this['logistic_number'] = $this['oracleInfo']['SOReference5'];
-        $this['batch_rule'] = $this['oracleInfo']['userdefine2']??null;
-        $this['batch_number'] = $this['oracleInfo']['waveno']??null;
+        $this['recipient'] = $this->oracleInfo['consigneename'];
+        $this['order_code'] = $this->oracleInfo['orderno'];
+        $this['batch_rule'] = $this->oracleInfo['descr'];
+        $this['recipient_mobile'] = $this->oracleInfo['c_tel2']??$this->oracleInfo['c_tel1'];
+        if($this->oracleInfo['soreference5'])
+            $this['logistic_number'] = $this->oracleInfo['soreference5'];
+        $this['batch_number'] = $this->oracleInfo['waveno']??null;
     }
 
     public function getOracleInfoAttribute()
     {
-        if(isset($this->temOracleInfo)&&$this->temOracleInfo)return $this->temOracleInfo;
-        if(!$this['logistic_number']&&!$this['order_code'])return '';
+        if(isset($this->tempFields['temOracleInfo']))return $this->tempFields['temOracleInfo'];
+        if(empty($this['logistic_number'])&&empty($this['order_code']))return '';
         if($this['order_code']){
             $resultOracleObjs=OracleDOCOrderHeader::select(self::$oracleOrderHeaderFields)->where('orderno',$this['order_code']);
+            $resultOracleObjs->leftJoin('doc_wave_header','doc_wave_header.waveno','doc_order_header.waveno');
         }else{
             $resultOracleObjs=OracleActAllocationDetails::select(self::$oracleOrderHeaderFields);
             $resultOracleObjs->where('picktotraceid',$this['logistic_number']);
             $resultOracleObjs->leftJoin('DOC_Order_Header','act_allocation_details.orderno','doc_order_header.orderno');
+            $resultOracleObjs->leftJoin('doc_wave_header','doc_wave_header.waveno','doc_order_header.waveno');
+        }
+        $this->tempFields['temOracleInfo']=$resultOracleObjs->first();
+        if(empty($this->tempFields['temOracleInfo'])) {
+            $resultOracleObjs=OracleDOCOrderHeader::select(self::$oracleOrderHeaderFields)->where('soreference5',$this['logistic_number']);
+            $resultOracleObjs->leftJoin('doc_wave_header','doc_wave_header.waveno','doc_order_header.waveno');
         }
-        $this->temOracleInfo=$resultOracleObjs->first();
-        return $this->temOracleInfo;
+        $this->tempFields['temOracleInfo']=$resultOracleObjs->first();
+        return $this->tempFields['temOracleInfo'];
     }
     public function getOwnerNameAttribute()
     {
@@ -178,11 +194,14 @@ class Package extends Model
 
 
     //寻找相近纸箱ID
-    public  function fetchPaperBox($max, $centre, $min, $owner_id=null){
+    public  function fetchPaperBox($max=null, $centre=null, $min=null, $owner_id=null){
         if($this['paper_box_id'])return $this['paper_box_id'];
         $sumDiffer=0;
         $maxDiffer=0;
         $paperBox_id=null;
+        if(!$max)$max=$this['length'];
+        if(!$centre)$centre=$this['width'];
+        if(!$min)$min=$this['height'];
         if(!$owner_id) $owner_id = $this['owner_id'];
         if(!$owner_id) {
             $owner = $this->fetchOwnerFromOracle();

+ 8 - 0
app/Process.php

@@ -17,6 +17,14 @@ class Process extends Model
     protected $appends=[
         'owner_name','process_method_name',
     ];
+    public static function filterAuthorities(){
+        $user=Auth::user();
+        if(!$user){
+            return (new static)->newQuery()->where('id','0');
+        }
+        $ownerIds=$user->getPermittingOwnerIdsAttribute();
+        return (new static)->newQuery()->whereIn('id',$ownerIds);
+    }
 
     public function owner(){
         return $this->belongsTo('App\Owner','owner_id','id');

+ 3 - 3
database/migrations/2020_02_10_103905_change_package_column.php

@@ -26,9 +26,9 @@ class ChangePackageColumn extends Migration
             $table->bigInteger('logistic_id')->nullable()->index()->comment('外键物流公司');
             $table->bigInteger('measuring_machine_id')->nullable()->index()->comment('外键设备');
             $table->decimal('weight')->nullable()->comment('重KG');
-            $table->decimal('length')->nullable()->index()->comment('长(cm)');
-            $table->decimal('width')->nullable()->index()->comment('宽(cm)');
-            $table->decimal('height')->nullable()->index()->comment('高(cm)');
+            $table->decimal('length')->nullable()->comment('长(cm)');
+            $table->decimal('width')->nullable()->comment('宽(cm)');
+            $table->decimal('height')->nullable()->comment('高(cm)');
             $table->decimal('bulk')->nullable()->comment('体积(cm³)');
             $table->bigInteger('paper_box_id')->nullable()->index()->comment('外键纸箱');
             $table->dateTime('weighed_at')->nullable()->comment('称重时间');

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

@@ -0,0 +1,40 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class ChangePackageColumnsDecimal extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('packages',function (Blueprint $table){
+            $table->decimal('weight',10,2)->comment('重KG')->change();
+            $table->decimal('length',10,2)->comment('长(cm)')->change();
+            $table->decimal('width',10,2)->comment('宽(cm)')->change();
+            $table->decimal('height',10,2)->comment('高(cm)')->change();
+            $table->decimal('bulk',16,2)->nullable()->comment('体积(cm³)')->change();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('packages', function (Blueprint $table) {
+            $table->decimal('weight',8,2)->nullable()->comment('重KG')->change();
+            $table->decimal('length',8,2)->nullable()->comment('长(cm)')->change();
+            $table->decimal('width',8,2)->nullable()->comment('宽(cm)')->change();
+            $table->decimal('height',8,2)->nullable()->comment('高(cm)')->change();
+            $table->decimal('bulk',8,2)->nullable()->comment('体积(cm³)')->change();
+        });
+    }
+}

+ 2 - 2
public/js/app.js

@@ -61945,8 +61945,8 @@ module.exports = tempTip;
 /*! no static exports found */
 /***/ (function(module, exports, __webpack_require__) {
 
-__webpack_require__(/*! D:\wamp64\www\bswas\resources\js\app.js */"./resources/js/app.js");
-module.exports = __webpack_require__(/*! D:\wamp64\www\bswas\resources\sass\app.scss */"./resources/sass/app.scss");
+__webpack_require__(/*! D:\Demo\bswas\resources\js\app.js */"./resources/js/app.js");
+module.exports = __webpack_require__(/*! D:\Demo\bswas\resources\sass\app.scss */"./resources/sass/app.scss");
 
 
 /***/ }),

+ 9 - 5
public/t.php

@@ -1,7 +1,11 @@
 <?php
 ;
-
-$str = '123';
-var_dump(json_encode($str));
-$i = 222;
-var_dump(json_encode($i));
+$arr=['a'=>'1', 'b',
+];
+var_dump(empty((int)('0.00')));
+var_dump((int)('0.00'));
+var_dump(empty((int)('1.00')));
+var_dump((int)('1.00'));
+var_dump(empty(0));
+var_dump(empty(0.00));
+var_dump(empty(1));

+ 10 - 0
resources/sass/text.scss

@@ -38,3 +38,13 @@
     50%{ text-shadow: 0 0 40px red}
     100%{ text-shadow: 0 0 4px red}
 }
+
+
+.noselect {
+    -webkit-touch-callout: none; /* iOS Safari */
+    -webkit-user-select: none; /* Chrome/Safari/Opera */
+    -khtml-user-select: none; /* Konqueror */
+    -moz-user-select: none; /* Firefox */
+    -ms-user-select: none; /* Internet Explorer/Edge */
+    user-select: none;
+}

+ 2 - 2
resources/views/order/index/delivering.blade.php

@@ -44,7 +44,7 @@
                             </td>
                             <td style="width: 300px">
                                 <div class="form-inline">
-                                    <input style="max-width: 200px" name="notes" title="右侧选择查询范围,默认为一内" v-model="filterData.notes" class="form-control form-control-sm tooltipTarget" placeholder="备注" autocomplete="off" :class="filterData.notes?'bg-warning':''">
+                                    <input style="max-width: 200px" name="notes" title="右侧选择查询范围,默认为一内" v-model="filterData.notes" class="form-control form-control-sm tooltipTarget" placeholder="备注" autocomplete="off" :class="filterData.notes?'bg-warning':''">
                                     <select style="max-width: 100px" title="查询范围,范围越短搜索越快"  name="addtime" v-model="filterData.addtime" class="form-control form-control-sm tooltipTarget">
                                         <option value="1">一天内</option>
                                         <option value="31">近一月</option>
@@ -270,7 +270,7 @@
             data:{
                 filterData:{
                     paginate:50,ordertime_start:'',orderdate_start:'',orderdate_end:'',ordertime_end:'',customerid:'',orderno:'',soreference5:'',codename_c:'',
-                    carriername:'',issuepartyname:'',soreference1:'',notes:'',addtime:'1',alternate_sku1:'',waveno:'',edisendflag2:'',
+                    carriername:'',issuepartyname:'',soreference1:'',notes:'',addtime:'31',alternate_sku1:'',waveno:'',edisendflag2:'',
                 },
                 page:Number('{{$page}}'),
                 maxPage:1,

+ 116 - 14
resources/views/process/create.blade.php

@@ -7,19 +7,47 @@
     <div class="container-fluid" id="list">
         <div class="card col-md-8 offset-md-2">
             <div class="card-body">
+                <div class="modal fade" id="pasteData" tabindex="-1" role="dialog" aria-labelledby="pasteDataTitle" aria-hidden="true">
+                    <div class="modal-dialog modal-dialog-centered modal-lg" role="document">
+                        <div class="modal-content">
+                            <div class="modal-header">
+                                <div class="row modal-title font-weight-bold w-100 text-nowrap ml-1 noselect" id="pasteDataTitle">
+                                    <span v-for="(row,i) in rows" draggable="true"
+                                          @drop="drop($event,i)" @dragover="dragover($event)" @dragstart="dragstart($event,i)"
+                                          :class="row=='货主' || row=='品名' || row=='数量' ? 'text-danger' : ''"
+                                          class="col-2 border" style="cursor: move">@{{ row }}</span>
+                                </div>
+                            </div>
+                            <div class="modal-body">
+                                <textarea class="w-100" style="height: 400px;" v-model="pasteData"
+                                placeholder="内容必须为EXCEL复制,请注意表头顺序,可拖拽调整顺序,以该顺序为准"
+                                ></textarea>
+                            </div>
+                            <div class="modal-footer">
+                                <button class="btn btn-dark" @click="importPasteData()">开始导入</button>
+                            </div>
+                        </div>
+                    </div>
+                </div>
                 <div class="row">
                     <div class="col-6  rounded mb-2 border" style="background: #efe3d9;">
                         <div class="form-group row mt-2">
                             <label class="col-2 text-right mt-2">原料单据</label>
-                            <input class="form-control col-7" v-model="process.wms_code">&nbsp;&nbsp;&nbsp;
+                            <input class="form-control col-6" v-model="process.wms_code">&nbsp;&nbsp;&nbsp;
                             <button class="btn btn-info btn-sm col-2"  type="button" @click="addProcessContent(false)"> 新增库单据</button>
+                            <button class="btn btn-sm btn-dark col-1 ml-1"
+                                    data-toggle="modal" data-target="#pasteData"><small>外部导入</small></button>
                         </div>
                         <div class="form-group row">
                             <div class="col-10 offset-1 pl-0 pt-2 border rounded bg-light">
                                 <div class="row pt-2 small"><label class="col-3 text-right" >单据号</label>
                                     <b class="col-8" v-if="processContents.length>0 && processContents[0].addBtnShow && !processContents[0].type">@{{ processContents[0].wms_code }}</b></div> <!---->
                                 <div class="row pt-2" v-if="processContents.length>0 && processContents[0].addBtnShow && !processContents[0].type">
-                                    <span class="col-12 text-center text-muted small">双击选择商品:</span>
+                                    <span class="col-12 text-center text-muted small">双击选择商品:
+                                        <button class="btn btn-sm btn-outline-info ml-1 mt-0" style="transform: scale(0.8)"
+                                            @click="addAll(processContents[0])"
+                                            >添加所有</button>
+                                    </span>
                                     <span class=" col-11 offset-1 input-group" style=" border-radius: 5px; opacity: 1.5; text-align: center;">
                                         <ul onselectstart="return false;" class="list-group tooltipTarget" style="width: 100%; max-height: 130px; overflow-y: scroll;">
                                             <li  v-for="commodity in processContents[0].commodities" :id="commodity.id"  :style="[{'background-color':processContents[0].commodity_id==commodity.id ? '#9fcdff':'' },{'text-decoration':commodityIds.includes(commodity.id+'_false')? 'line-through red' : ''}]"
@@ -64,9 +92,9 @@
                         </div>
                         <div class="form-group row">
                             <div class="col-10 offset-1 p-1 border rounded bg-light" v-for="processContent in processContents" v-if="!processContent.addBtnShow && !processContent.type">
-                                <div class="col-12 border">
+                                <div class="col-12">
                                     <div class="row small" style="background-color: white;opacity: 0.7"  @mouseover="update_delBtn(true,processContent.wms_code,processContent.commodity_id,false)" @mouseleave="update_delBtn(false,processContent.wms_code,processContent.commodity_id,false)">
-                                        <span class="font-weight-bold">单据号:</span>
+                                        <span class="font-weight-bold border">单据号:</span>
                                         <span class="font-weight-bold">@{{ processContent.wms_code }}</span>
                                         <span class="ml-2 text-muted">单据类型:</span>
                                         <span class=" text-muted">@{{ processContent.bill_type }}</span>
@@ -194,7 +222,7 @@
                     <label class="col-3 col-form-label text-right" >备注(选填)</label>
                     <textarea v-model="process.remark" type="text" class="form-control col-8"></textarea>
                 </div>
-                <div class="form-group row">
+                {{--<div class="form-group row">
                     <label class="col-3 col-form-label text-right" >引用教程(选填)</label>
                     <span class=" col-8 input-group p-0" style="max-height: 150px; overflow-y: scroll;border-radius:5px;opacity:0.7;text-align: center;">
                         <ul class="list-group" style="width: 100%" onselectstart="return false;">
@@ -207,7 +235,7 @@
                             <button type="button" @click="refreshTutorial()" class="btn btn-sm btn-outline-secondary ml-2">刷新</button>
                         </div>
                     </span>
-                </div>
+                </div>--}}
                 <div class="form-group row">
                     <div class="col-8 offset-3 p-0">
                         <input type="button" @click="submit()" class="btn btn-success form-control" value="提交">
@@ -237,14 +265,16 @@
                 msg:false,
                 commodityIds:[],
                 is_delBtn:[],
-                sum:0
+                sum:0,
+                pasteData:'',
+                rows:['货主','单据','品名','SKU','条码','数量'],
             },
             watch:{
                 processContents:{
                     handler(){
                         if (this.processContents.length===1){
                             this.process.owner_id=this.processContents[(this.processContents.length)-1].owner_id;
-                            this.getTutorial(this.processContents[(this.processContents.length)-1].owner_id);
+                            //this.getTutorial(this.processContents[(this.processContents.length)-1].owner_id);
                         }
                     }
                 },
@@ -373,7 +403,7 @@
                         _this.processContents.splice(data,1);
                     });
                 },
-                //获取教程
+                /*//获取教程
                 getTutorial(owner_id){
                     let _this=this;
                     axios.post("{{url('process/ownerGetTutorials')}}"+"/"+owner_id)
@@ -390,7 +420,7 @@
                         tempTip.setDuration(5000);
                         tempTip.show('获取教程失败!网络错误:'+err);
                         });
-                },
+                },*/
                 //选择商品
                 selectedCommodity(commodity,wms_code,type){
                     let _this=this;
@@ -411,7 +441,7 @@
                        return  true;
                     });
                 },
-                //选择教程
+               /* //选择教程
                 selectedTutorial(tutorial){
                     let _this=this;
                     if (tutorial.style){
@@ -441,7 +471,7 @@
                     setTimeout(function(){
                         $(".tooltipTarget").tooltip({'trigger':'hover'});
                     },10);
-                },
+                },*/
                 //异补提交
                 submit(){
                     let _this=this;
@@ -484,7 +514,7 @@
                         tempTip.show('提交失败!网络错误:'+err);
                     });
                 },
-                //去往新增教程
+                /*//去往新增教程
                 addTutorial(){
                     window.open("{{url('maintenance/tutorial/create?owner_id=')}}"+this.process.owner_id);
                 },
@@ -493,7 +523,7 @@
                     if (this.processContents.length>=1 && this.processContents[(this.processContents.length)-1].owner_id){
                         this.getTutorial(this.processContents[(this.processContents.length)-1].owner_id);
                     }
-                },
+                },*/
                 //删除按钮的显示
                 update_delBtn(is_type,wms_code,commodity_id,type){
                     if (is_type) this.$set(this.is_delBtn,wms_code+'_'+commodity_id+'_'+type,true);
@@ -502,6 +532,78 @@
                 update_commodity_name(processContent){
                     this.$set(processContent,'is_update_commodity_name',true);
                 },
+                //添加所有
+                addAll(processContent){
+                    let _this=this;
+                    processContent.commodities.forEach(function (commodity) {
+                        if (!_this.commodityIds.includes(commodity.id+"_"+false)){
+                            let content={};
+                            content['bill_type'] = processContent.bill_type ;
+                            content['commodity_id'] = commodity.id ;
+                            content['wms_code'] = processContent.wms_code ;
+                            content['amount'] = commodity.amount ;
+                            content['commodity_name'] = commodity.name ;
+                            content['commodity_barcodes'] = commodity.barcodes ;
+                            content['commodity_sku'] = commodity.sku ;
+                            content['lineNo'] = commodity.lineNo ;
+                            content['owner_id'] = commodity.owner_id ;
+                            content['owner_name'] = commodity.owner_name ;
+                            content['addBtnShow'] = false ;
+                            content['type'] = false ;
+                            _this.processContents.unshift(content);
+                            _this.commodityIds.push(commodity.id+"_"+content['type']);
+                            _this.sum += Number(commodity.amount);
+                            if (!_this.commodityIds.includes(commodity.id+"_"+true)){
+                                let contentTemp={};
+                                Object.assign(contentTemp,content);
+                                contentTemp['type'] = true;
+                                _this.processContents.unshift(contentTemp);
+                                _this.commodityIds.push(commodity.id+"_"+contentTemp['type']);
+                                _this.sum += Number(commodity.amount);
+                            }
+                        }
+                    });
+                    _this.$delete(_this.processContents,(_this.processContents.length)-1);
+                },
+                importPasteData(){
+                    let _this=this;
+                    if (!this.pasteData){
+                        tempTip.setDuration(3000);
+                        tempTip.show('文本为空!');
+                    }
+                    axios.post('{{url('process/importPasteData')}}',{data:this.pasteData,rows:this.rows})
+                        .then(res=>{
+                            if (res.data.success){
+                                res.data.data.forEach(function (processContent) {
+                                    _this.processContents.unshift(processContent);
+                                    _this.commodityIds.push(processContent.commodity_id+"_"+processContent.type);
+                                    _this.sum += Number(processContent.amount);
+                                });
+                                $('#pasteData').modal('hide');
+                                tempTip.setDuration(2000);
+                                tempTip.showSuccess('导入完毕');
+                            } 
+                        }).catch(err=>{
+                            tempTip.setDuration(4000);
+                            tempTip.showSuccess('网络错误:'+err);
+                        });
+                },
+                dragover(e){
+                    e.preventDefault();
+                },
+                dragstart(e,index){
+                    this.dom = e.target.innerHTML;
+                    e.dataTransfer.setData("text/html",index);
+                },
+                drop(e,index){
+                    e.preventDefault();
+                    if (this.dom != e.target.innerHTML){
+                        this.dom.innerHTML = e.target.innerHTML;
+                        let temp=JSON.parse(JSON.stringify(this.rows[index]));
+                        this.$set(this.rows,index,this.rows[e.dataTransfer.getData('text/html')]);
+                        this.$set(this.rows,Number(e.dataTransfer.getData('text/html')),temp);
+                    }
+                }
             },
         });
     </script>

+ 106 - 24
resources/views/process/index.blade.php

@@ -42,17 +42,7 @@
                            <td>
                                <input id="wms_code" name="wms_code" style="max-width: 200px" title="单据号:支持15内模糊搜索与15天外精确搜索" v-model="filterData.wms_code" class="form-control form-control-sm tooltipTarget" placeholder="单据号" :class="filterData.wms_code?'bg-warning':''">
                            </td>
-                           <td colspan="6"></td>
-                       </tr>
-                       <tr>
-                           <td >
-                               <input id="date_end" name="date_end" style="max-width: 200px" v-model="filterData.date_end" type="date" class="form-control form-control-sm tooltipTarget" title="选择显示指定日期的结束时间" :class="filterData.date_end?'bg-warning':''">
-                           </td>
                            <td>
-                               <input name="commodity_barcode" style="max-width: 200px" title="商品条码:支持15内模糊搜索与15天外精确搜索" v-model="filterData.commodity_barcode" class="form-control form-control-sm tooltipTarget" placeholder="商品条码" :class="filterData.commodity_barcode?'bg-warning':''">
-                           </td>
-                           <td >
-                                <div class="form-inline">
                                <select id="status" name="status" v-model="filterData.status" @change="submit" style="max-width: 100px" class="form-control form-control-sm tooltipTarget" :class="filterData.status?'bg-warning':''" >
                                    <option value="" selected>状态</option>
                                    <option value="待审核">待审核</option>
@@ -63,10 +53,24 @@
                                    <option value="待验收">待验收</option>
                                    <option value="交接完成">交接完成</option>
                                </select>
-                                <input hidden name="is_accomplish" v-model="filterData.is_accomplish">
-                               <button class="btn btn-sm btn-outline-dark pull-left ml-5" type="submit">按条件搜索</button></div>
+                               <input hidden name="is_accomplish" v-model="filterData.is_accomplish">
+                           </td>
+                           <td colspan="5"></td>
+                       </tr>
+                       <tr>
+                           <td >
+                               <input id="date_end" name="date_end" style="max-width: 200px" v-model="filterData.date_end" type="date" class="form-control form-control-sm tooltipTarget" title="选择显示指定日期的结束时间" :class="filterData.date_end?'bg-warning':''">
+                           </td>
+                           <td>
+                               <input name="commodity_barcode" style="max-width: 200px" title="商品条码:支持15内模糊搜索与15天外精确搜索" v-model="filterData.commodity_barcode" class="form-control form-control-sm tooltipTarget" placeholder="商品条码" :class="filterData.commodity_barcode?'bg-warning':''">
+                           </td>
+                           <td>
+                               <input name="code" style="max-width: 200px" title="任务号:支持15内模糊搜索与15天外精确搜索" v-model="filterData.code" class="form-control form-control-sm tooltipTarget" placeholder="任务号" :class="filterData.code?'bg-warning':''">
+                           </td>
+                           <td >
+                               <button class="btn btn-sm btn-outline-dark pull-left" type="submit">按条件搜索</button>
                            </td>
-                           <td colspan="6"></td>
+                           <td colspan="5"></td>
                        </tr>
                        <tr>
                            <td colspan="9">
@@ -173,7 +177,8 @@
                         <div class="form-group row">
                             <label for="initial_weight" class="col-3 col-form-label text-right">晚饭时间</label>
                             <div class="col-7">
-                                <select :class="{ 'is-invalid' : errors.dinner_duration }" v-model="processDailyParticipantOne.dinner_duration" class="form-control">
+                                <select :class="{ 'is-invalid' : errors.dinner_duration }" :data-old-value="processDailyParticipantOne.dinner_duration" v-model="processDailyParticipantOne.dinner_duration"
+                                        @change="updateDinnerDuration(processDailyParticipantOne,$event)" class="form-control">
                                     <option value="0">无</option>
                                     <option value="30">30分钟</option>
                                     <option value="60">60分钟</option>
@@ -454,9 +459,9 @@
                                 <td>工时差</td>
                                 <td>计费工时</td>
                                 <td>审核</td>
-                                <td>详情</td>
+                                <td>操作</td>
                             </tr>
-                            <tr  v-for="processDailyParticipant in processDailyParticipants" :id="'processDailyParticipant'+processDailyParticipant.id">
+                            <tr  v-for="(processDailyParticipant,i) in processDailyParticipants" :id="'processDailyParticipant'+processDailyParticipant.id">
                                 <td v-if="processDailyParticipant.rowspan" :rowspan="processDailyParticipant.rowspan"><p >@{{ processDailyParticipant.date }}</p></td>
                                 <td v-if="processDailyParticipant.rowspan"  :rowspan="processDailyParticipant.rowspan">
                                     <div  class="form-inline">
@@ -501,7 +506,8 @@
                                     </span><span v-else>@{{ processDailyParticipant.unit_price }}</span></td>
                                 <td>
                                     <span v-if="!processDailyParticipant.user_detail_full_name && processDailyParticipant.isAddProcessDailyParticipant==false">
-                                        <select :class="{ 'is-invalid' : errors.dinner_duration }" :data-original-title="errors.dinner_duration ? errors.dinner_duration[0] : ''" :id="processDailyParticipant.daily_id+'dinner_duration'" class="form-control tooltipTargetError" style="width:80px">
+                                        <select :class="{ 'is-invalid' : errors.dinner_duration }" @input="hourFilter(processDailyParticipant.daily_id,true)" :data-original-title="errors.dinner_duration ? errors.dinner_duration[0] : ''"
+                                                :id="processDailyParticipant.daily_id+'dinner_duration'" class="form-control tooltipTargetError" style="width:80px">
                                             <option value="0">无</option>
                                             <option value="30">30分钟</option>
                                             <option value="60">60分钟</option>
@@ -526,7 +532,13 @@
                                     @can("人事管理-任务审核")<button @click="processDailyParticipantAudit(processDailyParticipant.id)" v-if="processDailyParticipant.status=='未审核'" class="btn btn-sm btn-outline-success">审核</button>@endcan
                                     <b v-else class="text-success">@{{ processDailyParticipant.status }}</b>
                                 </td>
-                                @can("二次加工管理-临时工资料管理")<td class="text-info"><u v-if="processDailyParticipant.user_detail_full_name" style="cursor:pointer" @click="showUserDetail(processDailyParticipant.user_id)">详情</u></td>@endcan
+                                <td>
+                                    <div v-if="processDailyParticipant.user_detail_full_name">
+                                        @can("二次加工管理-临时工资料管理")<u class="text-info" style="cursor:pointer"
+                                                                 @click="showUserDetail(processDailyParticipant.user_id)">详情</u>@endcan
+                                        <button class="btn btn-sm btn-outline-danger" @click="deleteDailyParticipant(i)">删</button>
+                                    </div>
+                                </td>
                             </tr>
                         </table>
                     </td>
@@ -564,7 +576,7 @@
                 ],
                 errors:{},
                 checkData:[],
-                filterData:{paginate:50,date_start:'',date_end:'',owner_id:'',commodity_barcode:'',wms_code:'',status:'',is_accomplish:''},
+                filterData:{paginate:50,date_start:'',date_end:'',owner_id:'',commodity_barcode:'',wms_code:'',status:'',is_accomplish:'',code:''},
                 processDailies:[],
                 processDailyParticipants:[],
                 isShow:{
@@ -612,8 +624,21 @@
                 this.resetProcessData();
                 $(".tooltipTarget").tooltip({'trigger':'hover'});
                 $('#process').removeClass('d-none');
-                var today=new Date();
+                let today=new Date();
                 this.today = today.getFullYear() + "-" + ((today.getMonth() + 1) < 10 ? "0"+(today.getMonth() + 1) : (today.getMonth() + 1)) + "-" + today.getDate();
+                function focusin() {
+                    if(isJustBack())location.reload();
+                }
+                window.enterAt=(new Date()).getTime();
+                function isJustBack() {
+                    let nowAt=(new Date()).getTime();
+                    return (nowAt-window.enterAt)<600;
+                }
+                if ("onfocusin" in document){//for IE
+                    document.onfocusin = focusin;
+                } else {
+                    window.onfocus= focusin;
+                }
             },
             methods: {
                 arrayFilter: function (processesContents, process) {
@@ -1097,14 +1122,16 @@
                         let ended_at = new Date('2020/1/1 ' + $('#' + processDailyParticipant + 'ended_at')[0].value).getTime();
                         let hour_count = (ended_at - started_at) / 3600000;
                         if (started_at < start && ended_at > end) hour_count -= 1;
-                        $('#' + processDailyParticipant + 'hour_count')[0].value = hour_count;
+                        let dinner_duration=Number($('#' + processDailyParticipant + 'dinner_duration')[0].value)/60;
+                        $('#' + processDailyParticipant + 'hour_count')[0].value = (hour_count - dinner_duration).toFixed(1);
                         return;
                     }
                     let started_at = new Date('2020/1/1 ' + processDailyParticipant.started_at).getTime();
                     let ended_at = new Date('2020/1/1 ' + processDailyParticipant.ended_at).getTime();
                     let hour_count = (ended_at - started_at) / 3600000;
                     if (started_at < start && ended_at > end) hour_count -= 1;
-                    processDailyParticipant.hour_count = hour_count;
+                    let dinner_duration=Number(processDailyParticipant.dinner_duration) / 60;
+                    processDailyParticipant.hour_count = (hour_count - dinner_duration).toFixed(1);
                 },
                 //提交参与人
                 submitProcessDailyParticipant(e) {
@@ -1489,11 +1516,10 @@
                     axios.post('{{url('process/updateUnitPrice')}}', {id: process.id, unit_price: unit_price})
                         .then(function (response) {
                             if (response.data.success) {
-                                process.unit_price = response.data.data;
                                 process.signs.push(response.data.sign);
                                 process.is_update_unit_price = false;
                                 tempTip.setDuration(2000);
-                                tempTip.showSuccess('“' + process.code + "”价格修改成功!");
+                                tempTip.showSuccess('“' + process.code + "”价格修改成功,确认通过后生效!");
                                 return;
                             }
                             tempTip.setDuration(3000);
@@ -1577,6 +1603,62 @@
                             tempTip.show('网络错误:'+err);
                         })
                 },
+                resetProcessDailyParticipants(index){
+                    if (this.processDailyParticipants[index].daily_id){
+                        if (this.processDailyParticipants[index+1] && !this.processDailyParticipants[index+1].daily_id){
+                            this.processDailyParticipants[index+1].daily_id=this.processDailyParticipants[index].daily_id;
+                            this.processDailyParticipants[index+1].date=this.processDailyParticipants[index].date;
+                            this.processDailyParticipants[index+1].isAddProcessDailyParticipant=this.processDailyParticipants[index].isAddProcessDailyParticipant;
+                            this.processDailyParticipants[index+1].isConfirmBtn=this.processDailyParticipants[index].isConfirmBtn;
+                            this.processDailyParticipants[index+1].output=this.processDailyParticipants[index].output;
+                            this.processDailyParticipants[index+1].process_id=this.processDailyParticipants[index].process_id;
+                            this.processDailyParticipants[index+1].readonly=this.processDailyParticipants[index].readonly;
+                            this.processDailyParticipants[index+1].remain=this.processDailyParticipants[index].remain;
+                            this.processDailyParticipants[index+1].rowspan=this.processDailyParticipants[index].rowspan - 1;
+                            this.processDailyParticipants[index+1].submitOutput=this.processDailyParticipants[index].submitOutput;
+                            this.$delete(this.processDailyParticipants,index);
+                        }else{
+                            let processDailyParticipant = {
+                                'daily_id': this.processDailyParticipants[index].daily_id,
+                                'date': this.processDailyParticipants[index].date,
+                                'isAddProcessDailyParticipant': this.processDailyParticipants[index].isAddProcessDailyParticipant,
+                                'isConfirmBtn': this.processDailyParticipants[index].isConfirmBtn,
+                                'output': this.processDailyParticipants[index].output,
+                                'process_id': this.processDailyParticipants[index].process_id,
+                                'readonly': this.processDailyParticipants[index].readonly,
+                                'remain': this.processDailyParticipants[index].remain,
+                                'rowspan': this.processDailyParticipants[index].rowspan,
+                                'submitOutput': this.processDailyParticipants[index].submitOutput,
+                            };
+                            this.$set(this.processDailyParticipants,index,processDailyParticipant);
+                        }
+                    }
+                    else this.$delete(this.processDailyParticipants,index);
+                },
+                deleteDailyParticipant(index){
+                    let _this=this;
+                    if (!confirm('确定要删除“' + _this.processDailyParticipants[index].user_detail_full_name + "”的工作记录吗?"))return;
+                    axios.delete('{{url('process/destroyDailyParticipant')}}/'+_this.processDailyParticipants[index].id)
+                        .then(res=>{
+                            if (res.data.success){
+                                _this.resetProcessDailyParticipants(index);
+                                tempTip.setDuration(2000);
+                                tempTip.showSuccess('删除“'+_this.processDailyParticipants[index].user_detail_full_name+'”的工作记录成功!');
+                                return;
+                            }
+                            tempTip.setDuration(3000);
+                            tempTip.show(res.data.data);
+                        }).catch(err=>{
+                            tempTip.setDuration(4000);
+                            tempTip.show('网络错误:'+err);
+                        })
+                },
+                //修改时的晚饭时间改变计时工时
+                updateDinnerDuration(processDailyParticipantOne,e){
+                    let oldValue=Number(e.target.dataset.oldValue) / 60;
+                    let newValue=Number(processDailyParticipantOne.dinner_duration) / 60;
+                    processDailyParticipantOne.hour_count += (oldValue-newValue);
+                },
             },
         });
     </script>

+ 13 - 3
resources/views/weight/package/index.blade.php

@@ -99,7 +99,7 @@
                             <th>设备</th>
                             <th>重(KG)</th>
                             <th>长*宽*高(cm)</th>
-                            <th>体积(cm³)</th>
+                            <th>体积(dm³)</th>
                             <th>纸箱</th>
                             <th>状态</th>
                             <th>波次规则</th>
@@ -120,8 +120,8 @@
                             <td class="text-muted">@{{package.logisticName}}</td>
                             <td class="text-muted">@{{package.measuringMachineName}}</td>
                             <td>@{{package.weight}}</td>
-                            <td>@{{package.length}}<a v-if="package.length" class="text-primary">*</a>@{{package.width}}<a class="text-primary" v-if="package.width">*</a>@{{package.height}}</td>
-                            <td>@{{package.bulk}}</td>
+                            <td>@{{package.length|mmToCm}}<a v-if="package.length" class="text-primary">*</a>@{{package.width|mmToCm}}<a class="text-primary" v-if="package.width">*</a>@{{package.height|mmToCm}}</td>
+                            <td>@{{package.bulk|volumeMmToDm}}</td>
                             <td>@{{package.paperBoxName}}</td>
                             <td :class="[package.status==='已上传'?'text-success':'']">@{{package.status}}</td>
                             <td class="text-muted">@{{package.batchRule}}</td>
@@ -266,6 +266,16 @@
                         });
                 },
             },
+            filters:{
+                mmToCm:function (val) {
+                    if(!parseInt(val))return val;
+                    return parseInt(val)/10
+                },
+                volumeMmToDm:function (val) {
+                    if(!parseInt(val))return val;
+                    return Math.round(parseInt(val)/10000)/100;
+                },
+            }
         });
     </script>
 @endsection

+ 4 - 0
routes/web.php

@@ -228,6 +228,10 @@ Route::group(['prefix'=>'process'],function(){
     Route::post('updateStartDate','ProcessController@updateStartDate');
     //修改终止日期
     Route::post('updateEndDate','ProcessController@updateEndDate');
+    //删除临时工工作记录
+    Route::delete('destroyDailyParticipant/{id}','ProcessController@destroyDailyParticipant');
+    //导入粘贴商品数据
+    Route::post('importPasteData','ProcessController@importPasteData');
 });
 //process主方法 restful
 Route::resource('process','ProcessController');