Просмотр исходного кода

缓存架入库更为根据跟踪号批次号

Zhouzhendong 4 лет назад
Родитель
Сommit
bc8a018621

+ 11 - 5
app/Commodity.php

@@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Model;
 use App\Traits\ModelTimeFormat;
 
 use App\Traits\ModelLogChanging;
+use Illuminate\Database\Eloquent\Relations\HasOne;
 
 class Commodity extends Model
 {
@@ -16,11 +17,9 @@ class Commodity extends Model
         'width','height','volumn',"type","pack_spec",'updated_at',"remark"];
     protected $appends=['barcode'];
 
-    public function setNameAttribute($value){
-        $this->attributes['name']=str_replace(PHP_EOL,'',$value);
-    }
-    public function getNameAttribute($value){
-        return str_replace(array("\r\n","\n","\r","\"","""),' ',$value);
+    public function model():HasOne
+    {
+        return $this->hasOne(MaterialBoxModel::class,"commodity_id");
     }
     public function barcodes()
     {
@@ -29,6 +28,7 @@ class Commodity extends Model
     public function owner(){
         return $this->belongsTo('App\Owner','owner_id','id');
     }
+
     public function getBarcodeAttribute(){
         return $this->barcodes[0]['code']??'';
     }
@@ -38,6 +38,12 @@ class Commodity extends Model
     public function getOwnerCodeAttribute(){
         return $this->owner['code']??'';
     }
+    public function setNameAttribute($value){
+        $this->attributes['name']=str_replace(PHP_EOL,'',$value);
+    }
+    public function getNameAttribute($value){
+        return str_replace(array("\r\n","\n","\r","\"","""),' ',$value);
+    }
 
     public function newBarcode($barcode){
         $barcodeModel = $this->barcodes()->where('code', $barcode)->first();

+ 139 - 13
app/Http/Controllers/StorageController.php

@@ -13,6 +13,7 @@ use App\Services\LogService;
 use App\Station;
 use App\StationTask;
 use App\StationTaskMaterialBox;
+use App\Store;
 use App\StoreItem;
 use App\TaskTransaction;
 use Illuminate\Database\Eloquent\Builder;
@@ -92,13 +93,48 @@ class StorageController extends Controller
      */
     public function checkMaximum()
     {
-        $item = app("StoreItemService")->getMaxAvailableDetail(request("asn"),request("barCode"));
-        if (!$item)$this->error("无此单据记录");
-        $models = CommodityMaterialBoxModel::query()->where("commodity_id",$item->commodity_id)->get();
+        $track = request("track");
+        $barCode = request("barCode");
+        $lotNum = request("lotNum");
+        $sql = <<<SQL
+SELECT * FROM INV_LOT_ATT WHERE LOTNUM = '{$lotNum}'
+SQL;
+        $lot = DB::connection("oracle")->selectOne(DB::raw($sql));
+        if (!$lot)$this->error("批次丢失");
+        $commodity = Commodity::query()->whereHas("owner",function ($query)use($lot){
+            $query->where("code",$lot->customerid);
+        })->where("sku",$lot->sku)->first();
+        if (!$commodity)$this->error("WAS无此商品信息");
+        $models = CommodityMaterialBoxModel::query()->where("commodity_id",$commodity->id)->get();
         if ($models->count()==0)$this->success(["material_box_model_id"=>null]);
         $map = [];
         foreach ($models as $model)$map[$model->material_box_model_id] = $model;
-        $this->getMaterBoxModel($item,$map);
+        $models = app("MaterialBoxModelService")->getModelSortedByOwner($commodity->owner_id);
+        $m = null;
+        foreach ($models as $model){
+            if (!isset($map[$model->id]))continue;
+            $model->maximum = $map[$model->id]->maximum;
+            $boxes = app("MaterialBoxService")->getModelAvailableBox($model->id);
+            if ($boxes->count()==0)continue;
+            if (!$m)$m = $model;
+            $boxCodes = "";
+            foreach ($boxes as $box){
+                $boxCodes .= "'".$box->code."',";
+            }
+            $boxCodes = rtrim($boxCodes,",");
+            $sql = <<<SQL
+SELECT LOCATIONID,({$model->maximum}-QTY) AS QTY FROM INV_LOT_LOC_ID WHERE LOTNUM = '{$lotNum}'
+AND LOCATIONID IN ({$boxCodes}) AND TRACEID = '*' AND {$model->maximum}-QTY > 0 ORDER BY (CASE QTY WHEN 0 THEN 1 ELSE 0 END),{$model->maximum}-QTY
+SQL;
+            $res = DB::connection("oracle")->selectOne(DB::raw($sql));
+            if ($res){
+                $m = $model;
+                $m->maximum = $res->qty;
+                break;
+            }
+        }
+        if (!$m)$this->error("没有可用料箱");
+        $this->success(["need"=>$m->maximum,"material_box_model_id"=>$m->id,"commodity_id"=>$commodity->id]);
     }
 
     /**
@@ -399,7 +435,7 @@ sql;
             $map = [];
             $ids = [];
             foreach (request("models") as $model){
-                $insert[] = [
+                $in[] = [
                     "commodity_id" => $commodityId,
                     "material_box_model_id" => $model["id"],
                     "maximum" => $model["maximum"]
@@ -413,9 +449,14 @@ sql;
             list($in,$map,$ids) = $insert(request("commodityId"));
             if ($ids){
                 $map = array_flip($ids);
-                foreach (CommodityMaterialBoxModel::query()->whereIn("id",$ids)->lockForUpdate()->get() as $model){
-                    $index = $map[$model->id];
-                    if ($model->maximum != $in[$index]["maximum"])$model->update(["maximum"=>$in[$index]["maximum"]]);
+                foreach (CommodityMaterialBoxModel::query()->where("commodity_id",request("commodityId"))
+                             ->lockForUpdate()->get() as $model){
+                    $index = $map[$model->material_box_model_id];
+                    if ($model->maximum != $in[$index]["maximum"]){
+                        CommodityMaterialBoxModel::query()->where("commodity_id",request("commodityId"))
+                            ->where("material_box_model_id",$model->material_box_model_id)
+                            ->update(["maximum"=>$in[$index]["maximum"]]);
+                    }
                     unset($in[$index]);
                 }
                 $in = array_values($in);
@@ -440,17 +481,18 @@ sql;
         $this->getMaterBoxModel($item,$map);
     }
 
-    private function getMaterBoxModel($item,$map)
+    private function getMaterBoxModel($commodity,$map)
     {
-        $models = app("MaterialBoxModelService")->getModelSortedByOwner($item->store->owner_id);
+        $models = app("MaterialBoxModelService")->getModelSortedByOwner($commodity->owner_id);
         foreach ($models as $model){
             if (!isset($map[$model->id]))continue;
-            $result = app("StorageService")->getHalfBoxLocation($map[$model->id],$item,$item->store->asn_code);
+            //$result = app("StorageService")->getHalfBoxLocation($map[$model->id],$item,$item->store->asn_code);
+            $result = app("StorageService")->getMaxAvailableHalfBoxLocation($map[$model->id],$item,$item->store->asn_code);
             if (!$result)continue;
             $result->maximum = $model->maximum-$result->amount;
             $this->success($result);
         }
-        $this->success(["need"=>$models[0]->maximum,"material_box_model_id"=>$models[0]->material_box_model_id,"commodity_id"=>$item->commodity_id]);
+        $this->success(["need"=>$models[0]->maximum,"material_box_model_id"=>$models[0]->material_box_model_id,"commodity_id"=>$commodity->id]);
     }
 
     /**
@@ -458,11 +500,95 @@ sql;
      */
     public function searchBarCode()
     {
-        $commodities = Commodity::query()->whereHas("barcodes",function (Builder $query){
+        $commodities = Commodity::query()->with("owner")->whereHas("barcodes",function (Builder $query){
             $query->where("code",request("barCode"));
         })->get();
         if (!$commodities->count())$this->error("库内无此商品信息");
         if ($commodities->count()>1)$commodities->load("owner");
         $this->success($commodities);
     }
+
+    /**
+     * 根据商品ID检索已存在的上限设定
+     */
+    public function searchModel()
+    {
+        $mapping = [];
+        foreach (CommodityMaterialBoxModel::query()->where("commodity_id",request("id"))->get() as $model){
+            $mapping[$model->material_box_model_id] = $model->maximum;
+        }
+        $this->success($mapping);
+    }
+
+    /**
+     * 根据ASN号检索未设定商品型号上限的信息
+     */
+    public function searchAsn()
+    {
+        $sql = <<<SQL
+SELECT CUSTOMERID,SKU FROM TSK_TASKLISTS WHERE DOCNO = ? AND TASKPROCESS = '00' AND TASKTYPE = 'PA' GROUP BY CUSTOMERID,SKU
+SQL;
+        $store = Store::query()->select("owner_id")->where("asn_code",request("asn"))->first();
+        if (!$store || !$store->owner_id)$this->error("WAS内无此ASN单信息");
+
+        $tasks = DB::connection("oracle")->select(DB::raw($sql),[request("asn")]);
+        $codes = array_column($tasks,"sku");
+        $model = MaterialBoxModel::query()->where("maximum_kind",1)->first();
+        if (!$model)$this->error("单品型号缺失");
+        $commodities = Commodity::query()->with("model")->where("owner_id",$store->owner_id)
+            ->whereIn("sku",$codes)->get()->toArray();
+        if (count($codes)!=count($commodities))$this->error("WAS商品信息不全");
+        foreach ($commodities as $index=>$commodity){
+            if ($commodity->model)unset($commodities[$index]);
+        }
+        $this->success(["commodities"=>array_values($commodities),"model"=>$model]);
+    }
+
+    /**
+     * 设置商品上限
+     */
+    public function settingCommodityMaximum()
+    {
+        $modelId = request("modelId");
+        $insert = [];
+        $date = date("Y-m-d H:i:s");
+        foreach (request("commodities") as $commodity){
+            $insert[] = [
+                "commodity_id" => $commodity["id"],
+                "material_box_model_id" => $modelId,
+                "maximum" => $commodity->maximum,
+                "created_at" => $date,
+                "updated_at" => $date,
+            ];
+        }
+        $this->success(CommodityMaterialBoxModel::query()->insert($insert));
+    }
+
+    /**
+     * 检查任务获取多批次
+     */
+    public function checkTask()
+    {
+        $track = request("track");
+        $barCode = request("barCode");
+        $sql = <<<SQL
+SELECT TSK_TASKLISTS.FMLOTNUM FROM TSK_TASKLISTS LEFT JOIN BAS_SKU ON TSK_TASKLISTS.CUSTOMERID = BAS_SKU.CUSTOMERID
+AND TSK_TASKLISTS.SKU = BAS_SKU.SKU
+WHERE FMID = ? AND (ALTERNATE_SKU1 = ? OR ALTERNATE_SKU2 = ? OR ALTERNATE_SKU3 = ?)
+AND TASKPROCESS = '00' AND TASKTYPE = 'PA' GROUP BY FMID,FMLOTNUM
+SQL;
+        $tasks = DB::connection("oracle")->select(DB::raw($sql),[$track,$barCode,$barCode,$barCode]);
+        $result = ["count"=>count($tasks)];
+        if (count($tasks)>1){
+            $lotNums = "";
+            foreach ($tasks as $task)$lotNums .= "'".$task->fmlotnum."',";
+            $lotNums = rtrim($lotNums,",");
+            $sql = <<<SQL
+SELECT * FROM INV_LOT_ATT WHERE LOTNUM IN ({$lotNums});
+SQL;
+            $result["lots"] = DB::connection("oracle")->select(DB::raw($sql));
+        }
+        if (count($tasks)==1)$result["lots"] = $tasks[0]->fmlotnum;
+        $this->success($result);
+    }
 }

+ 5 - 38
app/Http/Controllers/TestController.php

@@ -6,6 +6,7 @@ use App\Components\AsyncResponse;
 use App\Components\ErrorPush;
 use App\ErrorTemp;
 use App\Feature;
+use App\MaterialBoxModel;
 use App\Owner;
 use App\OwnerFeeDetail;
 use App\OwnerPriceOperation;
@@ -44,44 +45,10 @@ class TestController extends Controller
     }
     public function test()
     {
-        ini_set('max_execution_time',-1);
-        $rule = OwnerPriceOperation::query()->with("items")->find(205);
-        $owner = 3;$discountIndex = 0;
-        $pivot = new \stdClass();
-        $pivot->owner_price_operation_id = 205;
-        $pivot->owner_id = 3;
-        $pivot->discount_date = "2021-08-01";
-        $pivot->target_value = 0;
-        DB::beginTransaction();
-        try{
-            $month = date("Y-m");
-            $day = date("t",strtotime($month));
-            $query = OwnerFeeDetail::query()->where("owner_id",$owner)->whereBetween("worked_at",[$month."-01",$month."-".$day]);
-            $units = app("UnitService")->getUnitMapping(["件","单","箱","m³","T","kg"]); //获取单位映射集
-            $exe = function ($mapping,$object,$detail)use($rule,$units,$owner,$discountIndex){
-                $money = app("OwnerPriceOperationService")->matchItem($rule,$mapping,$object,$units,$owner,[$discountIndex=>true]);
-                $rate = $rule->taxRate ?: (Owner::query()->with("taxRate")->find($owner)->taxRate ?? null);
-                if ($money>0)$detail->update(["work_fee"=>$money,"work_tax_fee"=>$rate ? ($money*($rate->value/100)) : null]);
-                else dd($money);
-            };
-            if ($rule->operation_type=='入库'){
-                foreach ($query->with(["store.storeItems.commodity","store.warehouse"])
-                             ->where("outer_table_name",'stores')->get() as $detail)
-                    $exe(Feature::MAPPING["store"],$detail->store,$detail);
-            }else{
-                foreach ($query->with(["order.logistic","order.shop","order.packages.commodities.commodity","order.batch"])
-                             ->where("outer_table_name",'orders')->get() as $detail)
-                    $exe(Feature::MAPPING["order"],$detail->order,$detail);
-            }
-            DB::commit();
-            dd("OK");
-        }catch (\Exception $e){
-            DB::rollBack();
-            //处理失败回退标记
-            DB::update(DB::raw("UPDATE owner_price_operation_owner SET discount_date = ?,target_value = ? WHERE  owner_price_operation_id = ? AND owner_id = ?"),
-                [$pivot->discount_date,$pivot->target_value,$rule->id,$owner]);
-            dd($e);
-        }
+        MaterialBoxModel::query()->where("id","!=",1)->delete();
+        MaterialBoxModel::query()->where("id",1)->update([
+            "description" => "单商品料箱"
+        ]);
     }
 
 }

