feat(顾家对账): 按工作簿子表补充各页签表头 #1276

Merged
chenxi merged 1 commits from feature/chenxi-kuka-reconciliation-headers into main 2026-11-19 16:25:16 +08:00
3 changed files with 305 additions and 14 deletions

View File

@ -1,40 +1,119 @@
@php
$simpleHeaders = static fn (array $labels): array => array_map(
static fn (string $label): array => ['label' => $label, 'code' => ''],
$labels,
);
$pairedHeaders = static function (array $labels, array $codes): array {
return array_map(
static function (string $label, int $index) use ($codes): array {
$code = trim((string) ($codes[$index] ?? ''));
return [
'label' => $label,
'code' => $code === $label ? '' : $code,
];
},
$labels,
array_keys($labels),
);
};
$tabs = [
[
'slug' => 'posting-data',
'title' => '顾家过账数据',
'icon' => 'dataset',
'description' => '顾家过账数据对账页面已建立,待接入订单与过账数据。',
'description' => '已按工作簿4“顾家过账数据”子表放入表头,数据待接入。',
'source_sheet' => '顾家过账数据',
'headers' => $simpleHeaders([
'年份', '月份', '物料编号', '物料描述', '采购数量', '单价', '供货商金额',
]),
],
[
'slug' => 'toc-orders',
'title' => 'TOC订单',
'icon' => 'shopping_cart',
'description' => 'TOC 订单对账页面已建立,待接入订单明细。',
'description' => '已按工作簿4“TOC订单”子表放入表头,订单明细待接入。',
'source_sheet' => 'TOC订单',
'headers' => $simpleHeaders([
'年份', '月份', '订单号', '物料编号', '物料描述', '发货数量',
]),
],
[
'slug' => 'lingshan-virtual-posting',
'title' => '灵珊虚拟过账',
'icon' => 'swap_horiz',
'description' => '灵珊虚拟过账页面已建立,待接入虚拟过账数据。',
'description' => '已按工作簿4“灵珊虚拟过账”子表放入表头,数据待接入。',
'source_sheet' => '灵珊虚拟过账',
'headers' => $simpleHeaders([
'年份', '月份', '序号', '顾家料号', '品名', '采购数量', '单价', '供货商金额',
'销售单价', '销售金额', '供货商', '供应商编码', '淘宝单号', 'N单号', '装载号',
'导入时间',
]),
],
[
'slug' => 'erp-product-import',
'title' => '顾家ERP商品导入',
'icon' => 'inventory_2',
'description' => '顾家 ERP 商品导入页面已建立,待接入商品导入流程。',
'description' => '已按工作簿4“顾家ERP商品导入”子表的双行表头放入字段和导入编码。',
'source_sheet' => '顾家ERP商品导入',
'headers' => $pairedHeaders(
[
'年份', '月份', '网店编号(必填)', '商城单号(必填)', '商城SKU编号(必填)',
'商品数量(必填)', '商城明细单号', '销售类型(必填)(0-销售,1-赠品)',
'成交单价(必填)', '金额(必填)', '实付金额', '下单时间(必填)', '付款时间(必填)',
'交期时间(必填)', '商品标题', '商品规格', '收货人(必填)', '收货人电话',
'收货人手机(必填)', '买家备注', '邮编', '收货人的所在省份(必填)',
'收货人的所在城市(必填)', '收货人的所在区(县)(必填)', '收货人街道',
'收货地址(必填)', '快递公司', '运费(必填)', '商城状态', '卖家备注',
'订单备注', '买家昵称(必填)', '实际下单店铺', '国补主体',
],
[
'', '', 'depotId', 'billsPlatformId', 'clothingId', 'billsNums',
'billsPlatformSubId', 'saleType', 'accSprice', 'accSums', 'payment',
'billsCreateDate', 'billsPayDate', 'plannedDeliveryDate', 'clothTitle',
'clothSpecs', 'clientName', 'clientTel', 'clientMobile', 'billsClientRemark',
'clientPostCode', 'clientProvince', 'clientCity', 'clientArea', 'clientStreet',
'clientAddress', 'logisticsId', 'freight', 'billsPlatformState',
'billsSellerRemark', 'billsRemark', 'buyerNick', 'setdepotId',
'nationalSubsidySubject',
],
),
],
[
'slug' => 'invoice-entry-template',
'title' => '开票填写模板-货物-灵珊',
'icon' => 'description',
'description' => '灵珊货物开票填写模板页面已建立。',
'description' => '已按工作簿4“开票填写模板-货物-灵珊”子表放入表头。',
'source_sheet' => '开票填写模板-货物-灵珊',
'headers' => $simpleHeaders([
'年份', '月份', '开票公司', '单据号(订单号)', '备注(没有就空着)', '货物名称',
'规格型号', '税收分类', '单位', '开票数量', '开票金额(含税,两位小数)', '税率',
'开票抬头', '开票税号', '开票地址', '开票电话', '开户银行', '开户账号',
'提交人邮箱', '提交人电话(手机)',
]),
],
[
'slug' => 'inventory-management-template',
'title' => '库存管理模板',
'icon' => 'warehouse',
'description' => '库存管理模板页面已建立。',
'description' => '已按工作簿4“库存管理模版”子表的双行表头放入字段和接口编码。',
'source_sheet' => '库存管理模版',
'headers' => $pairedHeaders(
[
'年份', '月份', '供应商ELS账号', 'SAP编码', '供应商ELS名称', '物料编号(*)',
'物料描述', '库存数量', '可用库存数量(含预生产)', '半成品库存', '3个月内库存',
'6个月以上库存', '3-6个月库存', '在制数量', '入库数量', '出库数量', '物料名称',
'物料规格', '货号', '品名', '库存属性', '采购员', '业务员', '经营部',
'物料批次', '最后修改时间', '预生产数量', '实际可用库存数量',
],
[
'年份', '月份', 'fbk6', 'toElsAccount', 'toElsAccountName', 'materialNumber',
'materialDesc', 'stockQuantity', 'availableStockQuantity', 'fbk2', 'fbk3',
'fbk5', 'fbk4', 'fbk8', 'stockInQuantity', 'stockOutQuantity',
'materialName', 'materialSpecifications', 'fbk9', 'fbk10', 'fbk1', 'fbk15',
'fbk14', 'fbk16', 'fbk7', 'lastUpdateDate', 'fbk18', 'fbk19',
],
),
],
[
'slug' => 'lingshan-statement',
@ -55,6 +134,7 @@
? $requestedSubmenu
: 'posting-data';
$placeholder = 'business.pages.posting-data.partials.kuka-posting-placeholder';
$sourceTable = 'business.pages.posting-data.partials.kuka-reconciliation-source-table';
@endphp
<div class="kuka-reconciliation-page">
@ -72,11 +152,21 @@
aria-labelledby="kuka-reconciliation-tab-{{ $tab['slug'] }}"
@if ($activeView !== $tab['slug']) hidden @endif
>
@include($placeholder, [
'title' => $tab['title'],
'description' => $tab['description'],
'icon' => $tab['icon'],
])
@if (! empty($tab['headers']))
@include($sourceTable, [
'title' => $tab['title'],
'description' => $tab['description'],
'icon' => $tab['icon'],
'sourceSheet' => $tab['source_sheet'],
'headers' => $tab['headers'],
])
@else
@include($placeholder, [
'title' => $tab['title'],
'description' => $tab['description'],
'icon' => $tab['icon'],
])
@endif
</section>
@endforeach
</div>

View File

@ -0,0 +1,155 @@
<section
class="kuka-source-table"
data-kuka-reconciliation-template="{{ $sourceSheet }}"
aria-label="{{ $title }}表头"
>
<header class="kuka-source-table__header">
<span class="kuka-source-table__icon" aria-hidden="true">
<span class="material-icons-outlined">{{ $icon }}</span>
</span>
<div class="kuka-source-table__heading">
<h2>{{ $title }}</h2>
<p>{{ $description }}</p>
</div>
<span class="kuka-source-table__meta">
工作簿4 · {{ $sourceSheet }} · {{ count($headers) }} 列
</span>
</header>
<div class="kuka-source-table__scroll">
<table class="kuka-source-table__grid">
<thead>
<tr>
@foreach ($headers as $header)
<th scope="col">
<span>{{ $header['label'] }}</span>
@if ($header['code'] !== '')
<code>{{ $header['code'] }}</code>
@endif
</th>
@endforeach
</tr>
</thead>
</table>
</div>
</section>
<style>
.kuka-source-table {
display: grid;
min-width: 0;
overflow: hidden;
border: 1px solid var(--vip-border, #d8d2c7);
border-radius: 12px;
background: var(--vip-surface, #fff);
color: var(--vip-content-ink, #171717);
}
.kuka-source-table__header {
display: flex;
min-width: 0;
align-items: center;
gap: 10px;
padding: 12px 14px;
border-bottom: 1px solid var(--vip-border, #d8d2c7);
background: #fff;
}
.kuka-source-table__icon {
display: grid;
width: 30px;
height: 30px;
flex: 0 0 30px;
place-items: center;
border: 1px solid #d9c89c;
border-radius: 8px;
background: var(--vip-content-accent-soft, #f7f0de);
color: var(--vip-content-accent-dark, #856632);
}
.kuka-source-table__icon .material-icons-outlined {
font-size: 17px;
}
.kuka-source-table__heading {
display: grid;
min-width: 0;
flex: 1 1 auto;
gap: 2px;
}
.kuka-source-table__heading h2 {
margin: 0;
font-size: 13px;
font-weight: 600;
line-height: 1.35;
}
.kuka-source-table__heading p {
margin: 0;
color: var(--vip-content-muted, #595959);
font-size: 11px;
line-height: 1.5;
}
.kuka-source-table__meta {
flex: 0 0 auto;
padding: 3px 8px;
border: 1px solid #d9c89c;
border-radius: 999px;
background: #fbf7ec;
color: var(--vip-content-accent-dark, #856632);
font-size: 10px;
font-weight: 600;
white-space: nowrap;
}
.kuka-source-table__scroll {
max-width: 100%;
max-height: min(50vh, 34rem);
overflow: auto;
scrollbar-color: var(--vip-content-accent, #b9954f) #efede8;
scrollbar-width: thin;
}
.kuka-source-table__grid {
width: max-content;
min-width: 100%;
border-collapse: separate;
border-spacing: 0;
font-size: 12px;
}
.kuka-source-table__grid th {
min-width: 8rem;
max-width: 15rem;
padding: 9px 10px;
border-right: 1px solid var(--vip-border, #d8d2c7);
border-bottom: 1px solid var(--vip-border, #d8d2c7);
background: var(--vip-content-accent-soft, #f7f0de);
color: var(--vip-content-ink, #171717);
font-size: 11px;
font-weight: 600;
line-height: 1.45;
text-align: left;
vertical-align: top;
white-space: normal;
}
.kuka-source-table__grid th:last-child {
border-right: 0;
}
.kuka-source-table__grid th span,
.kuka-source-table__grid th code {
display: block;
}
.kuka-source-table__grid th code {
margin-top: 3px;
color: var(--vip-content-muted, #595959);
font-family: inherit;
font-size: 9px;
font-weight: 500;
overflow-wrap: anywhere;
}
@media (max-width: 720px) {
.kuka-source-table__header {
align-items: flex-start;
flex-wrap: wrap;
}
.kuka-source-table__meta {
margin-left: 40px;
}
.kuka-source-table__grid th {
min-width: 7rem;
}
}
</style>

View File

@ -8,7 +8,7 @@ class KukaReconciliationPageTest extends FeatureTestCase
{
public function test_renders_all_kuka_reconciliation_tabs_with_the_first_tab_active(): void
{
$this->loginAs()
$response = $this->loginAs()
->get(route('business.pages.show', [
'section' => 'posting-data',
'page' => 'kuka-reconciliation',
@ -27,7 +27,38 @@ class KukaReconciliationPageTest extends FeatureTestCase
->assertSee('data-kuka-reconciliation-panel="posting-data"', false)
->assertSee('data-kuka-reconciliation-panel="oberna-statement"', false)
->assertSee('id="kuka-reconciliation-tab-posting-data"', false)
->assertSee('class="kuka-reconciliation-subnav__tab is-active"', false);
->assertSee('class="kuka-reconciliation-subnav__tab is-active"', false)
->assertSee('data-kuka-reconciliation-template="顾家过账数据"', false)
->assertSee('data-kuka-reconciliation-template="TOC订单"', false)
->assertSee('data-kuka-reconciliation-template="灵珊虚拟过账"', false)
->assertSee('data-kuka-reconciliation-template="顾家ERP商品导入"', false)
->assertSee('data-kuka-reconciliation-template="开票填写模板-货物-灵珊"', false)
->assertSee('data-kuka-reconciliation-template="库存管理模版"', false)
->assertSeeText('供货商金额')
->assertSeeText('装载号')
->assertSeeText('nationalSubsidySubject')
->assertSeeText('提交人电话(手机)')
->assertSeeText('toElsAccount')
->assertSeeText('实际可用库存数量')
->assertSeeText('灵珊对账单页面已建立')
->assertSeeText('欧伯娜对账单页面已建立');
$html = $response->getContent();
$this->assertSame([
'posting-data' => 7,
'toc-orders' => 6,
'lingshan-virtual-posting' => 16,
'erp-product-import' => 34,
'invoice-entry-template' => 20,
'inventory-management-template' => 28,
], [
'posting-data' => $this->headerCount($html, 'posting-data'),
'toc-orders' => $this->headerCount($html, 'toc-orders'),
'lingshan-virtual-posting' => $this->headerCount($html, 'lingshan-virtual-posting'),
'erp-product-import' => $this->headerCount($html, 'erp-product-import'),
'invoice-entry-template' => $this->headerCount($html, 'invoice-entry-template'),
'inventory-management-template' => $this->headerCount($html, 'inventory-management-template'),
]);
}
public function test_kuka_reconciliation_tab_can_open_directly_from_the_url(): void
@ -42,6 +73,21 @@ class KukaReconciliationPageTest extends FeatureTestCase
->assertSee('id="kuka-reconciliation-tab-toc-orders"', false)
->assertSee('class="kuka-reconciliation-subnav__tab is-active"', false)
->assertSee('data-kuka-reconciliation-panel="toc-orders"', false)
->assertSeeText('TOC 订单对账页面已建立');
->assertSee('data-kuka-reconciliation-template="TOC订单"', false)
->assertSeeText('订单号')
->assertSeeText('发货数量');
}
private function headerCount(string $html, string $slug): int
{
$panelStart = strpos($html, 'data-kuka-reconciliation-panel="'.$slug.'"');
$this->assertNotFalse($panelStart);
$panelEnd = strpos($html, '</section>', $panelStart);
$this->assertNotFalse($panelEnd);
$panel = substr($html, $panelStart, $panelEnd - $panelStart);
preg_match_all('/<th scope="col">/', $panel, $matches);
return count($matches[0]);
}
}