Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
dj-car-boutique-work-wechat
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
1
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 872db3c2
authored
Jun 05, 2026
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix 表单默认值回显问题
1 parent
ba27141a
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
148 additions
and
18 deletions
packageDynamicForm/api/negotiationDailyReport.js
packageDynamicForm/api/staffDailyReport.js
packageDynamicForm/api/storeDailyReport.js
packageDynamicForm/docs/DEVLOG.md
packageDynamicForm/form-engine/group-row-adapter.js
packageDynamicForm/form-engine/values.js
packageDynamicForm/tests/numberInput-zero-value.test.mjs
packageDynamicForm/tests/subform-add-row-template.test.mjs
packageEquity/api.js
tabIndex/api.js
tabWorkOrder/api.js
packageDynamicForm/api/negotiationDailyReport.js
View file @
872db3c
...
@@ -17,6 +17,7 @@ import {
...
@@ -17,6 +17,7 @@ import {
parseJsonContentDetailValues
parseJsonContentDetailValues
}
from
'../form-engine/submit-adapter.js'
}
from
'../form-engine/submit-adapter.js'
import
{
stripValuesFromSchemaRoot
}
from
'../form-engine/detail-echo.js'
import
{
stripValuesFromSchemaRoot
}
from
'../form-engine/detail-echo.js'
import
{
mergeTemplateDefaultsIntoInitialValues
}
from
'../form-engine/values.js'
import
{
import
{
mergeAppJsonIntoSchema
,
mergeAppJsonIntoSchema
,
enrichPageContextWithDetailEcho
enrichPageContextWithDetailEcho
...
@@ -285,7 +286,10 @@ async function fetchSchema({
...
@@ -285,7 +286,10 @@ async function fetchSchema({
if
(
detail
?.
jsonContent
)
{
if
(
detail
?.
jsonContent
)
{
schema
=
mergeAppJsonIntoSchema
(
normalizedRoot
,
detail
)
schema
=
mergeAppJsonIntoSchema
(
normalizedRoot
,
detail
)
}
}
const
initialValues
=
resolveSchemaDetailValues
(
detail
,
normalizedRoot
.
list
,
detailValues
)
const
initialValues
=
mergeTemplateDefaultsIntoInitialValues
(
normalizedRoot
.
list
,
resolveSchemaDetailValues
(
detail
,
normalizedRoot
.
list
,
detailValues
)
)
schema
=
stripValuesFromSchemaRoot
(
schema
)
schema
=
stripValuesFromSchemaRoot
(
schema
)
return
{
return
{
code
:
0
,
code
:
0
,
...
...
packageDynamicForm/api/staffDailyReport.js
View file @
872db3c
...
@@ -22,6 +22,7 @@ import {
...
@@ -22,6 +22,7 @@ import {
parseDetailEchoValues
,
parseDetailEchoValues
,
stripValuesFromSchemaRoot
stripValuesFromSchemaRoot
}
from
'../form-engine/detail-echo.js'
}
from
'../form-engine/detail-echo.js'
import
{
mergeTemplateDefaultsIntoInitialValues
}
from
'../form-engine/values.js'
import
{
enrichPageContextWithDetailEcho
}
from
'../form-engine/app-subform-json.js'
import
{
enrichPageContextWithDetailEcho
}
from
'../form-engine/app-subform-json.js'
const
{
buildDailyReportSaveRequest
}
=
require
(
'../form-engine/save-request.js'
)
const
{
buildDailyReportSaveRequest
}
=
require
(
'../form-engine/save-request.js'
)
import
{
import
{
...
@@ -311,7 +312,10 @@ async function fetchSchema({
...
@@ -311,7 +312,10 @@ async function fetchSchema({
if
(
!
data
?.
list
)
{
if
(
!
data
?.
list
)
{
return
{
code
:
-
1
,
message
:
'加载表单模板失败'
,
data
:
null
}
return
{
code
:
-
1
,
message
:
'加载表单模板失败'
,
data
:
null
}
}
}
const
initialValues
=
parseDetailEchoValues
(
detail
,
data
.
list
,
detailValues
)
const
initialValues
=
mergeTemplateDefaultsIntoInitialValues
(
data
.
list
,
parseDetailEchoValues
(
detail
,
data
.
list
,
detailValues
)
)
const
schema
=
stripValuesFromSchemaRoot
(
data
)
const
schema
=
stripValuesFromSchemaRoot
(
data
)
return
{
return
{
code
:
0
,
code
:
0
,
...
...
packageDynamicForm/api/storeDailyReport.js
View file @
872db3c
...
@@ -18,6 +18,7 @@ import {
...
@@ -18,6 +18,7 @@ import {
mapBrandListToBrandIds
mapBrandListToBrandIds
}
from
'../form-engine/submit-adapter.js'
}
from
'../form-engine/submit-adapter.js'
import
{
stripValuesFromSchemaRoot
}
from
'../form-engine/detail-echo.js'
import
{
stripValuesFromSchemaRoot
}
from
'../form-engine/detail-echo.js'
import
{
mergeTemplateDefaultsIntoInitialValues
}
from
'../form-engine/values.js'
import
{
import
{
mergeAppJsonIntoSchema
,
mergeAppJsonIntoSchema
,
normalizeJsonContentList
,
normalizeJsonContentList
,
...
@@ -350,7 +351,10 @@ async function fetchSchema({
...
@@ -350,7 +351,10 @@ async function fetchSchema({
if
(
detail
?.
jsonContent
)
{
if
(
detail
?.
jsonContent
)
{
schema
=
mergeAppJsonIntoSchema
(
normalizedRoot
,
detail
)
schema
=
mergeAppJsonIntoSchema
(
normalizedRoot
,
detail
)
}
}
const
initialValues
=
resolveSchemaDetailValues
(
detail
,
normalizedRoot
.
list
,
detailValues
)
const
initialValues
=
mergeTemplateDefaultsIntoInitialValues
(
normalizedRoot
.
list
,
resolveSchemaDetailValues
(
detail
,
normalizedRoot
.
list
,
detailValues
)
)
warnIfDetailSubformEchoEmpty
(
detail
,
initialValues
,
normalizedRoot
.
list
)
warnIfDetailSubformEchoEmpty
(
detail
,
initialValues
,
normalizedRoot
.
list
)
schema
=
stripValuesFromSchemaRoot
(
schema
)
schema
=
stripValuesFromSchemaRoot
(
schema
)
return
{
return
{
...
...
packageDynamicForm/docs/DEVLOG.md
View file @
872db3c
# DEVLOG — packageDynamicForm
# DEVLOG — packageDynamicForm
## 2026-06-04 — 模板 numberInput `value: 0` 展示补全
-
**缺口 A**
:
`valueMapToRowFieldsFromOrigin`
在 valueMap 缺 key 时回退
`origin_children`
列模板
`field.value`
(含
`0`
)。
-
**缺口 B**
:三页
`fetchSchema`
strip 前
`mergeTemplateDefaultsIntoInitialValues`
,顶层模板默认写入
`initialValues`
(详情优先)。
-
**单测**
:
`IT-SUBFORM-TPL-001/002`
、
`IT-ENG-ZERO-005`
。
## 2026-06-04 — 旧版精品/权益驻店日报周历已填接口恢复
-
**范围**
:
`tabWorkOrder/api.js`
、
`packageEquity/api.js`
、
`tabIndex/api.js`
的
`staffDailyReportDetailWeeklyList`
。
-
**修复**
:恢复
`dj.api.smartcarlife.staff.daily.report.weekly.list`
真实 POST(
`staffDaily`
/
`upgradeStaffDaily`
周历
`hasDailyValue`
)。
-
**说明**
:新版
`packageDynamicForm`
三页仍走
`dailyReport.weekly.list`
,互不影响。
## 2026-06-04 — subform 增行保留 numberInput 模板零值
-
**问题**
:
`cloneRowTemplateForAdd`
对
`origin_children`
也执行
`clearRowFieldForAdd`
,模板
`value: 0`
被清掉,新增行数字框显示空。
-
**修复**
:有
`origin_children`
时保留
`field.value`
(含
`0`
),仅清理 select 双 key;无
`origin_children`
回退
`children[0]`
仍清空。
-
**单测**
:
`IT-SUBFORM-ADD-007`
、
`IT-SUBFORM-ADD-008`
。
## 2026-06-04 — numberInput decimal 边缘输入增强
## 2026-06-04 — numberInput decimal 边缘输入增强
-
**范围**
:仅
`rules.decimal: true`
;整数默认模式不变;长度仍走
`resolveNumberInputMaxLength`
(不引入精品 100000 上限)。
-
**范围**
:仅
`rules.decimal: true`
;整数默认模式不变;长度仍走
`resolveNumberInputMaxLength`
(不引入精品 100000 上限)。
...
...
packageDynamicForm/form-engine/group-row-adapter.js
View file @
872db3c
...
@@ -39,7 +39,24 @@ export function cloneRowTemplate(group = {}) {
...
@@ -39,7 +39,24 @@ export function cloneRowTemplate(group = {}) {
/** 增行:基于 origin_children 克隆空行(不继承 children[0] 已填值) */
/** 增行:基于 origin_children 克隆空行(不继承 children[0] 已填值) */
export
function
cloneRowTemplateForAdd
(
group
=
{})
{
export
function
cloneRowTemplateForAdd
(
group
=
{})
{
return
cloneJson
(
getSubformRowTemplateForAdd
(
group
)).
map
(
clearRowFieldForAdd
)
const
template
=
cloneJson
(
getSubformRowTemplateForAdd
(
group
))
const
usesOrigin
=
Array
.
isArray
(
group
.
origin_children
)
&&
group
.
origin_children
.
length
>
0
if
(
usesOrigin
)
{
return
template
.
map
(
field
=>
{
const
next
=
{
...
field
}
const
key
=
next
.
key
if
(
key
!=
null
&&
next
.
type
===
'select'
&&
Object
.
prototype
.
hasOwnProperty
.
call
(
next
,
key
)
)
{
delete
next
[
key
]
}
return
next
})
}
return
template
.
map
(
clearRowFieldForAdd
)
}
}
/** 判断 value 是否为 gl_tape 形态 FormField[][] */
/** 判断 value 是否为 gl_tape 形态 FormField[][] */
...
@@ -172,9 +189,13 @@ export function applyValueMapToRowField(field = {}, raw) {
...
@@ -172,9 +189,13 @@ export function applyValueMapToRowField(field = {}, raw) {
/** 用 origin_children 列模板 + valueMap 还原一行(不继承 children[0] 双 key) */
/** 用 origin_children 列模板 + valueMap 还原一行(不继承 children[0] 双 key) */
export
function
valueMapToRowFieldsFromOrigin
(
columnTemplate
=
[],
valueMap
=
{})
{
export
function
valueMapToRowFieldsFromOrigin
(
columnTemplate
=
[],
valueMap
=
{})
{
return
(
columnTemplate
||
[]).
map
(
field
=>
return
(
columnTemplate
||
[]).
map
(
field
=>
{
applyValueMapToRowField
(
clearRowFieldForAdd
(
field
),
valueMap
[
field
.
key
])
const
key
=
field
?.
key
)
const
hasOwn
=
key
!=
null
&&
Object
.
prototype
.
hasOwnProperty
.
call
(
valueMap
,
key
)
const
raw
=
hasOwn
?
valueMap
[
key
]
:
field
?.
value
return
applyValueMapToRowField
(
clearRowFieldForAdd
(
field
),
raw
)
})
}
}
/** valueMap 按模板还原为 FormField[](legacy:模板可能含已填行字段) */
/** valueMap 按模板还原为 FormField[](legacy:模板可能含已填行字段) */
...
...
packageDynamicForm/form-engine/values.js
View file @
872db3c
...
@@ -54,6 +54,12 @@ export function buildInitialValues(list = []) {
...
@@ -54,6 +54,12 @@ export function buildInitialValues(list = []) {
return
normalizeSelectValuesInMap
(
list
,
values
)
return
normalizeSelectValuesInMap
(
list
,
values
)
}
}
/** strip 前合并 schema 模板默认(含 numberInput 0);详情 initialValues 优先 */
export
function
mergeTemplateDefaultsIntoInitialValues
(
schemaList
=
[],
initialValues
=
{})
{
const
templateDefaults
=
buildInitialValues
(
schemaList
)
return
{
...
templateDefaults
,
...
initialValues
}
}
/** 用详情回显 initialValues 覆盖 buildInitialValues 结果(schema 不带 .value) */
/** 用详情回显 initialValues 覆盖 buildInitialValues 结果(schema 不带 .value) */
export
function
applyInitialValues
(
values
=
{},
initialValues
=
{})
{
export
function
applyInitialValues
(
values
=
{},
initialValues
=
{})
{
if
(
!
initialValues
||
typeof
initialValues
!==
'object'
)
{
if
(
!
initialValues
||
typeof
initialValues
!==
'object'
)
{
...
...
packageDynamicForm/tests/numberInput-zero-value.test.mjs
View file @
872db3c
...
@@ -2,7 +2,9 @@
...
@@ -2,7 +2,9 @@
import assert from 'node:assert/strict'
import assert from 'node:assert/strict'
describe('numberInput zero value echo and validation', async () => {
describe('numberInput zero value echo and validation', async () => {
const { buildInitialValues } = await import('../form-engine/values.js')
const { buildInitialValues, mergeTemplateDefaultsIntoInitialValues } = await import(
'../form-engine/values.js'
)
const { rowFieldsToValueMap } = await import(
const { rowFieldsToValueMap } = await import(
'../form-engine/group-row-adapter.js'
'../form-engine/group-row-adapter.js'
)
)
...
@@ -42,6 +44,22 @@ describe('numberInput zero value echo and validation', async () => {
...
@@ -42,6 +44,22 @@ describe('numberInput zero value echo and validation', async () => {
assert.equal(values['F1-5-1'], 0)
assert.equal(values['F1-5-1'], 0)
})
})
it('IT-ENG-ZERO-005: mergeTemplateDefaultsIntoInitialValues keeps top-level 0', () => {
const list = [
{
key: 'F-ZERO',
type: 'numberInput',
label: '数量',
value: 0,
rules: { min: 0, integer: true }
}
]
const merged = mergeTemplateDefaultsIntoInitialValues(list, {})
assert.equal(merged['F-ZERO'], 0)
const overridden = mergeTemplateDefaultsIntoInitialValues(list, { 'F-ZERO': 5 })
assert.equal(overridden['F-ZERO'], 5)
})
it('IT-ENG-ZERO-004: required numberInput with value 0 passes validation', () => {
it('IT-ENG-ZERO-004: required numberInput with value 0 passes validation', () => {
const list = [
const list = [
{
{
...
...
packageDynamicForm/tests/subform-add-row-template.test.mjs
View file @
872db3c
...
@@ -3,7 +3,8 @@ import assert from 'node:assert/strict'
...
@@ -3,7 +3,8 @@ import assert from 'node:assert/strict'
import { createFormEngine } from '../form-engine/core.js'
import { createFormEngine } from '../form-engine/core.js'
import {
import {
cloneRowTemplateForAdd,
cloneRowTemplateForAdd,
clearRowFieldForAdd
clearRowFieldForAdd,
valueMapToRowFieldsFromOrigin
} from '../form-engine/group-row-adapter.js'
} from '../form-engine/group-row-adapter.js'
import { buildGroupRowsCache } from '../form-engine/group-rows-cache.js'
import { buildGroupRowsCache } from '../form-engine/group-rows-cache.js'
import { getSubformRowTemplateForAdd } from '../form-engine/field-types.js'
import { getSubformRowTemplateForAdd } from '../form-engine/field-types.js'
...
@@ -139,4 +140,64 @@ describe('subform add row template (origin_children)', () => {
...
@@ -139,4 +140,64 @@ describe('subform add row template (origin_children)', () => {
assert.equal(cleared.value, undefined)
assert.equal(cleared.value, undefined)
assert.equal(cleared['F2-9-1'], undefined)
assert.equal(cleared['F2-9-1'], undefined)
})
})
it('IT-SUBFORM-ADD-007: origin_children numberInput value 0 preserved on add row', () => {
const originWithZero = [
{ key: 'F2-9-1', label: '交付专员', type: 'select', optionsKey: '4sStaffList' },
{ key: 'F2-9-2', label: '今日交车', type: 'numberInput', value: 0 }
]
const group = {
key: 'F2-9',
type: 'subform',
origin_children: originWithZero,
children: [filledFirstRow]
}
const row = cloneRowTemplateForAdd(group)
const num = row.find(f => f.key === 'F2-9-2')
assert.equal(num.value, 0)
})
it('IT-SUBFORM-TPL-001: valueMapToRowFieldsFromOrigin falls back to template value 0', () => {
const originWithZero = [
{ key: 'F2-9-1', label: '交付专员', type: 'select', optionsKey: '4sStaffList' },
{ key: 'F2-9-2', label: '今日交车', type: 'numberInput', value: 0 }
]
const row = valueMapToRowFieldsFromOrigin(originWithZero, {})
const num = row.find(f => f.key === 'F2-9-2')
assert.equal(num.value, 0)
})
it('IT-SUBFORM-TPL-002: valueMapToRowFieldsFromOrigin keeps explicit valueMap 0', () => {
const originWithZero = [
{ key: 'F2-9-2', label: '今日交车', type: 'numberInput', value: 0 }
]
const row = valueMapToRowFieldsFromOrigin(originWithZero, { 'F2-9-2': 0 })
const num = row.find(f => f.key === 'F2-9-2')
assert.equal(num.value, 0)
})
it('IT-SUBFORM-ADD-008: addGroupRow new row keeps numberInput 0 in values and cache', () => {
const originWithZero = [
{ key: 'F2-9-1', label: '交付专员', type: 'select', optionsKey: '4sStaffList' },
{ key: 'F2-9-2', label: '今日交车', type: 'numberInput', value: 0 }
]
const schema = {
list: [
{
key: 'F2-9',
type: 'subform',
origin_children: originWithZero,
children: [originWithZero]
}
]
}
const engine = createFormEngine()
engine.init(schema, { initialValues: { 'F2-9': [{}] } })
const viewState = engine.addGroupRow(schema.list[0])
const rows = engine.getGroupRows('F2-9')
assert.equal(rows.length, 2)
assert.equal(rows[1]['F2-9-2'], 0)
const cacheNum = viewState.groupRowsCache['F2-9'][1].find(f => f.key === 'F2-9-2')
assert.equal(cacheNum.value, 0)
})
})
})
packageEquity/api.js
View file @
872db3c
...
@@ -160,9 +160,7 @@ module.exports = {
...
@@ -160,9 +160,7 @@ module.exports = {
},
},
/** 查询当周员工日报是否填写列表 */
/** 查询当周员工日报是否填写列表 */
staffDailyReportDetailWeeklyList
(
data
)
{
staffDailyReportDetailWeeklyList
(
data
)
{
// 暂时不调用 dj.api.smartcarlife.staff.daily.report.weekly.list
return
api
.
post
(
'dj.api.smartcarlife.staff.daily.report.weekly.list'
,
data
)
return
Promise
.
resolve
({
code
:
0
,
message
:
'ok'
,
data
:
[]
})
// return api.post('dj.api.smartcarlife.staff.daily.report.weekly.list', data)
},
},
/** 查询员工是否需要驻店日报弹窗 */
/** 查询员工是否需要驻店日报弹窗 */
...
...
tabIndex/api.js
View file @
872db3c
...
@@ -57,9 +57,7 @@ module.exports = {
...
@@ -57,9 +57,7 @@ module.exports = {
},
},
/** 查询当周员工日报是否填写列表 */
/** 查询当周员工日报是否填写列表 */
staffDailyReportDetailWeeklyList
(
data
)
{
staffDailyReportDetailWeeklyList
(
data
)
{
// 暂时不调用 dj.api.smartcarlife.staff.daily.report.weekly.list
return
api
.
post
(
'dj.api.smartcarlife.staff.daily.report.weekly.list'
,
data
)
return
Promise
.
resolve
({
code
:
0
,
message
:
'ok'
,
data
:
[]
})
// return api.post('dj.api.smartcarlife.staff.daily.report.weekly.list', data)
},
},
/** 员工是否需要推送开单预警 */
/** 员工是否需要推送开单预警 */
...
...
tabWorkOrder/api.js
View file @
872db3c
...
@@ -215,9 +215,7 @@ module.exports = {
...
@@ -215,9 +215,7 @@ module.exports = {
},
},
/** 查询当周员工日报是否填写列表 */
/** 查询当周员工日报是否填写列表 */
staffDailyReportDetailWeeklyList
(
data
)
{
staffDailyReportDetailWeeklyList
(
data
)
{
// 暂时不调用 dj.api.smartcarlife.staff.daily.report.weekly.list
return
api
.
post
(
'dj.api.smartcarlife.staff.daily.report.weekly.list'
,
data
)
return
Promise
.
resolve
({
code
:
0
,
message
:
'ok'
,
data
:
[]
})
// return api.post('dj.api.smartcarlife.staff.daily.report.weekly.list', data)
},
},
/** 批复员工日报 */
/** 批复员工日报 */
staffDailyReportApprove
(
data
)
{
staffDailyReportApprove
(
data
)
{
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment