修正非京喜退款两行对照表头 #35

Merged
renshen merged 1 commits from fix/renshen-refund-two-row-headers into main 2026-08-12 17:00:28 +08:00
2 changed files with 88 additions and 73 deletions

View File

@ -1,38 +1,38 @@
@php
$columns = [
'Id',
'refundDate',
'as_id',
'outer_as_id',
'o_id',
'',
'so_id',
'type',
'node',
'isZC',
'shop_name',
'platform',
'responsibleDepartment',
'totalRefundMoney',
'originPostcode',
'shop_i_i_id',
'shop_sku_id',
'i_id',
'sku_id',
'buyer_paid_amount',
'qty',
'unitCostGoods',
'detailRefundMoney',
'refundType',
'refundQty',
'refundCostGoods',
'RefundMoneyIncome',
'AfSalesMoney',
'createTime',
'status',
'shop_status',
'created',
'confirm_date',
['label' => '序号/主键ID', 'field' => 'Id'],
['label' => '退款日期', 'field' => 'refundDate'],
['label' => '售后单ID', 'field' => 'as_id'],
['label' => '外部售后单号', 'field' => 'outer_as_id'],
['label' => '订单ID', 'field' => 'o_id'],
['label' => '', 'field' => ''],
['label' => '子订单ID', 'field' => 'so_id'],
['label' => '类型', 'field' => 'type'],
['label' => '节点', 'field' => 'node'],
['label' => '是否自营', 'field' => 'isZC'],
['label' => '店铺名称', 'field' => 'shop_name'],
['label' => '平台', 'field' => 'platform'],
['label' => '责任部门', 'field' => 'responsibleDepartment'],
['label' => '退款总金额', 'field' => 'totalRefundMoney'],
['label' => '原始邮编', 'field' => 'originPostcode'],
['label' => '店铺商品ID', 'field' => 'shop_i_id'],
['label' => '店铺SKU编码', 'field' => 'shop_sku_id'],
['label' => '商品ID', 'field' => 'i_id'],
['label' => 'SKU编码', 'field' => 'sku_id'],
['label' => '买家实付金额', 'field' => 'buyer_paid_amount'],
['label' => '数量', 'field' => 'qty'],
['label' => '商品单位成本', 'field' => 'unitCostGoods'],
['label' => '明细退款金额', 'field' => 'detailRefundMoney'],
['label' => '退款类型', 'field' => 'refundType'],
['label' => '退款数量', 'field' => 'refundQty'],
['label' => '退款商品成本', 'field' => 'refundCostGoods'],
['label' => '退款回款金额', 'field' => 'RefundMoneyIncome'],
['label' => '售后金额', 'field' => 'AfSalesMoney'],
['label' => '创建时间', 'field' => 'createTime'],
['label' => '状态', 'field' => 'status'],
['label' => '店铺状态', 'field' => 'shop_status'],
['label' => '创建记录/创建时间', 'field' => 'created'],
['label' => '确认日期', 'field' => 'confirm_date'],
];
@endphp
@ -41,15 +41,25 @@
<style>
.refund-data-table--wide { min-width: 150rem; }
.refund-data-table__field-row th {
background: var(--vip-surface, #ffffff);
color: var(--vip-content-muted, #595959);
font-weight: 400;
}
</style>
<div class="upstream-data-table-panel">
<div class="upstream-data-table-scroll">
<table class="upstream-data-table refund-data-table refund-data-table--wide" aria-label="非京喜退款数据">
<thead>
<tr>
<tr data-header-row="labels">
@foreach ($columns as $column)
<th>{{ $column }}</th>
<th scope="col">{{ $column['label'] }}</th>
@endforeach
</tr>
<tr class="refund-data-table__field-row" data-header-row="fields">
@foreach ($columns as $column)
<th scope="col">{{ $column['field'] }}</th>
@endforeach
</tr>
</thead>

View File

@ -104,51 +104,56 @@ class PagesTest extends FeatureTestCase
->assertSeeText('该页面暂未配置数据表,敬请期待。')
->assertSee('class="biz-empty"', false);
$this->get(route('business.pages.show', [
$response = $this->get(route('business.pages.show', [
'section' => 'refunds',
'page' => 'non-jingxi-refund-data',
]))
]));
$response
->assertOk()
->assertSeeText('非京喜退款数据')
->assertSee('aria-label="非京喜退款数据"', false)
->assertSeeText('暂无数据')
->assertSee('class="upstream-data-table refund-data-table refund-data-table--wide"', false)
->assertDontSee('class="biz-empty"', false)
->assertSeeInOrder([
'<th>Id</th>',
'<th>refundDate</th>',
'<th>as_id</th>',
'<th>outer_as_id</th>',
'<th>o_id</th>',
'<th></th>',
'<th>so_id</th>',
'<th>type</th>',
'<th>node</th>',
'<th>isZC</th>',
'<th>shop_name</th>',
'<th>platform</th>',
'<th>responsibleDepartment</th>',
'<th>totalRefundMoney</th>',
'<th>originPostcode</th>',
'<th>shop_i_i_id</th>',
'<th>shop_sku_id</th>',
'<th>i_id</th>',
'<th>sku_id</th>',
'<th>buyer_paid_amount</th>',
'<th>qty</th>',
'<th>unitCostGoods</th>',
'<th>detailRefundMoney</th>',
'<th>refundType</th>',
'<th>refundQty</th>',
'<th>refundCostGoods</th>',
'<th>RefundMoneyIncome</th>',
'<th>AfSalesMoney</th>',
'<th>createTime</th>',
'<th>status</th>',
'<th>shop_status</th>',
'<th>created</th>',
'<th>confirm_date</th>',
], false);
->assertSee('data-header-row="labels"', false)
->assertSee('data-header-row="fields"', false)
->assertDontSee('class="biz-empty"', false);
$html = $response->getContent();
$headerRows = [];
preg_match_all(
'/<tr[^>]*data-header-row="(labels|fields)"[^>]*>(.*?)<\/tr>/s',
$html,
$headerRows,
PREG_SET_ORDER,
);
$headers = collect($headerRows)->mapWithKeys(function (array $row): array {
$cells = [];
preg_match_all('/<th[^>]*>(.*?)<\/th>/s', $row[2], $cells);
return [$row[1] => collect($cells[1])->map(
fn (string $cell): string => trim(html_entity_decode(strip_tags($cell)))
)->all()];
});
$this->assertSame([
'序号/主键ID', '退款日期', '售后单ID', '外部售后单号', '订单ID', '',
'子订单ID', '类型', '节点', '是否自营', '店铺名称', '平台', '责任部门',
'退款总金额', '原始邮编', '店铺商品ID', '店铺SKU编码', '商品ID', 'SKU编码',
'买家实付金额', '数量', '商品单位成本', '明细退款金额', '退款类型',
'退款数量', '退款商品成本', '退款回款金额', '售后金额', '创建时间', '状态',
'店铺状态', '创建记录/创建时间', '确认日期',
], $headers->get('labels'));
$this->assertSame([
'Id', 'refundDate', 'as_id', 'outer_as_id', 'o_id', '', 'so_id', 'type',
'node', 'isZC', 'shop_name', 'platform', 'responsibleDepartment',
'totalRefundMoney', 'originPostcode', 'shop_i_id', 'shop_sku_id', 'i_id',
'sku_id', 'buyer_paid_amount', 'qty', 'unitCostGoods', 'detailRefundMoney',
'refundType', 'refundQty', 'refundCostGoods', 'RefundMoneyIncome',
'AfSalesMoney', 'createTime', 'status', 'shop_status', 'created', 'confirm_date',
], $headers->get('fields'));
$this->withExceptionHandling()->get(route('business.pages.show', [
'section' => 'refunds',