Compare commits

...
Author SHA1 Message Date
wuzilongandCursor eab882f92c fix(deploy): nginx 隐藏 MinIO 上游 CORS 头避免双 Origin。
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-16 15:42:03 +08:00
wuzilongandCursor 04450fff88 fix(web-admin): 运输归档合计行与可见表头列对齐。
planNo 可隐藏后不再硬编码插入,避免统计行按索引错位。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-16 15:42:03 +08:00
wuzilongandCursor 82c21262ed fix(web-admin): 顶栏菜单折叠按钮改为内联 SVG 并始终可见。
避免 Iconify/el-icon 在部分浏览器不绘制,并去掉可关闭开关以免按钮被关掉。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-16 15:42:03 +08:00
wuzilongandCursor 8ac835fa96 fix(pl): 未安排计划按生效时间走新规则选证。
安排预检不再把空版本当成 legacy 去查合同绑证,与证书齐备待完善判定一致。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-16 15:26:12 +08:00
wuzilong e9f3602459 Merge branch 'codex/issue-43-cert-ready-pending-a8f3c1d9e2b4' into V3.0 2026-11-16 15:03:00 +08:00
wuzilong d2b8a573a1 Merge remote-tracking branch 'origin/V3.0' into V3.0 2026-11-16 15:02:57 +08:00
wuzilongandCursor 7e515d9ccd fix(pl): 客户品类安排运输时采用已保存单位换算。
安排自动选证不再忽略计划段次用证中的 manualAllocations,避免瓶升等异单位已填换算仍无法安排。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-16 10:56:29 +08:00
16 changed files with 637 additions and 66 deletions

No files matched your search

