fix: 保留OA审批汇总表一并追加表二 (#1299)

This commit is contained in:
yueyang 2026-11-20 10:43:49 +08:00
parent 556535d643
commit 3dbb09c5d2
4 changed files with 117 additions and 67 deletions

View File

@ -153,7 +153,7 @@ class ProcessDetailsPageData
$filters['payment_state'] = '';
unset($paginationQuery['payment_state']);
}
$result = $approvalSummaryDetailMode
$result = $approvalSummaryDetailMode && $request->ajax()
? $this->repository->paginate($filters, $page, $perPage)
: $this->repository->paginateApprovals($filters, $page, $perPage);

View File

@ -1548,11 +1548,6 @@
</div>
</details>
@if ($approvalSummaryDetailMode)
<div data-approval-summary-detail-host>
@include('business.pages.financial-operations.process-details-approval-detail')
</div>
@else
<div class="process-details-summary-panel" data-approval-summary-panel>
<div class="process-details-table-card">
<div class="process-details-table-wrap">
@ -1768,10 +1763,12 @@
<div
class="process-details-summary-detail-host"
data-approval-summary-detail-host
@if ($approvalSummaryDetailMode)
data-approval-summary-initial-view="detail"
@endif
hidden
></div>
@endif
@endif
</div>
<script>
@ -1950,11 +1947,6 @@
const detailTab = root?.querySelector('[data-approval-summary-detail-tab]');
if (!root || !summaryPanel || !detailHost || !summaryTab || !detailTab) return;
const countFormatter = new Intl.NumberFormat('zh-CN');
const moneyFormatter = new Intl.NumberFormat('zh-CN', {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
});
const originalSummary = {
rows: root.querySelector('[data-process-summary="rows"]')?.textContent || '0',
approvals: root.querySelector('[data-process-summary="approvals"]')?.textContent || '0',
@ -1973,15 +1965,6 @@
if (element) element.textContent = value;
};
const applyDetailSummary = () => {
const detail = detailHost.querySelector('[data-approval-summary-detail-page]');
if (!detail) return;
setSummaryValue('rows', countFormatter.format(Number(detail.dataset.summaryRows || 0)));
setSummaryValue('approvals', countFormatter.format(Number(detail.dataset.summaryApprovals || 0)));
setSummaryValue('amount', moneyFormatter.format(Number(detail.dataset.summaryAmount || 0)));
setSummaryValue('bank-amount', moneyFormatter.format(Number(detail.dataset.summaryBankAmount || 0)));
};
const restoreSummary = () => {
summaryPanel.hidden = false;
detailHost.hidden = true;
@ -2015,7 +1998,6 @@
})
.then((html) => {
detailHost.innerHTML = html;
applyDetailSummary();
if (pushHistory) {
window.history.pushState(
{ approvalSummaryView: 'detail' },
@ -2087,6 +2069,10 @@
}
showDetail(url.toString(), false);
});
if (detailHost.dataset.approvalSummaryInitialView === 'detail') {
showDetail(window.location.href, false);
}
})();
(() => {

View File

@ -397,7 +397,7 @@ class ProcessDetailsPageTest extends FeatureTestCase
->assertDontSee('表二 · 待付款明细');
}
public function test_approval_summary_detail_stays_inside_the_subpage(): void
public function test_approval_summary_detail_page_keeps_the_summary_table_visible(): void
{
$this->user->attachPermission(Permission::where('name', 'read-admin-panel')->firstOrFail());
@ -417,7 +417,7 @@ class ProcessDetailsPageTest extends FeatureTestCase
'payment_states' => ['待付款', '已付款'],
'current_approvers' => ['王五'],
]);
$repository->shouldReceive('paginate')->once()
$repository->shouldReceive('paginateApprovals')->once()
->with(Mockery::on(static fn (array $filters): bool =>
($filters['status'] ?? '') === '审批中'
&& ($filters['current_approver_name'] ?? '') === '王五'
@ -426,29 +426,11 @@ class ProcessDetailsPageTest extends FeatureTestCase
'data' => [
(object) [
'business_id' => '202611181944000459490',
'line_no' => 1,
'originator_department' => '财务中心',
'originator_name' => '陈阳',
'status' => '审批中',
'payment_state' => '待付款',
'current_approver_name' => '王五',
'current_task_started_at' => $startedAt,
'document_type' => '其他',
'purpose' => '待付款费用',
'invoice_title' => '江苏简尚品牌管理有限公司',
'cashier_payment_title' => '江苏简尚品牌管理有限公司',
'account_code' => '5602.04',
'account_name' => '管理费用_办公费',
'amount' => 880.00,
'bank_account_code' => '1002.01.001',
'bank_account_name' => '华夏银行-测试',
'bank_amount' => 0.00,
'payment_difference' => 880.00,
'payment_method' => '',
'paid_at' => '',
'payee_name' => '测试收款人',
'payee_bank_name' => '测试银行',
'payee_bank_account' => 'TEST-ACCOUNT-0001',
'amount_total' => 880.00,
'payment_amount_total' => 120.50,
],
],
'total' => 1,
@ -476,21 +458,21 @@ class ProcessDetailsPageTest extends FeatureTestCase
->assertOk()
->assertSee('表一 · 审批单汇总')
->assertSee('表二 · 费用明细')
->assertSee('data-approval-summary-detail-page', false)
->assertSee('返回表一')
->assertSee('data-approval-summary-panel', false)
->assertSee('data-approval-summary-initial-view="detail"', false)
->assertDontSee('data-approval-summary-detail-page', false)
->assertSee('showDetail(detailLink.href, false)', false)
->assertDontSee('summaryPanel.hidden = true', false)
->assertSee('202611181944000459490')
->assertSee('财务中心')
->assertSee('陈阳')
->assertSee('待付款费用')
->assertSee('880.00')
->assertSee('<th>发票抬头</th>', false)
->assertSee('<th>出纳打款抬头</th>', false)
->assertSee('<th class="num">付款差额</th>', false)
->assertSee('<th>收款人全称</th>', false)
->assertSee('<th>开户银行</th>', false)
->assertSee('<th>银行账号</th>', false)
->assertSee('测试收款人')
->assertSee('测试银行')
->assertSee('TEST-ACCOUNT-0001')
->assertSee('120.50')
->assertSee('<th>审批编号</th>', false)
->assertSee('<th>提交人</th>', false)
->assertSee('<th>用途</th>', false)
->assertSee('<th class="num">应付金额</th>', false)
->assertSee('<th class="num">实际付款</th>', false)
->assertSee(
'href="'
. e(url('/1/workspace/process-data/oa-process/approval-summary')
@ -519,10 +501,28 @@ class ProcessDetailsPageTest extends FeatureTestCase
'data' => [
(object) [
'business_id' => '202611181944000459490',
'line_no' => 1,
'originator_department' => '财务中心',
'originator_name' => '陈阳',
'current_approver_name' => '王五',
'status' => '审批中',
'payment_state' => '待付款',
'document_type' => '其他',
'purpose' => '待付款费用',
'invoice_title' => '江苏简尚品牌管理有限公司',
'cashier_payment_title' => '江苏简尚品牌管理有限公司',
'account_code' => '5602.04',
'account_name' => '管理费用_办公费',
'amount' => 100.0,
'bank_account_code' => '1002.01.001',
'bank_account_name' => '华夏银行-测试',
'bank_amount' => 0.0,
'payment_difference' => 100.0,
'payment_method' => '',
'paid_at' => '',
'payee_name' => '测试收款人',
'payee_bank_name' => '测试银行',
'payee_bank_account' => 'TEST-ACCOUNT-0001',
],
],
'total' => 1,
@ -553,6 +553,16 @@ class ProcessDetailsPageTest extends FeatureTestCase
->assertHeader('Cache-Control', 'no-store, private')
->assertSee('data-approval-summary-detail-page', false)
->assertSee('202611181944000459490')
->assertSee('陈阳')
->assertSee('<th>发票抬头</th>', false)
->assertSee('<th>出纳打款抬头</th>', false)
->assertSee('<th class="num">付款差额</th>', false)
->assertSee('<th>收款人全称</th>', false)
->assertSee('<th>开户银行</th>', false)
->assertSee('<th>银行账号</th>', false)
->assertSee('测试收款人')
->assertSee('测试银行')
->assertSee('TEST-ACCOUNT-0001')
->assertDontSee('data-oa-refresh-button', false);
}

View File

@ -295,7 +295,61 @@ class ProcessDetailsPageDataTest extends TestCase
$this->assertSame(1, $data['summary']['approvers']);
}
public function test_approval_summary_detail_uses_approval_detail_rows(): void
public function test_approval_summary_detail_page_uses_summary_rows_for_table_one(): void
{
$summaryRow = (object) [
'business_id' => '202601011200000000001',
'amount_total' => 800,
];
$repository = $this->createMock(DingProcessDetailMirrorRepository::class);
$repository->expects($this->once())
->method('filterOptions')
->willReturn([
'document_types' => [],
'statuses' => ['审批中'],
'payment_states' => ['待付款', '已付款'],
'current_approvers' => [],
]);
$repository->expects($this->once())
->method('paginateApprovals')
->willReturn([
'data' => [$summaryRow],
'total' => 1,
'summary' => [
'rows' => 1,
'approvals' => 1,
'amount_total' => 800,
'bank_amount_total' => 0,
],
'status' => 'succeeded',
'last_synced_at' => null,
'sync_stale' => false,
'sync_stale_after_minutes' => 15,
'scope' => 'personal_permission',
]);
$data = (new ProcessDetailsPageData($repository))->approvalSummaryPage(
Request::create(
'/1/workspace/process-data/oa-process/approval-summary',
'GET',
[
'status' => '审批中',
'approval_view' => 'detail',
'page' => 2,
],
),
);
$this->assertTrue($data['approvalSummaryMode']);
$this->assertTrue($data['approvalSummaryDetailMode']);
$this->assertSame($summaryRow, $data['processRows']->items()[0]);
$this->assertStringContainsString(
'approval_view=detail',
$data['processRows']->url(3),
);
}
public function test_approval_summary_detail_fragment_uses_approval_detail_rows(): void
{
$detailRow = (object) [
'business_id' => '202601011200000000001',
@ -337,17 +391,17 @@ class ProcessDetailsPageDataTest extends TestCase
'scope' => 'personal_permission',
]);
$data = (new ProcessDetailsPageData($repository))->approvalSummaryPage(
Request::create(
'/1/workspace/process-data/oa-process/approval-summary',
'GET',
[
'status' => '审批中',
'approval_view' => 'detail',
'page' => 2,
],
),
$request = Request::create(
'/1/workspace/process-data/oa-process/approval-summary',
'GET',
[
'status' => '审批中',
'approval_view' => 'detail',
'page' => 2,
],
);
$request->headers->set('X-Requested-With', 'XMLHttpRequest');
$data = (new ProcessDetailsPageData($repository))->approvalSummaryPage($request);
$this->assertTrue($data['approvalSummaryMode']);
$this->assertTrue($data['approvalSummaryDetailMode']);