| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- @extends('layouts.app')
- @section('content')
- <div class="container-fluid">
- <div class="row">
- <div class="col-12">
- <h2>{{ $title }}</h2>
- {{-- Навигация --}}
- <ul class="nav nav-tabs mb-3">
- <li class="nav-item">
- <a class="nav-link" href="{{ route('spare_parts.index') }}">
- Каталог
- </a>
- </li>
- <li class="nav-item">
- <a class="nav-link" href="{{ route('spare_part_orders.index') }}">
- Заказы деталей
- </a>
- </li>
- <li class="nav-item">
- <a class="nav-link" href="{{ route('spare_part_inventory.index') }}">
- Контроль наличия
- </a>
- </li>
- <li class="nav-item">
- <a class="nav-link active" href="{{ route('pricing_codes.index') }}">
- Справочник расшифровок
- </a>
- </li>
- </ul>
- {{-- Кнопки управления --}}
- <div class="mb-3">
- <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addCodeModal">
- Добавить код
- </button>
- </div>
- {{-- Поиск --}}
- <form method="GET" action="{{ route('pricing_codes.index') }}" class="mb-3">
- <div class="input-group">
- <input type="text" name="search" class="form-control" placeholder="Поиск по коду или расшифровке..." value="{{ $search ?? '' }}">
- <button type="submit" class="btn btn-outline-secondary">Найти</button>
- @if($search ?? false)
- <a href="{{ route('pricing_codes.index') }}" class="btn btn-outline-danger">Сбросить</a>
- @endif
- </div>
- </form>
- {{-- Таблица --}}
- @if(isset($pricing_codes))
- <div class="table-responsive">
- <table class="table table-striped table-hover">
- <thead>
- <tr>
- <th>ID</th>
- <th>Тип</th>
- <th>Код</th>
- <th>Расшифровка</th>
- <th>Действия</th>
- </tr>
- </thead>
- <tbody>
- @forelse($pricing_codes as $code)
- <tr>
- <td>{{ $code->id }}</td>
- <td>
- @if($code->type === 'tsn_number')
- <span class="badge bg-info">№ по ТСН</span>
- @else
- <span class="badge bg-primary">Шифр расценки</span>
- @endif
- </td>
- <td><strong>{{ $code->code }}</strong></td>
- <td>
- <div class="d-flex justify-content-between align-items-center">
- <span class="description-text-{{ $code->id }}">{{ $code->description }}</span>
- <button type="button" class="btn btn-sm btn-link edit-description"
- data-id="{{ $code->id }}"
- data-description="{{ $code->description }}">
- <i class="bi bi-pencil"></i>
- </button>
- </div>
- <form action="{{ route('pricing_codes.update', $code) }}" method="POST" class="edit-form-{{ $code->id }}" style="display: none;">
- @csrf
- @method('PUT')
- <div class="input-group input-group-sm">
- <input type="text" name="description" class="form-control" value="{{ $code->description }}">
- <button type="submit" class="btn btn-success">Сохранить</button>
- <button type="button" class="btn btn-secondary cancel-edit" data-id="{{ $code->id }}">Отмена</button>
- </div>
- </form>
- </td>
- <td>
- <form action="{{ route('pricing_codes.destroy', $code) }}" method="POST" class="d-inline"
- onsubmit="return confirm('Удалить код {{ $code->code }}?')">
- @csrf
- @method('DELETE')
- <button type="submit" class="btn btn-sm btn-danger">Удалить</button>
- </form>
- </td>
- </tr>
- @empty
- <tr>
- <td colspan="5" class="text-center text-muted">Нет записей</td>
- </tr>
- @endforelse
- </tbody>
- </table>
- </div>
- {{ $pricing_codes->links() }}
- @endif
- </div>
- </div>
- </div>
- {{-- Модальное окно добавления кода --}}
- <div class="modal fade" id="addCodeModal" tabindex="-1">
- <div class="modal-dialog">
- <div class="modal-content">
- <div class="modal-header">
- <h5 class="modal-title">Добавить код расценки</h5>
- <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
- </div>
- <form action="{{ route('pricing_codes.store') }}" method="POST">
- @csrf
- <div class="modal-body">
- <div class="mb-3">
- <label for="type" class="form-label">Тип</label>
- <select class="form-select" id="type" name="type" required>
- <option value="tsn_number">№ по ТСН</option>
- <option value="pricing_code">Шифр расценки</option>
- </select>
- </div>
- <div class="mb-3">
- <label for="code" class="form-label">Код</label>
- <input type="text" class="form-control" id="code" name="code" required>
- </div>
- <div class="mb-3">
- <label for="description" class="form-label">Расшифровка</label>
- <input type="text" class="form-control" id="description" name="description">
- </div>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Отмена</button>
- <button type="submit" class="btn btn-primary">Добавить</button>
- </div>
- </form>
- </div>
- </div>
- </div>
- @push('scripts')
- <script type="module">
- function waitForJQuery(callback) {
- if (typeof window.$ !== 'undefined') {
- callback();
- } else {
- setTimeout(() => waitForJQuery(callback), 50);
- }
- }
- waitForJQuery(function() {
- // Редактирование описания
- $('.edit-description').on('click', function() {
- const id = $(this).data('id');
- $('.description-text-' + id).hide();
- $(this).hide();
- $('.edit-form-' + id).show();
- });
- // Отмена редактирования
- $('.cancel-edit').on('click', function() {
- const id = $(this).data('id');
- $('.edit-form-' + id).hide();
- $('.description-text-' + id).show();
- $('.edit-description[data-id="' + id + '"]').show();
- });
- });
- </script>
- @endpush
- @endsection
|