+ 6 - 0
app/MaterialBox.php

@@ -34,6 +34,12 @@ class MaterialBox extends Model
         parent::__construct($attributes);
     }
 
+
+    public function performTask():HasOne
+    {
+        return $this->hasOne(StationTaskMaterialBox::class,"material_box_id")
+            ->whereNotIn("status",["完成","取消"]);
+    }
     public function station():HasOne
     {
         return $this->hasOne(Station::class);

+ 14 - 0
app/Services/MaterialBoxService.php

@@ -8,6 +8,7 @@ use App\MaterialBox;
 use App\MaterialBoxModel;
 use App\StationTaskMaterialBox;
 use App\Traits\ServiceAppAop;
+use Illuminate\Support\Collection;
 use Illuminate\Support\Facades\DB;
 
 
@@ -103,4 +104,17 @@ sql;
         if (StationTaskMaterialBox::query()->select(DB::raw(1))->whereNotIn("status",['完成','取消'])->where("material_box_id",$boxId)->first())return false;
         return true;
     }
+
+    /**
+     * 获取某个型号下的可用料箱
+     *
+     * @param integer $modelId
+     *
+     * @return Collection
+     */
+    public function getModelAvailableBox(int $modelId):Collection
+    {
+        $query = MaterialBox::query()->where("material_box_model_id",$modelId)->where("status",4);
+        return $query->whereNotIn("id",$query->whereHas("performTask"))->get();
+    }
 }

