增加触发价钱的输入框
This commit is contained in:
parent
b81a8481b3
commit
18c58aa976
|
|
@ -15,6 +15,7 @@
|
|||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use App\Filament\Widgets\TriggerPriceWidget;
|
||||
|
||||
class UsdtC2cResource extends Resource
|
||||
{
|
||||
|
|
@ -22,6 +23,13 @@ class UsdtC2cResource extends Resource
|
|||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
public static function getWidgets(): array
|
||||
{
|
||||
return [
|
||||
TriggerPriceWidget::class,
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationGroup(): ?string
|
||||
{
|
||||
return '财务管理'; // ⚠️ 注意这要与其他项的 group 完全一致
|
||||
|
|
|
|||
|
|
@ -3,17 +3,17 @@
|
|||
namespace App\Filament\Resources\UsdtC2cResource\Pages;
|
||||
|
||||
use App\Filament\Resources\UsdtC2cResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use App\Filament\Widgets\TriggerPriceWidget;
|
||||
|
||||
class ListUsdtC2cs extends ListRecords
|
||||
{
|
||||
protected static string $resource = UsdtC2cResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
protected function getHeaderWidgets(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
TriggerPriceWidget::class,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use Filament\Widgets\Widget;
|
||||
use Filament\Forms;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Filament\Forms\Contracts\HasForms;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
|
||||
class TriggerPriceWidget extends Widget implements HasForms
|
||||
{
|
||||
use InteractsWithForms;
|
||||
|
||||
protected static string $view = 'filament.widgets.trigger-price-widget';
|
||||
protected static string $heading = '触发价格设定';
|
||||
protected static ?int $sort = -1;
|
||||
protected int | string | array $columnSpan = 'full';
|
||||
|
||||
public ?string $price = null;
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->form->fill([
|
||||
'price' => Cache::get('trigger_price', ''),
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getFormSchema(): array
|
||||
{
|
||||
return [
|
||||
Forms\Components\TextInput::make('price')
|
||||
->numeric()
|
||||
->label('触发价格(例如 21800)')
|
||||
->required(),
|
||||
];
|
||||
}
|
||||
|
||||
public function submit(): void
|
||||
{
|
||||
$data = $this->form->getState();
|
||||
Cache::put('trigger_price', $data['price']);
|
||||
$this->dispatch('notify', type: 'success', title: '✅ 触发价格已更新为:' . $data['price']);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
<x-filament-panels::page>
|
||||
|
||||
</x-filament-panels::page>
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
<x-filament-panels::page>
|
||||
|
||||
</x-filament-panels::page>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<x-filament::widget>
|
||||
<x-filament::card>
|
||||
{{ $this->form }}
|
||||
|
||||
<x-filament::button wire:click="submit">
|
||||
保存
|
||||
</x-filament::button>
|
||||
</x-filament::card>
|
||||
</x-filament::widget>
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
*
|
||||
!.gitignore
|
||||
Loading…
Reference in New Issue