From 1e707c43c588846661a498a5e44ba0d3fd30400d Mon Sep 17 00:00:00 2001 From: ThearchyHelios Date: Thu, 15 Oct 2026 15:03:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=93=9D=E5=9B=BE=E5=8D=A1=E7=89=87=E5=8A=A0?= =?UTF-8?q?=E3=80=8C=E7=A1=AE=E8=AE=A4=E5=85=A8=E9=83=A8=E3=80=8D=EF=BC=9A?= =?UTF-8?q?=E4=B8=80=E5=BC=A0=E5=8D=A1=E7=89=87=E4=B8=8A=E5=BE=85=E7=A1=AE?= =?UTF-8?q?=E8=AE=A4=E3=80=81=E6=9C=89=E5=80=BC=E7=9A=84=E9=A1=B9=E4=B8=8D?= =?UTF-8?q?=E6=AD=A2=E4=B8=80=E9=A1=B9=E6=97=B6=EF=BC=8C=E5=8D=A1=E5=A4=B4?= =?UTF-8?q?=E6=91=86=E3=80=8C=E7=A1=AE=E8=AE=A4=E5=85=A8=E9=83=A8=EF=BC=88?= =?UTF-8?q?N=EF=BC=89=E3=80=8D=EF=BC=8C=E4=B8=80=E6=AC=A1=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=B8=A6=E4=B8=8A=E8=BF=99=E5=87=A0=E9=A1=B9=E7=9A=84?= =?UTF-8?q?=E7=8A=B6=E6=80=81=EF=BC=88=E5=8F=AA=E6=94=B9=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E3=80=81=E6=9D=A5=E6=BA=90=E4=B8=8D=E5=8F=98=EF=BC=8C=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=AB=AF=E6=95=B4=E6=89=B9=E8=90=BD=E6=88=96=E6=95=B4?= =?UTF-8?q?=E6=89=B9=E4=B8=8D=E8=90=BD=EF=BC=89=EF=BC=8C=E4=B8=8D=E7=94=A8?= =?UTF-8?q?=E5=86=8D=E4=B8=80=E9=A1=B9=E4=B8=80=E9=A1=B9=E7=82=B9=EF=BC=9B?= =?UTF-8?q?=E5=8F=AA=E6=9C=89=E4=B8=80=E9=A1=B9=E7=9A=84=E7=94=A8=E5=AE=83?= =?UTF-8?q?=E8=87=AA=E5=B7=B1=E7=9A=84=E3=80=8C=E7=A1=AE=E8=AE=A4=E3=80=8D?= =?UTF-8?q?=E3=80=82=E6=8C=89=E9=92=AE=E3=80=8C=E6=94=B9=E3=80=8D=E6=94=B9?= =?UTF-8?q?=E6=88=90=E3=80=8C=E4=BF=AE=E6=94=B9=E3=80=8D=EF=BC=8C=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=BC=96=E8=BE=91=E7=9A=84=E3=80=8C=E6=94=B9=E6=96=87?= =?UTF-8?q?=E5=AD=97=E3=80=8D=E6=94=B9=E6=88=90=E3=80=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=96=87=E5=AD=97=E3=80=8D=EF=BC=9B=E6=A3=80=E6=9F=A5=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E8=B7=9F=E4=B8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/lib/termsApp.ts | 4 +- frontend/src/lib/termsBlueprint.ts | 7 +- .../src/pages/blueprints/BlueprintCards.tsx | 80 +++++++++++++------ scripts/check-blueprint.mjs | 13 ++- 4 files changed, 75 insertions(+), 29 deletions(-) diff --git a/frontend/src/lib/termsApp.ts b/frontend/src/lib/termsApp.ts index db982f63..13c5b33e 100644 --- a/frontend/src/lib/termsApp.ts +++ b/frontend/src/lib/termsApp.ts @@ -491,8 +491,8 @@ export const PAGE_EDIT_TEXT = { personalNoPublish: '个人应用没有发布这一步:改动保存后直接生效', // ---- 小工具条 toolbar: (label: string) => `「${label}」的操作`, - editText: '改文字', - editTextTitle: (label: string) => `改「${label}」的文字`, + editText: '修改文字', + editTextTitle: (label: string) => `修改「${label}」的文字`, editTextHint: '只改组件上显示的文字,不改它的数据来源', noText: '这个组件没有可改的文字', saveText: '保存文字', diff --git a/frontend/src/lib/termsBlueprint.ts b/frontend/src/lib/termsBlueprint.ts index 5adf362f..edac4483 100644 --- a/frontend/src/lib/termsBlueprint.ts +++ b/frontend/src/lib/termsBlueprint.ts @@ -112,8 +112,8 @@ export const BLUEPRINT_TEXT = { // 右边的卡片 cardsTitle: '卡片', cardsHint: '每张卡片是一件你能判断对错的事。「缺」的要补上才能试运行,「待确认」的发布前要确认。', - edit: '改', - editTitle: (what: string) => `改「${what}」`, + edit: '修改', + editTitle: (what: string) => `修改「${what}」`, save: '保存', cancel: '取消', saving: '正在保存…', @@ -121,6 +121,9 @@ export const BLUEPRINT_TEXT = { confirm: '确认', confirmHint: '这一项没问题:标成已确认,来源不变', confirmed: '已确认', + confirmAll: (n: number) => `确认全部(${n})`, + confirmAllHint: (n: number) => `这张卡片上待确认的 ${n} 项都标成已确认,来源不变`, + confirmedAll: (n: number) => `已确认 ${n} 项`, remove: '删掉这一项', removed: '已删掉', add: '加一项', diff --git a/frontend/src/pages/blueprints/BlueprintCards.tsx b/frontend/src/pages/blueprints/BlueprintCards.tsx index 63c36fe3..a6c3ea53 100644 --- a/frontend/src/pages/blueprints/BlueprintCards.tsx +++ b/frontend/src/pages/blueprints/BlueprintCards.tsx @@ -6,8 +6,9 @@ * 条件这些选填的空着也是缺,只看项的状态会把它们都标成缺;「待确认」是助手、模板、目录提的、你还没看过的项。界面不自己判 * 哪些项必填(P7)。 * - * 每一项可以点开改:改完发一个 bp_set(值是纯值,服务端记成来源「你」、已确认);待确认的可以直接点「确认」(只改状态, - * 来源不变)。加一项是 bp_add(卡片字段写纯值),删一项是 bp_remove。对到数据的项写表、中文名、粒度、业务日期和 + * 每一项可以点「修改」:改完发一个 bp_set(值是纯值,服务端记成来源「你」、已确认);待确认的可以直接点「确认」(只改状态, + * 来源不变),一张卡片上待确认的不止一项时卡头另有「确认全部」,一次修改带上这几项的状态(服务端整批落或整批不落)。 + * 加一项是 bp_add(卡片字段写纯值),删一项是 bp_remove。对到数据的项写表、中文名、粒度、业务日期和 * 「为什么对到这张表」(来自查看和数据目录)。 * * 关节:按卡片生成之后列出生成关节的状态;「让助手填」走 fill-joints-stream,各组并行,逐组写进度。 @@ -87,6 +88,11 @@ function cardStatus(ctx: CardCtx, card: CardKey, items: [string, BpItem | null | return shown.includes('confirmed') ? 'confirmed' : null } +/** 这张卡片上待确认、有值的项(各自有「确认」按钮的那几项) */ +function pendingOf(items: [string, BpItem | null | undefined][]): string[] { + return items.filter(([, i]) => isItem(i) && i.status === 'proposed' && i.value != null && i.value !== '').map(([p]) => p) +} + /** 新加一项的 id(数据项、步骤):小写字母开头,和已有的不重 */ function freshId(prefix: string, taken: string[]): string { for (let n = taken.length + 1; ; n += 1) if (!taken.includes(`${prefix}${n}`)) return `${prefix}${n}` @@ -143,28 +149,35 @@ function CardFor({ card, ctx, template }: { card: CardKey; ctx: CardCtx; templat ) case 'template': return - case 'data': + case 'data': { + const items = spec.data.flatMap((d, i) => DATA_KEYS.map((k) => [`/data/${i}/${k}`, d[k] as BpItem] as [string, BpItem])) return ( - DATA_KEYS.map((k) => [`/data/${i}/${k}`, d[k] as BpItem] as [string, BpItem])))} - actions={ ({ id: freshId('d', spec.data.map((d) => d.id)), label: name })} />}> + + + ({ id: freshId('d', spec.data.map((d) => d.id)), label: name })} /> + }> {spec.data.length === 0 && } {spec.data.map((d, i) => )} ) + } case 'cadence': return ( ) - case 'people': + case 'people': { + const items = spec.people.flatMap((s, i) => STEP_KEYS.map((k) => [`/people/${i}/${k}`, s[k] as BpItem] as [string, BpItem])) return ( - STEP_KEYS.map((k) => [`/people/${i}/${k}`, s[k] as BpItem] as [string, BpItem])))} - actions={ ({ id: freshId('s', spec.people.map((s) => s.id)), label: name })} />}> + + + ({ id: freshId('s', spec.people.map((s) => s.id)), label: name })} /> + }> {spec.people.length === 0 && } {spec.people.map((s, i) => ( ) - case 'fields': + } + case 'fields': { + const items = spec.fields.map((f, i) => [`/fields/${i}/spec`, f.spec] as [string, BpItem]) return ( - [`/fields/${i}/spec`, f.spec] as [string, BpItem]))} - actions={ ({ name: freshFieldName(name, spec.fields.map((f) => f.name)), sensitive: false, - spec: { type: 'string', title: name } })} />}> + + + ({ name: freshFieldName(name, spec.fields.map((f) => f.name)), sensitive: false, + spec: { type: 'string', title: name } })} /> + }> {spec.fields.length === 0 && } {spec.fields.map((f, i) => )} ) + } case 'writeback': { const wb = spec.writeback + const items: [string, BpItem][] = wb ? [['/writeback/capability', wb.capability], ['/writeback/mapping', wb.mapping], + ['/writeback/confirm', wb.confirm]] : [] return ( - void ctx.edit.run('wb', [{ op: 'bp_set', path: '/writeback', value: {} }])}> {BP_EDIT_TEXT.addWriteback} - ) : undefined}> + ) : }> {!wb ? : ( @@ -281,7 +299,23 @@ function SubBlock({ ctx, title, path, attr, head, children }: { ) } -/** 卡片上的一项:名字、值、状态、来源、为什么;「改」打开编辑框,待确认的可以直接确认 */ +/** + * 「确认全部」:这张卡片上待确认的项一次标成已确认(一次修改带上这几项的 /status,服务端整批落或整批不落,来源不变)。 + * 只有一项时不摆,用那一项自己的「确认」 + */ +function ConfirmAll({ ctx, card, paths }: { ctx: CardCtx; card: CardKey; paths: string[] }) { + if (paths.length < 2) return null + const ops = paths.map((p): BpOp => ({ op: 'bp_set', path: `${p}/status`, value: 'confirmed' })) + return ( + + ) +} + +/** 卡片上的一项:名字、值、状态、来源、为什么;「修改」打开编辑框,待确认的可以直接确认 */ function ItemRow({ ctx, path, item, label, kind }: { ctx: CardCtx; path: string; item: BpItem | null | undefined; label: string; kind: EditorKind }) { diff --git a/scripts/check-blueprint.mjs b/scripts/check-blueprint.mjs index 306eada3..2f757ecf 100644 --- a/scripts/check-blueprint.mjs +++ b/scripts/check-blueprint.mjs @@ -6,8 +6,8 @@ // (模板卡写适用场景、会产出什么、要准备什么)、从已有的开始(最近的问数据回答;已发布的工作流只给搭建者)。身份决定范围: // 搭建者建共享蓝图;使用者在管理员开了个人应用时建个人蓝图,个人应用用不了的模板不给选;开关没开照实说没开放; // 应用首页的「新建应用」链到 /apps/create; -// - 卡片:卡头标状态(缺按服务端检查、待确认、已确认),对到数据的项写表、中文名、粒度、业务日期、为什么;点开改发 bp_set -// (纯值),确认只改状态,加一项发 bp_add(纯值);缺项时「用真数试一次」置灰并写清缺什么; +// - 卡片:卡头标状态(缺按服务端检查、待确认、已确认),对到数据的项写表、中文名、粒度、业务日期、为什么;「修改」发 bp_set +// (纯值),确认只改状态,「确认全部」一次带上整张卡片待确认的几项,加一项发 bp_add(纯值);缺项时「用真数试一次」置灰并写清缺什么; // - 反问:助手的 bp_ask 画成可点的选项,「这一轮在等你回答」常显,输入框提示回答;点选项就是把它作为下一轮发出去(回答记在 // 问题上、这一轮落进蓝图对话都是服务端做的,前端不另记); // - 关节:只列生成关节,按卡片填的汇总一句;「让助手填」走 fill-joints-stream,逐组写进度,组之间并行; @@ -472,6 +472,15 @@ await section('蓝图页:卡片的状态、对到的数据、改一项、缺 check('加一项:bp_add,卡片字段写纯值、id 不和已有的重', await until(() => (state.patches ?? []).length === 3) && JSON.stringify(state.patches[2].ops) === JSON.stringify([{ op: 'bp_add', path: '/data', value: { id: 'd3', label: '订单数' } }]), JSON.stringify(state.patches?.[2])) + // 确认全部:这张卡片上待确认、有值的几项一次标成已确认(单位、对到的表、算法);只有一项的卡片(多久更新)不摆 + const confirmAll = page.locator('[data-card="data"] [data-bp-confirm-all]') + check('卡头有「确认全部」,写明几项', (await confirmAll.innerText()).includes('确认全部(3)') + && await page.locator('[data-card="cadence"] [data-bp-confirm-all]').count() === 0, await confirmAll.innerText()) + check('改值的按钮写「修改」', (await page.locator('[data-bp-item="/data/0/unit"] [data-bp-edit]').innerText()).trim() === '修改') + await confirmAll.click() + check('确认全部:一次修改带上这几项的状态,只改状态', await until(() => (state.patches ?? []).length === 4) + && JSON.stringify(state.patches[3].ops) === JSON.stringify(['/data/0/unit', '/data/0/table', '/data/0/measure'] + .map((p) => ({ op: 'bp_set', path: `${p}/status`, value: 'confirmed' }))), JSON.stringify(state.patches?.[3])) // 被拒:照实说服务端的原因 state.patchReject = '「单位」最多 20 个字' await page.locator('[data-bp-item="/data/0/unit"] [data-bp-edit]').click()