可基本执行任务
This commit is contained in:
+82
-5
@@ -10,11 +10,22 @@ createApp({
|
||||
progress: 0,
|
||||
tasks: [],
|
||||
report: null,
|
||||
previewUrl: API + '/api/camera/preview',
|
||||
agvPreviewUrl: API + '/api/camera/preview',
|
||||
armPreviewUrl: API + '/api/camera/arm_refresh',
|
||||
polling: null,
|
||||
logs: [],
|
||||
showQrModal: false,
|
||||
qrValue: '',
|
||||
// 错误弹窗 / 单步执行
|
||||
waitingError: false,
|
||||
errorMsg: '',
|
||||
waitingStep: false,
|
||||
stepLabel: '',
|
||||
// 任务步骤控制开关(机械臂初始化并入AGV移动)
|
||||
agvMoveEnabled: true,
|
||||
qrScanEnabled: true,
|
||||
frontPhotoEnabled: true,
|
||||
backPhotoEnabled: true,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -24,7 +35,9 @@ createApp({
|
||||
running: '任务运行中',
|
||||
paused: '已暂停',
|
||||
completed: '已完成',
|
||||
waiting_qr: '等待输入二维码'
|
||||
waiting_qr: '等待输入二维码',
|
||||
waiting_error: '⚠️ 执行错误',
|
||||
waiting_step: '🦶 等待步骤确认',
|
||||
}
|
||||
return map[this.missionState] || '未知'
|
||||
},
|
||||
@@ -52,6 +65,22 @@ createApp({
|
||||
this.progress = data.progress || 0
|
||||
if (data.tasks) this.tasks = data.tasks
|
||||
|
||||
// 错误弹窗
|
||||
if (data.waiting_error) {
|
||||
this.waitingError = true
|
||||
this.errorMsg = data.error_msg || '任务执行出错'
|
||||
} else {
|
||||
this.waitingError = false
|
||||
}
|
||||
|
||||
// 步骤确认弹窗
|
||||
if (data.waiting_step) {
|
||||
this.waitingStep = true
|
||||
this.stepLabel = data.step_label || ''
|
||||
} else {
|
||||
this.waitingStep = false
|
||||
}
|
||||
|
||||
// QR 弹窗
|
||||
if (this.missionState === 'waiting_qr' && !this.showQrModal) {
|
||||
this.showQrModal = true
|
||||
@@ -67,7 +96,7 @@ createApp({
|
||||
} catch (e) {}
|
||||
},
|
||||
async pollLogs() {
|
||||
if (this.missionState !== 'running' && this.missionState !== 'waiting_qr') return
|
||||
if (this.missionState !== 'running' && this.missionState !== 'waiting_qr' && this.missionState !== 'waiting_error' && this.missionState !== 'waiting_step') return
|
||||
try {
|
||||
const res = await fetch(API + '/api/mission/log')
|
||||
const data = await res.json()
|
||||
@@ -87,9 +116,52 @@ createApp({
|
||||
this.progress = 0
|
||||
this.report = null
|
||||
this.showQrModal = false
|
||||
await fetch(API + '/api/mission/start', { method: 'POST' })
|
||||
await fetch(API + '/api/mission/start', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
agv_move: this.agvMoveEnabled,
|
||||
qr_scan: this.qrScanEnabled,
|
||||
front_photo: this.frontPhotoEnabled,
|
||||
back_photo: this.backPhotoEnabled,
|
||||
})
|
||||
})
|
||||
this.missionState = 'running'
|
||||
},
|
||||
async startSingleStep() {
|
||||
if (this.missionState !== 'idle') return
|
||||
this.logs = []
|
||||
this.progress = 0
|
||||
this.report = null
|
||||
this.showQrModal = false
|
||||
await fetch(API + '/api/mission/start', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ single_step: true })
|
||||
})
|
||||
if (this.polling) clearInterval(this.polling)
|
||||
this.poll()
|
||||
},
|
||||
async skipError() {
|
||||
await fetch(API + '/api/mission/error-skip', { method: 'POST' })
|
||||
this.waitingError = false
|
||||
},
|
||||
async abortError() {
|
||||
await fetch(API + '/api/mission/error-abort', { method: 'POST' })
|
||||
this.waitingError = false
|
||||
},
|
||||
async confirmStep() {
|
||||
await fetch(API + '/api/mission/singlestep/confirm', { method: 'POST' })
|
||||
this.waitingStep = false
|
||||
},
|
||||
async retryStep() {
|
||||
await fetch(API + '/api/mission/singlestep/retry', { method: 'POST' })
|
||||
this.waitingStep = false
|
||||
},
|
||||
async abortStep() {
|
||||
await fetch(API + '/api/mission/singlestep/abort', { method: 'POST' })
|
||||
this.waitingStep = false
|
||||
},
|
||||
async pauseMission() {
|
||||
await fetch(API + '/api/mission/pause', { method: 'POST' })
|
||||
this.missionState = 'paused'
|
||||
@@ -103,6 +175,8 @@ createApp({
|
||||
await fetch(API + '/api/mission/stop', { method: 'POST' })
|
||||
this.missionState = 'idle'
|
||||
this.showQrModal = false
|
||||
this.waitingError = false
|
||||
this.waitingStep = false
|
||||
},
|
||||
async submitQr() {
|
||||
const val = this.qrValue.trim()
|
||||
@@ -123,7 +197,10 @@ createApp({
|
||||
body: JSON.stringify({ qr: 'SKIP' })
|
||||
})
|
||||
},
|
||||
onPreviewError(e) {
|
||||
onAgvPreviewError(e) {
|
||||
e.target.style.display = 'none'
|
||||
},
|
||||
onArmPreviewError(e) {
|
||||
e.target.style.display = 'none'
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user