Xu ly giao dien San Pham
This commit is contained in:
@@ -7,17 +7,14 @@ use App\Models\Contract;
|
||||
use App\Models\Product;
|
||||
use App\Models\PaymentTemplate;
|
||||
use App\Enums\NavigationGroup;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use App\Filament\Resources\Contracts\ContractResource\RelationManagers\ScheduleItemsRelationManager;
|
||||
|
||||
use App\Filament\Resources\Contracts\Schemas\ContractForm;
|
||||
|
||||
class ContractResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Contract::class;
|
||||
@@ -30,24 +27,7 @@ class ContractResource extends Resource
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make('Liên kết & Mẫu thanh toán')
|
||||
->columns(2)
|
||||
->schema([
|
||||
Select::make('product_id')->label('Sản phẩm')->relationship('product', 'code')->required()->live(),
|
||||
Select::make('payment_template_id')->label('Mẫu thanh toán')
|
||||
->options(fn (Get $get) => PaymentTemplate::pluck('name', 'id'))
|
||||
->required()->dehydrated(false),
|
||||
Select::make('customers')->label('Khách hàng')->relationship('customers', 'full_name')->multiple()->required()->columnSpanFull(),
|
||||
]),
|
||||
Section::make('Chi tiết Hợp đồng')
|
||||
->columns(2)
|
||||
->schema([
|
||||
TextInput::make('contract_number')->label('Số HĐ')->required(),
|
||||
DatePicker::make('signing_date')->label('Ngày ký')->required(),
|
||||
])
|
||||
]);
|
||||
return ContractForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
|
||||
@@ -2,7 +2,15 @@
|
||||
|
||||
namespace App\Filament\Resources\Contracts\Schemas;
|
||||
|
||||
use App\Models\Product;
|
||||
use App\Models\PaymentTemplate;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
|
||||
class ContractForm
|
||||
{
|
||||
@@ -10,7 +18,63 @@ class ContractForm
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
Section::make('Liên kết & Mẫu thanh toán')
|
||||
->columns(2)
|
||||
->schema([
|
||||
Select::make('product_id')
|
||||
->label('Sản phẩm')
|
||||
->relationship('product', 'code')
|
||||
->required()
|
||||
->live()
|
||||
->afterStateUpdated(function (Set $set, $state) {
|
||||
if ($state) {
|
||||
$product = Product::find($state);
|
||||
if ($product) {
|
||||
$set('total_value', $product->total_price);
|
||||
}
|
||||
}
|
||||
}),
|
||||
Select::make('payment_template_id')
|
||||
->label('Mẫu thanh toán')
|
||||
->options(fn () => PaymentTemplate::pluck('name', 'id'))
|
||||
->required()
|
||||
->dehydrated(false),
|
||||
Select::make('customers')
|
||||
->label('Khách hàng')
|
||||
->relationship('customers', 'full_name')
|
||||
->multiple()
|
||||
->required()
|
||||
->columnSpanFull(),
|
||||
]),
|
||||
Section::make('Chi tiết Hợp đồng')
|
||||
->columns(2)
|
||||
->schema([
|
||||
TextInput::make('contract_number')->label('Số HĐ')->required(),
|
||||
Select::make('contract_type')
|
||||
->label('Loại HĐ')
|
||||
->options([
|
||||
'HĐMB' => 'HĐMB',
|
||||
'HĐGV' => 'HĐGV',
|
||||
'HĐDC' => 'HĐDC',
|
||||
])
|
||||
->default('HĐMB')
|
||||
->required(),
|
||||
DatePicker::make('signing_date')->label('Ngày ký')->required(),
|
||||
TextInput::make('total_value')
|
||||
->label('Giá trị HĐ')
|
||||
->numeric()
|
||||
->required()
|
||||
->prefix('VND'),
|
||||
Select::make('status')
|
||||
->label('Trạng thái')
|
||||
->options([
|
||||
'Đang hiệu lực' => 'Đang hiệu lực',
|
||||
'Đã hoàn thành' => 'Đã hoàn thành',
|
||||
'Đã hủy' => 'Đã hủy',
|
||||
])
|
||||
->default('Đang hiệu lực')
|
||||
->required(),
|
||||
])
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user