|
|
@@ -43,19 +43,19 @@
|
|
|
<input type="hidden" name="previous_url" value="{{ $previous_url ?? '' }}">
|
|
|
|
|
|
@include('partials.link', ['title' => 'Площадка', 'href' => route('order.show', ['order' => $reclamation->order_id, 'sync_year' => 1]), 'text' => $reclamation->order->common_name ?? ''])
|
|
|
- @include('partials.select', ['name' => 'status_id', 'title' => 'Статус', 'options' => $statuses, 'value' => $reclamation->status_id ?? old('status_id'), 'disabled' => !hasRole('admin,manager')])
|
|
|
- @include('partials.select', ['name' => 'user_id', 'title' => 'Менеджер', 'options' => $users, 'value' => $reclamation->user_id ?? old('user_id') ?? auth()->user()->id, 'disabled' => !hasRole('admin,manager')])
|
|
|
+ @include('partials.select', ['name' => 'status_id', 'title' => 'Статус', 'options' => $statuses, 'value' => $reclamation->status_id ?? old('status_id'), 'disabled' => !hasRole('admin,manager'), 'classes' => ['update-once']])
|
|
|
+ @include('partials.select', ['name' => 'user_id', 'title' => 'Менеджер', 'options' => $users, 'value' => $reclamation->user_id ?? old('user_id') ?? auth()->user()->id, 'disabled' => !hasRole('admin,manager'), 'classes' => ['update-once']])
|
|
|
@include('partials.input', ['name' => 'maf_installation_year', 'title' => 'Год установки МАФ', 'type' => 'text', 'value' => $reclamation->order->year, 'disabled' => true])
|
|
|
- @include('partials.input', ['name' => 'create_date', 'title' => 'Дата создания', 'type' => 'date', 'required' => true, 'value' => $reclamation->create_date ?? date('Y-m-d'), 'disabled' => !hasRole('admin,manager')])
|
|
|
- @include('partials.input', ['name' => 'finish_date', 'title' => 'Дата завершения', 'type' => 'date', 'required' => true, 'value' => $reclamation->finish_date ?? date('Y-m-d', strtotime('+30 days')), 'disabled' => !hasRole('admin,manager')])
|
|
|
- @include('partials.select', ['name' => 'brigadier_id', 'title' => 'Бригадир', 'options' => $brigadiers, 'value' => $reclamation->brigadier_id ?? old('brigadier_id'), 'disabled' => !hasRole('admin,manager'), 'first_empty' => true])
|
|
|
- @include('partials.input', ['name' => 'start_work_date', 'title' => 'Дата начала работ', 'type' => 'date', 'value' => $reclamation->start_work_date, 'disabled' => !hasRole('admin,manager')])
|
|
|
- @include('partials.input', ['name' => 'work_days', 'title' => 'Срок работ, дней', 'type' => 'number', 'min' => 1, 'value' => $reclamation->work_days, 'disabled' => !hasRole('admin,manager')])
|
|
|
- @include('partials.select', ['name' => 'reason', 'title' => 'Причина', 'size' => 6, 'value' => $reclamation->reason ?? '', 'options' => ['Вандализм', 'Гарантия', 'Сервисное обслуживание'], 'key_as_val' => true, 'disabled' => !hasRole('admin,manager')])
|
|
|
- @include('partials.input', ['name' => 'factory_reclamation_number', 'title' => '№ рекламации на фабрике', 'type' => 'text', 'value' => $reclamation->factory_reclamation_number ?? '', 'disabled' => !hasRole('admin,manager')])
|
|
|
- @include('partials.textarea', ['name' => 'guarantee', 'title' => 'Гарантии', 'size' => 6, 'value' => $reclamation->guarantee ?? '', 'disabled' => !hasRole('admin,manager')])
|
|
|
- @include('partials.textarea', ['name' => 'whats_done', 'title' => 'Что сделано', 'size' => 6, 'value' => $reclamation->whats_done ?? '', 'disabled' => !hasRole('admin,manager')])
|
|
|
- @include('partials.textarea', ['name' => 'comment', 'title' => 'Комментарий', 'size' => 6, 'value' => $reclamation->comment ?? '', 'disabled' => !hasRole('admin,manager')])
|
|
|
+ @include('partials.input', ['name' => 'create_date', 'title' => 'Дата создания', 'type' => 'date', 'required' => true, 'value' => $reclamation->create_date ?? date('Y-m-d'), 'disabled' => !hasRole('admin,manager'), 'classes' => ['update-once']])
|
|
|
+ @include('partials.input', ['name' => 'finish_date', 'title' => 'Дата завершения', 'type' => 'date', 'required' => true, 'value' => $reclamation->finish_date ?? date('Y-m-d', strtotime('+30 days')), 'disabled' => !hasRole('admin,manager'), 'classes' => ['update-once']])
|
|
|
+ @include('partials.select', ['name' => 'brigadier_id', 'title' => 'Бригадир', 'options' => $brigadiers, 'value' => $reclamation->brigadier_id ?? old('brigadier_id'), 'disabled' => !hasRole('admin,manager'), 'first_empty' => true, 'classes' => ['update-once']])
|
|
|
+ @include('partials.input', ['name' => 'start_work_date', 'title' => 'Дата начала работ', 'type' => 'date', 'value' => $reclamation->start_work_date, 'disabled' => !hasRole('admin,manager'), 'classes' => ['update-once']])
|
|
|
+ @include('partials.input', ['name' => 'work_days', 'title' => 'Срок работ, дней', 'type' => 'number', 'min' => 1, 'value' => $reclamation->work_days, 'disabled' => !hasRole('admin,manager'), 'classes' => ['update-once']])
|
|
|
+ @include('partials.select', ['name' => 'reason', 'title' => 'Причина', 'size' => 6, 'value' => $reclamation->reason ?? '', 'options' => ['Вандализм', 'Гарантия', 'Сервисное обслуживание'], 'key_as_val' => true, 'disabled' => !hasRole('admin,manager'), 'classes' => ['update-once']])
|
|
|
+ @include('partials.input', ['name' => 'factory_reclamation_number', 'title' => '№ рекламации на фабрике', 'type' => 'text', 'value' => $reclamation->factory_reclamation_number ?? '', 'disabled' => !hasRole('admin,manager'), 'classes' => ['update-once']])
|
|
|
+ @include('partials.textarea', ['name' => 'guarantee', 'title' => 'Гарантии', 'size' => 6, 'value' => $reclamation->guarantee ?? '', 'disabled' => !hasRole('admin,manager'), 'classes' => ['update-once']])
|
|
|
+ @include('partials.textarea', ['name' => 'whats_done', 'title' => 'Что сделано', 'size' => 6, 'value' => $reclamation->whats_done ?? '', 'disabled' => !hasRole('admin,manager'), 'classes' => ['update-once']])
|
|
|
+ @include('partials.textarea', ['name' => 'comment', 'title' => 'Комментарий', 'size' => 6, 'value' => $reclamation->comment ?? '', 'disabled' => !hasRole('admin,manager'), 'classes' => ['update-once']])
|
|
|
@include('partials.submit', ['name' => 'Сохранить', 'offset' => 5, 'disabled' => !hasRole('admin,manager'), 'backurl' => route('reclamations.index', session('gp_reclamations'))])
|
|
|
</form>
|
|
|
</div>
|
|
|
@@ -318,21 +318,28 @@
|
|
|
<td class="text-end">
|
|
|
@if($issueCandidateOrders->count() > 1)
|
|
|
<button type="button"
|
|
|
- class="btn btn-sm btn-success"
|
|
|
- title="Выбрать заказ для списания"
|
|
|
+ class="btn btn-sm btn-outline-primary"
|
|
|
+ title="Изменить заказ резерва"
|
|
|
data-bs-toggle="modal"
|
|
|
- data-bs-target="#issueReservationModal-{{ $reservation->id }}">
|
|
|
- <i class="bi bi-check-lg"></i>
|
|
|
+ data-bs-target="#reassignReservationModal-{{ $reservation->id }}">
|
|
|
+ <i class="bi bi-pencil"></i>
|
|
|
</button>
|
|
|
|
|
|
- <div class="modal fade" id="issueReservationModal-{{ $reservation->id }}" tabindex="-1" aria-labelledby="issueReservationModalLabel-{{ $reservation->id }}" aria-hidden="true">
|
|
|
+ <form action="{{ route('spare_part_reservations.issue', $reservation) }}" method="POST" class="d-inline">
|
|
|
+ @csrf
|
|
|
+ <button type="submit" class="btn btn-sm btn-success" title="Списать">
|
|
|
+ <i class="bi bi-check-lg"></i>
|
|
|
+ </button>
|
|
|
+ </form>
|
|
|
+
|
|
|
+ <div class="modal fade" id="reassignReservationModal-{{ $reservation->id }}" tabindex="-1" aria-labelledby="reassignReservationModalLabel-{{ $reservation->id }}" aria-hidden="true">
|
|
|
<div class="modal-dialog modal-dialog-scrollable">
|
|
|
<div class="modal-content">
|
|
|
<div class="modal-header">
|
|
|
- <h1 class="modal-title fs-5" id="issueReservationModalLabel-{{ $reservation->id }}">Выбор заказа для списания</h1>
|
|
|
+ <h1 class="modal-title fs-5" id="reassignReservationModalLabel-{{ $reservation->id }}">Выбор заказа для резерва</h1>
|
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>
|
|
|
</div>
|
|
|
- <form action="{{ route('spare_part_reservations.issue', $reservation) }}" method="POST">
|
|
|
+ <form action="{{ route('spare_part_reservations.reassign', $reservation) }}" method="POST">
|
|
|
@csrf
|
|
|
<div class="modal-body">
|
|
|
<div class="mb-2 small text-muted">
|
|
|
@@ -365,7 +372,7 @@
|
|
|
</div>
|
|
|
<div class="modal-footer">
|
|
|
<button type="button" class="btn btn-outline-secondary btn-sm" data-bs-dismiss="modal">Закрыть</button>
|
|
|
- <button type="submit" class="btn btn-success btn-sm">Списать</button>
|
|
|
+ <button type="submit" class="btn btn-primary btn-sm">Сохранить резерв</button>
|
|
|
</div>
|
|
|
</form>
|
|
|
</div>
|
|
|
@@ -851,6 +858,64 @@
|
|
|
$(target).toggleClass('d-none', $(this).val() !== 'user');
|
|
|
}).trigger('change');
|
|
|
|
|
|
+ $('.update-once').on('focus', function () {
|
|
|
+ $(this).data('previous-value', $(this).val());
|
|
|
+ });
|
|
|
+
|
|
|
+ $('.update-once').on('change', function () {
|
|
|
+ let $field = $(this);
|
|
|
+ let value = $field.val();
|
|
|
+ let fieldName = $field.attr('name');
|
|
|
+ let previousValue = $field.data('previous-value');
|
|
|
+
|
|
|
+ $.post(
|
|
|
+ '{{ route('reclamations.update', $reclamation) }}',
|
|
|
+ {
|
|
|
+ '_token': '{{ csrf_token() }}',
|
|
|
+ order_id: '{{ $reclamation->order_id }}',
|
|
|
+ previous_url: '{{ $previous_url ?? '' }}',
|
|
|
+ user_id: $('#user_id').val(),
|
|
|
+ status_id: $('#status_id').val(),
|
|
|
+ create_date: $('#create_date').val(),
|
|
|
+ finish_date: $('#finish_date').val(),
|
|
|
+ brigadier_id: $('#brigadier_id').val(),
|
|
|
+ start_work_date: $('#start_work_date').val(),
|
|
|
+ work_days: $('#work_days').val(),
|
|
|
+ reason: $('#reason').val(),
|
|
|
+ factory_reclamation_number: $('#factory_reclamation_number').val(),
|
|
|
+ guarantee: $('#guarantee').val(),
|
|
|
+ whats_done: $('#whats_done').val(),
|
|
|
+ comment: $('#comment').val(),
|
|
|
+ [fieldName]: value
|
|
|
+ },
|
|
|
+ function () {
|
|
|
+ $field.data('previous-value', value);
|
|
|
+ $('.alerts').append(
|
|
|
+ '<div class="main-alert alert alert-success" role="alert">Рекламация обновлена!</div>'
|
|
|
+ );
|
|
|
+ setTimeout(function () {
|
|
|
+ $('.main-alert').fadeTo(2000, 500).slideUp(500, function () {
|
|
|
+ $('.main-alert').slideUp(500);
|
|
|
+ });
|
|
|
+ }, 3000);
|
|
|
+ }
|
|
|
+ ).fail(function (xhr) {
|
|
|
+ if (previousValue !== undefined) {
|
|
|
+ $field.val(previousValue);
|
|
|
+ }
|
|
|
+
|
|
|
+ let errorText = xhr.responseJSON?.message || 'Не удалось обновить рекламацию!';
|
|
|
+ $('.alerts').append(
|
|
|
+ '<div class="main-alert alert alert-danger" role="alert">' + errorText + '</div>'
|
|
|
+ );
|
|
|
+ setTimeout(function () {
|
|
|
+ $('.main-alert').fadeTo(2000, 500).slideUp(500, function () {
|
|
|
+ $('.main-alert').slideUp(500);
|
|
|
+ });
|
|
|
+ }, 3000);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
// Инициализация для существующих строк
|
|
|
$('.spare-part-row').not('.spare-part-template').each(function() {
|
|
|
initSparePartAutocomplete($(this));
|