Xu ly giao dien San Pham
This commit is contained in:
@@ -2,6 +2,12 @@
|
||||
|
||||
namespace App\Filament\Resources\Products\Schemas;
|
||||
|
||||
use App\Enums\ProductType;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Forms\Components\KeyValue;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class ProductForm
|
||||
@@ -10,7 +16,76 @@ class ProductForm
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
Tabs::make('ProductDetails')
|
||||
->tabs([
|
||||
Tabs\Tab::make('Thông tin chung')
|
||||
->icon('heroicon-o-information-circle')
|
||||
->columns(2)
|
||||
->schema([
|
||||
Select::make('project_id')->label('Dự án')->relationship('project', 'name')->required(),
|
||||
Select::make('product_type')->label('Loại sản phẩm')->options(ProductType::class)->required(),
|
||||
TextInput::make('code')->label('Mã SP')->required(),
|
||||
Select::make('status')
|
||||
->label('Trạng thái')
|
||||
->options([
|
||||
'Đang mở bán' => 'Đang mở bán',
|
||||
'Đã cọc' => 'Đã cọc',
|
||||
'Đã bán' => 'Đã bán'
|
||||
])->required(),
|
||||
]),
|
||||
Tabs\Tab::make('Tài chính')
|
||||
->icon('heroicon-o-currency-dollar')
|
||||
->columns(2)
|
||||
->schema([
|
||||
TextInput::make('area')->label('Diện tích (m2)')->numeric()->required(),
|
||||
TextInput::make('price_per_unit')->label('Đơn giá')->numeric()->required()->prefix('VND'),
|
||||
TextInput::make('total_price')->label('Tổng giá')->numeric()->required()->prefix('VND'),
|
||||
Section::make('Bổ sung')
|
||||
->columns(2)
|
||||
->schema([
|
||||
TextInput::make('qsdd_value')->label('Giá trị QSDĐ')->numeric()->prefix('VND'),
|
||||
TextInput::make('foundation_temp_value')->label('Giá trị móng (tạm tính)')->numeric()->prefix('VND'),
|
||||
])
|
||||
]),
|
||||
Tabs\Tab::make('Kỹ thuật & Hạ tầng')
|
||||
->icon('heroicon-o-cog')
|
||||
->columns(2)
|
||||
->schema([
|
||||
TextInput::make('adjacent_road')->label('Đường tiếp giáp'),
|
||||
TextInput::make('frontage_count')->label('Số mặt tiền')->numeric(),
|
||||
TextInput::make('max_floors')->label('Số tầng tối đa')->numeric(),
|
||||
TextInput::make('construction_status')->label('Trạng thái XD'),
|
||||
KeyValue::make('infrastructure_status')
|
||||
->label('Trạng thái hạ tầng')
|
||||
->columnSpanFull(),
|
||||
]),
|
||||
Tabs\Tab::make('Tiến độ thanh toán')
|
||||
->icon('heroicon-o-calendar-days')
|
||||
->schema([
|
||||
\Filament\Forms\Components\Repeater::make('payment_schedule_preview')
|
||||
->label('Lịch trình dự kiến / Thực tế')
|
||||
->relationship(function ($record) {
|
||||
// Nếu sản phẩm đã có hợp đồng, lấy lịch trình từ hợp đồng đầu tiên
|
||||
if ($record && $record->contracts()->exists()) {
|
||||
return $record->contracts()->first()->scheduleItems();
|
||||
}
|
||||
// Nếu chưa có, chúng ta sẽ hiển thị mẫu từ Project (phần này cần logic state giả lập hoặc view)
|
||||
return null;
|
||||
})
|
||||
->schema([
|
||||
TextInput::make('installment_no')->label('Đợt')->disabled(),
|
||||
TextInput::make('type')->label('Loại')->disabled(),
|
||||
TextInput::make('percentage')->label('%')->disabled(),
|
||||
TextInput::make('amount')->label('Số tiền (VNĐ)')->numeric()->disabled(),
|
||||
DatePicker::make('due_date')->label('Ngày đến hạn')->disabled(),
|
||||
])
|
||||
->columns(5)
|
||||
->addable(false)
|
||||
->deletable(false)
|
||||
->reorderable(false)
|
||||
->placeholder('Sản phẩm chưa có hợp đồng hoặc Dự án chưa gán mẫu thanh toán mặc định.')
|
||||
]),
|
||||
])->columnSpanFull()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user