取消后台直接在数值加上单位
parent
c68b7eda81
commit
f03f175b5e
|
|
@ -23,14 +23,15 @@ class CropYieldResource extends JsonResource
|
||||||
'crop_name' => $this->whenLoaded('crop', function () {
|
'crop_name' => $this->whenLoaded('crop', function () {
|
||||||
return $this->crop?->name;
|
return $this->crop?->name;
|
||||||
}, ''),
|
}, ''),
|
||||||
|
'crop_unit' => $this->whenLoaded('crop', function () {
|
||||||
|
return $this->crop?->unit;
|
||||||
|
}, ''),
|
||||||
'crop_id' => $this->crop_id,
|
'crop_id' => $this->crop_id,
|
||||||
'time_year' => $this->time_year,
|
'time_year' => $this->time_year,
|
||||||
'quarter' => $this->quarter,
|
'quarter' => $this->quarter,
|
||||||
'yield' => $this->formatNumber($this->yield).$this->whenLoaded('crop', function () {
|
'yield' => $this->formatNumber($this->yield),
|
||||||
return $this->crop?->unit ?? '';
|
'output' => $this->formatNumber($this->output),
|
||||||
}, ''),
|
'cultivated' => $this->formatNumber($this->cultivated),
|
||||||
'output' => $this->formatNumber($this->output).'元',
|
|
||||||
'cultivated' => $this->formatNumber($this->cultivated).'亩',
|
|
||||||
'extends' => $this->extends,
|
'extends' => $this->extends,
|
||||||
'created_by' => $this->whenLoaded('createdBy', function () {
|
'created_by' => $this->whenLoaded('createdBy', function () {
|
||||||
return $this->createdBy?->name;
|
return $this->createdBy?->name;
|
||||||
|
|
@ -40,10 +41,10 @@ class CropYieldResource extends JsonResource
|
||||||
}
|
}
|
||||||
|
|
||||||
private function formatNumber($number){
|
private function formatNumber($number){
|
||||||
if($number > 10000){
|
// if($number > 10000){
|
||||||
return round($number/10000, 2).'万';
|
// return round($number/10000, 2).'万';
|
||||||
}else{
|
// }else{
|
||||||
return $number;
|
return $number;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue