diff --git a/modules/EcommerceFinance/View/FinanceLedgerPageData.php b/modules/EcommerceFinance/View/FinanceLedgerPageData.php index 9906b8e3..3f68649e 100644 --- a/modules/EcommerceFinance/View/FinanceLedgerPageData.php +++ b/modules/EcommerceFinance/View/FinanceLedgerPageData.php @@ -58,6 +58,8 @@ class FinanceLedgerPageData 'ledgerMeta' => $this->meta(), 'ledgerAccountOptions' => $this->accountOptions(), 'ledgerManualTransactionAccountOptions' => $this->manualTransactionAccountOptions(), + 'ledgerTransactionAccountHeaderOptions' => $this->transactionAccountHeaderOptions(), + 'ledgerTransactionDateHeaderOptions' => $this->transactionDateHeaderOptions(), 'ledgerAccountFilterOptions' => $this->accountFilterOptions(), 'ledgerAccountStatusOptions' => FinanceLedgerAccountStatus::OPTIONS, 'ledgerAccountPlanOptions' => $this->accountPlanOptions(), @@ -367,6 +369,40 @@ class FinanceLedgerPageData ->selectRaw($effectiveAccount . ' AS effective_account_short'); } + private function transactionAccountHeaderOptions(): array + { + $effectiveAccount = $this->transactionHeaderColumns()['effective_account_short']['sort']; + + return $this->db()->table('fin_transactions as t') + ->leftJoin('fin_account_map as m', function ($join): void { + $join->on('m.source', '=', 't.source') + ->on('m.source_value', '=', 't.source_value'); + }) + ->selectRaw($effectiveAccount . ' AS filter_value') + ->distinct() + ->orderBy('filter_value') + ->pluck('filter_value') + ->map(static fn (mixed $value): string => trim((string) $value)) + ->filter() + ->unique() + ->mapWithKeys(static fn (string $value): array => [$value => $value]) + ->all(); + } + + private function transactionDateHeaderOptions(): array + { + return $this->db()->table('fin_transactions') + ->select('txn_date') + ->distinct() + ->orderByDesc('txn_date') + ->pluck('txn_date') + ->map(static fn (mixed $value): string => (string) $value) + ->filter() + ->unique() + ->mapWithKeys(static fn (string $value): array => [$value => $value]) + ->all(); + } + private function mapping(): array { $query = $this->db()->table('fin_account_map'); diff --git a/resources/views/business/pages/financial-ledger/ledger.blade.php b/resources/views/business/pages/financial-ledger/ledger.blade.php index f02e2057..97d03f2a 100644 --- a/resources/views/business/pages/financial-ledger/ledger.blade.php +++ b/resources/views/business/pages/financial-ledger/ledger.blade.php @@ -56,6 +56,8 @@ $tabUrl = static fn (string $tab): string => $ledgerPageUrl . '?' . http_build_query(['tab' => $tab]); $sourceLabels = ['dingtalk' => '钉钉审批', 'shop' => '店铺提现', 'payable' => '供应商应付', 'store' => '店铺开店', 'workorder' => '聚工单', 'manual' => '手工录入']; $manualTransactionAccountOptions = $ledgerManualTransactionAccountOptions ?? []; + $transactionAccountHeaderOptions = $ledgerTransactionAccountHeaderOptions ?? []; + $transactionDateHeaderOptions = $ledgerTransactionDateHeaderOptions ?? []; $optionMap = static fn (array $values): array => array_combine($values, $values) ?: []; $ledgerHeaderPreserve = []; foreach (array_keys($tabs) as $tabKey) { @@ -120,8 +122,8 @@ ['remark', '异常/备注', 'text'], ], 'transactions' => [ - ['txn_date', '日期', 'date'], - ['effective_account_short', '账户简称', 'text'], + ['txn_date', '日期', 'date', ['options' => $transactionDateHeaderOptions]], + ['effective_account_short', '账户简称', 'enum', ['options' => $transactionAccountHeaderOptions]], ['detail', '明细', 'text'], ['source', '来源', 'enum', ['options' => $sourceLabels]], ['income', '收入', 'number', ['headerClass' => 'num', 'align' => 'end']], @@ -262,6 +264,8 @@ .ledger-table th:first-child { z-index:3; background:var(--vip-content-accent-soft, #F7F0DE); } .ledger-table tr:hover td:first-child { background:#fcfaf4; } .ledger-table td.num, .ledger-table th.num { text-align:right; font-variant-numeric:tabular-nums; } + #ledger-panel-transactions .ledger-transaction-row td { height:2.45rem; vertical-align:middle; } + #ledger-panel-transactions .ledger-transaction-row td.wrap { min-width:0; max-width:none; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; } .ledger-manual-trigger-row td { position:static !important; padding:.18rem .45rem; background:#fbf8f0; } .ledger-manual-trigger { display:inline-flex; align-items:center; gap:.35rem; height:1.75rem; padding:0 .55rem; border:0; border-radius:.35rem; background:transparent; color:var(--vip-content-accent-dark, #856632); font:inherit; font-size:.7rem; font-weight:700; cursor:pointer; } .ledger-manual-trigger:hover { background:var(--vip-content-accent-soft, #F7F0DE); } @@ -583,7 +587,7 @@ {{-- 动账明细 --}} -