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 7f89579c
authored
Apr 01, 2026
by
chenwq1
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix:路由跳转
1 parent
afdaa675
Pipeline
#164
for
7f89579c
failed
in 0 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
122 additions
and
23 deletions
apps/web/venus-usedcar-quality/src/config/center.ts
apps/web/venus-usedcar-quality/src/types/views/car-detail.ts
apps/web/venus-usedcar-quality/src/utils/request.ts
apps/web/venus-usedcar-quality/src/views/car-detail/composables/useInspectModules.ts
apps/web/venus-usedcar-quality/src/views/car-detail/index.vue
apps/web/venus-usedcar-quality/src/views/login/useLogin.ts
apps/web/venus-usedcar-quality/src/config/center.ts
View file @
7f89579
...
...
@@ -8,6 +8,13 @@ import { showToast } from "vant";
import
{
CONFIG_CACHE_KEY
,
CONFIG_CENTER_URL
,
TOKEN_KEY
}
from
"./constants"
;
const
defaultBaseURL
=
import
.
meta
.
env
.
VITE_API_BASE_URL
??
""
;
const
APP_BASE_PATH
=
(()
=>
{
const
base
=
import
.
meta
.
env
.
BASE_URL
??
"/"
;
if
(
!
base
||
base
===
"/"
)
{
return
""
;
}
return
base
.
endsWith
(
"/"
)
?
base
.
slice
(
0
,
-
1
)
:
base
;
})();
let
config
:
Record
<
string
,
unknown
>
=
{};
let
requestInstance
:
null
|
Request
=
null
;
...
...
@@ -53,7 +60,7 @@ function initRequestInstance(cfg: Record<string, unknown>): void {
case
401
:
{
showToast
(
"登录已过期,请重新登录"
);
localStorage
.
removeItem
(
TOKEN_KEY
);
window
.
location
.
href
=
"/login"
;
window
.
location
.
href
=
`
${
APP_BASE_PATH
}
/login`
;
break
;
}
...
...
apps/web/venus-usedcar-quality/src/types/views/car-detail.ts
View file @
7f89579
...
...
@@ -17,6 +17,8 @@ export interface SubTab {
}
export
interface
BigModule
{
/** 大项完成标志:0 未完成,1 已完成(接口可能返回字符串) */
completedFlag
?:
0
|
1
|
string
;
/** 是否存在二级分组 Tab;false 表示子节点直接为叶子(nodeType=3),不展示二级 Tab */
hasSecondaryTabs
?:
boolean
;
key
:
number
|
string
;
...
...
apps/web/venus-usedcar-quality/src/utils/request.ts
View file @
7f89579
...
...
@@ -50,6 +50,13 @@ export interface RequestConfig {
}
const
defaultBaseURL
=
import
.
meta
.
env
.
VITE_API_BASE_URL
??
""
;
const
APP_BASE_PATH
=
(()
=>
{
const
base
=
import
.
meta
.
env
.
BASE_URL
??
"/"
;
if
(
!
base
||
base
===
"/"
)
{
return
""
;
}
return
base
.
endsWith
(
"/"
)
?
base
.
slice
(
0
,
-
1
)
:
base
;
})();
/** 业务成功码 */
const
BIZ_CODE_OK
=
200
;
...
...
@@ -57,6 +64,7 @@ const BIZ_CODE_OK = 200;
const
BIZ_CODES_NO_GLOBAL_TOAST
=
new
Set
([
1000
,
1002
,
1003
,
1010
]);
/** 未登录或登录过期 */
const
BIZ_CODE_UNAUTHORIZED
=
1006
;
let
isRedirectingToLogin
=
false
;
function
normalizeBizCode
(
code
:
unknown
):
null
|
number
{
if
(
code
===
null
||
code
===
undefined
||
code
===
""
)
{
...
...
@@ -66,10 +74,24 @@ function normalizeBizCode(code: unknown): null | number {
return
Number
.
isNaN
(
n
)
?
null
:
n
;
}
function
buildLoginUrlWithHostContext
():
string
{
const
url
=
new
URL
(
window
.
location
.
href
);
const
next
=
new
URL
(
`
${
APP_BASE_PATH
}
/login`
,
window
.
location
.
origin
);
const
openType
=
url
.
searchParams
.
get
(
"openType"
);
if
(
openType
)
{
next
.
searchParams
.
set
(
"openType"
,
openType
);
}
return
`
${
next
.
pathname
}${
next
.
search
}
`
;
}
function
redirectToLogin
(
message
?:
string
)
{
if
(
isRedirectingToLogin
)
{
return
;
}
isRedirectingToLogin
=
true
;
showToast
(
message
||
"登录已过期,请重新登录"
);
localStorage
.
removeItem
(
TOKEN_KEY
);
window
.
location
.
href
=
"/login"
;
window
.
location
.
replace
(
buildLoginUrlWithHostContext
())
;
}
let
axiosInstance
:
AxiosInstance
|
null
=
null
;
...
...
@@ -141,7 +163,7 @@ function getInstance(): AxiosInstance {
break
;
}
case
500
:
{
showToast
(
"服务器异常,请稍后重试"
);
showToast
(
msg
||
"服务器异常,请稍后重试"
);
break
;
}
default
:
{
...
...
apps/web/venus-usedcar-quality/src/views/car-detail/composables/useInspectModules.ts
View file @
7f89579
...
...
@@ -16,6 +16,7 @@ import {
getInspectionRootNodes
,
getInspectionTemplateDefault
,
}
from
"@api"
;
import
{
isRequestFailureAlreadyHandled
}
from
"@utils/request"
;
import
{
showToast
}
from
"vant"
;
/** 检测评分大项的固定 key(非接口返回,手动追加至大项末尾) */
...
...
@@ -39,6 +40,11 @@ export function isSubTabMarkCompleted(sub: SubTab): boolean {
return
isCompletedFlagFieldDone
(
sub
.
completedFlag
);
}
/** 大项弹窗勾选:根据 rootNodes.completedFlag 判断是否完成 */
export
function
isBigModuleMarkCompleted
(
module
:
BigModule
):
boolean
{
return
isCompletedFlagFieldDone
(
module
.
completedFlag
);
}
/** 二级子节点列表:总进度 = 列表长度,已完成 = 各节点 inspectionResultVO.completedFlag */
function
computeSecondaryProgressFromList
(
list
:
InspectionNode
[]):
{
done
:
number
;
total
:
number
;
}
{
const
nodes
=
Array
.
isArray
(
list
)
?
list
:
[];
...
...
@@ -143,6 +149,48 @@ export function useInspectModules(route: RouteLocationNormalizedLoaded) {
const
currentLeafNodes
=
computed
(()
=>
activeSubTab
.
value
?.
leafNodes
??
[]);
/** 拉取 rootNodes 并刷新大项列表;保留已加载的大项二级缓存与当前选中项 */
async
function
refreshBigModulesFromRootNodes
()
{
if
(
taskId
.
value
===
""
||
taskId
.
value
===
null
||
taskId
.
value
===
undefined
)
return
;
const
rootNodes
=
await
getInspectionRootNodes
(
taskId
.
value
);
if
(
!
Array
.
isArray
(
rootNodes
)
||
rootNodes
.
length
===
0
)
return
;
const
oldModules
=
bigModules
.
value
;
const
oldByKey
=
new
Map
(
oldModules
.
map
((
m
)
=>
[
String
(
m
.
key
),
m
]));
const
scoreRoot
=
rootNodes
.
find
((
root
)
=>
String
(
root
.
id
)
===
"-1"
);
const
inspectionRoots
=
rootNodes
.
filter
((
root
)
=>
String
(
root
.
id
)
!==
"-1"
);
const
refreshedInspectionModules
:
BigModule
[]
=
inspectionRoots
.
map
((
root
)
=>
{
const
prev
=
oldByKey
.
get
(
String
(
root
.
id
));
return
{
key
:
root
.
id
,
label
:
root
.
nodeName
,
nodeId
:
root
.
id
,
completedFlag
:
root
.
completedFlag
as
0
|
1
|
string
|
undefined
,
subTabs
:
prev
?.
subTabs
??
[],
hasSecondaryTabs
:
prev
?.
hasSecondaryTabs
,
secondaryProgress
:
prev
?.
secondaryProgress
,
};
});
const
prevScore
=
oldByKey
.
get
(
String
(
SCORE_BIG_KEY
));
const
scoreModule
:
BigModule
=
{
key
:
SCORE_BIG_KEY
,
label
:
"检测评分"
,
completedFlag
:
scoreRoot
?.
completedFlag
as
0
|
1
|
string
|
undefined
,
subTabs
:
prevScore
?.
subTabs
??
[],
hasSecondaryTabs
:
prevScore
?.
hasSecondaryTabs
,
secondaryProgress
:
prevScore
?.
secondaryProgress
,
};
bigModules
.
value
=
[...
refreshedInspectionModules
,
scoreModule
];
const
activeExists
=
bigModules
.
value
.
some
((
m
)
=>
m
.
key
===
activeBigKey
.
value
);
if
(
!
activeExists
)
{
const
firstMain
=
bigModules
.
value
[
0
];
if
(
firstMain
)
activeBigKey
.
value
=
firstMain
.
key
;
}
}
async
function
initializeInspection
()
{
try
{
loading
.
value
=
true
;
...
...
@@ -155,23 +203,11 @@ export function useInspectModules(route: RouteLocationNormalizedLoaded) {
taskId
.
value
=
routeTaskId
;
const
rootNodes
=
await
getInspectionRootNodes
(
taskId
.
value
);
if
(
!
rootNodes
||
rootNodes
.
length
===
0
)
{
showToast
(
"暂无检测模板数据"
);
return
;
}
const
assembledBigModules
:
BigModule
[]
=
[
...
rootNodes
.
map
((
root
)
=>
({
key
:
root
.
id
,
label
:
root
.
nodeName
,
nodeId
:
root
.
id
,
subTabs
:
[],
})),
{
key
:
SCORE_BIG_KEY
,
label
:
"检测评分"
,
subTabs
:
[]
},
];
bigModules
.
value
=
assembledBigModules
;
await
refreshBigModulesFromRootNodes
();
const
firstMain
=
bigModules
.
value
[
0
];
if
(
firstMain
)
{
...
...
@@ -180,7 +216,9 @@ export function useInspectModules(route: RouteLocationNormalizedLoaded) {
}
}
catch
(
error
)
{
console
.
error
(
"初始化检测页失败:"
,
error
);
showToast
(
"加载检测模板失败"
);
if
(
!
isRequestFailureAlreadyHandled
(
error
))
{
showToast
(
"加载检测模板失败"
);
}
}
finally
{
loading
.
value
=
false
;
}
...
...
@@ -254,7 +292,9 @@ export function useInspectModules(route: RouteLocationNormalizedLoaded) {
}
}
catch
(
error
)
{
console
.
error
(
"加载二级项失败:"
,
error
);
showToast
(
"加载二级项失败"
);
if
(
!
isRequestFailureAlreadyHandled
(
error
))
{
showToast
(
"加载二级项失败"
);
}
}
}
...
...
@@ -327,7 +367,12 @@ export function useInspectModules(route: RouteLocationNormalizedLoaded) {
await
advanceToNextMainInspectionModule
();
}
function
onOpenModulePicker
()
{
async
function
onOpenModulePicker
()
{
try
{
await
refreshBigModulesFromRootNodes
();
}
catch
(
error
)
{
console
.
error
(
"刷新检测模块失败:"
,
error
);
}
showModulePicker
.
value
=
true
;
}
...
...
apps/web/venus-usedcar-quality/src/views/car-detail/index.vue
View file @
7f89579
...
...
@@ -141,7 +141,14 @@
class=
"module-picker-item"
:class=
"{ selected: bigModule.key === pendingModuleKey }"
@
click=
"setPendingModuleKey(bigModule.key)"
>
<span
class=
"picker-label"
>
{{ bigModule.label }}
</span>
<span
class=
"picker-label-wrap"
>
<span
class=
"picker-label"
>
{{ bigModule.label }}
</span>
<van-icon
v-if=
"isBigModuleMarkCompleted(bigModule)"
class=
"picker-done-icon"
color=
"#27CD5A"
name=
"checked"
size=
"14"
/>
</span>
<van-icon
v-if=
"bigModule.key === pendingModuleKey"
color=
"#477ffe"
name=
"success"
...
...
@@ -179,7 +186,7 @@ import { useRoute } from "vue-router";
import
customizeForm
from
"@/components/CustomizeForm/Index.vue"
;
import
ScoreForm
from
"./components/ScoreForm.vue"
;
import
{
isSubTabMarkCompleted
,
SCORE_BIG_KEY
,
useInspectModules
}
from
"./composables/useInspectModules"
;
import
{
is
BigModuleMarkCompleted
,
is
SubTabMarkCompleted
,
SCORE_BIG_KEY
,
useInspectModules
}
from
"./composables/useInspectModules"
;
import
{
useInspectSubmit
}
from
"./composables/useInspectSubmit"
;
const
route
=
useRoute
();
...
...
@@ -546,5 +553,16 @@ onMounted(() => {
font-size
:
$
font-size-base
;
color
:
$
color-text-primary
;
}
.picker-label-wrap
{
display
:
inline-flex
;
gap
:
4px
;
align-items
:
center
;
}
.picker-done-icon
{
flex-shrink
:
0
;
line-height
:
1
;
}
}
</
style
>
apps/web/venus-usedcar-quality/src/views/login/useLogin.ts
View file @
7f89579
...
...
@@ -4,6 +4,7 @@ import { useRouter } from "vue-router";
import
{
login
,
sendSmsCode
}
from
"@/api/modules/user.ts"
;
import
{
LOGIN_REDIRECT_KEY
}
from
"@/config/constants"
;
import
{
useUserStore
}
from
"@/stores/modules/user.ts"
;
import
{
isRequestFailureAlreadyHandled
}
from
"@/utils/request"
;
import
{
notifyHostToken
}
from
"@/utils/webviewBridge"
;
import
{
showFailToast
,
showSuccessToast
}
from
"vant"
;
...
...
@@ -60,7 +61,9 @@ export function useLogin() {
},
1000
);
}
catch
(
error
)
{
console
.
error
(
"sendSmsCode error"
,
error
);
showFailToast
(
"验证码发送失败,请稍后重试"
);
if
(
!
isRequestFailureAlreadyHandled
(
error
))
{
showFailToast
(
"验证码发送失败,请稍后重试"
);
}
}
finally
{
// sending 仅表示接口请求中;倒计时阶段由 countdown 控制禁用态
sending
.
value
=
false
;
...
...
@@ -102,7 +105,9 @@ export function useLogin() {
router
.
replace
(
redirect
);
}
catch
(
error
)
{
console
.
error
(
"login error"
,
error
);
showFailToast
(
"登录失败,请稍后重试"
);
if
(
!
isRequestFailureAlreadyHandled
(
error
))
{
showFailToast
(
"登录失败,请稍后重试"
);
}
}
finally
{
loggingIn
.
value
=
false
;
}
...
...
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