|
|
@@ -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>
|
|
|
@@ -851,6 +851,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));
|