增加触发价钱的输入框
This commit is contained in:
Executable
+45
@@ -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']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user