修复:去掉多余的 @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:
@@ -402,19 +402,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
@endsection
|
|
||||||
|
|
||||||
@push('scripts')
|
{{-- inlinePatch:职务列表内联编辑 Alpine 工厂函数(失焦/回车自动 PATCH 保存) --}}
|
||||||
<script>
|
<script>
|
||||||
/**
|
|
||||||
* inlinePatch - 职务列表内联编辑 Alpine 工厂函数
|
|
||||||
* 失焦或回车时自动 PATCH 保存单个字段到后端
|
|
||||||
*
|
|
||||||
* @param {number} positionId - 职务 ID
|
|
||||||
* @param {string} field - 要更新的字段名
|
|
||||||
* @param {number|null} initial - 初始值(null = 不限)
|
|
||||||
*/
|
|
||||||
function inlinePatch(positionId, field, initial) {
|
function inlinePatch(positionId, field, initial) {
|
||||||
return {
|
return {
|
||||||
val: initial, // null = 显示为空(placeholder "不限")
|
val: initial, // null = 显示为空(placeholder "不限")
|
||||||
@@ -429,15 +419,14 @@
|
|||||||
this.error = '';
|
this.error = '';
|
||||||
try {
|
try {
|
||||||
const body = {};
|
const body = {};
|
||||||
// 空字符串清空时发 null(=不限)
|
// 空字符串/null → 发 null(=不限)
|
||||||
body[field] = this.val === '' || this.val === null ? null : Number(this.val);
|
body[field] = (this.val === '' || this.val === null) ? null : Number(this.val);
|
||||||
|
|
||||||
const res = await fetch(`/admin/positions/${positionId}/patch`, {
|
const res = await fetch(`/admin/positions/${positionId}/patch`, {
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'X-CSRF-TOKEN': document.querySelector('meta[name=csrf-token]')?.content ||
|
'X-CSRF-TOKEN': document.querySelector('meta[name=csrf-token]')?.content || '',
|
||||||
'{{ csrf_token() }}',
|
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
},
|
},
|
||||||
body: JSON.stringify(body),
|
body: JSON.stringify(body),
|
||||||
@@ -459,4 +448,5 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|||||||
Reference in New Issue
Block a user