config.blade.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. @extends('base.base')
  2. @section('base')
  3. <!-- 内容区域 -->
  4. <div class="main-panel">
  5. <div class="content-wrapper">
  6. <div class="page-header">
  7. <h3 class="page-title">
  8. <span class="page-title-icon bg-gradient-primary text-white mr-2">
  9. <i class="mdi mdi-settings"></i>
  10. </span>
  11. {{ __('auto.咖啡渠道修改') }}
  12. </h3>
  13. <nav aria-label="breadcrumb">
  14. <ol class="breadcrumb">
  15. <li class="breadcrumb-item"><a href="#">{{ __('auto.咖啡管理') }}</a></li>
  16. <li class="breadcrumb-item active" aria-current="page">{{ __('auto.咖啡渠道修改') }}</li>
  17. <li class="breadcrumb-item active" aria-current="page">{{ __('auto.查看渠道') }}</li>
  18. </ol>
  19. </nav>
  20. </div>
  21. <div class="row">
  22. <div class="col-lg-12 grid-margin stretch-card">
  23. <div class="card">
  24. <div class="card-body">
  25. <h4 class="card-title">{{ __('auto.查看渠道') }}</h4>
  26. <div class="mb-2">
  27. <button type="button" class="btn btn-sm btn-outline-secondary" id="toggle-closed-btn">
  28. 显示已关闭渠道
  29. </button>
  30. </div>
  31. <form action="" method="post" class="form-ajax">
  32. {!! csrf_field() !!}
  33. <div class="table-responsive">
  34. <table class="table table-bordered table-striped">
  35. <thead>
  36. <tr>
  37. <th style="min-width: 80px;">ID</th>
  38. <th style="min-width: 180px;">{{ __('auto.渠道名称') }}</th>
  39. <th style="min-width: 120px;">Cash(1)</th>
  40. <th style="min-width: 120px;">PayPal(2)</th>
  41. <th style="min-width: 120px;">Apple(4)</th>
  42. <th style="min-width: 120px;">Google(8)</th>
  43. <th style="min-width: 150px;">{{ __('auto.当前状态') }}</th>
  44. </tr>
  45. </thead>
  46. <tbody>
  47. @foreach($list as $k => $v)
  48. @php
  49. $remarks = [];
  50. if (!empty($v->remarks)) {
  51. $decoded = \GuzzleHttp\json_decode($v->remarks, true);
  52. if (is_array($decoded)) {
  53. $remarks = $decoded;
  54. }
  55. }
  56. $weights = $remarks['weight'] ?? ($remarks['weights'] ?? []);
  57. $payTypes = (int)($v->pay_types ?? 0);
  58. @endphp
  59. <tr data-status="{{ (int)$v->status }}">
  60. <td>{{ $v->id }}</td>
  61. <td>{{ $v->name }}</td>
  62. <input type="hidden" name="config[{{$v->id}}][sort]" value="{{$v->sort}}">
  63. <td>
  64. <input class="form-control form-control-sm" type="number" min="0"
  65. name="config[{{$v->id}}][weight][1]"
  66. value="{{ $weights['type_1'] ?? '' }}"
  67. placeholder="{{ (($payTypes & 1) === 1) ? '0' : 'N/A' }}"
  68. {{ (($payTypes & 1) === 1) ? '' : 'disabled' }}>
  69. </td>
  70. <td>
  71. <input class="form-control form-control-sm" type="number" min="0"
  72. name="config[{{$v->id}}][weight][2]"
  73. value="{{ $weights['type_2'] ?? '' }}"
  74. placeholder="{{ (($payTypes & 2) === 2) ? '0' : 'N/A' }}"
  75. {{ (($payTypes & 2) === 2) ? '' : 'disabled' }}>
  76. </td>
  77. <td>
  78. <input class="form-control form-control-sm" type="number" min="0"
  79. name="config[{{$v->id}}][weight][4]"
  80. value="{{ $weights['type_4'] ?? '' }}"
  81. placeholder="{{ (($payTypes & 4) === 4) ? '0' : 'N/A' }}"
  82. {{ (($payTypes & 4) === 4) ? '' : 'disabled' }}>
  83. </td>
  84. <td>
  85. <input class="form-control form-control-sm" type="number" min="0"
  86. name="config[{{$v->id}}][weight][8]"
  87. value="{{ $weights['type_8'] ?? '' }}"
  88. placeholder="{{ (($payTypes & 8) === 8) ? '0' : 'N/A' }}"
  89. {{ (($payTypes & 8) === 8) ? '' : 'disabled' }}>
  90. </td>
  91. <td>
  92. @component('components.select', [
  93. 'name' => "config[{$v->id}][status]",
  94. 'class' => $v->status == 1 ? 'btn-primary' : 'btn-danger',
  95. 'options' => [1 => __('auto.开启'), -1 => __('auto.关闭')],
  96. 'default' => $v->status])
  97. @endcomponent
  98. </td>
  99. </tr>
  100. @endforeach
  101. </tbody>
  102. </table>
  103. </div>
  104. <div class="mt-3">
  105. <button class="btn btn-sm btn-primary">{{ __('auto.提交') }}</button>
  106. </div>
  107. </form>
  108. </div>
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. </div>
  114. <script>
  115. (function () {
  116. var showClosed = false;
  117. var btn = document.getElementById('toggle-closed-btn');
  118. if (!btn) return;
  119. function renderRows() {
  120. var rows = document.querySelectorAll('tr[data-status]');
  121. for (var i = 0; i < rows.length; i++) {
  122. var row = rows[i];
  123. var status = parseInt(row.getAttribute('data-status') || '0', 10);
  124. if (!showClosed && status === -1) {
  125. row.style.display = 'none';
  126. } else {
  127. row.style.display = '';
  128. }
  129. }
  130. btn.textContent = showClosed ? '隐藏已关闭渠道' : '显示已关闭渠道';
  131. }
  132. btn.addEventListener('click', function () {
  133. showClosed = !showClosed;
  134. renderRows();
  135. });
  136. renderRows();
  137. })();
  138. </script>
  139. @endsection