144 lines
7.7 KiB
PHP

@php
$edgeData = $edgeBanding ?? [];
$result = $edgeData['result'] ?? ['data' => [], 'total' => 0, 'totals' => []];
$rows = $result['data'] ?? [];
$totals = $result['totals'] ?? [];
$filters = $edgeData['filters'] ?? [];
$period = $filters['period'] ?? '2026-06';
[$periodYear, $periodMonth] = array_pad(explode('-', $period, 2), 2, '');
$periodTitle = ctype_digit($periodYear) && ctype_digit($periodMonth)
? $periodYear . '年公司应付封边条厂' . (int) $periodMonth . '月份货款'
: '公司应付封边条厂货款';
$total = (int) ($result['total'] ?? 0);
$currentPage = (int) ($edgeData['page'] ?? 1);
$lastPage = (int) ($edgeData['last_page'] ?? 1);
$error = $edgeData['error'] ?? null;
$money = static fn ($value) => $value === null || $value === '' ? '-' : number_format((float) $value, 2);
@endphp
<div class="edge-banding-page">
@include('business.pages.edge-banding-materials._styles')
@if ($error)
<div class="edge-banding-alert" role="alert">
<span class="material-icons-outlined" aria-hidden="true">error_outline</span>
<span>{{ $error }}</span>
</div>
@endif
<form class="edge-banding-toolbar" method="get" action="{{ request()->url() }}" aria-label="封边条应付筛选">
<div class="edge-banding-field">
<label for="edge-payables-period">应付月份</label>
<input id="edge-payables-period" name="period" type="month" value="{{ $period }}">
</div>
<div class="edge-banding-field">
<label for="edge-payables-supplier">供货单位</label>
<input id="edge-payables-supplier" name="supplier" type="text" value="{{ $filters['supplier'] ?? '' }}" placeholder="请输入供货单位">
</div>
<div class="edge-banding-actions">
<button class="edge-banding-button edge-banding-button--primary" type="submit">
<span class="material-icons-outlined" aria-hidden="true">search</span>
<span>查询</span>
</button>
<a class="edge-banding-button" href="{{ request()->url() }}" title="恢复默认月份并清除筛选条件">
<span class="material-icons-outlined" aria-hidden="true">refresh</span>
<span>重置</span>
</a>
</div>
</form>
<div class="edge-banding-table-card">
<div class="edge-banding-table-scroll">
<table class="edge-banding-table edge-banding-table--payables">
<thead>
<tr>
<th colspan="13">{{ $periodTitle }}</th>
</tr>
<tr>
<th rowspan="2">序号</th>
<th rowspan="2">供货单位</th>
<th rowspan="2">月初未付</th>
<th>加</th>
<th>加</th>
<th>减</th>
<th>加</th>
<th aria-hidden="true"></th>
<th aria-hidden="true"></th>
<th>单位:元</th>
<th aria-hidden="true"></th>
<th aria-hidden="true"></th>
<th rowspan="2">备注</th>
</tr>
<tr>
<th>货款</th>
<th>代垫付运费</th>
<th>赔付</th>
<th>封边条厂家回款</th>
<th>应付金额</th>
<th>已付金额</th>
<th>实际打款金额</th>
<th>对私打款</th>
<th>对公打款</th>
</tr>
</thead>
<tbody>
@forelse ($rows as $index => $row)
<tr>
<td>{{ (($currentPage - 1) * ($edgeData['limit'] ?? 25)) + $index + 1 }}</td>
<td>{{ $row['supplier'] ?: '-' }}</td>
<td>{{ $money($row['month_start_unpaid'] ?? null) }}</td>
<td>{{ $money($row['goods_amount'] ?? null) }}</td>
<td>{{ $money($row['prepaid_freight'] ?? null) }}</td>
<td>{{ $money($row['compensation'] ?? null) }}</td>
<td>{{ $money($row['supplier_refund'] ?? null) }}</td>
<td>{{ $money($row['payable_amount'] ?? null) }}</td>
<td>{{ $money($row['paid_amount'] ?? null) }}</td>
<td>{{ $money($row['actual_payment'] ?? null) }}</td>
<td>{{ $money($row['private_payment'] ?? null) }}</td>
<td>{{ $money($row['corporate_payment'] ?? null) }}</td>
<td>{{ $row['remark'] ?: '-' }}</td>
</tr>
@empty
<tr class="is-empty">
<td colspan="13">{{ $error ? '数据源暂不可用' : '当前月份没有匹配的封边条应付数据' }}</td>
</tr>
@endforelse
</tbody>
<tfoot>
<tr>
<td>合计</td>
<td></td>
<td>{{ $money($totals['month_start_unpaid'] ?? null) }}</td>
<td>{{ $money($totals['goods_amount'] ?? null) }}</td>
<td>{{ $money($totals['prepaid_freight'] ?? null) }}</td>
<td>{{ $money($totals['compensation'] ?? null) }}</td>
<td>{{ $money($totals['supplier_refund'] ?? null) }}</td>
<td>{{ $money($totals['payable_amount'] ?? null) }}</td>
<td>{{ $money($totals['paid_amount'] ?? null) }}</td>
<td>{{ $money($totals['actual_payment'] ?? null) }}</td>
<td>{{ $money($totals['private_payment'] ?? null) }}</td>
<td>{{ $money($totals['corporate_payment'] ?? null) }}</td>
<td>{{ (float) ($totals['private_payment'] ?? 0) === 0.0 ? '全部对公' : '-' }}</td>
</tr>
</tfoot>
</table>
</div>
<div class="edge-banding-pagination">
<span>共 {{ number_format($total) }} 条记录</span>
<div class="edge-banding-pagination__controls" aria-label="应付数据分页">
@if ($currentPage <= 1)
<span class="edge-banding-button is-disabled" aria-disabled="true" title="上一页"><span class="material-icons-outlined" aria-hidden="true">chevron_left</span></span>
@else
<a class="edge-banding-button" href="{{ request()->fullUrlWithQuery(['data_page' => $currentPage - 1]) }}" aria-label="上一页" title="上一页"><span class="material-icons-outlined" aria-hidden="true">chevron_left</span></a>
@endif
<span>第 {{ $currentPage }} / {{ max($lastPage, 1) }} 页</span>
@if ($currentPage >= $lastPage)
<span class="edge-banding-button is-disabled" aria-disabled="true" title="下一页"><span class="material-icons-outlined" aria-hidden="true">chevron_right</span></span>
@else
<a class="edge-banding-button" href="{{ request()->fullUrlWithQuery(['data_page' => $currentPage + 1]) }}" aria-label="下一页" title="下一页"><span class="material-icons-outlined" aria-hidden="true">chevron_right</span></a>
@endif
</div>
</div>
</div>
</div>