异步执行完成自动关闭

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

View File

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

View File

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