Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yd-csf-front
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yuzhenWang
yd-csf-front
Commits
6194d11b
Commit
6194d11b
authored
Jan 08, 2026
by
Sweet Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改入账检核没有入账项目的bug
parent
16afea7a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
108 additions
and
39 deletions
+108
-39
src/components/SearchForm/SearchForm.vue
+90
-19
src/views/financialCenter/financialIncome.vue
+18
-20
No files found.
src/components/SearchForm/SearchForm.vue
View file @
6194d11b
<
template
>
<el-form
ref=
"formRef"
:model=
"localModel"
:rules=
"formRules"
label-width=
"auto"
v-bind=
"$attrs"
:validate-on-rule-change=
"false"
>
<el-form
ref=
"formRef"
:model=
"localModel"
:rules=
"formRules"
label-width=
"auto"
v-bind=
"$attrs"
:validate-on-rule-change=
"false"
>
<el-row
:gutter=
"20"
>
<el-col
v-for=
"item in visibleConfig"
:key=
"item.prop"
:span=
"item.span || 6"
>
<el-form-item
:label=
"item.label"
:prop=
"item.prop"
:class=
"
{ 'search-form-item': isSearch }" :label-position="item.labelPosition || 'top'">
<el-form-item
:label=
"item.label"
:prop=
"item.prop"
:class=
"
{ 'search-form-item': isSearch }"
:label-position="item.labelPosition || 'top'">
<!-- Input -->
<el-input
v-if=
"item.type === 'input'"
v-model=
"localModel[item.prop]"
:placeholder=
"item.placeholder || `请输入$
{item.label}`" :clearable="true"
...
...
@@ -194,25 +196,77 @@ watch(
}
}
localModel
.
value
=
initialModel
// ✅ 在这里同步 modelValue(包括 extra 字段)
localModel
.
value
=
syncModelFromProps
(
props
.
modelValue
,
internalConfig
.
value
)
},
{
immediate
:
true
}
)
console
.
log
(
'🚀 子组件 props.modelValue 初始值:'
,
props
.
modelValue
)
// 监听 modelValue(用于后续外部更新)
watch
(
()
=>
props
.
modelValue
,
(
newVal
)
=>
{
if
(
!
newVal
)
return
// 只同步存在的字段,避免污染
for
(
const
item
of
internalConfig
.
value
)
{
if
(
!
newVal
||
!
internalConfig
.
value
)
return
// ✅ 同样使用 sync 函数
localModel
.
value
=
syncModelFromProps
(
newVal
,
internalConfig
.
value
)
},
{
deep
:
true
}
)
// 提取同步逻辑
function
syncModelFromProps
(
newModelValue
,
newConfig
)
{
if
(
!
newModelValue
||
!
newConfig
)
return
{}
const
synced
=
{}
// 1️⃣ 同步主字段(config 中定义的 prop)
for
(
const
item
of
newConfig
)
{
const
key
=
item
.
prop
if
(
newVal
.
hasOwnProperty
(
key
))
{
localModel
.
value
[
key
]
=
newVal
[
key
]
if
(
newModelValue
.
hasOwnProperty
(
key
))
{
synced
[
key
]
=
newModelValue
[
key
]
}
else
if
(
item
.
multiple
||
[
'checkbox-group'
,
'daterange'
].
includes
(
item
.
type
))
{
synced
[
key
]
=
item
.
defaultValue
??
[]
}
else
{
synced
[
key
]
=
item
.
defaultValue
??
''
}
}
// 2️⃣ 同步 extra 字段(从主字段的 raw 中提取)
for
(
const
item
of
newConfig
)
{
const
sourceField
=
item
.
prop
const
extraMap
=
item
.
onChangeExtraFields
if
(
!
extraMap
||
typeof
extraMap
!==
'object'
)
continue
const
sourceObj
=
newModelValue
[
sourceField
]
if
(
!
sourceObj
||
typeof
sourceObj
!==
'object'
)
continue
for
(
const
[
targetKey
,
subPath
]
of
Object
.
entries
(
extraMap
))
{
const
val
=
getNestedValue
(
sourceObj
,
subPath
)
if
(
val
!==
undefined
)
{
synced
[
targetKey
]
=
val
}
}
}
)
// ✅ 3️⃣ 【关键】保留 localModel 中已有的、未被覆盖的 extra 字段
for
(
const
key
in
localModel
.
value
)
{
// 如果这个 key 不是主字段(不在 config 中),且 synced 没有覆盖它
if
(
!
synced
.
hasOwnProperty
(
key
)
&&
!
newConfig
.
some
(
item
=>
item
.
prop
===
key
)
)
{
// 说明它是 extra 字段,且这次同步没提供新值 → 保留旧值
synced
[
key
]
=
localModel
.
value
[
key
]
}
}
return
synced
}
function
getNestedValue
(
obj
,
path
)
{
return
path
.
split
(
'.'
).
reduce
((
current
,
key
)
=>
current
?.[
key
],
obj
)
}
// 当字典加载完成时,触发同步
function
markDictLoaded
(
prop
)
{
dictLoaded
.
value
.
add
(
prop
)
...
...
@@ -222,27 +276,44 @@ function markDictLoaded(prop) {
}
}
// 2. 用户操作导致 localModel 变化时,emit(防抖可选)
function
handleModelChange
(
value
,
item
)
{
console
.
log
(
'✅ handleModelChange 被调用'
,
{
prop
:
item
?.
prop
,
value
})
// 同步额外字段
console
.
group
(
'🔄 handleModelChange'
)
console
.
log
(
'输入 value:'
,
value
)
console
.
log
(
'item:'
,
item
)
console
.
log
(
'当前 localModel:'
,
localModel
.
value
)
const
newModel
=
{
...
localModel
.
value
,
[
item
.
prop
]:
value
}
if
(
item
?.
type
===
'select'
&&
item
.
onChangeExtraFields
)
{
const
options
=
getSelectOptions
(
item
)
const
opt
=
options
.
find
(
o
=>
o
.
value
===
value
)
// ✅ 现在 value 和 o.value 类型一致
if
(
opt
)
{
console
.
log
(
'可用 options:'
,
options
)
const
opt
=
options
.
find
(
o
=>
o
.
value
===
value
)
console
.
log
(
'匹配的 opt:'
,
opt
)
if
(
opt
?.
raw
)
{
for
(
const
[
targetProp
,
sourceKey
]
of
Object
.
entries
(
item
.
onChangeExtraFields
))
{
localModel
.
value
[
targetProp
]
=
opt
.
raw
[
sourceKey
]
console
.
log
(
`✅ 同步
${
targetProp
}
=`
,
opt
.
raw
[
sourceKey
])
const
extraValue
=
opt
.
raw
[
sourceKey
]
newModel
[
targetProp
]
=
extraValue
console
.
log
(
`✅ 设置
${
targetProp
}
=`
,
extraValue
)
}
}
}
// emit 更新
console
.
log
(
'🆕 newModel:'
,
newModel
)
console
.
log
(
'📦 props.modelValue:'
,
props
.
modelValue
)
console
.
log
(
'isEqualShallow?'
,
isEqualShallow
(
props
.
modelValue
,
newModel
))
localModel
.
value
=
newModel
nextTick
(()
=>
{
if
(
!
isEqualShallow
(
props
.
modelValue
,
localModel
.
value
))
{
console
.
log
(
'准备 emit modelValue:'
,
localModel
.
value
)
emit
(
'update:modelValue'
,
{
...
localModel
.
value
})
if
(
!
isEqualShallow
(
props
.
modelValue
,
newModel
))
{
console
.
log
(
'📤 emit update:modelValue:'
,
newModel
)
emit
(
'update:modelValue'
,
newModel
)
}
else
{
console
.
log
(
'🚫 跳过 emit:认为相等'
)
}
})
console
.
groupEnd
()
}
// 辅助函数:浅比较两个对象
function
isEqualShallow
(
a
,
b
)
{
...
...
src/views/financialCenter/financialIncome.vue
View file @
6194d11b
...
...
@@ -431,7 +431,7 @@ const checkRecordEdit = (row) => {
editStatus
.
value
=
'edit'
addReceivablesFormModel
.
value
=
{
...
row
}
addCheckRecordDialogFlag
.
value
=
true
// console.log('父组件赋值',
addReceivablesFormModel.value)
console
.
log
(
'父组件赋值'
,
addReceivablesFormModel
.
value
)
}
const
checkFormData
=
ref
({
...
...
@@ -614,36 +614,34 @@ const addCheckRecordConfig = ref([
])
const
addCheckRecordDialogFlag
=
ref
(
false
)
const
handleAddCheckRecord
=
async
()
=>
{
try
{
const
params
=
ref
({})
// ✅ 统一从子组件获取完整表单数据(含 extra 字段)
await
nextTick
()
// 确保子组件已同步
const
formData
=
addCheckRecordFormRef
.
value
.
getFormData
()
console
.
log
(
'======'
,
formData
)
let
params
if
(
editStatus
.
value
===
'edit'
)
{
params
.
value
=
{
...
addReceivablesFormModel
.
value
,
params
=
{
...
formData
,
// ←←← 使用 formData,不是 addReceivablesFormModel.value
commissionBizId
:
selectedRowCheck
.
value
.
commissionBizId
}
console
.
log
(
params
)
await
updateCommissionRecord
(
params
.
value
)
ElMessage
.
success
(
'更新检核记录成功'
)
addCheckRecordDialogFlag
.
value
=
false
resetForm
(
'addReceivablesFormModel'
)
await
updateCommissionRecord
(
params
)
}
else
{
const
addCheckSearchParams
=
addCheckRecordFormRef
.
value
.
getFormData
()
console
.
log
(
'新增检核记录'
,
addCheckSearchParams
)
params
.
value
=
{
...
addCheckSearchParams
,
params
=
{
...
formData
,
reconciliationYearMonth
:
checkFormData
.
value
.
reconciliationYearMonth
}
await
addPayrollCheckRecord
([
params
.
value
])
ElMessage
.
success
(
'新增检核记录成功'
)
await
addPayrollCheckRecord
([
params
])
}
ElMessage
.
success
(
editStatus
.
value
===
'edit'
?
'更新成功'
:
'新增成功'
)
addCheckRecordDialogFlag
.
value
=
false
resetForm
(
'addReceivablesFormModel'
)
checkRecordTableData
.
value
=
[]
}
checkRecordQuery
()
}
catch
(
error
)
{
console
.
error
(
'
新增检核记录
失败'
,
error
)
ElMessage
.
error
(
'
新增检核记录
失败'
)
console
.
error
(
'
操作
失败'
,
error
)
ElMessage
.
error
(
'
操作
失败'
)
}
}
const
resetForm
=
(
type
)
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment