edit.blade.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. @extends('layouts.app')
  2. @section('content')
  3. <div class="px-3">
  4. <form class="row" action="{{ route('order.store') }}" method="post">
  5. <div class="col-xxl-6">
  6. <h4>Общая информация об объекте</h4>
  7. @csrf
  8. @if(isset($order))
  9. <input type="hidden" name="id" value="{{ $order->id }}">
  10. @endif
  11. @include('partials.select', ['name' => 'district_id', 'title' => 'Округ', 'options' => $districts, 'value' => $order?->district_id ?? old('district_id'), 'first_empty' => true, 'required' => true])
  12. @include('partials.select', ['name' => 'area_id', 'title' => 'Район', 'options' => $areas, 'value' => $order?->area_id ?? old('area_id'), 'required' => true, 'first_empty' => true])
  13. @include('partials.input', ['name' => 'object_address', 'title' => 'Адрес объекта', 'value' => $order->object_address ?? old('object_address'), 'required' => true])
  14. @include('partials.select', ['name' => 'object_type_id', 'title' => 'Тип объекта', 'options' => $objectTypes, 'value' => $order->object_type_id ?? old('object_type_id'), 'required' => true, 'first_empty' => true])
  15. @include('partials.select', ['name' => 'order_status_id', 'title' => 'Статус', 'options' => $orderStatuses, 'value' => $order->order_status_id ?? old('order_status_id'), 'required' => true])
  16. @include('partials.input', ['name' => 'contract_date', 'title' => 'Дата договора', 'type' => 'date', 'value' => $order->contract_date ?? old('contract_date')])
  17. @include('partials.input', ['name' => 'contract_number', 'title' => 'Номер договора', 'value' => $order->contract_number ?? old('contract_number')])
  18. @include('partials.textarea', ['name' => 'comment', 'title' => 'Комментарий', 'value' => $order->comment ?? old('comment')])
  19. @include('partials.input', ['name' => 'installation_date', 'title' => 'Дата выхода на монтаж', 'type' => 'date', 'value' => $order->installation_date ?? old('installation_date')])
  20. @include('partials.select', ['name' => 'brigadier_id', 'title' => 'Бригадир', 'options' => $brigadiers, 'value' => $order->brigadier_id ?? old('brigadier_id')])
  21. @include('partials.select', ['name' => 'user_id', 'title' => 'Менеджер', 'options' => $users, 'value' => $order->user_id ?? old('user_id') ?? auth()->user()->id])
  22. @include('partials.input', ['name' => 'tg_group_name', 'title' => 'Название группы в ТГ', 'value' => $order->tg_group_name ?? old('tg_group_name')])
  23. @include('partials.input', ['name' => 'tg_group_link', 'title' => 'Ссылка на группу в ТГ', 'value' => $order->tg_group_link ?? old('tg_group_link')])
  24. </div>
  25. <div class="col-xxl-6">
  26. <h4>МАФ</h4>
  27. @include('partials.input', ['name' => 'search_maf', 'title' => 'Поиск МАФ', 'value' => '',
  28. 'placeholder' => 'Артикул или номер номенклатуры', 'datalist' => []])
  29. @include('partials.select', ['name' => 'select_maf', 'title' => '', 'options' => [], 'multiple' => true])
  30. <div id="selected_maf"></div>
  31. </div>
  32. <div class="col-12 text-end">
  33. @include('partials.submit')
  34. </div>
  35. </form>
  36. </div>
  37. @if($errors->any())
  38. @dump($errors->all())
  39. @endif
  40. @endsection
  41. @push('scripts')
  42. <script type="module">
  43. let selectMaf = $('#select_maf');
  44. $('#search_maf').on('keyup', function () {
  45. // search products on backend
  46. $.get('{{ route('product.search') }}?s=' + $(this).val(),
  47. function (data) {
  48. selectMaf.children().remove()
  49. $.each(data, function (id, name) {
  50. selectMaf.append('<option value=\'' + id + '\'>' + name + '</option>');
  51. });
  52. }
  53. );
  54. });
  55. selectMaf.on('change', function () {
  56. $('#selected_maf').append('' +
  57. '<div class="maf">' +
  58. '<input type="hidden" name="products[]" value="'+ $(this).val() +'">' +
  59. '<span>'+ $('#select_maf option:selected').text() +'</span> ' +
  60. '<i onclick="$(this).parent().remove()" class="bi bi-trash text-danger cursor-pointer"></i>' +
  61. '</div>'
  62. );
  63. $('#select_maf').children().remove();
  64. $('#search_maf').val('');
  65. });
  66. $('#district_id').on('change', function () {
  67. // load areas of selected district
  68. console.log($(this).val());
  69. $.get('{{ route('area.ajax-get-areas-by-district') }}/' + $(this).val(),
  70. function (data) {
  71. $('#area_id').children().remove();
  72. $.each(data, function (id, name) {
  73. $('#area_id').append('<option value=\'' + id + '\'>' + name + '</option>');
  74. });
  75. }
  76. );
  77. });
  78. </script>
  79. @endpush