config.blade.php 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. @foreach(config('payment.methods', []) as $methodKey => $method)
  40. <th style="min-width: 120px;">{{ $method['name'] }}({{ $methodKey }})</th>
  41. @endforeach
  42. <th style="min-width: 150px;">{{ __('auto.当前状态') }}</th>
  43. </tr>
  44. </thead>
  45. <tbody>
  46. @foreach($list as $k => $v)
  47. @php
  48. $remarks = [];
  49. if (!empty($v->remarks)) {
  50. $decoded = \GuzzleHttp\json_decode($v->remarks, true);
  51. if (is_array($decoded)) {
  52. $remarks = $decoded;
  53. }
  54. }
  55. $weights = $remarks['weight'] ?? ($remarks['weights'] ?? []);
  56. $payTypes = (int)($v->pay_types ?? 0);
  57. $payRate = config('pay.' . ($v->config_key ?? '') . '.pay_rate', []);
  58. $rateText = function ($method) use ($payRate) {
  59. $methodRate = $payRate[$method] ?? null;
  60. if (is_array($methodRate) && count($methodRate) >= 2) {
  61. return $methodRate[0] . '%+' . $methodRate[1];
  62. }
  63. return '-';
  64. };
  65. @endphp
  66. <tr data-status="{{ (int)$v->status }}">
  67. <td>{{ $v->id }}</td>
  68. <td>{{ $v->name }}</td>
  69. <input type="hidden" name="config[{{$v->id}}][sort]" value="{{$v->sort}}">
  70. @foreach(config('payment.methods', []) as $methodKey => $method)
  71. <td>
  72. <div style="display:flex; align-items:center; gap:6px;">
  73. <input class="form-control form-control-sm" type="number" min="0"
  74. style="width:72px;"
  75. name="config[{{$v->id}}][weight][{{ $methodKey }}]"
  76. value="{{ $weights['type_' . $methodKey] ?? '' }}"
  77. placeholder="{{ (($payTypes & $methodKey) === $methodKey) ? '0' : 'N/A' }}"
  78. {{ (($payTypes & $methodKey) === $methodKey) ? '' : 'disabled' }}>
  79. <small style="white-space:nowrap; color:#495057; font-size:13px;">{{ $rateText($methodKey) }}</small>
  80. </div>
  81. </td>
  82. @endforeach
  83. <td>
  84. @component('components.select', [
  85. 'name' => "config[{$v->id}][status]",
  86. 'class' => $v->status == 1 ? 'btn-primary' : 'btn-danger',
  87. 'options' => [1 => __('auto.开启'), -1 => __('auto.关闭')],
  88. 'default' => $v->status])
  89. @endcomponent
  90. </td>
  91. </tr>
  92. @endforeach
  93. </tbody>
  94. </table>
  95. </div>
  96. <div class="mt-3">
  97. <button class="btn btn-sm btn-primary">{{ __('auto.提交') }}</button>
  98. </div>
  99. </form>
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. </div>
  106. <script>
  107. (function () {
  108. var showClosed = false;
  109. var btn = document.getElementById('toggle-closed-btn');
  110. if (!btn) return;
  111. function renderRows() {
  112. var rows = document.querySelectorAll('tr[data-status]');
  113. for (var i = 0; i < rows.length; i++) {
  114. var row = rows[i];
  115. var status = parseInt(row.getAttribute('data-status') || '0', 10);
  116. if (!showClosed && status === -1) {
  117. row.style.display = 'none';
  118. } else {
  119. row.style.display = '';
  120. }
  121. }
  122. btn.textContent = showClosed ? '隐藏已关闭渠道' : '显示已关闭渠道';
  123. }
  124. btn.addEventListener('click', function () {
  125. showClosed = !showClosed;
  126. renderRows();
  127. });
  128. renderRows();
  129. })();
  130. </script>
  131. @endsection