diff --git a/app/controller/VehicleController.php b/app/controller/VehicleController.php index a14df47..d4a94d8 100644 --- a/app/controller/VehicleController.php +++ b/app/controller/VehicleController.php @@ -22,7 +22,13 @@ use support\Cache; class VehicleController { - protected $status = ['未知','待发车','在途(发往fbo港口)','抵达发货港口','在途(发往目的地仓库)','抵达目的地','售出']; +// protected $status = ['未知','待发车','在途(发往fbo港口)','抵达发货港口','在途(发往目的地仓库)','抵达目的地','售出']; + protected $status = [ + 'zh' => ['未知', '待发车', '在途(发往fbo港口)', '抵达发货港口', '在途(发往目的地仓库)', '抵达目的地', '售出'], + 'en' => ['Unknown', 'Pending Departure', 'In Transit (to FBO Port)', 'Arrived at Shipping Port', 'In Transit (to Destination Warehouse)', 'Arrived at Destination', 'Sold'], + 'ru' => ['Неизвестно', 'Ожидает отправки', 'В пути (к порту FBO)', 'Прибыл в порт отправки', 'В пути (к складу назначения)', 'Прибыл в пункт назначения', 'Продано'], + 'ar' => ['غير معروف', 'في انتظار الشحن', 'في الطريق (إلى ميناء FBO)', 'وصل إلى ميناء الشحن', 'في الطريق (إلى مستودع الوجهة)', 'وصل إلى الوجهة', 'تم البيع'], + ]; /** * Mask VIN number by showing only first 2 and last 6 characters */ @@ -107,7 +113,10 @@ class VehicleController } $vehicle->fbo_destination = isset($arr[$vehicle->fbo_locations_id]) ? $arr[$vehicle->fbo_locations_id]['name'] : ''; - $vehicle->status = $this->status[$vehicle->status]??$this->status[0]; + $vehicle->status_val = $vehicle->status; + if(is_numeric($vehicle->status)) { + $vehicle->status = $this->status[$lang][$vehicle->status]??$this->status[$lang][0]; + } if(!str_starts_with($vehicle['img_url'], 'http')){ $img_url = Cache::get('img_dibai_'.$vehicle->id); if ($img_url) { diff --git a/plugin/admin/app/controller/VehicleController.php b/plugin/admin/app/controller/VehicleController.php index 5a2d841..271fe0b 100644 --- a/plugin/admin/app/controller/VehicleController.php +++ b/plugin/admin/app/controller/VehicleController.php @@ -62,7 +62,7 @@ class VehicleController extends Crud public function status() { $lang = session('lang', 'zh-cn'); - $status = $this->status[$lang]; + $status = isset($this->status[$lang])?$this->status[$lang]:$this->status['zh-cn']; return json(['code' => 0, 'msg' => 'success', 'data' => $status]); } @@ -530,6 +530,7 @@ class VehicleController extends Crud break; } + $ossservice = new OssService(); foreach ($items as &$item) { $item = $vehicle::find($item['id']); $location = $hz::find($item->locations_id); @@ -551,29 +552,26 @@ class VehicleController extends Crud $location = $hz::find($item->fbo_locations_id); $item->fbo_location_name = $location ? $location->name : ''; - if(!str_starts_with($item['img_url'], 'http')){ - try { - $img_url = Cache::get('img_dibai_'.$item->id); - if ($img_url) { - $item['img_url'] = $img_url; - } else { - $ossservice = new OssService(); - $img_url = $ossservice->generatePrivateUrl($item['img_url'],86400); - $item['img_url'] = $img_url; - Cache::set('img_dibai_'.$item->id, $img_url, 86390); - } - + try { + $img_url = Cache::get('img_dibai_'.$item->id); + if ($img_url) { + $item['img_url'] = $img_url; + } else { + $img_url = $ossservice->generatePrivateUrl($item['img_url'],86400); + $item['img_url'] = $img_url; + Cache::set('img_dibai_'.$item->id, $img_url, 86390); + } + // $ossservice = new OssService(); // $oss_picture = $ossservice->generatePrivateUrl($follow['picture'],86400); // $item['img_url'] = $img_url; - } catch (\Exception $e) { - Log::error("Vehicle image URL generation failed:", [ - 'error' => $e->getMessage(), - 'original_url' => $item['img_url'], - 'error_code' => $e->getCode(), - 'trace' => $e->getTraceAsString() - ]); - } + } catch (\Exception $e) { + Log::error("Vehicle image URL generation failed:", [ + 'error' => $e->getMessage(), + 'original_url' => $item['img_url'], + 'error_code' => $e->getCode(), + 'trace' => $e->getTraceAsString() + ]); } } diff --git a/plugin/admin/app/view/vehicle/index.html b/plugin/admin/app/view/vehicle/index.html index e2c64ef..fa175a9 100644 --- a/plugin/admin/app/view/vehicle/index.html +++ b/plugin/admin/app/view/vehicle/index.html @@ -98,14 +98,23 @@ // 表头参数 let cols = [[ {type: "checkbox", align: "center"}, - {title: translations.id, align: "center", field: "id"}, {title: translations.vin, align: "center", field: "vin"}, + {title: translations.brand, align: "center", field: "brand"}, + // {title: translations.img_url, align: "center", field: "img_url"}, + { + title: "translations.img_url", + field: "url", + templet: function (d) { + return ''; + } + }, + {title: translations.status, align: "center", field: "status_txt"}, {title: translations.status, align: "center", field: "status_txt"}, {title: translations.current_location, align: "center", field: "location_name"}, - {title: translations.final_location, align: "center", field: "final_location_name"}, - {title: translations.fbo_location, align: "center", field: "fbo_location_name"}, - {title: translations.created_at, align: "center", field: "created_at"}, - {title: translations.updated_at, align: "center", field: "updated_at"}, + // {title: translations.final_location, align: "center", field: "final_location_name"}, + // {title: translations.fbo_location, align: "center", field: "fbo_location_name"}, + // {title: translations.created_at, align: "center", field: "created_at"}, + // {title: translations.updated_at, align: "center", field: "updated_at"}, {title: translations.operation, toolbar: "#table-bar", align: "center", fixed: "right", width: 150} ]];