|
|
@@ -7,7 +7,8 @@
|
|
|
* ③ 1888 diff:无变化 → null(零写入)、`"[]"` 与 `[]` 不产生假差异、期望为空不清存量
|
|
|
* ④ 1886 荣誉对齐:解析 `honors.records`、按「荣誉名+级别+来源」全量对齐
|
|
|
* (补新增 / 更新差异 / 删多余)、`complete !== true` 时**不许删**、
|
|
|
- * 荣誉名回退顺序(c_tag_name → title,字符串 "null" 不算名字)
|
|
|
+ * 荣誉名回退顺序(c_honor → c_tag_name → title,字符串 "null" 不算名字)——
|
|
|
+ * c_honor 是 2026-09-18 晚用户新建的**荣誉名称**列;c_tag_name 只作读取兼容
|
|
|
* ⑤ partial / errors 不可解析时的降级语义
|
|
|
* ⑥ 分类接口地址拼接(VITE_CHAT_API 的两种写法)
|
|
|
*
|
|
|
@@ -17,7 +18,7 @@
|
|
|
|
|
|
import {
|
|
|
ANGLE_TO_FIELD,
|
|
|
- HONOR_TAG_FIELD,
|
|
|
+ HONOR_NAME_FIELD,
|
|
|
buildEnterpriseRow,
|
|
|
buildHonorKey,
|
|
|
buildHonorRowContent,
|
|
|
@@ -188,7 +189,7 @@ console.log('\n【4】1886 荣誉对齐');
|
|
|
const seededRow = (id, title, level, source, extra = {}) => ({ id, title, c_level: level, c_source: source, ...extra });
|
|
|
/** 已对齐过的行:title 与 c_tag_name 都有 */
|
|
|
const alignedRow = (id, title, level, source, extra = {}) =>
|
|
|
- seededRow(id, title, level, source, { [HONOR_TAG_FIELD]: title, ...extra });
|
|
|
+ seededRow(id, title, level, source, { [HONOR_NAME_FIELD]: title, ...extra });
|
|
|
|
|
|
const rows = [
|
|
|
alignedRow('u1', '高新技术企业', '国家级', '某认定公告', { c_publish_office: '科技部', c_publish_date: '2025-01-02', c_certificate_code: 'CERT-1' }),
|
|
|
@@ -210,19 +211,20 @@ console.log('\n【4】1886 荣誉对齐');
|
|
|
[records[0]],
|
|
|
{ allowDelete: true }
|
|
|
);
|
|
|
- check('灌入行首次对齐:只补 c_tag_name,不动其它列', seedOnly.toUpdate.length === 1 && JSON.stringify(Object.keys(seedOnly.toUpdate[0].patch)) === JSON.stringify([HONOR_TAG_FIELD]), seedOnly.toUpdate[0]?.patch);
|
|
|
+ check('灌入行首次对齐:只补 c_honor,不动其它列', seedOnly.toUpdate.length === 1 && JSON.stringify(Object.keys(seedOnly.toUpdate[0].patch)) === JSON.stringify([HONOR_NAME_FIELD]), seedOnly.toUpdate[0]?.patch);
|
|
|
|
|
|
// 差异 → update(只 patch 有差异的列)
|
|
|
const staleRow = [seededRow('u1', '高新技术企业', '国家级', '某认定公告', { c_publish_office: '旧机构' })];
|
|
|
const upd = diffHonorRows(staleRow, [records[0]], { allowDelete: true });
|
|
|
check('同键字段有差异 → toUpdate,只含差异列', upd.toUpdate.length === 1 && upd.toUpdate[0].patch.c_publish_office === '科技部' && upd.toUpdate[0].patch.title === undefined, upd.toUpdate);
|
|
|
check('title 与荣誉名一致时不重复 patch', upd.toUpdate[0].patch.title === undefined);
|
|
|
- check('已匹配的行若缺 c_tag_name 也会补上', upd.toUpdate[0].patch[HONOR_TAG_FIELD] === '高新技术企业', upd.toUpdate[0].patch);
|
|
|
+ check('已匹配的行若缺 c_honor 也会补上', upd.toUpdate[0].patch[HONOR_NAME_FIELD] === '高新技术企业', upd.toUpdate[0].patch);
|
|
|
|
|
|
- const titleNull = [seededRow('u9', 'null', '国家级', '某认定公告', { [HONOR_TAG_FIELD]: '高新技术企业' })];
|
|
|
+ const titleNull = [seededRow('u9', 'null', '国家级', '某认定公告', { c_tag_name: '高新技术企业' })];
|
|
|
const fixTitle = diffHonorRows(titleNull, [records[0]], { allowDelete: true });
|
|
|
check('title 是字符串 "null" → 用 c_tag_name 认名字,并把 title 修正', fixTitle.toUpdate.length === 1 && fixTitle.toUpdate[0].patch.title === '高新技术企业', fixTitle);
|
|
|
check('字符串 "null" 不被当成荣誉名(键能对上)', fixTitle.toAdd.length === 0);
|
|
|
+ check('早期同步的行(只有 c_tag_name)也会补上 c_honor', fixTitle.toUpdate[0].patch[HONOR_NAME_FIELD] === '高新技术企业', fixTitle.toUpdate[0].patch);
|
|
|
|
|
|
// 新增
|
|
|
const empty = diffHonorRows([], records, { allowDelete: true });
|
|
|
@@ -239,7 +241,7 @@ console.log('\n【4】1886 荣誉对齐');
|
|
|
|
|
|
// 内容
|
|
|
const content = buildHonorRowContent('CODE-X', '合成公司', records[0], '2026-09-18 18:00:00');
|
|
|
- check('荣誉行内容:title 与 c_tag_name 都写荣誉名', content.title === '高新技术企业' && content[HONOR_TAG_FIELD] === '高新技术企业', content);
|
|
|
+ check('荣誉行内容:title 与 c_honor 都写荣誉名', content.title === '高新技术企业' && content[HONOR_NAME_FIELD] === '高新技术企业', content);
|
|
|
check('荣誉行内容:级别/来源/机构/日期/证书编号各就各位', content.c_level === '国家级' && content.c_source === '某认定公告' && content.c_publish_office === '科技部' && content.c_publish_date === '2025-01-02' && content.c_certificate_code === 'CERT-1', content);
|
|
|
check('荣誉行内容:必填与归属', content.c_credit_code === 'CODE-X' && content.c_name === '合成公司' && content.c_id === 0, content);
|
|
|
check('空字段不写进行(不落空值)', !('c_dead_line' in content) && !('c_beging_date' in content), content);
|