Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 7b7e5776
authored
Mar 24, 2026
by
chenwq1
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix: 抽离公共方法
1 parent
bd73d1ec
Pipeline
#91
for
7b7e5776
failed
in 0 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
45 deletions
apps/web/venus-usedcar-quality/src/components/CustomizeForm/Index.vue
apps/web/venus-usedcar-quality/src/views/car-detail/index.vue
apps/web/venus-usedcar-quality/src/components/CustomizeForm/Index.vue
View file @
7b7e577
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
type
{
CustomizeFormValidateResult
}
from
"@/types/views/car-detail"
;
import
{
ref
,
watch
}
from
"vue"
;
import
{
ref
,
watch
}
from
"vue"
;
import
selectDatePicker
from
"@/components/customizeForm/selectDatePicker.vue"
;
import
selectDatePicker
from
"@/components/customizeForm/selectDatePicker.vue"
;
...
@@ -126,7 +128,7 @@ function setSubmitData() {
...
@@ -126,7 +128,7 @@ function setSubmitData() {
};
};
}
}
async
function
validate
()
{
async
function
validate
()
:
Promise
<
CustomizeFormValidateResult
>
{
const
nodesData
=
setSubmitData
();
const
nodesData
=
setSubmitData
();
console
.
log
(
'validate'
,
nodesData
);
console
.
log
(
'validate'
,
nodesData
);
let
success
=
true
;
let
success
=
true
;
...
@@ -144,7 +146,8 @@ async function validate() {
...
@@ -144,7 +146,8 @@ async function validate() {
};
};
}
}
function
saveData
()
{
/** 与 `validate` 相同返回结构,不校验必填,用于静默保存 / 上一步等场景 */
async
function
saveData
():
Promise
<
CustomizeFormValidateResult
>
{
const
nodesData
=
setSubmitData
();
const
nodesData
=
setSubmitData
();
console
.
log
(
'saveData'
,
nodesData
);
console
.
log
(
'saveData'
,
nodesData
);
return
{
return
{
...
...
apps/web/venus-usedcar-quality/src/views/car-detail/index.vue
View file @
7b7e577
...
@@ -146,17 +146,13 @@
...
@@ -146,17 +146,13 @@
</template>
</template>
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
type
{
BigModule
,
CustomizeFormValidateResult
}
from
"@/types/views/car-detail"
;
import
type
{
InspectionTemplateDefaultData
,
LeafNodeRecord
}
from
"@api"
;
import
type
{
InspectionTemplateDefaultData
,
LeafNodeRecord
}
from
"@api"
;
import
{
computed
,
onMounted
,
ref
}
from
"vue"
;
import
{
computed
,
onMounted
,
ref
}
from
"vue"
;
import
{
useRoute
,
useRouter
}
from
"vue-router"
;
import
{
useRoute
,
useRouter
}
from
"vue-router"
;
import
customizeForm
from
"@/components/customizeForm/Index.vue"
;
import
customizeForm
from
"@/components/customizeForm/Index.vue"
;
import
type
{
BigModule
,
CustomizeFormValidateResult
,
InspectSubContentExpose
,
}
from
"@/types/views/car-detail"
;
import
{
import
{
applyResolvedInitialValuesToLeafNodes
,
applyResolvedInitialValuesToLeafNodes
,
completeInspection
,
completeInspection
,
...
@@ -184,8 +180,7 @@ const activeBigKey = ref<number | string>("");
...
@@ -184,8 +180,7 @@ const activeBigKey = ref<number | string>("");
const
showModulePicker
=
ref
(
false
);
const
showModulePicker
=
ref
(
false
);
const
loading
=
ref
(
false
);
const
loading
=
ref
(
false
);
const
submitting
=
ref
(
false
);
const
submitting
=
ref
(
false
);
/** 二级项检测内容区(叶子节点表单),子组件 defineExpose */
const
customizeFormRef
=
ref
<
InstanceType
<
typeof
customizeForm
>
|
null
>
(
null
);
const
inspectSubContentRef
=
ref
<
InspectSubContentExpose
|
null
>
(
null
);
/** 检测评分表单 */
/** 检测评分表单 */
const
inspectionScoreFormRef
=
ref
<
InstanceType
<
typeof
ScoreForm
>
|
null
>
(
null
);
const
inspectionScoreFormRef
=
ref
<
InstanceType
<
typeof
ScoreForm
>
|
null
>
(
null
);
...
@@ -316,34 +311,6 @@ function onOpenModulePicker() {
...
@@ -316,34 +311,6 @@ function onOpenModulePicker() {
showModulePicker
.
value
=
true
;
showModulePicker
.
value
=
true
;
}
}
/** 切换大项 / 二级项前静默落库当前叶子数据 */
async
function
persistCurrentSubTabSilently
()
{
if
(
activeBigKey
.
value
===
SCORE_BIG_KEY
)
return
;
try
{
const
leafNodes
=
(
await
inspectSubContentRef
.
value
?.
collectData
(
false
))
??
[];
await
saveInspectionRecord
(
buildInspectionSavePayload
(
leafNodes
,
false
));
}
catch
{
// 静默失败,不阻断切换
}
}
async
function
onSelectBigModule
(
selectedBigModule
:
BigModule
)
{
showModulePicker
.
value
=
false
;
if
(
selectedBigModule
.
key
===
activeBigKey
.
value
)
return
;
await
persistCurrentSubTabSilently
();
activeBigKey
.
value
=
selectedBigModule
.
key
;
activeSubKey
.
value
=
""
;
if
(
selectedBigModule
.
key
!==
SCORE_BIG_KEY
)
{
loadSubTabsForBigModule
(
selectedBigModule
.
key
);
}
}
async
function
onSelectSubTab
(
subTabKey
:
number
|
string
)
{
if
(
subTabKey
===
activeSubKey
.
value
)
return
;
await
persistCurrentSubTabSilently
();
activeSubKey
.
value
=
subTabKey
;
}
/** 构造 `saveInspectionRecord` 请求体 */
/** 构造 `saveInspectionRecord` 请求体 */
function
buildInspectionSavePayload
(
leafNodes
:
LeafNodeRecord
[],
nextFlag
:
boolean
)
{
function
buildInspectionSavePayload
(
leafNodes
:
LeafNodeRecord
[],
nextFlag
:
boolean
)
{
return
{
return
{
...
@@ -382,9 +349,6 @@ function advanceInspectionStep() {
...
@@ -382,9 +349,6 @@ function advanceInspectionStep() {
}
}
}
}
const
customizeFormRef
=
ref
();
function
leafRecordFromValidateData
(
raw
:
CustomizeFormValidateResult
[
"data"
]):
LeafNodeRecord
|
null
{
function
leafRecordFromValidateData
(
raw
:
CustomizeFormValidateResult
[
"data"
]):
LeafNodeRecord
|
null
{
if
(
!
raw
)
return
null
;
if
(
!
raw
)
return
null
;
return
{
return
{
...
@@ -403,6 +367,42 @@ function leafRecordFromValidateData(raw: CustomizeFormValidateResult["data"]): L
...
@@ -403,6 +367,42 @@ function leafRecordFromValidateData(raw: CustomizeFormValidateResult["data"]): L
};
};
}
}
/** `saveData` → 转叶子记录 → `saveInspectionRecord`;无有效数据时不请求接口 */
async
function
saveCurrentLeafInspectionRecord
(
nextFlag
:
boolean
):
Promise
<
boolean
>
{
const
saved
=
(
await
customizeFormRef
.
value
?.
saveData
?.())
as
CustomizeFormValidateResult
|
undefined
;
const
record
=
saved
?.
data
?
leafRecordFromValidateData
(
saved
.
data
)
:
null
;
if
(
!
record
)
return
false
;
await
saveInspectionRecord
(
buildInspectionSavePayload
([
record
],
nextFlag
));
return
true
;
}
/** 切换大项 / 二级项前静默落库当前叶子数据 */
async
function
persistCurrentSubTabSilently
()
{
if
(
activeBigKey
.
value
===
SCORE_BIG_KEY
)
return
;
try
{
await
saveCurrentLeafInspectionRecord
(
false
);
}
catch
{
// 静默失败,不阻断切换
}
}
async
function
onSelectBigModule
(
selectedBigModule
:
BigModule
)
{
showModulePicker
.
value
=
false
;
if
(
selectedBigModule
.
key
===
activeBigKey
.
value
)
return
;
await
persistCurrentSubTabSilently
();
activeBigKey
.
value
=
selectedBigModule
.
key
;
activeSubKey
.
value
=
""
;
if
(
selectedBigModule
.
key
!==
SCORE_BIG_KEY
)
{
loadSubTabsForBigModule
(
selectedBigModule
.
key
);
}
}
async
function
onSelectSubTab
(
subTabKey
:
number
|
string
)
{
if
(
subTabKey
===
activeSubKey
.
value
)
return
;
await
persistCurrentSubTabSilently
();
activeSubKey
.
value
=
subTabKey
;
}
/** 下一步:校验当前叶子 → 保存 → 前进 */
/** 下一步:校验当前叶子 → 保存 → 前进 */
async
function
onNext
()
{
async
function
onNext
()
{
if
(
submitting
.
value
)
return
;
if
(
submitting
.
value
)
return
;
...
@@ -413,12 +413,11 @@ async function onNext() {
...
@@ -413,12 +413,11 @@ async function onNext() {
showToast
(
res
?.
message
??
"校验失败"
);
showToast
(
res
?.
message
??
"校验失败"
);
return
;
return
;
}
}
const
record
=
leafRecordFromValidateData
(
res
.
data
);
const
savedOk
=
await
saveCurrentLeafInspectionRecord
(
true
);
if
(
!
record
)
{
if
(
!
savedOk
)
{
showToast
(
"未获取到表单数据"
);
showToast
(
"未获取到表单数据"
);
return
;
return
;
}
}
await
saveInspectionRecord
(
buildInspectionSavePayload
([
record
],
true
));
advanceInspectionStep
();
advanceInspectionStep
();
}
catch
(
error
)
{
}
catch
(
error
)
{
if
(
!
isRequestFailureAlreadyHandled
(
error
))
{
if
(
!
isRequestFailureAlreadyHandled
(
error
))
{
...
@@ -450,8 +449,7 @@ async function onPrev() {
...
@@ -450,8 +449,7 @@ async function onPrev() {
return
;
return
;
}
}
const
leafNodes
=
(
await
inspectSubContentRef
.
value
?.
collectData
(
false
))
??
[];
await
saveCurrentLeafInspectionRecord
(
false
);
await
saveInspectionRecord
(
buildInspectionSavePayload
(
leafNodes
,
false
));
const
subTabsOfActive
=
activeBigModule
.
value
?.
subTabs
??
[];
const
subTabsOfActive
=
activeBigModule
.
value
?.
subTabs
??
[];
const
activeSubIndex
=
subTabsOfActive
.
findIndex
((
subTab
)
=>
subTab
.
key
===
activeSubKey
.
value
);
const
activeSubIndex
=
subTabsOfActive
.
findIndex
((
subTab
)
=>
subTab
.
key
===
activeSubKey
.
value
);
...
...
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