Compare commits
No commits in common. "96c4744bd7be4e4293442690bdde8f304734a33e" and "f0312e34f09469216b3f9089d72cbe565b141613" have entirely different histories.
96c4744bd7
...
f0312e34f0
|
|
@ -86,10 +86,6 @@ class Components extends BaseRenderer {
|
||||||
->options(Keyword::getByParentKey($typeKey)->pluck('name', 'id')->toArray());
|
->options(Keyword::getByParentKey($typeKey)->pluck('name', 'id')->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function keywordsTag($label = '标签'){
|
|
||||||
return amisMake()->Tag()->label($label)->displayMode('rounded')->color('inactive');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成统计图config
|
* 生成统计图config
|
||||||
* 折线图或者柱状图
|
* 折线图或者柱状图
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,12 @@
|
||||||
|
|
||||||
namespace App\Admin\Controllers;
|
namespace App\Admin\Controllers;
|
||||||
|
|
||||||
use Slowlyo\OwlAdmin\Renderers\{Button, Form, Page, TableColumn, TextControl, Json, Component, CRUDTable, Card, Video, DateRangeControl, Mapping};
|
use Slowlyo\OwlAdmin\Renderers\{Button, Form, Page, TableColumn, TextControl, Component, CRUDTable, Card, Video, DateRangeControl};
|
||||||
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;
|
||||||
use App\Models\Keyword;
|
use App\Models\Keyword;
|
||||||
|
use App\Admin\Components;
|
||||||
|
|
||||||
class DeviceController extends AdminController
|
class DeviceController extends AdminController
|
||||||
{
|
{
|
||||||
|
|
@ -71,12 +72,6 @@ class DeviceController extends AdminController
|
||||||
TextControl::make()->static(true)->name('id')->label('ID'),
|
TextControl::make()->static(true)->name('id')->label('ID'),
|
||||||
TextControl::make()->static(true)->name('name')->label('名称'),
|
TextControl::make()->static(true)->name('name')->label('名称'),
|
||||||
TextControl::make()->static(true)->name('sn')->label('编号'),
|
TextControl::make()->static(true)->name('sn')->label('编号'),
|
||||||
TextControl::make()->static(true)->name('factory.name')->label('厂家'),
|
|
||||||
TextControl::make()->static(true)->name('model_sn')->label('型号'),
|
|
||||||
TextControl::make()->static(true)->name('type')->label('类型')->staticSchema(
|
|
||||||
Mapping::make()->map(Device::typeMap())),
|
|
||||||
TextControl::make()->static(true)->name('extends')->label('扩展信息')->staticSchema(
|
|
||||||
Json::make()),
|
|
||||||
TextControl::make()->static(true)->name('created_at')->label('创建时间'),
|
TextControl::make()->static(true)->name('created_at')->label('创建时间'),
|
||||||
TextControl::make()->static(true)->name('updated_at')->label('更新时间')
|
TextControl::make()->static(true)->name('updated_at')->label('更新时间')
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ use App\Services\Admin\MonitorModeService;
|
||||||
use App\Admin\Components;
|
use App\Admin\Components;
|
||||||
use App\Models\MonitorMode;
|
use App\Models\MonitorMode;
|
||||||
use App\Models\Device;
|
use App\Models\Device;
|
||||||
use App\Models\Keyword;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property MonitorModeService $service
|
* @property MonitorModeService $service
|
||||||
|
|
@ -31,7 +30,7 @@ class MonitorModeController extends AdminController
|
||||||
->filter($this->baseFilter()->actions([])->body([
|
->filter($this->baseFilter()->actions([])->body([
|
||||||
TextControl::make()->name('name')->label('名称')->size('md'),
|
TextControl::make()->name('name')->label('名称')->size('md'),
|
||||||
amisMake()->SelectControl()->name('type')->label('类型')->options(MonitorMode::typeMap())->size('md'),
|
amisMake()->SelectControl()->name('type')->label('类型')->options(MonitorMode::typeMap())->size('md'),
|
||||||
Components::make()->keywordsTagControl('group_tags', '分组', 'monitor-mode-group')->size('md'),
|
Components::make()->keywordsTagControl('group_tags', '分组', 'device-group')->size('md'),
|
||||||
amis('button')->label(__('admin.reset'))->actionType('clear-and-submit'),
|
amis('button')->label(__('admin.reset'))->actionType('clear-and-submit'),
|
||||||
amis('submit')->label(__('admin.search'))->level('primary'),
|
amis('submit')->label(__('admin.search'))->level('primary'),
|
||||||
]))
|
]))
|
||||||
|
|
@ -39,11 +38,9 @@ class MonitorModeController extends AdminController
|
||||||
TableColumn::make()->name('id')->label('ID')->sortable(true),
|
TableColumn::make()->name('id')->label('ID')->sortable(true),
|
||||||
TableColumn::make()->name('name')->label('名称'),
|
TableColumn::make()->name('name')->label('名称'),
|
||||||
TableColumn::make()->name('type')->type('mapping')->map(MonitorMode::typeMap())->label('类型'),
|
TableColumn::make()->name('type')->type('mapping')->map(MonitorMode::typeMap())->label('类型'),
|
||||||
TableColumn::make()->name('tags')->type('mapping')->map(Keyword::tagsMap('monitor-mode-group'))->label('分组'),
|
|
||||||
TableColumn::make()->name('created_at')->label(__('admin.created_at'))->type('datetime')->sortable(true),
|
TableColumn::make()->name('created_at')->label(__('admin.created_at'))->type('datetime')->sortable(true),
|
||||||
amisMake()->Operation()->label(__('admin.actions'))->buttons([
|
amisMake()->Operation()->label(__('admin.actions'))->buttons([
|
||||||
$this->setAboutDevice(),
|
$this->setAboutDevice(),
|
||||||
$this->rowEditButton(true, 'lg'),
|
|
||||||
$this->rowDeleteButton()
|
$this->rowDeleteButton()
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
|
|
@ -55,8 +52,8 @@ class MonitorModeController extends AdminController
|
||||||
{
|
{
|
||||||
return $this->baseForm()->body([
|
return $this->baseForm()->body([
|
||||||
TextControl::make()->name('name')->label('名称'),
|
TextControl::make()->name('name')->label('名称'),
|
||||||
\amisMake()->RadiosControl()->name('type')->label('类型')->options(MonitorMode::typeMap())->required(true)->disabledOn('data.id > 0'),
|
\amisMake()->RadiosControl()->name('type')->label('类型')->options(MonitorMode::typeMap())->required(true),
|
||||||
Components::make()->keywordsTagControl('group_tags', '分组', 'monitor-mode-group'),
|
Components::make()->keywordsTagControl('group_tags', '分组', 'device-group'),
|
||||||
Components::make()->sortControl('sort', __('admin.order')),
|
Components::make()->sortControl('sort', __('admin.order')),
|
||||||
TextControl::make()->name('is_enable')->type('switch')->default(1)->label('显示'),
|
TextControl::make()->name('is_enable')->type('switch')->default(1)->label('显示'),
|
||||||
TextControl::make()->name('is_recommend')->type('switch')->default(0)->label('推荐'),
|
TextControl::make()->name('is_recommend')->type('switch')->default(0)->label('推荐'),
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ class Device extends Model
|
||||||
public const TYPE_METEOROLOGICAL = 4; //气象设备
|
public const TYPE_METEOROLOGICAL = 4; //气象设备
|
||||||
public const TYPE_AIR = 5; //通风设备
|
public const TYPE_AIR = 5; //通风设备
|
||||||
public const TYPE_ATOMIZING = 6; //喷雾设备
|
public const TYPE_ATOMIZING = 6; //喷雾设备
|
||||||
public const TYPE_INSECT = 7; //虫情监测
|
|
||||||
|
|
||||||
public const STATE_DISABLED = 0;
|
public const STATE_DISABLED = 0;
|
||||||
public const STATE_ONLINE = 1;
|
public const STATE_ONLINE = 1;
|
||||||
|
|
@ -50,8 +49,7 @@ class Device extends Model
|
||||||
// self::TYPE_WATER_QUALITY => '水质设备',
|
// self::TYPE_WATER_QUALITY => '水质设备',
|
||||||
self::TYPE_METEOROLOGICAL => '气象设备',
|
self::TYPE_METEOROLOGICAL => '气象设备',
|
||||||
self::TYPE_AIR => '通风设备',
|
self::TYPE_AIR => '通风设备',
|
||||||
self::TYPE_ATOMIZING => '喷雾设备',
|
self::TYPE_ATOMIZING => '喷雾设备'
|
||||||
self::TYPE_INSECT => '虫情监测',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use EloquentFilter\Filterable;
|
use EloquentFilter\Filterable;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use App\Admin\Components;
|
|
||||||
|
|
||||||
class Keyword extends Model
|
class Keyword extends Model
|
||||||
{
|
{
|
||||||
|
|
@ -55,10 +54,4 @@ class Keyword extends Model
|
||||||
return self::query()->where('type_key', $key)->get();
|
return self::query()->where('type_key', $key)->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function tagsMap(String $key){
|
|
||||||
$list = self::query()->where('type_key', $key)->get()->pluck('name', 'id')->toArray();
|
|
||||||
return array_map(function($item){
|
|
||||||
return Components::make()->keywordsTag($item);
|
|
||||||
}, $list);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ namespace App\Models;
|
||||||
|
|
||||||
use EloquentFilter\Filterable;
|
use EloquentFilter\Filterable;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
||||||
|
|
||||||
class MonitorMode extends Model
|
class MonitorMode extends Model
|
||||||
{
|
{
|
||||||
|
|
@ -16,15 +15,12 @@ class MonitorMode extends Model
|
||||||
'group_tags'
|
'group_tags'
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $appends = ['tags'];
|
|
||||||
|
|
||||||
public const TYPE_MONITOR = 1; //视频监控
|
public const TYPE_MONITOR = 1; //视频监控
|
||||||
public const TYPE_SOIL = 2; //土壤监测
|
public const TYPE_SOIL = 2; //土壤监测
|
||||||
public const TYPE_WATER_QUALITY = 3; //水质监测
|
public const TYPE_WATER_QUALITY = 3; //水质监测
|
||||||
public const TYPE_METEOROLOGICAL = 4; //气象监测
|
public const TYPE_METEOROLOGICAL = 4; //气象监测
|
||||||
public const TYPE_AIR = 5; //通风控制
|
public const TYPE_AIR = 5; //通风控制
|
||||||
public const TYPE_ATOMIZING = 6; //喷雾控制
|
public const TYPE_ATOMIZING = 6; //喷雾控制
|
||||||
public const TYPE_INSECT = 7; //虫情监测
|
|
||||||
|
|
||||||
public static function typeMap()
|
public static function typeMap()
|
||||||
{
|
{
|
||||||
|
|
@ -34,8 +30,7 @@ class MonitorMode extends Model
|
||||||
// self::TYPE_WATER_QUALITY => '水质监测',
|
// self::TYPE_WATER_QUALITY => '水质监测',
|
||||||
self::TYPE_METEOROLOGICAL => '气象监测',
|
self::TYPE_METEOROLOGICAL => '气象监测',
|
||||||
self::TYPE_AIR => '通风控制',
|
self::TYPE_AIR => '通风控制',
|
||||||
self::TYPE_ATOMIZING => '喷雾控制',
|
self::TYPE_ATOMIZING => '喷雾控制'
|
||||||
self::TYPE_INSECT => '虫情监测',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,11 +73,4 @@ class MonitorMode extends Model
|
||||||
protected function serializeDate(\DateTimeInterface $date){
|
protected function serializeDate(\DateTimeInterface $date){
|
||||||
return $date->format('Y-m-d H:i:s');
|
return $date->format('Y-m-d H:i:s');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tags():Attribute
|
|
||||||
{
|
|
||||||
return Attribute::make(
|
|
||||||
get: fn($value) => $this->group_tags ? explode(',', $this->group_tags) : [],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ class KeywordSeeder extends Seeder
|
||||||
['key' => 'device-factory', 'name' => '厂家', 'list' => [
|
['key' => 'device-factory', 'name' => '厂家', 'list' => [
|
||||||
['name' => 'LINK-OS', 'key'=>'link-os']
|
['name' => 'LINK-OS', 'key'=>'link-os']
|
||||||
]],
|
]],
|
||||||
['key' => 'monitor-mode-group', 'name' => '监测组', 'list' => [
|
['key' => 'device-group', 'name' => '设备组', 'list' => [
|
||||||
['name' => '农机', 'key'=>'machinery']
|
['name' => '农机', 'key'=>'machinery']
|
||||||
]],
|
]],
|
||||||
];
|
];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue