调整收获记录
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 Illuminate\Http\Request;
|
||||||
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
||||||
|
use Slowlyo\OwlAdmin\Renderers\DialogAction;
|
||||||
|
use Slowlyo\OwlAdmin\Renderers\Dialog;
|
||||||
use App\Services\Admin\CropPlantService;
|
use App\Services\Admin\CropPlantService;
|
||||||
|
use App\Admin\Components;
|
||||||
|
use App\Models\RegionPlantLog;
|
||||||
|
|
||||||
class CropPlantController extends AdminController
|
class CropPlantController extends AdminController
|
||||||
{
|
{
|
||||||
|
|
@ -23,72 +27,80 @@ class CropPlantController extends AdminController
|
||||||
$random1 = $randArr();
|
$random1 = $randArr();
|
||||||
$random2 = $randArr();
|
$random2 = $randArr();
|
||||||
|
|
||||||
return amisMake()->Grid()->columns([
|
$id = $request->id;
|
||||||
amisMake()->Wrapper()->sm(6)->body([
|
$plant = RegionPlantLog::find($id);
|
||||||
amisMake()->Panel()->title('基础详情')
|
$page = $this->basePage()->body([
|
||||||
->subFormMode('horizontal')
|
amisMake()->Grid()->columns([
|
||||||
->labelWidth(100)
|
amisMake()->Wrapper()->sm(6)->body([
|
||||||
->className('Panel--success')
|
amisMake()->Panel()->title('种植详情')
|
||||||
->body([
|
->subFormMode('horizontal')
|
||||||
\amisMake()->TextControl()->static(true)->name('name')->label('名称')->value('试验田1'),
|
->labelWidth(100)
|
||||||
\amisMake()->TextControl()->static(true)->name('name1')->label('负责人')->value('负责人'),
|
->body([
|
||||||
\amisMake()->TextControl()->static(true)->name('area')->label('种植面积m²')->value(),
|
\amisMake()->TextControl()->static(true)->name('plant_name')->label('作物名称')->value($plant->plant_name),
|
||||||
\amisMake()->TextControl()->static(true)->name('time')->label('种植时间')->value('2023-03-01'),
|
\amisMake()->TextControl()->static(true)->name('director')->label('负责人')->value($plant->director),
|
||||||
]),
|
\amisMake()->TextControl()->static(true)->name('area')->label('种植面积m²')->value($plant->area),
|
||||||
amisMake()->Panel()->title('收割记录')
|
\amisMake()->TextControl()->static(true)->name('start_at')->label('种植时间')->value($plant->start_at),
|
||||||
->className('Panel--success')
|
]),
|
||||||
->body([
|
amisMake()->Panel()->title('收获记录')
|
||||||
\amisMake()->Button()->className('absolute top-1 right-4')->actionType('dialog')->label('新增')->dialog([
|
->body([
|
||||||
"title"=> "收割记录",
|
DialogAction::make()->className('absolute top-1 right-4')->label(__('admin.create'))->dialog(
|
||||||
"body"=> [
|
Dialog::make()->title('收获记录')->body($this->harvestCreateForm($plant))
|
||||||
"type"=> "form",
|
),
|
||||||
"api"=> "",
|
\amisMake()->CRUDTable()
|
||||||
"body"=> [
|
->api(admin_url('crop-harvestes').'?_action=getData&plant_id='.$plant->id)
|
||||||
\amisMake()->TextControl()->label('负责人'),
|
->title('')
|
||||||
\amisMake()->TextControl()->label('收割面积'),
|
->columns([
|
||||||
\amisMake()->TextControl()->label('收割产量'),
|
amisMake()->TableColumn()->name('name')->label('负责人'),
|
||||||
\amisMake()->DateControl()->label('收割时间'),
|
amisMake()->TableColumn()->name('name1')->label('收获面积m²'),
|
||||||
]
|
amisMake()->TableColumn()->name('area')->label('收获产量kg'),
|
||||||
]
|
amisMake()->TableColumn()->name('time1')->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'),
|
|
||||||
]),
|
|
||||||
]),
|
]),
|
||||||
amisMake()->Card()->className('m-r')->body(
|
amisMake()->Wrapper()->sm(6)->body([
|
||||||
amisMake()->Chart()->config("{
|
\amisMake()->grid()->columns([
|
||||||
title:{ text: '种植情况'},
|
\amisMake()->Form()->title('搜索条件')->mode('inline')->body([
|
||||||
tooltip: { trigger: 'axis' },
|
\amisMake()->DateRangeControl()->label('时间范围'),
|
||||||
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'] },
|
amis('submit')->label(__('admin.search'))->level('primary'),
|
||||||
yAxis: { type: 'value' },
|
]),
|
||||||
grid:{ left: '7%', right:'3%', top: 60, bottom: 30, },
|
]),
|
||||||
series: [
|
amisMake()->Card()->className('m-r')->body(
|
||||||
{ name:'面积', data: {$random2}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', },
|
amisMake()->Chart()->config("{
|
||||||
{ name:'产量', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', },
|
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([
|
->columns([
|
||||||
amisMake()->TableColumn()->name('plant_name')->label('名称'),
|
amisMake()->TableColumn()->name('plant_name')->label('名称'),
|
||||||
amisMake()->TableColumn()->name('director')->label('负责人'),
|
amisMake()->TableColumn()->name('director')->label('负责人'),
|
||||||
amisMake()->TableColumn()->name('area')->label('种植面积'),
|
amisMake()->TableColumn()->name('area')->label('种植面积m²'),
|
||||||
amisMake()->TableColumn()->name('start_at')->label('种植时间'),
|
amisMake()->TableColumn()->name('start_at')->label('种植时间'),
|
||||||
])
|
])
|
||||||
->itemAction([
|
->itemAction([
|
||||||
'type'=>'button',
|
'type'=>'button',
|
||||||
'actionType'=>'dialog',
|
'actionType'=>'dialog',
|
||||||
'dialog'=> \amisMake()->Dialog()->title('作物名称')
|
'dialog'=> \amisMake()->Dialog()->title('${plant_name}')
|
||||||
->size('full')->actions([])->body([
|
->size('full')->actions([])->body([
|
||||||
\amisMake()->Tabs()->tabsMode('simple')->name('detailTab')->tabs([
|
\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-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->post('crop-plant-detail', '\App\Admin\Controllers\CropPlantController@plantDetail');
|
||||||
|
|
||||||
$router->resource('system/settings', \App\Admin\Controllers\SettingController::class);
|
$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;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use EloquentFilter\Filterable;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class PlantHarvestLog extends Model
|
class PlantHarvestLog extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use Filterable;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use EloquentFilter\Filterable;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class RegionPlantLog extends 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;
|
namespace App\Services\Admin;
|
||||||
|
|
||||||
use App\Models\RegionPlantLog;
|
use App\Models\RegionPlantLog;
|
||||||
|
use App\Filters\Admin\RegionPlantFilter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method RegionPlantLog getModel()
|
* @method RegionPlantLog getModel()
|
||||||
|
|
@ -11,4 +12,7 @@ use App\Models\RegionPlantLog;
|
||||||
class CropPlantService extends BaseService
|
class CropPlantService extends BaseService
|
||||||
{
|
{
|
||||||
protected string $modelName = RegionPlantLog::class;
|
protected string $modelName = RegionPlantLog::class;
|
||||||
|
|
||||||
|
protected string $modelFilterName = RegionPlantFilter::class;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue