index.blade.php 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. @extends('layouts.app')
  2. @section('content')
  3. <div class="container-fluid">
  4. <div class="row">
  5. <div class="col-12">
  6. <h2>{{ $title }}</h2>
  7. {{-- Навигация --}}
  8. <ul class="nav nav-tabs mb-3">
  9. <li class="nav-item">
  10. <a class="nav-link" href="{{ route('spare_parts.index') }}">
  11. Каталог
  12. </a>
  13. </li>
  14. <li class="nav-item">
  15. <a class="nav-link" href="{{ route('spare_part_orders.index') }}">
  16. Заказы деталей
  17. </a>
  18. </li>
  19. <li class="nav-item">
  20. <a class="nav-link" href="{{ route('spare_part_inventory.index') }}">
  21. Контроль наличия
  22. </a>
  23. </li>
  24. <li class="nav-item">
  25. <a class="nav-link active" href="{{ route('pricing_codes.index') }}">
  26. Справочник расшифровок
  27. </a>
  28. </li>
  29. </ul>
  30. {{-- Кнопки управления --}}
  31. <div class="mb-3">
  32. <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addCodeModal">
  33. Добавить код
  34. </button>
  35. </div>
  36. {{-- Поиск --}}
  37. <form method="GET" action="{{ route('pricing_codes.index') }}" class="mb-3">
  38. <div class="input-group">
  39. <input type="text" name="search" class="form-control" placeholder="Поиск по коду или расшифровке..." value="{{ $search ?? '' }}">
  40. <button type="submit" class="btn btn-outline-secondary">Найти</button>
  41. @if($search ?? false)
  42. <a href="{{ route('pricing_codes.index') }}" class="btn btn-outline-danger">Сбросить</a>
  43. @endif
  44. </div>
  45. </form>
  46. {{-- Таблица --}}
  47. @if(isset($pricing_codes))
  48. <div class="table-responsive">
  49. <table class="table table-striped table-hover">
  50. <thead>
  51. <tr>
  52. <th>ID</th>
  53. <th>Тип</th>
  54. <th>Код</th>
  55. <th>Расшифровка</th>
  56. <th>Действия</th>
  57. </tr>
  58. </thead>
  59. <tbody>
  60. @forelse($pricing_codes as $code)
  61. <tr>
  62. <td>{{ $code->id }}</td>
  63. <td>
  64. @if($code->type === 'tsn_number')
  65. <span class="badge bg-info">№ по ТСН</span>
  66. @else
  67. <span class="badge bg-primary">Шифр расценки</span>
  68. @endif
  69. </td>
  70. <td><strong>{{ $code->code }}</strong></td>
  71. <td>
  72. <div class="d-flex justify-content-between align-items-center">
  73. <span class="description-text-{{ $code->id }}">{{ $code->description }}</span>
  74. <button type="button" class="btn btn-sm btn-link edit-description"
  75. data-id="{{ $code->id }}"
  76. data-description="{{ $code->description }}">
  77. <i class="bi bi-pencil"></i>
  78. </button>
  79. </div>
  80. <form action="{{ route('pricing_codes.update', $code) }}" method="POST" class="edit-form-{{ $code->id }}" style="display: none;">
  81. @csrf
  82. @method('PUT')
  83. <div class="input-group input-group-sm">
  84. <input type="text" name="description" class="form-control" value="{{ $code->description }}">
  85. <button type="submit" class="btn btn-success">Сохранить</button>
  86. <button type="button" class="btn btn-secondary cancel-edit" data-id="{{ $code->id }}">Отмена</button>
  87. </div>
  88. </form>
  89. </td>
  90. <td>
  91. <form action="{{ route('pricing_codes.destroy', $code) }}" method="POST" class="d-inline"
  92. onsubmit="return confirm('Удалить код {{ $code->code }}?')">
  93. @csrf
  94. @method('DELETE')
  95. <button type="submit" class="btn btn-sm btn-danger">Удалить</button>
  96. </form>
  97. </td>
  98. </tr>
  99. @empty
  100. <tr>
  101. <td colspan="5" class="text-center text-muted">Нет записей</td>
  102. </tr>
  103. @endforelse
  104. </tbody>
  105. </table>
  106. </div>
  107. {{ $pricing_codes->links() }}
  108. @endif
  109. </div>
  110. </div>
  111. </div>
  112. {{-- Модальное окно добавления кода --}}
  113. <div class="modal fade" id="addCodeModal" tabindex="-1">
  114. <div class="modal-dialog">
  115. <div class="modal-content">
  116. <div class="modal-header">
  117. <h5 class="modal-title">Добавить код расценки</h5>
  118. <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
  119. </div>
  120. <form action="{{ route('pricing_codes.store') }}" method="POST">
  121. @csrf
  122. <div class="modal-body">
  123. <div class="mb-3">
  124. <label for="type" class="form-label">Тип</label>
  125. <select class="form-select" id="type" name="type" required>
  126. <option value="tsn_number">№ по ТСН</option>
  127. <option value="pricing_code">Шифр расценки</option>
  128. </select>
  129. </div>
  130. <div class="mb-3">
  131. <label for="code" class="form-label">Код</label>
  132. <input type="text" class="form-control" id="code" name="code" required>
  133. </div>
  134. <div class="mb-3">
  135. <label for="description" class="form-label">Расшифровка</label>
  136. <input type="text" class="form-control" id="description" name="description">
  137. </div>
  138. </div>
  139. <div class="modal-footer">
  140. <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Отмена</button>
  141. <button type="submit" class="btn btn-primary">Добавить</button>
  142. </div>
  143. </form>
  144. </div>
  145. </div>
  146. </div>
  147. @push('scripts')
  148. <script type="module">
  149. function waitForJQuery(callback) {
  150. if (typeof window.$ !== 'undefined') {
  151. callback();
  152. } else {
  153. setTimeout(() => waitForJQuery(callback), 50);
  154. }
  155. }
  156. waitForJQuery(function() {
  157. // Редактирование описания
  158. $('.edit-description').on('click', function() {
  159. const id = $(this).data('id');
  160. $('.description-text-' + id).hide();
  161. $(this).hide();
  162. $('.edit-form-' + id).show();
  163. });
  164. // Отмена редактирования
  165. $('.cancel-edit').on('click', function() {
  166. const id = $(this).data('id');
  167. $('.edit-form-' + id).hide();
  168. $('.description-text-' + id).show();
  169. $('.edit-description[data-id="' + id + '"]').show();
  170. });
  171. });
  172. </script>
  173. @endpush
  174. @endsection