From a5a68488f0e2fb6dbc2a93ebb97cc74487428825 Mon Sep 17 00:00:00 2001 From: ThearchyHelios Date: Sun, 4 Oct 2026 02:19:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=9B=AE=E5=BD=95=20F2b?= =?UTF-8?q?=EF=BC=9A=E5=8A=A9=E6=89=8B=E3=80=8C=E5=BB=BA=E8=AE=AE=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=95=B0=E6=8D=AE=E7=9B=AE=E5=BD=95=E3=80=8D=E5=8D=A1?= =?UTF-8?q?=E7=89=87=E8=A1=A5=E4=B8=8A=E6=9C=8D=E5=8A=A1=E7=AB=AF=E5=AF=B9?= =?UTF-8?q?=E4=B8=80=E9=A1=B9=E7=9A=84=E8=AF=B4=E6=98=8E=EF=BC=88=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E7=9A=84=E5=85=B3=E8=81=94=E5=85=B3=E7=B3=BB=E6=B2=A1?= =?UTF-8?q?=E5=86=99=E5=9F=BA=E6=95=B0=E3=80=81=E5=8F=88=E6=8E=A8=E7=AE=97?= =?UTF-8?q?=E4=B8=8D=E5=87=BA=E6=9D=A5=E6=97=B6=20PatchChange=20=E5=B8=A6?= =?UTF-8?q?=E7=9A=84=20note=EF=BC=89=EF=BC=8C=E5=86=99=E5=9C=A8=E9=82=A3?= =?UTF-8?q?=E4=B8=80=E9=A1=B9=E4=B8=8B=E9=9D=A2=EF=BC=9B=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E6=97=B6=E4=BF=9D=E7=95=99=20note=EF=BC=9B=E8=A1=A5=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E8=84=9A=E6=9C=AC=E7=9A=84=E6=96=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/lib/terms.ts | 2 ++ frontend/src/run/CatalogPatchCard.tsx | 11 +++++++++-- frontend/src/run/catalogPatch.ts | 1 + frontend/src/types.ts | 2 ++ scripts/check-studio.mjs | 10 +++++++++- 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/frontend/src/lib/terms.ts b/frontend/src/lib/terms.ts index aee96903..36434933 100644 --- a/frontend/src/lib/terms.ts +++ b/frontend/src/lib/terms.ts @@ -2529,6 +2529,8 @@ export const CATALOG_UI_TEXT = { savedImpact: (n: number) => `已保存。${formatNumber(n)} 个已发布模板引用这张表,下次正式运行时会提示数据目录有变化`, savedImpactShow: '查看模板', savedImpactDismiss: '收起这条提示', + // ---- 助手「建议更新数据目录」卡片:服务端对一项的说明(新增的关联关系推算不出基数) + patchNote: '说明', } // =========================================================================== diff --git a/frontend/src/run/CatalogPatchCard.tsx b/frontend/src/run/CatalogPatchCard.tsx index d8100689..d4c7d4d0 100644 --- a/frontend/src/run/CatalogPatchCard.tsx +++ b/frontend/src/run/CatalogPatchCard.tsx @@ -1,11 +1,11 @@ import { useCallback, useState } from 'react' import { Link } from 'react-router-dom' -import { BookMarked, Check, ExternalLink, RotateCw } from 'lucide-react' +import { BookMarked, Check, ExternalLink, Info, RotateCw } from 'lucide-react' import clsx from 'clsx' import { ApiError, api } from '../api/client' import { Notice, Spinner, toast } from '../components/ui' import { CatalogImpactList } from '../components/CatalogImpact' -import { CATALOG_PATCH_TEXT as T, CATALOG_STATUS_LABEL } from '../lib/terms' +import { CATALOG_PATCH_TEXT as T, CATALOG_STATUS_LABEL, CATALOG_UI_TEXT as UT } from '../lib/terms' import type { CatalogPatchChange } from '../types' import { catalogTableHref, codeMeaning, patchSubmit, patchTarget, patchValueText, patchWhere, type CatalogPatch, @@ -198,6 +198,13 @@ function ChangeRow({ change: c, dense }: { change: CatalogPatchChange; dense: bo )} + {/* 服务端的说明(新增关系推算不出基数时):保存照样能存,但要让人知道哪一处空着、影响哪条检查 */} + {c.note && ( +

+ + {UT.patchNote}:{c.note} +

+ )} ) } diff --git a/frontend/src/run/catalogPatch.ts b/frontend/src/run/catalogPatch.ts index 16be315c..900ae164 100644 --- a/frontend/src/run/catalogPatch.ts +++ b/frontend/src/run/catalogPatch.ts @@ -61,6 +61,7 @@ function changeOf(x: unknown): CatalogPatchChange | null { value: 'value' in c ? c.value : c.after, reason: typeof c.reason === 'string' ? c.reason : '', state: typeof c.state === 'string' && STATES.has(c.state) ? c.state as CatalogPatchChange['state'] : 'change', + ...(typeof c.note === 'string' && c.note.trim() ? { note: c.note.trim() } : {}), } } diff --git a/frontend/src/types.ts b/frontend/src/types.ts index a89b1e58..215e4b66 100644 --- a/frontend/src/types.ts +++ b/frontend/src/types.ts @@ -2761,6 +2761,8 @@ export interface CatalogPatchChange { reason: string /** change 值有变化;confirm 值相同、还不是已确认(保存即确认);same 已经是这个值且已确认 */ state: 'change' | 'confirm' | 'same' + /** 服务端对这一项的说明(目前只有:新增的关联关系没写基数、又推算不出来)。没有时不给 */ + note?: string } /** 保存、预览提案时交回的一项:路径、原样取值、理由 */ diff --git a/scripts/check-studio.mjs b/scripts/check-studio.mjs index 90cba8cc..7bec27aa 100644 --- a/scripts/check-studio.mjs +++ b/scripts/check-studio.mjs @@ -1149,7 +1149,12 @@ await section('助手改图:一步撤销、回执、只回话、失败退回 { op: 'model', model: 'fake-model' }, { op: 'catalog_patch', source: 'shop', source_id: 'src-shop', table: 'orders', table_label: '订单', version: 2, changes: [ { path: 'columns.status.codes', before: { 1: '已支付' }, before_status: 'confirmed', after: { 1: '已支付', 9: '作废' }, - value: { 9: '作废' }, reason: '用户说明 status=9 表示作废', state: 'change' }] }, + value: { 9: '作废' }, reason: '用户说明 status=9 表示作废', state: 'change' }, + // 新增的关联关系没写基数、又推算不出来:服务端(PatchChange.as_dict)带一句说明 + { path: 'relations.rmember-id-members-id', before: null, before_status: null, + after: { columns: ['member_id'], to_table: 'members', to_columns: ['id'], cardinality: null }, + value: { columns: ['member_id'], to_table: 'members', to_columns: ['id'] }, reason: '用户说明 member_id 对应会员', state: 'change', + note: '没有写明基数,表结构里也查不到两端的主键和唯一约束,基数暂时空着;一对多关联后重复计算的检查用不上这条关系' }] }, { op: 'reply', text: '已整理成数据目录的修改建议。' }, ] const patchSent = [] @@ -1169,6 +1174,9 @@ await section('助手改图:一步撤销、回执、只回话、失败退回 const patchCard = page.locator('[data-catalog-patch="orders"]').last() check('助手栏里有「建议更新数据目录」卡片', await patchCard.waitFor({ timeout: 3000 }).then(() => true, () => false) && (await patchCard.innerText()).includes('列 status 的码值')) + const noteRow = patchCard.locator('[data-patch-change="relations.rmember-id-members-id"]') + check('……服务端对一项的说明(新增关系推算不出基数)写在那一项下面', (await noteRow.locator('[data-patch-note]').innerText().catch(() => '')) + .includes('没有写明基数') && await patchCard.locator('[data-patch-note]').count() === 1, await noteRow.innerText().catch(() => '')) await patchCard.locator('[data-patch-save]').click() await patchCard.locator('[data-patch-done]').waitFor({ timeout: 3000 }) check('保存带版本和原样取值', patchSent[0]?.if_version === 2 && JSON.stringify(patchSent[0]?.changes?.[0]?.value) === '{"9":"作废"}',