完善种植记录添加删除修改
parent
2ed2ce6968
commit
e0f73aff5d
|
|
@ -4,9 +4,12 @@ namespace App\Admin\Controllers;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
||||||
|
use App\Services\Admin\CropPlanService;
|
||||||
|
|
||||||
class CropController extends AdminController
|
class CropController extends AdminController
|
||||||
{
|
{
|
||||||
|
protected string $serviceName = CropPlanService::class;
|
||||||
|
|
||||||
public function planDetail(Request $request)
|
public function planDetail(Request $request)
|
||||||
{
|
{
|
||||||
$randArr = function () {
|
$randArr = function () {
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,9 @@ use Slowlyo\OwlAdmin\Controllers\AdminController;
|
||||||
use App\Admin\Components;
|
use App\Admin\Components;
|
||||||
use App\Models\Region;
|
use App\Models\Region;
|
||||||
use App\Models\Device;
|
use App\Models\Device;
|
||||||
|
use Slowlyo\OwlAdmin\Renderers\DialogAction;
|
||||||
|
use Slowlyo\OwlAdmin\Renderers\Dialog;
|
||||||
|
use Slowlyo\OwlAdmin\Renderers\Service;
|
||||||
|
|
||||||
class CustomRegionController extends AdminController
|
class CustomRegionController extends AdminController
|
||||||
{
|
{
|
||||||
|
|
@ -115,13 +118,11 @@ class CustomRegionController extends AdminController
|
||||||
$resList[] = [
|
$resList[] = [
|
||||||
"icon"=> $region->cover ?? '',
|
"icon"=> $region->cover ?? '',
|
||||||
"text"=> $region->name,
|
"text"=> $region->name,
|
||||||
'clickAction' => [
|
'clickAction' => DialogAction::make()->dialog(
|
||||||
'actionType'=> 'dialog',
|
Dialog::make()->title($region['name'])->body([
|
||||||
'dialog' => \amisMake()->Dialog()->title($region['name'])
|
\amisMake()->Tabs()->tabsMode('simple')->name('detailTab')->tabs($tabs),
|
||||||
->size('full')->actions([])->body([
|
])->size('full')
|
||||||
\amisMake()->Tabs()->tabsMode('simple')->name('detailTab')->tabs($tabs),
|
),
|
||||||
])
|
|
||||||
]
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
return $resList;
|
return $resList;
|
||||||
|
|
@ -131,98 +132,122 @@ class CustomRegionController extends AdminController
|
||||||
{
|
{
|
||||||
$id = $request->id;
|
$id = $request->id;
|
||||||
$region = Region::find($id);
|
$region = Region::find($id);
|
||||||
return amisMake()->Grid()->columns([
|
$page = $this->basePage()->body([
|
||||||
amisMake()->Wrapper()->sm(4)->body([
|
amisMake()->Grid()->columns([
|
||||||
amisMake()->Panel()->title('基础详情')
|
amisMake()->Wrapper()->sm(4)->body([
|
||||||
->subFormMode('horizontal')
|
amisMake()->Panel()->title('基础详情')
|
||||||
->labelWidth(100)
|
->subFormMode('horizontal')
|
||||||
// ->headerClassName('text-white')
|
->labelWidth(100)
|
||||||
|
->body([
|
||||||
|
\amisMake()->TextControl()->static(true)->name('name')->label('名称')->value($region->name),
|
||||||
|
\amisMake()->TextControl()->static(true)->name('director')->label('负责人')->value($region->director),
|
||||||
|
\amisMake()->TextControl()->static(true)->name('category')->label('分类')->value($region->category?->name ?? ''),
|
||||||
|
\amisMake()->TextControl()->static(true)->name('area')->label('面积m²')->value($region?->area ?? ''),
|
||||||
|
\amisMake()->TextControl()->static(true)->name('sort')->label('排序')->value($region?->sort ?? '0'),
|
||||||
|
\amisMake()->SwitchControl()->static(true)->name('is_enable')->name('is_enable')->label('显示')->value($region?->is_enable ?? 0),
|
||||||
|
]),
|
||||||
|
amisMake()->Panel()->title('基础介绍')
|
||||||
->body([
|
->body([
|
||||||
\amisMake()->TextControl()->static(true)->name('name')->label('名称')->value('试验田1'),
|
amisMake()->Tpl()->tpl($region?->content ?? '')
|
||||||
\amisMake()->TextControl()->static(true)->name('name1')->label('负责人')->value('负责人'),
|
])
|
||||||
\amisMake()->TextControl()->static(true)->name('category')->label('分类')->value($region->category?->name ?? ''),
|
]),
|
||||||
\amisMake()->TextControl()->static(true)->name('area')->label('面积m²')->value($region?->area ?? ''),
|
amisMake()->Wrapper()->sm(8)->body([
|
||||||
\amisMake()->TextControl()->static(true)->name('sort')->label('排序')->value($region?->sort ?? '0'),
|
amisMake()->Panel()->title('种植记录')
|
||||||
\amisMake()->SwitchControl()->static(true)->name('is_enable')->name('is_enable')->label('显示')->value($region?->is_enable ?? 0),
|
->body([
|
||||||
]),
|
DialogAction::make()->className('absolute top-1 right-4')->label(__('admin.create'))->dialog(
|
||||||
amisMake()->Panel()->title('基础介绍')
|
Dialog::make()->title('新增种植记录')->body($this->plantCreateForm($region))
|
||||||
// ->headerClassName('text-white')
|
),
|
||||||
->body([
|
\amisMake()->CRUDTable()
|
||||||
amisMake()->Tpl()->tpl($region?->content ?? '')
|
->title('')
|
||||||
])
|
->api(admin_url('crop-plans').'?_action=getData®ion_id='.$region->id)
|
||||||
]),
|
->columns([
|
||||||
amisMake()->Wrapper()->sm(8)->body([
|
amisMake()->TableColumn()->name('plant_name')->label('名称'),
|
||||||
amisMake()->Panel()->title('种植记录')
|
amisMake()->TableColumn()->name('director')->label('负责人'),
|
||||||
// ->headerClassName('text-white')
|
amisMake()->TableColumn()->name('area')->label('种植面积'),
|
||||||
->body([
|
amisMake()->TableColumn()->name('start_at')->label('种植时间'),
|
||||||
\amisMake()->Button()->className('absolute top-1 right-4')->actionType('dialog')->label('新增')->dialog([
|
])
|
||||||
"title"=> "种植记录",
|
->itemAction([
|
||||||
"body"=> [
|
'type'=>'button',
|
||||||
"type"=> "form",
|
'actionType'=>'dialog',
|
||||||
"api"=> "post:/amis/api/mock2/sample",
|
'dialog'=> \amisMake()->Dialog()->title('作物名称')
|
||||||
"body"=> [
|
->size('full')->actions([])->body([
|
||||||
\amisMake()->TextControl()->label('作物名称'),
|
\amisMake()->Tabs()->tabsMode('simple')->name('detailTab')->tabs([
|
||||||
\amisMake()->TextControl()->label('负责人'),
|
[
|
||||||
\amisMake()->TextControl()->label('种植面积'),
|
'title' => '种植详情',
|
||||||
\amisMake()->DateControl()->label('种植时间'),
|
'value' => 'detail',
|
||||||
]
|
'tab'=>\amisMake()->Service()->schemaApi(admin_url('crop-plan-detail?id=')),//传id
|
||||||
]
|
'unmountOnExit' => true//每次切换tab都要销毁
|
||||||
])->level('enhance'),
|
],
|
||||||
\amisMake()->CRUDTable()->title('')
|
[
|
||||||
->data([
|
'title' => '报警记录',
|
||||||
'items' => [
|
'value' => 'warning',
|
||||||
[
|
// 'tab'=>\amisMake()->Service()->schemaApi(admin_url('custom-region-detail?id='.$region['id'])),
|
||||||
'name'=> '作物名称',
|
'unmountOnExit' => true//每次切换tab都要销毁
|
||||||
'name1'=> '负责人',
|
],
|
||||||
'area'=> '100',
|
[
|
||||||
'time1'=> '2023-03-21',
|
'title' => '虫情记录',
|
||||||
],
|
'value' => 'warning',
|
||||||
[
|
// 'tab'=>\amisMake()->Service()->schemaApi(admin_url('custom-region-detail?id='.$region['id'])),
|
||||||
'name'=> '作物名称2',
|
'unmountOnExit' => true//每次切换tab都要销毁
|
||||||
'name1'=> '负责人',
|
],
|
||||||
'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('种植时间'),
|
|
||||||
])
|
|
||||||
->itemAction([
|
|
||||||
'type'=>'button',
|
|
||||||
'actionType'=>'dialog',
|
|
||||||
'dialog'=> \amisMake()->Dialog()->title('作物名称')
|
|
||||||
->size('full')->actions([])->body([
|
|
||||||
\amisMake()->Tabs()->tabsMode('simple')->name('detailTab')->tabs([
|
|
||||||
[
|
|
||||||
'title' => '种植详情',
|
|
||||||
'value' => 'detail',
|
|
||||||
'tab'=>\amisMake()->Service()->schemaApi(admin_url('crop-plan-detail?id=')),//传id
|
|
||||||
'unmountOnExit' => true//每次切换tab都要销毁
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'title' => '报警记录',
|
|
||||||
'value' => 'warning',
|
|
||||||
// 'tab'=>\amisMake()->Service()->schemaApi(admin_url('custom-region-detail?id='.$region['id'])),
|
|
||||||
'unmountOnExit' => true//每次切换tab都要销毁
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'title' => '虫情记录',
|
|
||||||
'value' => 'warning',
|
|
||||||
// 'tab'=>\amisMake()->Service()->schemaApi(admin_url('custom-region-detail?id='.$region['id'])),
|
|
||||||
'unmountOnExit' => true//每次切换tab都要销毁
|
|
||||||
],
|
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
])
|
->itemActions([
|
||||||
// ->itemActions([
|
\amisMake()->DialogAction()->label('编辑')->dialog(
|
||||||
// \amisMake()->DialogAction()->label('新增收获')->level('link')
|
Dialog::make()->title('编辑种植记录')->body($this->plantEditForm())
|
||||||
// ])
|
),
|
||||||
])
|
\amisMake()->AjaxAction()->label('删除')->level('link')
|
||||||
]),
|
->actionType('ajax')
|
||||||
|
->confirmText(__('admin.confirm_delete'))
|
||||||
|
->api([
|
||||||
|
'method' => 'delete',
|
||||||
|
'url' => admin_url('crop-plans/${id}')
|
||||||
|
])
|
||||||
|
])
|
||||||
|
])
|
||||||
|
]),
|
||||||
|
])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
return $this->response()->success($page);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function plantCreateForm(Region $region = null){
|
||||||
|
return amisMake()->Form()
|
||||||
|
->api([
|
||||||
|
'method'=>'post',
|
||||||
|
'url'=>admin_url('crop-plans'),
|
||||||
|
"data" => [
|
||||||
|
'region_id'=>'${region_id}',
|
||||||
|
'plant_name'=>'${plant_name}',
|
||||||
|
'director'=>'${plant_director}',
|
||||||
|
'area'=>'${plant_area}',
|
||||||
|
'start_at'=>'${start_at}',
|
||||||
|
],
|
||||||
|
])
|
||||||
|
->body([
|
||||||
|
\amisMake()->TextControl()->name('region_id')->label('区域ID')->hidden(true)->value($region?->id ?? 0),
|
||||||
|
\amisMake()->TextControl()->name('plant_name')->label('作物名称')->required(true),
|
||||||
|
\amisMake()->TextControl()->name('plant_director')->label('负责人')->required(true),
|
||||||
|
Components::make()->decimalControl('plant_area','种植面积')->required(true),
|
||||||
|
\amisMake()->DateControl()->name('start_at')->format('YYYY-MM-DD HH:mm:ss')->label('种植时间')->required(true),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function plantEditForm(){
|
||||||
|
return amisMake()->Form()
|
||||||
|
->api([
|
||||||
|
'method'=>'put',
|
||||||
|
'url'=>admin_url('crop-plans/${id}'),
|
||||||
|
])->initApi(admin_url('crop-plans/${id}/edit').'?_action=getData')
|
||||||
|
->body([
|
||||||
|
\amisMake()->TextControl()->name('id')->hidden(true),
|
||||||
|
\amisMake()->TextControl()->name('region_id')->label('区域ID')->hidden(true),
|
||||||
|
\amisMake()->TextControl()->name('plant_name')->label('作物名称')->required(true),
|
||||||
|
\amisMake()->TextControl()->name('director')->label('负责人')->required(true),
|
||||||
|
Components::make()->decimalControl('area','种植面积')->required(true),
|
||||||
|
\amisMake()->DateControl()->name('start_at')->format('YYYY-MM-DD HH:mm:ss')->label('种植时间')->required(true),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,7 @@ Route::group([
|
||||||
$router->post('custom-region-wasserstrahl', '\App\Admin\Controllers\DeviceController@wasserstrahlDetail');
|
$router->post('custom-region-wasserstrahl', '\App\Admin\Controllers\DeviceController@wasserstrahlDetail');
|
||||||
|
|
||||||
//种植记录
|
//种植记录
|
||||||
|
$router->resource('crop-plans', \App\Admin\Controllers\CropController::class)->only(['index','store', 'edit', 'update', 'destroy']);
|
||||||
$router->post('crop-plan-detail', '\App\Admin\Controllers\CropController@planDetail');
|
$router->post('crop-plan-detail', '\App\Admin\Controllers\CropController@planDetail');
|
||||||
|
|
||||||
$router->resource('system/settings', \App\Admin\Controllers\SettingController::class);
|
$router->resource('system/settings', \App\Admin\Controllers\SettingController::class);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Admin;
|
||||||
|
|
||||||
|
use App\Models\RegionPlantLog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method RegionPlantLog getModel()
|
||||||
|
* @method RegionPlantLog|\Illuminate\Database\Query\Builder query()
|
||||||
|
*/
|
||||||
|
class CropPlanService extends BaseService
|
||||||
|
{
|
||||||
|
protected string $modelName = RegionPlantLog::class;
|
||||||
|
}
|
||||||
|
|
@ -19,6 +19,7 @@ return new class extends Migration
|
||||||
$table->string('plant_name')->comment('种植名称');
|
$table->string('plant_name')->comment('种植名称');
|
||||||
$table->string('director')->nullable()->comment('负责人');
|
$table->string('director')->nullable()->comment('负责人');
|
||||||
$table->text('description')->nullable()->comment('描述');
|
$table->text('description')->nullable()->comment('描述');
|
||||||
|
$table->decimal('area')->default(0.00)->comment('面积/平米');
|
||||||
$table->timestamp('start_at')->nullable()->comment('种植开始时间');
|
$table->timestamp('start_at')->nullable()->comment('种植开始时间');
|
||||||
$table->unsignedTinyInteger('status')->default(0)->comment('0未开始,1种植中,2已结束');
|
$table->unsignedTinyInteger('status')->default(0)->comment('0未开始,1种植中,2已结束');
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
|
|
@ -7,7 +7,7 @@
|
||||||
<meta http-equiv="X-UA-Compatible" content="ie=edge"/>
|
<meta http-equiv="X-UA-Compatible" content="ie=edge"/>
|
||||||
<title></title>
|
<title></title>
|
||||||
<script type="module" crossorigin src="/admin/assets/index.6254441a.js"></script>
|
<script type="module" crossorigin src="/admin/assets/index.6254441a.js"></script>
|
||||||
<link rel="stylesheet" href="/admin/assets/index.0b145e6a.css">
|
<link rel="stylesheet" href="/admin/assets/index.7e62ffe4.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue