调整标签
parent
f0312e34f0
commit
7ffb4048b2
|
|
@ -86,6 +86,10 @@ 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
|
||||||
* 折线图或者柱状图
|
* 折线图或者柱状图
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ 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
|
||||||
|
|
@ -30,7 +31,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', '分组', 'device-group')->size('md'),
|
Components::make()->keywordsTagControl('group_tags', '分组', 'monitor-mode-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'),
|
||||||
]))
|
]))
|
||||||
|
|
@ -38,9 +39,11 @@ 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()
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
|
|
@ -52,8 +55,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),
|
\amisMake()->RadiosControl()->name('type')->label('类型')->options(MonitorMode::typeMap())->required(true)->disabledOn('data.id > 0'),
|
||||||
Components::make()->keywordsTagControl('group_tags', '分组', 'device-group'),
|
Components::make()->keywordsTagControl('group_tags', '分组', 'monitor-mode-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,6 +17,7 @@ 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;
|
||||||
|
|
@ -49,7 +50,8 @@ 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,6 +6,7 @@ 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
|
||||||
{
|
{
|
||||||
|
|
@ -54,4 +55,10 @@ 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,6 +4,7 @@ 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
|
||||||
{
|
{
|
||||||
|
|
@ -15,12 +16,15 @@ 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()
|
||||||
{
|
{
|
||||||
|
|
@ -30,7 +34,8 @@ 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 => '虫情监测',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -73,4 +78,11 @@ 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' => 'device-group', 'name' => '设备组', 'list' => [
|
['key' => 'monitor-mode-group', 'name' => '监测组', 'list' => [
|
||||||
['name' => '农机', 'key'=>'machinery']
|
['name' => '农机', 'key'=>'machinery']
|
||||||
]],
|
]],
|
||||||
];
|
];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue