Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
zrch-risk-39
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
zrch-risk-39
Commits
56fa3c83
提交
56fa3c83
authored
3月 24, 2026
作者:
kxjia
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
改绝对路径
上级
769c14f2
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
79 行增加
和
42 行删除
+79
-42
StProblemIndex.vue
...ient-39/src/views/project/problemCheck/StProblemIndex.vue
+79
-42
没有找到文件。
zrch-risk-client-39/src/views/project/problemCheck/StProblemIndex.vue
浏览文件 @
56fa3c83
...
...
@@ -15,76 +15,112 @@
<
script
lang=
"ts"
name=
"problem-stProblemCheck"
setup
>
import
{
ref
,
nextTick
,
onMounted
,
defineAsyncComponent
,
h
}
from
'vue'
;
import
{
useRoute
}
from
'vue-router'
;
import
{
getNodesByTableName
}
from
'/@/components/Process/api/definition'
;
const
route
=
useRoute
();
const
workflowNodes
=
ref
<
any
[]
>
([]);
const
activeTab
=
ref
(
1
);
// 组件缓存,避免重复加载
const
componentCache
=
new
Map
();
// 使用 import.meta.glob 预加载所有可能的组件,使用 /@/ 格式
const
modules
=
import
.
meta
.
glob
(
'@/views/**/*.vue'
);
function
handleTabChange
(
key
)
{
activeTab
.
value
=
key
;
}
// 将
formListurl
转换为正确的导入路径并动态加载组件
function
loadComponent
(
formList
url
:
string
)
{
console
.
log
(
'开始加载组件,
formListurl:'
,
formList
url
);
// 将
URL
转换为正确的导入路径并动态加载组件
function
loadComponent
(
url
:
string
)
{
console
.
log
(
'开始加载组件,
URL:'
,
url
);
if
(
componentCache
.
has
(
formList
url
))
{
console
.
log
(
'从缓存加载组件:'
,
formList
url
);
return
componentCache
.
get
(
formList
url
);
if
(
componentCache
.
has
(
url
))
{
console
.
log
(
'从缓存加载组件:'
,
url
);
return
componentCache
.
get
(
url
);
}
// 解析formListurl,提取组件路径
// formListurl格式:/project/problemCheck/StProblemCheckList
// 转换为:./StProblemCheckList.vue
const
pathParts
=
formListurl
.
split
(
'/'
);
console
.
log
(
'路径分割结果:'
,
pathParts
);
// 构建使用 /@/ 格式的组件路径
let
componentPath
=
''
;
// 获取最后一个部分作为组件名
const
componentName
=
pathParts
[
pathParts
.
length
-
1
];
console
.
log
(
'提取的组件名:'
,
componentName
);
// 检查url是否已包含/views
if
(
url
.
includes
(
'/views'
))
{
// 如果已包含/views,直接使用 /@/ 前缀
componentPath
=
`/src
${
url
}
`
;
}
else
{
// 否则添加 /@/views 前缀
componentPath
=
`/src/views
${
url
}
`
;
}
// 构建导入路径
const
importPath
=
`./
${
componentName
}
.vue`
;
console
.
log
(
'生成的导入路径:'
,
importPath
);
// 检查是否已有文件后缀
if
(
!
componentPath
.
match
(
/
\.(
vue|js|ts|jsx|tsx
)
$/
))
{
// 如果没有文件后缀,添加.vue
componentPath
+=
'.vue'
;
}
console
.
log
(
'生成的组件路径:'
,
componentPath
);
console
.
log
(
'所有可用的组件路径示例:'
,
Object
.
keys
(
modules
).
slice
(
0
,
10
));
// 从预加载的 modules 中获取加载器
let
loader
=
modules
[
componentPath
];
if
(
!
loader
)
{
console
.
error
(
'未找到组件:'
,
componentPath
);
console
.
log
(
'包含 problemCheck 的路径:'
,
Object
.
keys
(
modules
).
filter
(
key
=>
key
.
includes
(
'problemCheck'
)));
// 返回错误组件
const
ErrorComponent
=
{
render
:
()
=>
h
(
'div'
,
{
style
:
'color: red; padding: 20px;'
},
`组件未找到:
${
componentPath
}
`
)
};
componentCache
.
set
(
url
,
ErrorComponent
);
return
ErrorComponent
;
}
// 创建异步组件
const
AsyncComponent
=
defineAsyncComponent
({
loader
:
async
()
=>
{
try
{
const
module
=
await
import
(
importPath
);
return
module
.
default
||
module
;
}
catch
(
error
)
{
console
.
error
(
`加载组件失败 (
${
formListurl
}
):`
,
error
);
return
{
render
:
()
=>
h
(
'div'
,
'组件加载失败'
)
};
}
loader
:
()
=>
loader
()
as
Promise
<
{
default
:
any
}
>
,
loadingComponent
:
{
render
:
()
=>
h
(
'div'
,
{
style
:
'text-align: center; padding: 20px;'
},
'加载中...'
)
},
errorComponent
:
{
render
:
()
=>
h
(
'div'
,
{
style
:
'color: red; padding: 20px;'
},
'组件加载失败,请刷新页面重试'
)
},
loadingComponent
:
{
render
:
()
=>
h
(
'div'
,
'加载中...'
)
},
errorComponent
:
{
render
:
()
=>
h
(
'div'
,
'组件加载失败'
)
},
// 延迟显示加载组件的时间(毫秒)
delay
:
200
,
// 超时时间(毫秒)
timeout
:
3000
timeout
:
3000
,
onError
(
error
)
{
console
.
error
(
'异步组件加载错误:'
,
error
);
}
});
componentCache
.
set
(
formList
url
,
AsyncComponent
);
componentCache
.
set
(
url
,
AsyncComponent
);
return
AsyncComponent
;
}
onMounted
(
async
()
=>
{
await
nextTick
();
try
{
const
nodes
=
await
getNodesByTableName
(
"st_problem_check"
);
const
nodeData
=
nodes
?.
data
?.
records
||
nodes
?.
records
||
nodes
||
[];
workflowNodes
.
value
=
nodeData
;
}
catch
(
error
)
{
console
.
error
(
'获取工作流节点失败:'
,
error
);
try
{
console
.
log
(
'开始获取工作流节点...'
);
const
nodes
=
await
getNodesByTableName
(
"st_problem_check"
);
workflowNodes
.
value
=
nodes
;
console
.
log
(
'获取到的工作流节点:'
,
workflowNodes
.
value
);
// 打印每个节点的 formListUrl
workflowNodes
.
value
.
forEach
((
node
,
index
)
=>
{
console
.
log
(
`节点
${
index
+
1
}
:`
,
node
.
name
,
'formListUrl:'
,
node
.
formListUrl
);
});
// 预加载所有节点的组件
if
(
workflowNodes
.
value
&&
workflowNodes
.
value
.
length
>
0
)
{
console
.
log
(
'开始预加载组件...'
);
workflowNodes
.
value
.
forEach
(
node
=>
{
if
(
node
.
formListUrl
)
{
console
.
log
(
'预加载组件 URL:'
,
node
.
formListUrl
);
loadComponent
(
node
.
formListUrl
);
}
});
}
}
catch
(
error
)
{
console
.
error
(
'获取工作流节点失败:'
,
error
);
}
});
</
script
>
...
...
@@ -98,4 +134,4 @@
text-align
:
center
;
color
:
#999
;
}
</
style
>
</
style
>
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论