修复:去掉多余的 @section 导致的 section 嵌套报错

将 inlinePatch script 块迁移回 @section('content') 内部,
彻底移除 @push/@endpush/@section('scripts') 等无效指令。

根本原因:admin layout 无 @yield('scripts'),在 @endsection 后
再开 @push 或 @section 会触发 'Cannot end a section' 异常。
This commit is contained in:
2026-03-01 11:30:23 +08:00
parent 89d93c92ed
commit 57f515e2eb
@@ -402,19 +402,9 @@
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
{{-- inlinePatch:职务列表内联编辑 Alpine 工厂函数(失焦/回车自动 PATCH 保存) --}}
<script>
/**
* inlinePatch - 职务列表内联编辑 Alpine 工厂函数
* 失焦或回车时自动 PATCH 保存单个字段到后端
*
* @param {number} positionId - 职务 ID
* @param {string} field - 要更新的字段名
* @param {number|null} initial - 初始值(null = 不限)
*/
function inlinePatch(positionId, field, initial) {
return {
val: initial, // null = 显示为空(placeholder "不限"
@@ -429,15 +419,14 @@
this.error = '';
try {
const body = {};
// 空字符串清空时发 null=不限)
body[field] = this.val === '' || this.val === null ? null : Number(this.val);
// 空字符串/null → 发 null=不限)
body[field] = (this.val === '' || this.val === null) ? null : Number(this.val);
const res = await fetch(`/admin/positions/${positionId}/patch`, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': document.querySelector('meta[name=csrf-token]')?.content ||
'{{ csrf_token() }}',
'X-CSRF-TOKEN': document.querySelector('meta[name=csrf-token]')?.content || '',
'Accept': 'application/json',
},
body: JSON.stringify(body),
@@ -459,4 +448,5 @@
};
}
</script>
</div>
@endsection