From 234d225e0221ebf8e1cc6da450de81454e265f5e Mon Sep 17 00:00:00 2001
From: shanshi <3316401569@qq.com>
Date: Wed, 21 Oct 2026 14:13:49 +0800
Subject: [PATCH] =?UTF-8?q?=E8=B4=A2=E5=8A=A1=E5=8F=B0=E8=B4=A6=EF=BC=9A?=
=?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BC=96=E8=BE=91=E6=A8=A1=E5=BC=8F=E5=BC=80?=
=?UTF-8?q?=E5=85=B3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../pages/financial-ledger/ledger.blade.php | 48 +++++++++++++++++--
.../FinanceLedgerAccountStatusTest.php | 13 +++++
2 files changed, 57 insertions(+), 4 deletions(-)
diff --git a/resources/views/business/pages/financial-ledger/ledger.blade.php b/resources/views/business/pages/financial-ledger/ledger.blade.php
index f85c14e6..df2880b3 100644
--- a/resources/views/business/pages/financial-ledger/ledger.blade.php
+++ b/resources/views/business/pages/financial-ledger/ledger.blade.php
@@ -5,6 +5,7 @@
$canEdit = (bool) ($ledgerCanEditMapping ?? false);
$canEditAccountStatus = (bool) ($ledgerCanEditAccountStatus ?? false);
$canEditAccountType = (bool) ($ledgerCanEditAccountType ?? false);
+ $canEditAccounts = $canEditAccountStatus || $canEditAccountType;
$accountStatusOptions = $ledgerAccountStatusOptions ?? \App\Utilities\FinanceLedgerAccountStatus::OPTIONS;
$accountFilterOptions = $ledgerAccountFilterOptions ?? ['regions' => [], 'types' => []];
$accountTypeOptions = $accountFilterOptions['types'] ?? [];
@@ -45,6 +46,18 @@
.ledger-field input, .ledger-field select { height:2.15rem; padding:0 .6rem; border:1px solid var(--vip-border, #D8D2C7); border-radius:.45rem; background:#fff; color:var(--vip-content-ink, #171717); font:inherit; }
.ledger-field input:focus, .ledger-field select:focus { border-color:var(--vip-content-accent-dark, #856632); outline:none; box-shadow:0 0 0 3px rgba(133,102,50,.16); }
.ledger-actions { display:flex; gap:.45rem; padding-bottom:.05rem; }
+ .ledger-edit-switch { position:relative; display:inline-flex; align-items:center; align-self:flex-end; gap:.45rem; height:2.15rem; padding:0 .65rem; border:1px solid var(--vip-border, #D8D2C7); border-radius:.45rem; background:#fff; color:var(--vip-content-muted, #595959); font-size:.72rem; font-weight:600; cursor:pointer; user-select:none; white-space:nowrap; }
+ .ledger-edit-switch input { position:absolute; width:1px; height:1px; opacity:0; pointer-events:none; }
+ .ledger-edit-switch__track { position:relative; width:2.15rem; height:1.2rem; border-radius:999px; background:#d6d0c5; transition:background .16s ease; }
+ .ledger-edit-switch__thumb { position:absolute; top:.15rem; left:.15rem; width:.9rem; height:.9rem; border-radius:50%; background:#fff; box-shadow:0 1px 2px rgba(23,23,23,.2); transition:transform .16s ease; }
+ .ledger-edit-switch input:checked + .ledger-edit-switch__track { background:var(--vip-content-accent-dark, #856632); }
+ .ledger-edit-switch input:checked + .ledger-edit-switch__track .ledger-edit-switch__thumb { transform:translateX(.95rem); }
+ .ledger-edit-switch input:focus-visible + .ledger-edit-switch__track { outline:2px solid var(--vip-content-accent-dark, #856632); outline-offset:2px; }
+ .ledger-edit-switch:has(input:checked) { border-color:var(--vip-content-accent-dark, #856632); background:var(--vip-content-accent-soft, #F7F0DE); color:var(--vip-content-accent-dark, #856632); }
+ .ledger-edit-switch.is-disabled { cursor:not-allowed; opacity:.55; }
+ #ledger-panel-accounts .ledger-account-editor { display:none; }
+ #ledger-panel-accounts.is-account-edit-mode .ledger-account-readonly { display:none; }
+ #ledger-panel-accounts.is-account-edit-mode .ledger-account-editor { display:block; }
.ledger-btn { display:inline-flex; align-items:center; justify-content:center; gap:.35rem; height:2.15rem; padding:0 .8rem; border:1px solid var(--vip-border, #D8D2C7); border-radius:.45rem; background:#fff; color:var(--vip-content-ink, #171717); font:inherit; font-weight:600; text-decoration:none; cursor:pointer; white-space:nowrap; }
.ledger-btn:hover { border-color:var(--vip-content-accent-dark, #856632); color:var(--vip-content-accent-dark, #856632); }
.ledger-btn.primary { border-color:var(--vip-content-accent-dark, #856632); background:var(--vip-content-accent-dark, #856632); color:#fff; }
@@ -178,6 +191,11 @@
@if ($activeAccountFilterCount > 0)
filter_alt筛选中{{ $activeAccountFilterCount }}
@endif
+
@@ -205,25 +223,27 @@
{{ $row->account_short }} |
@if ($canEditAccountType)
- |
@if ($canEditAccountStatus)
-
+ {{ $accountStatusOptions[$row->account_status] ?? '正常' }}
+
@foreach ($accountStatusOptions as $statusCode => $statusLabel)
@endforeach
@else
- {{ $accountStatusOptions[$row->account_status] ?? '正常' }}
+ {{ $accountStatusOptions[$row->account_status] ?? '正常' }}
@endif
|
{{ $row->region }} | {{ $row->account_no }} | {{ $row->bank_name }} | {{ $row->bank_city_branch }} |
@@ -415,6 +435,19 @@
});
const accountPanel = page.querySelector('#ledger-panel-accounts');
+ const accountEditToggle = page.querySelector('[data-ledger-edit-mode-toggle]');
+ const applyAccountEditMode = (enabled) => {
+ const active = Boolean(enabled && accountEditToggle && !accountEditToggle.disabled);
+ accountPanel?.classList.toggle('is-account-edit-mode', active);
+ accountPanel?.querySelectorAll('[data-account-editor]').forEach((editor) => {
+ editor.disabled = !active;
+ });
+ accountEditToggle?.setAttribute('aria-checked', active ? 'true' : 'false');
+ };
+ accountEditToggle?.addEventListener('change', () => {
+ applyAccountEditMode(accountEditToggle.checked);
+ notify(accountEditToggle.checked ? '编辑模式已开启' : '编辑模式已关闭');
+ });
const accountColumnPicker = page.querySelector('[data-ledger-column-picker]');
const accountColumnPanel = accountColumnPicker?.querySelector('[data-ledger-column-panel]');
const accountColumnOptions = accountColumnPicker?.querySelector('[data-ledger-column-options]');
@@ -749,6 +782,11 @@
item.value = value;
item.dataset.previousValue = value;
if (field === 'status') item.dataset.status = value;
+ const display = item.closest('td')?.querySelector('[data-account-edit-display]');
+ if (display) {
+ display.textContent = payload.label || (value || '未填写');
+ if (field === 'status') display.dataset.status = value;
+ }
});
notify(successLabel + ':' + (payload.label || ''));
} catch (error) {
@@ -764,6 +802,7 @@
};
bindInlineAccountSelect('[data-account-status]', 'status', '账户状态已保存');
bindInlineAccountSelect('[data-account-type]', 'account_type', '账户类型已保存');
+ applyAccountEditMode(accountEditToggle?.checked === true);
let accountPageRequest = null;
const bindAccountPagination = () => {
@@ -825,6 +864,7 @@
}
bindInlineAccountSelect('[data-account-status]', 'status', '账户状态已保存');
bindInlineAccountSelect('[data-account-type]', 'account_type', '账户类型已保存');
+ applyAccountEditMode(accountEditToggle?.checked === true);
applyAccountColumnLayout();
bindAccountPagination();
notify(targetPage ? '已加载第 ' + targetPage + ' 页' : '下一页已加载');
diff --git a/tests/Feature/Business/FinanceLedgerAccountStatusTest.php b/tests/Feature/Business/FinanceLedgerAccountStatusTest.php
index 7e9c7a85..3111d229 100644
--- a/tests/Feature/Business/FinanceLedgerAccountStatusTest.php
+++ b/tests/Feature/Business/FinanceLedgerAccountStatusTest.php
@@ -3,6 +3,7 @@
namespace Tests\Feature\Business;
use App\Models\Auth\Permission;
+use App\Models\Auth\Role;
use Illuminate\Support\Facades\DB;
use Tests\Feature\FeatureTestCase;
@@ -78,6 +79,10 @@ class FinanceLedgerAccountStatusTest extends FeatureTestCase
->assertSee('1 / 1', false)
->assertSee('data-ledger-column-picker', false)
->assertSee('data-ledger-column-panel', false)
+ ->assertSee('data-ledger-edit-mode-toggle', false)
+ ->assertSee('aria-checked="false"', false)
+ ->assertSee('ledger-account-editor', false)
+ ->assertSee('data-account-edit-display', false)
->assertSee('列设置')
->assertSee('拖动字段可调整列顺序')
->assertSee('恢复默认')
@@ -325,8 +330,16 @@ class FinanceLedgerAccountStatusTest extends FeatureTestCase
'created_from' => 'core::test',
]);
$viewer->companies()->attach($this->company->id);
+ $viewer->roles()->attach(Role::where('name', 'user')->firstOrFail()->id);
$viewer->attachPermission(Permission::where('name', 'read-admin-panel')->firstOrFail());
+ $this->loginAs($viewer)->get($this->pageUrl())
+ ->assertOk()
+ ->assertSee('data-ledger-edit-mode-toggle', false)
+ ->assertSee('当前账号没有财务台账编辑权限')
+ ->assertDontSee('data-account-status data-account-short', false)
+ ->assertDontSee('data-account-type data-account-short', false);
+
$this->withExceptionHandling()->loginAs($viewer)->postJson($this->statusUrl(), [
'account_short' => '测试账户',
'status' => 'limited',
--
2.47.2