index.blade.php 9.0 KB

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