From f4aa9482c3c38a6f443432cd484a9cbcc9d4eb0e Mon Sep 17 00:00:00 2001 From: Gabriel Moreira Date: Thu, 9 Apr 2026 10:01:50 -0300 Subject: [PATCH 01/17] =?UTF-8?q?adicionando=20component=20de=20a=C3=A7?= =?UTF-8?q?=C3=B5es=20para=20lote?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/ProjectController.php | 24 +++++++++++++++++++ resources/js/Pages/Projects/Index.vue | 3 ++- .../Projects/Partials/ProjectActions.vue | 24 +++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 resources/js/Pages/Projects/Partials/ProjectActions.vue diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index e8b799b..d8fb31a 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -32,5 +32,29 @@ public function index(Request $request, Notice $notice) ]), ]); } + + public function assignProjectSupervisor(Request $request, Notice $notice) + { + // Implement the logic to assign a supervisor to a project + //it will receive an array of project ids and an array of supervisor ids, and it will assign each supervisor to each project + $request->validate([ + 'project_ids' => 'required|array', + 'supervisor_ids' => 'required|array', + ]); + $projectIds = $request->input('project_ids'); + $supervisorIds = $request->input('supervisor_ids'); + foreach ($projectIds as $projectId) { + foreach ($supervisorIds as $supervisorId) { + + ProjectSupervisor::create([ + 'project_id' => $projectId, + 'supervisor_id' => $supervisorId, + 'assigned_by' => Auth::id(), + 'assigned_at' => now(), + ]); + } + } + return redirect()->back()->with('success', 'Supervisores atribuídos com sucesso!'); + } } \ No newline at end of file diff --git a/resources/js/Pages/Projects/Index.vue b/resources/js/Pages/Projects/Index.vue index 60d2205..2524d5f 100644 --- a/resources/js/Pages/Projects/Index.vue +++ b/resources/js/Pages/Projects/Index.vue @@ -5,6 +5,7 @@ import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout.vue' import ProjectList from '@/Pages/Projects/Partials/ProjectList.vue' import PhaseFilter from '@/Pages/Projects/Partials/PhaseFilter.vue' import ProjectNoticeEdit from '@/Pages/Projects/Partials/ProjectNoticeEdit.vue' +import ProjectActions from '@/Pages/Projects/Partials/ProjectActions.vue' import { Head, router } from '@inertiajs/vue3' import { ref } from 'vue' @@ -113,7 +114,7 @@ const selectedProjects = ref([]) @update:search="onSearch" @clearPhaseFilter="clearPhaseFilter" />
- +
diff --git a/resources/js/Pages/Projects/Partials/ProjectActions.vue b/resources/js/Pages/Projects/Partials/ProjectActions.vue new file mode 100644 index 0000000..88d58bf --- /dev/null +++ b/resources/js/Pages/Projects/Partials/ProjectActions.vue @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file From df6b32ce31e230675f5de37332f811c6924a55d8 Mon Sep 17 00:00:00 2001 From: Gabriel Moreira Date: Fri, 10 Apr 2026 12:48:45 -0300 Subject: [PATCH 02/17] adicionado feature de atribuir fiscais --- app/Http/Controllers/ProjectController.php | 49 +++++--- resources/js/Components/ListDataTable.vue | 9 +- resources/js/Pages/Projects/Index.vue | 6 +- .../Projects/Partials/ProjectActions.vue | 65 ++++++++--- .../Projects/Partials/supervisorDialog.vue | 106 ++++++++++++++++++ routes/web.php | 3 +- 6 files changed, 200 insertions(+), 38 deletions(-) create mode 100644 resources/js/Pages/Projects/Partials/supervisorDialog.vue diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index d8fb31a..2524c4d 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -7,6 +7,9 @@ use Inertia\Inertia; use Inertia\Response; use App\Models\Notice; +use App\Models\User; +use App\Models\Project; +use App\Models\OpeningSupervisor; use App\Enums\ProjectPhase; use App\Enums\InstrumentType; @@ -15,7 +18,7 @@ class ProjectController extends Controller public function index(Request $request, Notice $notice) { $query = $notice->projects() - ->with(['agent', 'category', 'opening']) + ->with(['agent', 'category', 'opening', 'opening.supervisors']) ->withCount('openings') ->filterPhase($request->phase) ->search($request->search); @@ -30,31 +33,45 @@ public function index(Request $request, Notice $notice) 'title' => $phase->label(), 'total' => $phase->count($query), ]), + 'supervisors_available' => User::select('id', 'name')->get(), ]); } - public function assignProjectSupervisor(Request $request, Notice $notice) + public function assignProjectSupervisor(Request $request) { - // Implement the logic to assign a supervisor to a project - //it will receive an array of project ids and an array of supervisor ids, and it will assign each supervisor to each project - $request->validate([ - 'project_ids' => 'required|array', - 'supervisor_ids' => 'required|array', + $data = $request->validate([ + 'selected_projects' => 'required|array', + 'selected_projects.*' => 'exists:projects,id', + + 'selected_supervisors' => 'required|array', + 'selected_supervisors.*' => 'exists:users,id', ]); - $projectIds = $request->input('project_ids'); - $supervisorIds = $request->input('supervisor_ids'); - foreach ($projectIds as $projectId) { - foreach ($supervisorIds as $supervisorId) { - - ProjectSupervisor::create([ - 'project_id' => $projectId, - 'supervisor_id' => $supervisorId, + + $projects = Project::with('opening')->whereIn('id', $data['selected_projects'])->get(); + + foreach ($projects as $project) { + if(!$project->opening) { + continue; + } + OpeningSupervisor::where('opening_id', $project->opening->id) + ->where('is_active', true) + ->update([ + 'is_active' => false, + 'removed_at' => now(), + ]); + + foreach ($data['selected_supervisors'] as $supervisorId) { + OpeningSupervisor::create([ + 'opening_id' => $project->opening->id, + 'user_id' => $supervisorId, 'assigned_by' => Auth::id(), 'assigned_at' => now(), + 'is_active' => true, ]); } } - return redirect()->back()->with('success', 'Supervisores atribuídos com sucesso!'); + + return back()->with('success', 'Supervisores atribuídos com sucesso!'); } } \ No newline at end of file diff --git a/resources/js/Components/ListDataTable.vue b/resources/js/Components/ListDataTable.vue index 3ff873b..8bfa337 100644 --- a/resources/js/Components/ListDataTable.vue +++ b/resources/js/Components/ListDataTable.vue @@ -34,6 +34,11 @@ const props = defineProps({ selectable: { type: Boolean, default: false }, + isSelectable: { + type: Function, + default: () => true, + }, + modelValue: { type: Array, default: () => [], @@ -48,6 +53,8 @@ const selected = computed({ }) function toggle(item) { + if (!props.isSelectable(item)) return + const exists = selected.value.includes(item.id) if (exists) { @@ -72,7 +79,7 @@ function runAction(action, item) { rounded="lg" variant="outlined">
-
diff --git a/resources/js/Pages/Projects/Index.vue b/resources/js/Pages/Projects/Index.vue index 2524d5f..700b686 100644 --- a/resources/js/Pages/Projects/Index.vue +++ b/resources/js/Pages/Projects/Index.vue @@ -14,7 +14,8 @@ const props = defineProps({ projects: Array, filters: Object, phases: Array, - instrumentTypes: Array + instrumentTypes: Array, + supervisors_available: Array, }) const search = ref(props.filters?.search ?? '') @@ -91,6 +92,7 @@ const tableConfig = { chips, data, actions, + isSelectable: (item) => item.openings_count > 0, } const selectedProjects = ref([]) @@ -114,7 +116,7 @@ const selectedProjects = ref([]) @update:search="onSearch" @clearPhaseFilter="clearPhaseFilter" />
- +
diff --git a/resources/js/Pages/Projects/Partials/ProjectActions.vue b/resources/js/Pages/Projects/Partials/ProjectActions.vue index 88d58bf..c44f9fe 100644 --- a/resources/js/Pages/Projects/Partials/ProjectActions.vue +++ b/resources/js/Pages/Projects/Partials/ProjectActions.vue @@ -1,24 +1,53 @@ + - - - - \ No newline at end of file + \ No newline at end of file diff --git a/resources/js/Pages/Projects/Partials/supervisorDialog.vue b/resources/js/Pages/Projects/Partials/supervisorDialog.vue new file mode 100644 index 0000000..d72c866 --- /dev/null +++ b/resources/js/Pages/Projects/Partials/supervisorDialog.vue @@ -0,0 +1,106 @@ + + + diff --git a/routes/web.php b/routes/web.php index cadb8e8..0055623 100644 --- a/routes/web.php +++ b/routes/web.php @@ -58,7 +58,8 @@ 'update' => 'projects.update', 'destroy' => 'projects.destroy', ]); - + Route::post('/projetos/atribuir-fiscal', [ProjectController::class, 'assignProjectSupervisor']) + ->name('projects.assign-supervisors'); Route::get('editais/{notice}/projetos', [ProjectController::class, 'index']) ->name('notices.projects'); }); From f2f5784284409c8c9b2a7af5e74516011d075a75 Mon Sep 17 00:00:00 2001 From: Gabriel Moreira Date: Fri, 10 Apr 2026 12:54:42 -0300 Subject: [PATCH 03/17] formatando codigo --- app/Http/Controllers/ProjectController.php | 3 +- resources/js/Pages/Projects/Index.vue | 5 ++-- .../Projects/Partials/ProjectActions.vue | 29 +++++++++--------- .../Projects/Partials/supervisorDialog.vue | 30 ++++++------------- 4 files changed, 29 insertions(+), 38 deletions(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 2524c4d..03ef451 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -53,6 +53,7 @@ public function assignProjectSupervisor(Request $request) if(!$project->opening) { continue; } + OpeningSupervisor::where('opening_id', $project->opening->id) ->where('is_active', true) ->update([ @@ -70,7 +71,7 @@ public function assignProjectSupervisor(Request $request) ]); } } - + return back()->with('success', 'Supervisores atribuídos com sucesso!'); } diff --git a/resources/js/Pages/Projects/Index.vue b/resources/js/Pages/Projects/Index.vue index 700b686..a387977 100644 --- a/resources/js/Pages/Projects/Index.vue +++ b/resources/js/Pages/Projects/Index.vue @@ -104,7 +104,7 @@ const selectedProjects = ref([]) - +
@@ -116,7 +116,8 @@ const selectedProjects = ref([]) @update:search="onSearch" @clearPhaseFilter="clearPhaseFilter" />
- +
diff --git a/resources/js/Pages/Projects/Partials/ProjectActions.vue b/resources/js/Pages/Projects/Partials/ProjectActions.vue index c44f9fe..05a4919 100644 --- a/resources/js/Pages/Projects/Partials/ProjectActions.vue +++ b/resources/js/Pages/Projects/Partials/ProjectActions.vue @@ -1,5 +1,5 @@