调整收获记录
parent
9eac19eafe
commit
94883ec937
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
||||
use App\Services\Admin\CropHarvestService;
|
||||
|
||||
class CropHarvestController extends AdminController
|
||||
{
|
||||
protected string $serviceName = CropHarvestService::class;
|
||||
}
|
||||
|
|
@ -4,7 +4,11 @@ namespace App\Admin\Controllers;
|
|||
|
||||
use Illuminate\Http\Request;
|
||||
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
||||
use Slowlyo\OwlAdmin\Renderers\DialogAction;
|
||||
use Slowlyo\OwlAdmin\Renderers\Dialog;
|
||||
use App\Services\Admin\CropPlantService;
|
||||
use App\Admin\Components;
|
||||
use App\Models\RegionPlantLog;
|
||||
|
||||
class CropPlantController extends AdminController
|
||||
{
|
||||
|
|
@ -23,72 +27,80 @@ class CropPlantController extends AdminController
|
|||
$random1 = $randArr();
|
||||
$random2 = $randArr();
|
||||
|
||||
return amisMake()->Grid()->columns([
|
||||
amisMake()->Wrapper()->sm(6)->body([
|
||||
amisMake()->Panel()->title('基础详情')
|
||||
->subFormMode('horizontal')
|
||||
->labelWidth(100)
|
||||
->className('Panel--success')
|
||||
->body([
|
||||
\amisMake()->TextControl()->static(true)->name('name')->label('名称')->value('试验田1'),
|
||||
\amisMake()->TextControl()->static(true)->name('name1')->label('负责人')->value('负责人'),
|
||||
\amisMake()->TextControl()->static(true)->name('area')->label('种植面积m²')->value(),
|
||||
\amisMake()->TextControl()->static(true)->name('time')->label('种植时间')->value('2023-03-01'),
|
||||
]),
|
||||
amisMake()->Panel()->title('收割记录')
|
||||
->className('Panel--success')
|
||||
->body([
|
||||
\amisMake()->Button()->className('absolute top-1 right-4')->actionType('dialog')->label('新增')->dialog([
|
||||
"title"=> "收割记录",
|
||||
"body"=> [
|
||||
"type"=> "form",
|
||||
"api"=> "",
|
||||
"body"=> [
|
||||
\amisMake()->TextControl()->label('负责人'),
|
||||
\amisMake()->TextControl()->label('收割面积'),
|
||||
\amisMake()->TextControl()->label('收割产量'),
|
||||
\amisMake()->DateControl()->label('收割时间'),
|
||||
]
|
||||
]
|
||||
])->level('primary'),
|
||||
\amisMake()->CRUDTable()->title('')
|
||||
->data([
|
||||
'items' => [
|
||||
[
|
||||
'name'=> '负责人',
|
||||
'name1'=> '100',
|
||||
'area'=> '100',
|
||||
'time1'=> '2023-03-21',
|
||||
],
|
||||
]
|
||||
])->columns([
|
||||
amisMake()->TableColumn()->name('name')->label('负责人'),
|
||||
amisMake()->TableColumn()->name('name1')->label('收割面积'),
|
||||
amisMake()->TableColumn()->name('area')->label('收割产量'),
|
||||
amisMake()->TableColumn()->name('time1')->label('收割时间'),
|
||||
])
|
||||
]),
|
||||
]),
|
||||
amisMake()->Wrapper()->sm(6)->body([
|
||||
\amisMake()->grid()->columns([
|
||||
\amisMake()->Form()->title('搜索条件')->mode('inline')->body([
|
||||
\amisMake()->DateRangeControl()->label('时间范围'),
|
||||
amis('submit')->label(__('admin.search'))->level('primary'),
|
||||
]),
|
||||
$id = $request->id;
|
||||
$plant = RegionPlantLog::find($id);
|
||||
$page = $this->basePage()->body([
|
||||
amisMake()->Grid()->columns([
|
||||
amisMake()->Wrapper()->sm(6)->body([
|
||||
amisMake()->Panel()->title('种植详情')
|
||||
->subFormMode('horizontal')
|
||||
->labelWidth(100)
|
||||
->body([
|
||||
\amisMake()->TextControl()->static(true)->name('plant_name')->label('作物名称')->value($plant->plant_name),
|
||||
\amisMake()->TextControl()->static(true)->name('director')->label('负责人')->value($plant->director),
|
||||
\amisMake()->TextControl()->static(true)->name('area')->label('种植面积m²')->value($plant->area),
|
||||
\amisMake()->TextControl()->static(true)->name('start_at')->label('种植时间')->value($plant->start_at),
|
||||
]),
|
||||
amisMake()->Panel()->title('收获记录')
|
||||
->body([
|
||||
DialogAction::make()->className('absolute top-1 right-4')->label(__('admin.create'))->dialog(
|
||||
Dialog::make()->title('收获记录')->body($this->harvestCreateForm($plant))
|
||||
),
|
||||
\amisMake()->CRUDTable()
|
||||
->api(admin_url('crop-harvestes').'?_action=getData&plant_id='.$plant->id)
|
||||
->title('')
|
||||
->columns([
|
||||
amisMake()->TableColumn()->name('name')->label('负责人'),
|
||||
amisMake()->TableColumn()->name('name1')->label('收获面积m²'),
|
||||
amisMake()->TableColumn()->name('area')->label('收获产量kg'),
|
||||
amisMake()->TableColumn()->name('time1')->label('收获时间'),
|
||||
])
|
||||
]),
|
||||
]),
|
||||
amisMake()->Card()->className('m-r')->body(
|
||||
amisMake()->Chart()->config("{
|
||||
title:{ text: '种植情况'},
|
||||
tooltip: { trigger: 'axis' },
|
||||
xAxis: { type: 'category', boundaryGap: false, data: ['2023-03-01', '2023-03-10', '2023-03-15', '2023-03-15', '2023-03-20', '2023-03-25', '2023-03-31'] },
|
||||
yAxis: { type: 'value' },
|
||||
grid:{ left: '7%', right:'3%', top: 60, bottom: 30, },
|
||||
series: [
|
||||
{ name:'面积', data: {$random2}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', },
|
||||
{ name:'产量', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', },
|
||||
]}")
|
||||
),
|
||||
]),
|
||||
amisMake()->Wrapper()->sm(6)->body([
|
||||
\amisMake()->grid()->columns([
|
||||
\amisMake()->Form()->title('搜索条件')->mode('inline')->body([
|
||||
\amisMake()->DateRangeControl()->label('时间范围'),
|
||||
amis('submit')->label(__('admin.search'))->level('primary'),
|
||||
]),
|
||||
]),
|
||||
amisMake()->Card()->className('m-r')->body(
|
||||
amisMake()->Chart()->config("{
|
||||
title:{ text: '种植情况'},
|
||||
tooltip: { trigger: 'axis' },
|
||||
xAxis: { type: 'category', boundaryGap: false, data: ['2023-03-01', '2023-03-10', '2023-03-15', '2023-03-15', '2023-03-20', '2023-03-25', '2023-03-31'] },
|
||||
yAxis: { type: 'value' },
|
||||
grid:{ left: '7%', right:'3%', top: 60, bottom: 30, },
|
||||
series: [
|
||||
{ name:'面积', data: {$random2}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', },
|
||||
{ name:'产量', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', },
|
||||
]}")
|
||||
),
|
||||
]),
|
||||
])
|
||||
]);
|
||||
}
|
||||
return $page;
|
||||
}
|
||||
|
||||
public function harvestCreateForm(RegionPlantLog $plant = null) {
|
||||
return amisMake()->Form()
|
||||
->api([
|
||||
'method'=>'post',
|
||||
'url'=>admin_url('crop-harvestes'),
|
||||
"data" => [
|
||||
'plant_id'=>'${plant_id}',
|
||||
'director'=>'${harbest_director}',
|
||||
'area'=>'${harbest_area}',
|
||||
'output'=>'${output}',
|
||||
'harvest_at'=>'${harvest_at}',
|
||||
],
|
||||
])
|
||||
->body([
|
||||
\amisMake()->TextControl()->name('plant_id')->label('计划ID')->hidden(true)->value($plant?->id ?? 0),
|
||||
\amisMake()->TextControl()->name('harbest_director')->label('负责人')->required(true),
|
||||
Components::make()->decimalControl('harbest_area','收获面积m²')->required(true),
|
||||
Components::make()->decimalControl('output','收获产量kg')->required(true),
|
||||
\amisMake()->DateControl()->name('harvest_at')->format('YYYY-MM-DD HH:mm:ss')->label('收获时间')->required(true),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -163,13 +163,13 @@ class CustomRegionController extends AdminController
|
|||
->columns([
|
||||
amisMake()->TableColumn()->name('plant_name')->label('名称'),
|
||||
amisMake()->TableColumn()->name('director')->label('负责人'),
|
||||
amisMake()->TableColumn()->name('area')->label('种植面积'),
|
||||
amisMake()->TableColumn()->name('area')->label('种植面积m²'),
|
||||
amisMake()->TableColumn()->name('start_at')->label('种植时间'),
|
||||
])
|
||||
->itemAction([
|
||||
'type'=>'button',
|
||||
'actionType'=>'dialog',
|
||||
'dialog'=> \amisMake()->Dialog()->title('作物名称')
|
||||
'dialog'=> \amisMake()->Dialog()->title('${plant_name}')
|
||||
->size('full')->actions([])->body([
|
||||
\amisMake()->Tabs()->tabsMode('simple')->name('detailTab')->tabs([
|
||||
[
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ Route::group([
|
|||
|
||||
//种植记录
|
||||
$router->resource('crop-plants', \App\Admin\Controllers\CropPlantController::class)->only(['index','store', 'edit', 'update', 'destroy']);
|
||||
$router->resource('crop-harvestes', \App\Admin\Controllers\CropHarvestController::class)->only(['index','store', 'edit', 'update', 'destroy']);
|
||||
$router->post('crop-plant-detail', '\App\Admin\Controllers\CropPlantController@plantDetail');
|
||||
|
||||
$router->resource('system/settings', \App\Admin\Controllers\SettingController::class);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filters\Admin;
|
||||
|
||||
use EloquentFilter\ModelFilter;
|
||||
|
||||
class PlantHarvestLogFilter extends ModelFilter
|
||||
{
|
||||
/**
|
||||
* 所属种植计划
|
||||
*/
|
||||
public function plant($plantId){
|
||||
return $this->where('plant_id', $plantId);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filters\Admin;
|
||||
|
||||
use EloquentFilter\ModelFilter;
|
||||
|
||||
class RegionPlantLogFilter extends ModelFilter
|
||||
{
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
public function plantName($name){
|
||||
return $this->where('plant_name', 'like', '%'.$name.'%');
|
||||
}
|
||||
|
||||
/**
|
||||
* 所属区域
|
||||
*/
|
||||
public function region($regionId){
|
||||
return $this->where('region_id', $regionId);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use EloquentFilter\Filterable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PlantHarvestLog extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use Filterable;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use EloquentFilter\Filterable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class RegionPlantLog extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use Filterable;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services\Admin;
|
||||
|
||||
use App\Models\PlantHarvestLog;
|
||||
|
||||
/**
|
||||
* @method PlantHarvestLog getModel()
|
||||
* @method PlantHarvestLog|\Illuminate\Database\Query\Builder query()
|
||||
*/
|
||||
class CropHarvestService extends BaseService
|
||||
{
|
||||
protected string $modelName = PlantHarvestLog::class;
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Services\Admin;
|
||||
|
||||
use App\Models\RegionPlantLog;
|
||||
use App\Filters\Admin\RegionPlantFilter;
|
||||
|
||||
/**
|
||||
* @method RegionPlantLog getModel()
|
||||
|
|
@ -11,4 +12,7 @@ use App\Models\RegionPlantLog;
|
|||
class CropPlantService extends BaseService
|
||||
{
|
||||
protected string $modelName = RegionPlantLog::class;
|
||||
|
||||
protected string $modelFilterName = RegionPlantFilter::class;
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue