取消后台直接在数值加上单位

dev
vine_liutk 2022-11-21 11:37:33 +08:00
parent c68b7eda81
commit f03f175b5e
1 changed files with 10 additions and 9 deletions

View File

@ -23,14 +23,15 @@ class CropYieldResource extends JsonResource
'crop_name' => $this->whenLoaded('crop', function () {
return $this->crop?->name;
}, ''),
'crop_unit' => $this->whenLoaded('crop', function () {
return $this->crop?->unit;
}, ''),
'crop_id' => $this->crop_id,
'time_year' => $this->time_year,
'quarter' => $this->quarter,
'yield' => $this->formatNumber($this->yield).$this->whenLoaded('crop', function () {
return $this->crop?->unit ?? '';
}, ''),
'output' => $this->formatNumber($this->output).'元',
'cultivated' => $this->formatNumber($this->cultivated).'亩',
'yield' => $this->formatNumber($this->yield),
'output' => $this->formatNumber($this->output),
'cultivated' => $this->formatNumber($this->cultivated),
'extends' => $this->extends,
'created_by' => $this->whenLoaded('createdBy', function () {
return $this->createdBy?->name;
@ -40,10 +41,10 @@ class CropYieldResource extends JsonResource
}
private function formatNumber($number){
if($number > 10000){
return round($number/10000, 2).'万';
}else{
// if($number > 10000){
// return round($number/10000, 2).'万';
// }else{
return $number;
}
// }
}
}