优化功能
This commit is contained in:
@@ -2,57 +2,79 @@
|
||||
|
||||
@section('title', $item->exists ? '编辑分类' : '新建分类')
|
||||
|
||||
@section('head')
|
||||
@include('admin.partials.modern-form-head')
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="card">
|
||||
<div class="card modern-form-card">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<h3 class="card-title mb-0">{{ $item->exists ? '编辑分类' : '新建分类' }}</h3>
|
||||
<a class="btn btn-sm btn-outline-secondary" href="{{ route('admin.categories.index') }}">返回列表</a>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<p class="required-tip"><span class="required-star">*</span> 为必填项</p>
|
||||
|
||||
<form method="post" action="{{ $submitRoute }}" class="row g-3">
|
||||
@csrf
|
||||
@if($method !== 'POST') @method($method) @endif
|
||||
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">类型</label>
|
||||
<input class="form-control" list="categoryTypeList" name="type" value="{{ old('type', $item->type) }}" required placeholder="tool / model / news / guide">
|
||||
<datalist id="categoryTypeList">
|
||||
@foreach($typeOptions as $type)
|
||||
<option value="{{ $type }}"></option>
|
||||
@endforeach
|
||||
<option value="tool"></option>
|
||||
<option value="model"></option>
|
||||
<option value="news"></option>
|
||||
<option value="guide"></option>
|
||||
</datalist>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<section class="form-section">
|
||||
<h4 class="form-section-title">基础信息</h4>
|
||||
<p class="form-section-subtitle">分类会影响前台聚合页面展示,请优先保证类型与 slug 规范。</p>
|
||||
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">名称</label>
|
||||
<input class="form-control" name="name" value="{{ old('name', $item->name) }}" required>
|
||||
</div>
|
||||
<div class="row g-3">
|
||||
<div class="col-md-4 field-required">
|
||||
<label class="form-label">类型<span class="required-star">*</span></label>
|
||||
<input class="form-control" list="categoryTypeList" name="type" value="{{ old('type', $item->type) }}" required placeholder="tool / model / news / guide">
|
||||
<datalist id="categoryTypeList">
|
||||
@foreach($typeOptions as $type)
|
||||
<option value="{{ $type }}"></option>
|
||||
@endforeach
|
||||
</datalist>
|
||||
<div class="form-hint">必须与系统允许类型一致。</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Slug</label>
|
||||
<input class="form-control" name="slug" value="{{ old('slug', $item->slug) }}" required>
|
||||
<div class="col-md-4 field-required">
|
||||
<label class="form-label">名称<span class="required-star">*</span></label>
|
||||
<input class="form-control" name="name" value="{{ old('name', $item->name) }}" required>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4 field-required">
|
||||
<label class="form-label">Slug<span class="required-star">*</span></label>
|
||||
<input class="form-control" name="slug" value="{{ old('slug', $item->slug) }}" required>
|
||||
<div class="form-hint">默认由名称生成,可手动调整。</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<label class="form-label">描述</label>
|
||||
<textarea class="form-control" name="description" rows="3">{{ old('description', $item->description) }}</textarea>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<label class="form-check">
|
||||
<input class="form-check-input" type="checkbox" name="is_active" value="1" @checked(old('is_active', $item->is_active ?? true))>
|
||||
<span class="form-check-label">启用分类</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<label class="form-label">描述</label>
|
||||
<textarea class="form-control" name="description" rows="3">{{ old('description', $item->description) }}</textarea>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<label class="form-check">
|
||||
<input class="form-check-input" type="checkbox" name="is_active" value="1" @checked(old('is_active', $item->is_active ?? true))>
|
||||
<span class="form-check-label">启用分类</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<button class="btn btn-primary" type="submit">保存</button>
|
||||
<div class="editor-sticky-actions">
|
||||
<small class="text-muted">建议保持 slug 简短并避免重复。</small>
|
||||
<button class="btn btn-primary" type="submit">保存分类</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('scripts')
|
||||
@include('admin.partials.slug-autofill-script')
|
||||
@endsection
|
||||
|
||||
|
||||
@@ -2,9 +2,13 @@
|
||||
|
||||
@section('title', '分类管理')
|
||||
|
||||
@section('head')
|
||||
@include('admin.partials.modern-index-head')
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="card mb-3">
|
||||
<div class="card-body d-flex flex-column flex-lg-row gap-2 align-items-lg-center justify-content-between">
|
||||
<div class="card modern-index-toolbar mb-3">
|
||||
<div class="card-body d-flex flex-column flex-lg-row gap-3 align-items-lg-center justify-content-between">
|
||||
<form method="get" action="{{ route('admin.categories.index') }}" class="d-flex flex-column flex-md-row gap-2 w-100">
|
||||
<input class="form-control" type="text" name="q" value="{{ $filters['q'] ?? '' }}" placeholder="搜索分类名称 / Slug">
|
||||
<select class="form-select" name="type" style="max-width: 180px;">
|
||||
@@ -17,11 +21,14 @@
|
||||
</form>
|
||||
<a class="btn btn-success" href="{{ route('admin.categories.create') }}"><i class="bi bi-plus-circle me-1"></i>新建分类</a>
|
||||
</div>
|
||||
<div class="card-footer bg-transparent border-0 pt-0">
|
||||
<div class="toolbar-meta">共 {{ number_format($items->total()) }} 条分类记录</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card modern-index-card">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-vcenter card-table">
|
||||
<table class="table table-vcenter card-table modern-index-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>名称</th>
|
||||
@@ -36,8 +43,8 @@
|
||||
@forelse($items as $item)
|
||||
<tr>
|
||||
<td>
|
||||
<div class="fw-semibold">{{ $item->name }}</div>
|
||||
<div class="text-muted small">{{ $item->description ?: '-' }}</div>
|
||||
<div class="modern-index-title">{{ $item->name }}</div>
|
||||
<div class="modern-index-summary">{{ $item->description ?: '暂无描述' }}</div>
|
||||
</td>
|
||||
<td><span class="badge bg-indigo-lt text-indigo-fg">{{ $item->type }}</span></td>
|
||||
<td><code>{{ $item->slug }}</code></td>
|
||||
@@ -49,10 +56,14 @@
|
||||
@endif
|
||||
</td>
|
||||
<td>{{ $item->updated_at?->format('Y-m-d H:i') }}</td>
|
||||
<td class="text-end"><a class="btn btn-sm btn-outline-primary" href="{{ route('admin.categories.edit', $item) }}">编辑</a></td>
|
||||
<td class="text-end">
|
||||
<a class="btn btn-sm btn-outline-primary" href="{{ route('admin.categories.edit', $item) }}">编辑</a>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr><td colspan="6" class="text-center text-muted py-4">暂无分类数据</td></tr>
|
||||
<tr>
|
||||
<td colspan="6" class="text-center text-muted py-5">暂无分类数据,先新增一条内容吧。</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -60,3 +71,4 @@
|
||||
<div class="card-footer">{{ $items->links() }}</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
|
||||
Reference in New Issue
Block a user