refactor: 修复知识库和操作指引
This commit is contained in:
@@ -68,11 +68,21 @@ class TerminalResource extends Resource
|
||||
->placeholder('例如: 192.168.1.100')
|
||||
->helperText('终端的IP地址'),
|
||||
|
||||
Forms\Components\TextInput::make('mac_address')
|
||||
->label('MAC地址')
|
||||
->maxLength(17)
|
||||
->placeholder('AA:BB:CC:DD:EE:FF')
|
||||
->helperText('终端的MAC地址,用于自动识别终端')
|
||||
->regex('/^([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$/')
|
||||
->validationMessages([
|
||||
'regex' => 'MAC地址格式不正确,应为 AA:BB:CC:DD:EE:FF',
|
||||
]),
|
||||
|
||||
Forms\Components\TextInput::make('station_id')
|
||||
->label('线站ID')
|
||||
->numeric()
|
||||
->placeholder('请输入线站ID')
|
||||
->helperText('关联的生产线站ID'),
|
||||
->maxLength(50)
|
||||
->placeholder('例如: BL02U1')
|
||||
->helperText('关联的光束线/线站标识'),
|
||||
])
|
||||
->columns(2),
|
||||
|
||||
@@ -86,6 +96,24 @@ class TerminalResource extends Resource
|
||||
->helperText('组态图的访问地址'),
|
||||
]),
|
||||
|
||||
Forms\Components\Section::make('SCADA网关配置')
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('scada_data_url')
|
||||
->label('SCADA数据查询URL')
|
||||
->url()
|
||||
->maxLength(500)
|
||||
->placeholder('http://gateway:8080/api/data')
|
||||
->helperText('OPC UA HTTP网关的数据查询地址'),
|
||||
|
||||
Forms\Components\TextInput::make('scada_tags_url')
|
||||
->label('SCADA点位定义URL')
|
||||
->url()
|
||||
->maxLength(500)
|
||||
->placeholder('http://gateway:8080/api/tags')
|
||||
->helperText('OPC UA HTTP网关的点位定义查询地址'),
|
||||
])
|
||||
->columns(2),
|
||||
|
||||
Forms\Components\Section::make('显示配置')
|
||||
->schema([
|
||||
Forms\Components\KeyValue::make('display_config')
|
||||
@@ -130,7 +158,7 @@ class TerminalResource extends Resource
|
||||
->reorderableWithButtons()
|
||||
->addActionLabel('添加知识库')
|
||||
->reorderableWithDragAndDrop(false)
|
||||
->itemLabel(fn (array $state): ?string =>
|
||||
->itemLabel(fn (array $state): ?string =>
|
||||
\App\Models\KnowledgeBase::find($state['id'])?->name ?? '未选择'
|
||||
)
|
||||
->collapsed()
|
||||
@@ -139,6 +167,43 @@ class TerminalResource extends Resource
|
||||
])
|
||||
->description('配置终端可以访问的知识库及其优先级'),
|
||||
|
||||
Forms\Components\Section::make('指引关联')
|
||||
->schema([
|
||||
Forms\Components\Repeater::make('guideAssociations')
|
||||
->label('关联指引')
|
||||
->relationship('guides')
|
||||
->schema([
|
||||
Forms\Components\Select::make('id')
|
||||
->label('指引')
|
||||
->options(\App\Models\Guide::where('status', 'published')->pluck('name', 'id'))
|
||||
->required()
|
||||
->searchable()
|
||||
->distinct()
|
||||
->disableOptionsWhenSelectedInSiblingRepeaterItems()
|
||||
->helperText('选择要关联的指引'),
|
||||
|
||||
Forms\Components\TextInput::make('priority')
|
||||
->label('优先级')
|
||||
->numeric()
|
||||
->default(0)
|
||||
->required()
|
||||
->minValue(0)
|
||||
->helperText('数字越小优先级越高,0为最高优先级'),
|
||||
])
|
||||
->columns(2)
|
||||
->reorderable()
|
||||
->reorderableWithButtons()
|
||||
->addActionLabel('添加指引')
|
||||
->reorderableWithDragAndDrop(false)
|
||||
->itemLabel(fn (array $state): ?string =>
|
||||
\App\Models\Guide::find($state['id'])?->name ?? '未选择'
|
||||
)
|
||||
->collapsed()
|
||||
->collapsible()
|
||||
->helperText('可以关联多个指引,并设置优先级。拖动或使用按钮调整顺序。'),
|
||||
])
|
||||
->description('配置终端可以访问的操作指引及其优先级'),
|
||||
|
||||
Forms\Components\Section::make('AI提示词配置')
|
||||
->schema([
|
||||
Forms\Components\Grid::make(3)
|
||||
@@ -204,6 +269,13 @@ class TerminalResource extends Resource
|
||||
->copyable()
|
||||
->tooltip('点击复制'),
|
||||
|
||||
Tables\Columns\TextColumn::make('mac_address')
|
||||
->label('MAC地址')
|
||||
->searchable()
|
||||
->copyable()
|
||||
->placeholder('未设置')
|
||||
->toggleable(),
|
||||
|
||||
Tables\Columns\TextColumn::make('ip_address')
|
||||
->label('IP地址')
|
||||
->searchable()
|
||||
|
||||
Reference in New Issue
Block a user