dsh-form-fill-agent 0.2.19 → 0.2.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/lib/brand.css +13 -0
- package/lib/http.js +7 -4
- package/lib/mapping-recommendations.js +3 -1
- package/lib/task-presentation.js +31 -0
- package/lib/ui.html +32 -24
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
AI填表智能体:支持自动填表、表格填充、表格补全、Excel填表与 Excel回填;使用企查查 MCP 填写 XLSX 空白字段,预览确认后导出新副本。
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
|
-
dsh plugin --profile web add dsh-form-fill-agent@0.2.
|
|
8
|
+
dsh plugin --profile web add dsh-form-fill-agent@0.2.21
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
请先满足下文的 DSH、连接器及侧边栏依赖要求;安装后完整停止并重启对应 Profile。
|
|
@@ -55,7 +55,7 @@ dsh plugin --profile web add dsh-form-fill-agent@latest
|
|
|
55
55
|
- 结果筛选显示当前/总数及已选格数,下载始终包含全部确认内容。
|
|
56
56
|
- 简单 XLSX 安全解析、工作表与表头识别、企业名称或信用代码锚点识别。
|
|
57
57
|
- 确定性字段语义映射、只填空白、单元格级预览与来源追溯。
|
|
58
|
-
-
|
|
58
|
+
- 137 字段目录:工商、企业简介、联系方式、上市、开票、进出口、自身及关联风险、实际控制人。唯一完整实控人记录可填写,多名/分页/异常留空待核验。事实和确定性摘要区分来源,不生成风险结论。
|
|
59
59
|
- 五步工作台、指令回填、任务历史、可恢复单元格选择、取消/失败重试与重启恢复。
|
|
60
60
|
- 可选择工作表、表头行并修正字段映射;修改后需重新预览。
|
|
61
61
|
- 查询主体不一致时展示返回候选,人工选择或补充已核验的完整主体后重新查询,原表名称不覆盖。
|
|
@@ -64,7 +64,7 @@ dsh plugin --profile web add dsh-form-fill-agent@latest
|
|
|
64
64
|
|
|
65
65
|
## 使用边界与数据保存
|
|
66
66
|
|
|
67
|
-
补充要求为模型可读文本;字段或工作表范围请通过向导/工作台修改,不能仅改文字后假定执行范围已同步。任务 schema 5 可读取 schema 1–5;回退旧版本请使用升级前目录副本或独立任务目录。主包为 0.2.
|
|
67
|
+
补充要求为模型可读文本;字段或工作表范围请通过向导/工作台修改,不能仅改文字后假定执行范围已同步。任务 schema 5 可读取 schema 1–5;回退旧版本请使用升级前目录副本或独立任务目录。主包为 0.2.21,共享内核为 0.2.10,Provider 为 0.2.2,共享字段契约为 0.1.0。
|
|
68
68
|
|
|
69
69
|
支持企业完整登记名称或 18 位信用代码;简称、主体不一致或多候选不会自动猜选。仅有信用代码的表格也可作为查询锚点。连接候选检索工具时可检索简称,仍需人工确认;缺少工具时降级人工输入。字段映射采用确定性规则及人工确认,不让模型编造事实。支持普通内部公式、固定区域下拉、基础条件格式和普通表格对象;复杂 Excel 结构和 Word 暂不支持,保真边界见下方安全说明。
|
|
70
70
|
|
|
@@ -72,7 +72,7 @@ dsh plugin --profile web add dsh-form-fill-agent@latest
|
|
|
72
72
|
|
|
73
73
|
显式设置 DSH_HOME 时,任务保存至其 form-fill-tasks 目录,默认 24 小时过期;未设置时使用内存。任务保存输入表格和归一化预览,不持久化原始 MCP 响应,可主动删除任务。模型及 MCP 凭据由宿主管理。
|
|
74
74
|
|
|
75
|
-
0.2.
|
|
75
|
+
0.2.21 保存任务 schema 5,兼容读取旧 schema 1–4;回退旧版本须使用升级前任务目录副本或新目录,防止丢失已确认的字段/主体设置。
|
|
76
76
|
|
|
77
77
|
## 文档与反馈
|
|
78
78
|
|
package/lib/brand.css
CHANGED
|
@@ -60,3 +60,16 @@
|
|
|
60
60
|
.ff-ui #wizard-mapping>.card>h2,.ff-ui #wizard-mapping #mapping-next{display:none}
|
|
61
61
|
.ff-ui #wizard-mapping fieldset{min-width:0}
|
|
62
62
|
.ff-ui #wizard-mapping .ff-mapping-row{min-width:0}
|
|
63
|
+
/* Progress measures processed work, independently from result quality. */
|
|
64
|
+
#progress-panel { padding: 12px 16px; }
|
|
65
|
+
#task-progress { width: 100%; height: 12px; accent-color: #087bd8; }
|
|
66
|
+
#task-progress[data-ended="true"] { accent-color: #138263; }
|
|
67
|
+
#task-progress::-webkit-progress-bar { background: #e3e9ef; border-radius: 6px; }
|
|
68
|
+
#task-progress::-webkit-progress-value { background: #087bd8; border-radius: 6px; }
|
|
69
|
+
#task-progress[data-ended="true"]::-webkit-progress-value { background: #138263; }
|
|
70
|
+
#progress-label { color: var(--action); font-weight: 600; }
|
|
71
|
+
#progress-label[data-ended="true"] { color: var(--success); }
|
|
72
|
+
.ff-review-count { color: var(--review); font-weight: 600; }
|
|
73
|
+
.ff-failure-count { color: var(--error); font-weight: 600; }
|
|
74
|
+
#wizard-grid { min-width: 0; margin-bottom: 16px; }
|
|
75
|
+
#task-meta, #task-details { overflow-wrap: anywhere; }
|
package/lib/http.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { randomUUID, createHash } from 'node:crypto';
|
|
2
2
|
import { readFile } from 'node:fs/promises';
|
|
3
3
|
import { applyChangeSet, parseWorkbook } from 'form-fill-core';
|
|
4
|
-
import { FIELD_CATALOG, QCC_FIELD_CATALOG, ACTUAL_CONTROLLER_GROUP, isCompleteAnchor } from 'qcc-form-fill-provider';
|
|
4
|
+
import { FIELD_CATALOG, QCC_FIELD_CATALOG, ACTUAL_CONTROLLER_GROUP, SNAPSHOT_GROUPS, isCompleteAnchor } from 'qcc-form-fill-provider';
|
|
5
5
|
import { previewBytes } from './workflow.js';
|
|
6
6
|
import { createTaskStore } from './task-store.js';
|
|
7
7
|
import { allCandidates, selectCandidates } from './task-model.js';
|
|
8
8
|
import { gridPage } from './grid.js';
|
|
9
9
|
import { diagnostics } from './diagnostics.js';
|
|
10
|
+
import { taskPresentation, isResultExplanation } from './task-presentation.js';
|
|
10
11
|
import { mappingRecommendations, mappingSearchAliases } from './mapping-recommendations.js';
|
|
11
12
|
const XLSX_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
|
12
13
|
const FIXTURES = ['客户台账', '供应商准入表', '合同主体信息表'];
|
|
@@ -17,17 +18,19 @@ export function createFormFillHandler({ basePath = '', getPort, now = Date.now,
|
|
|
17
18
|
const controllers=new Map();
|
|
18
19
|
const validOwner = value => typeof value === 'string' && /^[a-f0-9]{64}$/.test(value);
|
|
19
20
|
const visible = (task, owner) => task && (!task.owner || task.owner === owner);
|
|
20
|
-
const metadata = (id, task) => ({ id, filename: task.filename ?? '未命名表格.xlsx', revision: task.revision ?? 1, state: task.state ?? (task.result ? 'completed' : 'preview_ready'), created: task.created, updatedAt: task.updatedAt ?? task.created, expiresAt: task.created + ttlMs, sessionId: task.sessionId, confirmed: !!task.result });
|
|
21
|
+
const metadata = (id, task) => ({ id, presentation:taskPresentation(task), filename: task.filename ?? '未命名表格.xlsx', revision: task.revision ?? 1, state: task.state ?? (task.result ? 'completed' : 'preview_ready'), created: task.created, updatedAt: task.updatedAt ?? task.created, expiresAt: task.created + ttlMs, sessionId: task.sessionId, confirmed: !!task.result });
|
|
21
22
|
const settings = task => ({
|
|
22
23
|
mappingProtocol: 2,
|
|
23
24
|
diagnostics: diagnostics(task.preview),
|
|
25
|
+
resultExplanations: task.preview.changeSet.incomplete.filter(isResultExplanation),
|
|
26
|
+
exceptions: task.preview.changeSet.incomplete.filter(i=>!isResultExplanation(i)),
|
|
24
27
|
configuration: task.configuration ?? {},
|
|
25
28
|
selectedFields: task.selectedFields,
|
|
26
29
|
progress: task.progress,
|
|
27
30
|
candidates: allCandidates(task).changes,
|
|
28
31
|
selectedIds: task.preview.changeSet.changes.map(c=>c.id),
|
|
29
32
|
catalog: FIELD_CATALOG.map(field=>({...field,searchAliases:mappingSearchAliases(field.key)})),
|
|
30
|
-
catalogGroups: [...QCC_FIELD_CATALOG,ACTUAL_CONTROLLER_GROUP].map(g=>({id:g.id,label:g.label,fields:g.fields.flatMap(item=>FIELD_CATALOG.filter(f=>f.key===item.id||f.aliases?.includes(item.id)).map(f=>f.key))})),
|
|
33
|
+
catalogGroups: [...QCC_FIELD_CATALOG,ACTUAL_CONTROLLER_GROUP,...SNAPSHOT_GROUPS].map(g=>({id:g.id,label:g.label,fields:g.fields.flatMap(item=>FIELD_CATALOG.filter(f=>f.key===item.id||f.aliases?.includes(item.id)).map(f=>f.key))})),
|
|
31
34
|
structure: parseWorkbook(task.bytes).sheets.filter(s => !s.hidden).map(s => ({
|
|
32
35
|
name: s.name,
|
|
33
36
|
rows: s.rows.filter(r => !r.hidden).slice(0,30).map(r => ({ number: r.number, cells: Object.values(s.cells).filter(c => c.row === r.number && !c.hidden && c.value.trim()).map(c => ({ column: c.column, label: c.value, recommendations: mappingRecommendations(c.value,FIELD_CATALOG) })) })),
|
|
@@ -134,7 +137,7 @@ export function createFormFillHandler({ basePath = '', getPort, now = Date.now,
|
|
|
134
137
|
}
|
|
135
138
|
const preview = await previewBytes(task.bytes, { configuration, selectedFields, ...(task.analyzeOnly !== false ? { provider: { mode: 'mock', version: '0.1.0-alpha.5', capabilities: [], lookup: async () => ({ status: 'not-found' }) } } : {}) });
|
|
136
139
|
if (disposed || tasks.get(body.id) !== task || running.has(body.id)) return send(409, { message: '任务已更新,请刷新后重试' });
|
|
137
|
-
const updated = { ...task, configuration, selectedFields, preview, baseChangeSet:undefined, revision: (task.revision ?? 1)+1, updatedAt: now(), state: 'preview_ready' };
|
|
140
|
+
const updated = { ...task, configuration, selectedFields, preview, progress:undefined, baseChangeSet:undefined, revision: (task.revision ?? 1)+1, updatedAt: now(), state: 'preview_ready' };
|
|
138
141
|
tasks.set(body.id,updated);
|
|
139
142
|
return send(200, { ...preview, ...metadata(body.id,updated), ...settings(updated) });
|
|
140
143
|
}
|
|
@@ -17,6 +17,8 @@ const aliases = {
|
|
|
17
17
|
actual_controller_voting_ratio:['实际控制人表决权比例'],
|
|
18
18
|
};
|
|
19
19
|
const ambiguous = {
|
|
20
|
+
受益人:['beneficial_owner_first_name'],受益所有人:['beneficial_owner_first_name'],UBO:['beneficial_owner_first_name'],
|
|
21
|
+
主营业务收入:['financial_total_revenue'],
|
|
20
22
|
地址:['registered_address','mailing_address','invoice_address'],
|
|
21
23
|
address:['registered_address','mailing_address'],企业地址:['registered_address','mailing_address'],公司地址:['registered_address','mailing_address'],
|
|
22
24
|
开业时间:['established_date'],开业日期:['established_date'],
|
|
@@ -27,7 +29,7 @@ export function mappingSearchAliases(key){
|
|
|
27
29
|
return [...(aliases[key]||[]),...Object.entries(ambiguous).filter(([,keys])=>keys.includes(key)).map(([label])=>label)];
|
|
28
30
|
}
|
|
29
31
|
export function mappingRecommendations(header,catalog){
|
|
30
|
-
const label=normalize(String(header??'').normalize('NFKC').replace(/\s*\(?\s*YYYY[-/]MM[-/]DD\s*\)?\s*$/i,''));
|
|
32
|
+
const label=normalize(String(header??'').normalize('NFKC').replace(/\s*\(重复列\s*\d+\)\s*$/,'').replace(/\s*\(?\s*YYYY[-/]MM[-/]DD\s*\)?\s*$/i,''));
|
|
31
33
|
if(!label)return [];
|
|
32
34
|
const available=new Set(catalog.map(f=>f.key));
|
|
33
35
|
const hinted=Object.entries(ambiguous).find(([name])=>normalize(name)===label)?.[1];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { parseWorkbook } from 'form-fill-core';
|
|
2
|
+
|
|
3
|
+
const retained = new Set(['no-data','user-excluded','formula-preserved','hidden-or-merged','hidden-row','hidden-sheet','sheet-excluded','protected-source-range','placeholder-needs-confirmation']);
|
|
4
|
+
export function taskPresentation(task) {
|
|
5
|
+
const items=task.preview.changeSet.incomplete;
|
|
6
|
+
const failures=Math.max(task.state==='failed'?1:0,items.filter(i=>i.reason==='provider-error').length);
|
|
7
|
+
const review=items.filter(i=>i.reason!=='provider-error'&&!retained.has(i.reason)).length;
|
|
8
|
+
const noData=items.filter(i=>i.reason==='no-data').length;
|
|
9
|
+
const running=task.state==='enriching';
|
|
10
|
+
const ended=!running&&(!!task.progress||!!task.result||task.state==='failed');
|
|
11
|
+
const interrupted=['cancelled','interrupted'].includes(task.state);
|
|
12
|
+
const status=running?'处理中':!ended?'待确认字段':task.state==='failed'?'执行失败':review||failures||interrupted?'处理结束(需核验)':noData?'已完成(部分字段无数据)':'已完成';
|
|
13
|
+
const total=task.progress?.total||0,completed=task.progress?.completed||0;
|
|
14
|
+
// A stopped/cancelled run must not imply that all planned items ran.
|
|
15
|
+
const percent=ended&&!interrupted&&task.state!=='failed'?100:total?Math.min(99,Math.floor(completed/total*100)):0;
|
|
16
|
+
const subjects=new Set();
|
|
17
|
+
const document=parseWorkbook(task.bytes);
|
|
18
|
+
for(const table of task.preview.analysis.tables){
|
|
19
|
+
const sheet=document.sheets.find(s=>s.name===table.sheet);
|
|
20
|
+
const cells=new Map(Object.values(sheet?.cells||{}).map(c=>[c.row+':'+c.column,c]));
|
|
21
|
+
const inputs=table.mappings.filter(m=>table.anchorColumns?table.anchorColumns.includes(m.column):table.anchors.includes(m.field));
|
|
22
|
+
for(const row of sheet?.rows||[]){
|
|
23
|
+
if(row.hidden||row.number<=table.headerRow)continue;
|
|
24
|
+
const values=inputs.map(m=>{const c=cells.get(row.number+':'+m.column);return c&&!c.formula&&!c.hidden?c.value.trim():''});
|
|
25
|
+
if(values.some(Boolean))subjects.add(JSON.stringify(values));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const date=new Intl.DateTimeFormat('zh-CN',{timeZone:'Asia/Shanghai',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hour12:false}).format(new Date(task.created)).replace('/', '-');
|
|
29
|
+
return {title:(task.filename||'未命名表格').replace(/\.xlsx$/i,'')+'|'+subjects.size+' 家企业|'+date,status,running,ended,percent,completed,total,failures,review,noData};
|
|
30
|
+
}
|
|
31
|
+
export const isResultExplanation = item => retained.has(item.reason);
|
package/lib/ui.html
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
<main id="current">
|
|
10
10
|
<nav class="ff-stages" aria-label="工作流程"><button data-step="import"><span class="ff-stage-icon" data-icon="upload"></span><span class="ff-stage-label">导入表格</span></button><button data-step="rules"><span class="ff-stage-icon" data-icon="settings"></span><span class="ff-stage-label">字段设置</span></button><button data-step="identity"><span class="ff-stage-icon" data-icon="identity"></span><span class="ff-stage-label">主体核验</span></button><button data-step="preview"><span class="ff-stage-icon" data-icon="table"></span><span class="ff-stage-label">填写预览</span></button><button data-step="download"><span class="ff-stage-icon" data-icon="download"></span><span class="ff-stage-label">确认下载</span></button></nav>
|
|
11
11
|
<p id="task-meta" class="badge"></p>
|
|
12
|
+
<details><summary>任务详情</summary><p id="task-details"></p></details>
|
|
13
|
+
<div id="progress-panel" hidden><progress id="task-progress" max="100" aria-label="处理进度"></progress><p id="progress-label" role="status"></p><span id="review-count" class="ff-review-count"></span> <span id="failure-count" class="ff-failure-count"></span><p class="muted">100% 只代表处理结束,填写内容需在预览中核验并确认生成副本。</p></div>
|
|
12
14
|
<div class="toolbar ff-execution-toolbar"><span id="execution-progress" role="status"></span><button id="cancel-run" disabled>取消查询</button><button id="retry-run" disabled>仅重试失败 / 未完成查询</button></div>
|
|
13
15
|
<details id="grid" hidden><summary>查看完整原表 / 结果表格</summary><p class="muted">全量行列按页查看,隐藏行列只读标注。结果视图展示当前已选填写;下载不受分页或搜索影响。</p><div class="toolbar"><label>工作表 <select id="grid-sheet"></select></label><label>视图 <select id="grid-view"><option value="original">原表</option><option value="result">结果预览</option></select></label><label>搜索全部行 <input id="grid-query" type="search" maxlength="200"></label><button id="grid-search">搜索</button></div><p id="grid-status" role="status"></p><div class="scroll"><table><thead id="grid-head"></thead><tbody id="grid-body"></tbody></table></div><div class="toolbar"><button id="grid-prev">上一页</button><button id="grid-next">下一页</button><button id="grid-left">前 16 列</button><button id="grid-right">后 16 列</button></div></details>
|
|
14
16
|
<div class="card" data-pane="import"><h2>导入表格</h2><p class="muted">支持 XLSX,最大 8 MiB。支持普通内部公式、固定文本或区域下拉、基础条件格式及普通表格对象;宏、图片、图表及复杂扩展结构暂不支持。上传仅做本地分析,不查询企查查。</p>
|
|
@@ -17,10 +19,10 @@
|
|
|
17
19
|
<section id="preview" hidden>
|
|
18
20
|
<div class="card" data-pane="rules"><h2>字段与规则</h2><p id="structure"></p><p id="anchor-alert" role="status"></p><p>默认只填空白。可选择工作表、修正表头行及字段;应用设置会清除旧预览和主体确认,请重新核验。</p><label>搜索字段 <input id="mapping-search" type="search" placeholder="按原表字段名称筛选"></label><p class="muted">未识别字段可手动选择;没有数据来源的字段选择“不填写”。绿色仅表示字段映射已确认,不代表企业已核验或已查询。多个输出位置可分别确认同一字段;定位企业的输入列需明确。规则只保存表头与映射,不含记录。</p><button id="mapping-save">保存字段规则</button><button id="mapping-load">复用字段规则</button><div id="mapping"></div><button id="configure" class="primary">应用字段设置</button><div id="mapping-next" hidden role="status"><p>设置已保存。下一步核验企业主体,确认填写范围后生成指令并发送,查询结果会进入填写预览。</p><button id="mapping-continue" class="primary">下一步:主体核验</button></div></div>
|
|
19
21
|
<div class="card" data-pane="identity"><h2>主体核验与查询</h2><p id="connection"></p><p>候选不自动选择。查询返回歧义后,可选择返回候选或填写已核验的完整登记名称/信用代码;原表主体文字不覆盖,选择仅用于后续查询。</p><div id="entities"></div><div id="direct-scope" role="status"></div><details id="scope-omissions" hidden><summary>查看未纳入字段</summary><p id="scope-omissions-list"></p></details><label id="direct-ack-label" hidden><input id="direct-ack" type="checkbox">确认仅填写已纳入的原表字段</label><textarea id="direct-command" aria-label="填写指令" readonly hidden></textarea><button id="wizard-open" class="primary">生成填写指令</button><p class="muted">查询不会自动发送;回填后可在原生对话框修改并发送。</p></div>
|
|
20
|
-
<div class="card" data-pane="preview"><h2>填写预览</h2><p id="summary"></p><details><summary>逐列填写结果</summary><p class="muted">按单元格统计;整行缺少主体标识的情况另见下方原因分类。</p><div class="scroll"><table><thead><tr><th>原表字段</th><th>映射字段</th><th>预览可填写格数</th><th>未完成项</th></tr></thead><tbody id="field-results"></tbody></table></div></details><p class="muted">每格显示原值、准备填写值和来源。取消勾选后点击“应用选择”,再确认新的预览。</p>
|
|
22
|
+
<div class="card" data-pane="preview"><h2>填写预览</h2><p id="summary"></p><details><summary>结果说明(未披露及保留位置)</summary><p id="result-explanations"></p></details><details><summary>逐列填写结果</summary><p class="muted">按单元格统计;整行缺少主体标识的情况另见下方原因分类。</p><div class="scroll"><table><thead><tr><th>原表字段</th><th>映射字段</th><th>预览可填写格数</th><th>未完成项</th></tr></thead><tbody id="field-results"></tbody></table></div></details><p class="muted">每格显示原值、准备填写值和来源。取消勾选后点击“应用选择”,再确认新的预览。</p>
|
|
21
23
|
<div class="toolbar"><label>筛选单元格 <input id="result-search" type="search" placeholder="位置、字段或值"></label><span id="result-count" class="muted"></span></div>
|
|
22
24
|
<div class="scroll"><table><thead><tr><th>位置</th><th>字段</th><th>原值</th><th>准备填写</th><th>依据与来源</th><th>填写</th></tr></thead><tbody id="changes"></tbody></table></div><button id="selection">应用选择</button></div>
|
|
23
|
-
<div class="card" data-pane="preview"><h2
|
|
25
|
+
<div class="card" data-pane="preview"><h2>待核验与失败项</h2><p id="reason-summary"></p><div class="scroll"><table><thead><tr><th>位置</th><th>字段</th><th>原因</th></tr></thead><tbody id="incomplete"></tbody></table></div></div>
|
|
24
26
|
<div class="card" data-pane="download"><h2>确认并下载</h2><p>原文件不会被覆盖。下载包含全部已确认填写及完整清单,不受当前筛选影响。</p><button id="confirm" class="primary">确认这些填写,生成新副本</button><div id="downloads"></div></div>
|
|
25
27
|
<details class="ff-task-more"><summary>更多任务操作</summary><div class="controls"><button id="refresh" class="secondary">刷新任务</button><button id="discard" class="secondary">删除任务</button></div></details><div class="ff-next-action" data-pane="preview" hidden><span>核验填充值后继续,下一步生成副本。</span><button id="preview-continue" class="primary">下一步:确认下载</button></div>
|
|
26
28
|
</section></main>
|
|
@@ -28,7 +30,7 @@
|
|
|
28
30
|
<nav class="ff-wizard-nav" aria-label="提示词向导步骤"><button data-wizard-step="0"><span class="ff-step-number">1</span> 数据来源</button><button data-wizard-step="1"><span class="ff-step-number">2</span> 填写规则</button><button data-wizard-step="2"><span class="ff-step-number">3</span> 填写字段</button><button data-wizard-step="3"><span class="ff-step-number">4</span> 确认描述</button></nav>
|
|
29
31
|
<div class="dialog-body">
|
|
30
32
|
<section class="ff-wizard-step" data-wizard-pane="0"><h3>选择需要填写的原表</h3><p class="muted">识别表头与空白字段,再由企查查 MCP 查询对应的企业信息,填写到原表位置。</p><div class="ff-upload-zone"><label>上传 Excel 表格 <input id="wizard-file" type="file" accept=".xlsx"></label><p class="muted">支持 XLSX,最大 8 MiB。保留已有内容,确认结果后生成新副本。</p></div><p id="wizard-source" class="ff-summary"></p><p class="ff-service-note">完成向导后,将任务描述回填到对话框;发送后使用已连接的企查查 MCP 执行核验与填写。</p></section>
|
|
31
|
-
<section class="ff-wizard-step" data-wizard-pane="1"><h3>确认原表字段映射</h3><p id="wizard-rules" hidden></p><div id="wizard-mapping"></div></section>
|
|
33
|
+
<section class="ff-wizard-step" data-wizard-pane="1"><h3>确认原表字段映射</h3><div id="wizard-grid"></div><p id="wizard-rules" hidden></p><div id="wizard-mapping"></div></section>
|
|
32
34
|
<section class="ff-wizard-step" data-wizard-pane="2"><h3>确认填写范围</h3><p>已确认映射已自动纳入,无需重复选择;下方可按需减少填写范围。</p><div class="toolbar"><label>搜索 <input id="field-search" type="search" placeholder="字段名称"></label><span id="field-count"></span><button id="fields-all">选择可用字段</button><button id="fields-clear">清空可选字段</button></div><p class="muted">主体锚点固定保留;只有原表已映射的字段可选。修改映射请返回第二步。</p><div id="wizard-fields" class="ff-field-grid"></div></section>
|
|
33
35
|
<section class="ff-wizard-step" data-wizard-pane="3"><h3>确认任务描述</h3><p id="business-summary" class="ff-summary"></p><p id="scope-review" class="ff-summary"></p><details><summary>查看待补空位置与保留列</summary><pre id="wizard-positions" style="white-space:pre-wrap;max-height:240px;overflow:auto"></pre></details><label id="scope-ack-label" hidden><input id="scope-ack" type="checkbox">确认本次不填写以上列</label><label>补充要求<textarea id="requirements" rows="4" maxlength="1000" placeholder="补充核验说明;字段或范围变更请返回前面步骤设置。"></textarea></label><details><summary>兼容执行信息</summary><p id="qcc-command" class="ff-tech"></p></details></section>
|
|
34
36
|
</div><p id="wizard-message" role="status"></p><footer class="dialog-footer"><button id="wizard-prev">上一步</button><button id="wizard-next" class="primary">下一步</button><button id="draft" class="primary" hidden>回填到对话框</button><button id="copy-command" hidden>复制指令</button></footer></dialog>
|
|
@@ -65,7 +67,9 @@ const reasons={'unknown-field':'暂无可用字段映射','no-capability':'尚
|
|
|
65
67
|
function controls(value){busy=value;document.querySelectorAll('button').forEach(b=>b.disabled=value);if($('wizard').open)renderWizard();syncActions();if(!value)loadGrid()}
|
|
66
68
|
function row(target,values,labels){const tr=document.createElement('tr');values.forEach((v,i)=>{const td=document.createElement('td');td.textContent=v;td.dataset.label=labels[i];tr.append(td)});$(target).append(tr);return tr}
|
|
67
69
|
function syncActions(){
|
|
68
|
-
const running=current?.state==='enriching'
|
|
70
|
+
const running=current?.state==='enriching';
|
|
71
|
+
const p=current?.presentation;$('progress-panel').hidden=!p||(!p.running&&!p.ended);if(p){$('task-progress').value=p.percent;$('task-progress').dataset.ended=String(p.ended);$('progress-label').textContent=(p.running?'处理中':p.ended?'处理结束':'待处理')+' · '+p.percent+'% · '+p.completed+' / '+p.total+' 查询计划项';$('progress-label').dataset.ended=String(p.ended);$('review-count').textContent='待核验 '+p.review+' 项';$('failure-count').textContent='失败 '+p.failures+' 项';}
|
|
72
|
+
$('cancel-run').hidden=!running;$('cancel-run').disabled=busy||!running;
|
|
69
73
|
$('retry-run').hidden=!current||current.confirmed||!current.changeSet.incomplete.some(i=>['provider-error','cancelled','not-started'].includes(i.reason));
|
|
70
74
|
$('retry-run').disabled=busy||!current||current.confirmed||running||!current.changeSet.incomplete.some(i=>['provider-error','cancelled','not-started'].includes(i.reason));
|
|
71
75
|
$('execution-progress').textContent=running?(current.progress?.total?'已处理查询计划项 '+(current.progress?.completed||0)+' / '+current.progress.total+'(含失败,不代表填写成功)':'正在准备查询…'):current?.state==='cancelled'?'已取消,成功结果保留。':current?.state==='interrupted'?'上次查询中断,已保存进度,可重试剩余部分。':'';
|
|
@@ -99,9 +103,10 @@ function scopeReview(){
|
|
|
99
103
|
return {omitted,missing,blocked:!!problem,problem};
|
|
100
104
|
}
|
|
101
105
|
let wizardMappingApplied=false;
|
|
106
|
+
const gridHome=document.createComment('grid home');$('grid').before(gridHome);
|
|
102
107
|
const sharedMapping=document.querySelector('[data-pane="rules"]'),mappingHome=document.createComment('shared mapping home');sharedMapping.before(mappingHome);
|
|
103
108
|
function renderWizard(){
|
|
104
|
-
if($('wizard').open){$('wizard-mapping').append(sharedMapping);sharedMapping.hidden=false}
|
|
109
|
+
if($('wizard').open){$('wizard-mapping').append(sharedMapping);sharedMapping.hidden=false;$('wizard-grid').append($('grid'));if(wizardStep===1){$('grid').open=true;loadGrid()}}
|
|
105
110
|
initWizard();
|
|
106
111
|
document.querySelectorAll('[data-wizard-pane]').forEach(p=>p.setAttribute('aria-current',String(Number(p.dataset.wizardPane)===wizardStep)));
|
|
107
112
|
document.querySelectorAll('[data-wizard-step]').forEach(p=>p.setAttribute('aria-current',String(Number(p.dataset.wizardStep)===wizardStep)));
|
|
@@ -121,17 +126,17 @@ function renderWizard(){
|
|
|
121
126
|
if($('scope-ack').dataset.signature!==signature){$('scope-ack').checked=false;$('scope-ack').dataset.signature=signature}
|
|
122
127
|
$('scope-review').textContent=(review.omitted.length?'本次不填写 '+review.omitted.length+' 列:'+review.omitted.slice(0,3).join('、')+(review.omitted.length>3?'等,详见明细':'')+'。':'所有已映射的非主体字段均已纳入。')+(review.missing.length?'有 '+review.missing.length+' 行缺少可用主体标识;请检查企业名称列,不能使用整列为空的信用代码定位主体。':'');
|
|
123
128
|
$('wizard-positions').textContent=(current?.analysis.opportunities||[]).filter(p=>wizardFields.has(p.field)).slice(0,200).map(p=>p.sheet+'!'+p.cell+':'+p.label).join('\n')+'\n最多展示前 200 个位置;完整计划保存在任务中。\n保留列:'+review.omitted.join('、');
|
|
124
|
-
$('wizard-message').textContent=review.blocked?review.problem:
|
|
125
|
-
$('scope-ack-label').hidden
|
|
129
|
+
$('wizard-message').textContent=review.blocked?review.problem:'';
|
|
130
|
+
$('scope-ack-label').hidden=true;
|
|
126
131
|
$('wizard-next').textContent=wizardStep===1?'应用映射并继续':'下一步';
|
|
127
132
|
$('wizard-prev').disabled=wizardStep===0||busy;$('wizard-next').hidden=wizardStep===3;$('wizard-next').disabled=!current||busy;
|
|
128
|
-
$('draft').hidden=wizardStep!==3;$('copy-command').hidden=wizardStep!==3;$('draft').disabled=!current||!wizardFields.size||busy||review.blocked
|
|
133
|
+
$('draft').hidden=wizardStep!==3;$('copy-command').hidden=wizardStep!==3;$('draft').disabled=!current||!wizardFields.size||busy||review.blocked;$('copy-command').disabled=$('draft').disabled;
|
|
129
134
|
}
|
|
130
135
|
function openWizard(retry=false){retryIntent=retry===true;initWizard();renderWizard();if(!$('wizard').open)$('wizard').showModal();renderWizard();if(parent!==window){document.body.classList.add('ff-modal-host');parent.postMessage({type:'ff-wizard-state',open:true},location.origin)}}
|
|
131
|
-
function closeWizard(focusComposer=false){saveWizard();$('draft-conflict').close();$('wizard').close();mappingHome.after(sharedMapping);sharedMapping.hidden=step!=='rules';document.body.classList.remove('ff-modal-host');if(parent!==window)parent.postMessage({type:'ff-wizard-state',open:false,focusComposer},location.origin);if(!focusComposer)$('wizard-open').focus()}
|
|
136
|
+
function closeWizard(focusComposer=false){saveWizard();$('draft-conflict').close();$('wizard').close();mappingHome.after(sharedMapping);gridHome.after($('grid'));sharedMapping.hidden=step!=='rules';document.body.classList.remove('ff-modal-host');if(parent!==window)parent.postMessage({type:'ff-wizard-state',open:false,focusComposer},location.origin);if(!focusComposer)$('wizard-open').focus()}
|
|
132
137
|
async function applyScope(){
|
|
133
138
|
if(!current||!wizardFields.size)throw Error('请至少选择一个已映射的填写字段');
|
|
134
|
-
const review=scopeReview();if(review.blocked)throw Error('没有可用主体标识,请先到字段设置映射企业名称列。');
|
|
139
|
+
const review=scopeReview();if(review.blocked)throw Error('没有可用主体标识,请先到字段设置映射企业名称列。');
|
|
135
140
|
const original=current.selectedFields||[...new Set(current.analysis.tables.flatMap(t=>t.mappings.filter(m=>m.field&&!isInput(t,m)).map(m=>m.field)))];
|
|
136
141
|
if(retryIntent&&JSON.stringify([...original].sort())!==JSON.stringify([...wizardFields].sort()))throw Error('重试时请保留原字段范围;如需更改,请重新生成完整核验指令。');
|
|
137
142
|
if(JSON.stringify([...original].sort())!==JSON.stringify([...wizardFields].sort()))render(await api('/scope',{id:current.id,selectedFields:[...wizardFields]}));
|
|
@@ -149,14 +154,14 @@ function directScope(){
|
|
|
149
154
|
if($('direct-ack').dataset.signature!==signature){$('direct-ack').checked=false;$('direct-ack').dataset.signature=signature}
|
|
150
155
|
$('direct-scope').textContent=review.problem||'将填写 '+wizardFields.size+' 个已确认字段。'+(review.omitted.length?'另有 '+review.omitted.length+' 列未纳入,可展开查看。':'');
|
|
151
156
|
$('scope-omissions').hidden=!review.omitted.length;$('scope-omissions-list').textContent=review.omitted.slice(0,3).join('、')+(review.omitted.length>3?'等,详见明细':'');
|
|
152
|
-
$('direct-ack-label').hidden
|
|
157
|
+
$('direct-ack-label').hidden=true;
|
|
153
158
|
return review;
|
|
154
159
|
}
|
|
155
160
|
async function directDraft(){
|
|
156
161
|
if(busy||!current)return;
|
|
157
162
|
const review=directScope();
|
|
158
163
|
if(review.blocked){$('status').textContent=review.problem;navigate('rules');$('anchor-alert').textContent=review.problem;$('anchor-alert').scrollIntoView({block:'center'});return}
|
|
159
|
-
|
|
164
|
+
|
|
160
165
|
$('scope-ack').checked=$('direct-ack').checked;
|
|
161
166
|
if(parent===window){$('direct-command').hidden=false;$('direct-command').value=command();$('direct-command').focus();$('direct-command').select();$('status').textContent='指令已生成,请复制到 DSH 对话框发送。';return}
|
|
162
167
|
$('status').textContent='正在回填到对话框…';await sendDraft();
|
|
@@ -165,7 +170,7 @@ function highlightMappingConflicts(){
|
|
|
165
170
|
for(const section of $('mapping').querySelectorAll('fieldset')){
|
|
166
171
|
const fields=[...section.querySelectorAll('select[data-column]')];
|
|
167
172
|
for(const field of fields)field.closest('.ff-mapping-row').updateMappingStatus?.();
|
|
168
|
-
for(const field of fields){const peers=fields.filter(other=>other.value===field.value);const conflict=!!field.value&&peers.length>1&&(
|
|
173
|
+
for(const field of fields){const peers=fields.filter(other=>other.value===field.value);const conflict=!!field.value&&peers.length>1&&(field.dataset.primary==='true'&&peers.filter(other=>other.closest('.ff-mapping-row').querySelector('.ff-mapping-role').value!=='output').length>1);field.setAttribute('aria-invalid',String(conflict));const row=field.closest('.ff-mapping-row');row.classList.toggle('ff-mapping-conflict',conflict);if(conflict){const message=row.querySelector('.ff-mapping-status');message.dataset.state='pending';message.textContent='待人工确认:重复位置需逐一确认;企业标识需保留唯一定位列。';}}
|
|
169
174
|
}
|
|
170
175
|
}
|
|
171
176
|
function filterResults(){const query=$('result-search').value.trim().toLowerCase(),rows=[...$('changes').rows];let shown=0;for(const tr of rows){tr.hidden=!!query&&!tr.textContent.toLowerCase().includes(query);if(!tr.hidden)shown++}const selected=rows.filter(tr=>tr.querySelector('input')?.checked).length;$('result-count').textContent=rows.length?'显示 '+shown+' / '+rows.length+' 格 · 已选 '+selected+' 格'+(!shown?' · 无匹配结果':''):'暂无可填写单元格'}
|
|
@@ -208,9 +213,11 @@ function renderSettings(data){
|
|
|
208
213
|
const status=document.createElement('p');status.className='ff-mapping-status';status.setAttribute('aria-live','polite');
|
|
209
214
|
const count=document.createElement('small');count.className='muted';
|
|
210
215
|
const suggestions=document.createElement('div');suggestions.className='ff-mapping-suggestions';
|
|
216
|
+
const selectionNote=document.createElement('p');selectionNote.className='muted';label.append(selectionNote);
|
|
211
217
|
const updateStatus=()=>{const f=data.catalog.find(f=>f.key===chosen);role.hidden=!(f?.anchor||f?.anchorFallback);select.dataset.manual=String(manual);select.dataset.primary=String(!role.hidden);status.dataset.state=chosen?(manual?'confirmed':'automatic'):manual?'skipped':suggestions.childElementCount?'pending':'unmatched';status.textContent=chosen?(manual?'已确认':'自动通过')+':'+(f?.label||chosen):manual?'已跳过:保留原值,不填写':suggestions.childElementCount?'待人工确认:请选择推荐字段':'未匹配:保留原值,不填写;可搜索字段';};
|
|
212
218
|
label.updateMappingStatus=updateStatus;
|
|
213
|
-
|
|
219
|
+
const originalUpdate=label.updateMappingStatus;label.updateMappingStatus=()=>{originalUpdate();selectionNote.textContent=(data.catalog.find(f=>f.key===(chosen||cell.recommendations?.[0]))?.selectionNote||'')+((chosen||cell.recommendations?.[0])==='financial_total_revenue'&&cell.label.includes('主营业务收入')?';主营业务收入与营业总收入口径不同,采用前请确认。':'')};
|
|
220
|
+
role.onchange=()=>{manual=true;label.updateMappingStatus();highlightMappingConflicts()};
|
|
214
221
|
const options=()=>{
|
|
215
222
|
const group=data.catalogGroups?.find(g=>g.id===dimension.value);
|
|
216
223
|
const found=(data.catalog||[]).filter(f=>matches(f,search.value)&&(!dimension.value||(dimension.value==='other'?!data.catalogGroups?.some(g=>g.fields.includes(f.key)):group?.fields.includes(f.key))));
|
|
@@ -220,9 +227,9 @@ function renderSettings(data){
|
|
|
220
227
|
const buckets=new Map();
|
|
221
228
|
for(const field of list){const option=document.createElement('option');option.value=field.key;option.textContent=field.label;const group=field.key?data.catalogGroups?.find(g=>g.fields.includes(field.key)):null;if(group){if(!buckets.has(group.id)){const optgroup=document.createElement('optgroup');optgroup.label=group.label;select.append(optgroup);buckets.set(group.id,optgroup)}buckets.get(group.id).append(option)}else select.append(option)}
|
|
222
229
|
trigger.textContent=chosen?(data.catalog.find(f=>f.key===chosen)?.label||chosen):'选择填写字段';
|
|
223
|
-
select.value=chosen;count.textContent=found.length?'匹配 '+found.length+' 个字段':'没有匹配字段,请更换关键词或维度';
|
|
230
|
+
select.value=chosen;count.textContent=found.length?'匹配 '+found.length+' 个字段':'没有匹配字段,请更换关键词或维度';label.updateMappingStatus();
|
|
224
231
|
};
|
|
225
|
-
const choose=()=>{chosen=select.value;manual=true;suggestions.replaceChildren();trigger.textContent=chosen?(data.catalog.find(f=>f.key===chosen)?.label||chosen):'不填写';
|
|
232
|
+
const choose=()=>{chosen=select.value;manual=true;suggestions.replaceChildren();trigger.textContent=chosen?(data.catalog.find(f=>f.key===chosen)?.label||chosen):'不填写';label.updateMappingStatus();$('mapping-next').hidden=true};
|
|
226
233
|
const finish=()=>{choose();highlightMappingConflicts();picker.open=false;trigger.focus()};
|
|
227
234
|
select.onchange=choose;
|
|
228
235
|
select.ondblclick=finish;
|
|
@@ -266,27 +273,28 @@ function render(data){
|
|
|
266
273
|
current=data;directScope();$('direct-command').hidden=true;filename=(data.filename||'已填表格.xlsx').replace(/\.xlsx$/i,'');location.hash='task='+data.id;
|
|
267
274
|
if(gridTask!==data.id){gridTask=data.id;gridPageNumber=1;gridColumn=1;$('grid-sheet').replaceChildren();$('grid-query').value=''}$('grid').hidden=false;loadGrid();
|
|
268
275
|
if(parent!==window)parent.postMessage({type:'ff-task',taskId:data.id},location.origin);
|
|
269
|
-
$('incomplete').closest('.card').style.display=data.changeSet.incomplete.length?'':'none';$('changes').replaceChildren();$('incomplete').replaceChildren();$('downloads').replaceChildren();
|
|
276
|
+
$('incomplete').closest('.card').style.display=(data.exceptions||data.changeSet.incomplete).length?'':'none';$('changes').replaceChildren();$('incomplete').replaceChildren();$('downloads').replaceChildren();
|
|
270
277
|
$('task-meta').dataset.state=data.state;
|
|
271
|
-
$('task-meta').textContent=(data.filename
|
|
278
|
+
$('task-meta').textContent=(data.presentation?.title||data.filename)+' · '+(data.presentation?.status||data.state);$('task-details').textContent='任务 ID:'+data.id+' · 有效期至 '+new Date(data.expiresAt).toLocaleString();
|
|
272
279
|
$('summary').textContent='可填写 '+data.changeSet.changes.length+' 格 · '+(data.plan.paidCalls?'企查查来源':'本地分析 / 合成示例 · 费用 0')+' · 未完成 '+data.changeSet.incomplete.length+' 项';
|
|
280
|
+
$('result-explanations').textContent=(data.resultExplanations||[]).map(i=>(i.sheet||'')+' '+(i.cell||'')+':'+(data.diagnostics?.reasons.find(r=>r.code===i.reason)?.label||i.reason)).join(';')||'暂无。';
|
|
273
281
|
$('structure').textContent=data.analysis.tables.map(t=>t.sheet+':表头第 '+t.headerRow+' 行').join(';');
|
|
274
282
|
renderSettings(data);
|
|
275
283
|
for(const c of data.candidates||data.changeSet.changes){const tr=row('changes',[c.sheet+' ! '+c.cell,c.label,c.oldValue||'(空白)',c.newValue,(c.source.startsWith('qcc://')?'企查查 · '+c.source.slice(6):'合成示例')+' · 获取于 '+c.acquiredAt.slice(0,10)+' · 明确字段映射'],['位置','字段','原值','准备填写','来源']);const td=document.createElement('td'),check=document.createElement('input');check.type='checkbox';check.checked=(data.selectedIds||data.changeSet.changes.map(x=>x.id)).includes(c.id);check.value=c.id;check.disabled=data.confirmed;check.setAttribute('aria-label','填写 '+c.cell);td.append(check);tr.append(td)}
|
|
276
|
-
for(const i of data.changeSet.incomplete)row('incomplete',[i.sheet+' '+(i.cell||('第 '+i.row+' 行')),i.label||'—',i.detail||data.diagnostics?.reasons.find(r=>r.code===i.reason)?.label||reasons[i.reason]||'此项需要人工处理'],['位置','字段','原因']);
|
|
284
|
+
for(const i of data.exceptions||data.changeSet.incomplete)row('incomplete',[i.sheet+' '+(i.cell||('第 '+i.row+' 行')),i.label||'—',i.detail||data.diagnostics?.reasons.find(r=>r.code===i.reason)?.label||reasons[i.reason]||'此项需要人工处理'],['位置','字段','原因']);
|
|
277
285
|
$('field-results').replaceChildren();
|
|
278
286
|
for(const column of data.diagnostics?.columns||[])row('field-results',[column.label,(data.catalog.find(f=>f.key===column.field)?.label||'未映射 / 不填写'),column.ready,column.incomplete],['原表字段','映射字段','预览可填写格数','未完成项']);
|
|
279
287
|
$('preview').hidden=false;if(data.confirmed)downloads();$('qcc-command').textContent=command();
|
|
280
288
|
initWizard();filterResults();syncActions();if($('wizard').open)renderWizard();
|
|
281
|
-
$('reason-summary').textContent=(data.diagnostics?.reasons||[]).map(r=>r.label+':'+r.count+r.unit).join(';')||'
|
|
289
|
+
$('reason-summary').textContent=(data.diagnostics?.reasons||[]).filter(r=>(data.exceptions||data.changeSet.incomplete).some(i=>i.reason===r.code)).map(r=>r.label+':'+r.count+r.unit).join(';')||'暂无待核验或失败项。';
|
|
282
290
|
const missing=data.analysis.incomplete.filter(i=>i.reason==='missing-anchor');
|
|
283
291
|
$('anchor-alert').textContent=missing.length?'有 '+missing.length+' 行缺少可用主体标识。请把实际包含名称的列映射为“企业名称”,或提供非空信用代码;当前不会查询这些行。':'';
|
|
284
292
|
}
|
|
285
|
-
async function restore(silent=false){if(busy||!current&& !location.hash)return;const id=new URLSearchParams(location.hash.slice(1)).get('task');if(!id)return;try{const data=await api('/task/'+encodeURIComponent(id));if(!silent||data.id!==current?.id||data.revision!==current?.revision){render(data);if(!silent){const target=pendingNavigation||(data.confirmed?'download':'preview');pendingNavigation=undefined;if(target==='history')$('history-tab').click();else navigate(target)}}}catch(e){if(!silent)$('status').textContent=e.message}}
|
|
293
|
+
async function restore(silent=false){if(busy||!current&& !location.hash)return;const id=new URLSearchParams(location.hash.slice(1)).get('task');if(!id)return;try{const data=await api('/task/'+encodeURIComponent(id));if(!silent||data.id!==current?.id||data.revision!==current?.revision){const wasRunning=current?.state==='enriching';render(data);if(silent&&data.state==='enriching'){navigate('identity');$('status').textContent=$('execution-progress').textContent}else if(silent&&wasRunning){navigate('preview');$('status').textContent='查询已结束,请检查填写预览。'}if(!silent){const target=pendingNavigation||(data.confirmed?'download':'preview');pendingNavigation=undefined;if(target==='history')$('history-tab').click();else navigate(target)}}}catch(e){if(!silent)$('status').textContent=e.message}}
|
|
286
294
|
async function preview(buffer,name,demo=false){controls(true);try{const bytes=new Uint8Array(buffer);if(bytes.length>8388608)throw Error('文件超过 8 MiB');let binary='';for(let i=0;i<bytes.length;i+=32768)binary+=String.fromCharCode(...bytes.subarray(i,i+32768));$('grid').open=true;render(await api('/preview',{base64:btoa(binary),filename:name,sessionId,analyzeOnly:!demo}));navigate(demo?'preview':'rules');$('status').textContent='预览已准备好,请检查后确认。'}catch(e){$('status').textContent=e.message;$('wizard-message').textContent=e.message}finally{controls(false)}}
|
|
287
295
|
document.querySelectorAll('[data-step]').forEach(b=>b.onclick=()=>navigate(b.dataset.step));
|
|
288
296
|
$('file').onchange=async()=>{const input=$('file'),f=input.files[0];if(!f||busy)return;input.disabled=true;controls(true);$('status').textContent='正在自动解析表格…';try{await preview(await f.arrayBuffer(),f.name)}catch(e){$('status').textContent=e.message}finally{input.disabled=false;input.value='';controls(false)}};
|
|
289
|
-
function readMapping(){const configuration={sheets:[],headers:[],mappings:[]};for(const section of $('mapping').querySelectorAll('fieldset')){if(!section.querySelector('.sheet-enabled').checked)continue;const sheet=section.dataset.sheet;configuration.sheets.push(sheet);configuration.headers.push({sheet,row:Number(section.querySelector('.header-row').value)});for(const field of section.querySelectorAll('[data-column]'))if(field.dataset.manual==='true')configuration.mappings.push({sheet,column:Number(field.dataset.column),field:field.value||null,...(field.dataset.primary==='true'?{role:field.closest('.ff-mapping-row').querySelector('.ff-mapping-role').value}:{})})}return configuration}
|
|
297
|
+
function readMapping(){const configuration={sheets:[],headers:[],mappings:[]};for(const section of $('mapping').querySelectorAll('fieldset')){if(!section.querySelector('.sheet-enabled').checked)continue;const sheet=section.dataset.sheet;configuration.sheets.push(sheet);configuration.headers.push({sheet,row:Number(section.querySelector('.header-row').value)});for(const field of section.querySelectorAll('[data-column]'))if(field.value||field.dataset.manual==='true')configuration.mappings.push({sheet,column:Number(field.dataset.column),field:field.value||null,...(field.dataset.primary==='true'?{role:field.closest('.ff-mapping-row').querySelector('.ff-mapping-role').value}:{})})}return configuration}
|
|
290
298
|
function mappingSignature(configuration){return JSON.stringify(configuration.headers.map(h=>({sheet:h.sheet,row:h.row,cells:current.structure.find(s=>s.name===h.sheet)?.rows.find(r=>r.number===h.row)?.cells}))) }
|
|
291
299
|
$('mapping-save').onclick=()=>{try{if(!current||busy)return;const configuration=readMapping();localStorage.setItem('ff-mapping:'+owner,JSON.stringify({schema:1,signature:mappingSignature(configuration),configuration}));$('status').textContent='字段规则已保存在本浏览器。'}catch{$('status').textContent='浏览器无法保存字段规则。'}};
|
|
292
300
|
$('mapping-load').onclick=async()=>{if(!current||busy)return;controls(true);try{const saved=JSON.parse(localStorage.getItem('ff-mapping:'+owner)||'null');if(saved?.schema!==1||saved.signature!==mappingSignature(saved.configuration))throw Error('没有与当前工作表及表头一致的规则,请手动设置。');render(await api('/configure',{id:current.id,configuration:saved.configuration}));$('status').textContent='字段规则已复用,请检查后重新核验。'}catch(e){$('status').textContent=e.message}finally{controls(false)}};
|
|
@@ -296,7 +304,7 @@ $('confirm').onclick=async()=>{if(!current||busy)return;controls(true);try{await
|
|
|
296
304
|
$('selection').onclick=async()=>{if(!current||busy)return;controls(true);try{render(await api('/select',{id:current.id,selectedIds:[...$('changes').querySelectorAll('input:checked')].map(x=>x.value)}));$('status').textContent='选择已应用,请核对新的预览。'}catch(e){$('status').textContent=e.message}finally{controls(false)}};
|
|
297
305
|
$('refresh').onclick=()=>restore();
|
|
298
306
|
$('discard').onclick=async()=>{if(!current||busy)return;controls(true);try{await api('/discard',{id:current.id});current=null;history.replaceState(null,'',location.pathname+location.search);$('preview').hidden=true;$('grid').hidden=true;gridTask=null;navigate('import');$('status').textContent='任务及保存的表格已删除。'}catch(e){$('status').textContent=e.message}finally{controls(false)}};
|
|
299
|
-
$('history-tab').onclick=async()=>{try{const list=await api('/tasks');$('history-list').replaceChildren();for(const item of list){const div=document.createElement('div');div.className='history-item';const button=document.createElement('button');button.textContent=item.filename+' · '+item.state;button.onclick=()=>{location.hash='task='+item.id;restore()};div.append(button);$('history-list').append(div)}$('history').hidden=false;$('current').hidden=true;$('current-tab').setAttribute('aria-pressed','false');$('history-tab').setAttribute('aria-pressed','true');if(!list.length)$('history-list').textContent='暂无可恢复的任务。'}catch(e){$('status').textContent=e.message}};
|
|
307
|
+
$('history-tab').onclick=async()=>{try{const list=await api('/tasks');$('history-list').replaceChildren();for(const item of list){const div=document.createElement('div');div.className='history-item';const button=document.createElement('button');button.textContent=(item.presentation?.title||item.filename)+' · '+(item.presentation?.status||item.state);button.onclick=()=>{location.hash='task='+item.id;restore()};const details=document.createElement('details'),summary=document.createElement('summary');summary.textContent='任务详情';details.append(summary,document.createTextNode('任务 ID:'+item.id));div.append(button,details);$('history-list').append(div)}$('history').hidden=false;$('current').hidden=true;$('current-tab').setAttribute('aria-pressed','false');$('history-tab').setAttribute('aria-pressed','true');if(!list.length)$('history-list').textContent='暂无可恢复的任务。'}catch(e){$('status').textContent=e.message}};
|
|
300
308
|
$('current-tab').onclick=()=>navigate(step);
|
|
301
309
|
$('wizard-open').onclick=()=>directDraft();$('wizard-close').onclick=()=>closeWizard();$('wizard').addEventListener('cancel',e=>{e.preventDefault();closeWizard()});
|
|
302
310
|
document.querySelectorAll('[data-wizard-step]').forEach(b=>b.onclick=()=>{const next=Number(b.dataset.wizardStep);wizardStep=next>1&&wizardMappingApplied!==JSON.stringify([current?.id,readMapping()])?1:next;saveWizard();renderWizard()});
|
|
@@ -312,7 +320,7 @@ $('draft-cancel').onclick=()=>$('draft-conflict').close();
|
|
|
312
320
|
for(const mode of ['append','replace'])$('draft-'+mode).onclick=()=>{$('draft-conflict').close();sendDraft(mode)};
|
|
313
321
|
$('mapping-search').oninput=()=>{const query=$('mapping-search').value.trim().toLowerCase();$('mapping').querySelectorAll('.ff-mapping-row').forEach(row=>row.hidden=!row.dataset.sourceLabel.toLowerCase().includes(query))};
|
|
314
322
|
$('result-search').oninput=filterResults;$('changes').onchange=filterResults;
|
|
315
|
-
window.addEventListener('message',e=>{if(e.origin!==location.origin||e.source!==parent)return;if(e.data?.type==='ff-theme'&&['light','dark'].includes(e.data.theme))document.body.dataset.ffTheme=e.data.theme;if(e.data?.type==='ff-draft-conflict'){expectedDraft=e.data.draft;if(!$('draft-conflict').open)$('draft-conflict').showModal()}if(e.data?.type==='ff-draft-result'){$('status').textContent=e.data.ok?'已回填,请在对话框修改或发送。':'回填失败,任务已保留。';if(e.data.ok)closeWizard(true)}if(e.data?.type==='ff-navigate'){if(!current&&location.hash)pendingNavigation=e.data.step;if(e.data.step==='history')$('history-tab').click();else navigate(e.data.step)}});
|
|
323
|
+
window.addEventListener('message',e=>{if(e.origin!==location.origin||e.source!==parent)return;if(e.data?.type==='ff-theme'&&['light','dark'].includes(e.data.theme))document.body.dataset.ffTheme=e.data.theme;if(e.data?.type==='ff-draft-conflict'){expectedDraft=e.data.draft;if(!$('draft-conflict').open)$('draft-conflict').showModal()}if(e.data?.type==='ff-draft-result'){$('status').textContent=e.data.ok?'已回填,请在对话框修改或发送。':'回填失败,任务已保留。';if(e.data.ok){closeWizard(true);navigate('identity');$('status').textContent='指令已回填,发送后将在此显示查询进度。'}}if(e.data?.type==='ff-navigate'){if(!current&&location.hash)pendingNavigation=e.data.step;if(e.data.step==='history')$('history-tab').click();else navigate(e.data.step)}});
|
|
316
324
|
api('/health').then(s=>{$('connection').textContent=s.qccAvailable?'已发现企查查工商工具,可在对话中执行。':'尚未发现企查查工商工具;请先连接 MCP。合成模板仍可体验。'}).catch(()=>{});
|
|
317
325
|
$('preview-continue').onclick=async()=>{if(busy||!current)return;controls(true);try{const ids=[...$('changes').querySelectorAll('input:checked')].map(x=>x.value);if(!current.confirmed&&JSON.stringify([...ids].sort())!==JSON.stringify([...(current.selectedIds||[])].sort()))render(await api('/select',{id:current.id,selectedIds:ids}));navigate('download');$('confirm').scrollIntoView({block:'center'});$('confirm').focus();$('status').textContent=current.confirmed?'副本已生成,请点击下载。':'请确认填写结果,点击蓝色按钮生成新副本。'}catch(e){$('status').textContent=e.message}finally{controls(false)}};
|
|
318
326
|
$('mapping-continue').onclick=()=>{if(busy||!current)return;navigate('identity');$('wizard-open').focus()};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-form-fill-agent",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.21",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "AI form filling and spreadsheet autofill for XLSX in DeepSeek Harness, using authorized Qichacha MCP facts with cell previews, user confirmation and export to a new copy.",
|
|
6
6
|
"repository": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"form-fill-core": "0.2.10",
|
|
36
|
-
"qcc-form-fill-provider": "0.2.
|
|
36
|
+
"qcc-form-fill-provider": "0.2.2"
|
|
37
37
|
},
|
|
38
38
|
"dsh": {
|
|
39
39
|
"client": {
|