优化
This commit is contained in:
@@ -22,7 +22,13 @@ use support\Cache;
|
|||||||
class VehicleController
|
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
|
* 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->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')){
|
if(!str_starts_with($vehicle['img_url'], 'http')){
|
||||||
$img_url = Cache::get('img_dibai_'.$vehicle->id);
|
$img_url = Cache::get('img_dibai_'.$vehicle->id);
|
||||||
if ($img_url) {
|
if ($img_url) {
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class VehicleController extends Crud
|
|||||||
public function status()
|
public function status()
|
||||||
{
|
{
|
||||||
$lang = session('lang', 'zh-cn');
|
$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]);
|
return json(['code' => 0, 'msg' => 'success', 'data' => $status]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -530,6 +530,7 @@ class VehicleController extends Crud
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$ossservice = new OssService();
|
||||||
foreach ($items as &$item) {
|
foreach ($items as &$item) {
|
||||||
$item = $vehicle::find($item['id']);
|
$item = $vehicle::find($item['id']);
|
||||||
$location = $hz::find($item->locations_id);
|
$location = $hz::find($item->locations_id);
|
||||||
@@ -551,29 +552,26 @@ class VehicleController extends Crud
|
|||||||
$location = $hz::find($item->fbo_locations_id);
|
$location = $hz::find($item->fbo_locations_id);
|
||||||
$item->fbo_location_name = $location ? $location->name : '';
|
$item->fbo_location_name = $location ? $location->name : '';
|
||||||
|
|
||||||
if(!str_starts_with($item['img_url'], 'http')){
|
try {
|
||||||
try {
|
$img_url = Cache::get('img_dibai_'.$item->id);
|
||||||
$img_url = Cache::get('img_dibai_'.$item->id);
|
if ($img_url) {
|
||||||
if ($img_url) {
|
$item['img_url'] = $img_url;
|
||||||
$item['img_url'] = $img_url;
|
} else {
|
||||||
} else {
|
$img_url = $ossservice->generatePrivateUrl($item['img_url'],86400);
|
||||||
$ossservice = new OssService();
|
$item['img_url'] = $img_url;
|
||||||
$img_url = $ossservice->generatePrivateUrl($item['img_url'],86400);
|
Cache::set('img_dibai_'.$item->id, $img_url, 86390);
|
||||||
$item['img_url'] = $img_url;
|
}
|
||||||
Cache::set('img_dibai_'.$item->id, $img_url, 86390);
|
|
||||||
}
|
|
||||||
|
|
||||||
// $ossservice = new OssService();
|
// $ossservice = new OssService();
|
||||||
// $oss_picture = $ossservice->generatePrivateUrl($follow['picture'],86400);
|
// $oss_picture = $ossservice->generatePrivateUrl($follow['picture'],86400);
|
||||||
// $item['img_url'] = $img_url;
|
// $item['img_url'] = $img_url;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Log::error("Vehicle image URL generation failed:", [
|
Log::error("Vehicle image URL generation failed:", [
|
||||||
'error' => $e->getMessage(),
|
'error' => $e->getMessage(),
|
||||||
'original_url' => $item['img_url'],
|
'original_url' => $item['img_url'],
|
||||||
'error_code' => $e->getCode(),
|
'error_code' => $e->getCode(),
|
||||||
'trace' => $e->getTraceAsString()
|
'trace' => $e->getTraceAsString()
|
||||||
]);
|
]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -98,14 +98,23 @@
|
|||||||
// 表头参数
|
// 表头参数
|
||||||
let cols = [[
|
let cols = [[
|
||||||
{type: "checkbox", align: "center"},
|
{type: "checkbox", align: "center"},
|
||||||
{title: translations.id, align: "center", field: "id"},
|
|
||||||
{title: translations.vin, align: "center", field: "vin"},
|
{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 '<img src="' + encodeURI(d['url']) + '" style="max-width:32px;max-height:32px;" />';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{title: translations.status, align: "center", field: "status_txt"},
|
||||||
{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.current_location, align: "center", field: "location_name"},
|
||||||
{title: translations.final_location, align: "center", field: "final_location_name"},
|
// {title: translations.final_location, align: "center", field: "final_location_name"},
|
||||||
{title: translations.fbo_location, align: "center", field: "fbo_location_name"},
|
// {title: translations.fbo_location, align: "center", field: "fbo_location_name"},
|
||||||
{title: translations.created_at, align: "center", field: "created_at"},
|
// {title: translations.created_at, align: "center", field: "created_at"},
|
||||||
{title: translations.updated_at, align: "center", field: "updated_at"},
|
// {title: translations.updated_at, align: "center", field: "updated_at"},
|
||||||
{title: translations.operation, toolbar: "#table-bar", align: "center", fixed: "right", width: 150}
|
{title: translations.operation, toolbar: "#table-bar", align: "center", fixed: "right", width: 150}
|
||||||
]];
|
]];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user