| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- @extends('base.base')
- @section('base')
- <!-- 内容区域 -->
- <div class="main-panel">
- <div class="content-wrapper">
- <div class="page-header">
- <h3 class="page-title">
- <span class="page-title-icon bg-gradient-primary text-white mr-2">
- <i class="mdi mdi-settings"></i>
- </span>
- {{ __('auto.咖啡渠道修改') }}
- </h3>
- <nav aria-label="breadcrumb">
- <ol class="breadcrumb">
- <li class="breadcrumb-item"><a href="#">{{ __('auto.咖啡管理') }}</a></li>
- <li class="breadcrumb-item active" aria-current="page">{{ __('auto.咖啡渠道修改') }}</li>
- <li class="breadcrumb-item active" aria-current="page">{{ __('auto.查看渠道') }}</li>
- </ol>
- </nav>
- </div>
- <div class="row">
- <div class="col-lg-12 grid-margin stretch-card">
- <div class="card">
- <div class="card-body">
- <h4 class="card-title">{{ __('auto.查看渠道') }}</h4>
- <div class="mb-2">
- <button type="button" class="btn btn-sm btn-outline-secondary" id="toggle-closed-btn">
- 显示已关闭渠道
- </button>
- </div>
- <form action="" method="post" class="form-ajax">
- {!! csrf_field() !!}
- <div class="table-responsive">
- <table class="table table-bordered table-striped">
- <thead>
- <tr>
- <th style="min-width: 80px;">ID</th>
- <th style="min-width: 180px;">{{ __('auto.渠道名称') }}</th>
- <th style="min-width: 120px;">Cash(1)</th>
- <th style="min-width: 120px;">PayPal(2)</th>
- <th style="min-width: 120px;">Apple(4)</th>
- <th style="min-width: 120px;">Google(8)</th>
- <th style="min-width: 150px;">{{ __('auto.当前状态') }}</th>
- </tr>
- </thead>
- <tbody>
- @foreach($list as $k => $v)
- @php
- $remarks = [];
- if (!empty($v->remarks)) {
- $decoded = \GuzzleHttp\json_decode($v->remarks, true);
- if (is_array($decoded)) {
- $remarks = $decoded;
- }
- }
- $weights = $remarks['weight'] ?? ($remarks['weights'] ?? []);
- $payTypes = (int)($v->pay_types ?? 0);
- @endphp
- <tr data-status="{{ (int)$v->status }}">
- <td>{{ $v->id }}</td>
- <td>{{ $v->name }}</td>
- <input type="hidden" name="config[{{$v->id}}][sort]" value="{{$v->sort}}">
- <td>
- <input class="form-control form-control-sm" type="number" min="0"
- name="config[{{$v->id}}][weight][1]"
- value="{{ $weights['type_1'] ?? '' }}"
- placeholder="{{ (($payTypes & 1) === 1) ? '0' : 'N/A' }}"
- {{ (($payTypes & 1) === 1) ? '' : 'disabled' }}>
- </td>
- <td>
- <input class="form-control form-control-sm" type="number" min="0"
- name="config[{{$v->id}}][weight][2]"
- value="{{ $weights['type_2'] ?? '' }}"
- placeholder="{{ (($payTypes & 2) === 2) ? '0' : 'N/A' }}"
- {{ (($payTypes & 2) === 2) ? '' : 'disabled' }}>
- </td>
- <td>
- <input class="form-control form-control-sm" type="number" min="0"
- name="config[{{$v->id}}][weight][4]"
- value="{{ $weights['type_4'] ?? '' }}"
- placeholder="{{ (($payTypes & 4) === 4) ? '0' : 'N/A' }}"
- {{ (($payTypes & 4) === 4) ? '' : 'disabled' }}>
- </td>
- <td>
- <input class="form-control form-control-sm" type="number" min="0"
- name="config[{{$v->id}}][weight][8]"
- value="{{ $weights['type_8'] ?? '' }}"
- placeholder="{{ (($payTypes & 8) === 8) ? '0' : 'N/A' }}"
- {{ (($payTypes & 8) === 8) ? '' : 'disabled' }}>
- </td>
- <td>
- @component('components.select', [
- 'name' => "config[{$v->id}][status]",
- 'class' => $v->status == 1 ? 'btn-primary' : 'btn-danger',
- 'options' => [1 => __('auto.开启'), -1 => __('auto.关闭')],
- 'default' => $v->status])
- @endcomponent
- </td>
- </tr>
- @endforeach
- </tbody>
- </table>
- </div>
- <div class="mt-3">
- <button class="btn btn-sm btn-primary">{{ __('auto.提交') }}</button>
- </div>
- </form>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <script>
- (function () {
- var showClosed = false;
- var btn = document.getElementById('toggle-closed-btn');
- if (!btn) return;
- function renderRows() {
- var rows = document.querySelectorAll('tr[data-status]');
- for (var i = 0; i < rows.length; i++) {
- var row = rows[i];
- var status = parseInt(row.getAttribute('data-status') || '0', 10);
- if (!showClosed && status === -1) {
- row.style.display = 'none';
- } else {
- row.style.display = '';
- }
- }
- btn.textContent = showClosed ? '隐藏已关闭渠道' : '显示已关闭渠道';
- }
- btn.addEventListener('click', function () {
- showClosed = !showClosed;
- renderRows();
- });
- renderRows();
- })();
- </script>
- @endsection
|