@@ -99,14 +99,15 @@ def stamp_plan_rule_version(db: Session, user, plan) -> str:
def plan_uses_customer_category(plan) -> bool:
"""仅看已落库版本;空版本视为 legacy。安排前请用 plan_applies_customer_category_rule。"""
return (getattr(plan, 'cert_quota_rule_version', None) or VERSION_LEGACY) == VERSION_CUSTOMER_CATEGORY
def plan_requires_cert_fulfill(db: Session, tenant_no: str, plan) -> bool:
"""齐备后是否须进待完善:已打新规则,或尚未安排但按当前时刻将落入新规则。
def plan_applies_customer_category_rule(db: Session, tenant_no: str, plan) -> bool:
"""业务是否按新规则:已打 customer_category,或尚未安排且按当前时刻将落入新规则。
安排前 `cert_quota_rule_version` 常为空;不能把空当成 legacy,否则会漏写 pending。
已安排并打成 legacy 的计划仍按旧规则,不进待完善。
安排前 `cert_quota_rule_version` 常为空;不能把空当成 legacy,否则会误走合同绑证、
漏写齐备待完善。已首次安排并打成 legacy 的计划保持旧规则。
"""
if plan_uses_customer_category(plan):
return True
@@ -115,6 +116,11 @@ def plan_requires_cert_fulfill(db: Session, tenant_no: str, plan) -> bool:
return resolve_rule_version_for_arrange(db, tenant_no) == VERSION_CUSTOMER_CATEGORY
def plan_requires_cert_fulfill(db: Session, tenant_no: str, plan) -> bool:
"""齐备后是否须进待完善;与安排是否走新规则同一判定。"""
return plan_applies_customer_category_rule(db, tenant_no, plan)
def infer_arranged_at(db: Session, plan) -> Optional[datetime]:
"""历史缺字段时用关联运输单创建时间推断首次安排。"""
stamped = getattr(plan, 'cert_quota_arranged_at', None)
@@ -80,6 +80,49 @@ def _permit_qty_for(source_qty: Decimal, source_unit: str, cert_unit: str) -> De
return (source_qty * Decimal(str(ratio))).quantize(Decimal('0.000001'))
def _manual_field(row, *names):
if isinstance(row, dict):
for name in names:
if name in row and row[name] is not None:
return row[name]
return None
for name in names:
value = getattr(row, name, None)
if value is not None:
return value
return None
def _saved_permit_qty(manuals, kind, source_id, permit_id, source_qty: Decimal):
"""计划段次用证已保存的人工换算;来源量变化时按原比例缩放。"""
for row in manuals or ():
if (
str(_manual_field(row, 'permit_kind', 'permitKind') or '') != kind
or str(_manual_field(row, 'source_id', 'sourceId') or '') != str(source_id)
or str(_manual_field(row, 'permit_id', 'permitId') or '') != str(permit_id)
):
continue
saved_src = Decimal(str(_manual_field(row, 'source_quantity', 'sourceQuantity') or '0'))
saved_permit = Decimal(str(_manual_field(row, 'permit_quantity', 'permitQuantity') or '0'))
if saved_src <= 0 or saved_permit <= 0:
return None
current = Decimal(source_qty)
if saved_src == current:
return saved_permit
return (saved_permit * current / saved_src).quantize(Decimal('0.000001'))
return None
def _need_permit_qty(source_qty, source_unit, cert_unit, manuals, kind, source_id, permit_id):
try:
return _permit_qty_for(Decimal(source_qty), source_unit, cert_unit)
except HTTPException:
manual_qty = _saved_permit_qty(manuals, kind, source_id, permit_id, Decimal(source_qty))
if manual_qty is None:
raise
return manual_qty
def _customer_id_from_source(source) -> str:
snap = source.snapshot or {}
cid = snap.get('customerId') or snap.get('customer_id')
@@ -181,13 +224,16 @@ def _linked_transports(db, user, customer_id, purchase_id):
)
def _diagnose_select_failure(db, user, source, *, vehicle_no: str, on_date: date, candidates):
def _diagnose_select_failure(
db, user, source, *, vehicle_no: str, on_date: date, candidates, manual_allocations=(),
):
"""选证失败时按证据优先给出单一可执行原因,避免笼统兜底句。"""
place = '同市' if not source.requires_transport else '异地'
plate = (vehicle_no or '').strip()
need_qty = Decimal(source.quantity)
customer_label = _source_customer_label(source)
product_label = _source_product_label(db, user, source)
manuals = manual_allocations or ()
if not candidates:
product_part = f'产品「{product_label}」' if product_label else '该产品'
@@ -227,7 +273,10 @@ def _diagnose_select_failure(db, user, source, *, vehicle_no: str, on_date: date
consumed_buy.append(purchase)
continue
try:
need = _permit_qty_for(need_qty, source.unit, purchase.quantity_unit)
need = _need_permit_qty(
need_qty, source.unit, purchase.quantity_unit,
manuals, 'purchase', source.source_id, purchase.id,
)
except HTTPException:
unit_buy.append(purchase)
continue
@@ -263,7 +312,10 @@ def _diagnose_select_failure(db, user, source, *, vehicle_no: str, on_date: date
vehicle_miss.append(transport)
continue
try:
t_need = _permit_qty_for(need_qty, source.unit, transport.quantity_unit)
t_need = _need_permit_qty(
need_qty, source.unit, transport.quantity_unit,
manuals, 'transport', source.source_id, transport.id,
)
except HTTPException:
unit_move.append(transport)
continue
@@ -374,10 +426,13 @@ def _diagnose_select_failure(db, user, source, *, vehicle_no: str, on_date: date
)
def select_whole_cover_certs(db, user, sources, *, vehicle_no: str, on_date: date):
def select_whole_cover_certs(
db, user, sources, *, vehicle_no: str, on_date: date, manual_allocations=(),
):
"""返回 purchase_cert_ids, transport_cert_ids, manual_allocations。
每个来源必须由一张购买证整笔覆盖;异地再配一张关联且车号/余量够的运输证。
单位无法自动换算时,使用计划段次用证已保存的人工换算量。
"""
if not sources:
return [], [], []
@@ -385,6 +440,7 @@ def select_whole_cover_certs(db, user, sources, *, vehicle_no: str, on_date: dat
purchase_ids = []
transport_ids = []
manuals = []
saved_manuals = manual_allocations or ()
for source in sources:
customer_id = _customer_id_from_source(source)
@@ -414,7 +470,10 @@ def select_whole_cover_certs(db, user, sources, *, vehicle_no: str, on_date: dat
if is_single_use_consumed(db, user, 'purchase', purchase):
continue
try:
need = _permit_qty_for(Decimal(source.quantity), source.unit, purchase.quantity_unit)
need = _need_permit_qty(
source.quantity, source.unit, purchase.quantity_unit,
saved_manuals, 'purchase', source.source_id, purchase.id,
)
except HTTPException:
continue
if _available(purchase) < need:
@@ -441,7 +500,10 @@ def select_whole_cover_certs(db, user, sources, *, vehicle_no: str, on_date: dat
if not _vehicle_ok(transport, vehicle_no):
continue
try:
t_need = _permit_qty_for(Decimal(source.quantity), source.unit, transport.quantity_unit)
t_need = _need_permit_qty(
source.quantity, source.unit, transport.quantity_unit,
saved_manuals, 'transport', source.source_id, transport.id,
)
except HTTPException:
continue
if _available(transport) < t_need:
@@ -458,7 +520,8 @@ def select_whole_cover_certs(db, user, sources, *, vehicle_no: str, on_date: dat
raise HTTPException(
409,
_diagnose_select_failure(
db, user, source, vehicle_no=vehicle_no, on_date=on_date, candidates=candidates,
db, user, source, vehicle_no=vehicle_no, on_date=on_date,
candidates=candidates, manual_allocations=saved_manuals,
),
)
+19 -7
View File
@@ -131,8 +131,8 @@ def build_usage_request(db, user, plan_id, operation, action, *, lock=False, che
sources, actuals = [], {}
else:
sources, actuals = extract_sources(db, user, plan_id, mapping, actual=action in ('settle', 'actual_adjust'), lock=lock, preview_vehicle=preview_vehicle, measurement_version=config.measurement_version)
from app.services.pl_cert_quota_rule_config_service import plan_uses_customer_category
customer_rule = plan_uses_customer_category(plan)
from app.services.pl_cert_quota_rule_config_service import plan_applies_customer_category_rule
customer_rule = plan_applies_customer_category_rule(db, user.tenant_no, plan)
if action in ('reserve', 'resize') and not explicit and sources:
if customer_rule:
# 新规则:禁止手工选证;按客户+品类整笔自动选证
@@ -143,6 +143,7 @@ def build_usage_request(db, user, plan_id, operation, action, *, lock=False, che
on_date = max(date.today(), plan.plan_date or date.today())
purchase_ids, transport_ids, manuals = select_whole_cover_certs(
db, user, sources, vehicle_no=vehicle, on_date=on_date,
manual_allocations=config.manual_allocations,
)
config = config.model_copy(update={
'purchase_cert_ids': purchase_ids,
@@ -227,10 +228,10 @@ def preview_plan(db, user, plan_id, config, preview_vehicle=None):
def save_configuration(db, user, plan_id, config):
from app.services.pl_plan_service import record_plan_change
from app.services.pl_cert_quota_rule_config_service import plan_uses_customer_category
from app.services.pl_cert_quota_rule_config_service import plan_applies_customer_category_rule
config = config if isinstance(config, PlanQuotaConfiguration) else PlanQuotaConfiguration.model_validate(config)
plan = _plan(db, user, plan_id, lock=True)
if plan_uses_customer_category(plan):
if plan_applies_customer_category_rule(db, user.tenant_no, plan):
raise HTTPException(409, '新规则下安排仅自动选证,不支持手工保存用证配置')
if plan.transport_status == 'arranged' or plan.archive_status == 'archived':
raise HTTPException(409, '已安排计划请通过调整运输在同一事务重算用证')
@@ -337,11 +338,22 @@ def get_plan_quota(db, user, plan_id):
options.append(item)
usages = db.query(PlPlanCertUsage).filter_by(tenant_no=user.tenant_no, plan_id=plan_id, del_flag=0).order_by(PlPlanCertUsage.create_time.desc()).all()
version = resolve_measurement_version(db, user, plan)
from app.services.pl_cert_quota_rule_config_service import plan_uses_customer_category
customer_rule = plan_uses_customer_category(plan)
from app.services.pl_cert_quota_rule_config_service import (
VERSION_LEGACY,
plan_applies_customer_category_rule,
resolve_rule_version_for_arrange,
)
customer_rule = plan_applies_customer_category_rule(db, user.tenant_no, plan)
stamped = getattr(plan, 'cert_quota_rule_version', None)
if stamped:
rule_version = stamped
elif getattr(plan, 'cert_quota_arranged_at', None) is None:
rule_version = resolve_rule_version_for_arrange(db, user.tenant_no)
else:
rule_version = VERSION_LEGACY
result = {'planId': plan.id, 'planNo': plan.plan_no, 'licensePlate': plan.license_plate,
'quotaCertWaived': int(getattr(plan, 'quota_cert_waived', 0) or 0) == 1,
'certQuotaRuleVersion': getattr(plan, 'cert_quota_rule_version', None) or 'legacy',
'certQuotaRuleVersion': rule_version or VERSION_LEGACY,
'measurementVersion': version,
'configuration': {**(plan.cert_configuration or {}), 'measurementVersion': version}, 'sourceOptions': options,
'stopProducts': stop_products,
@@ -1232,3 +1232,291 @@ def test_archive_cover_block_message_customer_rule_wording(monkeypatch):
)
assert '客户名下' in message
assert '合同' not in message
def test_whole_cover_uses_saved_manual_when_units_need_conversion(monkeypatch):
"""计划段次用证已填瓶→升换算时,同市自动选证应采用该证面量,不能因无法自动换算失败。"""
from app.services import pl_quota_customer_select as sel
from app.schemas.pl.quota_planning import ManualQuantity
purchase = _ok_purchase(
id='78bde6ea',
cert_no='G34280697302194',
quantity_unit='sheng',
total_qty=Decimal('2.5'),
)
db = _mock_select_db([purchase], [], [])
monkeypatch.setattr(sel, 'category_ids_for_product', lambda *a, **k: {'cat1'})
source = _remote_source(
requires_transport=False,
quantity=Decimal('5'),
unit='ping',
source_stop_type='delivery',
source_stop_id='d1',
source_stop_product_id='012423E0',
)
saved = [
ManualQuantity(
permit_kind='purchase',
source_id=source.source_id,
permit_id='78bde6ea',
source_quantity=Decimal('5'),
permit_quantity=Decimal('2.5'),
)
]
purchase_ids, transport_ids, manuals = sel.select_whole_cover_certs(
db,
SimpleNamespace(tenant_no='t'),
[source],
vehicle_no='皖H21522',
on_date=date(2026, 11, 16),
manual_allocations=saved,
)
assert purchase_ids == ['78bde6ea']
assert transport_ids == []
assert len(manuals) == 1
assert manuals[0].permit_id == '78bde6ea'
assert manuals[0].permit_quantity == Decimal('2.5')
assert manuals[0].source_quantity == Decimal('5')
def test_whole_cover_hetero_unit_without_manual_still_blocks(monkeypatch):
from app.services import pl_quota_customer_select as sel
purchase = _ok_purchase(quantity_unit='sheng', total_qty=Decimal('2.5'))
db = _mock_select_db([purchase], [], [])
monkeypatch.setattr(sel, 'category_ids_for_product', lambda *a, **k: {'cat1'})
with pytest.raises(HTTPException) as exc:
sel.select_whole_cover_certs(
db,
SimpleNamespace(tenant_no='t'),
[_remote_source(requires_transport=False, quantity=Decimal('5'), unit='ping')],
vehicle_no='皖H21522',
on_date=date(2026, 11, 16),
)
assert exc.value.status_code == 409
assert '无法自动换算' in str(exc.value.detail)
def test_build_usage_request_passes_saved_manuals_to_customer_select(monkeypatch):
"""安排预占在客户品类规则下应把已保存换算传给自动选证。"""
from app.services import pl_quota_planning as planning
from app.schemas.pl.quota_planning import ManualQuantity, PlanQuotaOperation
from app.schemas.pl.quota_usage import UsageSource
source = UsageSource(
source_stop_type='delivery',
source_stop_id='d1',
source_stop_product_id='sp1',
plan_product_id='pp1',
contract_id='c1',
contract_product_id='cp1',
product_id='prod1',
quantity=Decimal('5'),
unit='ping',
fingerprint='f' * 64,
snapshot={'customerId': 'cust1'},
requires_transport=False,
)
saved = [
ManualQuantity(
permit_kind='purchase',
source_id=source.source_id,
permit_id='buy1',
source_quantity=Decimal('5'),
permit_quantity=Decimal('2.5'),
)
]
plan = SimpleNamespace(
id='p1',
plan_date=date(2026, 11, 16),
license_plate='皖H21522',
transport_status='pending',
archive_status='unarchived',
cert_quota_rule_version='customer_category',
cert_configuration={
'measurementVersion': 'per_stop_v2',
'manualAllocations': [row.model_dump(by_alias=True) for row in saved],
},
)
captured = {}
def fake_select(db, user, sources, *, vehicle_no, on_date, manual_allocations=()):
captured['manual_allocations'] = list(manual_allocations)
return ['buy1'], [], list(manual_allocations)
monkeypatch.setattr(planning, '_plan', lambda *a, **k: plan)
monkeypatch.setattr(planning, 'extract_sources', lambda *a, **k: ([source], {}))
monkeypatch.setattr(planning, 'resolve_measurement_version', lambda *a, **k: 'per_stop_v2')
monkeypatch.setattr(planning, 'plan_execution_lock_reason', lambda *a, **k: None)
monkeypatch.setattr(
'app.services.pl_cert_quota_rule_config_service.plan_uses_customer_category',
lambda p: True,
)
monkeypatch.setattr(
'app.services.pl_quota_customer_select.select_whole_cover_certs',
fake_select,
)
monkeypatch.setattr(planning, '_get_row', lambda *a, **k: SimpleNamespace(id='buy1', revision=1))
request, config = planning.build_usage_request(
MagicMock(),
SimpleNamespace(id='u', tenant_no='t', dept_id=''),
'p1',
PlanQuotaOperation(operationId='op1'),
'reserve',
check_conditions=False,
)
assert captured['manual_allocations']
assert captured['manual_allocations'][0].permit_id == 'buy1'
assert config.purchase_cert_ids == ['buy1']
assert request.manual_allocations[0].permit_quantity == Decimal('2.5')
def test_unarranged_plan_build_usage_uses_customer_rule_by_effective_at(monkeypatch):
"""尚未安排且版本为空时,按生效时间走新规则自动选证,不查合同绑证。"""
from app.services import pl_quota_planning as planning
from app.schemas.pl.quota_planning import PlanQuotaOperation
from app.schemas.pl.quota_usage import UsageSource
source = UsageSource(
source_stop_type='delivery',
source_stop_id='d1',
source_stop_product_id='sp1',
plan_product_id='pp1',
contract_id='c1',
contract_product_id='cp1',
product_id='prod1',
quantity=Decimal('33'),
unit='dun',
fingerprint='f' * 64,
snapshot={'customerId': 'cust1'},
requires_transport=True,
)
plan = SimpleNamespace(
id='p1',
plan_date=date(2026, 11, 14),
license_plate='皖R48299',
transport_status='pending',
archive_status='unarchived',
cert_quota_rule_version=None,
cert_quota_arranged_at=None,
cert_configuration={'measurementVersion': 'per_stop_v2'},
tenant_no='t',
)
called = {'customer_select': 0, 'contract_bind': 0}
def fake_select(*args, **kwargs):
called['customer_select'] += 1
return ['buy1'], ['move1'], []
def fake_contract_bind(*args, **kwargs):
called['contract_bind'] += 1
raise AssertionError('未安排计划不应再走合同绑证')
monkeypatch.setattr(planning, '_plan', lambda *a, **k: plan)
monkeypatch.setattr(planning, 'extract_sources', lambda *a, **k: ([source], {}))
monkeypatch.setattr(planning, 'resolve_measurement_version', lambda *a, **k: 'per_stop_v2')
monkeypatch.setattr(planning, 'plan_execution_lock_reason', lambda *a, **k: None)
monkeypatch.setattr(
'app.services.pl_cert_quota_rule_config_service.get_effective_at',
lambda *a, **k: datetime(2026, 11, 15, 20, 0, 0),
)
monkeypatch.setattr(
'app.services.pl_quota_customer_select.select_whole_cover_certs',
fake_select,
)
monkeypatch.setattr(planning, 'resolve_contract_bound_certs', fake_contract_bind)
monkeypatch.setattr(
planning,
'_get_row',
lambda *a, **k: SimpleNamespace(id='x', revision=1),
)
request, config = planning.build_usage_request(
MagicMock(),
SimpleNamespace(id='u', tenant_no='t', dept_id=''),
'p1',
PlanQuotaOperation(operationId='arrange-check'),
'reserve',
check_conditions=False,
)
assert called['customer_select'] == 1
assert called['contract_bind'] == 0
assert config.purchase_cert_ids == ['buy1']
assert config.transport_cert_ids == ['move1']
assert request.purchase_cert_ids == ['buy1']
def test_arranged_legacy_plan_build_usage_keeps_contract_bind(monkeypatch):
"""已首次安排并打成 legacy 的计划,安排/改派预占仍走合同绑证。"""
from app.services import pl_quota_planning as planning
from app.schemas.pl.quota_planning import PlanQuotaOperation
from app.schemas.pl.quota_usage import UsageSource
source = UsageSource(
source_stop_type='delivery',
source_stop_id='d1',
source_stop_product_id='sp1',
plan_product_id='pp1',
contract_id='c1',
contract_product_id='cp1',
product_id='prod1',
quantity=Decimal('33'),
unit='dun',
fingerprint='f' * 64,
snapshot={'customerId': 'cust1'},
requires_transport=True,
)
plan = SimpleNamespace(
id='p1',
plan_date=date(2026, 11, 14),
license_plate='皖R48299',
transport_status='arranged',
archive_status='unarchived',
cert_quota_rule_version='legacy',
cert_quota_arranged_at=datetime(2026, 11, 14, 10, 0, 0),
cert_configuration={'measurementVersion': 'per_stop_v2'},
tenant_no='t',
)
called = {'customer_select': 0, 'contract_bind': 0}
def fake_select(*args, **kwargs):
called['customer_select'] += 1
return ['buy1'], ['move1'], []
def fake_contract_bind(*args, **kwargs):
called['contract_bind'] += 1
return ['buy1'], ['move1']
monkeypatch.setattr(planning, '_plan', lambda *a, **k: plan)
monkeypatch.setattr(planning, 'extract_sources', lambda *a, **k: ([source], {}))
monkeypatch.setattr(planning, 'resolve_measurement_version', lambda *a, **k: 'per_stop_v2')
monkeypatch.setattr(planning, 'plan_execution_lock_reason', lambda *a, **k: None)
monkeypatch.setattr(
'app.services.pl_cert_quota_rule_config_service.get_effective_at',
lambda *a, **k: datetime(2026, 11, 15, 20, 0, 0),
)
monkeypatch.setattr(
'app.services.pl_quota_customer_select.select_whole_cover_certs',
fake_select,
)
monkeypatch.setattr(planning, 'resolve_contract_bound_certs', fake_contract_bind)
monkeypatch.setattr(
planning,
'_get_row',
lambda *a, **k: SimpleNamespace(id='x', revision=1),
)
planning.build_usage_request(
MagicMock(),
SimpleNamespace(id='u', tenant_no='t', dept_id=''),
'p1',
PlanQuotaOperation(operationId='arrange-check'),
'resize',
check_conditions=False,
)
assert called['contract_bind'] == 1
assert called['customer_select'] == 0
@@ -0,0 +1,46 @@
/**
* 顶栏侧栏收起按钮必须始终可见:
* - persist afterRestore 强制 ensureMenuButtonVisible(禁止 toggle)
* - AppLayout 挂载时再次兜底
* - 设置面板不再提供可关闭开关
*/
import test from 'node:test'
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
const root = join(dirname(fileURLToPath(import.meta.url)), '..')
test('setting store forces menu button visible on restore', () => {
const src = readFileSync(join(root, 'src/store/modules/setting.ts'), 'utf8')
assert.match(src, /ensureMenuButtonVisible\s*=\s*\(\)\s*=>\s*\{[\s\S]*?showMenuButton\.value\s*=\s*true/)
assert.match(src, /afterRestore:\s*\(ctx\)\s*=>\s*\{[\s\S]*?ensureMenuButtonVisible\(\)/)
assert.doesNotMatch(
src,
/afterRestore:[\s\S]*?if\s*\(\s*!ctx\.store\.showMenuButton\s*\)[\s\S]*?setButton\(\)/,
'afterRestore must not rely on setButton toggle'
)
assert.match(
src,
/const setButton = \(\) => \{\s*showMenuButton\.value = true/,
'setButton must assign true, not toggle'
)
})
test('AppLayout mount ensures menu button visible', () => {
const src = readFileSync(join(root, 'src/views/index/index.vue'), 'utf8')
assert.match(src, /ensureMenuButtonVisible\(\)/)
})
test('settings panel does not expose showMenuButton switch', () => {
const src = readFileSync(
join(root, 'src/components/core/layouts/art-settings-panel/composables/useSettingsConfig.ts'),
'utf8'
)
assert.doesNotMatch(
src,
/key:\s*'showMenuButton'/,
'settings UI must not allow turning off the fold control'
)
})
@@ -12,18 +12,36 @@ import { parse } from '@vue/compiler-sfc'
const root = join(dirname(fileURLToPath(import.meta.url)), '..')
test('ArtSvgIcon: el-icon branch must not use Tailwind inline class', () => {
test('ArtSvgIcon: icon roots must not use Tailwind inline class', () => {
const src = readFileSync(join(root, 'src/components/core/base/art-svg-icon/index.vue'), 'utf8')
const { descriptor } = parse(src)
const template = descriptor.template?.content || ''
assert.match(template, /<el-icon\b[^>]*class="[^"]*art-svg-icon/)
assert.doesNotMatch(
template,
/<el-icon\b[^>]*class="[^"]*\binline\b/,
'el-icon must not include Tailwind inline (breaks display:inline-flex in prod CSS order)'
/<(?:el-icon|Icon)\b[^>]*class="[^"]*\binline\b/,
'icon roots must not include Tailwind inline (breaks display in prod CSS order)'
)
})
test('header fold button uses inline SVG button (Chrome-safe)', () => {
const src = readFileSync(
join(root, 'src/components/core/layouts/art-header-bar/index.vue'),
'utf8'
)
const { descriptor } = parse(src)
const template = descriptor.template?.content || ''
assert.match(template, /class="menu-fold-btn/)
assert.match(template, /menu-fold-btn__icon/)
assert.match(template, /<svg[\s\S]*viewBox="0 0 24 24"/)
assert.doesNotMatch(
template,
/<ArtIconButton[\s\S]*menu-fold/,
'fold control must not rely on ArtIconButton/iconify in Chrome'
)
assert.match(template, /<button[\s\S]*class="menu-fold-btn/)
})
test('plan-archive: planNo is in column defs and table visibility gate', () => {
const src = readFileSync(join(root, 'src/views/pl/plan-archive/index.vue'), 'utf8')
assert.match(src, /prop:\s*'planNo',\s*label:\s*'计划编号'/)
@@ -0,0 +1,66 @@
/**
* #41 回归:运输归档绿色合计行须与表头列一一对应。
* planNo 可隐藏后,不得再无条件硬编码插入 planNo,否则按索引错位。
*/
import test from 'node:test'
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { buildStatsRowColumns } from '../src/utils/list-column-stats.ts'
const root = join(dirname(fileURLToPath(import.meta.url)), '..')
const ARCHIVE_DEFS = [
{ prop: 'planNo' },
{ prop: 'planDate' },
{ prop: 'planQty' },
{ prop: 'actualQty' },
{ prop: 'amount' }
]
test('buildStatsRowColumns: hidden planNo must not leave a phantom stats cell', () => {
const visible = new Set(['planDate', 'planQty', 'actualQty', 'amount'])
const cols = buildStatsRowColumns({
leadingSpacers: 2,
optionalDefs: ARCHIVE_DEFS,
isColumnVisible: (prop) => visible.has(prop),
moneyProps: ['amount']
})
const props = cols.map((c) => c.prop || c.key)
assert.deepEqual(props, [
'__spacer_0',
'__spacer_1',
'planDate',
'planQty',
'actualQty',
'amount'
])
assert.equal(cols.filter((c) => c.prop === 'planNo').length, 0)
})
test('buildStatsRowColumns: visible planNo appears once after spacers', () => {
const visible = new Set(['planNo', 'planDate', 'planQty'])
const cols = buildStatsRowColumns({
leadingSpacers: 2,
optionalDefs: ARCHIVE_DEFS,
isColumnVisible: (prop) => visible.has(prop)
})
const props = cols.map((c) => c.prop || c.key)
assert.deepEqual(props, ['__spacer_0', '__spacer_1', 'planNo', 'planDate', 'planQty'])
assert.equal(cols.filter((c) => c.prop === 'planNo').length, 1)
})
test('plan-archive: stats row builds from visible columns without always-on planNo', () => {
const src = readFileSync(join(root, 'src/views/pl/plan-archive/index.vue'), 'utf8')
assert.match(
src,
/archiveStatsRowColumns[\s\S]*?buildStatsRowColumns\s*\(/,
'archive stats columns should use buildStatsRowColumns so visibility stays in sync'
)
assert.doesNotMatch(
src,
/archiveStatsRowColumns[\s\S]*?key:\s*'__index'[\s\S]*?key:\s*'planNo'[\s\S]*?for\s*\(\s*const\s+def\s+of\s+listColumnDefs/,
'must not hardcode planNo before looping listColumnDefs (causes off-by-one when hidden)'
)
})
@@ -1,11 +1,11 @@
<!-- 图标组件:支持 Element Plus 图标(无 : 前缀)与 Iconify 图标(含 : 前缀) -->
<template>
<!-- el-icon 勿加 Tailwind `inline`:生产 CSS 中 `.inline{display:inline}` 会覆盖
`.el-icon{display:inline-flex}`,导致 Fold 等图标在打包后不可见 -->
<!-- 勿给图标根节点加 Tailwind `inline`:生产 CSS 中 `.inline{display:inline}`
会覆盖 flex/尺寸,部分 Chrome 下 Fold 等图标不可见 -->
<el-icon v-if="epIcon" v-bind="iconAttrs" class="art-svg-icon">
<component :is="epIcon" />
</el-icon>
<Icon v-else-if="icon" :icon="icon" v-bind="iconAttrs" class="art-svg-icon inline" />
<Icon v-else-if="icon" :icon="icon" v-bind="iconAttrs" class="art-svg-icon" />
</template>
<script setup lang="ts">
@@ -21,17 +21,31 @@
@click="toHome"
/>
<!-- 菜单按钮 -->
<ArtIconButton
<!-- 菜单按钮:内联 SVG,避开 Chrome 下 el-icon / Iconify 偶发不绘制 -->
<button
v-if="isLeftMenu && shouldShowMenuButton"
icon="fold"
class="ml-3 max-sm:ml-[7px] menu-fold-btn"
type="button"
class="menu-fold-btn"
:class="{ 'is-menu-collapsed': !menuOpen }"
:title="menuOpen ? '收起菜单' : '展开菜单'"
:aria-label="menuOpen ? '收起菜单' : '展开菜单'"
:aria-expanded="menuOpen"
@click="visibleMenu"
/>
>
<svg
class="menu-fold-btn__icon"
viewBox="0 0 24 24"
width="20"
height="20"
aria-hidden="true"
focusable="false"
>
<path
fill="currentColor"
d="M21 18v2H3v-2zm0-5v2h-9v-2zm0-5v2h-9V8zM3 3.5v10l5-5z"
/>
</svg>
</button>
<!-- 刷新按钮 - 已隐藏 -->
<ArtIconButton
@@ -388,14 +402,49 @@
}
}
.menu-fold-btn :deep(.art-svg-icon) {
transition: transform 0.3s ease;
/* 顶栏折叠按钮:原生 button + 内联 SVG,保证 Chrome/Safari 一致可见 */
.menu-fold-btn {
box-sizing: border-box;
display: inline-flex;
flex-shrink: 0;
align-items: center;
justify-content: center;
width: 34px;
height: 34px;
margin-left: 12px;
padding: 0;
color: #64748b;
cursor: pointer;
background: transparent;
border: 0;
border-radius: 8px;
appearance: none;
}
.menu-fold-btn.is-menu-collapsed :deep(.art-svg-icon) {
@media (max-width: 640px) {
.menu-fold-btn {
margin-left: 7px;
}
}
.menu-fold-btn:hover {
color: #1e293b;
background: var(--mint-row-alt, #f1f5f9);
}
.menu-fold-btn__icon {
display: block;
width: 20px;
height: 20px;
transition: transform 0.3s ease;
/* 展开态默认旋转,与收起态对调 */
transform: rotate(180deg);
}
.menu-fold-btn.is-menu-collapsed .menu-fold-btn__icon {
transform: rotate(0deg);
}
/* Hover animation classes */
.refresh-btn:hover :deep(.art-svg-icon) {
animation: rotate180 0.5s;
@@ -119,13 +119,7 @@ export function useSettingsConfig() {
handler: 'uniqueOpened',
headerBarKey: null // 不依赖headerBar配置
},
{
key: 'showMenuButton',
label: t('setting.basics.list.collapseSidebar'),
type: 'switch' as const,
handler: 'menuButton',
headerBarKey: 'menuButton' as const
},
// showMenuButton 不提供开关:顶栏收起侧栏按钮为产品必显能力
{
key: 'showFastEnter',
label: t('setting.basics.list.fastEnter'),
@@ -67,7 +67,7 @@ export function useSettingsHandlers() {
uniqueOpened: createToggleHandler(() => settingStore.setUniqueOpened()),
// 显示菜单按钮
menuButton: createToggleHandler(() => settingStore.setButton()),
menuButton: createToggleHandler(() => settingStore.ensureMenuButtonVisible()),
// 显示快速入口
fastEnter: createToggleHandler(() => settingStore.setFastEnter()),
@@ -185,9 +185,8 @@
settingStore.setElementTheme(config.systemThemeColor)
// 界面显示(切换类方法)
toggleIfDifferent(settingStore.showMenuButton, config.showMenuButton, () =>
settingStore.setButton()
)
// 顶栏收起按钮为必显,导入配置时也强制打开
settingStore.ensureMenuButtonVisible()
toggleIfDifferent(settingStore.showFastEnter, config.showFastEnter, () =>
settingStore.setFastEnter()
)
+10 -6
View File
@@ -227,10 +227,15 @@ export const useSettingStore = defineStore(
}
/**
* 切换菜单按钮显示
* 切换菜单按钮显示(产品要求顶栏始终可收起侧栏,禁止关闭)
*/
const setButton = () => {
showMenuButton.value = !showMenuButton.value
showMenuButton.value = true
}
/** 强制显示顶栏侧栏收起按钮,修复旧 localStorage 中 false 残留 */
const ensureMenuButtonVisible = () => {
showMenuButton.value = true
}
/**
@@ -423,6 +428,7 @@ export const useSettingStore = defineStore(
setContainerWidth,
setUniqueOpened,
setButton,
ensureMenuButtonVisible,
setFastEnter,
setAutoClose,
setShowRefreshButton,
@@ -458,10 +464,8 @@ export const useSettingStore = defineStore(
} else if (width === 290) {
ctx.store.setMenuOpenWidth(270)
}
// 旧本地配置把收起按钮关掉了;产品需要顶栏始终能收起侧栏
if (!ctx.store.showMenuButton) {
ctx.store.setButton()
}
// 旧本地配置(sys-v*-setting)可能残留 showMenuButton:false;必须赋值 true,禁止用 toggle
ctx.store.ensureMenuButtonVisible()
}
}
}
+2
View File
@@ -75,6 +75,8 @@
if (!settingStore.showCrumbs) {
settingStore.setCrumbs()
}
// 纠正版本化 localStorage 中 showMenuButton:false,保证折叠钮始终可见
settingStore.ensureMenuButtonVisible()
})
</script>
+10 -17
View File
@@ -970,7 +970,7 @@ import {
overflowExportPlaceholder
} from '@/utils/list-toolbar-overflow-items'
import ListColumnStatsRow from '@/components/business/list-column-stats-row/index.vue'
import type { StatsRowColumn } from '@/utils/list-column-stats'
import { buildStatsRowColumns, type StatsRowColumn } from '@/utils/list-column-stats'
import { useContractDetailDialog } from '@/composables/useContractDetailDialog'
import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
import { useListTableViewportHeight } from '@/composables/useListTableViewportHeight'
@@ -1287,22 +1287,15 @@ const {
const archiveStatsRowRef = ref<{ resync?: () => void } | null>(null)
const archiveStatsRowColumns = computed((): StatsRowColumn[] => {
const cols: StatsRowColumn[] = [
{ key: '__selection', interactive: false },
{ key: '__index', interactive: false },
{ key: 'planNo', interactive: true, prop: 'planNo' }
]
for (const def of listColumnDefs.value) {
if (!isArchiveColumnVisible(def.prop)) continue
cols.push({
key: def.prop,
interactive: true,
prop: def.prop
})
}
return cols
})
/** 与表头可见列一一对应:勾选/序号占位 + 可见业务列(含可隐藏的 planNo) */
const archiveStatsRowColumns = computed((): StatsRowColumn[] =>
buildStatsRowColumns({
leadingSpacers: 2,
optionalDefs: listColumnDefs.value,
isColumnVisible: isArchiveColumnVisible,
moneyProps: PRICE_COLUMN_PROPS
})
)
function getArchiveStatCellValue(row: PlPlanListDisplayRow, prop: string): unknown {
const plan = row.plan
+31
View File
@@ -84,6 +84,7 @@ server {
}
# MinIO(bucket=ruoyi);兼容旧链接,推荐逐步切到 res.shanxiachem.com
# 必须 proxy_hide_header 上游 CORS,否则 MinIO 的 Origin 与 nginx 的 * 叠成非法双头
location ^~ /ruoyi/ {
proxy_pass http://127.0.0.1:9000;
@@ -96,8 +97,15 @@ server {
proxy_send_timeout 60s;
proxy_read_timeout 60s;
proxy_hide_header Access-Control-Allow-Origin;
proxy_hide_header Access-Control-Allow-Methods;
proxy_hide_header Access-Control-Allow-Headers;
proxy_hide_header Access-Control-Expose-Headers;
proxy_hide_header Access-Control-Allow-Credentials;
add_header Access-Control-Allow-Origin * always;
add_header Access-Control-Allow-Methods 'GET, HEAD, OPTIONS' always;
add_header Access-Control-Allow-Headers 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always;
if ($request_method = 'OPTIONS') {
return 204;
@@ -224,6 +232,7 @@ server {
}
}
# 必须 proxy_hide_header 上游 CORS,否则 MinIO 的 Origin 与 nginx 的 * 叠成非法双头
location ^~ /ruoyi/ {
proxy_pass http://127.0.0.1:9000;
@@ -236,8 +245,15 @@ server {
proxy_send_timeout 60s;
proxy_read_timeout 60s;
proxy_hide_header Access-Control-Allow-Origin;
proxy_hide_header Access-Control-Allow-Methods;
proxy_hide_header Access-Control-Allow-Headers;
proxy_hide_header Access-Control-Expose-Headers;
proxy_hide_header Access-Control-Allow-Credentials;
add_header Access-Control-Allow-Origin * always;
add_header Access-Control-Allow-Methods 'GET, HEAD, OPTIONS' always;
add_header Access-Control-Allow-Headers 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always;
if ($request_method = 'OPTIONS') {
return 204;
@@ -364,6 +380,7 @@ server {
}
}
# 必须 proxy_hide_header 上游 CORS,否则 MinIO 的 Origin 与 nginx 的 * 叠成非法双头
location ^~ /ruoyi/ {
proxy_pass http://127.0.0.1:9000;
@@ -376,8 +393,15 @@ server {
proxy_send_timeout 60s;
proxy_read_timeout 60s;
proxy_hide_header Access-Control-Allow-Origin;
proxy_hide_header Access-Control-Allow-Methods;
proxy_hide_header Access-Control-Allow-Headers;
proxy_hide_header Access-Control-Expose-Headers;
proxy_hide_header Access-Control-Allow-Credentials;
add_header Access-Control-Allow-Origin * always;
add_header Access-Control-Allow-Methods 'GET, HEAD, OPTIONS' always;
add_header Access-Control-Allow-Headers 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always;
if ($request_method = 'OPTIONS') {
return 204;
@@ -477,6 +501,7 @@ server {
add_header X-Content-Type-Options "nosniff" always;
# 必须 proxy_hide_header 上游 CORS,否则 MinIO 的 Origin 与 nginx 的 * 叠成非法双头
location ^~ /ruoyi/ {
proxy_pass http://127.0.0.1:9000;
@@ -489,6 +514,12 @@ server {
proxy_send_timeout 60s;
proxy_read_timeout 60s;
proxy_hide_header Access-Control-Allow-Origin;
proxy_hide_header Access-Control-Allow-Methods;
proxy_hide_header Access-Control-Allow-Headers;
proxy_hide_header Access-Control-Expose-Headers;
proxy_hide_header Access-Control-Allow-Credentials;
add_header Access-Control-Allow-Origin * always;
add_header Access-Control-Allow-Methods 'GET, HEAD, OPTIONS' always;
add_header Access-Control-Allow-Headers 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always;