Commit f8f491a4 by 张立顺

feat: generate store daily v2.3.0 templates

1 parent be420291
packageDynamicForm/fixtures/schema-store-daily-v2.3.0*.js text eol=lf
packageDynamicForm/fixtures/schema-store-daily-v2.3.0*.json text eol=lf
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
| `驻店日报-填写表单` | `staff` | `fixtures/schema-staff-daily-v2.1.1.js` / `.json` | | `驻店日报-填写表单` | `staff` | `fixtures/schema-staff-daily-v2.1.1.js` / `.json` |
| `门店日报-填写表单` | `store` | `fixtures/schema-store-daily-v2.1.1.js` / `.json` | | `门店日报-填写表单` | `store` | `fixtures/schema-store-daily-v2.1.1.js` / `.json` |
V2.3.0 门店日报使用独立模式:`--sheet store --version 2.3.0`。该模式精确匹配 `输入-门店日报`(不会误选 `输入-门店日报(原始)`),仅解析状态为“在用”且编号从 `F2-101` 开始的记录。该模式不读 baseline,也不依赖删除线/紫色行样式。
默认输入路径(可在命令行 `--input` 覆盖): 默认输入路径(可在命令行 `--input` 覆盖):
```text ```text
...@@ -73,6 +75,11 @@ c:/Users/admin/Downloads/门店工作汇报模板-V2.1.1.xlsx ...@@ -73,6 +75,11 @@ c:/Users/admin/Downloads/门店工作汇报模板-V2.1.1.xlsx
| 子表单 | `subform` | | 子表单 | `subform` |
| 分割线 | `divider` | | 分割线 | `divider` |
| 选择器 | `select`(选项含「驻店人员」→ `multipleSelect` + `storeStaffList`;「4S店成员」→ `4sStaffList`) | | 选择器 | `select`(选项含「驻店人员」→ `multipleSelect` + `storeStaffList`;「4S店成员」→ `4sStaffList`) |
| 单行文本输入框 | `input`(11 位手机号规则→ `phoneInput`) |
| 日期时间 | `date`(当前及过去日期→ `rules.maxDate: "today"`) |
| 级联选择 | `carBrandSelect` |
V2.3.0 选择器的单选/多选以“其他规则”列为准;多行“固定值 / 选项N”会拆成 `options`,选项后的场景/品牌说明保存为 `sourceRule`。动态默认值(如“当前用户”、“最近一次提交数值”)保存为 `sourceDefaultRule`,不伪造静态 `value`。
--- ---
...@@ -185,6 +192,12 @@ python packageDynamicForm/scripts/convert-excel-template-to-schema.py --sheet st ...@@ -185,6 +192,12 @@ python packageDynamicForm/scripts/convert-excel-template-to-schema.py --sheet st
python packageDynamicForm/scripts/convert-excel-template-to-schema.py --sheet store --format js python packageDynamicForm/scripts/convert-excel-template-to-schema.py --sheet store --format js
python packageDynamicForm/scripts/convert-excel-template-to-schema.py --sheet store --format json python packageDynamicForm/scripts/convert-excel-template-to-schema.py --sheet store --format json
# 门店日报 V2.3.0(精确 sheet + F2-101 起始边界)
python packageDynamicForm/scripts/convert-excel-template-to-schema.py --sheet store --version 2.3.0 --input "C:/Users/admin/Downloads/门店工作汇报-V2.3.0输入输出模板.xlsx" --format js
python packageDynamicForm/scripts/convert-excel-template-to-schema.py --sheet store --version 2.3.0 --input "C:/Users/admin/Downloads/门店工作汇报-V2.3.0输入输出模板.xlsx" --format json
python packageDynamicForm/scripts/convert-excel-template-to-schema.py --sheet store --version 2.3.0 --input "C:/Users/admin/Downloads/门店工作汇报-V2.3.0输入输出模板.xlsx" --env production --format js
python packageDynamicForm/scripts/convert-excel-template-to-schema.py --sheet store --version 2.3.0 --input "C:/Users/admin/Downloads/门店工作汇报-V2.3.0输入输出模板.xlsx" --env production --format json
# 生产环境 brandId(直出 .prod.js / .prod.json) # 生产环境 brandId(直出 .prod.js / .prod.json)
python packageDynamicForm/scripts/convert-excel-template-to-schema.py --sheet staff --env production --format js python packageDynamicForm/scripts/convert-excel-template-to-schema.py --sheet staff --env production --format js
python packageDynamicForm/scripts/convert-excel-template-to-schema.py --sheet store --env production --format json python packageDynamicForm/scripts/convert-excel-template-to-schema.py --sheet store --env production --format json
...@@ -204,6 +217,7 @@ python packageDynamicForm/scripts/convert-excel-template-to-schema.py ^ ...@@ -204,6 +217,7 @@ python packageDynamicForm/scripts/convert-excel-template-to-schema.py ^
| 参数 | 说明 | | 参数 | 说明 |
|------|------| |------|------|
| `--sheet` | 必填:`staff` \| `store` | | `--sheet` | 必填:`staff` \| `store` |
| `--version` | `2.1.1`(默认)或 `2.3.0`(当前仅支持 `store`) |
| `--input` | xlsx 路径,默认见脚本 `DEFAULT_XLSX` | | `--input` | xlsx 路径,默认见脚本 `DEFAULT_XLSX` |
| `--output` | 输出路径,默认 `fixtures/schema-*-daily-v2.1.1.js`;`--env production` 时默认 `.prod.js` | | `--output` | 输出路径,默认 `fixtures/schema-*-daily-v2.1.1.js`;`--env production` 时默认 `.prod.js` |
| `--format` | `js`(默认)或 `json` | | `--format` | `js`(默认)或 `json` |
...@@ -252,6 +266,8 @@ python packageDynamicForm/scripts/convert-excel-template-to-schema.py ^ ...@@ -252,6 +266,8 @@ python packageDynamicForm/scripts/convert-excel-template-to-schema.py ^
| `schema-staff-daily-full.js` | 驻店 V2.0 全量 indexed baseline(`keep` 行来源) | | `schema-staff-daily-full.js` | 驻店 V2.0 全量 indexed baseline(`keep` 行来源) |
| `schema-store-daily-full.js` | 门店 V2.0 全量 indexed baseline | | `schema-store-daily-full.js` | 门店 V2.0 全量 indexed baseline |
| `schema-*-daily-v2.1.1.js/json` | 由 V2.1.1 Excel 生成的目标产物 | | `schema-*-daily-v2.1.1.js/json` | 由 V2.1.1 Excel 生成的目标产物 |
| `schema-store-daily-v2.3.0.js/json` | V2.3.0 daily brandId,7 个顶层字段 / 25 个总 key |
| `schema-store-daily-v2.3.0.prod.js/json` | V2.3.0 production brandId,其余结构与 daily 一致 |
**V2.1.1 相对 V2.0 主要结构变化(示例)**: **V2.1.1 相对 V2.0 主要结构变化(示例)**:
...@@ -277,6 +293,8 @@ python packageDynamicForm/scripts/convert-excel-template-to-schema.py ^ ...@@ -277,6 +293,8 @@ python packageDynamicForm/scripts/convert-excel-template-to-schema.py ^
```bash ```bash
node --test packageDynamicForm/tests/staff-template-schema.test.mjs packageDynamicForm/tests/store-template-schema.test.mjs packageDynamicForm/tests/v211-template-visibility.test.mjs packageDynamicForm/tests/v211-template-brand-id-prod.test.mjs node --test packageDynamicForm/tests/staff-template-schema.test.mjs packageDynamicForm/tests/store-template-schema.test.mjs packageDynamicForm/tests/v211-template-visibility.test.mjs packageDynamicForm/tests/v211-template-brand-id-prod.test.mjs
python packageDynamicForm/tests/test_store_v230_converter.py
node --test packageDynamicForm/tests/store-v230-template-schema.test.mjs
``` ```
覆盖:场景码提取契约、V2.1.1 字段结构、F1-11/F2-11 权益 `baseSceneCode`、轻改/权益场景显隐不匹配等。 覆盖:场景码提取契约、V2.1.1 字段结构、F1-11/F2-11 权益 `baseSceneCode`、轻改/权益场景显隐不匹配等。
...@@ -322,6 +340,8 @@ node --test packageDynamicForm/tests/staff-template-schema.test.mjs packageDynam ...@@ -322,6 +340,8 @@ node --test packageDynamicForm/tests/staff-template-schema.test.mjs packageDynam
| `fixtures/template-field-comments.json` | JS 注释 sidecar | | `fixtures/template-field-comments.json` | JS 注释 sidecar |
| `fixtures/schema-staff-daily-v2.1.1.js` | 驻店生成结果(JS,测试 brandId) | | `fixtures/schema-staff-daily-v2.1.1.js` | 驻店生成结果(JS,测试 brandId) |
| `fixtures/schema-store-daily-v2.1.1.js` | 门店生成结果(JS,测试 brandId) | | `fixtures/schema-store-daily-v2.1.1.js` | 门店生成结果(JS,测试 brandId) |
| `fixtures/schema-store-daily-v2.3.0.js/json` | V2.3.0 门店日报 daily 产物 |
| `fixtures/schema-store-daily-v2.3.0.prod.js/json` | V2.3.0 门店日报 production 产物 |
| `fixtures/schema-*-daily-v2.1.1.prod.js/json` | 生产 brandId 版本(remap 或 `--env production`) | | `fixtures/schema-*-daily-v2.1.1.prod.js/json` | 生产 brandId 版本(remap 或 `--env production`) |
| `fixtures/brand-id-env-maps.mjs` / `.json` | 双环境 brandId 映射 | | `fixtures/brand-id-env-maps.mjs` / `.json` | 双环境 brandId 映射 |
| `scripts/remap-schema-brand-ids.mjs` | daily → production brandId 转换 | | `scripts/remap-schema-brand-ids.mjs` | daily → production brandId 转换 |
...@@ -329,3 +349,5 @@ node --test packageDynamicForm/tests/staff-template-schema.test.mjs packageDynam ...@@ -329,3 +349,5 @@ node --test packageDynamicForm/tests/staff-template-schema.test.mjs packageDynam
| `tests/staff-template-schema.test.mjs` | V2.1.1 驻店结构回归 | | `tests/staff-template-schema.test.mjs` | V2.1.1 驻店结构回归 |
| `tests/store-template-schema.test.mjs` | V2.1.1 门店结构回归 | | `tests/store-template-schema.test.mjs` | V2.1.1 门店结构回归 |
| `tests/v211-template-visibility.test.mjs` | V2.1.1 显隐回归测试 | | `tests/v211-template-visibility.test.mjs` | V2.1.1 显隐回归测试 |
| `tests/test_store_v230_converter.py` | V2.3.0 转换器单元测试 |
| `tests/store-v230-template-schema.test.mjs` | V2.3.0 最终 fixtures 结构与双环境回归 |
...@@ -9,11 +9,13 @@ ...@@ -9,11 +9,13 @@
- `packageDynamicForm/fixtures/schema-store-daily-v2.1.1.js` / `.json` — **V2.1.1 门店模版**(测试环境 brandId) - `packageDynamicForm/fixtures/schema-store-daily-v2.1.1.js` / `.json` — **V2.1.1 门店模版**(测试环境 brandId)
- `packageDynamicForm/fixtures/schema-staff-daily-v2.1.1.prod.js` / `.prod.json` — **V2.1.1 驻店生产 brandId**(配置中心生产粘贴) - `packageDynamicForm/fixtures/schema-staff-daily-v2.1.1.prod.js` / `.prod.json` — **V2.1.1 驻店生产 brandId**(配置中心生产粘贴)
- `packageDynamicForm/fixtures/schema-store-daily-v2.1.1.prod.js` / `.prod.json` — **V2.1.1 门店生产 brandId** - `packageDynamicForm/fixtures/schema-store-daily-v2.1.1.prod.js` / `.prod.json` — **V2.1.1 门店生产 brandId**
- `packageDynamicForm/fixtures/schema-store-daily-v2.3.0.js` / `.json` — **V2.3.0 门店日报**(`F2-101` 起,daily brandId)
- `packageDynamicForm/fixtures/schema-store-daily-v2.3.0.prod.js` / `.prod.json` — **V2.3.0 门店生产 brandId**
- `packageDynamicForm/fixtures/brand-id-env-maps.mjs` / `.json` — daily / production 双环境 brandId 映射 - `packageDynamicForm/fixtures/brand-id-env-maps.mjs` / `.json` — daily / production 双环境 brandId 映射
本目录仅保留体积较小的样例(`schema-staff-daily-minimal.json`、`page-context-sample.json`)。 本目录仅保留体积较小的样例(`schema-staff-daily-minimal.json`、`page-context-sample.json`)。
- 从 list 转 indexed:`node packageDynamicForm/scripts/convert-schema-to-indexed.mjs` - 从 list 转 indexed:`node packageDynamicForm/scripts/convert-schema-to-indexed.mjs`
- Excel 转 V2.1.x:`python packageDynamicForm/scripts/convert-excel-template-to-schema.py` — 见 [excel转js模板配置说明.md](../excel转js模板配置说明.md) - Excel 转 V2.1.x / V2.3.0:`python packageDynamicForm/scripts/convert-excel-template-to-schema.py`(V2.3.0 使用 `--sheet store --version 2.3.0`)— 见 [excel转js模板配置说明.md](../excel转js模板配置说明.md)
- daily → production brandId remap:`node packageDynamicForm/scripts/remap-schema-brand-ids.mjs --sheet staff|store` - daily → production brandId remap:`node packageDynamicForm/scripts/remap-schema-brand-ids.mjs --sheet staff|store`
- numberInput 补 `value: 0`:`node packageDynamicForm/scripts/patch-number-input-defaults.mjs` — 见 [MAINTENANCE.md § Schema fixture](../MAINTENANCE.md#schema-fixture-维护mock) - numberInput 补 `value: 0`:`node packageDynamicForm/scripts/patch-number-input-defaults.mjs` — 见 [MAINTENANCE.md § Schema fixture](../MAINTENANCE.md#schema-fixture-维护mock)
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
const here = path.dirname(fileURLToPath(import.meta.url))
const fixturesDir = path.join(here, '..', 'fixtures')
function loadJson(name) {
return JSON.parse(fs.readFileSync(path.join(fixturesDir, name), 'utf8'))
}
function loadBareArray(name) {
const source = fs.readFileSync(path.join(fixturesDir, name), 'utf8')
return Function(`return (\n${source}\n)`)()
}
function collectFields(list = []) {
const result = []
function walk(field) {
result.push(field)
for (const child of field.children || []) {
if (Array.isArray(child)) child.forEach(walk)
else walk(child)
}
}
list.forEach(walk)
return result
}
function findDeep(list, key) {
return collectFields(list).find(field => field.key === key)
}
function withoutBrandIds(value) {
if (Array.isArray(value)) return value.map(withoutBrandIds)
if (!value || typeof value !== 'object') return value
return Object.fromEntries(
Object.entries(value)
.filter(([key]) => key !== 'brandId' && key !== 'filterBrandId')
.map(([key, item]) => [key, withoutBrandIds(item)])
)
}
const daily = loadJson('schema-store-daily-v2.3.0.json')
const production = loadJson('schema-store-daily-v2.3.0.prod.json')
describe('store daily template V2.3.0 schema', () => {
it('IT-V230-001: metadata and exact F2-101 onward shape', () => {
assert.equal(daily.version, '2.3.0')
assert.equal(daily.formCode, 'store_daily_report')
assert.equal(daily.title, '门店日报 V2.3.0')
assert.deepEqual(
daily.list.map(field => field.key),
['F2-101', 'F2-102', 'F2-103', 'F2-104', 'F2-105', 'F2-106', 'F2-107']
)
assert.equal(collectFields(daily.list).length, 25)
assert.equal(findDeep(daily.list, 'F2-100'), undefined)
assert.equal(findDeep(daily.list, 'F2-107')?.children?.[0]?.length, 18)
})
it('IT-V230-002: selector, phone, date, car and VIN mappings', () => {
assert.equal(findDeep(daily.list, 'F2-101')?.type, 'multipleSelect')
assert.equal(findDeep(daily.list, 'F2-101')?.optionsKey, 'storeStaffList')
assert.equal(findDeep(daily.list, 'F2-107-2')?.type, 'phoneInput')
assert.deepEqual(findDeep(daily.list, 'F2-107-4')?.rules, {
maxDate: 'today',
format: 'date'
})
assert.equal(findDeep(daily.list, 'F2-107-8')?.type, 'carBrandSelect')
assert.equal(findDeep(daily.list, 'F2-107-8')?.rules?.level, 4)
assert.equal(findDeep(daily.list, 'F2-107-9')?.prefixComponent, 'scan')
assert.equal(findDeep(daily.list, 'F2-107-9')?.rules?.maxLength, 20)
})
it('IT-V230-003: dynamic defaults and option annotations are preserved as source metadata', () => {
const monthly = findDeep(daily.list, 'F2-102')
assert.match(monthly?.sourceDefaultRule, /每月首日/)
assert.equal(Object.hasOwn(monthly, 'value'), false)
const owner = findDeep(daily.list, 'F2-107-6')
assert.equal(owner?.type, 'select')
assert.equal(owner?.optionsKey, 'storeStaffList')
assert.match(owner?.sourceDefaultRule, /当前用户/)
const tags = findDeep(daily.list, 'F2-107-7')
assert.equal(tags?.type, 'multipleSelect')
assert.ok(tags?.options?.some(option => option.sourceRule))
})
it('IT-V230-004: subform childrenShowRules retain every Excel dependency', () => {
const rules = findDeep(daily.list, 'F2-107')?.childrenShowRules
assert.deepEqual(Object.keys(rules), [
'F2-107-4',
'F2-107-12',
'F2-107-13',
'F2-107-14',
'F2-107-15',
'F2-107-16',
'F2-107-17',
'F2-107-18'
])
assert.deepEqual(rules['F2-107-14']?.keys, ['F2-107-13'])
assert.match(rules['F2-107-12']?.result, /已交付引荐/)
})
it('IT-V230-005: daily and production differ only by brand IDs', () => {
assert.deepEqual(withoutBrandIds(production), withoutBrandIds(daily))
assert.deepEqual(findDeep(daily.list, 'F2-103')?.brandId, [3454, 3503, 3458, 3574, 3502, 3067])
assert.deepEqual(findDeep(production.list, 'F2-103')?.brandId, [2695, 2741, 2698, 2797, 2740, 2188])
assert.deepEqual(findDeep(daily.list, 'F2-102')?.filterBrandId, [3454, 3503, 3458, 3574, 3502])
assert.deepEqual(findDeep(production.list, 'F2-102')?.filterBrandId, [2695, 2741, 2698, 2797, 2740])
})
it('IT-V230-006: both config-center JS fixtures are parseable and match JSON lists', () => {
assert.deepEqual(loadBareArray('schema-store-daily-v2.3.0.js'), daily.list)
assert.deepEqual(loadBareArray('schema-store-daily-v2.3.0.prod.js'), production.list)
})
})
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!