loustwo 4 лет назад
Родитель
Сommit
55eba8ffd4

+ 17 - 1
app/Http/Controllers/ReceivingTaskController.php

@@ -6,6 +6,7 @@ use App\DeliveryAppointmentCar;
 use App\Filters\ReceivingTaskFilters;
 use App\Http\Requests\Api\ReceivingTaskRequest;
 use App\ReceivingTask;
+use App\ReceivingTaskItem;
 use App\Services\OwnerService;
 use App\Services\ReceivingTaskService;
 use App\Warehouse;
@@ -66,8 +67,23 @@ class ReceivingTaskController extends Controller
             return ['success' => false, 'errors' => ['appointment_number' => ['预约号没有对应的Asn号']]];
         }
 
+        $asn_nos = array_unique(array_merge($ans_numbers, $request->input('asn_nos') ?? []));
+
+        if (count($asn_nos) == 0){
+            return ['success' => false, 'errors' => ['appointment_number' => ['预约号没有对应的Asn号']]];
+        }
+
+        $receiving_task_items = ReceivingTaskItem::query()->whereIn('asn_no',$request->input('asn_nos') ?? [])->get()->map(function($item){
+            return $item->asn_no;
+        })->toArray();
+        if (count($receiving_task_items) >0 ){
+            return [
+                'success' => false,'errors' => ['appointment_number' => '勾选的asn号'.json_encode($receiving_task_items).'已再其他开单入库中有关联']
+            ];
+        }
+
         if ($delivery_appointment_car->deliveryAppointment->owner_id != $request->input('owner_id')) {
-            return ['success' => false, 'errors' => ['appointment_number' => ['预约号与货主未对应']]];
+            return ['success' => false, 'errors' => ['appointment_number' => ['预约号与货主未必填项']]];
         }
 
         if (ReceivingTask::query()->where('delivery_appointment_car_id', $delivery_appointment_car->id)->exists()) {

+ 22 - 2
resources/views/store/receivingTasks/create.blade.php

@@ -57,17 +57,21 @@
                                     <span class="text-danger">*</span>
                                     货主</label>
                                 <div class="form-inline col-8">
-                                    <select class="form-control form-control-sm col-12" name="owner_id" id="owner_id"
+                                    <select class="form-control form-control-sm col-8" name="owner_id" id="owner_id"
                                             :class="{'is-invalid':errors.owner_id}"
                                             @change="getASNDetails"
                                             @input="clearError('owner_id')"
                                             v-model="receiving_task.owner_id">
-                                        <option v-for="item in owners" :value="item.id" v-text="item.name"></option>
+                                        <option v-for="item in filterOwners" :value="item.id" v-text="item.name"></option>
                                     </select>
                                     <div id="validation-owner-id" class="invalid-feedback" v-show="errors.owner_id">
                                         <span v-text="errors.owner_id"></span>
                                     </div>
+                                    <div class="form-inline col-3">
+                                        <input type="text" name="owner_search" id="owner_search" v-model="owner_search" class="form-control form-control-sm">
+                                    </div>
                                 </div>
+
                             </div>
                         </div>
 
@@ -419,6 +423,7 @@
                     @endforeach
                 ],
                 driving_license_image: null,
+                owner_search:null,
                 page_size: 20,
                 pager_count: 0,
                 current_page: 0,
@@ -469,6 +474,21 @@
             mounted() {
                 $("#list").removeClass('d-none');
             },
+            computed:{
+                filterOwners(){
+                    let owners = JSON.parse(JSON.stringify(this.owners));
+                    let owner_name = this.owner_search ? this.owner_search.trim() : '';
+                    if (owner_name === '') return owners;
+                    owners = owners.filter(e=>{
+                        return e.name.includes(owner_name);
+                    });
+                    setTimeout(()=>{
+                        let owner = owners.find(e=>e);
+                        owner ?  this.$set(this.receiving_task,'owner_id',owner.id) : null;
+                    },200);
+                    return owners;
+                },
+            },
             methods: {
                 waitingTempTip(message) {
                     window.tempTip.setIndex(2005);