Kimi chinh sua

This commit is contained in:
2026-04-24 08:58:53 +00:00
parent 91ff4a5e4d
commit 86216ef872
43 changed files with 2868 additions and 597 deletions

View File

@@ -8,7 +8,10 @@ use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\Tabs;
use Filament\Schemas\Components\Section;
use Filament\Forms\Components\KeyValue;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\Placeholder;
use Filament\Schemas\Schema;
use Illuminate\Support\HtmlString;
class ProductForm
{
@@ -49,29 +52,64 @@ class ProductForm
]),
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(),
Section::make('Thông số kỹ thuật')
->columns(3)
->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 cao')->numeric(),
]),
Section::make('Chi tiết hạ tầng thực tế')
->description('Trình trạng hạ tầng kỹ thuật thực tế tại lô đất')
->schema([
Placeholder::make('infra_overview')
->label('Tổng quan trạng thái (Tự động cập nhật)')
->content(function ($record) {
if (!$record || !$record->infrastructure_status || !is_array($record->infrastructure_status)) {
return new HtmlString('<span style="color: #6b7280;">Chưa có dữ liệu hạ tầng</span>');
}
$html = '<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; background: #f9fafb; padding: 15px; border-radius: 8px; border: 1px solid #e5e7eb;">';
foreach ($record->infrastructure_status as $key => $status) {
$statusLower = mb_strtolower($status);
$color = '#6b7280'; // Mặc định xám
$icon = '○';
if (str_contains($statusLower, 'hoàn thành') || str_contains($statusLower, 'đã bàn giao')) {
$color = '#16a34a'; // Xanh lá
$icon = '●';
} elseif (str_contains($statusLower, 'đang thi công') || str_contains($statusLower, 'đang triển khai')) {
$color = '#ca8a04'; // Vàng cam
$icon = '◐';
}
$html .= "<div style='display: flex; align-items: center; gap: 8px;'>
<span style='color: {$color}; font-size: 1.2rem;'>{$icon}</span>
<div>
<div style='font-size: 0.75rem; color: #6b7280; text-transform: uppercase;'>{$key}</div>
<div style='font-weight: 600; color: {$color}; font-size: 0.875rem;'>{$status}</div>
</div>
</div>";
}
$html .= '</div>';
return new HtmlString($html);
}),
KeyValue::make('infrastructure_status')
->label('Chỉnh sửa hạ tầng chi tiết')
->addActionLabel('Thêm hạng mục hạ tầng')
->keyLabel('Hạng mục')
->valueLabel('Trạng thái hiện tại')
->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(),
@@ -83,7 +121,7 @@ class ProductForm
->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.')
->dehydrated(false)
]),
])->columnSpanFull()
]);