异步执行完成自动关闭

This commit is contained in:
wangxk 2025-07-07 10:02:22 +08:00
parent e5d791e520
commit 485e754646
3 changed files with 25 additions and 12 deletions

View File

@ -52,6 +52,7 @@ onBeforeUnmount(() => {
})
const projectId = ref()
const storageKey: any = ref()
const statustype: any = ref('')
//websocket
let ws1
function setupWebSocket() {
@ -62,6 +63,12 @@ function setupWebSocket() {
};
ws1.onmessage = (e) => {
console.log('websocket接收到消息', e)
// debugger
if (e.data == '专项文档扫描任务处理完成!') {
statustype.vlaue = '1'
} else {
statustype.vlaue = '2'
}
tonstatus(true)
}
ws1.onclose = () => {
@ -820,7 +827,9 @@ function tonstatus(ready: any) {
if (res.data.scanstatus == '1') {
tonloading.value = false
buttonmsg.value = '扫描项目完整路径'
readyto(ready,'1')
if (statustype.vlaue == '1') {
readyto(ready, '1')
}
} else if (res.data.scanstatus == '0') {
tonloading.value = true
buttonmsg.value = '处理中...'
@ -828,7 +837,9 @@ function tonstatus(ready: any) {
if (res.data.uploadstatus == '1') {
tonloading1.value = false
buttonmsg1.value = '初始化导入项目完整压缩包'
readyto(ready,'2')
if (statustype.vlaue == '2') {
readyto(ready, '2')
}
} else if (res.data.uploadstatus == '0') {
tonloading1.value = true
buttonmsg1.value = '处理中...'
@ -837,7 +848,9 @@ function tonstatus(ready: any) {
gettreedata()
}
function readyto(ready: any, type: any) {
if (ready) {
let msg = type == '1' ? '项目扫描成功' : '项目初始化成功'
ElMessageBox.confirm(
msg,
@ -848,9 +861,9 @@ function readyto(ready: any, type: any) {
type: 'warning',
}
)
.then(() => {
})
setTimeout(() => {
ElMessageBox.close()
}, 5000)
}
}
</script>

View File

@ -155,9 +155,9 @@ function readyto(ready: any) {
type: 'warning',
}
)
.then(() => {
})
setTimeout(() => {
ElMessageBox.close()
}, 5000)
}
}
//

View File

@ -126,7 +126,7 @@ function tonstatus(ready: any) {
function readyto(ready: any) {
if (ready) {
ElMessageBox.confirm(
'项目扫描成功',
'文件备份成功',
'提示',
{
confirmButtonText: '确定',
@ -134,9 +134,9 @@ function readyto(ready: any) {
type: 'warning',
}
)
.then(() => {
})
setTimeout(() => {
ElMessageBox.close()
}, 5000)
}
}
////