+ 8 - 7
app/Services/StorageService.php

@@ -296,12 +296,13 @@ class StorageService
      */
     public function getFluxTask(string $asn,string $barCode,int $amount):array
     {
-        $sql = <<<sql
-SELECT TSK_TASKLISTS.* FROM DOC_ASN_DETAILS LEFT JOIN BAS_SKU ON DOC_ASN_DETAILS.CUSTOMERID = BAS_SKU.CUSTOMERID AND DOC_ASN_DETAILS.SKU = BAS_SKU.SKU
-LEFT JOIN TSK_TASKLISTS ON DOC_ASN_DETAILS.ASNNO = TSK_TASKLISTS.DOCNO AND DOC_ASN_DETAILS.ASNLINENO = TSK_TASKLISTS.DOCLINENO
-WHERE ASNNO = ? AND (ALTERNATE_SKU1 = ? OR ALTERNATE_SKU2 = ? OR ALTERNATE_SKU3 = ?) AND RECEIVEDQTY >= ?
-  AND TASKPROCESS = '00' AND TASKTYPE = 'PA'
-sql;
+        $sql = <<<SQL
+SELECT TSK_TASKLISTS.* FROM TSK_TASKLISTS LEFT JOIN BAS_SKU ON TSK_TASKLISTS.CUSTOMERID = BAS_SKU.CUSTOMERID
+AND TSK_TASKLISTS.SKU = BAS_SKU.SKU
+WHERE FMID = ? AND (ALTERNATE_SKU1 = ? OR ALTERNATE_SKU2 = ? OR ALTERNATE_SKU3 = ?)
+AND TASKPROCESS = '00' AND TASKTYPE = 'PA'
+SQL;
+
         $tasks = DB::connection("oracle")->select(DB::raw($sql),[$asn,$barCode,$barCode,$barCode,$amount]);
         if (!$tasks)return [];
         $nums = [];
@@ -594,7 +595,7 @@ SQL;
     }
 
     /**
-     * 获取半箱库位库存信息
+     * 获取半箱库位库存信息  废弃
      *
      * @param CommodityMaterialBoxModel|\stdClass $model
      * @param StoreItem|\stdClass $item

+ 15 - 13
app/TaskTransaction.php

@@ -11,19 +11,21 @@ class TaskTransaction extends Model
     use ModelLogChanging;
 
     protected $fillable = [
-        "doc_code",
-        "bar_code",
-        "fm_station_id",
-        "to_station_id",
-        "material_box_id",
-        "task_id",
-        "commodity_id",
-        "amount",
-        "type",
-        "status",
-        "user_id",
-        "mark",
-        "bin_number",
+        "doc_code",     //单号
+        "bar_code",     //条码
+        "fm_station_id",//来源库位
+        "to_station_id",//目标库位
+        "material_box_id",//料箱
+        "task_id",      //机器人任务
+        "commodity_id", //商品
+        "amount",       //数量
+        "type",         //类型
+        "status",       //状态
+        "user_id",      //操作人
+        "mark",         //标记
+        "bin_number",   //格口号
+        "lot_num",      //批号
+        "track_num",    //跟踪号
     ];
 
     const STATUS = [

+ 34 - 0
database/migrations/2021_08_03_092749_change_task_transactions_add_column_lotnum.php

@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class ChangeTaskTransactionsAddColumnLotnum extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('task_transactions', function (Blueprint $table) {
+            $table->string("lot_num")->nullable()->comment("批次号");
+            $table->string("track_num")->nullable()->comment("跟踪号");
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('task_transactions', function (Blueprint $table) {
+            $table->dropColumn("lot_num");
+            $table->dropColumn("track_num");
+        });
+    }
+}

+ 5 - 5
resources/views/customer/project/part/_three.blade.php

@@ -58,7 +58,7 @@
                         @can("项目管理-项目-计费模型-审核")<button class="btn btn-sm btn-success" type="button" @click="auditOrRecoverModel('operation')">审核</button>
                         <button class="btn btn-sm btn-danger" type="button" @click="auditOrRecoverModel('operation',false)">恢复</button>@endcan
                     </div>
-                </div>  
+                </div>
                 <div class="col-3 pull-right small mb-0 text-secondary" v-if="selectedModel.operation.length>0">双击下方已添加内容可编辑</div>
             </div>
             <div class="card-body" id="operation">
@@ -186,7 +186,7 @@
                 </div>
                 <div class="col-3 pull-right small mb-0 text-secondary" v-if="selectedModel.express.length>0">双击下方已添加内容可编辑</div>
             </div>
-            <div class="card-body" id="express">
+            <div class="card-body w-100 overflow-auto" id="express">
                 <table class="table table-sm">
                     <tr>
                         <th>承运商</th>
@@ -200,7 +200,7 @@
                     <tbody v-for="(express,i) in selectedModel.express" @dblclick="editExpress(i)" style="cursor: pointer">
                         <tr>
                             <td>
-                                <div class="text-overflow-warp-100 small">
+                                <div class="small">
                                     <label v-for="(logistic,j) in express.logistics" class="m-0">@{{ poolMapping.logistics ? poolMapping.logistics[logistic] : '' }}<br></label>
                                 </div>
                             </td>
@@ -281,7 +281,7 @@
                 </div>
                 <div class="col-3 pull-right small mb-0 text-secondary" v-if="selectedModel.logistic.length>0">双击下方已添加内容可编辑</div>
             </div>
-            <div class="card-body" id="logistic">
+            <div class="card-body w-100 overflow-auto" id="logistic">
                 <table class="table table-sm">
                     <tr>
                         <th>承运商</th>
@@ -300,7 +300,7 @@
                     <tbody v-for="(logistic,i) in selectedModel.logistic" @dblclick="editLogistic(i)" style="cursor: pointer">
                         <tr>
                             <td>
-                                <div class="text-overflow-warp-100 small">
+                                <div class="small">
                                     <label v-for="(logistic,j) in logistic.logistics" class="m-0">@{{ poolMapping.logistics ? poolMapping.logistics[logistic] : '' }}</label>
                                 </div>
                             </td>

+ 1 - 1
resources/views/store/inStorage/_commodities.blade.php

@@ -14,7 +14,7 @@
                        <th></th>
                     </tr>
                     <tr v-for="(commodity,index) in commodities">
-                        <td>@{{ commodity.owner.name }}</td>
+                        <td>@{{ commodity.owner ? commodity.owner.name : '未知' }}</td>
                         <td>@{{ commodity.name }}</td>
                         <td>@{{ commodity.sku }}</td>
                         <td>

+ 36 - 0
resources/views/store/inStorage/_lotModal.blade.php

@@ -0,0 +1,36 @@
+<div class="modal fade" tabindex="-1" role="dialog" id="commodities">
+    <div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable">
+        <div class="modal-content">
+            <div class="modal-header">
+                <div class="font-weight-bold h4">多批次选择</div>
+                <button type="button" class="close" data-dismiss="modal">&times;</button>
+            </div>
+            <div class="modal-body">
+                <table class="w-100 h-100 table table-bordered table-striped">
+                    <tr>
+                        <th>货主</th>
+                        <th>生产日期</th>
+                        <th>失效日期</th>
+                        <th>入库日期</th>
+                        <th>属性仓</th>
+                        <th>批号</th>
+                        <th>质量</th>
+                        <th></th>
+                    </tr>
+                    <tr v-for="(lot,index) in lots">
+                        <td>@{{ lot.customerid }}</td>
+                        <td>@{{ lot.lotatt01 }}</td>
+                        <td>@{{ lot.lotatt02 }}</td>
+                        <td>@{{ lot.lotatt03 }}</td>
+                        <td>@{{ lot.lotatt04 }}</td>
+                        <td>@{{ lot.lotatt05 }}</td>
+                        <td>@{{ lot.lotatt08 }}</td>
+                        <td>
+                            <button class="btn btn-sm btn-primary" @click="selectedLot(index)">选定</button>
+                        </td>
+                    </tr>
+                </table>
+            </div>
+        </div>
+    </div>
+</div>

+ 25 - 0
resources/views/store/inStorage/_setCommodityMaximum.blade.php

@@ -0,0 +1,25 @@
+<div class="modal fade" tabindex="-1" role="dialog" id="maximumModal">
+    <div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable">
+        <div class="modal-content">
+            <div class="modal-header">
+                <div class="font-weight-bold h4">单品料箱设置</div>
+                <button type="button" class="close" data-dismiss="modal">&times;</button>
+            </div>
+            <div class="modal-body">
+                <div class="row mt-2" v-for="commodity in commodities">
+                    <div class="col-6" style="overflow: hidden">
+                        @{{ commodity.name }}
+                    </div>
+                    <div class="col-6">
+                        <input class="form-control" type="number" step="1" min="1" placeholder="最大上限"
+                               v-model="commodity.maximum">
+                    </div>
+                    <hr class="w-100">
+                </div>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-success" @click="settingCommodityMaximum()">提交</button>
+            </div>
+        </div>
+    </div>
+</div>

+ 8 - 10
resources/views/store/inStorage/commodityBindModel.blade.php

@@ -51,25 +51,23 @@
                 searchBarCode(){
                     if(!this.barCode)return;
                     window.tempTip.postBasicRequest("{{url('store/inStorage/searchBarCode')}}",{barCode:this.barCode},res=>{
-                        console.log(res)
                         this.commodities = res;
                         if (res.length>1){
                             $("#commodities").modal("show");
                             return;
                         }
-                        $("#maximumModal").modal("show");
+                        this.selectedCommodity(0);
                     },true)
                 },
-                submitBind(){
-                    window.tempTip.postBasicRequest("{{url('store/inStorage/boxBindModel')}}",this.info,()=>{
-                        this.info = {};
-                        return "绑定成功";
-                    })
-                },
                 selectedCommodity(index){
                     this.commodityIndex = index;
-                    $("#commodities").modal("hide");
-                    $("#maximumModal").modal("show");
+                    window.tempTip.postBasicRequest("{{url('store/inStorage/searchModel')}}",{id:this.commodities[this.commodityIndex].id},res=>{
+                        this.models.forEach((model,i)=>{
+                            this.$set(this.models[i],"maximum",res ? (res[model.id] ? res[model.id] : null) : null);
+                        });
+                        $("#commodities").modal("hide");
+                        $("#maximumModal").modal("show");
+                    });
                 },
                 settingModelMaximum(){
                     let models = [];

+ 43 - 24
resources/views/store/inStorage/halfChestStorage.blade.php

@@ -11,17 +11,17 @@
                         <a class="small" href="#" @click="openModal()">溢出减量</a>
                     </div>
                     <div class="form-group row">
-                        <label for="asn" class="col-sm-2 col-3 text-right">ASN号:</label>
-                        <input type="text" class="form-control col-8" id="asn" placeholder="只需填写后几位,自动补充"
-                             @change="downSign()" :class="errors.asn ? 'is-invalid' : ''" @keydown.enter="enterVal($event)" v-model="info.asn" @blur="checkAsn()">
-                        <span class="invalid-feedback offset-3" role="alert" v-if="errors.asn">
-                            <strong>@{{ errors.asn[0] }}</strong>
+                        <label for="track" class="col-sm-2 col-3 text-right">跟踪号:</label>
+                        <input type="text" class="form-control col-8" id="track"
+                             @change="downSign()" :class="errors.track ? 'is-invalid' : ''" @keydown.enter="enterVal($event)" v-model="info.track" @blur="check()">
+                        <span class="invalid-feedback offset-3" role="alert" v-if="errors.track">
+                            <strong>@{{ errors.track[0] }}</strong>
                         </span>
                     </div>
                     <div class="form-group row">
                         <label for="station" class="col-sm-2 col-3 text-right">库位:</label>
                         <input type="text" class="form-control col-8" id="station" placeholder="扫描货架条码"
-                               :class="errors.station ? 'is-invalid' : ''" v-model="info.station" @blur="checkMaximum()" @keydown.enter="enterVal($event)">
+                               :class="errors.station ? 'is-invalid' : ''" v-model="info.station" @blur="check()" @keydown.enter="enterVal($event)">
                         <span class="invalid-feedback offset-3" role="alert" v-if="errors.station">
                             <strong>@{{ errors.station[0] }}</strong>
                         </span>
@@ -29,7 +29,7 @@
                     <div class="form-group row">
                         <label for="barCode" class="col-sm-2 col-3 text-right">条码:</label>
                         <input type="text" class="form-control col-8" id="barCode" placeholder="扫描商品条码"
-                               @change="downSign()" :class="errors.barCode ? 'is-invalid' : ''" v-model="info.barCode" @blur="checkMaximum()" @keydown.enter="enterVal($event)">
+                               @change="downSign()" :class="errors.barCode ? 'is-invalid' : ''" v-model="info.barCode" @blur="check()" @keydown.enter="enterVal($event)">
                         <span class="invalid-feedback offset-3" role="alert" v-if="errors.barCode">
                             <strong>@{{ errors.barCode[0] }}</strong>
                         </span>
@@ -37,7 +37,7 @@
                     <div class="form-group row">
                         <label for="amount" class="col-sm-2 col-3 text-right">数量:</label>
                         <input type="number" class="form-control col-8" id="amount"
-                               @keydown.enter="enterVal($event)" :class="errors.amount ? 'is-invalid' : ''" @blur="checkMaximum()" v-model="info.amount" :placeholder="info.maximum!==undefined ? '最大可上:'+info.maximum : ''" :max="info.maximum" step="1">
+                               @keydown.enter="enterVal($event)" :class="errors.amount ? 'is-invalid' : ''" @blur="check()" v-model="info.amount" :placeholder="info.maximum!==undefined ? '最大可上:'+info.maximum : ''" :max="info.maximum" step="1">
                         <span class="invalid-feedback offset-3" role="alert" v-if="errors.amount">
                             <strong>@{{ errors.amount[0] }}</strong>
                         </span>
@@ -87,6 +87,7 @@
                 </div>
             </div>
             @include("store.inStorage._setMaximum")
+            @include("store.inStorage._lotModal")
         </div>
     </div>
 @stop
@@ -97,19 +98,19 @@
             el:"#container",
             data:{
                 permissionList:[ //允许聚焦许可列表
-                    "asn","station","amount","location","ov_amount"
+                    "track","station","amount","location","ov_amount"
                 ],
                 info:{},
                 mount:false,
                 before:{
-                    asn:"",
+
                 },
                 focus:"",
                 errors:{},
                 ov:{},//溢出减量数值
                 checkSign:false,
                 element:[
-                    "asn","station","barCode","amount","submit"
+                    "track","station","barCode","amount","submit"
                 ],
                 isAndroid:false,
                 shelfOccupy:{},
@@ -127,13 +128,15 @@
                     ],
                 ],
                 models:null,
+                oldInfo:{},
+                lots:[],
             },
             mounted(){
                 if (navigator.userAgent.indexOf("Android")!==-1)this.isAndroid = true;
                 @foreach($stations as $station)this.$set(this.shelfOccupy,"{{$station->code}}",!!{{$station->material_box_id}});@endforeach
                 //this.codeFocus();
                 //this.globalClick();
-                this.createBefore();
+                //this.createBefore();
                 this.pageInit();
                 $("#container").removeClass("d-none");
             },
@@ -184,8 +187,7 @@
 
                 checkInfo(){
                     let error = {};
-                    if (!this.info.asn)error.asn = ["ASN号必填"];
-                    if (this.info.asn && this.info.asn.length!==13)error.asn = ["非法ASN号"];
+                    if (!this.info.track)error.track = ["跟踪号必填"];
                     if (!this.info.barCode)error.barCode = ["商品条码必填"];
                     if (!this.info.station)error.station = ["库位必填"];
                     if (!this.info.amount && !this.info.maximum)error.amount = ["数量必填"];
@@ -195,7 +197,7 @@
                 },
                 _exeTask(){
                     window.tempTip.postBasicRequest("{{url('store/inStorage/acquireBox')}}",this.info,()=>{
-                        this.info = {asn:this.info.asn};
+                        this.info = {track:this.info.track};
                         this.errors = {};
                         return "上架成功!";
                     });
@@ -209,17 +211,10 @@
                     dd = dd <10 ? '0'+dd : dd.toString();
                     this.before.asn = 'ASN'+yy+mm+dd+'000';
                 },
-                checkAsn(){
-                    if(!this.info.asn)return;
-                    let len = this.info.asn.length;
-                    if (len<13)this.info.asn = this.before.asn.substr(0,13-len)+this.info.asn;
-                    if (!this.checkSign)this.checkMaximum(e,'');
-                },
                 downSign(){
                     this.checkSign = false;
                 },
                 checkMaximum(){
-                    if (!this.info.asn || !this.info.barCode || this.checkSign)return;
                     window.tempTip.postBasicRequest("{{url('store/inStorage/checkMaximum')}}",this.info,res=>{
                         if (!res.material_box_model_id){
                             this.showMaximumModal();
@@ -232,6 +227,26 @@
                         if(!this.info.amount)this.info.amount = res.maximum;
                         return "该库位最大可上数为"+res.maximum;
                     });
+                },
+                check(){
+                    if (!this.info.track || !this.info.barCode || this.checkSign)return;
+                    if (!this.info.lotNum || this.info.track !== this.oldInfo.track || this.info.barCode !== this.oldInfo.barCode){
+                        window.tempTip.postBasicRequest("{{url('store/inStorage/checkTask')}}",this.info,res=>{
+                            this.oldInfo = {track:this.info.track,barCode:this.info.barCode};
+                            switch (res.count){
+                                case 0:
+                                    window.tempTip.show("无此上架信息");
+                                    break;
+                                case 1:
+                                    this.info.lotNum = res.lots;
+                                    this.checkMaximum();
+                                    break;
+                                default:
+                                    this.lots = res.lots;
+                                    $("#lotModal").modal("show");
+                            }
+                        });
+                    }
                     this.checkSign = true;
                 },
                 enterVal(e){
@@ -304,7 +319,7 @@
                         return;
                     }
                     window.tempTip.postBasicRequest("{{url('store/inStorage/setMaximum')}}",
-                        {models:models,asn:this.info.asn,barCode:this.info.barCode},res=>{
+                        {models:models,track:this.info.track,barCode:this.info.barCode},res=>{
                         this.info.maximum = res.maximum;
                         this.info.material_box_id = res.material_box_id;
                         this.info.material_box_model_id = res.material_box_model_id;
@@ -313,7 +328,11 @@
                         $("#maximumModal").modal("hide");
                         return "该库位最大可上数为"+res.maximum;
                     },true);
-                }
+                },
+                selectedLot(index){
+                    this.info.lotNum = this.lots[index].lotnum;
+                    this.checkMaximum();
+                },
             },
         });
     </script>

+ 53 - 0
resources/views/store/inStorage/quickPutStorage.blade.php

@@ -0,0 +1,53 @@
+@extends('layouts.app')
+@section('title')商品绑定型号-入库管理@endsection
+
+@section('content')
+    <div class="container-fluid d-none" id="container">
+        <div class="mt-3 col-8 offset-2">
+            <div class="form-group row">
+                <label for="asn">ASN号</label>
+                <input id="asn" type="text" class="form-control" v-model="asn"></input>
+            </div>
+            <div class="input-group row mt-5">
+                <button type="submit" id="submit" class="btn btn-info offset-2 col-10" @click="searchAsn()">检索</button>
+            </div>
+        </div>
+        @include("store.inStorage._setCommodityMaximum")
+        @include("store.inStorage._commodities")
+    </div>
+@stop
+
+@section('lastScript')
+    <script>
+        new Vue({
+            el:"#container",
+            data:{
+                asn:"",
+                commodities:[],
+                model:{},
+            },
+            methods:{
+                searchAsn(){
+                    if (!this.asn)return;
+                    window.tempTip.postBasicRequest("{{url('store/inStorage/searchAsn')}}",{asn:this.asn},res=>{
+                        this.commodities = res.commodities;
+                        this.model = res.model;
+                    })
+                },
+                settingCommodityMaximum(){
+                    this.commodities.forEach(commodity=>{
+                        if (!commodity.maximum){
+                            window.tempTip.setDuration(2000);
+                            window.tempTip.show("'"+commodity.name+"'未设定上限");
+                            return;
+                        }
+                    });
+                    window.tempTip.postBasicRequest("{{url('store/inStorage/settingCommodityMaximum')}}",
+                        {commodities:this.commodities,modelId:this.model.id},res=>{
+                        return "设定完毕";
+                    })
+                },
+            },
+        });
+    </script>
+@stop

+ 2 - 2
resources/views/transport/waybill/edit.blade.php

@@ -60,9 +60,9 @@
                             <div class="form-group row">
                                 <label for="deliver_at" class="col-2 col-form-label text-right text-muted">发货时间</label>
                                 <div class="col-8 form-inline">
-                                    <input  id="deliver_at_date" @input="spliceDeliverAt" name="deliver_at_date" type="date" class="form-control col-4"
+                                    <input  id="deliver_at_date" @input="spliceDeliverAt" name="deliver_at_date" type="date" class="form-control col-4 @error('deliver_at_date') is-invalid @enderror"
                                             value="@if(old('deliver_at_date')){{ old('deliver_at_date') }}@else{{$waybill->deliver_at_date}}@endif">
-                                    <input  id="deliver_at_time" @input="spliceDeliverAt" name="deliver_at_time" type="time" class="form-control col-4"
+                                    <input  id="deliver_at_time" @input="spliceDeliverAt" name="deliver_at_time" type="time" class="form-control col-4 @error('deliver_at_date') is-invalid @enderror"
                                             value="@if(old('deliver_at_time')){{ old('deliver_at_time') }}@else{{$waybill->deliver_at_time}}@endif">
                                     <input hidden id="deliver_at"  name="deliver_at" type="text" class="form-control col-4">
                                 </div>

+ 4 - 1
routes/web.php

@@ -468,7 +468,6 @@ Route::group(['middleware'=>'auth'],function ($route){
             Route::get('halfChestStorage','StoreController@halfChestStorage');
             Route::post('putShelf','StorageController@putShelf');
             Route::post('resetCacheShelf','StorageController@resetCacheShelf');
-            Route::post('setMaximum','StorageController@setMaximum');
             Route::post('checkMaximum','StorageController@checkMaximum');
             Route::post('overflowRevision','StorageController@overflowRevision');
             Route::post('acquireBox','StorageController@acquireBox');
@@ -485,6 +484,10 @@ Route::group(['middleware'=>'auth'],function ($route){
             Route::post('getModels','StorageController@getModels');
             Route::post('setMaximum','StorageController@settingModelMaximum');
             Route::post('searchBarCode','StorageController@searchBarCode');
+            Route::post('searchModel','StorageController@searchModel');
+            Route::post('searchAsn','StorageController@searchAsn');
+            Route::post('settingCommodityMaximum','StorageController@settingCommodityMaximum');
+            Route::post('checkTask','StorageController@checkTask');
         });
         Route::group(['prefix'=>'handInStorage'],function() {
             Route::get('receive',function (){return view('store.handInStorage.receive');});//收货页面