Compare commits
No commits in common. "7ef12f611e3533362ca025e64c2dcbc0ea31a9f8" and "4b2d6f95ac5bd6d9281dcd35ce976672277d585d" have entirely different histories.
7ef12f611e
...
4b2d6f95ac
|
|
@ -25,24 +25,10 @@ class Components extends BaseRenderer {
|
||||||
public function sortControl($name ='sort', $label = '排序'){
|
public function sortControl($name ='sort', $label = '排序'){
|
||||||
return amisMake()->NumberControl()
|
return amisMake()->NumberControl()
|
||||||
->name($name)->label($label)
|
->name($name)->label($label)
|
||||||
->displayMode('enhance')
|
|
||||||
->value(0)
|
->value(0)
|
||||||
->min(0);
|
->min(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 2位小数输入框
|
|
||||||
*/
|
|
||||||
public function decimalControl($name ='decimal', $label = '数值'){
|
|
||||||
return amisMake()->NumberControl()
|
|
||||||
->name($name)->label($label)
|
|
||||||
->kilobitSeparator(true)
|
|
||||||
->percision(2)
|
|
||||||
->step(0.01)
|
|
||||||
->value(0.00)
|
|
||||||
->min(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 富文本编辑器
|
* 富文本编辑器
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,6 @@ class ArticleController extends AdminController
|
||||||
->columns([
|
->columns([
|
||||||
TableColumn::make()->name('id')->label('ID')->sortable(true),
|
TableColumn::make()->name('id')->label('ID')->sortable(true),
|
||||||
TableColumn::make()->name('title')->label('标题'),
|
TableColumn::make()->name('title')->label('标题'),
|
||||||
TableColumn::make()->name('category_id')->label('分类')->className('text-primary'),
|
|
||||||
TableColumn::make()->name('sub_title')->label('副标题'),
|
|
||||||
TableColumn::make()->name('is_enable')->type('switch')->label('显示'),
|
|
||||||
TableColumn::make()->name('published_at')->label('发布时间')->type('datetime')->sortable(true),
|
|
||||||
TableColumn::make()->name('created_at')->label('创建时间')->type('datetime')->sortable(true),
|
TableColumn::make()->name('created_at')->label('创建时间')->type('datetime')->sortable(true),
|
||||||
TableColumn::make()->name('updated_at')->label('更新时间')->type('datetime')->sortable(true),
|
TableColumn::make()->name('updated_at')->label('更新时间')->type('datetime')->sortable(true),
|
||||||
$this->rowActions(true, 'lg'),
|
$this->rowActions(true, 'lg'),
|
||||||
|
|
|
||||||
|
|
@ -1,151 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Admin\Controllers;
|
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Slowlyo\OwlAdmin\Renderers\Page;
|
|
||||||
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
|
||||||
use App\Admin\Components;
|
|
||||||
use App\Models\Region;
|
|
||||||
|
|
||||||
class CustomRegionController extends AdminController
|
|
||||||
{
|
|
||||||
protected string $pageTitle = '标题';
|
|
||||||
|
|
||||||
protected string $queryPath = 'custom-region';
|
|
||||||
|
|
||||||
public function regionIndex($type)
|
|
||||||
{
|
|
||||||
|
|
||||||
switch($type){
|
|
||||||
case 'yuyang':
|
|
||||||
$this->pageTitle = '育秧列表';
|
|
||||||
break;
|
|
||||||
case 'daotian':
|
|
||||||
$this->pageTitle = '稻田列表';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$page = $this->basePage()->body([
|
|
||||||
\amisMake()->GridNav()->options(
|
|
||||||
$this->regionList()
|
|
||||||
)
|
|
||||||
]);
|
|
||||||
|
|
||||||
return $this->response()->success($page);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function regionList(){
|
|
||||||
$regionList = [
|
|
||||||
[
|
|
||||||
'id' => 1,
|
|
||||||
'name' => '实验田1',
|
|
||||||
'cover' => 'https://internal-amis-res.cdn.bcebos.com/images/icon-1.png'
|
|
||||||
]
|
|
||||||
];
|
|
||||||
return array_map(function($region){
|
|
||||||
return [
|
|
||||||
"icon"=> $region['cover'],
|
|
||||||
"text"=> $region['name'],
|
|
||||||
'clickAction' => [
|
|
||||||
'actionType'=> 'dialog',
|
|
||||||
'dialog' => \amisMake()->Dialog()->title($region['name'])
|
|
||||||
->size('full')->actions([])->body([
|
|
||||||
\amisMake()->Tabs()->tabsMode('simple')->name('detailTab')->tabs([
|
|
||||||
[
|
|
||||||
'title' => '基地详情',
|
|
||||||
'value' => 'detail',
|
|
||||||
'tab'=>\amisMake()->Service()->schemaApi(admin_url('custom-region-detail?id='.$region['id']))
|
|
||||||
],
|
|
||||||
[//有监控设备才有
|
|
||||||
'title' => '监控视频',
|
|
||||||
'value' => 'monitor',
|
|
||||||
'tab'=>\amisMake()->Service()->schemaApi(admin_url('custom-region-monitor?id='.$region['id'])),
|
|
||||||
'unmountOnExit' => true//每次切换tab都要销毁
|
|
||||||
],
|
|
||||||
[//有气象设备才有
|
|
||||||
'title' => '气象数据',
|
|
||||||
'value' => 'qixiang',
|
|
||||||
'tab'=>\amisMake()->Service()->schemaApi(admin_url('custom-region-detail?type=qixiang'))
|
|
||||||
],
|
|
||||||
[//有水质设备才有
|
|
||||||
'title' => '水质数据',
|
|
||||||
'value' => 'shuizi',
|
|
||||||
'tab'=>\amisMake()->Service()->schemaApi(admin_url('custom-region-detail?type=shuizi'))
|
|
||||||
],
|
|
||||||
[//有土壤设备才有
|
|
||||||
'title' => '土壤数据',
|
|
||||||
'value' => 'turang',
|
|
||||||
'tab'=>\amisMake()->Service()->schemaApi(admin_url('custom-region-detail?type=turang'))
|
|
||||||
],
|
|
||||||
[//有通风设备才有
|
|
||||||
'title' => '通风设备',
|
|
||||||
'value' => 'tongfeng',
|
|
||||||
'tab'=>\amisMake()->Service()->schemaApi(admin_url('custom-region-detail?type=tongfeng'))
|
|
||||||
],
|
|
||||||
[//有喷灌设备才有
|
|
||||||
'title' => '喷灌设备',
|
|
||||||
'value' => 'penguan',
|
|
||||||
'tab'=>\amisMake()->Service()->schemaApi(admin_url('custom-region-detail?type=penguan'))
|
|
||||||
],
|
|
||||||
|
|
||||||
]),
|
|
||||||
])
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}, $regionList);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function regionDetail(Request $request)
|
|
||||||
{
|
|
||||||
$id = $request->id;
|
|
||||||
$region = Region::find($id);
|
|
||||||
return amisMake()->Grid()->columns([
|
|
||||||
amisMake()->Wrapper()->sm(4)->body([
|
|
||||||
amisMake()->Panel()->title('基础详情')
|
|
||||||
->subFormMode('horizontal')
|
|
||||||
->labelWidth(100)
|
|
||||||
->className('Panel--success')
|
|
||||||
->body([
|
|
||||||
\amisMake()->TextControl()->static(true)->label('名称')->value('试验田1'),
|
|
||||||
\amisMake()->TextControl()->static(true)->label('负责人')->value('负责人'),
|
|
||||||
\amisMake()->TextControl()->static(true)->label('分类')->value($region->category?->name ?? ''),
|
|
||||||
\amisMake()->TextControl()->static(true)->label('面积m²')->value($region->area),
|
|
||||||
\amisMake()->TextControl()->static(true)->label('排序')->value($region->sort),
|
|
||||||
\amisMake()->SwitchControl()->static(true)->name('is_enable')->label('显示')->value($region->is_enable),
|
|
||||||
]),
|
|
||||||
amisMake()->Panel()->title('基础介绍')
|
|
||||||
->className('Panel--success')
|
|
||||||
->body([
|
|
||||||
amisMake()->Tpl()->tpl($region->content)
|
|
||||||
])
|
|
||||||
]),
|
|
||||||
amisMake()->Wrapper()->sm(8)->body([
|
|
||||||
amisMake()->Panel()->title('种植记录')
|
|
||||||
->className('Panel--success')
|
|
||||||
->body([
|
|
||||||
\amisMake()->Table()->title('')
|
|
||||||
->data([
|
|
||||||
'items' => [
|
|
||||||
[
|
|
||||||
'name'=> '作物名称',
|
|
||||||
'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('开始时间'),
|
|
||||||
])
|
|
||||||
->itemActions([
|
|
||||||
// amisMake()->DialogAction()->label('收获记录')->level('link')
|
|
||||||
])
|
|
||||||
])
|
|
||||||
]),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -6,7 +6,6 @@ use Slowlyo\OwlAdmin\Renderers\Page;
|
||||||
use Slowlyo\OwlAdmin\Renderers\Form;
|
use Slowlyo\OwlAdmin\Renderers\Form;
|
||||||
use Slowlyo\OwlAdmin\Renderers\TableColumn;
|
use Slowlyo\OwlAdmin\Renderers\TableColumn;
|
||||||
use Slowlyo\OwlAdmin\Renderers\TextControl;
|
use Slowlyo\OwlAdmin\Renderers\TextControl;
|
||||||
use Slowlyo\OwlAdmin\Renderers\CRUDTable;
|
|
||||||
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
||||||
use App\Services\Admin\DeviceService;
|
use App\Services\Admin\DeviceService;
|
||||||
use App\Models\Device;
|
use App\Models\Device;
|
||||||
|
|
@ -70,34 +69,4 @@ class DeviceController extends AdminController
|
||||||
TextControl::make()->static(true)->name('updated_at')->label('更新时间')
|
TextControl::make()->static(true)->name('updated_at')->label('更新时间')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 监控设备列表
|
|
||||||
*/
|
|
||||||
public function monitorList(){
|
|
||||||
return CRUDTable::make()->mode('cards')->columnsCount(3)
|
|
||||||
->data([
|
|
||||||
'items' => [
|
|
||||||
[
|
|
||||||
'id'=>1,
|
|
||||||
'src'=>'ws://183.221.204.29:8100/rtsp?url=cnRzcDovL2FkbWluOjEyMzQ1Njc4OXhAMTE3LjE3NC4xODQuMTE4OjkwMDkvY2FtL3JlYWxtb25pdG9yP2NoYW5uZWw9MSZzdWJ0eXBlPTA='
|
|
||||||
],
|
|
||||||
]
|
|
||||||
])
|
|
||||||
// ->filter([
|
|
||||||
// 'title' => '指定位置',
|
|
||||||
// 'body' => [
|
|
||||||
// \amisMake()->TableControl()->name('name')->label('点位名称')->size('sm')->actions([
|
|
||||||
// ["type"=> "submit","level"=> "primary","label"=> "查询"]
|
|
||||||
// ])
|
|
||||||
// ]
|
|
||||||
// ])
|
|
||||||
->itemClassName('col-sm-4')
|
|
||||||
->card([
|
|
||||||
'header' => [],
|
|
||||||
'body' => amisMake()->Video()
|
|
||||||
->isLive(true)->videoType('video/x-flv')->muted(true)->autoPlay(true)
|
|
||||||
->src('${src}')
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@ use Slowlyo\OwlAdmin\Controllers\AdminController;
|
||||||
|
|
||||||
class HomeController extends AdminController
|
class HomeController extends AdminController
|
||||||
{
|
{
|
||||||
|
protected string $queryPath = 'dashboard';
|
||||||
|
|
||||||
protected string $pageTitle = '首页';
|
protected string $pageTitle = '首页';
|
||||||
|
|
||||||
public function index(): JsonResponse|JsonResource
|
public function index(): JsonResponse|JsonResource
|
||||||
|
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Admin\Controllers;
|
|
||||||
|
|
||||||
use Slowlyo\OwlAdmin\Renderers\Page;
|
|
||||||
use Slowlyo\OwlAdmin\Renderers\Form;
|
|
||||||
use Slowlyo\OwlAdmin\Renderers\TableColumn;
|
|
||||||
use Slowlyo\OwlAdmin\Renderers\TextControl;
|
|
||||||
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
|
||||||
use App\Services\Admin\RegionCategoryService;
|
|
||||||
use App\Admin\Components;
|
|
||||||
|
|
||||||
class RegionCategoryController extends AdminController
|
|
||||||
{
|
|
||||||
protected string $serviceName = RegionCategoryService::class;
|
|
||||||
|
|
||||||
protected string $pageTitle = '区域分类';
|
|
||||||
|
|
||||||
public function list(): Page
|
|
||||||
{
|
|
||||||
$crud = $this->baseCRUD()
|
|
||||||
//关闭查询
|
|
||||||
->filterTogglable(false)
|
|
||||||
//去掉分页-start
|
|
||||||
->loadDataOnce(true)
|
|
||||||
->footerToolbar([])
|
|
||||||
//去掉分页-end
|
|
||||||
->headerToolbar([
|
|
||||||
$this->createButton(true),
|
|
||||||
...$this->baseHeaderToolBar(),
|
|
||||||
])
|
|
||||||
->columns([
|
|
||||||
TableColumn::make()->name('id')->label('ID')->sortable(true),
|
|
||||||
TableColumn::make()->name('name')->label('名称'),
|
|
||||||
// TableColumn::make()->name('parent.name')->label('父级ID'),
|
|
||||||
TableColumn::make()->name('sort')->label('排序'),
|
|
||||||
TableColumn::make()->name('is_enable')->type('switch')->label('显示'),
|
|
||||||
TableColumn::make()->name('created_at')->label('创建时间')->type('datetime')->sortable(true),
|
|
||||||
$this->rowActions(true),
|
|
||||||
]);
|
|
||||||
|
|
||||||
return $this->baseList($crud);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function form(): Form
|
|
||||||
{
|
|
||||||
return $this->baseForm()->body([
|
|
||||||
amisMake()->TextControl()->name('name')->label('名称')->required(true),
|
|
||||||
amisMake()->ImageControl()->name('icon')->label('封面图')->autoUpload(true),
|
|
||||||
amisMake()->TextControl()->name('description')->label('描述'),
|
|
||||||
Components::make()->parentControl(),
|
|
||||||
Components::make()->sortControl(),
|
|
||||||
amisMake()->SwitchControl()->name('is_enable')->label('状态'),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function detail(): Form
|
|
||||||
{
|
|
||||||
return $this->baseDetail()->body([
|
|
||||||
TextControl::make()->static(true)->name('id')->label('ID'),
|
|
||||||
TextControl::make()->static(true)->name('name')->label('名称'),
|
|
||||||
TextControl::make()->static(true)->name('created_at')->label('创建时间'),
|
|
||||||
TextControl::make()->static(true)->name('updated_at')->label('更新时间')
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Admin\Controllers;
|
|
||||||
|
|
||||||
use Slowlyo\OwlAdmin\Renderers\Page;
|
|
||||||
use Slowlyo\OwlAdmin\Renderers\Form;
|
|
||||||
use Slowlyo\OwlAdmin\Renderers\TableColumn;
|
|
||||||
use Slowlyo\OwlAdmin\Renderers\TextControl;
|
|
||||||
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
|
||||||
use App\Services\Admin\RegionService;
|
|
||||||
use App\Admin\Components;
|
|
||||||
|
|
||||||
class RegionController extends AdminController
|
|
||||||
{
|
|
||||||
protected string $serviceName = RegionService::class;
|
|
||||||
|
|
||||||
protected string $pageTitle = '实验田';
|
|
||||||
|
|
||||||
public function list(): Page
|
|
||||||
{
|
|
||||||
$crud = $this->baseCRUD()
|
|
||||||
->filterTogglable(false)
|
|
||||||
->headerToolbar([
|
|
||||||
$this->createButton(true, 'lg'),
|
|
||||||
...$this->baseHeaderToolBar(),
|
|
||||||
])
|
|
||||||
->columns([
|
|
||||||
TableColumn::make()->name('id')->label('ID')->sortable(true),
|
|
||||||
TableColumn::make()->name('name')->label('名称'),
|
|
||||||
TableColumn::make()->name('category_id')->label('分类')->className('text-primary'),
|
|
||||||
TableColumn::make()->name('area')->label('面积'),
|
|
||||||
TableColumn::make()->name('device_count')->label('设备数量'),
|
|
||||||
TableColumn::make()->name('is_enable')->type('switch')->label('显示'),
|
|
||||||
TableColumn::make()->name('created_at')->label('创建时间')->type('datetime')->sortable(true),
|
|
||||||
// TableColumn::make()->name('updated_at')->label('更新时间')->type('datetime')->sortable(true),
|
|
||||||
$this->rowActions(true, 'lg'),
|
|
||||||
]);
|
|
||||||
|
|
||||||
return $this->baseList($crud);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function form(): Form
|
|
||||||
{
|
|
||||||
return $this->baseForm()->body([
|
|
||||||
TextControl::make()->name('name')->label('名称')->required(true),
|
|
||||||
Components::make()->parentControl('', 'category_id', '分类'),
|
|
||||||
Components::make()->fuEditorControl('description', '介绍'),
|
|
||||||
Components::make()->decimalControl('area', '面积m²'),
|
|
||||||
Components::make()->sortControl(),
|
|
||||||
\amisMake()->SwitchControl()->name('is_enable')->label('显示'),
|
|
||||||
\amisMake()->TransferControl()->name('devices')->label('关联设备')
|
|
||||||
->selectMode('chained')->searchable(true)->options(),
|
|
||||||
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function detail(): Form
|
|
||||||
{
|
|
||||||
return $this->baseDetail()->body([
|
|
||||||
TextControl::make()->static(true)->name('id')->label('ID'),
|
|
||||||
TextControl::make()->static(true)->name('name')->label('名称'),
|
|
||||||
TextControl::make()->static(true)->name('created_at')->label('创建时间'),
|
|
||||||
TextControl::make()->static(true)->name('updated_at')->label('更新时间')
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -14,7 +14,7 @@ Route::group([
|
||||||
$router->get('keywords/tree-list', '\App\Admin\Controllers\KeywordController@getTreeList')->name('api.keywords.tree-list');
|
$router->get('keywords/tree-list', '\App\Admin\Controllers\KeywordController@getTreeList')->name('api.keywords.tree-list');
|
||||||
});
|
});
|
||||||
|
|
||||||
$router->get('dashboard', '\App\Admin\Controllers\HomeController@index');
|
$router->resource('dashboard', \App\Admin\Controllers\HomeController::class);
|
||||||
|
|
||||||
//公告管理
|
//公告管理
|
||||||
$router->resource('admin-notices', \App\Admin\Controllers\AdminNoticeController::class);
|
$router->resource('admin-notices', \App\Admin\Controllers\AdminNoticeController::class);
|
||||||
|
|
@ -33,15 +33,5 @@ Route::group([
|
||||||
//设备管理
|
//设备管理
|
||||||
$router->resource('devices', \App\Admin\Controllers\DeviceController::class);
|
$router->resource('devices', \App\Admin\Controllers\DeviceController::class);
|
||||||
|
|
||||||
//区域分类
|
|
||||||
$router->resource('region-categories', \App\Admin\Controllers\RegionCategoryController::class);
|
|
||||||
//区域列表
|
|
||||||
$router->resource('regions', \App\Admin\Controllers\RegionController::class);
|
|
||||||
|
|
||||||
//特殊菜单
|
|
||||||
$router->get('custom-region/{type}', '\App\Admin\Controllers\CustomRegionController@regionIndex');
|
|
||||||
$router->post('custom-region-detail', '\App\Admin\Controllers\CustomRegionController@regionDetail');
|
|
||||||
$router->post('custom-region-monitor', '\App\Admin\Controllers\DeviceController@monitorList');
|
|
||||||
|
|
||||||
$router->resource('system/settings', \App\Admin\Controllers\SettingController::class);
|
$router->resource('system/settings', \App\Admin\Controllers\SettingController::class);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class PlantHarvestLog extends Model
|
|
||||||
{
|
|
||||||
use HasFactory;
|
|
||||||
}
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class Region extends Model
|
|
||||||
{
|
|
||||||
use HasFactory;
|
|
||||||
}
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
use EloquentFilter\Filterable;
|
|
||||||
|
|
||||||
class RegionCategory extends Model
|
|
||||||
{
|
|
||||||
use HasFactory;
|
|
||||||
use Filterable;
|
|
||||||
|
|
||||||
protected $fillable = ['name', 'icon', 'description', 'parent_id', 'level', 'sort', 'path', 'is_enable'];
|
|
||||||
|
|
||||||
|
|
||||||
protected static function boot()
|
|
||||||
{
|
|
||||||
parent::boot();
|
|
||||||
// 监听 Category 的创建事件,用于初始化 path 和 level 字段值
|
|
||||||
static::creating(function ($category) {
|
|
||||||
// 如果创建的是一个根类目
|
|
||||||
if (! $category->parent_id) {
|
|
||||||
// 将层级设为 1
|
|
||||||
$category->level = 1;
|
|
||||||
// 将 path 设为 -
|
|
||||||
$category->path = '-';
|
|
||||||
} else {
|
|
||||||
// 将层级设为父类目的层级 + 1
|
|
||||||
$category->level = $category->parent->level + 1;
|
|
||||||
// 将 path 值设为父类目的 path 追加父类目 ID 以及最后跟上一个 - 分隔符
|
|
||||||
$category->path = $category->parent->path.$category->parent_id.'-';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public function parent()
|
|
||||||
{
|
|
||||||
return $this->belongsTo(self::class, 'parent_id');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class RegionDevice extends Model
|
|
||||||
{
|
|
||||||
use HasFactory;
|
|
||||||
}
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class RegionPlantLog extends Model
|
|
||||||
{
|
|
||||||
use HasFactory;
|
|
||||||
}
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Services\Admin;
|
|
||||||
|
|
||||||
use App\Models\RegionCategory;
|
|
||||||
use Slowlyo\OwlAdmin\Services\AdminService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @method RegionCategory getModel()
|
|
||||||
* @method RegionCategory|\Illuminate\Database\Query\Builder query()
|
|
||||||
*/
|
|
||||||
class RegionCategoryService extends AdminService
|
|
||||||
{
|
|
||||||
protected string $modelName = RegionCategory::class;
|
|
||||||
}
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Services\Admin;
|
|
||||||
|
|
||||||
use App\Models\Region;
|
|
||||||
use Slowlyo\OwlAdmin\Services\AdminService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @method Region getModel()
|
|
||||||
* @method Region|\Illuminate\Database\Query\Builder query()
|
|
||||||
*/
|
|
||||||
class RegionService extends AdminService
|
|
||||||
{
|
|
||||||
protected string $modelName = Region::class;
|
|
||||||
}
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
return new class extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Schema::create('region_categories', function (Blueprint $table) {
|
|
||||||
$table->id();
|
|
||||||
$table->string('name')->comment('分类名称');
|
|
||||||
$table->string('icon')->nullable()->comment('封面图');
|
|
||||||
$table->string('description')->nullable()->comment('描述');
|
|
||||||
$table->unsignedBigInteger('parent_id')->default(0)->comment('父级ID');
|
|
||||||
$table->unsignedInteger('level')->default(1)->comment('层级');
|
|
||||||
$table->unsignedInteger('sort')->default(0)->comment('排序');
|
|
||||||
$table->unsignedTinyInteger('is_enable')->default(1)->comment('状态');
|
|
||||||
$table->string('path')->default('-')->comment('所有的父级ID');
|
|
||||||
$table->timestamps();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::dropIfExists('region_categories');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
return new class extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Schema::create('regions', function (Blueprint $table) {
|
|
||||||
$table->id();
|
|
||||||
$table->string('name');
|
|
||||||
$table->string('cover')->nullable()->comment('封面图');
|
|
||||||
$table->string('director')->nullable()->comment('负责人');
|
|
||||||
$table->decimal('area')->default(0.00)->comment('面积');
|
|
||||||
$table->text('description')->nullable()->comment('描述');
|
|
||||||
$table->unsignedBigInteger('category_id')->nullable()->comment('分类');
|
|
||||||
$table->unsignedTinyInteger('is_recommend')->default(0)->comment('推荐开关');
|
|
||||||
$table->unsignedTinyInteger('is_enable')->default(1)->comment('显示开关');
|
|
||||||
$table->unsignedInteger('sort')->default(0)->comment('排序');
|
|
||||||
$table->unsignedTinyInteger('status')->default(0)->comment('0未使用,1种植中,2维护中,3已废弃');
|
|
||||||
$table->timestamps();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::dropIfExists('regions');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
return new class extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Schema::create('region_devices', function (Blueprint $table) {
|
|
||||||
$table->id();
|
|
||||||
$table->unsignedBigInteger('region_id');
|
|
||||||
$table->unsignedBigInteger('device_id');
|
|
||||||
$table->unsignedTinyInteger('device_type')->comment('类型: 1 监控设备, 2 土壤设备, 3 水质设备, 4 气象设备');
|
|
||||||
$table->text('config')->nullable()->comment('配置信息');
|
|
||||||
$table->timestamps();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::dropIfExists('region_devices');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
return new class extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Schema::create('region_plant_logs', function (Blueprint $table) {
|
|
||||||
$table->id();
|
|
||||||
$table->unsignedBigInteger('region_id');
|
|
||||||
$table->string('plant_name')->comment('种植名称');
|
|
||||||
$table->string('director')->nullable()->comment('负责人');
|
|
||||||
$table->text('description')->nullable()->comment('描述');
|
|
||||||
$table->timestamp('start_at')->nullable()->comment('种植开始时间');
|
|
||||||
$table->unsignedTinyInteger('status')->default(0)->comment('0未开始,1种植中,2已结束');
|
|
||||||
$table->timestamps();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::dropIfExists('region_plant_logs');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
return new class extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Schema::create('plant_harvest_logs', function (Blueprint $table) {
|
|
||||||
$table->id();
|
|
||||||
$table->unsignedBigInteger('plant_id');
|
|
||||||
$table->string('director')->nullable()->comment('负责人');
|
|
||||||
$table->decimal('area')->default(0.00)->comment('面积/平米');
|
|
||||||
$table->decimal('output')->default(0.00)->comment('产量/千克');
|
|
||||||
$table->timestamp('harvest_at')->nullable()->comment('收获时间');
|
|
||||||
$table->timestamps();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::dropIfExists('plant_harvest_logs');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -32,20 +32,20 @@ class AdminMenuSeeder extends Seeder
|
||||||
|
|
||||||
['title' => '区域管理', 'icon' => 'icon-park:category-management', 'url' => '',
|
['title' => '区域管理', 'icon' => 'icon-park:category-management', 'url' => '',
|
||||||
'children' => [
|
'children' => [
|
||||||
['title' => '区域分类', 'icon' => 'icon-park:graphic-stitching-four', 'url' => '/region-categories'],
|
['title' => '分类管理', 'icon' => 'icon-park:graphic-stitching-four', 'url' => '/region-categories'],
|
||||||
['title' => '实验田', 'icon' => 'icon-park:freezing-line-column', 'url' => '/regions'],
|
['title' => '实验田', 'icon' => 'icon-park:freezing-line-column', 'url' => '/regions'],
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
['title' => '育秧中心', 'icon' => 'icon-park:lotus', 'url' => '',
|
['title' => '育秧中心', 'icon' => 'icon-park:lotus', 'url' => '',
|
||||||
'children' => [
|
'children' => [
|
||||||
['title' => '大棚控制', 'icon' => 'icon-park:link-one', 'url' => 'https://www.baidu.com', 'url_type'=>2],
|
['title' => '大棚控制', 'icon' => 'icon-park:link-one', 'url' => 'https://www.baidu.com', 'url_type'=>2],
|
||||||
['title' => '育秧列表', 'icon' => 'icon-park:more-app', 'url' => '/custom-region/yuyang'],
|
['title' => '育秧列表', 'icon' => 'icon-park:more-app', 'url' => '/yuyang1'],
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
['title' => '实验稻田', 'icon' => 'icon-park:four-leaves', 'url' => '',
|
['title' => '实验稻田', 'icon' => 'icon-park:four-leaves', 'url' => '',
|
||||||
'children' => [
|
'children' => [
|
||||||
['title' => '农机控制', 'icon' => 'icon-park:link-one', 'url' => 'https://www.baidu.com', 'url_type'=>2],
|
['title' => '农机控制', 'icon' => 'icon-park:link-one', 'url' => 'https://www.baidu.com', 'url_type'=>2],
|
||||||
['title' => '稻田列表', 'icon' => 'icon-park:more-app', 'url' => '/custom-region/daotian'],
|
['title' => '稻田列表', 'icon' => 'icon-park:more-app', 'url' => '/daotian2'],
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue