Added rework logic in panel box validation page
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
This commit is contained in:
@@ -9,6 +9,7 @@ use App\Models\ProductionCharacteristic;
|
|||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Forms\Get;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
@@ -31,6 +32,7 @@ use App\Filament\Exports\PanelBoxValidationExporter;
|
|||||||
use App\Filament\Imports\PanelBoxValidationImporter;
|
use App\Filament\Imports\PanelBoxValidationImporter;
|
||||||
use Filament\Forms\Components\Actions;
|
use Filament\Forms\Components\Actions;
|
||||||
use Filament\Forms\Components\Actions\Action;
|
use Filament\Forms\Components\Actions\Action;
|
||||||
|
use Illuminate\Support\Js;
|
||||||
|
|
||||||
class PanelBoxValidationResource extends Resource
|
class PanelBoxValidationResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -64,6 +66,7 @@ class PanelBoxValidationResource extends Resource
|
|||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
$set('line_id', null);
|
$set('line_id', null);
|
||||||
$set('production_order', null);
|
$set('production_order', null);
|
||||||
|
$set('inspection_lot_number', null);
|
||||||
|
|
||||||
$set('part_validation_type_options', []);
|
$set('part_validation_type_options', []);
|
||||||
$set('part_validation_type', null);
|
$set('part_validation_type', null);
|
||||||
@@ -117,6 +120,7 @@ class PanelBoxValidationResource extends Resource
|
|||||||
->afterStateUpdated(function (callable $set, callable $get, $state) {
|
->afterStateUpdated(function (callable $set, callable $get, $state) {
|
||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
$set('production_order', null);
|
$set('production_order', null);
|
||||||
|
$set('inspection_lot_number', null);
|
||||||
|
|
||||||
$set('line', $state);
|
$set('line', $state);
|
||||||
|
|
||||||
@@ -810,21 +814,21 @@ class PanelBoxValidationResource extends Resource
|
|||||||
|
|
||||||
$serialExists = PanelBoxValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)->first();
|
$serialExists = PanelBoxValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)->first();
|
||||||
|
|
||||||
// if ($serialExists) {
|
if ($serialExists) {
|
||||||
// $set('serial_exists', true);
|
$set('serial_exists', true);
|
||||||
// } else {
|
} else {
|
||||||
// $set('serial_exists', false);
|
$set('serial_exists', false);
|
||||||
// }
|
|
||||||
|
|
||||||
if ($serialExists && ! $get('id')) {
|
|
||||||
$set('validationError', 'Serial number already exists in panel box validation.');
|
|
||||||
$set('sticker_master_id', null);
|
|
||||||
$set('uom', null);
|
|
||||||
$set('serial_number', null);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if ($serialExists && ! $get('id')) {
|
||||||
|
// $set('validationError', 'Serial number already exists in panel box validation.');
|
||||||
|
// $set('sticker_master_id', null);
|
||||||
|
// $set('uom', null);
|
||||||
|
// $set('serial_number', null);
|
||||||
|
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
$set('validationError', null);
|
$set('validationError', null);
|
||||||
|
|
||||||
foreach ($serialFields as $column) {
|
foreach ($serialFields as $column) {
|
||||||
@@ -943,6 +947,7 @@ class PanelBoxValidationResource extends Resource
|
|||||||
'id' => 'item_id',
|
'id' => 'item_id',
|
||||||
'onkeydown' => "
|
'onkeydown' => "
|
||||||
if (event.key === 'Enter') {
|
if (event.key === 'Enter') {
|
||||||
|
|
||||||
const serialFields = [
|
const serialFields = [
|
||||||
'serial_number_motor_qr', 'serial_number_pump_qr', 'pack_slip_motor_qr',
|
'serial_number_motor_qr', 'serial_number_pump_qr', 'pack_slip_motor_qr',
|
||||||
'name_plate_motor_qr', 'tube_sticker_motor_qr', 'warranty_card_qr'
|
'name_plate_motor_qr', 'tube_sticker_motor_qr', 'warranty_card_qr'
|
||||||
@@ -962,6 +967,7 @@ class PanelBoxValidationResource extends Resource
|
|||||||
if (anyVisible) {
|
if (anyVisible) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
event.stopImmediatePropagation();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -969,8 +975,11 @@ class PanelBoxValidationResource extends Resource
|
|||||||
])
|
])
|
||||||
->hint(fn ($get) => $get('validationError') ? $get('validationError') : null)
|
->hint(fn ($get) => $get('validationError') ? $get('validationError') : null)
|
||||||
->hintColor('danger'),
|
->hintColor('danger'),
|
||||||
Forms\Components\Hidden::make('serial_exists')
|
Forms\Components\Hidden::make('serial_exists')
|
||||||
->default(false),
|
// ->default(false)
|
||||||
|
->live()
|
||||||
|
->dehydrated()
|
||||||
|
->id('serial_exists'),
|
||||||
|
|
||||||
Forms\Components\Actions::make([
|
Forms\Components\Actions::make([
|
||||||
Action::make('rework')
|
Action::make('rework')
|
||||||
@@ -996,9 +1005,9 @@ class PanelBoxValidationResource extends Resource
|
|||||||
|
|
||||||
if ($alreadyExists) {
|
if ($alreadyExists) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invalid Rework')
|
->title('Duplicate Found')
|
||||||
->body(
|
->body(
|
||||||
'This document number and inspection lot number have already been used for this serial number. Please provide a new document number and inspection lot number for rework..'
|
'This document number and inspection lot number have already been used for this serial number. Please provide a new document number and inspection lot number for rework...'
|
||||||
)
|
)
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
|
|||||||
Reference in New Issue
Block a user